New returns a new SegmentDisplay.
(opts ...Option)
| 69 | |
| 70 | // New returns a new SegmentDisplay. |
| 71 | func New(opts ...Option) (*SegmentDisplay, error) { |
| 72 | opt := newOptions() |
| 73 | for _, o := range opts { |
| 74 | o.set(opt) |
| 75 | } |
| 76 | if err := opt.validate(); err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | |
| 80 | dotChars := map[rune]bool{} |
| 81 | for _, r := range dotseg.SupportedChars() { |
| 82 | dotChars[r] = true |
| 83 | } |
| 84 | return &SegmentDisplay{ |
| 85 | wOptsTracker: attrrange.NewTracker(), |
| 86 | opts: opt, |
| 87 | dotChars: dotChars, |
| 88 | }, nil |
| 89 | } |
| 90 | |
| 91 | // TextChunk is a part of or the full text that will be displayed. |
| 92 | type TextChunk struct { |