GetStringMaxWidth returns the maximum width of a string with multiple lines.
(s string)
| 8 | |
| 9 | // GetStringMaxWidth returns the maximum width of a string with multiple lines. |
| 10 | func GetStringMaxWidth(s string) int { |
| 11 | var maxString int |
| 12 | ss := strings.Split(s, "\n") |
| 13 | for _, s2 := range ss { |
| 14 | // Strip OSC 8 hyperlinks and color codes |
| 15 | s2WithoutEscapes := RemoveEscapeCodes(s2) |
| 16 | if runewidth.StringWidth(s2WithoutEscapes) > maxString { |
| 17 | maxString = runewidth.StringWidth(s2WithoutEscapes) |
| 18 | } |
| 19 | } |
| 20 | return maxString |
| 21 | } |
searching dependent graphs…