MCPcopy
hub / github.com/docker/compose / lenAnsi

Function lenAnsi

cmd/display/tty.go:677–694  ·  view source on GitHub ↗

lenAnsi count of user-perceived characters in ANSI string.

(s string)

Source from the content-addressed store, hash-verified

675
676// lenAnsi count of user-perceived characters in ANSI string.
677func lenAnsi(s string) int {
678 length := 0
679 ansiCode := false
680 for _, r := range s {
681 if r == '\x1b' {
682 ansiCode = true
683 continue
684 }
685 if ansiCode && r == 'm' {
686 ansiCode = false
687 continue
688 }
689 if !ansiCode {
690 length++
691 }
692 }
693 return length
694}
695
696var percentChars = strings.Split("⠀⡀⣀⣄⣤⣦⣶⣷⣿", "")

Calls

no outgoing calls