MCPcopy Create free account
hub / github.com/codeaashu/claude-code / applySGR

Function applySGR

src/ink/termio/sgr.ts:127–308  ·  view source on GitHub ↗
(paramStr: string, style: TextStyle)

Source from the content-addressed store, hash-verified

125}
126
127export function applySGR(paramStr: string, style: TextStyle): TextStyle {
128 const params = parseParams(paramStr)
129 let s = { ...style }
130 let i = 0
131
132 while (i < params.length) {
133 const p = params[i]!
134 const code = p.value ?? 0
135
136 if (code === 0) {
137 s = defaultStyle()
138 i++
139 continue
140 }
141 if (code === 1) {
142 s.bold = true
143 i++
144 continue
145 }
146 if (code === 2) {
147 s.dim = true
148 i++
149 continue
150 }
151 if (code === 3) {
152 s.italic = true
153 i++
154 continue
155 }
156 if (code === 4) {
157 s.underline = p.colon
158 ? (UNDERLINE_STYLES[p.subparams[0]!] ?? 'single')
159 : 'single'
160 i++
161 continue
162 }
163 if (code === 5 || code === 6) {
164 s.blink = true
165 i++
166 continue
167 }
168 if (code === 7) {
169 s.inverse = true
170 i++
171 continue
172 }
173 if (code === 8) {
174 s.hidden = true
175 i++
176 continue
177 }
178 if (code === 9) {
179 s.strikethrough = true
180 i++
181 continue
182 }
183 if (code === 21) {
184 s.underline = 'double'

Callers 1

processSequenceMethod · 0.85

Calls 3

parseParamsFunction · 0.85
parseExtendedColorFunction · 0.85
defaultStyleFunction · 0.70

Tested by

no test coverage detected