summaryrefslogtreecommitdiffstats
path: root/lib/remote/print.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2025-10-22 06:39:13 +0200
committerSuren A. Chilingaryan <csa@suren.me>2025-10-22 06:39:13 +0200
commit04ff3adccc48664c366b705ab9265c155633671d (patch)
treeb75b89e8fc5b8e833eb15cca59506e7b36acb554 /lib/remote/print.sh
parent9378edc09d4a0b9f19ef4314e0de7efa9634d849 (diff)
downloadconky-04ff3adccc48664c366b705ab9265c155633671d.tar.gz
conky-04ff3adccc48664c366b705ab9265c155633671d.tar.bz2
conky-04ff3adccc48664c366b705ab9265c155633671d.tar.xz
conky-04ff3adccc48664c366b705ab9265c155633671d.zip
Last adaption of configs and a few fixes to run on Ubuntu 24.04HEADmaster
Diffstat (limited to 'lib/remote/print.sh')
-rw-r--r--lib/remote/print.sh26
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 {