diff --git a/.gitignore b/.gitignore index 6f72f89..d75edd7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ go.work.sum # env file .env + +# macOS +.DS_Store \ No newline at end of file diff --git a/utils.go b/utils.go index db7c22f..25ae125 100644 --- a/utils.go +++ b/utils.go @@ -14,30 +14,16 @@ import ( ) func renderLine(frameLine, line string, x int) string { - result := []rune(frameLine) // Convert frameLine to a slice of runes for mutability - visibleCount := 0 // Track visible characters in frameLine + result := []rune(frameLine) + lineRunes := []rune(line) + frameLen := len(result) + lineLen := len(lineRunes) - for _, c := range line { - // Skip over non-visible characters when counting the frameLine length - 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 - 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 + for i := 0; i < lineLen && x+i < frameLen; i++ { + result[x+i] = lineRunes[i] } - return string(result) // Convert the result back to a string + return string(result) } func RenderOnFrame(c Component, frame *[]string) {