renderLine fine length
This commit is contained in:
@@ -13,19 +13,53 @@ import (
|
|||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
func renderLine(frameLine, line string, x int) string {
|
// NOTE: for now keep this code in case of needing it later
|
||||||
|
|
||||||
|
// func renderLine(frameLine, line string, x int) string {
|
||||||
|
// result := []rune(frameLine)
|
||||||
|
// lineRunes := []rune(line)
|
||||||
|
// x += strings.Count(string(result[:(x+1)]), "\t") + strings.Count(string(result[:(x+1)]), "\b")
|
||||||
|
|
||||||
|
// for range strings.Count(line, "\t") + strings.Count(line, "\b") {
|
||||||
|
// result = append(result, ' ')
|
||||||
|
// }
|
||||||
|
|
||||||
|
// frameLen := len(result)
|
||||||
|
|
||||||
|
// for i := 0; i < len(lineRunes) && x+i < frameLen; i++ {
|
||||||
|
// result[x+i] = lineRunes[i]
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return string(result)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// lineRunes := []rune(line)
|
||||||
|
// x += strings.Count(string(frameLine[:(x+1)]), "\b")
|
||||||
|
// result = append(result, []rune(strings.Repeat(" ", strings.Count(line, "\t")))...)
|
||||||
|
// frameLen := len(result)
|
||||||
|
// d := strings.Count(frameLine, "\b") - strings.Count(string(result), "\b")
|
||||||
|
// for i := 0; i < len(lineRunes) && x+i < frameLen; i++ {
|
||||||
|
// result[x+i] = lineRunes[i]
|
||||||
|
// }
|
||||||
|
// NOTE: for now keep this code in case of needing it later
|
||||||
|
|
||||||
|
func renderLine(frameLine, line_ string, x int) string {
|
||||||
result := []rune(frameLine)
|
result := []rune(frameLine)
|
||||||
lineRunes := []rune(line)
|
line := []rune(line_)
|
||||||
x += strings.Count(string(result[:(x+1)]), "\t") + strings.Count(string(result[:(x+1)]), "\b")
|
|
||||||
|
|
||||||
for range strings.Count(line, "\t") + strings.Count(line, "\b") {
|
i := 0
|
||||||
result = append(result, ' ')
|
v := 0
|
||||||
}
|
for _, c := range result {
|
||||||
|
if i >= x && v < len(line) {
|
||||||
frameLen := len(result)
|
if c != '\b' && line[v] == '\t' {
|
||||||
|
result = append(result, ' ')
|
||||||
for i := 0; i < len(lineRunes) && x+i < frameLen; i++ {
|
}
|
||||||
result[x+i] = lineRunes[i]
|
result[i] = line[v]
|
||||||
|
v++
|
||||||
|
}
|
||||||
|
if c != '\b' {
|
||||||
|
i++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(result)
|
return string(result)
|
||||||
|
|||||||
Reference in New Issue
Block a user