From: Nicolas Boisselier Date: Thu, 29 Aug 2024 00:28:38 +0000 (+0200) Subject: lib/php/out.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a0efd56ebe97d9122636b07156b1fce3f3cd5faa;p=nb.git lib/php/out.php --- diff --git a/bin/dbq-vi b/bin/dbq-vi index 1666b0e3..23b253f0 100755 --- a/bin/dbq-vi +++ b/bin/dbq-vi @@ -5,7 +5,7 @@ main() { #exec echo $tmp dbq.php "$1/vi/$2.sh" > "$tmp" || return - perl -i -pe 's/(\w+=".*?") /$1\n/g; s/;\s*$// ' "$tmp" + perl -i -pe 's/(\w+=".*?") /$1\n/g; s/;\s*$/\n/ ' "$tmp" md5=$(md5sum "$tmp") @@ -13,9 +13,9 @@ main() { [ -s "$tmp" ] || return [ "$md5" == "$(md5sum "$tmp")" ] && return bash -f "$tmp" || return - #exec echo $md5 + #echo $md5 " == $(md5sum "$tmp")" - eval dbq.php $1/update/ $(cat "$tmp") + eval "dbq.php $1/update/ $(cat "$tmp")" | csv2human } diff --git a/lib/php/out.php b/lib/php/out.php index cd89724d..cc3ae286 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -581,17 +581,70 @@ Class Out extends Nb { } public static function out_human_end(&$o) { +/* +my $format = "│ ".join(" │ ",map {$t+=$_+3; "\%-".$_."s"} @len)." │".chr(10); +my $sep_line_first = "┌".join("┬",map {("─"x($_+2))} @len)."┐".chr(10); +my $sep_line = "├".join("┼",map {("─"x($_+2))} @len)."┤".chr(10); +my $sep_line_last = "└".join("┴",map {("─"x($_+2))} @len)."┘".chr(10); +*/ $len = $o['_human']['len']; fseek($o['_human']['tmpfile'], 0); + $sep = $o['_human']['sep']; + $sep_top = (isset($o['sep_top']) ? $o['sep_top'] : $sep); + $sep_bottom = (isset($o['sep_bottom']) ? $o['sep_bottom'] : $sep); + $sep_line = ''; + $sep_line_top = ''; + $sep_line_bottom = ''; if (self::p('sep_line') !== '0') { + $count = 0; foreach ($len as $i) { - $sep_line .= $o['corner'].str_repeat($o['line'],$i+strlen($o['_human']['sep'])-1); + # NB 29.08.24 $sep = $o['_human']['sep']; + # NB 29.08.24 if ($count == 0) $sep = $sep_top; + # NB 29.08.24 if ($count == count($len)) $sep = $sep_bottom; + + /* + if ($count == 0) { + $sep_line_top .= + ( (isset($o['corner_left_top'])) ? $o['corner_left_top'] : $o['corner']) + .str_repeat($o['line'],$i+mb_strlen($sep)-1) + ; + } else { + $sep_line_top .= $sep_top.str_repeat($o['line'],$i+mb_strlen($sep)-1); + } + */ + $sep_line_top .= + ( ($count == 0 and isset($o['corner_left_top'])) ? $o['corner_left_top'] : $o['corner']) + .str_repeat($o['line'],$i+mb_strlen($sep_top)-1) + ; + $sep_line .= + (($count == 0 and isset($o['corner_left'])) ? $o['corner_left'] : $o['corner']) + .str_repeat($o['line'],$i+mb_strlen($sep)-1) + ; + $sep_line_bottom .= + ( ($count == 0 and isset($o['corner_left_bottom'])) ? $o['corner_left_bottom'] : $o['corner']) + .str_repeat($o['line'],$i+mb_strlen($sep_bottom)-1) + ; + $count++; } - $sep_line .= $o['corner'].$o['_human']['eol']; + + $sep_line_top .= + (isset($o['corner_right_top']) ? $o['corner_right_top'] : $o['corner']) + .$o['_human']['eol'] + ; + $sep_line .= + (isset($o['corner_right']) ? $o['corner_right'] : $o['corner']) + .$o['_human']['eol'] + ; + $sep_line_bottom .= + (isset($o['corner_right_bottom']) ? $o['corner_right_bottom'] : $o['corner']) + .$o['_human']['eol'] + ; + } + #bye($sep_line_top); $header = empty($o['_human']['head']) ? 0 : 1; $count = 0; @@ -605,12 +658,18 @@ Class Out extends Nb { } # header - if (!$count) echo $sep_line; + if (!$count) { + echo $sep_line_top; + } + + $sep = $o['_human']['sep']; + #if ($count == 0) $sep = $sep_top; + #if ($count == count($len)) $sep = $sep_bottom; echo '' - . ltrim($o['_human']['sep']) - . join($o['_human']['sep'],$values) - . rtrim($o['_human']['sep']) + . ltrim($sep) + . join($sep,$values) + . rtrim($sep) .$o['_human']['eol']; if ($header and !$count) echo $sep_line; @@ -623,7 +682,8 @@ Class Out extends Nb { if ($header) $count--; if (!$count) return; - echo $sep_line; + echo $sep_line_bottom; + #if ($o['corner_left_bottom']) if ($header) echo "$count Records\n"; } diff --git a/lib/php/out/human.php b/lib/php/out/human.php index 7bb002b7..ba268855 100644 --- a/lib/php/out/human.php +++ b/lib/php/out/human.php @@ -1,10 +1,18 @@ self::p('sep'," | "), - 'corner' => self::p('corner',"+"), + 'sep' => self::p('sep'," │ "), + 'sep_top' => self::p('sep_top'," ┬ "), + 'sep_bottom' => self::p('sep_bottom'," ┴ "), + 'corner' => self::p('corner',"┼"), + 'corner_left_top' => self::p('corner_left_top',"┌"), + 'corner_right_top' => self::p('corner_right_top',"┐"), + 'corner_left' => self::p('corner_left',"├"), + 'corner_right' => self::p('corner_right',"┤"), + 'corner_left_bottom' => self::p('corner_left_bottom',"└"), + 'corner_right_bottom' => self::p('corner_right_bottom',"┘"), 'eol' => self::p('eol',"\n"), - 'line' => self::p('line',"-"), + 'line' => self::p('line',"─"), 'head' => 'out_human_head', 'row' => 'out_human', 'end' => 'out_human_end',