mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-11 16:01:28 +00:00
feat(tui_layout.sh): identify line break "\n"
This commit is contained in:
@@ -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 {}
|
||||
'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user