Documentation ¶
Overview ¶
Package segmentdisplay is a widget that displays text by simulating a segment display.
Index ¶
- Constants
- type Option
- type SegmentDisplay
- func (sd *SegmentDisplay) Draw(cvs *canvas.Canvas) error
- func (*SegmentDisplay) Keyboard(k *terminalapi.Keyboard) error
- func (*SegmentDisplay) Mouse(m *terminalapi.Mouse) error
- func (sd *SegmentDisplay) Options() widgetapi.Options
- func (sd *SegmentDisplay) Reset()
- func (sd *SegmentDisplay) Write(chunks []*TextChunk, opts ...Option) error
- type TextChunk
- type WriteOption
Constants ¶
const DefaultGapPercent = 20
DefaultGapPercent is the default value for the GapPercent option.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
func AlignHorizontal ¶
func AlignHorizontal(h align.Horizontal) Option
AlignHorizontal sets the horizontal alignment for the individual display segments. Defaults to alignment in the center.
func AlignVertical ¶
AlignVertical sets the vertical alignment for the individual display segments. Defaults to alignment in the middle
func GapPercent ¶
GapPercent sets the size of the horizontal gap between individual segments (characters) expressed as a percentage of the segment height.
func MaximizeDisplayedText ¶
func MaximizeDisplayedText() Option
MaximizeDisplayedText tells the widget to maximize the amount of characters that are displayed. When this option is set and the user has provided more text than we can fit on the canvas, the widget will prefer to decrease the height of individual characters and fit more of them on the canvas. This is the default behavior.
func MaximizeSegmentHeight ¶
func MaximizeSegmentHeight() Option
MaximizeSegmentHeight tells the widget to maximize the height of the individual display segments. When this option is set and the user has provided more text than we can fit on the canvas, the widget will prefer to maximize height of individual characters which will result in earlier trimming of the text.
type SegmentDisplay ¶
type SegmentDisplay struct {
// contains filtered or unexported fields
}
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, provided options determine the behavior when an unsupported character is encountered.
Implements widgetapi.Widget. This object is thread-safe.
func (*SegmentDisplay) Draw ¶
func (sd *SegmentDisplay) Draw(cvs *canvas.Canvas) error
Draw draws the SegmentDisplay widget onto the canvas. Implements widgetapi.Widget.Draw.
func (*SegmentDisplay) Keyboard ¶
func (*SegmentDisplay) Keyboard(k *terminalapi.Keyboard) error
Keyboard input isn't supported on the SegmentDisplay widget.
func (*SegmentDisplay) Mouse ¶
func (*SegmentDisplay) Mouse(m *terminalapi.Mouse) error
Mouse input isn't supported on the SegmentDisplay widget.
func (*SegmentDisplay) Options ¶
func (sd *SegmentDisplay) Options() widgetapi.Options
Options implements widgetapi.Widget.Options.
func (*SegmentDisplay) Reset ¶
func (sd *SegmentDisplay) Reset()
Reset resets the widget back to empty content.
func (*SegmentDisplay) Write ¶
func (sd *SegmentDisplay) Write(chunks []*TextChunk, opts ...Option) error
Write writes text for the widget to display. Subsequent calls replace text written previously. All the provided text chunks are broken into characters and each character is displayed in one segment.
The provided write options determine the behavior when text contains unsupported characters and set cell options for cells that contain individual display segments.
Each of the text chunks can have its own options. At least one chunk must be specified.
Any provided options override options given to New.
type TextChunk ¶
type TextChunk struct {
// contains filtered or unexported fields
}
TextChunk is a part of or the full text that will be displayed.
func NewChunk ¶
func NewChunk(text string, wOpts ...WriteOption) *TextChunk
NewChunk creates a new text chunk.
type WriteOption ¶
type WriteOption interface {
// contains filtered or unexported methods
}
WriteOption is used to provide options to Write().
func WriteCellOpts ¶
func WriteCellOpts(opts ...cell.Option) WriteOption
WriteCellOpts sets options on the cells that contain the text.
func WriteErrOnUnsupported ¶
func WriteErrOnUnsupported(opts ...cell.Option) WriteOption
WriteErrOnUnsupported instructs Write to return an error when the text contains a character the display doesn't support. The default behavior is to sanitize the text, see WriteSanitize().
func WriteSanitize ¶
func WriteSanitize(opts ...cell.Option) WriteOption
WriteSanitize instructs Write to sanitize the text, replacing all characters the display doesn't support with a space ' ' character. This is the default behavior.
Directories ¶
Path | Synopsis |
---|---|
Binary segmentdisplaydemo shows the functionality of a segment display.
|
Binary segmentdisplaydemo shows the functionality of a segment display. |