fix bug but now new bug hehe
fixed the bug where the "some text here" example would have spaces inserted inside when typing in a textbox
This commit is contained in:
@@ -23,3 +23,6 @@ go.work.sum
|
|||||||
|
|
||||||
# env file
|
# env file
|
||||||
.env
|
.env
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
@@ -14,30 +14,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func renderLine(frameLine, line string, x int) string {
|
func renderLine(frameLine, line string, x int) string {
|
||||||
result := []rune(frameLine) // Convert frameLine to a slice of runes for mutability
|
result := []rune(frameLine)
|
||||||
visibleCount := 0 // Track visible characters in frameLine
|
lineRunes := []rune(line)
|
||||||
|
frameLen := len(result)
|
||||||
|
lineLen := len(lineRunes)
|
||||||
|
|
||||||
for _, c := range line {
|
for i := 0; i < lineLen && x+i < frameLen; i++ {
|
||||||
// Skip over non-visible characters when counting the frameLine length
|
result[x+i] = lineRunes[i]
|
||||||
for visibleCount < len(result) {
|
|
||||||
if result[visibleCount] == '\t' || result[visibleCount] == '\b' {
|
|
||||||
visibleCount++ // Skip these characters without counting them
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If visibleCount exceeds the length of frameLine, stop
|
return string(result)
|
||||||
if x+visibleCount >= len(result) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overlay the character from the line onto frameLine at the correct position
|
|
||||||
result[x+visibleCount] = c
|
|
||||||
visibleCount++ // Increment visible character count
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(result) // Convert the result back to a string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RenderOnFrame(c Component, frame *[]string) {
|
func RenderOnFrame(c Component, frame *[]string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user