MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / wrapVisibleLine

Function wrapVisibleLine

ui/fullscreen_backend.go:1161–1199  ·  view source on GitHub ↗
(text string, width int)

Source from the content-addressed store, hash-verified

1159}
1160
1161func wrapVisibleLine(text string, width int) []string {
1162 if width <= 0 {
1163 return []string{text}
1164 }
1165 var lines []string
1166 var current strings.Builder
1167 currentWidth := 0
1168 inEscape := false
1169 inCSI := false
1170 for _, r := range text {
1171 if inEscape {
1172 current.WriteRune(r)
1173 if r == '[' && !inCSI {
1174 inCSI = true
1175 continue
1176 }
1177 if !inCSI || (r >= '@' && r <= '~') {
1178 inEscape = false
1179 inCSI = false
1180 }
1181 continue
1182 }
1183 if r == '\x1b' {
1184 inEscape = true
1185 current.WriteRune(r)
1186 continue
1187 }
1188 runeWidth := runewidth.RuneWidth(r)
1189 if currentWidth > 0 && currentWidth+runeWidth > width {
1190 lines = append(lines, current.String())
1191 current.Reset()
1192 currentWidth = 0
1193 }
1194 current.WriteRune(r)
1195 currentWidth += runeWidth
1196 }
1197 lines = append(lines, current.String())
1198 return lines
1199}
1200
1201func splitNonEmptyViewportLines(text string) []string {
1202 if text == "" {

Callers 1

wrapVisibleLinesFunction · 0.85

Calls 2

StringMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected