charWidth returns the visible width of a string, treating zero-width results as width 1 so that box calculations always make progress.
(s string)
| 79 | // charWidth returns the visible width of a string, treating zero-width |
| 80 | // results as width 1 so that box calculations always make progress. |
| 81 | func charWidth(s string) int { |
| 82 | w := runewidth.StringWidth(ansi.Strip(s)) |
| 83 | if w == 0 { |
| 84 | w = 1 |
| 85 | } |
| 86 | return w |
| 87 | } |
| 88 | |
| 89 | // buildSegment builds a horizontal segment with the given visual width using |
| 90 | // the provided fill glyph, padding with spaces if needed to match width. |
no outgoing calls