MCPcopy
hub / github.com/mum4k/termdash / SegmentDisplay

Struct SegmentDisplay

widgets/segmentdisplay/segmentdisplay.go:46–68  ·  view source on GitHub ↗

SegmentDisplay displays ASCII content by simulating a segment display. Automatically determines the size of individual segments with goal of maximizing the segment size or with fitting the entire text depending on the provided options. Segment displays support only a subset of ASCII characters, pr

Source from the content-addressed store, hash-verified

44//
45// Implements widgetapi.Widget. This object is thread-safe.
46type SegmentDisplay struct {
47 // buff contains the text to be displayed.
48 buff strings.Builder
49
50 // givenWOpts are write options given for the text in buff.
51 givenWOpts []*writeOptions
52 // wOptsTracker tracks the positions in a buff to which the givenWOpts apply.
53 wOptsTracker *attrrange.Tracker
54
55 // lastCanFit is the number of segments that could fit the area the last
56 // time Draw was called.
57 lastCanFit int
58
59 // dotChars are characters that are drawn using the dot segment.
60 // All other characters are draws using the 16-segment display.
61 dotChars map[rune]bool
62
63 // mu protects the widget.
64 mu sync.Mutex
65
66 // opts are the provided options.
67 opts *options
68}
69
70// New returns a new SegmentDisplay.
71func New(opts ...Option) (*SegmentDisplay, error) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected