MCPcopy Create free account
hub / github.com/github/gh-aw / skipCSISequence

Function skipCSISequence

pkg/stringutil/ansi.go:76–88  ·  view source on GitHub ↗

skipCSISequence advances past a CSI sequence (\x1b[...final_char). Parameters are in range 0x30-0x3F, intermediate chars 0x20-0x2F, final 0x40-0x7E.

(s string, i int)

Source from the content-addressed store, hash-verified

74// skipCSISequence advances past a CSI sequence (\x1b[...final_char).
75// Parameters are in range 0x30-0x3F, intermediate chars 0x20-0x2F, final 0x40-0x7E.
76func skipCSISequence(s string, i int) int {
77 i += 2 // Skip ESC and [
78 for i < len(s) {
79 if isFinalCSIChar(s[i]) {
80 return i + 1 // Skip the final character
81 } else if isCSIParameterChar(s[i]) {
82 i++ // Skip parameter/intermediate character
83 } else {
84 break // Invalid character, stop
85 }
86 }
87 return i
88}
89
90// skipOSCSequence advances past an OSC sequence (\x1b]...terminator).
91// Terminators: \x07 (BEL) or \x1b\\ (ST).

Callers 1

skipEscapeSequenceFunction · 0.85

Calls 2

isFinalCSICharFunction · 0.85
isCSIParameterCharFunction · 0.85

Tested by

no test coverage detected