menu

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 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 Menu struct {
	// contains filtered or unexported fields
}

Menu 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) (*Menu, error)

New returns a new text widget.

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

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

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

Keyboard implements widgetapi.Widget.Keyboard.

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

Mouse implements widgetapi.Widget.Mouse.

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

Options of the widget

func (t *Menu) Reset()

Reset resets the widget back to empty content.

func (t *Menu) SetIndex(idx int)

Setindex sets the current index.

func (t *Menu) 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 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

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

func WriteReplace() WriteOption

WriteReplace instructs the text widget to replace the entire text content on this write instead of appending.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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