text

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package text contains a widget that displays textual data.

Index

Constants

View Source
const (
	DefaultScrollMouseButtonUp   = mouse.ButtonWheelUp
	DefaultScrollMouseButtonDown = mouse.ButtonWheelDown
)

The default mouse buttons for content scrolling.

View Source
const (
	DefaultScrollKeyUp       = keyboard.KeyArrowUp
	DefaultScrollKeyDown     = keyboard.KeyArrowDown
	DefaultScrollKeyPageUp   = keyboard.KeyPgUp
	DefaultScrollKeyPageDown = keyboard.KeyPgDn
)

The default keys for content scrolling.

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 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

func ScrollKeys(up, down, pageUp, pageDown keyboard.Key) Option

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

func ScrollMouseButtons(up, down mouse.Button) Option

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 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 New

func New(opts ...Option) (*Text, error)

New returns a new text widget.

func (*Text) Draw

func (t *Text) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error

Draw draws the text onto the canvas. Implements widgetapi.Widget.Draw.

func (*Text) Keyboard

func (t *Text) Keyboard(k *terminalapi.Keyboard) error

Keyboard implements widgetapi.Widget.Keyboard.

func (*Text) Mouse

func (t *Text) Mouse(m *terminalapi.Mouse) error

Mouse implements widgetapi.Widget.Mouse.

func (*Text) Options

func (t *Text) Options() widgetapi.Options

Options of the widget

func (*Text) Reset

func (t *Text) Reset()

Reset resets the widget back to empty content.

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.

Directories

Path Synopsis
Binary textdemo displays a couple of Text widgets.
Binary textdemo displays a couple of Text widgets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL