MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseTabStatus

Function parseTabStatus

src/ink/termio/osc.ts:350–366  ·  view source on GitHub ↗

* Parse OSC 21337 payload: `key=value;key=value;...` with `\;` and `\\` * escapes inside values. Bare key or `key=` clears that field; unknown * keys are ignored.

(data: string)

Source from the content-addressed store, hash-verified

348 * keys are ignored.
349 */
350function parseTabStatus(data: string): TabStatusAction {
351 const action: TabStatusAction = {}
352 for (const [key, value] of splitTabStatusPairs(data)) {
353 switch (key) {
354 case 'indicator':
355 action.indicator = value === '' ? null : parseOscColor(value)
356 break
357 case 'status':
358 action.status = value === '' ? null : value
359 break
360 case 'status-color':
361 action.statusColor = value === '' ? null : parseOscColor(value)
362 break
363 }
364 }
365 return action
366}
367
368/** Split `k=v;k=v` honoring `\;` and `\\` escapes. Yields [key, unescapedValue]. */
369function* splitTabStatusPairs(data: string): Generator<[string, string]> {

Callers 1

parseOSCFunction · 0.85

Calls 2

splitTabStatusPairsFunction · 0.85
parseOscColorFunction · 0.85

Tested by

no test coverage detected