MCPcopy
hub / github.com/pterm/pterm / GetStringMaxWidth

Function GetStringMaxWidth

internal/max_text_width.go:10–21  ·  view source on GitHub ↗

GetStringMaxWidth returns the maximum width of a string with multiple lines.

(s string)

Source from the content-addressed store, hash-verified

8
9// GetStringMaxWidth returns the maximum width of a string with multiple lines.
10func 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}

Callers 14

SprintMethod · 0.92
SrenderMethod · 0.92
renderRowMethod · 0.92
SrenderMethod · 0.92
renderColorfulMethod · 0.92
SrenderMethod · 0.92
ShowMethod · 0.92
updateAreaMethod · 0.92
SrenderMethod · 0.92
SrenderMethod · 0.92
AddTitleToLineFunction · 0.85
AddTitleToLineCenterFunction · 0.85

Calls 1

RemoveEscapeCodesFunction · 0.85

Tested by 1

TestGetStringMaxWidthFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…