MCPcopy Index your code
hub / github.com/docker/cli / charWidth

Function charWidth

cli/command/formatter/displayutils.go:20–29  ·  view source on GitHub ↗

charWidth returns the number of horizontal positions a character occupies, and is used to account for wide characters when displaying strings. In a broad sense, wide characters include East Asian Wide, East Asian Full-width, (when not in East Asian context) see http://unicode.org/reports/tr11/.

(r rune)

Source from the content-addressed store, hash-verified

18// In a broad sense, wide characters include East Asian Wide, East Asian Full-width,
19// (when not in East Asian context) see http://unicode.org/reports/tr11/.
20func charWidth(r rune) int {
21 switch width.LookupRune(r).Kind() {
22 case width.EastAsianWide, width.EastAsianFullwidth:
23 return 2
24 case width.Neutral, width.EastAsianAmbiguous, width.EastAsianNarrow, width.EastAsianHalfwidth:
25 return 1
26 default:
27 return 1
28 }
29}
30
31// TruncateID returns a shorthand version of a string identifier for presentation,
32// after trimming digest algorithm prefix (if any).

Callers 1

EllipsisFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…