mauview

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MPL-2.0 Imports: 17 Imported by: 5

README

mauview

Work in progress

Documentation

Index

Constants

View Source
const (
	// Block: General Punctation U+2000-U+206F (http://unicode.org/charts/PDF/U2000.pdf)
	SemigraphicsHorizontalEllipsis rune = '\u2026' // …

	// Block: Box Drawing U+2500-U+257F (http://unicode.org/charts/PDF/U2500.pdf)
	BoxDrawingsLightHorizontal                    rune = '\u2500' // ─
	BoxDrawingsHeavyHorizontal                    rune = '\u2501' // ━
	BoxDrawingsLightVertical                      rune = '\u2502' // │
	BoxDrawingsHeavyVertical                      rune = '\u2503' // ┃
	BoxDrawingsLightTripleDashHorizontal          rune = '\u2504' // ┄
	BoxDrawingsHeavyTripleDashHorizontal          rune = '\u2505' // ┅
	BoxDrawingsLightTripleDashVertical            rune = '\u2506' // ┆
	BoxDrawingsHeavyTripleDashVertical            rune = '\u2507' // ┇
	BoxDrawingsLightQuadrupleDashHorizontal       rune = '\u2508' // ┈
	BoxDrawingsHeavyQuadrupleDashHorizontal       rune = '\u2509' // ┉
	BoxDrawingsLightQuadrupleDashVertical         rune = '\u250a' // ┊
	BoxDrawingsHeavyQuadrupleDashVertical         rune = '\u250b' // ┋
	BoxDrawingsLightDownAndRight                  rune = '\u250c' // ┌
	BoxDrawingsDownLighAndRightHeavy              rune = '\u250d' // ┍
	BoxDrawingsDownHeavyAndRightLight             rune = '\u250e' // ┎
	BoxDrawingsHeavyDownAndRight                  rune = '\u250f' // ┏
	BoxDrawingsLightDownAndLeft                   rune = '\u2510' // ┐
	BoxDrawingsDownLighAndLeftHeavy               rune = '\u2511' // ┑
	BoxDrawingsDownHeavyAndLeftLight              rune = '\u2512' // ┒
	BoxDrawingsHeavyDownAndLeft                   rune = '\u2513' // ┓
	BoxDrawingsLightUpAndRight                    rune = '\u2514' // └
	BoxDrawingsUpLightAndRightHeavy               rune = '\u2515' // ┕
	BoxDrawingsUpHeavyAndRightLight               rune = '\u2516' // ┖
	BoxDrawingsHeavyUpAndRight                    rune = '\u2517' // ┗
	BoxDrawingsLightUpAndLeft                     rune = '\u2518' // ┘
	BoxDrawingsUpLightAndLeftHeavy                rune = '\u2519' // ┙
	BoxDrawingsUpHeavyAndLeftLight                rune = '\u251a' // ┚
	BoxDrawingsHeavyUpAndLeft                     rune = '\u251b' // ┛
	BoxDrawingsLightVerticalAndRight              rune = '\u251c' // ├
	BoxDrawingsVerticalLightAndRightHeavy         rune = '\u251d' // ┝
	BoxDrawingsUpHeavyAndRightDownLight           rune = '\u251e' // ┞
	BoxDrawingsDownHeacyAndRightUpLight           rune = '\u251f' // ┟
	BoxDrawingsVerticalHeavyAndRightLight         rune = '\u2520' // ┠
	BoxDrawingsDownLightAnbdRightUpHeavy          rune = '\u2521' // ┡
	BoxDrawingsUpLightAndRightDownHeavy           rune = '\u2522' // ┢
	BoxDrawingsHeavyVerticalAndRight              rune = '\u2523' // ┣
	BoxDrawingsLightVerticalAndLeft               rune = '\u2524' // ┤
	BoxDrawingsVerticalLightAndLeftHeavy          rune = '\u2525' // ┥
	BoxDrawingsUpHeavyAndLeftDownLight            rune = '\u2526' // ┦
	BoxDrawingsDownHeavyAndLeftUpLight            rune = '\u2527' // ┧
	BoxDrawingsVerticalheavyAndLeftLight          rune = '\u2528' // ┨
	BoxDrawingsDownLightAndLeftUpHeavy            rune = '\u2529' // ┨
	BoxDrawingsUpLightAndLeftDownHeavy            rune = '\u252a' // ┪
	BoxDrawingsHeavyVerticalAndLeft               rune = '\u252b' // ┫
	BoxDrawingsLightDownAndHorizontal             rune = '\u252c' // ┬
	BoxDrawingsLeftHeavyAndRightDownLight         rune = '\u252d' // ┭
	BoxDrawingsRightHeavyAndLeftDownLight         rune = '\u252e' // ┮
	BoxDrawingsDownLightAndHorizontalHeavy        rune = '\u252f' // ┯
	BoxDrawingsDownHeavyAndHorizontalLight        rune = '\u2530' // ┰
	BoxDrawingsRightLightAndLeftDownHeavy         rune = '\u2531' // ┱
	BoxDrawingsLeftLightAndRightDownHeavy         rune = '\u2532' // ┲
	BoxDrawingsHeavyDownAndHorizontal             rune = '\u2533' // ┳
	BoxDrawingsLightUpAndHorizontal               rune = '\u2534' // ┴
	BoxDrawingsLeftHeavyAndRightUpLight           rune = '\u2535' // ┵
	BoxDrawingsRightHeavyAndLeftUpLight           rune = '\u2536' // ┶
	BoxDrawingsUpLightAndHorizontalHeavy          rune = '\u2537' // ┷
	BoxDrawingsUpHeavyAndHorizontalLight          rune = '\u2538' // ┸
	BoxDrawingsRightLightAndLeftUpHeavy           rune = '\u2539' // ┹
	BoxDrawingsLeftLightAndRightUpHeavy           rune = '\u253a' // ┺
	BoxDrawingsHeavyUpAndHorizontal               rune = '\u253b' // ┻
	BoxDrawingsLightVerticalAndHorizontal         rune = '\u253c' // ┼
	BoxDrawingsLeftHeavyAndRightVerticalLight     rune = '\u253d' // ┽
	BoxDrawingsRightHeavyAndLeftVerticalLight     rune = '\u253e' // ┾
	BoxDrawingsVerticalLightAndHorizontalHeavy    rune = '\u253f' // ┿
	BoxDrawingsUpHeavyAndDownHorizontalLight      rune = '\u2540' // ╀
	BoxDrawingsDownHeavyAndUpHorizontalLight      rune = '\u2541' // ╁
	BoxDrawingsVerticalHeavyAndHorizontalLight    rune = '\u2542' // ╂
	BoxDrawingsLeftUpHeavyAndRightDownLight       rune = '\u2543' // ╃
	BoxDrawingsRightUpHeavyAndLeftDownLight       rune = '\u2544' // ╄
	BoxDrawingsLeftDownHeavyAndRightUpLight       rune = '\u2545' // ╅
	BoxDrawingsRightDownHeavyAndLeftUpLight       rune = '\u2546' // ╆
	BoxDrawingsDownLightAndUpHorizontalHeavy      rune = '\u2547' // ╇
	BoxDrawingsUpLightAndDownHorizontalHeavy      rune = '\u2548' // ╈
	BoxDrawingsRightLightAndLeftVerticalHeavy     rune = '\u2549' // ╉
	BoxDrawingsLeftLightAndRightVerticalHeavy     rune = '\u254a' // ╊
	BoxDrawingsHeavyVerticalAndHorizontal         rune = '\u254b' // ╋
	BoxDrawingsLightDoubleDashHorizontal          rune = '\u254c' // ╌
	BoxDrawingsHeavyDoubleDashHorizontal          rune = '\u254d' // ╍
	BoxDrawingsLightDoubleDashVertical            rune = '\u254e' // ╎
	BoxDrawingsHeavyDoubleDashVertical            rune = '\u254f' // ╏
	BoxDrawingsDoubleHorizontal                   rune = '\u2550' // ═
	BoxDrawingsDoubleVertical                     rune = '\u2551' // ║
	BoxDrawingsDownSingleAndRightDouble           rune = '\u2552' // ╒
	BoxDrawingsDownDoubleAndRightSingle           rune = '\u2553' // ╓
	BoxDrawingsDoubleDownAndRight                 rune = '\u2554' // ╔
	BoxDrawingsDownSingleAndLeftDouble            rune = '\u2555' // ╕
	BoxDrawingsDownDoubleAndLeftSingle            rune = '\u2556' // ╖
	BoxDrawingsDoubleDownAndLeft                  rune = '\u2557' // ╗
	BoxDrawingsUpSingleAndRightDouble             rune = '\u2558' // ╘
	BoxDrawingsUpDoubleAndRightSingle             rune = '\u2559' // ╙
	BoxDrawingsDoubleUpAndRight                   rune = '\u255a' // ╚
	BoxDrawingsUpSingleAndLeftDouble              rune = '\u255b' // ╛
	BoxDrawingsUpDobuleAndLeftSingle              rune = '\u255c' // ╜
	BoxDrawingsDoubleUpAndLeft                    rune = '\u255d' // ╝
	BoxDrawingsVerticalSingleAndRightDouble       rune = '\u255e' // ╞
	BoxDrawingsVerticalDoubleAndRightSingle       rune = '\u255f' // ╟
	BoxDrawingsDoubleVerticalAndRight             rune = '\u2560' // ╠
	BoxDrawingsVerticalSingleAndLeftDouble        rune = '\u2561' // ╡
	BoxDrawingsVerticalDoubleAndLeftSingle        rune = '\u2562' // ╢
	BoxDrawingsDoubleVerticalAndLeft              rune = '\u2563' // ╣
	BoxDrawingsDownSingleAndHorizontalDouble      rune = '\u2564' // ╤
	BoxDrawingsDownDoubleAndHorizontalSingle      rune = '\u2565' // ╥
	BoxDrawingsDoubleDownAndHorizontal            rune = '\u2566' // ╦
	BoxDrawingsUpSingleAndHorizontalDouble        rune = '\u2567' // ╧
	BoxDrawingsUpDoubleAndHorizontalSingle        rune = '\u2568' // ╨
	BoxDrawingsDoubleUpAndHorizontal              rune = '\u2569' // ╩
	BoxDrawingsVerticalSingleAndHorizontalDouble  rune = '\u256a' // ╪
	BoxDrawingsVerticalDoubleAndHorizontalSingle  rune = '\u256b' // ╫
	BoxDrawingsDoubleVerticalAndHorizontal        rune = '\u256c' // ╬
	BoxDrawingsLightArcDownAndRight               rune = '\u256d' // ╭
	BoxDrawingsLightArcDownAndLeft                rune = '\u256e' // ╮
	BoxDrawingsLightArcUpAndLeft                  rune = '\u256f' // ╯
	BoxDrawingsLightArcUpAndRight                 rune = '\u2570' // ╰
	BoxDrawingsLightDiagonalUpperRightToLowerLeft rune = '\u2571' // ╱
	BoxDrawingsLightDiagonalUpperLeftToLowerRight rune = '\u2572' // ╲
	BoxDrawingsLightDiagonalCross                 rune = '\u2573' // ╳
	BoxDrawingsLightLeft                          rune = '\u2574' // ╴
	BoxDrawingsLightUp                            rune = '\u2575' // ╵
	BoxDrawingsLightRight                         rune = '\u2576' // ╶
	BoxDrawingsLightDown                          rune = '\u2577' // ╷
	BoxDrawingsHeavyLeft                          rune = '\u2578' // ╸
	BoxDrawingsHeavyUp                            rune = '\u2579' // ╹
	BoxDrawingsHeavyRight                         rune = '\u257a' // ╺
	BoxDrawingsHeavyDown                          rune = '\u257b' // ╻
	BoxDrawingsLightLeftAndHeavyRight             rune = '\u257c' // ╼
	BoxDrawingsLightUpAndHeavyDown                rune = '\u257d' // ╽
	BoxDrawingsHeavyLeftAndLightRight             rune = '\u257e' // ╾
	BoxDrawingsHeavyUpAndLightDown                rune = '\u257f' // ╿
)

Semigraphics provides an easy way to access unicode characters for drawing.

Named like the unicode characters, 'Semigraphics'-prefix used if unicode block isn't prefixed itself.

View Source
const (
	AlignLeft = iota
	AlignCenter
	AlignRight
)

Text alignment within a box.

Variables

View Source
var (
	Backspace1RemovesWord = true
	Backspace2RemovesWord = false
)

Global options to specify which of the two backspace key codes should remove the whole previous word. If false, only the previous character will be removed with that key code.

View Source
var (
	// InputFieldInteger accepts integers.
	InputFieldInteger func(text string, ch rune) bool

	// InputFieldFloat accepts floating-point numbers.
	InputFieldFloat func(text string, ch rune) bool

	// InputFieldMaxLength returns an input field accept handler which accepts
	// input strings up to a given length. Use it like this:
	//
	//   inputField.SetAcceptanceFunc(InputFieldMaxLength(10)) // Accept up to 10 characters.
	InputFieldMaxLength func(maxLength int) func(text string, ch rune) bool
)

Predefined InputField acceptance functions.

View Source
var Blocks = [9]rune{' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'}
View Source
var Borders = struct {
	Horizontal  rune
	Vertical    rune
	TopLeft     rune
	TopRight    rune
	BottomLeft  rune
	BottomRight rune

	LeftT   rune
	RightT  rune
	TopT    rune
	BottomT rune
	Cross   rune

	HorizontalFocus  rune
	VerticalFocus    rune
	TopLeftFocus     rune
	TopRightFocus    rune
	BottomLeftFocus  rune
	BottomRightFocus rune
}{
	Horizontal:  BoxDrawingsLightHorizontal,
	Vertical:    BoxDrawingsLightVertical,
	TopLeft:     BoxDrawingsLightDownAndRight,
	TopRight:    BoxDrawingsLightDownAndLeft,
	BottomLeft:  BoxDrawingsLightUpAndRight,
	BottomRight: BoxDrawingsLightUpAndLeft,

	LeftT:   BoxDrawingsLightVerticalAndRight,
	RightT:  BoxDrawingsLightVerticalAndLeft,
	TopT:    BoxDrawingsLightDownAndHorizontal,
	BottomT: BoxDrawingsLightUpAndHorizontal,
	Cross:   BoxDrawingsLightVerticalAndHorizontal,

	HorizontalFocus:  BoxDrawingsDoubleHorizontal,
	VerticalFocus:    BoxDrawingsDoubleVertical,
	TopLeftFocus:     BoxDrawingsDoubleDownAndRight,
	TopRightFocus:    BoxDrawingsDoubleDownAndLeft,
	BottomLeftFocus:  BoxDrawingsDoubleUpAndRight,
	BottomRightFocus: BoxDrawingsDoubleUpAndLeft,
}

Borders defines various borders used when primitives are drawn. These may be changed to accommodate a different look and feel.

View Source
var SemigraphicJoints = map[string]rune{

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVertical}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndRight}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndRight}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVertical, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightDownAndLeft}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndRight}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightDownAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightUpAndLeft}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndRight,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndRight}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndLeft,

	string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightUpAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVerticalAndLeft}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightDownAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightUpAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,

	string([]rune{BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightVerticalAndHorizontal}): BoxDrawingsLightVerticalAndHorizontal,
}

SemigraphicJoints is a map for joining semigraphic (or otherwise) runes. So far only light lines are supported but if you want to change the border styling you need to provide the joints, too. The matching will be sorted ascending by rune value, so you don't need to provide all rune combinations, e.g. (─) + (│) = (┼) will also match (│) + (─) = (┼)

View Source
var Styles = struct {
	PrimitiveBackgroundColor    tcell.Color // Main background color for primitives.
	ContrastBackgroundColor     tcell.Color // Background color for contrasting elements.
	MoreContrastBackgroundColor tcell.Color // Background color for even more contrasting elements.
	BorderColor                 tcell.Color // Box borders.
	TitleColor                  tcell.Color // Box titles.
	GraphicsColor               tcell.Color // Graphics.
	PrimaryTextColor            tcell.Color // Primary text.
	SecondaryTextColor          tcell.Color // Secondary text (e.g. labels).
	TertiaryTextColor           tcell.Color // Tertiary text (e.g. subtitles, notes).
	InverseTextColor            tcell.Color // Text on primary-colored backgrounds.
	ContrastSecondaryTextColor  tcell.Color // Secondary text on ContrastBackgroundColor-colored backgrounds.
}{
	PrimitiveBackgroundColor:    tcell.ColorBlack,
	ContrastBackgroundColor:     tcell.ColorBlue,
	MoreContrastBackgroundColor: tcell.ColorGreen,
	BorderColor:                 tcell.ColorWhite,
	TitleColor:                  tcell.ColorWhite,
	GraphicsColor:               tcell.ColorWhite,
	PrimaryTextColor:            tcell.ColorWhite,
	SecondaryTextColor:          tcell.ColorYellow,
	TertiaryTextColor:           tcell.ColorGreen,
	InverseTextColor:            tcell.ColorBlue,
	ContrastSecondaryTextColor:  tcell.ColorDarkCyan,
}

Styles defines various colors used when primitives are initialized. These may be changed to accommodate a different look and feel.

The default is for applications with a black background and basic colors: black, white, yellow, green, and blue.

View Source
var TabSize = 4

TabSize is the number of spaces with which a tab character will be replaced.

Functions

func Escape

func Escape(text string) string

Escape escapes the given text such that color and/or region tags are not recognized and substituted by the print functions of this package. For example, to include a tag-like string in a box title or in a TextView:

box.SetTitle(tview.Escape("[squarebrackets]"))
fmt.Fprint(textView, tview.Escape(`["quoted"]`))

func OffsetMouseEvent

func OffsetMouseEvent(evt MouseEvent, offsetX, offsetY int) *proxyEventMouse

OffsetMouseEvent creates a new MouseEvent with the given offset.

func Print

func Print(screen Screen, text string, x, y, maxWidth, align int, color tcell.Color) (int, int)

Print prints text onto the screen into the given box at (x,y,maxWidth,1), not exceeding that box. "align" is one of AlignLeft, AlignCenter, or AlignRight. The screen's background color will not be changed.

You can change the colors and text styles mid-text by inserting a color tag. See the package description for details.

Returns the number of actual bytes of the text printed (including color tags) and the actual width used for the printed runes.

func PrintJoinedSemigraphics

func PrintJoinedSemigraphics(screen tcell.Screen, x, y int, ch rune, color tcell.Color)

PrintJoinedSemigraphics prints a semigraphics rune into the screen at the given position with the given color, joining it with any existing semigraphics rune. Background colors are preserved. At this point, only regular single line borders are supported.

func PrintSimple

func PrintSimple(screen Screen, text string, x, y int)

PrintSimple prints white text to the screen at the given position.

func PrintWithStyle

func PrintWithStyle(screen Screen, text string, x, y, maxWidth, align int, style tcell.Style) (int, int)

func SubstringBefore

func SubstringBefore(s string, w int) string

func TaggedStringWidth

func TaggedStringWidth(text string) int

TaggedStringWidth returns the width of the given string needed to print it on screen. The text may contain color tags which are not counted.

func WordWrap

func WordWrap(text string, width int) (lines []string)

WordWrap splits a text such that each resulting line does not exceed the given screen width. Possible split points are after any punctuation or whitespace. Whitespace after split points will be dropped.

This function considers color tags to have no width.

Text is always split at newline characters ('\n').

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication() *Application

func (*Application) ForceStop

func (app *Application) ForceStop()

func (*Application) Redraw

func (app *Application) Redraw()

func (*Application) Screen

func (app *Application) Screen() tcell.Screen

Screen returns the main tcell screen currently used in the app.

func (*Application) SetAlwaysClear

func (app *Application) SetAlwaysClear(always bool)

func (*Application) SetRedrawTicker

func (app *Application) SetRedrawTicker(tick time.Duration)

func (*Application) SetRoot

func (app *Application) SetRoot(view Component)

func (*Application) Start

func (app *Application) Start() error

func (*Application) Stop

func (app *Application) Stop()

func (*Application) Suspend

func (app *Application) Suspend(wait func())

type Box

type Box struct {
	// contains filtered or unexported fields
}

func NewBox

func NewBox(inner Component) *Box

func (*Box) Blur

func (box *Box) Blur()

func (*Box) Draw

func (box *Box) Draw(screen Screen)

func (*Box) Focus

func (box *Box) Focus()

func (*Box) OnKeyEvent

func (box *Box) OnKeyEvent(event KeyEvent) bool

func (*Box) OnMouseEvent

func (box *Box) OnMouseEvent(event MouseEvent) bool

func (*Box) OnPasteEvent

func (box *Box) OnPasteEvent(event PasteEvent) bool

func (*Box) SetBackgroundColor

func (box *Box) SetBackgroundColor(color tcell.Color) *Box

func (*Box) SetBlurCaptureFunc

func (box *Box) SetBlurCaptureFunc(blurCapture func() bool) *Box

func (*Box) SetBorder

func (box *Box) SetBorder(border bool) *Box

func (*Box) SetBorderStyle

func (box *Box) SetBorderStyle(borderStyle tcell.Style) *Box

func (*Box) SetFocusCaptureFunc

func (box *Box) SetFocusCaptureFunc(focusCapture func() bool) *Box

func (*Box) SetInnerComponent

func (box *Box) SetInnerComponent(component Component) *Box

func (*Box) SetKeyCaptureFunc

func (box *Box) SetKeyCaptureFunc(keyCapture KeyCaptureFunc) *Box

func (*Box) SetMouseCaptureFunc

func (box *Box) SetMouseCaptureFunc(mouseCapture MouseCaptureFunc) *Box

func (*Box) SetPasteCaptureFunc

func (box *Box) SetPasteCaptureFunc(pasteCapture PasteCaptureFunc) *Box

func (*Box) SetTitle

func (box *Box) SetTitle(title string) *Box

type Button

type Button struct {
	// contains filtered or unexported fields
}

func NewButton

func NewButton(text string) *Button

func (*Button) Blur

func (b *Button) Blur()

func (*Button) Draw

func (b *Button) Draw(screen Screen)

func (*Button) Focus

func (b *Button) Focus()

func (*Button) OnKeyEvent

func (b *Button) OnKeyEvent(event KeyEvent) bool

func (*Button) OnMouseEvent

func (b *Button) OnMouseEvent(event MouseEvent) bool

func (*Button) OnPasteEvent

func (b *Button) OnPasteEvent(event PasteEvent) bool

func (*Button) SetBackgroundColor

func (b *Button) SetBackgroundColor(color tcell.Color) *Button

func (*Button) SetFocusedBackgroundColor

func (b *Button) SetFocusedBackgroundColor(color tcell.Color) *Button

func (*Button) SetFocusedForegroundColor

func (b *Button) SetFocusedForegroundColor(color tcell.Color) *Button

func (*Button) SetFocusedStyle

func (b *Button) SetFocusedStyle(style tcell.Style) *Button

func (*Button) SetForegroundColor

func (b *Button) SetForegroundColor(color tcell.Color) *Button

func (*Button) SetOnClick

func (b *Button) SetOnClick(fn func()) *Button

func (*Button) SetStyle

func (b *Button) SetStyle(style tcell.Style) *Button

func (*Button) SetText

func (b *Button) SetText(text string) *Button

func (*Button) Submit

func (b *Button) Submit(event KeyEvent) bool

type Centerer

type Centerer struct {
	// contains filtered or unexported fields
}

func Center

func Center(target Component, width, height int) *Centerer

func (*Centerer) Blur

func (center *Centerer) Blur()

func (*Centerer) Draw

func (center *Centerer) Draw(screen Screen)

func (*Centerer) Focus

func (center *Centerer) Focus()

func (*Centerer) OnKeyEvent

func (center *Centerer) OnKeyEvent(evt KeyEvent) bool

func (*Centerer) OnMouseEvent

func (center *Centerer) OnMouseEvent(evt MouseEvent) bool

func (*Centerer) OnPasteEvent

func (center *Centerer) OnPasteEvent(evt PasteEvent) bool

func (*Centerer) SetAlwaysFocusChild

func (center *Centerer) SetAlwaysFocusChild(always bool) *Centerer

func (*Centerer) SetHeight

func (center *Centerer) SetHeight(height int)

func (*Centerer) SetSize

func (center *Centerer) SetSize(width, height int)

func (*Centerer) SetWidth

func (center *Centerer) SetWidth(width int)

type Component

type Component interface {
	Draw(screen Screen)
	OnKeyEvent(event KeyEvent) bool
	OnPasteEvent(event PasteEvent) bool
	OnMouseEvent(event MouseEvent) bool
}

type Flex

type Flex struct {
	// contains filtered or unexported fields
}

func NewFlex

func NewFlex() *Flex

func (*Flex) AddFixedComponent

func (flex *Flex) AddFixedComponent(comp Component, size int) *Flex

func (*Flex) AddProportionalComponent

func (flex *Flex) AddProportionalComponent(comp Component, size int) *Flex

func (*Flex) Blur

func (flex *Flex) Blur()

func (*Flex) Draw

func (flex *Flex) Draw(screen Screen)

func (*Flex) Focus

func (flex *Flex) Focus()

func (*Flex) OnKeyEvent

func (flex *Flex) OnKeyEvent(event KeyEvent) bool

func (*Flex) OnMouseEvent

func (flex *Flex) OnMouseEvent(event MouseEvent) bool

func (*Flex) OnPasteEvent

func (flex *Flex) OnPasteEvent(event PasteEvent) bool

func (*Flex) RemoveComponent

func (flex *Flex) RemoveComponent(comp Component) *Flex

func (*Flex) SetDirection

func (flex *Flex) SetDirection(direction FlexDirection) *Flex

func (*Flex) SetFocused

func (flex *Flex) SetFocused(comp Component)

type FlexDirection

type FlexDirection int
const (
	FlexRow FlexDirection = iota
	FlexColumn
)

type Focusable

type Focusable interface {
	Focus()
	Blur()
}

type FocusableComponent

type FocusableComponent interface {
	Component
	Focusable
}

type Form

type Form struct {
	*Grid
	// contains filtered or unexported fields
}

func NewForm

func NewForm() *Form

func (*Form) AddFormItem

func (form *Form) AddFormItem(comp Component, x, y, width, height int) *Form

func (*Form) Draw

func (form *Form) Draw(screen Screen)

func (*Form) FocusNextItem

func (form *Form) FocusNextItem()

func (*Form) FocusPreviousItem

func (form *Form) FocusPreviousItem()

func (*Form) OnKeyEvent

func (form *Form) OnKeyEvent(event KeyEvent) bool

func (*Form) RemoveFormItem

func (form *Form) RemoveFormItem(comp Component) *Form

func (*Form) SetOnFocusChanged

func (form *Form) SetOnFocusChanged(fn func(from, to Component)) *Form

type FormItem

type FormItem interface {
	Component
	Submit(event KeyEvent) bool
}

type FractionalCenterer

type FractionalCenterer struct {
	// contains filtered or unexported fields
}

func FractionalCenter

func FractionalCenter(target Component, minWidth, minHeight int, fractionalWidth, fractionalHeight float64) *FractionalCenterer

func (*FractionalCenterer) Blur

func (fc *FractionalCenterer) Blur()

func (*FractionalCenterer) Draw

func (fc *FractionalCenterer) Draw(screen Screen)

func (*FractionalCenterer) Focus

func (fc *FractionalCenterer) Focus()

func (*FractionalCenterer) OnKeyEvent

func (fc *FractionalCenterer) OnKeyEvent(evt KeyEvent) bool

func (*FractionalCenterer) OnMouseEvent

func (fc *FractionalCenterer) OnMouseEvent(evt MouseEvent) bool

func (*FractionalCenterer) OnPasteEvent

func (fc *FractionalCenterer) OnPasteEvent(evt PasteEvent) bool

func (*FractionalCenterer) SetAlwaysFocusChild

func (fc *FractionalCenterer) SetAlwaysFocusChild(always bool) *FractionalCenterer

type Grid

type Grid struct {
	// contains filtered or unexported fields
}

func NewGrid

func NewGrid() *Grid

func (*Grid) AddComponent

func (grid *Grid) AddComponent(comp Component, x, y, width, height int) *Grid

func (*Grid) Blur

func (grid *Grid) Blur()

func (*Grid) Draw

func (grid *Grid) Draw(screen Screen)

func (*Grid) Focus

func (grid *Grid) Focus()

func (*Grid) OnKeyEvent

func (grid *Grid) OnKeyEvent(event KeyEvent) bool

func (*Grid) OnMouseEvent

func (grid *Grid) OnMouseEvent(event MouseEvent) bool

func (*Grid) OnPasteEvent

func (grid *Grid) OnPasteEvent(event PasteEvent) bool

func (*Grid) OnResize

func (grid *Grid) OnResize(width, height int)

func (*Grid) RemoveComponent

func (grid *Grid) RemoveComponent(comp Component) *Grid

func (*Grid) SetColumn

func (grid *Grid) SetColumn(col, width int) *Grid

func (*Grid) SetColumns

func (grid *Grid) SetColumns(columns []int) *Grid

func (*Grid) SetRow

func (grid *Grid) SetRow(row, height int) *Grid

func (*Grid) SetRows

func (grid *Grid) SetRows(rows []int) *Grid

type InputArea

type InputArea struct {
	// contains filtered or unexported fields
}

InputArea is a multi-line user-editable text area.

func NewInputArea

func NewInputArea() *InputArea

NewInputArea returns a new input field.

func (*InputArea) Blur

func (field *InputArea) Blur()

Blur marks the input area as not focused.

func (*InputArea) Clear

func (field *InputArea) Clear()

Clear clears the input area.

func (*InputArea) ClearSelection

func (field *InputArea) ClearSelection()

func (*InputArea) Copy

func (field *InputArea) Copy()

Copy copies the currently selected content onto the clipboard.

func (*InputArea) Cut

func (field *InputArea) Cut()

func (*InputArea) Draw

func (field *InputArea) Draw(screen Screen)

Draw draws this primitive onto the screen.

func (*InputArea) ExtendSelection

func (field *InputArea) ExtendSelection(x, y int)

ExtendSelection extends the selection as if the user dragged their mouse to the given coordinates.

func (*InputArea) Focus

func (field *InputArea) Focus()

Focus marks the input area as focused.

func (*InputArea) GetCursorOffset

func (field *InputArea) GetCursorOffset() int

func (*InputArea) GetCursorPos

func (field *InputArea) GetCursorPos() (int, int)

func (*InputArea) GetSelectedText

func (field *InputArea) GetSelectedText() string

func (*InputArea) GetSelection

func (field *InputArea) GetSelection() (int, int)

func (*InputArea) GetText

func (field *InputArea) GetText() string

GetText returns the current text of the input field.

func (*InputArea) GetTextHeight

func (field *InputArea) GetTextHeight() int

GetTextHeight returns the number of lines in the text during the previous render.

func (*InputArea) MoveCursorDown

func (field *InputArea) MoveCursorDown(extendSelection bool)

MoveCursorDown moves the cursor down one line.

If extendSelection is true, the selection is either extended down if the cursor is at the end of the selection or retracted from the top if the cursor is at the beginning of the selection.

func (*InputArea) MoveCursorEnd

func (field *InputArea) MoveCursorEnd(extendSelection bool)

func (*InputArea) MoveCursorHome

func (field *InputArea) MoveCursorHome(extendSelection bool)

func (*InputArea) MoveCursorLeft

func (field *InputArea) MoveCursorLeft(moveWord, extendSelection bool)

MoveCursorLeft moves the cursor left.

If moveWord is true, the cursor moves a whole word to the left.

If extendSelection is true, the selection is either extended to the left if the cursor is on the left side of the selection or retracted from the right if the cursor is on the right side. If there is no existing selection, the selection will be created towards the left of the cursor.

func (*InputArea) MoveCursorRight

func (field *InputArea) MoveCursorRight(moveWord, extendSelection bool)

MoveCursorRight moves the cursor right.

If moveWord is true, the cursor moves a whole word to the right.

If extendSelection is true, the selection is either extended to the right if the cursor is on the right side of the selection or retracted from the left if the cursor is on the left side. If there is no existing selection, the selection will be created towards the right of the cursor.

func (*InputArea) MoveCursorUp

func (field *InputArea) MoveCursorUp(extendSelection bool)

MoveCursorUp moves the cursor up one line.

If extendSelection is true, the selection is either extended up if the cursor is at the beginning of the selection or retracted from the bottom if the cursor is at the end of the selection.

func (*InputArea) OnKeyEvent

func (field *InputArea) OnKeyEvent(event KeyEvent) bool

OnKeyEvent handles a terminal key press event.

func (*InputArea) OnMouseEvent

func (field *InputArea) OnMouseEvent(event MouseEvent) bool

OnMouseEvent handles a terminal mouse event.

func (*InputArea) OnPasteEvent

func (field *InputArea) OnPasteEvent(event PasteEvent) bool

OnPasteEvent handles a terminal bracketed paste event.

func (*InputArea) Paste

func (field *InputArea) Paste()

Paste reads the clipboard and inserts the content at the cursor position.

func (*InputArea) PrepareDraw

func (field *InputArea) PrepareDraw(width int)

func (*InputArea) Redo

func (field *InputArea) Redo()

Redo reverses an undo.

func (*InputArea) RemoveNextCharacter

func (field *InputArea) RemoveNextCharacter()

RemoveNextCharacter removes the character after the cursor.

func (*InputArea) RemovePreviousCharacter

func (field *InputArea) RemovePreviousCharacter()

RemovePreviousCharacter removes the character before the cursor.

func (*InputArea) RemovePreviousWord

func (field *InputArea) RemovePreviousWord()

RemovePreviousWord removes the word before the cursor.

func (*InputArea) RemoveSelection

func (field *InputArea) RemoveSelection()

RemoveSelection removes the selected content.

func (*InputArea) SelectAll

func (field *InputArea) SelectAll()

SelectAll extends the selection to cover all text in the input area.

func (*InputArea) SetBackgroundColor

func (field *InputArea) SetBackgroundColor(color tcell.Color) *InputArea

SetBackgroundColor sets the background color of the input area.

func (*InputArea) SetChangedFunc

func (field *InputArea) SetChangedFunc(handler func(text string)) *InputArea

SetChangedFunc sets a handler which is called whenever the text of the input field has changed. It receives the current text (after the change).

func (*InputArea) SetCursorOffset

func (field *InputArea) SetCursorOffset(offset int)

SetCursorOffset sets the runewidth cursor offset.

func (*InputArea) SetCursorPos

func (field *InputArea) SetCursorPos(x, y int)

SetCursorPos sets the X and Y cursor offsets.

func (*InputArea) SetPlaceholder

func (field *InputArea) SetPlaceholder(text string) *InputArea

SetPlaceholder sets the text to be displayed when the input text is empty.

func (*InputArea) SetPlaceholderTextColor

func (field *InputArea) SetPlaceholderTextColor(color tcell.Color) *InputArea

SetPlaceholderTextColor sets the text color of placeholder text.

func (*InputArea) SetPressKeyDownAtEndFunc

func (field *InputArea) SetPressKeyDownAtEndFunc(handler func()) *InputArea

func (*InputArea) SetPressKeyUpAtStartFunc

func (field *InputArea) SetPressKeyUpAtStartFunc(handler func()) *InputArea

func (*InputArea) SetSelection

func (field *InputArea) SetSelection(start, end int)

func (*InputArea) SetTabCompleteFunc

func (field *InputArea) SetTabCompleteFunc(handler func(text string, cursorOffset int)) *InputArea

func (*InputArea) SetText

func (field *InputArea) SetText(text string) *InputArea

SetText sets the current text of the input field.

func (*InputArea) SetTextAndMoveCursor

func (field *InputArea) SetTextAndMoveCursor(text string) *InputArea

SetTextAndMoveCursor sets the current text of the input field and moves the cursor with the width difference.

func (*InputArea) SetTextColor

func (field *InputArea) SetTextColor(color tcell.Color) *InputArea

SetTextColor sets the text color of the input area.

func (*InputArea) TypeRune

func (field *InputArea) TypeRune(ch rune)

TypeRune inserts the given rune at the current cursor position.

func (*InputArea) Undo

func (field *InputArea) Undo()

Undo reverses the input area to the previous history snapshot.

type InputField

type InputField struct {
	// contains filtered or unexported fields
}

InputField is a single-line user-editable text field.

Use SetMaskCharacter() to hide input from onlookers (e.g. for password input).

func NewInputField

func NewInputField() *InputField

NewInputField returns a new input field.

func (*InputField) Blur

func (field *InputField) Blur()

func (*InputField) Clear

func (field *InputField) Clear()

func (*InputField) Draw

func (field *InputField) Draw(screen Screen)

Draw draws this primitive onto the screen.

func (*InputField) Focus

func (field *InputField) Focus()

func (*InputField) GetCursorOffset

func (field *InputField) GetCursorOffset() int

func (*InputField) GetText

func (field *InputField) GetText() string

GetText returns the current text of the input field.

func (*InputField) MoveCursorLeft

func (field *InputField) MoveCursorLeft(moveWord bool)

func (*InputField) MoveCursorRight

func (field *InputField) MoveCursorRight(moveWord bool)

func (*InputField) OnKeyEvent

func (field *InputField) OnKeyEvent(event KeyEvent) bool

func (*InputField) OnMouseEvent

func (field *InputField) OnMouseEvent(event MouseEvent) bool

func (*InputField) OnPasteEvent

func (field *InputField) OnPasteEvent(event PasteEvent) bool

func (*InputField) RemoveNextCharacter

func (field *InputField) RemoveNextCharacter()

func (*InputField) RemovePreviousCharacter

func (field *InputField) RemovePreviousCharacter()

func (*InputField) RemovePreviousWord

func (field *InputField) RemovePreviousWord()

func (*InputField) SetBackgroundColor

func (field *InputField) SetBackgroundColor(color tcell.Color) *InputField

SetBackgroundColor sets the background color of the input area.

func (*InputField) SetChangedFunc

func (field *InputField) SetChangedFunc(handler func(text string)) *InputField

SetChangedFunc sets a handler which is called whenever the text of the input field has changed. It receives the current text (after the change).

func (*InputField) SetCursorOffset

func (field *InputField) SetCursorOffset(offset int) *InputField

func (*InputField) SetMaskCharacter

func (field *InputField) SetMaskCharacter(mask rune) *InputField

SetMaskCharacter sets a character that masks user input on a screen. A value of 0 disables masking.

func (*InputField) SetPlaceholder

func (field *InputField) SetPlaceholder(text string) *InputField

SetPlaceholder sets the text to be displayed when the input text is empty.

func (*InputField) SetPlaceholderTextColor

func (field *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField

SetPlaceholderTextColor sets the text color of placeholder text.

func (*InputField) SetTabCompleteFunc

func (field *InputField) SetTabCompleteFunc(handler func(text string, cursorOffset int)) *InputField

func (*InputField) SetText

func (field *InputField) SetText(text string) *InputField

SetText sets the current text of the input field.

func (*InputField) SetTextAndMoveCursor

func (field *InputField) SetTextAndMoveCursor(text string) *InputField

SetTextAndMoveCursor sets the current text of the input field and moves the cursor with the width difference.

func (*InputField) SetTextColor

func (field *InputField) SetTextColor(color tcell.Color) *InputField

SetTextColor sets the text color of the input area.

func (*InputField) Submit

func (field *InputField) Submit(event KeyEvent) bool

func (*InputField) TypeRune

func (field *InputField) TypeRune(ch rune)

type KeyCaptureFunc

type KeyCaptureFunc func(event KeyEvent) KeyEvent

type KeyEvent

type KeyEvent interface {
	tcell.Event
	// The rune corresponding to the key that was pressed.
	Rune() rune
	// The keyboard key that was pressed.
	Key() tcell.Key
	// The keyboard modifiers that were pressed during the event.
	Modifiers() tcell.ModMask
}

KeyEvent is an interface of the *tcell.EventKey type.

type MouseCaptureFunc

type MouseCaptureFunc func(event MouseEvent) MouseEvent

type MouseEvent

type MouseEvent interface {
	tcell.Event
	// The mouse buttons that were pressed.
	Buttons() tcell.ButtonMask
	// The keyboard modifiers that were pressed during the event.
	Modifiers() tcell.ModMask
	// The current position of the mouse.
	Position() (int, int)
	// Whether or not the event is a mouse move event.
	HasMotion() bool
}

MouseEvent is an interface of the *tcell.EventMouse type.

type NoopEventHandler

type NoopEventHandler struct{}

func (NoopEventHandler) OnKeyEvent

func (neh NoopEventHandler) OnKeyEvent(event KeyEvent) bool

func (NoopEventHandler) OnMouseEvent

func (neh NoopEventHandler) OnMouseEvent(event MouseEvent) bool

func (NoopEventHandler) OnPasteEvent

func (neh NoopEventHandler) OnPasteEvent(event PasteEvent) bool

type PasteCaptureFunc

type PasteCaptureFunc func(event PasteEvent) PasteEvent

type PasteEvent

type PasteEvent interface {
	tcell.Event
	// The text pasted.
	Text() string
}

PasteEvent is an interface of the customPasteEvent type.

type ProgressBar

type ProgressBar struct {
	*SimpleEventHandler
	// contains filtered or unexported fields
}

func NewProgressBar

func NewProgressBar() *ProgressBar

func (*ProgressBar) Draw

func (pb *ProgressBar) Draw(screen Screen)

Draw draws this primitive onto the screen.

func (*ProgressBar) Increment

func (pb *ProgressBar) Increment(increment int) *ProgressBar

func (*ProgressBar) SetIndeterminate

func (pb *ProgressBar) SetIndeterminate(indeterminate bool) *ProgressBar

func (*ProgressBar) SetMax

func (pb *ProgressBar) SetMax(max int) *ProgressBar

func (*ProgressBar) SetProgress

func (pb *ProgressBar) SetProgress(progress int) *ProgressBar

type ProxyScreen

type ProxyScreen struct {
	Parent           Screen
	OffsetX, OffsetY int
	Width, Height    int
	Style            tcell.Style
}

ProxyScreen is a proxy to a tcell Screen with a specific allowed drawing area.

func (*ProxyScreen) CanDisplay

func (ss *ProxyScreen) CanDisplay(r rune, checkFallbacks bool) bool

func (*ProxyScreen) CharacterSet

func (ss *ProxyScreen) CharacterSet() string

func (*ProxyScreen) Clear

func (ss *ProxyScreen) Clear()

func (*ProxyScreen) Colors

func (ss *ProxyScreen) Colors() int

func (*ProxyScreen) Fill

func (ss *ProxyScreen) Fill(r rune, style tcell.Style)

func (*ProxyScreen) GetContent

func (ss *ProxyScreen) GetContent(x, y int) (mainc rune, combc []rune, style tcell.Style, width int)

func (*ProxyScreen) HasKey

func (ss *ProxyScreen) HasKey(key tcell.Key) bool

func (*ProxyScreen) HideCursor

func (ss *ProxyScreen) HideCursor()

func (*ProxyScreen) IsInArea

func (ss *ProxyScreen) IsInArea(x, y int) bool

func (*ProxyScreen) OffsetMouseEvent

func (ss *ProxyScreen) OffsetMouseEvent(event MouseEvent) MouseEvent

func (*ProxyScreen) SetCell

func (ss *ProxyScreen) SetCell(x, y int, style tcell.Style, ch ...rune)

func (*ProxyScreen) SetContent

func (ss *ProxyScreen) SetContent(x int, y int, mainc rune, combc []rune, style tcell.Style)

func (*ProxyScreen) SetStyle

func (ss *ProxyScreen) SetStyle(style tcell.Style)

func (*ProxyScreen) ShowCursor

func (ss *ProxyScreen) ShowCursor(x, y int)

func (*ProxyScreen) Size

func (ss *ProxyScreen) Size() (width int, height int)

Size returns the size of this subscreen.

If the subscreen doesn't fit in the parent with the set offset and size, the returned size is whatever can actually be rendered.

func (*ProxyScreen) XEnd

func (ss *ProxyScreen) XEnd() int

func (*ProxyScreen) YEnd

func (ss *ProxyScreen) YEnd() int

type Screen

type Screen interface {
	Clear()
	Fill(rune, tcell.Style)
	SetStyle(style tcell.Style)
	SetCell(x, y int, style tcell.Style, ch ...rune)
	GetContent(x, y int) (mainc rune, combc []rune, style tcell.Style, width int)
	SetContent(x int, y int, mainc rune, combc []rune, style tcell.Style)
	ShowCursor(x int, y int)
	HideCursor()
	Size() (int, int)
	Colors() int
	CharacterSet() string
	CanDisplay(r rune, checkFallbacks bool) bool
	HasKey(tcell.Key) bool
}

Screen is a subset of the tcell Screen. See https://godoc.org/maunium.net/go/tcell#Screen for documentation.

func NewProxyScreen

func NewProxyScreen(parent Screen, offsetX, offsetY, width, height int) Screen

type SimpleEventHandler

type SimpleEventHandler struct {
	OnKey   func(event KeyEvent) bool
	OnPaste func(event PasteEvent) bool
	OnMouse func(event MouseEvent) bool
}

SimpleEventHandler is a simple implementation of the event handling methods required for components.

func (*SimpleEventHandler) OnKeyEvent

func (seh *SimpleEventHandler) OnKeyEvent(event KeyEvent) bool

func (*SimpleEventHandler) OnMouseEvent

func (seh *SimpleEventHandler) OnMouseEvent(event MouseEvent) bool

func (*SimpleEventHandler) OnPasteEvent

func (seh *SimpleEventHandler) OnPasteEvent(event PasteEvent) bool

type TextField

type TextField struct {
	sync.Mutex
	*SimpleEventHandler
	// contains filtered or unexported fields
}

func NewTextField

func NewTextField() *TextField

func (*TextField) Draw

func (tf *TextField) Draw(screen Screen)

func (*TextField) SetBackgroundColor

func (tf *TextField) SetBackgroundColor(color tcell.Color) *TextField

func (*TextField) SetStyle

func (tf *TextField) SetStyle(style tcell.Style) *TextField

func (*TextField) SetText

func (tf *TextField) SetText(text string) *TextField

func (*TextField) SetTextColor

func (tf *TextField) SetTextColor(color tcell.Color) *TextField

type TextView

type TextView struct {
	sync.Mutex
	// contains filtered or unexported fields
}

TextView is a box which displays text. It implements the io.Writer interface so you can stream text to it. This does not trigger a redraw automatically but if a handler is installed via SetChangedFunc(), you can cause it to be redrawn. (See SetChangedFunc() for more details.)

Navigation

If the text view is scrollable (the default), text is kept in a buffer which may be larger than the screen and can be navigated similarly to Vim:

  • h, left arrow: Move left.
  • l, right arrow: Move right.
  • j, down arrow: Move down.
  • k, up arrow: Move up.
  • g, home: Move to the top.
  • G, end: Move to the bottom.
  • Ctrl-F, page down: Move down by one page.
  • Ctrl-B, page up: Move up by one page.

If the text is not scrollable, any text above the top visible line is discarded.

Use SetInputCapture() to override or modify keyboard input.

Colors

If dynamic colors are enabled via SetDynamicColors(), text color can be changed dynamically by embedding color strings in square brackets. This works the same way as anywhere else. Please see the package documentation for more information.

Regions and Highlights

If regions are enabled via SetRegions(), you can define text regions within the text and assign region IDs to them. Text regions start with region tags. Region tags are square brackets that contain a region ID in double quotes, for example:

We define a ["rg"]region[""] here.

A text region ends with the next region tag. Tags with no region ID ([""]) don't start new regions. They can therefore be used to mark the end of a region. Region IDs must satisfy the following regular expression:

[a-zA-Z0-9_,;: \-\.]+

Regions can be highlighted by calling the Highlight() function with one or more region IDs. This can be used to display search results, for example.

The ScrollToHighlight() function can be used to jump to the currently highlighted region once when the text view is drawn the next time.

See https://github.com/rivo/tview/wiki/TextView for an example.

func NewTextView

func NewTextView() *TextView

NewTextView returns a new text view.

func (*TextView) Clear

func (t *TextView) Clear() *TextView

Clear removes all text from the buffer.

func (*TextView) Draw

func (t *TextView) Draw(screen Screen)

Draw draws this primitive onto the screen.

func (*TextView) GetHighlights

func (t *TextView) GetHighlights() (regionIDs []string)

GetHighlights returns the IDs of all currently highlighted regions.

func (*TextView) GetRegionText

func (t *TextView) GetRegionText(regionID string) string

GetRegionText returns the text of the region with the given ID. If dynamic colors are enabled, color tags are stripped from the text. Newlines are always returned as '\n' runes.

If the region does not exist or if regions are turned off, an empty string is returned.

func (*TextView) GetScrollOffset

func (t *TextView) GetScrollOffset() (row, column int)

GetScrollOffset returns the number of rows and columns that are skipped at the top left corner when the text view has been scrolled.

func (*TextView) Highlight

func (t *TextView) Highlight(regionIDs ...string) *TextView

Highlight specifies which regions should be highlighted. See class description for details on regions. Empty region strings are ignored.

Text in highlighted regions will be drawn inverted, i.e. with their background and foreground colors swapped.

Calling this function will remove any previous highlights. To remove all highlights, call this function without any arguments.

func (*TextView) OnKeyEvent

func (t *TextView) OnKeyEvent(event KeyEvent) bool

func (*TextView) OnMouseEvent

func (t *TextView) OnMouseEvent(event MouseEvent) bool

func (*TextView) OnPasteEvent

func (t *TextView) OnPasteEvent(event PasteEvent) bool

func (*TextView) ScrollTo

func (t *TextView) ScrollTo(row, column int) *TextView

ScrollTo scrolls to the specified row and column (both starting with 0).

func (*TextView) ScrollToBeginning

func (t *TextView) ScrollToBeginning() *TextView

ScrollToBeginning scrolls to the top left corner of the text if the text view is scrollable.

func (*TextView) ScrollToEnd

func (t *TextView) ScrollToEnd() *TextView

ScrollToEnd scrolls to the bottom left corner of the text if the text view is scrollable. Adding new rows to the end of the text view will cause it to scroll with the new data.

func (*TextView) ScrollToHighlight

func (t *TextView) ScrollToHighlight() *TextView

ScrollToHighlight will cause the visible area to be scrolled so that the highlighted regions appear in the visible area of the text view. This repositioning happens the next time the text view is drawn. It happens only once so you will need to call this function repeatedly to always keep highlighted regions in view.

Nothing happens if there are no highlighted regions or if the text view is not scrollable.

func (*TextView) SetBackgroundColor

func (t *TextView) SetBackgroundColor(color tcell.Color) *TextView

func (*TextView) SetChangedFunc

func (t *TextView) SetChangedFunc(handler func()) *TextView

SetChangedFunc sets a handler function which is called when the text of the text view has changed. This is useful when text is written to this io.Writer in a separate goroutine. This does not automatically cause the screen to be refreshed so you may want to use the "changed" handler to redraw the screen.

Note that to avoid race conditions or deadlocks, there are a few rules you should follow:

  • You can call Application.Draw() from this handler.
  • You can call TextView.HasFocus() from this handler.
  • During the execution of this handler, access to any other variables from this primitive or any other primitive should be queued using Application.QueueUpdate().

See package description for details on dealing with concurrency.

func (*TextView) SetDoneFunc

func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView

SetDoneFunc sets a handler which is called when the user presses on the following keys: Escape, Enter, Tab, Backtab. The key is passed to the handler.

func (*TextView) SetDynamicColors

func (t *TextView) SetDynamicColors(dynamic bool) *TextView

SetDynamicColors sets the flag that allows the text color to be changed dynamically. See class description for details.

func (*TextView) SetRegions

func (t *TextView) SetRegions(regions bool) *TextView

SetRegions sets the flag that allows to define regions in the text. See class description for details.

func (*TextView) SetScrollable

func (t *TextView) SetScrollable(scrollable bool) *TextView

SetScrollable sets the flag that decides whether or not the text view is scrollable. If true, text is kept in a buffer and can be navigated.

func (*TextView) SetText

func (t *TextView) SetText(text string) *TextView

SetText sets the text of this text view to the provided string. Previously contained text will be removed.

func (*TextView) SetTextAlign

func (t *TextView) SetTextAlign(align int) *TextView

SetTextAlign sets the text alignment within the text view. This must be either AlignLeft, AlignCenter, or AlignRight.

func (*TextView) SetTextColor

func (t *TextView) SetTextColor(color tcell.Color) *TextView

SetTextColor sets the initial color of the text (which can be changed dynamically by sending color strings in square brackets to the text view if dynamic colors are enabled).

func (*TextView) SetWordWrap

func (t *TextView) SetWordWrap(wrapOnWords bool) *TextView

SetWordWrap sets the flag that, if true and if the "wrap" flag is also true (see SetWrap()), wraps the line at spaces or after punctuation marks. Note that trailing spaces will not be printed.

This flag is ignored if the "wrap" flag is false.

func (*TextView) SetWrap

func (t *TextView) SetWrap(wrap bool) *TextView

SetWrap sets the flag that, if true, leads to lines that are longer than the available width being wrapped onto the next line. If false, any characters beyond the available width are not displayed.

func (*TextView) Submit

func (t *TextView) Submit(event KeyEvent) bool

func (*TextView) Write

func (t *TextView) Write(p []byte) (n int, err error)

Write lets us implement the io.Writer interface. Tab characters will be replaced with TabSize space characters. A "\n" or "\r\n" will be interpreted as a new line.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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