smarter ansi_error

This commit is contained in:
pvincent
2026-07-21 11:33:25 +04:00
parent ef95f5cce8
commit 0a5e0cdce4
4 changed files with 105 additions and 39 deletions
+14 -5
View File
@@ -4,6 +4,9 @@
PADDING=0
ANSI_RESET='\e[0m'
BLOCK_CONTINUATION_COL=
BLOCK_CONTINUATION_SYMBOL=
declare -A STYLE_VARIANTS
STYLE_VARIANTS[BOLD]='\e[1m'
STYLE_VARIANTS[ITALIC]='\e[3m'
@@ -88,7 +91,7 @@ function style_ansi {
}
function style_block {
local content length top bottom
local content length top bottom i
content=$(style_padding "$1")
length=$(ansi_length "$content")
@@ -97,16 +100,22 @@ function style_block {
for _ in $(seq 1 "${length}"); do builtin echo -n '═'; done
builtin echo "╗"
)
style_ansi "${top}" && echo
style_ansi "${top}" && builtin echo
style_ansi "║"
style_ansi "${content}"
style_ansi "║" && echo
style_ansi "║" && builtin echo
bottom=$(
builtin echo -n "╚"
for _ in $(seq 1 "${length}"); do builtin echo -n '═'; done
for i in $(seq 1 "${length}"); do
if [[ $i == "$BLOCK_CONTINUATION_COL" ]]; then
builtin echo -n "$BLOCK_CONTINUATION_SYMBOL"
else
builtin echo -n '═'
fi
done
builtin echo "╝"
)
style_ansi "${bottom}" && echo
style_ansi "${bottom}" && builtin echo
}