MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / formatDebugTermCSILine

Function formatDebugTermCSILine

cmd/wsh/cmd/wshcmd-debugterm.go:426–465  ·  view source on GitHub ↗
(seq []byte)

Source from the content-addressed store, hash-verified

424}
425
426func formatDebugTermCSILine(seq []byte) string {
427 // seq is the full sequence starting with ESC [
428 if len(seq) < 3 {
429 return "CSI " + strconv.QuoteToASCII(string(seq))
430 }
431 inner := seq[2:]
432 finalByte := inner[len(inner)-1]
433 params := string(inner[:len(inner)-1])
434
435 // DEC private mode: params starts with "?" and final byte is 'h' (set) or 'l' (reset)
436 if strings.HasPrefix(params, "?") && (finalByte == 'h' || finalByte == 'l') {
437 modeStr := params[1:]
438 var line string
439 if finalByte == 'h' {
440 line = "DEC SET " + modeStr
441 } else {
442 line = "DEC RST " + modeStr
443 }
444 if desc, ok := decModeDescriptions[modeStr]; ok {
445 line += " // " + desc
446 }
447 return line
448 }
449
450 finalStr := string([]byte{finalByte})
451 var line string
452 if params == "" {
453 line = "CSI " + finalStr
454 } else {
455 line = "CSI " + finalStr + " " + params
456 }
457 if finalByte == 'm' {
458 if desc := describeSGR(params); desc != "" {
459 line += " // " + desc
460 }
461 } else if desc, ok := csiCommandDescriptions[finalByte]; ok {
462 line += " // " + desc
463 }
464 return line
465}
466
467func consumeDebugTermCSI(data []byte, start int) ([]byte, int) {
468 i := start + 2

Callers 1

formatDebugTermDecodeFunction · 0.85

Calls 1

describeSGRFunction · 0.85

Tested by

no test coverage detected