From 358fd945f226ac8ca7a21e83ec22239dd2efdb31 Mon Sep 17 00:00:00 2001 From: Sofia <253282481+sofia-riese@users.noreply.github.com> Date: Fri, 23 Jan 2026 13:47:29 +0800 Subject: [PATCH] fix(tui_layout.sh): apply font color --- scripts/menus/tui_layout.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/menus/tui_layout.sh b/scripts/menus/tui_layout.sh index 8a44f335..42ca4247 100644 --- a/scripts/menus/tui_layout.sh +++ b/scripts/menus/tui_layout.sh @@ -29,15 +29,14 @@ content_line() { currentLine = "" wordBuffer = "" lastColor = "" + savedColor = "" ESC = sprintf("%c", 27) } { n = split($0, chars, "") - for (i = 1; i <= n; i++) { r = chars[i] - if (r == ESC && i+1 <= n && chars[i+1] == "[") { ansiSeq = "" for (j = i; j <= n; j++) { @@ -74,26 +73,28 @@ content_line() { if (r == " " || charWidth == 2) { if (currentDisplayWidth + wordWidth + charWidth > textWidth) { printf " %s\033[0m\033[%dG||\n", currentLine, table_width - currentLine = lastColor wordBuffer + currentLine = savedColor wordBuffer currentDisplayWidth = wordWidth wordBuffer = r wordWidth = charWidth + savedColor = lastColor } else { currentLine = currentLine wordBuffer r currentDisplayWidth += wordWidth + charWidth wordBuffer = "" wordWidth = 0 + savedColor = lastColor } } else { wordBuffer = wordBuffer r wordWidth += charWidth - if (wordWidth > textWidth) { printf " %s%s\033[0m\033[%dG||\n", currentLine, wordBuffer, table_width - currentLine = lastColor + currentLine = savedColor currentDisplayWidth = 0 wordBuffer = "" wordWidth = 0 + savedColor = lastColor } } } @@ -103,7 +104,7 @@ content_line() { if (wordWidth > 0) { if (currentDisplayWidth + wordWidth > textWidth) { printf " %s\033[0m\033[%dG||\n", currentLine, table_width - currentLine = lastColor wordBuffer + currentLine = savedColor wordBuffer } else { currentLine = currentLine wordBuffer }