diff options
Diffstat (limited to 'lib/remote/print.sh')
| -rw-r--r-- | lib/remote/print.sh | 26 | 
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/remote/print.sh b/lib/remote/print.sh index a0fdcbe..ef9c9b8 100644 --- a/lib/remote/print.sh +++ b/lib/remote/print.sh @@ -130,9 +130,33 @@ function print_hline {      echo | eol  } +acolumn() { +  local sep="$1" out="$2" +  awk -v FS="$sep" -v SEP="$out" -v OFS='' ' +    function strip(s) { gsub(/\x1B\[[0-9;?]*[ -/]*[@-~]/, "", s); return s } +    { +      rows[NR] = $0 +      if (NF > cols) cols = NF +      for (i = 1; i <= NF; i++) +        if (length(strip($i)) > w[i]) w[i] = length(strip($i)) +    } +    END { +      for (r = 1; r <= NR; r++) { +        n = split(rows[r], a, FS) +        for (i = 1; i <= n; i++) { +          pad = w[i] - length(strip(a[i])) +          printf "%s%*s", a[i], (i < n ? pad : 0), "" +          if (i < n) printf "%s", SEP +        } +        print "" +      } +    }' +} +  function print_table {      # The problem here is that all escapes for colors are treated as normal visible symbols -    sed "s/ ::: /@/g" | column -t -s "@" -o "    " | eol +#    sed "s/ ::: /@/g" | column -t -s "@" -o "x    x" --output-width 0 | eol +    sed "s/ ::: /@/g" | acolumn "@" "    " | eol  }  function decorate_table {  | 
