lenAnsi count of user-perceived characters in ANSI string.
(s string)
| 675 | |
| 676 | // lenAnsi count of user-perceived characters in ANSI string. |
| 677 | func 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 | |
| 696 | var percentChars = strings.Split("⠀⡀⣀⣄⣤⣦⣶⣷⣿", "") |
no outgoing calls