Documentation ¶
Index ¶
- Constants
- Variables
- func Escape(text string) string
- func OffsetMouseEvent(evt MouseEvent, offsetX, offsetY int) *proxyEventMouse
- func Print(screen Screen, text string, x, y, maxWidth, align int, color tcell.Color) (int, int)
- func PrintJoinedSemigraphics(screen tcell.Screen, x, y int, ch rune, color tcell.Color)
- func PrintSimple(screen Screen, text string, x, y int)
- func PrintWithStyle(screen Screen, text string, x, y, maxWidth, align int, style tcell.Style) (int, int)
- func SubstringBefore(s string, w int) string
- func TaggedStringWidth(text string) int
- func WordWrap(text string, width int) (lines []string)
- type Application
- func (app *Application) ForceStop()
- func (app *Application) Redraw()
- func (app *Application) Screen() tcell.Screen
- func (app *Application) SetAlwaysClear(always bool)
- func (app *Application) SetRedrawTicker(tick time.Duration)
- func (app *Application) SetRoot(view Component)
- func (app *Application) Start() error
- func (app *Application) Stop()
- func (app *Application) Suspend(wait func())
- type Box
- func (box *Box) Blur()
- func (box *Box) Draw(screen Screen)
- func (box *Box) Focus()
- func (box *Box) OnKeyEvent(event KeyEvent) bool
- func (box *Box) OnMouseEvent(event MouseEvent) bool
- func (box *Box) OnPasteEvent(event PasteEvent) bool
- func (box *Box) SetBackgroundColor(color tcell.Color) *Box
- func (box *Box) SetBlurCaptureFunc(blurCapture func() bool) *Box
- func (box *Box) SetBorder(border bool) *Box
- func (box *Box) SetBorderStyle(borderStyle tcell.Style) *Box
- func (box *Box) SetFocusCaptureFunc(focusCapture func() bool) *Box
- func (box *Box) SetInnerComponent(component Component) *Box
- func (box *Box) SetKeyCaptureFunc(keyCapture KeyCaptureFunc) *Box
- func (box *Box) SetMouseCaptureFunc(mouseCapture MouseCaptureFunc) *Box
- func (box *Box) SetPasteCaptureFunc(pasteCapture PasteCaptureFunc) *Box
- func (box *Box) SetTitle(title string) *Box
- type Button
- func (b *Button) Blur()
- func (b *Button) Draw(screen Screen)
- func (b *Button) Focus()
- func (b *Button) OnKeyEvent(event KeyEvent) bool
- func (b *Button) OnMouseEvent(event MouseEvent) bool
- func (b *Button) OnPasteEvent(event PasteEvent) bool
- func (b *Button) SetBackgroundColor(color tcell.Color) *Button
- func (b *Button) SetFocusedBackgroundColor(color tcell.Color) *Button
- func (b *Button) SetFocusedForegroundColor(color tcell.Color) *Button
- func (b *Button) SetFocusedStyle(style tcell.Style) *Button
- func (b *Button) SetForegroundColor(color tcell.Color) *Button
- func (b *Button) SetOnClick(fn func()) *Button
- func (b *Button) SetStyle(style tcell.Style) *Button
- func (b *Button) SetText(text string) *Button
- func (b *Button) Submit(event KeyEvent) bool
- type Centerer
- func (center *Centerer) Blur()
- func (center *Centerer) Draw(screen Screen)
- func (center *Centerer) Focus()
- func (center *Centerer) OnKeyEvent(evt KeyEvent) bool
- func (center *Centerer) OnMouseEvent(evt MouseEvent) bool
- func (center *Centerer) OnPasteEvent(evt PasteEvent) bool
- func (center *Centerer) SetAlwaysFocusChild(always bool) *Centerer
- func (center *Centerer) SetHeight(height int)
- func (center *Centerer) SetSize(width, height int)
- func (center *Centerer) SetWidth(width int)
- type Component
- type Flex
- func (flex *Flex) AddFixedComponent(comp Component, size int) *Flex
- func (flex *Flex) AddProportionalComponent(comp Component, size int) *Flex
- func (flex *Flex) Blur()
- func (flex *Flex) Draw(screen Screen)
- func (flex *Flex) Focus()
- func (flex *Flex) OnKeyEvent(event KeyEvent) bool
- func (flex *Flex) OnMouseEvent(event MouseEvent) bool
- func (flex *Flex) OnPasteEvent(event PasteEvent) bool
- func (flex *Flex) RemoveComponent(comp Component) *Flex
- func (flex *Flex) SetDirection(direction FlexDirection) *Flex
- func (flex *Flex) SetFocused(comp Component)
- type FlexDirection
- type Focusable
- type FocusableComponent
- type Form
- func (form *Form) AddFormItem(comp Component, x, y, width, height int) *Form
- func (form *Form) Draw(screen Screen)
- func (form *Form) FocusNextItem()
- func (form *Form) FocusPreviousItem()
- func (form *Form) OnKeyEvent(event KeyEvent) bool
- func (form *Form) RemoveFormItem(comp Component) *Form
- func (form *Form) SetOnFocusChanged(fn func(from, to Component)) *Form
- type FormItem
- type FractionalCenterer
- func (fc *FractionalCenterer) Blur()
- func (fc *FractionalCenterer) Draw(screen Screen)
- func (fc *FractionalCenterer) Focus()
- func (fc *FractionalCenterer) OnKeyEvent(evt KeyEvent) bool
- func (fc *FractionalCenterer) OnMouseEvent(evt MouseEvent) bool
- func (fc *FractionalCenterer) OnPasteEvent(evt PasteEvent) bool
- func (fc *FractionalCenterer) SetAlwaysFocusChild(always bool) *FractionalCenterer
- type Grid
- func (grid *Grid) AddComponent(comp Component, x, y, width, height int) *Grid
- func (grid *Grid) Blur()
- func (grid *Grid) Draw(screen Screen)
- func (grid *Grid) Focus()
- func (grid *Grid) OnKeyEvent(event KeyEvent) bool
- func (grid *Grid) OnMouseEvent(event MouseEvent) bool
- func (grid *Grid) OnPasteEvent(event PasteEvent) bool
- func (grid *Grid) OnResize(width, height int)
- func (grid *Grid) RemoveComponent(comp Component) *Grid
- func (grid *Grid) SetColumn(col, width int) *Grid
- func (grid *Grid) SetColumns(columns []int) *Grid
- func (grid *Grid) SetRow(row, height int) *Grid
- func (grid *Grid) SetRows(rows []int) *Grid
- type InputArea
- func (field *InputArea) Blur()
- func (field *InputArea) Clear()
- func (field *InputArea) ClearSelection()
- func (field *InputArea) Copy()
- func (field *InputArea) Cut()
- func (field *InputArea) Draw(screen Screen)
- func (field *InputArea) ExtendSelection(x, y int)
- func (field *InputArea) Focus()
- func (field *InputArea) GetCursorOffset() int
- func (field *InputArea) GetCursorPos() (int, int)
- func (field *InputArea) GetSelectedText() string
- func (field *InputArea) GetSelection() (int, int)
- func (field *InputArea) GetText() string
- func (field *InputArea) GetTextHeight() int
- func (field *InputArea) MoveCursorDown(extendSelection bool)
- func (field *InputArea) MoveCursorEnd(extendSelection bool)
- func (field *InputArea) MoveCursorHome(extendSelection bool)
- func (field *InputArea) MoveCursorLeft(moveWord, extendSelection bool)
- func (field *InputArea) MoveCursorRight(moveWord, extendSelection bool)
- func (field *InputArea) MoveCursorUp(extendSelection bool)
- func (field *InputArea) OnKeyEvent(event KeyEvent) bool
- func (field *InputArea) OnMouseEvent(event MouseEvent) bool
- func (field *InputArea) OnPasteEvent(event PasteEvent) bool
- func (field *InputArea) Paste()
- func (field *InputArea) PrepareDraw(width int)
- func (field *InputArea) Redo()
- func (field *InputArea) RemoveNextCharacter()
- func (field *InputArea) RemovePreviousCharacter()
- func (field *InputArea) RemovePreviousWord()
- func (field *InputArea) RemoveSelection()
- func (field *InputArea) SelectAll()
- func (field *InputArea) SetBackgroundColor(color tcell.Color) *InputArea
- func (field *InputArea) SetChangedFunc(handler func(text string)) *InputArea
- func (field *InputArea) SetCursorOffset(offset int)
- func (field *InputArea) SetCursorPos(x, y int)
- func (field *InputArea) SetPlaceholder(text string) *InputArea
- func (field *InputArea) SetPlaceholderTextColor(color tcell.Color) *InputArea
- func (field *InputArea) SetPressKeyDownAtEndFunc(handler func()) *InputArea
- func (field *InputArea) SetPressKeyUpAtStartFunc(handler func()) *InputArea
- func (field *InputArea) SetSelection(start, end int)
- func (field *InputArea) SetTabCompleteFunc(handler func(text string, cursorOffset int)) *InputArea
- func (field *InputArea) SetText(text string) *InputArea
- func (field *InputArea) SetTextAndMoveCursor(text string) *InputArea
- func (field *InputArea) SetTextColor(color tcell.Color) *InputArea
- func (field *InputArea) TypeRune(ch rune)
- func (field *InputArea) Undo()
- type InputField
- func (field *InputField) Blur()
- func (field *InputField) Clear()
- func (field *InputField) Draw(screen Screen)
- func (field *InputField) Focus()
- func (field *InputField) GetCursorOffset() int
- func (field *InputField) GetText() string
- func (field *InputField) MoveCursorLeft(moveWord bool)
- func (field *InputField) MoveCursorRight(moveWord bool)
- func (field *InputField) OnKeyEvent(event KeyEvent) bool
- func (field *InputField) OnMouseEvent(event MouseEvent) bool
- func (field *InputField) OnPasteEvent(event PasteEvent) bool
- func (field *InputField) RemoveNextCharacter()
- func (field *InputField) RemovePreviousCharacter()
- func (field *InputField) RemovePreviousWord()
- func (field *InputField) SetBackgroundColor(color tcell.Color) *InputField
- func (field *InputField) SetChangedFunc(handler func(text string)) *InputField
- func (field *InputField) SetCursorOffset(offset int) *InputField
- func (field *InputField) SetMaskCharacter(mask rune) *InputField
- func (field *InputField) SetPlaceholder(text string) *InputField
- func (field *InputField) SetPlaceholderTextColor(color tcell.Color) *InputField
- func (field *InputField) SetTabCompleteFunc(handler func(text string, cursorOffset int)) *InputField
- func (field *InputField) SetText(text string) *InputField
- func (field *InputField) SetTextAndMoveCursor(text string) *InputField
- func (field *InputField) SetTextColor(color tcell.Color) *InputField
- func (field *InputField) Submit(event KeyEvent) bool
- func (field *InputField) TypeRune(ch rune)
- type KeyCaptureFunc
- type KeyEvent
- type MouseCaptureFunc
- type MouseEvent
- type NoopEventHandler
- type PasteCaptureFunc
- type PasteEvent
- type ProgressBar
- type ProxyScreen
- func (ss *ProxyScreen) CanDisplay(r rune, checkFallbacks bool) bool
- func (ss *ProxyScreen) CharacterSet() string
- func (ss *ProxyScreen) Clear()
- func (ss *ProxyScreen) Colors() int
- func (ss *ProxyScreen) Fill(r rune, style tcell.Style)
- func (ss *ProxyScreen) GetContent(x, y int) (mainc rune, combc []rune, style tcell.Style, width int)
- func (ss *ProxyScreen) HasKey(key tcell.Key) bool
- func (ss *ProxyScreen) HideCursor()
- func (ss *ProxyScreen) IsInArea(x, y int) bool
- func (ss *ProxyScreen) OffsetMouseEvent(event MouseEvent) MouseEvent
- func (ss *ProxyScreen) SetCell(x, y int, style tcell.Style, ch ...rune)
- func (ss *ProxyScreen) SetContent(x int, y int, mainc rune, combc []rune, style tcell.Style)
- func (ss *ProxyScreen) SetStyle(style tcell.Style)
- func (ss *ProxyScreen) ShowCursor(x, y int)
- func (ss *ProxyScreen) Size() (width int, height int)
- func (ss *ProxyScreen) XEnd() int
- func (ss *ProxyScreen) YEnd() int
- type Screen
- type SimpleEventHandler
- type TextField
- type TextView
- func (t *TextView) Clear() *TextView
- func (t *TextView) Draw(screen Screen)
- func (t *TextView) GetHighlights() (regionIDs []string)
- func (t *TextView) GetRegionText(regionID string) string
- func (t *TextView) GetScrollOffset() (row, column int)
- func (t *TextView) Highlight(regionIDs ...string) *TextView
- func (t *TextView) OnKeyEvent(event KeyEvent) bool
- func (t *TextView) OnMouseEvent(event MouseEvent) bool
- func (t *TextView) OnPasteEvent(event PasteEvent) bool
- func (t *TextView) ScrollTo(row, column int) *TextView
- func (t *TextView) ScrollToBeginning() *TextView
- func (t *TextView) ScrollToEnd() *TextView
- func (t *TextView) ScrollToHighlight() *TextView
- func (t *TextView) SetBackgroundColor(color tcell.Color) *TextView
- func (t *TextView) SetChangedFunc(handler func()) *TextView
- func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView
- func (t *TextView) SetDynamicColors(dynamic bool) *TextView
- func (t *TextView) SetRegions(regions bool) *TextView
- func (t *TextView) SetScrollable(scrollable bool) *TextView
- func (t *TextView) SetText(text string) *TextView
- func (t *TextView) SetTextAlign(align int) *TextView
- func (t *TextView) SetTextColor(color tcell.Color) *TextView
- func (t *TextView) SetWordWrap(wrapOnWords bool) *TextView
- func (t *TextView) SetWrap(wrap bool) *TextView
- func (t *TextView) Submit(event KeyEvent) bool
- func (t *TextView) Write(p []byte) (n int, err error)
Constants ¶
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.
const ( AlignLeft = iota AlignCenter AlignRight )
Text alignment within a box.
Variables ¶
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.
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.
var Blocks = [9]rune{' ', '▏', '▎', '▍', '▌', '▋', '▊', '▉', '█'}
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.
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 (│) + (─) = (┼)
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.
var TabSize = 4
TabSize is the number of spaces with which a tab character will be replaced.
Functions ¶
func Escape ¶
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 ¶
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 ¶
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 ¶
PrintSimple prints white text to the screen at the given position.
func PrintWithStyle ¶
func SubstringBefore ¶
func TaggedStringWidth ¶
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 ¶
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 (*Box) OnKeyEvent ¶
func (*Box) OnMouseEvent ¶
func (box *Box) OnMouseEvent(event MouseEvent) bool
func (*Box) OnPasteEvent ¶
func (box *Box) OnPasteEvent(event PasteEvent) bool
func (*Box) SetBlurCaptureFunc ¶
func (*Box) SetFocusCaptureFunc ¶
func (*Box) SetInnerComponent ¶
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
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
func (*Button) OnKeyEvent ¶
func (*Button) OnMouseEvent ¶
func (b *Button) OnMouseEvent(event MouseEvent) bool
func (*Button) OnPasteEvent ¶
func (b *Button) OnPasteEvent(event PasteEvent) bool
func (*Button) SetFocusedBackgroundColor ¶
func (*Button) SetFocusedForegroundColor ¶
func (*Button) SetOnClick ¶
type Centerer ¶
type Centerer struct {
// contains filtered or unexported fields
}
func (*Centerer) OnKeyEvent ¶
func (*Centerer) OnMouseEvent ¶
func (center *Centerer) OnMouseEvent(evt MouseEvent) bool
func (*Centerer) OnPasteEvent ¶
func (center *Centerer) OnPasteEvent(evt PasteEvent) bool
func (*Centerer) SetAlwaysFocusChild ¶
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 (*Flex) AddFixedComponent ¶
func (*Flex) AddProportionalComponent ¶
func (*Flex) OnKeyEvent ¶
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) SetDirection ¶
func (flex *Flex) SetDirection(direction FlexDirection) *Flex
func (*Flex) SetFocused ¶
type FocusableComponent ¶
type Form ¶
type Form struct { *Grid // contains filtered or unexported fields }
func (*Form) AddFormItem ¶
func (*Form) FocusNextItem ¶
func (form *Form) FocusNextItem()
func (*Form) FocusPreviousItem ¶
func (form *Form) FocusPreviousItem()
func (*Form) OnKeyEvent ¶
func (*Form) RemoveFormItem ¶
func (*Form) SetOnFocusChanged ¶
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 (*Grid) AddComponent ¶
func (*Grid) OnKeyEvent ¶
func (*Grid) OnMouseEvent ¶
func (grid *Grid) OnMouseEvent(event MouseEvent) bool
func (*Grid) OnPasteEvent ¶
func (grid *Grid) OnPasteEvent(event PasteEvent) bool
func (*Grid) RemoveComponent ¶
func (*Grid) SetColumns ¶
type InputArea ¶
type InputArea struct {
// contains filtered or unexported fields
}
InputArea is a multi-line user-editable text 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) ExtendSelection ¶
ExtendSelection extends the selection as if the user dragged their mouse to the given coordinates.
func (*InputArea) GetCursorOffset ¶
func (*InputArea) GetCursorPos ¶
func (*InputArea) GetSelectedText ¶
func (*InputArea) GetSelection ¶
func (*InputArea) GetTextHeight ¶
GetTextHeight returns the number of lines in the text during the previous render.
func (*InputArea) MoveCursorDown ¶
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 (*InputArea) MoveCursorHome ¶
func (*InputArea) MoveCursorLeft ¶
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 ¶
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 ¶
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 ¶
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 (*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 ¶
SetBackgroundColor sets the background color of the input area.
func (*InputArea) SetChangedFunc ¶
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 ¶
SetCursorOffset sets the runewidth cursor offset.
func (*InputArea) SetCursorPos ¶
SetCursorPos sets the X and Y cursor offsets.
func (*InputArea) SetPlaceholder ¶
SetPlaceholder sets the text to be displayed when the input text is empty.
func (*InputArea) SetPlaceholderTextColor ¶
SetPlaceholderTextColor sets the text color of placeholder text.
func (*InputArea) SetPressKeyDownAtEndFunc ¶
func (*InputArea) SetPressKeyUpAtStartFunc ¶
func (*InputArea) SetSelection ¶
func (*InputArea) SetTabCompleteFunc ¶
func (*InputArea) SetTextAndMoveCursor ¶
SetTextAndMoveCursor sets the current text of the input field and moves the cursor with the width difference.
func (*InputArea) SetTextColor ¶
SetTextColor sets the text color of the input area.
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 (*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 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 ¶
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 ¶
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) GetContent ¶
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 (*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 ¶
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) SetBackgroundColor ¶
type TextView ¶
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 (*TextView) GetHighlights ¶
GetHighlights returns the IDs of all currently highlighted regions.
func (*TextView) GetRegionText ¶
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 ¶
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 ¶
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 (*TextView) OnMouseEvent ¶
func (t *TextView) OnMouseEvent(event MouseEvent) bool
func (*TextView) OnPasteEvent ¶
func (t *TextView) OnPasteEvent(event PasteEvent) bool
func (*TextView) ScrollTo ¶
ScrollTo scrolls to the specified row and column (both starting with 0).
func (*TextView) ScrollToBeginning ¶
ScrollToBeginning scrolls to the top left corner of the text if the text view is scrollable.
func (*TextView) ScrollToEnd ¶
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 ¶
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 (*TextView) SetChangedFunc ¶
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 ¶
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 ¶
SetDynamicColors sets the flag that allows the text color to be changed dynamically. See class description for details.
func (*TextView) SetRegions ¶
SetRegions sets the flag that allows to define regions in the text. See class description for details.
func (*TextView) SetScrollable ¶
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 ¶
SetText sets the text of this text view to the provided string. Previously contained text will be removed.
func (*TextView) SetTextAlign ¶
SetTextAlign sets the text alignment within the text view. This must be either AlignLeft, AlignCenter, or AlignRight.
func (*TextView) SetTextColor ¶
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 ¶
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.