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

Function describeSGR

cmd/wsh/cmd/wshcmd-debugterm.go:384–424  ·  view source on GitHub ↗
(params string)

Source from the content-addressed store, hash-verified

382}
383
384func describeSGR(params string) string {
385 if params == "" {
386 return "reset all"
387 }
388 parts := strings.Split(params, ";")
389 if len(parts) >= 5 && parts[0] == "38" && parts[1] == "2" {
390 return fmt.Sprintf("fg rgb(%s,%s,%s)", parts[2], parts[3], parts[4])
391 }
392 if len(parts) >= 5 && parts[0] == "48" && parts[1] == "2" {
393 return fmt.Sprintf("bg rgb(%s,%s,%s)", parts[2], parts[3], parts[4])
394 }
395 if len(parts) == 3 && parts[0] == "38" && parts[1] == "5" {
396 return fmt.Sprintf("fg color256(%s)", parts[2])
397 }
398 if len(parts) == 3 && parts[0] == "48" && parts[1] == "5" {
399 return fmt.Sprintf("bg color256(%s)", parts[2])
400 }
401 if len(parts) != 1 {
402 return ""
403 }
404 n, err := strconv.Atoi(parts[0])
405 if err != nil {
406 return ""
407 }
408 if desc, ok := sgrSingleDescriptions[n]; ok {
409 return desc
410 }
411 if n >= 30 && n <= 37 {
412 return fmt.Sprintf("fg ansi color %d", n-30)
413 }
414 if n >= 40 && n <= 47 {
415 return fmt.Sprintf("bg ansi color %d", n-40)
416 }
417 if n >= 90 && n <= 97 {
418 return fmt.Sprintf("fg bright color %d", n-90)
419 }
420 if n >= 100 && n <= 107 {
421 return fmt.Sprintf("bg bright color %d", n-100)
422 }
423 return ""
424}
425
426func formatDebugTermCSILine(seq []byte) string {
427 // seq is the full sequence starting with ESC [

Callers 1

formatDebugTermCSILineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected