mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-03-12 16:31:25 +00:00
feat(tui_layout.sh): identify line break "\n"
This commit is contained in:
@@ -52,10 +52,7 @@ content_line() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
charWidth = 1
|
charWidth = 1
|
||||||
|
if (r <= "\177") { charWidth = 1 }
|
||||||
if (r <= "\177") {
|
|
||||||
charWidth = 1
|
|
||||||
}
|
|
||||||
else if (r >= "\340" && r <= "\357" && i+2 <= n) {
|
else if (r >= "\340" && r <= "\357" && i+2 <= n) {
|
||||||
r = chars[i] chars[i+1] chars[i+2]
|
r = chars[i] chars[i+1] chars[i+2]
|
||||||
i += 2
|
i += 2
|
||||||
@@ -66,9 +63,6 @@ content_line() {
|
|||||||
i += 1
|
i += 1
|
||||||
charWidth = 1
|
charWidth = 1
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
charWidth = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r == " " || charWidth == 2) {
|
if (r == " " || charWidth == 2) {
|
||||||
if (currentDisplayWidth + wordWidth + charWidth > textWidth) {
|
if (currentDisplayWidth + wordWidth + charWidth > textWidth) {
|
||||||
@@ -98,9 +92,7 @@ content_line() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
if (wordWidth > 0) {
|
if (wordWidth > 0) {
|
||||||
if (currentDisplayWidth + wordWidth > textWidth) {
|
if (currentDisplayWidth + wordWidth > textWidth) {
|
||||||
printf " %s\033[0m\033[%dG||\n", currentLine, table_width
|
printf " %s\033[0m\033[%dG||\n", currentLine, table_width
|
||||||
@@ -110,14 +102,15 @@ content_line() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanText = currentLine
|
printf " %s\033[0m\033[%dG||\n", currentLine, table_width
|
||||||
gsub(/\033\[[0-9;]*m/, "", cleanText)
|
|
||||||
gsub(/^[ \t]+|[ \t]+$/, "", cleanText)
|
|
||||||
|
|
||||||
if (cleanText != "") {
|
currentLine = lastColor
|
||||||
printf " %s\033[0m\033[%dG||\n", currentLine, table_width
|
currentDisplayWidth = 0
|
||||||
}
|
wordBuffer = ""
|
||||||
|
wordWidth = 0
|
||||||
|
savedColor = lastColor
|
||||||
}
|
}
|
||||||
|
END {}
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user