Documentation
¶
Overview ¶
Package text contains a widget that displays textual data.
Index ¶
- Constants
- type Option
- type Text
- func (t *Text) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (t *Text) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (t *Text) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (t *Text) Options() widgetapi.Options
- func (t *Text) Reset()
- func (t *Text) Write(text string, wOpts ...WriteOption) error
- type WriteOption
Constants ¶
const ( DefaultScrollUpRune = '⇧' DefaultScrollDownRune = '⇩' )
The default scroll runes for content scrolling
const ( DefaultScrollMouseButtonUp = mouse.ButtonWheelUp DefaultScrollMouseButtonDown = mouse.ButtonWheelDown )
The default mouse buttons for content scrolling.
const ( DefaultScrollKeyUp = keyboard.KeyArrowUp DefaultScrollKeyDown = keyboard.KeyArrowDown DefaultScrollKeyPageUp = keyboard.KeyPgUp DefaultScrollKeyPageDown = keyboard.KeyPgDn )
The default keys for content scrolling.
const (
DefaultMaxTextCells = 0
)
The default value for the MaxTextCells option. Use zero as no limit, for logs you may wish to try 10,000 or higher.
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 to New().
func DisableScrolling ¶
func DisableScrolling() Option
DisableScrolling disables the scrolling of the content using keyboard and mouse.
func MaxTextCells ¶ added in v0.16.0
MaxTextCells limits the text content to this number of terminal cells. This is useful when sending large amounts of text to the Text widget, e.g. when tailing logs as it will limit the memory usage. When the newly added content goes over this number of cells, the Text widget behaves as a circular buffer and drops earlier content to accommodate the new one. Note the count is in cells, not runes, some wide runes can take multiple terminal cells.
func RollContent ¶
func RollContent() Option
RollContent configures the text widget so that it rolls the text content up if more text than the size of the container is added. If not provided, the content is trimmed instead.
func ScrollKeys ¶
ScrollKeys configures the keyboard keys that scroll the content. The provided keys must be unique, e.g. the same key cannot be both up and down.
func ScrollMouseButtons ¶
ScrollMouseButtons configures the mouse buttons that scroll the content. The provided buttons must be unique, e.g. the same button cannot be both up and down.
func ScrollRunes ¶ added in v0.13.0
ScrollRunes configures the text widgets scroll runes, shown at the top and bottom of a scrollable text widget. If not provided, the default scroll runes will be used.
func WrapAtRunes ¶
func WrapAtRunes() Option
WrapAtRunes configures the text widget so that it automatically wraps lines that are longer than the width of the widget at rune boundaries. If not provided, long lines are trimmed instead.
func WrapAtWords ¶ added in v0.8.0
func WrapAtWords() Option
WrapAtWords configures the text widget so that it automatically wraps lines that are longer than the width of the widget at word boundaries. If not provided, long lines are trimmed instead.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text displays a block of text.
Each line of the text is either trimmed or wrapped according to the provided options. The entire text content is either trimmed or rolled up through the canvas according to the provided options.
By default the widget supports scrolling of content with either the keyboard or mouse. See the options for the default keys and mouse buttons.
Implements widgetapi.Widget. This object is thread-safe.
func (*Text) Write ¶
func (t *Text) Write(text string, wOpts ...WriteOption) error
Write writes text for the widget to display. Multiple calls append additional text. The text contain cannot control characters (unicode.IsControl) or space character (unicode.IsSpace) other than:
' ', '\n'
Any newline ('\n') characters are interpreted as newlines when displaying the text.
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 WriteReplace ¶ added in v0.7.0
func WriteReplace() WriteOption
WriteReplace instructs the text widget to replace the entire text content on this write instead of appending.