From fed0bfeb90212997d2900e120509095d082b1b1f Mon Sep 17 00:00:00 2001 From: Sofia <253282481+sofia-riese@users.noreply.github.com> Date: Fri, 23 Jan 2026 14:34:35 +0800 Subject: [PATCH] feat(tui_layout.sh): identify line break "\n" --- scripts/menus/tui_layout.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/scripts/menus/tui_layout.sh b/scripts/menus/tui_layout.sh index 42ca4247..5f3bcea3 100644 --- a/scripts/menus/tui_layout.sh +++ b/scripts/menus/tui_layout.sh @@ -52,10 +52,7 @@ content_line() { } charWidth = 1 - - if (r <= "\177") { - charWidth = 1 - } + if (r <= "\177") { charWidth = 1 } else if (r >= "\340" && r <= "\357" && i+2 <= n) { r = chars[i] chars[i+1] chars[i+2] i += 2 @@ -66,9 +63,6 @@ content_line() { i += 1 charWidth = 1 } - else { - charWidth = 1 - } if (r == " " || charWidth == 2) { if (currentDisplayWidth + wordWidth + charWidth > textWidth) { @@ -98,9 +92,7 @@ content_line() { } } } - } - END { if (wordWidth > 0) { if (currentDisplayWidth + wordWidth > textWidth) { printf " %s\033[0m\033[%dG||\n", currentLine, table_width @@ -110,14 +102,15 @@ content_line() { } } - cleanText = currentLine - gsub(/\033\[[0-9;]*m/, "", cleanText) - gsub(/^[ \t]+|[ \t]+$/, "", cleanText) + printf " %s\033[0m\033[%dG||\n", currentLine, table_width - if (cleanText != "") { - printf " %s\033[0m\033[%dG||\n", currentLine, table_width - } + currentLine = lastColor + currentDisplayWidth = 0 + wordBuffer = "" + wordWidth = 0 + savedColor = lastColor } + END {} ' }