views

package
v1.4.12 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CellModel

type CellModel interface {
	GetCell(x, y int) (rune, tcell.Style, []rune, int)
	GetBounds() (int, int)
	SetCursor(int, int)
	GetCursor() (int, int, bool, bool)
	MoveCursor(offx, offy int)
}

CellModel models the content of a CellView. The dimensions used within a CellModel are always logical, and have origin 0, 0.

type CellView

type CellView struct {
	WidgetWatchers
	// contains filtered or unexported fields
}

CellView is a flexible view of a CellModel, offering both cursor management and a panning.

func NewCellView

func NewCellView() *CellView

NewCellView creates a CellView.

func (*CellView) Draw

func (a *CellView) Draw()

Draw draws the content.

func (*CellView) GetModel added in v1.4.11

func (a *CellView) GetModel() CellModel

GetModel gets the model for this CellView

func (*CellView) HandleEvent

func (a *CellView) HandleEvent(e tcell.Event) bool

HandleEvent handles events. In particular, it handles certain key events to move the cursor or pan the view.

func (*CellView) Init

func (a *CellView) Init()

Init initializes a new CellView for use.

func (*CellView) MakeCursorVisible

func (a *CellView) MakeCursorVisible()

MakeCursorVisible ensures that the cursor is visible, panning the ViewPort as necessary, if the cursor is enabled.

func (*CellView) MakeVisible

func (a *CellView) MakeVisible(x, y int)

MakeVisible makes the given coordinates visible, if they are not already. It does this by moving the ViewPort for the CellView.

func (*CellView) Resize

func (a *CellView) Resize()

Resize is called when the View is resized. It will ensure that the cursor is visible, if present.

func (*CellView) SetCursor

func (a *CellView) SetCursor(x, y int)

SetCursor sets the the cursor position.

func (*CellView) SetCursorX

func (a *CellView) SetCursorX(x int)

SetCursorX sets the the cursor column.

func (*CellView) SetCursorY

func (a *CellView) SetCursorY(y int)

SetCursorY sets the the cursor row.

func (*CellView) SetModel

func (a *CellView) SetModel(model CellModel)

SetModel sets the model for this CellView.

func (*CellView) SetStyle

func (a *CellView) SetStyle(s tcell.Style)

SetStyle sets the the default fill style.

func (*CellView) SetView

func (a *CellView) SetView(view View)

SetView sets the View context.

func (*CellView) Size

func (a *CellView) Size() (int, int)

Size returns the content size, based on the model.

type Text

type Text struct {
	WidgetWatchers
	// contains filtered or unexported fields
}

Text is a Widget with containing a block of text, which can optionally be styled.

func NewText

func NewText() *Text

NewText creates an empty Text.

func (*Text) Alignment

func (t *Text) Alignment() Alignment

Alignment returns the alignment of the Text.

func (*Text) Draw

func (t *Text) Draw()

Draw draws the Text.

func (*Text) HandleEvent

func (t *Text) HandleEvent(tcell.Event) bool

HandleEvent implements a tcell.EventHandler, but does nothing.

func (*Text) Resize

func (t *Text) Resize()

Resize is called when our View changes sizes.

func (*Text) SetAlignment

func (t *Text) SetAlignment(align Alignment)

SetAlignment sets the alignment. Negative values indicate right justification, positive values are left, and zero indicates center aligned.

func (*Text) SetStyle

func (t *Text) SetStyle(style tcell.Style)

SetStyle sets the style used. This applies to every cell in the in the text.

func (*Text) SetStyleAt

func (t *Text) SetStyleAt(pos int, style tcell.Style)

SetStyleAt sets the style at the given rune index. Note that for strings containing combining characters, it is not possible to change the style at the position of the combining character, but those positions *do* count for calculating the index. A lot of complexity can be avoided by avoiding the use of combining characters.

func (*Text) SetText

func (t *Text) SetText(s string)

SetText sets the text used for the string. Any previously set styles on individual rune indices are reset, and the default style for the widget is set.

func (*Text) SetView

func (t *Text) SetView(view View)

SetView sets the View object used for the text bar.

func (*Text) Size

func (t *Text) Size() (int, int)

Size returns the width and height in character cells of the Text.

func (*Text) Style

func (t *Text) Style() tcell.Style

Style returns the previously set default style. Note that individual characters may have different styles.

func (*Text) StyleAt

func (t *Text) StyleAt(pos int) tcell.Style

StyleAt gets the style at the given rune index. If an invalid index is given, or the index is a combining character, then tcell.StyleDefault is returned.

func (*Text) Text

func (t *Text) Text() string

Text returns the text that was set.

type TextArea

type TextArea struct {
	CellView
	// contains filtered or unexported fields
}

TextArea is a pannable 2 dimensional text widget. It wraps both the view and the model for text in a single, convenient widget. Text is provided as an array of strings, each of which represents a single line to display. All text in the TextArea has the same style. An optional soft cursor is available.

func NewTextArea

func NewTextArea() *TextArea

NewTextArea creates a blank TextArea.

func (*TextArea) EnableCursor

func (ta *TextArea) EnableCursor(on bool)

EnableCursor enables a soft cursor in the TextArea.

func (*TextArea) HideCursor

func (ta *TextArea) HideCursor(on bool)

HideCursor hides or shows the cursor in the TextArea. If on is true, the cursor is hidden. Note that a cursor is only shown if it is enabled.

func (*TextArea) Init

func (ta *TextArea) Init()

Init initializes the TextArea.

func (*TextArea) SetContent

func (ta *TextArea) SetContent(text string)

SetContent is used to set the textual content, passed as a single string. Lines within the string are delimited by newlines.

func (*TextArea) SetLines

func (ta *TextArea) SetLines(lines []string)

SetLines sets the content text to display.

func (*TextArea) SetStyle

func (ta *TextArea) SetStyle(style tcell.Style)

Jump to

Keyboard shortcuts

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