MCPcopy Create free account
hub / github.com/box-cli-maker/box-cli-maker / buildSegment

Function buildSegment

util.go:91–102  ·  view source on GitHub ↗

buildSegment builds a horizontal segment with the given visual width using the provided fill glyph, padding with spaces if needed to match width.

(fill string, width, horizontalWidth int)

Source from the content-addressed store, hash-verified

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.
91func buildSegment(fill string, width, horizontalWidth int) string {
92 if width <= 0 {
93 return ""
94 }
95 fillCount := width / horizontalWidth
96 seg := strings.Repeat(fill, fillCount)
97 padWidth := width - fillCount*horizontalWidth
98 if padWidth > 0 {
99 seg += strings.Repeat(" ", padWidth)
100 }
101 return seg
102}
103
104// buildPlainBar builds a horizontal bar (without title) that matches the
105// specified visual line width.

Callers 3

TestBuildSegmentFunction · 0.85
buildPlainBarFunction · 0.85
buildTitledBarFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestBuildSegmentFunction · 0.68