Documentation
¶
Index ¶
- Constants
- Variables
- func Print(screen tcell.Screen, text string, x, y, maxWidth int, alignment Alignment, ...) (int, int)
- func PrintJoinedSemigraphics(screen tcell.Screen, x, y int, str string, style tcell.Style)
- func PrintSimple(screen tcell.Screen, text string, x, y int)
- func PrintWithStyle(screen tcell.Screen, text string, x, y, maxWidth int, alignment Alignment, ...) (int, int)
- func TaggedStringWidth(text string) (width int)
- func WordWrap(text string, width int) []string
- type Alignment
- type Application
- func (a *Application) Focused() Model
- func (a *Application) Run() error
- func (a *Application) Send(msg Msg) *Application
- func (a *Application) SetCatchPanics(catchPanics bool) *Application
- func (a *Application) SetRoot(root Model) *Application
- func (a *Application) SetScreen(screen tcell.Screen) *Application
- func (a *Application) Suspend(f func()) bool
- type BorderSet
- type Borders
- type Box
- func (b *Box) Blur()
- func (b *Box) BorderPadding() (top, bottom, left, right int)
- func (b *Box) Borders() Borders
- func (b *Box) Draw(screen tcell.Screen)
- func (b *Box) DrawForSubclass(screen tcell.Screen, p Model)
- func (b *Box) Focus(delegate func(m Model))
- func (b *Box) GetBackgroundColor() tcell.Color
- func (b *Box) GetBorderSet() BorderSet
- func (b *Box) GetFooter() string
- func (b *Box) HasFocus() bool
- func (b *Box) InInnerRect(x, y int) bool
- func (b *Box) InRect(x, y int) bool
- func (b *Box) InnerRect() (int, int, int, int)
- func (b *Box) Rect() (int, int, int, int)
- func (b *Box) SetBackgroundColor(color tcell.Color) *Box
- func (b *Box) SetBlurFunc(callback func()) *Box
- func (b *Box) SetBorderPadding(top, bottom, left, right int) *Box
- func (b *Box) SetBorderSet(borderSet BorderSet) *Box
- func (b *Box) SetBorderStyle(style tcell.Style) *Box
- func (b *Box) SetBorders(flag Borders) *Box
- func (b *Box) SetDontClear(dontClear bool) *Box
- func (b *Box) SetFocusFunc(callback func()) *Box
- func (b *Box) SetFooter(footer string) *Box
- func (b *Box) SetFooterAlignment(alignment Alignment) *Box
- func (b *Box) SetFooterStyle(style tcell.Style) *Box
- func (b *Box) SetRect(x, y, width, height int)
- func (b *Box) SetTitle(title string) *Box
- func (b *Box) SetTitleAlignment(alignment Alignment) *Box
- func (b *Box) SetTitleStyle(style tcell.Style) *Box
- func (b *Box) Title() string
- func (b *Box) Update(msg Msg) Cmd
- type Button
- func (b *Button) Draw(screen tcell.Screen)
- func (b *Button) GetDisabled() bool
- func (b *Button) GetLabel() string
- func (b *Button) SetActivatedStyle(style tcell.Style) *Button
- func (b *Button) SetBackgroundColorActivated(color tcell.Color) *Button
- func (b *Button) SetDisabled(disabled bool) *Button
- func (b *Button) SetDisabledStyle(style tcell.Style) *Button
- func (b *Button) SetLabel(label string) *Button
- func (b *Button) SetLabelColor(color tcell.Color) *Button
- func (b *Button) SetLabelColorActivated(color tcell.Color) *Button
- func (b *Button) SetStyle(style tcell.Style) *Button
- func (b *Button) Update(msg Msg) Cmd
- type ButtonExitMsg
- type ButtonSelectedMsg
- type Checkbox
- func (c *Checkbox) Draw(screen tcell.Screen)
- func (c *Checkbox) Focus(delegate func(m Model))
- func (c *Checkbox) GetDisabled() bool
- func (c *Checkbox) GetFieldHeight() int
- func (c *Checkbox) GetFieldWidth() int
- func (c *Checkbox) GetLabel() string
- func (c *Checkbox) IsChecked() bool
- func (c *Checkbox) SetActivatedStyle(style tcell.Style) *Checkbox
- func (c *Checkbox) SetChangedFunc(handler func(checked bool)) *Checkbox
- func (c *Checkbox) SetChecked(checked bool) *Checkbox
- func (c *Checkbox) SetCheckedString(checked string) *Checkbox
- func (c *Checkbox) SetCheckedStyle(style tcell.Style) *Checkbox
- func (c *Checkbox) SetDisabled(disabled bool) FormItem
- func (c *Checkbox) SetDoneFunc(handler func(key tcell.Key)) *Checkbox
- func (c *Checkbox) SetFieldBackgroundColor(color tcell.Color) *Checkbox
- func (c *Checkbox) SetFieldTextColor(color tcell.Color) *Checkbox
- func (c *Checkbox) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (c *Checkbox) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
- func (c *Checkbox) SetLabel(label string) *Checkbox
- func (c *Checkbox) SetLabelColor(color tcell.Color) *Checkbox
- func (c *Checkbox) SetLabelStyle(style tcell.Style) *Checkbox
- func (c *Checkbox) SetLabelWidth(width int) *Checkbox
- func (c *Checkbox) SetUncheckedString(unchecked string) *Checkbox
- func (c *Checkbox) SetUncheckedStyle(style tcell.Style) *Checkbox
- func (c *Checkbox) Update(msg Msg) Cmd
- type Cmd
- type Form
- func (f *Form) AddButton(label string) *Form
- func (f *Form) AddCheckbox(label string, checked bool, changed func(checked bool)) *Form
- func (f *Form) AddFormItem(item FormItem) *Form
- func (f *Form) AddInputField(label, value string, fieldWidth int, changed func(text string)) *Form
- func (f *Form) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string)) *Form
- func (f *Form) AddTextArea(label, text string, fieldWidth, fieldHeight, maxLength int, ...) *Form
- func (f *Form) AddTextView(label, text string, fieldWidth, fieldHeight int, scrollable bool) *Form
- func (f *Form) Clear(includeButtons bool) *Form
- func (f *Form) ClearButtons() *Form
- func (f *Form) Draw(screen tcell.Screen)
- func (f *Form) Focus(delegate func(m Model))
- func (f *Form) GetButton(index int) *Button
- func (f *Form) GetButtonCount() int
- func (f *Form) GetButtonIndex(label string) int
- func (f *Form) GetFocusedItemIndex() (formItem, button int)
- func (f *Form) GetFormItem(index int) FormItem
- func (f *Form) GetFormItemByLabel(label string) FormItem
- func (f *Form) GetFormItemCount() int
- func (f *Form) GetFormItemIndex(label string) int
- func (f *Form) HasFocus() bool
- func (f *Form) RemoveButton(index int) *Form
- func (f *Form) RemoveFormItem(index int) *Form
- func (f *Form) SetButtonActivatedStyle(style tcell.Style) *Form
- func (f *Form) SetButtonDisabledStyle(style tcell.Style) *Form
- func (f *Form) SetButtonStyle(style tcell.Style) *Form
- func (f *Form) SetButtonsAlignment(alignment Alignment) *Form
- func (f *Form) SetFieldStyle(style tcell.Style) *Form
- func (f *Form) SetFocus(index int) *Form
- func (f *Form) SetHorizontal(horizontal bool) *Form
- func (f *Form) SetItemPadding(padding int) *Form
- func (f *Form) SetLabelColor(color tcell.Color) *Form
- func (f *Form) Update(msg Msg) Cmd
- type FormCancelMsg
- type FormItem
- type FormSubmitMsg
- type Frame
- func (f *Frame) AddText(text string, header bool, alignment Alignment, color tcell.Color) *Frame
- func (f *Frame) Clear() *Frame
- func (f *Frame) Draw(screen tcell.Screen)
- func (f *Frame) Focus(delegate func(m Model))
- func (f *Frame) GetPrimitive() Model
- func (f *Frame) HasFocus() bool
- func (f *Frame) SetBorders(top, bottom, header, footer, left, right int) *Frame
- func (f *Frame) SetPrimitive(m Model) *Frame
- func (f *Frame) Update(msg Msg) Cmd
- type GlyphSet
- type Grid
- func (g *Grid) AddItem(p Model, row, column, rowSpan, colSpan, minGridHeight, minGridWidth int, ...) *Grid
- func (g *Grid) Clear() *Grid
- func (g *Grid) Draw(screen tcell.Screen)
- func (g *Grid) Focus(delegate func(m Model))
- func (g *Grid) GetOffset() (rows, columns int)
- func (g *Grid) HasFocus() bool
- func (g *Grid) RemoveItem(m Model) *Grid
- func (g *Grid) SetBorders(borders bool) *Grid
- func (g *Grid) SetBordersColor(color tcell.Color) *Grid
- func (g *Grid) SetColumns(columns ...int) *Grid
- func (g *Grid) SetGap(row, column int) *Grid
- func (g *Grid) SetMinSize(row, column int) *Grid
- func (g *Grid) SetOffset(rows, columns int) *Grid
- func (g *Grid) SetRows(rows ...int) *Grid
- func (g *Grid) SetSize(numRows, numColumns, rowSize, columnSize int) *Grid
- func (g *Grid) Update(msg Msg) Cmd
- type InitMsg
- type InputField
- func (i *InputField) Blur()
- func (i *InputField) Draw(screen tcell.Screen)
- func (i *InputField) Focus(delegate func(m Model))
- func (i *InputField) GetDisabled() bool
- func (i *InputField) GetFieldHeight() int
- func (i *InputField) GetFieldStyle() tcell.Style
- func (i *InputField) GetFieldWidth() int
- func (i *InputField) GetLabel() string
- func (i *InputField) GetLabelStyle() tcell.Style
- func (i *InputField) GetText() string
- func (i *InputField) HasFocus() bool
- func (i *InputField) SetChangedFunc(handler func(text string)) *InputField
- func (i *InputField) SetDisabled(disabled bool) FormItem
- func (i *InputField) SetDoneFunc(handler func(key tcell.Key)) *InputField
- func (i *InputField) SetFieldStyle(style tcell.Style) *InputField
- func (i *InputField) SetFieldWidth(width int) *InputField
- func (i *InputField) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (i *InputField) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
- func (i *InputField) SetLabel(label string) *InputField
- func (i *InputField) SetLabelColor(color tcell.Color) *InputField
- func (i *InputField) SetLabelStyle(style tcell.Style) *InputField
- func (i *InputField) SetLabelWidth(width int) *InputField
- func (i *InputField) SetMaskCharacter(mask rune) *InputField
- func (i *InputField) SetPlaceholder(line Line) *InputField
- func (i *InputField) SetText(text string) *InputField
- func (i *InputField) Update(msg Msg) Cmd
- type KeyMsg
- type Line
- type LineBuilder
- type Modal
- func (m *Modal) AddButtons(labels []string) *Modal
- func (m *Modal) ClearButtons() *Modal
- func (m *Modal) Draw(screen tcell.Screen)
- func (m *Modal) Focus(delegate func(m Model))
- func (m *Modal) HasFocus() bool
- func (m *Modal) SetBackgroundColor(color tcell.Color) *Modal
- func (m *Modal) SetButtonActivatedStyle(style tcell.Style) *Modal
- func (m *Modal) SetButtonStyle(style tcell.Style) *Modal
- func (m *Modal) SetFocus(index int) *Modal
- func (m *Modal) SetText(text string) *Modal
- func (m *Modal) SetTextColor(color tcell.Color) *Modal
- func (m *Modal) Update(msg Msg) Cmd
- type ModalDoneMsg
- type Model
- type MouseAction
- type MouseMsg
- type Msg
- type PasteMsg
- type ScrollBar
- func (s *ScrollBar) Draw(screen tcell.Screen)
- func (s *ScrollBar) HasEndArrow() bool
- func (s *ScrollBar) HasStartArrow() bool
- func (s *ScrollBar) ScrollStep() int
- func (s *ScrollBar) SetArrowStyle(style tcell.Style) *ScrollBar
- func (s *ScrollBar) SetArrows(arrows ScrollBarArrows) *ScrollBar
- func (s *ScrollBar) SetAutoHide(autoHide bool) *ScrollBar
- func (s *ScrollBar) SetGlyphSet(g GlyphSet) *ScrollBar
- func (s *ScrollBar) SetLengths(lengths ScrollLengths) *ScrollBar
- func (s *ScrollBar) SetOffset(offset int) *ScrollBar
- func (s *ScrollBar) SetScrollStep(step int) *ScrollBar
- func (s *ScrollBar) SetThumbGlyph(glyph string) *ScrollBar
- func (s *ScrollBar) SetThumbStyle(style tcell.Style) *ScrollBar
- func (s *ScrollBar) SetTrackClickBehavior(behavior TrackClickBehavior) *ScrollBar
- func (s *ScrollBar) SetTrackGlyph(glyph string, visible bool) *ScrollBar
- func (s *ScrollBar) SetTrackStyle(style tcell.Style) *ScrollBar
- func (s *ScrollBar) TrackClickBehavior() TrackClickBehavior
- func (s *ScrollBar) TrackLengthExcludingArrowHeads(length int) int
- type ScrollBarArrows
- type ScrollLengths
- type Segment
- type TextArea
- func (t *TextArea) Draw(screen tcell.Screen)
- func (t *TextArea) Focus(delegate func(m Model))
- func (t *TextArea) GetClipboardText() string
- func (t *TextArea) GetCursor() (fromRow, fromColumn, toRow, toColumn int)
- func (t *TextArea) GetDisabled() bool
- func (t *TextArea) GetFieldHeight() int
- func (t *TextArea) GetFieldWidth() int
- func (t *TextArea) GetLabel() string
- func (t *TextArea) GetLabelStyle() tcell.Style
- func (t *TextArea) GetLabelWidth() int
- func (t *TextArea) GetOffset() (row, column int)
- func (t *TextArea) GetSelection() (text string, start int, end int)
- func (t *TextArea) GetText() string
- func (t *TextArea) GetTextLength() int
- func (t *TextArea) GetTextStyle() tcell.Style
- func (t *TextArea) GetWordUnderCursor(f func(rune) bool) (int, string, rune)
- func (t *TextArea) HasSelection() bool
- func (t *TextArea) Replace(start, end int, text string) *TextArea
- func (t *TextArea) Select(start, end int) *TextArea
- func (t *TextArea) SetChangedFunc(handler func()) *TextArea
- func (t *TextArea) SetClipboard(copyToClipboard func(string), pasteFromClipboard func() string) *TextArea
- func (t *TextArea) SetDisabled(disabled bool) FormItem
- func (t *TextArea) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (t *TextArea) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
- func (t *TextArea) SetLabel(label string) *TextArea
- func (t *TextArea) SetLabelStyle(style tcell.Style) *TextArea
- func (t *TextArea) SetLabelWidth(width int) *TextArea
- func (t *TextArea) SetMaxLength(maxLength int) *TextArea
- func (t *TextArea) SetMovedFunc(handler func()) *TextArea
- func (t *TextArea) SetOffset(row, column int) *TextArea
- func (t *TextArea) SetPlaceholder(placeholder Line) *TextArea
- func (t *TextArea) SetSelectedStyle(style tcell.Style) *TextArea
- func (t *TextArea) SetSize(rows, columns int) *TextArea
- func (t *TextArea) SetText(text string, cursorAtTheEnd bool) *TextArea
- func (t *TextArea) SetTextStyle(style tcell.Style) *TextArea
- func (t *TextArea) SetWordWrap(wrapOnWords bool) *TextArea
- func (t *TextArea) SetWrap(wrap bool) *TextArea
- func (t *TextArea) Update(msg Msg) Cmd
- type TextView
- func (t *TextView) AppendLine(line Line) *TextView
- func (t *TextView) AppendSegments(segments ...Segment) *TextView
- func (t *TextView) BatchWriter() TextViewWriter
- func (t *TextView) Clear() *TextView
- func (t *TextView) Draw(screen tcell.Screen)
- func (t *TextView) Focus(delegate func(m Model))
- func (t *TextView) GetDisabled() bool
- func (t *TextView) GetFieldHeight() int
- func (t *TextView) GetFieldWidth() int
- func (t *TextView) GetLabel() string
- func (t *TextView) GetLines() []Line
- func (t *TextView) GetOriginalLineCount() int
- func (t *TextView) GetScrollOffset() (row, column int)
- func (t *TextView) GetText() string
- func (t *TextView) GetWrappedLineCount() int
- func (t *TextView) HasFocus() bool
- func (t *TextView) Height(width int) int
- func (t *TextView) ScrollTo(row, column int) *TextView
- func (t *TextView) ScrollToBeginning() *TextView
- func (t *TextView) ScrollToEnd() *TextView
- func (t *TextView) SetBackgroundColor(color tcell.Color) *Box
- func (t *TextView) SetChangedFunc(handler func()) *TextView
- func (t *TextView) SetDisabled(disabled bool) FormItem
- func (t *TextView) SetDoneFunc(handler func(key tcell.Key)) *TextView
- func (t *TextView) SetFinishedFunc(handler func(key tcell.Key)) FormItem
- func (t *TextView) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
- func (t *TextView) SetLabel(label string) *TextView
- func (t *TextView) SetLabelWidth(width int) *TextView
- func (t *TextView) SetLines(lines []Line) *TextView
- func (t *TextView) SetMaxLines(maxLines int) *TextView
- func (t *TextView) SetScrollable(scrollable bool) *TextView
- func (t *TextView) SetSize(rows, columns int) *TextView
- func (t *TextView) SetText(text string) *TextView
- func (t *TextView) SetTextAlign(alignment Alignment) *TextView
- func (t *TextView) SetTextStyle(style tcell.Style) *TextView
- func (t *TextView) SetWordWrap(wrapOnWords bool) *TextView
- func (t *TextView) SetWrap(wrap bool) *TextView
- func (t *TextView) Update(msg Msg) Cmd
- func (t *TextView) Write(p []byte) (n int, err error)
- type TextViewWriter
- type Theme
- type TrackClickBehavior
- type TreeMarkers
- type TreeNode
- func (n *TreeNode) AddChild(node *TreeNode) *TreeNode
- func (n *TreeNode) ClearChildren() *TreeNode
- func (n *TreeNode) Collapse() *TreeNode
- func (n *TreeNode) CollapseAll() *TreeNode
- func (n *TreeNode) Expand() *TreeNode
- func (n *TreeNode) ExpandAll() *TreeNode
- func (n *TreeNode) GetChildren() []*TreeNode
- func (n *TreeNode) GetLevel() int
- func (n *TreeNode) GetLine() Line
- func (n *TreeNode) GetReference() any
- func (n *TreeNode) GetSelectedTextStyle() tcell.Style
- func (n *TreeNode) IsExpandable() bool
- func (n *TreeNode) IsExpanded() bool
- func (n *TreeNode) RemoveChild(node *TreeNode) *TreeNode
- func (n *TreeNode) SetChildren(childNodes []*TreeNode) *TreeNode
- func (n *TreeNode) SetExpandable(expandable bool) *TreeNode
- func (n *TreeNode) SetExpanded(expanded bool) *TreeNode
- func (n *TreeNode) SetIndent(indent int) *TreeNode
- func (n *TreeNode) SetLine(line Line) *TreeNode
- func (n *TreeNode) SetReference(reference any) *TreeNode
- func (n *TreeNode) SetSelectable(selectable bool) *TreeNode
- func (n *TreeNode) SetSelectedTextStyle(style tcell.Style) *TreeNode
- func (n *TreeNode) Walk(callback func(node, parent *TreeNode) bool) *TreeNode
- type TreeView
- func (t *TreeView) Draw(screen tcell.Screen)
- func (t *TreeView) GetCurrentNode() *TreeNode
- func (t *TreeView) GetMarkers() TreeMarkers
- func (t *TreeView) GetPath(node *TreeNode) []*TreeNode
- func (t *TreeView) GetRoot() *TreeNode
- func (t *TreeView) GetRowCount() int
- func (t *TreeView) GetScrollOffset() int
- func (t *TreeView) Move(offset int) *TreeView
- func (t *TreeView) SetAlign(align bool) *TreeView
- func (t *TreeView) SetCenterCursor(center bool) *TreeView
- func (t *TreeView) SetCurrentNode(node *TreeNode) *TreeView
- func (t *TreeView) SetGraphics(showGraphics bool) *TreeView
- func (t *TreeView) SetGraphicsColor(color tcell.Color) *TreeView
- func (t *TreeView) SetMarkers(markers TreeMarkers) *TreeView
- func (t *TreeView) SetPrefixes(prefixes []string) *TreeView
- func (t *TreeView) SetRoot(root *TreeNode) *TreeView
- func (t *TreeView) SetTopLevel(topLevel int) *TreeView
- func (t *TreeView) Update(msg Msg) Cmd
- type TreeViewSelectedMsg
Constants ¶
const ( // General Punctuation U+2000-U+206F SemigraphicsHorizontalEllipsis = "\u2026" // … // Box Drawing U+2500-U+257F BoxDrawingsLightHorizontal = "\u2500" // ─ BoxDrawingsHeavyHorizontal = "\u2501" // ━ BoxDrawingsLightVertical = "\u2502" // │ BoxDrawingsHeavyVertical = "\u2503" // ┃ BoxDrawingsLightTripleDashHorizontal = "\u2504" // ┄ BoxDrawingsHeavyTripleDashHorizontal = "\u2505" // ┅ BoxDrawingsLightTripleDashVertical = "\u2506" // ┆ BoxDrawingsHeavyTripleDashVertical = "\u2507" // ┇ BoxDrawingsLightQuadrupleDashHorizontal = "\u2508" // ┈ BoxDrawingsHeavyQuadrupleDashHorizontal = "\u2509" // ┉ BoxDrawingsLightQuadrupleDashVertical = "\u250a" // ┊ BoxDrawingsHeavyQuadrupleDashVertical = "\u250b" // ┋ BoxDrawingsLightDownAndRight = "\u250c" // ┌ BoxDrawingsDownLightAndRightHeavy = "\u250d" // ┍ BoxDrawingsDownHeavyAndRightLight = "\u250e" // ┎ BoxDrawingsHeavyDownAndRight = "\u250f" // ┏ BoxDrawingsLightDownAndLeft = "\u2510" // ┐ BoxDrawingsDownLightAndLeftHeavy = "\u2511" // ┑ BoxDrawingsDownHeavyAndLeftLight = "\u2512" // ┒ BoxDrawingsHeavyDownAndLeft = "\u2513" // ┓ BoxDrawingsLightUpAndRight = "\u2514" // └ BoxDrawingsUpLightAndRightHeavy = "\u2515" // ┕ BoxDrawingsUpHeavyAndRightLight = "\u2516" // ┖ BoxDrawingsHeavyUpAndRight = "\u2517" // ┗ BoxDrawingsLightUpAndLeft = "\u2518" // ┘ BoxDrawingsUpLightAndLeftHeavy = "\u2519" // ┙ BoxDrawingsUpHeavyAndLeftLight = "\u251a" // ┚ BoxDrawingsHeavyUpAndLeft = "\u251b" // ┛ BoxDrawingsLightVerticalAndRight = "\u251c" // ├ BoxDrawingsVerticalLightAndRightHeavy = "\u251d" // ┝ BoxDrawingsUpHeavyAndRightDownLight = "\u251e" // ┞ BoxDrawingsDownHeavyAndRightUpLight = "\u251f" // ┟ BoxDrawingsVerticalHeavyAndRightLight = "\u2520" // ┠ BoxDrawingsDownLightAndRightUpHeavy = "\u2521" // ┡ BoxDrawingsUpLightAndRightDownHeavy = "\u2522" // ┢ BoxDrawingsHeavyVerticalAndRight = "\u2523" // ┣ BoxDrawingsLightVerticalAndLeft = "\u2524" // ┤ BoxDrawingsVerticalLightAndLeftHeavy = "\u2525" // ┥ BoxDrawingsUpHeavyAndLeftDownLight = "\u2526" // ┦ BoxDrawingsDownHeavyAndLeftUpLight = "\u2527" // ┧ BoxDrawingsVerticalHeavyAndLeftLight = "\u2528" // ┨ BoxDrawingsDownLightAndLeftUpHeavy = "\u2529" // ┩ BoxDrawingsUpLightAndLeftDownHeavy = "\u252a" // ┪ BoxDrawingsHeavyVerticalAndLeft = "\u252b" // ┫ BoxDrawingsLightDownAndHorizontal = "\u252c" // ┬ BoxDrawingsLeftHeavyAndRightDownLight = "\u252d" // ┭ BoxDrawingsRightHeavyAndLeftDownLight = "\u252e" // ┮ BoxDrawingsDownLightAndHorizontalHeavy = "\u252f" // ┯ BoxDrawingsDownHeavyAndHorizontalLight = "\u2530" // ┰ BoxDrawingsRightLightAndLeftDownHeavy = "\u2531" // ┱ BoxDrawingsLeftLightAndRightDownHeavy = "\u2532" // ┲ BoxDrawingsHeavyDownAndHorizontal = "\u2533" // ┳ BoxDrawingsLightUpAndHorizontal = "\u2534" // ┴ BoxDrawingsLeftHeavyAndRightUpLight = "\u2535" // ┵ BoxDrawingsRightHeavyAndLeftUpLight = "\u2536" // ┶ BoxDrawingsUpLightAndHorizontalHeavy = "\u2537" // ┷ BoxDrawingsUpHeavyAndHorizontalLight = "\u2538" // ┸ BoxDrawingsRightLightAndLeftUpHeavy = "\u2539" // ┹ BoxDrawingsLeftLightAndRightUpHeavy = "\u253a" // ┺ BoxDrawingsHeavyUpAndHorizontal = "\u253b" // ┻ BoxDrawingsLightVerticalAndHorizontal = "\u253c" // ┼ BoxDrawingsLeftHeavyAndRightVerticalLight = "\u253d" // ┽ BoxDrawingsRightHeavyAndLeftVerticalLight = "\u253e" // ┾ BoxDrawingsVerticalLightAndHorizontalHeavy = "\u253f" // ┿ BoxDrawingsUpHeavyAndDownHorizontalLight = "\u2540" // ╀ BoxDrawingsDownHeavyAndUpHorizontalLight = "\u2541" // ╁ BoxDrawingsVerticalHeavyAndHorizontalLight = "\u2542" // ╂ BoxDrawingsLeftUpHeavyAndRightDownLight = "\u2543" // ╃ BoxDrawingsRightUpHeavyAndLeftDownLight = "\u2544" // ╄ BoxDrawingsLeftDownHeavyAndRightUpLight = "\u2545" // ╅ BoxDrawingsRightDownHeavyAndLeftUpLight = "\u2546" // ╆ BoxDrawingsDownLightAndUpHorizontalHeavy = "\u2547" // ╇ BoxDrawingsUpLightAndDownHorizontalHeavy = "\u2548" // ╈ BoxDrawingsRightLightAndLeftVerticalHeavy = "\u2549" // ╉ BoxDrawingsLeftLightAndRightVerticalHeavy = "\u254a" // ╊ BoxDrawingsHeavyVerticalAndHorizontal = "\u254b" // ╋ BoxDrawingsLightDoubleDashHorizontal = "\u254c" // ╌ BoxDrawingsHeavyDoubleDashHorizontal = "\u254d" // ╍ BoxDrawingsLightDoubleDashVertical = "\u254e" // ╎ BoxDrawingsHeavyDoubleDashVertical = "\u254f" // ╏ BoxDrawingsDoubleHorizontal = "\u2550" // ═ BoxDrawingsDoubleVertical = "\u2551" // ║ BoxDrawingsDownSingleAndRightDouble = "\u2552" // ╒ BoxDrawingsDownDoubleAndRightSingle = "\u2553" // ╓ BoxDrawingsDoubleDownAndRight = "\u2554" // ╔ BoxDrawingsDownSingleAndLeftDouble = "\u2555" // ╕ BoxDrawingsDownDoubleAndLeftSingle = "\u2556" // ╖ BoxDrawingsDoubleDownAndLeft = "\u2557" // ╗ BoxDrawingsUpSingleAndRightDouble = "\u2558" // ╘ BoxDrawingsUpDoubleAndRightSingle = "\u2559" // ╙ BoxDrawingsDoubleUpAndRight = "\u255a" // ╚ BoxDrawingsUpSingleAndLeftDouble = "\u255b" // ╛ BoxDrawingsUpDoubleAndLeftSingle = "\u255c" // ╜ BoxDrawingsDoubleUpAndLeft = "\u255d" // ╝ BoxDrawingsVerticalSingleAndRightDouble = "\u255e" // ╞ BoxDrawingsVerticalDoubleAndRightSingle = "\u255f" // ╟ BoxDrawingsDoubleVerticalAndRight = "\u2560" // ╠ BoxDrawingsVerticalSingleAndLeftDouble = "\u2561" // ╡ BoxDrawingsVerticalDoubleAndLeftSingle = "\u2562" // ╢ BoxDrawingsDoubleVerticalAndLeft = "\u2563" // ╣ BoxDrawingsDownSingleAndHorizontalDouble = "\u2564" // ╤ BoxDrawingsDownDoubleAndHorizontalSingle = "\u2565" // ╥ BoxDrawingsDoubleDownAndHorizontal = "\u2566" // ╦ BoxDrawingsUpSingleAndHorizontalDouble = "\u2567" // ╧ BoxDrawingsUpDoubleAndHorizontalSingle = "\u2568" // ╨ BoxDrawingsDoubleUpAndHorizontal = "\u2569" // ╩ BoxDrawingsVerticalSingleAndHorizontalDouble = "\u256a" // ╪ BoxDrawingsVerticalDoubleAndHorizontalSingle = "\u256b" // ╫ BoxDrawingsDoubleVerticalAndHorizontal = "\u256c" // ╬ BoxDrawingsLightArcDownAndRight = "\u256d" // ╭ BoxDrawingsLightArcDownAndLeft = "\u256e" // ╮ BoxDrawingsLightArcUpAndLeft = "\u256f" // ╯ BoxDrawingsLightArcUpAndRight = "\u2570" // ╰ BoxDrawingsLightDiagonalUpperRightToLowerLeft = "\u2571" // ╱ BoxDrawingsLightDiagonalUpperLeftToLowerRight = "\u2572" // ╲ BoxDrawingsLightDiagonalCross = "\u2573" // ╳ BoxDrawingsLightLeft = "\u2574" // ╴ BoxDrawingsLightUp = "\u2575" // ╵ BoxDrawingsLightRight = "\u2576" // ╶ BoxDrawingsLightDown = "\u2577" // ╷ BoxDrawingsHeavyLeft = "\u2578" // ╸ BoxDrawingsHeavyUp = "\u2579" // ╹ BoxDrawingsHeavyRight = "\u257a" // ╺ BoxDrawingsHeavyDown = "\u257b" // ╻ BoxDrawingsLightLeftAndHeavyRight = "\u257c" // ╼ BoxDrawingsLightUpAndHeavyDown = "\u257d" // ╽ BoxDrawingsHeavyLeftAndLightRight = "\u257e" // ╾ BoxDrawingsHeavyUpAndLightDown = "\u257f" // ╿ // Block Elements U+2580–U+259F BlockUpperHalfBlock = "\u2580" // ▀ BlockLowerOneEighthBlock = "\u2581" // ▁ BlockLowerOneQuarterBlock = "\u2582" // ▂ BlockLowerThreeEighthsBlock = "\u2583" // ▃ BlockLowerHalfBlock = "\u2584" // ▄ BlockLowerFiveEighthsBlock = "\u2585" // ▅ BlockLowerThreeQuartersBlock = "\u2586" // ▆ BlockLowerSevenEighthsBlock = "\u2587" // ▇ BlockFullBlock = "\u2588" // █ BlockLeftSevenEighthsBlock = "\u2589" // ▉ BlockLeftThreeQuartersBlock = "\u258A" // ▊ BlockLeftFiveEighthsBlock = "\u258B" // ▋ BlockLeftHalfBlock = "\u258C" // ▌ BlockLeftThreeEighthsBlock = "\u258D" // ▍ BlockLeftOneQuarterBlock = "\u258E" // ▎ BlockLeftOneEighthBlock = "\u258F" // ▏ BlockRightHalfBlock = "\u2590" // ▐ BlockLightShade = "\u2591" // ░ BlockMediumShade = "\u2592" // ▒ BlockDarkShade = "\u2593" // ▓ BlockUpperOneEighthBlock = "\u2594" // ▔ BlockRightOneEighthBlock = "\u2595" // ▕ BlockQuadrantLowerLeft = "\u2596" // ▖ BlockQuadrantLowerRight = "\u2597" // ▗ BlockQuadrantUpperLeft = "\u2598" // ▘ BlockQuadrantUpperLeftAndLowerLeftAndLowerRight = "\u2599" // ▙ BlockQuadrantUpperLeftAndLowerRight = "\u259A" // ▚ BlockQuadrantUpperLeftAndUpperRightAndLowerLeft = "\u259B" // ▛ BlockQuadrantUpperLeftAndUpperRightAndLowerRight = "\u259C" // ▜ BlockQuadrantUpperRight = "\u259D" // ▝ BlockQuadrantUpperRightAndLowerLeft = "\u259E" // ▞ BlockQuadrantUpperRightAndLowerLeftAndLowerRight = "\u259F" // ▟ )
Semigraphics provides easy access to Unicode characters for drawing. Using strings with \u escapes to keep the source ASCII-safe.
Variables ¶
var ( // DefaultFormFieldWidth is the default field screen width of form elements // whose field width is flexible (0). This is used in the Form class for // horizontal layouts. DefaultFormFieldWidth = 10 // DefaultFormFieldHeight is the default field height of multi-line form // elements whose field height is flexible (0). DefaultFormFieldHeight = 5 )
var DoubleClickInterval = 500 * time.Millisecond
DoubleClickInterval specifies the maximum time between clicks to register a double click rather than click.
var SemigraphicJoints = map[string]string{ BoxDrawingsLightHorizontal + BoxDrawingsLightVertical: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightDownAndRight: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightDownAndLeft: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightUpAndRight: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightUpAndLeft: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightHorizontal + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVertical + BoxDrawingsLightDownAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVertical + BoxDrawingsLightDownAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightVertical + BoxDrawingsLightUpAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVertical + BoxDrawingsLightUpAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightVertical + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightVertical + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightVertical + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVertical + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVertical + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightDownAndLeft: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightUpAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightDownAndRight + BoxDrawingsLightUpAndLeft: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightDownAndRight + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndRight + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndLeft + BoxDrawingsLightUpAndRight: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndLeft + BoxDrawingsLightUpAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightDownAndLeft + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndLeft + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightDownAndLeft + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightDownAndHorizontal, BoxDrawingsLightDownAndLeft + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndLeft + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndRight + BoxDrawingsLightUpAndLeft: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightUpAndRight + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndRight, BoxDrawingsLightUpAndRight + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndRight + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndRight + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightUpAndRight + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndLeft + BoxDrawingsLightVerticalAndRight: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndLeft + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndLeft, BoxDrawingsLightUpAndLeft + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndLeft + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightUpAndHorizontal, BoxDrawingsLightUpAndLeft + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndRight + BoxDrawingsLightVerticalAndLeft: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndRight + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndRight + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndRight + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndLeft + BoxDrawingsLightDownAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndLeft + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightVerticalAndLeft + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndHorizontal + BoxDrawingsLightUpAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightDownAndHorizontal + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsLightUpAndHorizontal + BoxDrawingsLightVerticalAndHorizontal: BoxDrawingsLightVerticalAndHorizontal, BoxDrawingsDoubleHorizontal + BoxDrawingsDoubleVertical: BoxDrawingsDoubleVerticalAndHorizontal, }
SemigraphicJoints maps pairs of semigraphics strings to the resulting joint. All combinations for light and double lines are included.
var Styles = Theme{ PrimitiveBackgroundColor: color.Black, ContrastBackgroundColor: color.Blue, MoreContrastBackgroundColor: color.Green, BorderColor: color.White, TitleColor: color.White, GraphicsColor: color.White, PrimaryTextColor: color.White, SecondaryTextColor: color.Yellow, TertiaryTextColor: color.Green, InverseTextColor: color.Blue, ContrastSecondaryTextColor: color.Navy, }
Styles defines the theme for applications. The default is for a black background and some basic colors: black, white, yellow, green, cyan, and blue.
var TabSize = 4
TabSize is the number of spaces with which a tab character will be replaced.
var TextAreaNewLine = "\n"
TextAreaNewLine is the string sequence to be inserted when hitting the Enter key in a TextArea. The default is "\n" but you may change it to "\r\n" if required.
Functions ¶
func Print ¶
func Print(screen tcell.Screen, text string, x, y, maxWidth int, alignment Alignment, color tcell.Color) (int, int)
Print prints text onto the screen into the given box at (x,y,maxWidth,1), not exceeding that box. The screen's background color will not be changed.
Returns the number of actual bytes of the text printed and the actual width used for the printed runes.
func PrintJoinedSemigraphics ¶
PrintJoinedSemigraphics prints a semigraphics string into the screen at the given position with the given style, joining it with any existing semigraphics.
func PrintSimple ¶
PrintSimple prints white text to the screen at the given position.
func PrintWithStyle ¶
func PrintWithStyle(screen tcell.Screen, text string, x, y, maxWidth int, alignment Alignment, style tcell.Style) (int, int)
PrintWithStyle prints text onto the screen into the given box at (x,y,maxWidth,1), not exceeding that box, using the provided style.
Returns the number of actual bytes of the text printed and the actual width used for the printed runes.
func TaggedStringWidth ¶
TaggedStringWidth returns the width of the given string needed to print it on screen.
Types ¶
type Application ¶
Application represents the top node of an application.
It is not strictly required to use this class as none of the other classes depend on it. However, it provides useful tools to set up an application and plays nicely with all widgets.
func NewApplication ¶
func NewApplication() *Application
NewApplication creates and returns a new application.
func (*Application) Focused ¶
func (a *Application) Focused() Model
Focused returns the model which has the current focus. If none has it, nil is returned.
func (*Application) Run ¶
func (a *Application) Run() error
Run starts the application and thus the messages loop.
func (*Application) Send ¶
func (a *Application) Send(msg Msg) *Application
Send sends a message to the internal messages loop.
func (*Application) SetCatchPanics ¶
func (a *Application) SetCatchPanics(catchPanics bool) *Application
SetCatchPanics sets whether cmd panics should be recovered.
func (*Application) SetRoot ¶
func (a *Application) SetRoot(root Model) *Application
SetRoot sets the root model for this application. This function must be called at least once or nothing will be displayed when the application starts.
It also calls SetFocus() on the model.
func (*Application) SetScreen ¶
func (a *Application) SetScreen(screen tcell.Screen) *Application
SetScreen sets the application's screen.
func (*Application) Suspend ¶
func (a *Application) Suspend(f func()) bool
Suspend temporarily suspends the application by exiting terminal UI mode and invoking the provided function "f". When "f" returns, terminal UI mode is entered again and the application resumes.
A return value of true indicates that the application was suspended and "f" was called. If false is returned, the application was already suspended, terminal UI mode was not exited, and "f" was not called.
type BorderSet ¶
type BorderSet struct {
Top string
Bottom string
Left string
Right string
TopLeft string
TopRight string
BottomLeft string
BottomRight string
TopT string
BottomT string
LeftT string
RightT string
}
BorderSet defines various borders used when models are drawn.
func BorderSetDouble ¶
func BorderSetDouble() BorderSet
func BorderSetHidden ¶
func BorderSetHidden() BorderSet
func BorderSetPlain ¶
func BorderSetPlain() BorderSet
func BorderSetRound ¶
func BorderSetRound() BorderSet
func BorderSetThick ¶
func BorderSetThick() BorderSet
type Borders ¶
type Borders uint
const ( BordersTop Borders = 1 << iota BordersBottom BordersLeft BordersRight BordersNone Borders = 0 BordersAll Borders = BordersTop | BordersBottom | BordersLeft | BordersRight )
type Box ¶
type Box struct {
// contains filtered or unexported fields
}
Box implements the Model interface with an empty background and optional elements such as a border and a title. Box itself does not hold any content but serves as the superclass of all other models. Subclasses add their own content, typically (but not necessarily) keeping their content within the box's rectangle.
Box provides a number of utility functions available to all models.
See https://github.com/ayn2op/tview/wiki/Box for an example.
func (*Box) BorderPadding ¶
BorderPadding returns the configured border padding.
func (*Box) DrawForSubclass ¶
DrawForSubclass draws this box under the assumption that model p is a subclass of this box. This is needed e.g. to draw proper box frames which depend on the subclass's focus.
Only call this function from your own custom models. It is not needed in applications that have no custom models.
func (*Box) GetBackgroundColor ¶
GetBackgroundColor returns the box's background color.
func (*Box) GetBorderSet ¶
GetBorderSet returns the border set.
func (*Box) InInnerRect ¶
InInnerRect returns true if the given coordinate is within the bounds of the box's inner rectangle (within the border and padding).
func (*Box) InRect ¶
InRect returns true if the given coordinate is within the bounds of the box's rectangle.
func (*Box) InnerRect ¶
InnerRect returns the position of the inner rectangle (x, y, width, height), without the border and without any padding. Width and height values will clamp to 0 and thus never be negative.
func (*Box) SetBackgroundColor ¶
SetBackgroundColor sets the box's background color.
func (*Box) SetBlurFunc ¶
SetBlurFunc sets a callback function which is invoked when this model loses focus. Container models such as [Flex] or Grid will also be notified if one of their descendents lose focus. Note that this may result in a blur notification, immediately followed by a focus notification, when the focus is set to a different descendent of the container model.
At this point, the order in which the blur callbacks are invoked during one draw cycle, is not defined. However, the blur callbacks are always invoked before the focus callbacks.
Set to nil to remove the callback function.
func (*Box) SetBorderPadding ¶
SetBorderPadding sets the size of the borders around the box content.
func (*Box) SetBorderSet ¶
SetBorderSet sets the border set.
func (*Box) SetBorderStyle ¶
SetBorderStyle sets the box's border style.
func (*Box) SetBorders ¶
SetBorders sets which borders to draw.
func (*Box) SetDontClear ¶
SetDontClear sets whether drawing should skip clearing the background.
func (*Box) SetFocusFunc ¶
SetFocusFunc sets a callback function which is invoked when this model receives focus. Container models such as [Flex] or Grid will also be notified if one of their descendents receive focus directly. Note that this may result in a blur notification, immediately followed by a focus notification, when the focus is set to a different descendent of the container model.
At this point, the order in which the focus callbacks are invoked during one draw cycle, is not defined. However, the blur callbacks are always invoked before the focus callbacks.
Set to nil to remove the callback function.
func (*Box) SetFooterAlignment ¶
SetFooterAlignment sets the alignment of the footer.
func (*Box) SetFooterStyle ¶
SetFooterStyle sets the style of the footer.
func (*Box) SetRect ¶
SetRect sets a new position of the model. Note that this has no effect if this model is part of a layout (e.g. Flex, Grid) or if it was added like this:
application.SetRoot(p, true)
func (*Box) SetTitleAlignment ¶
SetTitleAlignment sets the alignment of the title.
func (*Box) SetTitleStyle ¶
SetTitleStyle sets the style of the title.
type Button ¶
type Button struct {
*Box
// contains filtered or unexported fields
}
Button is labeled box that triggers an action when selected.
See https://github.com/ayn2op/tview/wiki/Button for an example.
func (*Button) GetDisabled ¶
GetDisabled returns whether or not the button is disabled.
func (*Button) SetActivatedStyle ¶
SetActivatedStyle sets the style of the button used when it is focused.
func (*Button) SetBackgroundColorActivated ¶
SetBackgroundColorActivated sets the background color of the button text when the button is in focus.
func (*Button) SetDisabled ¶
SetDisabled sets whether or not the button is disabled. Disabled buttons cannot be activated.
If the button is part of a form, you should set focus to the form itself after calling this function to set focus to the next non-disabled form item.
func (*Button) SetDisabledStyle ¶
SetDisabledStyle sets the style of the button used when it is disabled.
func (*Button) SetLabelColor ¶
SetLabelColor sets the color of the button text.
func (*Button) SetLabelColorActivated ¶
SetLabelColorActivated sets the color of the button text when the button is in focus.
type ButtonSelectedMsg ¶
type Checkbox ¶
type Checkbox struct {
*Box
// contains filtered or unexported fields
}
Checkbox implements a simple box for boolean values which can be checked and unchecked.
See https://github.com/ayn2op/tview/wiki/Checkbox for an example.
func (*Checkbox) GetDisabled ¶
GetDisabled returns whether or not the item is disabled / read-only.
func (*Checkbox) GetFieldHeight ¶
GetFieldHeight returns this model's field height.
func (*Checkbox) GetFieldWidth ¶
GetFieldWidth returns this model's field width.
func (*Checkbox) SetActivatedStyle ¶
SetActivatedStyle sets the style of the checkbox when it is currently focused.
func (*Checkbox) SetChangedFunc ¶
SetChangedFunc sets a handler which is called when the checked state of this checkbox was changed. The handler function receives the new state.
func (*Checkbox) SetChecked ¶
SetChecked sets the state of the checkbox. This also triggers the "changed" callback if the state changes with this call.
func (*Checkbox) SetCheckedString ¶
SetCheckedString sets the string to be displayed when the checkbox is checked (defaults to "X").
func (*Checkbox) SetCheckedStyle ¶
SetCheckedStyle sets the style of the checked checkbox.
func (*Checkbox) SetDisabled ¶
SetDisabled sets whether or not the item is disabled / read-only.
func (*Checkbox) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user is done using the checkbox. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEscape: Abort text input.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*Checkbox) SetFieldBackgroundColor ¶
SetFieldBackgroundColor sets the background color of the input area.
func (*Checkbox) SetFieldTextColor ¶
SetFieldTextColor sets the text color of the input area.
func (*Checkbox) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*Checkbox) SetFormAttributes ¶
func (c *Checkbox) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
SetFormAttributes sets attributes shared by all form items.
func (*Checkbox) SetLabelColor ¶
SetLabelColor sets the color of the label.
func (*Checkbox) SetLabelStyle ¶
SetLabelStyle sets the style of the label.
func (*Checkbox) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the model to use the width of the label string.
func (*Checkbox) SetUncheckedString ¶
SetUncheckedString sets the string to be displayed when the checkbox is not checked (defaults to the empty space " ").
func (*Checkbox) SetUncheckedStyle ¶
SetUncheckedStyle sets the style of the unchecked checkbox.
type Cmd ¶
type Cmd func() Msg
Cmd is a side effect requested by a model during input handling.
func GetClipboard ¶
func GetClipboard() Cmd
func SetClipboard ¶
func SetMouseCapture ¶
type Form ¶
type Form struct {
*Box
// contains filtered or unexported fields
}
Form allows you to combine multiple one-line form elements into a vertical or horizontal layout. Form elements include types such as InputField or Checkbox. These elements can be optionally followed by one or more buttons for which you can define form-wide actions (e.g. Save, Clear, Cancel).
See https://github.com/ayn2op/tview/wiki/Form for an example.
func (*Form) AddCheckbox ¶
AddCheckbox adds a checkbox to the form. It has a label, an initial state, and an (optional) callback function which is invoked when the state of the checkbox was changed by the user.
func (*Form) AddFormItem ¶
AddFormItem adds a new item to the form. This can be used to add your own objects to the form. Note, however, that the Form class will override some of its attributes to make it work in the form context. Specifically, these are:
- The label width
- The label color
- The background color
- The field text color
- The field background color
func (*Form) AddInputField ¶
AddInputField adds an input field to the form. It has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), and an (optional) callback function which is invoked when the input field's text has changed.
func (*Form) AddPasswordField ¶
func (f *Form) AddPasswordField(label, value string, fieldWidth int, mask rune, changed func(text string)) *Form
AddPasswordField adds a password field to the form. This is similar to an input field except that the user's input not shown. Instead, a "mask" character is displayed. The password field has a label, an optional initial value, a field width (a value of 0 extends it as far as possible), and an (optional) callback function which is invoked when the input field's text has changed.
func (*Form) AddTextArea ¶
func (f *Form) AddTextArea(label, text string, fieldWidth, fieldHeight, maxLength int, changed func(text string)) *Form
AddTextArea adds a text area to the form. It has a label, an optional initial text, a size (width and height) referring to the actual input area (a fieldWidth of 0 extends it as far right as possible, a fieldHeight of 0 will cause it to be DefaultFormFieldHeight), and a maximum number of bytes of text allowed (0 means no limit).
The optional callback function is invoked when the content of the text area has changed. Note that especially for larger texts, this is an expensive operation due to technical constraints of the TextArea model (every key stroke leads to a new reallocation of the entire text).
func (*Form) AddTextView ¶
AddTextView adds a text view to the form. It has a label and text, a size (width and height) referring to the actual text element (a fieldWidth of 0 extends it as far right as possible, a fieldHeight of 0 will cause it to be DefaultFormFieldHeight), and a flag to turn on/off scrolling. If scrolling is turned off, the text view will not receive focus.
func (*Form) Clear ¶
Clear removes all input elements from the form, including the buttons if specified.
func (*Form) ClearButtons ¶
ClearButtons removes all buttons from the form.
func (*Form) GetButton ¶
GetButton returns the button at the specified 0-based index. Note that buttons have been specially prepared for this form and modifying some of their attributes may have unintended side effects.
func (*Form) GetButtonCount ¶
GetButtonCount returns the number of buttons in this form.
func (*Form) GetButtonIndex ¶
GetButtonIndex returns the index of the button with the given label, starting with 0 for the button that was added first. If no such label was found, -1 is returned.
func (*Form) GetFocusedItemIndex ¶
GetFocusedItemIndex returns the indices of the form element or button which currently has focus. If they don't, -1 is returned respectively.
func (*Form) GetFormItem ¶
GetFormItem returns the form item at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included.
func (*Form) GetFormItemByLabel ¶
GetFormItemByLabel returns the first form element with the given label. If no such element is found, nil is returned. Buttons are not searched and will therefore not be returned.
func (*Form) GetFormItemCount ¶
GetFormItemCount returns the number of items in the form (not including the buttons).
func (*Form) GetFormItemIndex ¶
GetFormItemIndex returns the index of the first form element with the given label. If no such element is found, -1 is returned. Buttons are not searched and will therefore not be returned.
func (*Form) RemoveButton ¶
RemoveButton removes the button at the specified position, starting with 0 for the button that was added first.
func (*Form) RemoveFormItem ¶
RemoveFormItem removes the form element at the given position, starting with index 0. Elements are referenced in the order they were added. Buttons are not included.
func (*Form) SetButtonActivatedStyle ¶
SetButtonActivatedStyle sets the style of the buttons when they are focused.
func (*Form) SetButtonDisabledStyle ¶
SetButtonDisabledStyle sets the style of the buttons when they are disabled.
func (*Form) SetButtonStyle ¶
SetButtonStyle sets the style of the buttons when they are not focused.
func (*Form) SetButtonsAlignment ¶
SetButtonsAlignment sets how the buttons align horizontally.
func (*Form) SetFieldStyle ¶
SetFieldStyle sets the style of the input areas.
func (*Form) SetFocus ¶
SetFocus shifts the focus to the form element with the given index, counting non-button items first and buttons last. This does not change the application's focus immediately, but the next time the form itself receives focus, the given element will be focused once. Set to a negative value to focus the first (enabled) element.
func (*Form) SetHorizontal ¶
SetHorizontal sets the direction the form elements are laid out. If set to true, instead of positioning them from top to bottom (the default), they are positioned from left to right, moving into the next row if there is not enough space.
func (*Form) SetItemPadding ¶
SetItemPadding sets the number of empty rows between form items for vertical layouts and the number of empty cells between form items for horizontal layouts. In vertical layouts, there is always at least one empty line between the last item and the buttons, if any.
func (*Form) SetLabelColor ¶
SetLabelColor sets the color of the labels.
type FormCancelMsg ¶
type FormItem ¶
type FormItem interface {
Model
// GetLabel returns the item's label text.
GetLabel() string
// SetFormAttributes sets a number of item attributes at once.
SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
// GetFieldWidth returns the width of the form item's field (the area which
// is manipulated by the user) in number of screen cells. A value of 0
// indicates the field width is flexible and may use as much space as
// required.
GetFieldWidth() int
// GetFieldHeight returns the height of the form item's field (the area which
// is manipulated by the user). This value must be greater than 0.
GetFieldHeight() int
// SetFinishedFunc sets the handler function for when the user finished
// entering data into the item. The handler may receive events for the
// Enter key (we're done), the Escape key (cancel input), the Tab key (move
// to next field), the Backtab key (move to previous field), or a negative
// value, indicating that the action for the last known key should be
// repeated.
SetFinishedFunc(handler func(key tcell.Key)) FormItem
// SetDisabled sets whether or not the item is disabled / read-only. A form
// must have at least one item that is not disabled.
SetDisabled(disabled bool) FormItem
// GetDisabled returns whether or not the item is disabled / read-only.
GetDisabled() bool
}
FormItem is the interface all form items must implement to be able to be included in a form.
type FormSubmitMsg ¶
type Frame ¶
type Frame struct {
*Box
// contains filtered or unexported fields
}
Frame is a wrapper which adds space around another model. In addition, the top area (header) and the bottom area (footer) may also contain text.
See https://github.com/ayn2op/tview/wiki/Frame for an example.
func NewFrame ¶
NewFrame returns a new frame around the given model. The model's size will be changed to fit within this frame. The model may be nil, in which case no other model is embedded in the frame.
func (*Frame) AddText ¶
AddText adds text to the frame. Set "header" to true if the text is to appear in the header, above the contained model. Set it to false for it to appear in the footer, below the contained model. Rows in the header are printed top to bottom, rows in the footer are printed bottom to top. Note that long text can overlap as different alignments will be placed on the same row.
func (*Frame) GetPrimitive ¶
GetPrimitive returns the model contained in this frame.
func (*Frame) SetBorders ¶
SetBorders sets the width of the frame borders as well as "header" and "footer", the vertical space between the header and footer text and the contained model (does not apply if there is no text).
func (*Frame) SetPrimitive ¶
SetPrimitive replaces the contained model with the given one. To remove a model, set it to nil.
type GlyphSet ¶
type GlyphSet struct {
TrackVertical string
ArrowVerticalStart string
ArrowVerticalEnd string
ThumbVerticalLower [8]string
ThumbVerticalUpper [8]string
}
GlyphSet defines vertical track, arrow, and fractional thumb glyphs.
func BoxDrawingGlyphSet ¶
func BoxDrawingGlyphSet() GlyphSet
BoxDrawingGlyphSet returns box-drawing track glyphs with legacy fractional symbols.
func LegacyComputingGlyphSet ¶
func LegacyComputingGlyphSet() GlyphSet
LegacyComputingGlyphSet returns legacy-computing symbols for full 1/8 fractional fidelity.
func MinimalGlyphSet ¶
func MinimalGlyphSet() GlyphSet
MinimalGlyphSet returns the minimal glyph set (space track, fractional thumbs).
func UnicodeGlyphSet ¶
func UnicodeGlyphSet() GlyphSet
UnicodeGlyphSet returns a standard-unicode-only approximation set.
type Grid ¶
type Grid struct {
*Box
// contains filtered or unexported fields
}
Grid is an implementation of a grid-based layout. It works by defining the size of the rows and columns, then placing models into the grid.
Some settings can lead to the grid exceeding its available space. SetOffset() can then be used to scroll in steps of rows and columns. These offset values can also be controlled with the arrow keys (or the "g","G", "j", "k", "h", and "l" keys) while the grid has focus and none of its contained models do.
See https://github.com/rivo/tview/wiki/Grid for an example.
func NewGrid ¶
func NewGrid() *Grid
NewGrid returns a new grid-based layout container with no initial models.
Note that Box, the superclass of Grid, will be transparent so that any grid areas not covered by any models will leave their background unchanged. To clear a Grid's background before any items are drawn, reset its Box to one with the desired color:
grid.Box = NewBox()
func (*Grid) AddItem ¶
func (g *Grid) AddItem(p Model, row, column, rowSpan, colSpan, minGridHeight, minGridWidth int, focus bool) *Grid
AddItem adds a model and its position to the grid. The top-left corner of the model will be located in the top-left corner of the grid cell at the given row and column and will span "rowSpan" rows and "colSpan" columns. For example, for a model to occupy rows 2, 3, and 4 and columns 5 and 6:
grid.AddItem(p, 2, 5, 3, 2, 0, 0, true)
If rowSpan or colSpan is 0, the model will not be drawn.
You can add the same model multiple times with different grid positions. The minGridWidth and minGridHeight values will then determine which of those positions will be used. This is similar to CSS media queries. These minimum values refer to the overall size of the grid. If multiple items for the same model apply, the one with the highest minimum value (width or height, whatever is higher) will be used, or the model added last if those values are the same. Example:
grid.AddItem(p, 0, 0, 0, 0, 0, 0, true). // Hide in small grids. AddItem(p, 0, 0, 1, 2, 100, 0, true). // One-column layout for medium grids. AddItem(p, 1, 1, 3, 2, 300, 0, true) // Multi-column layout for large grids.
To use the same grid layout for all sizes, simply set minGridWidth and minGridHeight to 0.
If the item's focus is set to true, it will receive focus when the grid receives focus. If there are multiple items with a true focus flag, the last visible one that was added will receive focus.
func (*Grid) GetOffset ¶
GetOffset returns the current row and column offset (see SetOffset() for details).
func (*Grid) RemoveItem ¶
RemoveItem removes all items for the given model from the grid, keeping the order of the remaining items intact.
func (*Grid) SetBorders ¶
SetBorders sets whether or not borders are drawn around grid items. Setting this value to true will cause the gap values (see SetGap()) to be ignored and automatically assumed to be 1 where the border graphics are drawn.
func (*Grid) SetBordersColor ¶
SetBordersColor sets the color of the item borders.
func (*Grid) SetColumns ¶
SetColumns defines how the columns of the grid are distributed. Each value defines the size of one column, starting with the leftmost column. Values greater than 0 represent absolute column widths (gaps not included). Values less than or equal to 0 represent proportional column widths or fractions of the remaining free space, where 0 is treated the same as -1. That is, a column with a value of -3 will have three times the width of a column with a value of -1 (or 0). The minimum width set with SetMinSize() is always observed.
Models may extend beyond the columns defined explicitly with this function. A value of 0 is assumed for any undefined column. In fact, if you never call this function, all columns occupied by models will have the same width. On the other hand, unoccupied columns defined with this function will always take their place.
Assuming a total width of the grid of 100 cells and a minimum width of 0, the following call will result in columns with widths of 30, 10, 15, 15, and 30 cells:
grid.SetColumns(30, 10, -1, -1, -2)
If a model were then placed in the 6th and 7th column, the resulting widths would be: 30, 10, 10, 10, 20, 10, and 10 cells.
If you then called SetMinSize() as follows:
grid.SetMinSize(15, 20)
The resulting widths would be: 30, 15, 15, 15, 20, 15, and 15 cells, a total of 125 cells, 25 cells wider than the available grid width.
func (*Grid) SetGap ¶
SetGap sets the size of the gaps between neighboring models on the grid. If borders are drawn (see SetBorders()), these values are ignored and a gap of 1 is assumed. Panics if negative values are provided.
func (*Grid) SetMinSize ¶
SetMinSize sets an absolute minimum width for rows and an absolute minimum height for columns. Panics if negative values are provided.
func (*Grid) SetOffset ¶
SetOffset sets the number of rows and columns which are skipped before drawing the first grid cell in the top-left corner. As the grid will never completely move off the screen, these values may be adjusted the next time the grid is drawn. The actual position of the grid may also be adjusted such that contained models that have focus remain visible.
func (*Grid) SetRows ¶
SetRows defines how the rows of the grid are distributed. These values behave the same as the column values provided with Grid.SetColumns, see there for a definition and examples.
The provided values correspond to row heights, the first value defining the height of the topmost row.
func (*Grid) SetSize ¶
SetSize is a shortcut for Grid.SetRows and Grid.SetColumns where all row and column values are set to the given size values. See Grid.SetColumns for details on sizes.
type InputField ¶
type InputField struct {
*Box
// contains filtered or unexported fields
}
InputField is a one-line box into which the user can enter text. Use [InputField.SetAcceptanceFunc] to accept or reject input, InputField.SetChangedFunc to listen for changes, and InputField.SetMaskCharacter to hide input from onlookers (e.g. for password input).
Navigation and editing is the same as for a TextArea, with the following exceptions:
- Tab, BackTab, Enter, Escape: Finish editing.
Note that while pressing Tab or Enter is intercepted by the input field, it is possible to paste such characters into the input field, possibly resulting in multi-line input. You can use [InputField.SetAcceptanceFunc] to prevent this.
See https://github.com/ayn2op/tview/wiki/InputField for an example.
func (*InputField) Draw ¶
func (i *InputField) Draw(screen tcell.Screen)
Draw draws this model onto the screen.
func (*InputField) Focus ¶
func (i *InputField) Focus(delegate func(m Model))
Focus is called when this model receives focus.
func (*InputField) GetDisabled ¶
func (i *InputField) GetDisabled() bool
GetDisabled returns whether or not the item is disabled / read-only.
func (*InputField) GetFieldHeight ¶
func (i *InputField) GetFieldHeight() int
GetFieldHeight returns this model's field height.
func (*InputField) GetFieldStyle ¶
func (i *InputField) GetFieldStyle() tcell.Style
GetFieldStyle returns the style of the input area (when no placeholder is shown).
func (*InputField) GetFieldWidth ¶
func (i *InputField) GetFieldWidth() int
GetFieldWidth returns this model's field width.
func (*InputField) GetLabel ¶
func (i *InputField) GetLabel() string
GetLabel returns the text to be displayed before the input area.
func (*InputField) GetLabelStyle ¶
func (i *InputField) GetLabelStyle() tcell.Style
GetLabelStyle returns the style of the label.
func (*InputField) GetText ¶
func (i *InputField) GetText() string
GetText returns the current text of the input field.
func (*InputField) HasFocus ¶
func (i *InputField) HasFocus() bool
HasFocus returns whether or not this model has focus.
func (*InputField) SetChangedFunc ¶
func (i *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) SetDisabled ¶
func (i *InputField) SetDisabled(disabled bool) FormItem
SetDisabled sets whether or not the item is disabled / read-only.
func (*InputField) SetDoneFunc ¶
func (i *InputField) SetDoneFunc(handler func(key tcell.Key)) *InputField
SetDoneFunc sets a handler which is called when the user is done entering text. The callback function is provided with the key that was pressed, which is one of the following:
- KeyEnter: Done entering text.
- KeyEscape: Abort text input.
- KeyTab: Move to the next field.
- KeyBacktab: Move to the previous field.
func (*InputField) SetFieldStyle ¶
func (i *InputField) SetFieldStyle(style tcell.Style) *InputField
SetFieldStyle sets the style of the input area (when no placeholder is shown).
func (*InputField) SetFieldWidth ¶
func (i *InputField) SetFieldWidth(width int) *InputField
SetFieldWidth sets the screen width of the input area. A value of 0 means extend as much as possible.
func (*InputField) SetFinishedFunc ¶
func (i *InputField) SetFinishedFunc(handler func(key tcell.Key)) FormItem
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*InputField) SetFormAttributes ¶
func (i *InputField) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
SetFormAttributes sets attributes shared by all form items.
func (*InputField) SetLabel ¶
func (i *InputField) SetLabel(label string) *InputField
SetLabel sets the text to be displayed before the input area.
func (*InputField) SetLabelColor ¶
func (i *InputField) SetLabelColor(color tcell.Color) *InputField
SetLabelColor sets the text color of the label.
func (*InputField) SetLabelStyle ¶
func (i *InputField) SetLabelStyle(style tcell.Style) *InputField
SetLabelStyle sets the style of the label.
func (*InputField) SetLabelWidth ¶
func (i *InputField) SetLabelWidth(width int) *InputField
SetLabelWidth sets the screen width of the label. A value of 0 represents the width of the label string.
func (*InputField) SetMaskCharacter ¶
func (i *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 (i *InputField) SetPlaceholder(line Line) *InputField
SetPlaceholder sets the styled text to be displayed when the input text is empty.
func (*InputField) SetText ¶
func (i *InputField) SetText(text string) *InputField
SetText sets the current text of the input field. This can be undone by the user. Calling this function will also trigger a "changed" event.
func (*InputField) Update ¶
func (i *InputField) Update(msg Msg) Cmd
Update handles input events for this model.
type Line ¶
type Line []Segment
Line is a list of styled segments.
type LineBuilder ¶
type LineBuilder struct {
// contains filtered or unexported fields
}
LineBuilder incrementally builds styled lines from text writes.
func (*LineBuilder) AppendLines ¶
func (b *LineBuilder) AppendLines(lines []Line)
AppendLines appends fully built lines into the builder.
func (*LineBuilder) HasCurrentLine ¶
func (b *LineBuilder) HasCurrentLine() bool
HasCurrentLine returns true when unflushed segments exist.
func (*LineBuilder) NewLine ¶
func (b *LineBuilder) NewLine()
NewLine flushes the current line into the builder output.
type Modal ¶
type Modal struct {
*Box
// contains filtered or unexported fields
}
Modal is a centered message window used to inform the user or prompt them for an immediate decision. It needs to have at least one button (added via Modal.AddButtons) or it will never disappear.
See https://github.com/ayn2op/tview/wiki/Modal for an example.
func (*Modal) AddButtons ¶
AddButtons adds buttons to the window.
func (*Modal) ClearButtons ¶
ClearButtons removes all buttons from the window.
func (*Modal) SetBackgroundColor ¶
SetBackgroundColor sets the color of the modal frame background.
func (*Modal) SetButtonActivatedStyle ¶
SetButtonActivatedStyle sets the style of the buttons when they are focused.
func (*Modal) SetButtonStyle ¶
SetButtonStyle sets the style of the buttons when they are not focused.
func (*Modal) SetText ¶
SetText sets the message text of the window. The text may contain line breaks. Note that words are wrapped, too, based on the final size of the window.
func (*Modal) SetTextColor ¶
SetTextColor sets the color of the message text.
type Model ¶
type Model interface {
// Draw draws this model onto the screen. Implementers can call the
// screen's ShowCursor() function but should only do so when they have focus.
// (They will need to keep track of this themselves.)
Draw(tcell.Screen)
// Update receives messages when this model has focus.
Update(Msg) Cmd
// Rect returns the current position of the model, x, y, width, and
// height.
Rect() (int, int, int, int)
// SetRect sets a new position of the model.
SetRect(x, y, width, height int)
// HasFocus determines if the model has focus. This function must return
// true also if one of this model's child elements has focus.
HasFocus() bool
// Focus is called by the application when the model receives focus.
// Implementers may call delegate() to pass the focus on to another model.
Focus(delegate func(Model))
// Blur is called by the application when the model loses focus.
Blur()
}
Model is the top-most interface for all graphical models.
type MouseAction ¶
type MouseAction int16
MouseAction indicates one of the actions the mouse is logically doing.
const ( MouseMove MouseAction = iota MouseLeftDown MouseLeftUp MouseLeftClick MouseLeftDoubleClick MouseMiddleDown MouseMiddleUp MouseMiddleClick MouseMiddleDoubleClick MouseRightDown MouseRightUp MouseRightClick MouseRightDoubleClick MouseScrollUp MouseScrollDown MouseScrollLeft MouseScrollRight )
Available mouse actions.
type MouseMsg ¶
type MouseMsg struct {
tcell.EventMouse
Action MouseAction
}
type ScrollBar ¶
type ScrollBar struct {
*Box
// contains filtered or unexported fields
}
ScrollBar renders a vertical customizable scrollBar widget.
func NewVerticalScrollBar ¶
func NewVerticalScrollBar(lengths ScrollLengths) *ScrollBar
NewVerticalScrollBar creates a vertical scrollBar from lengths.
func (*ScrollBar) HasEndArrow ¶
HasEndArrow reports whether an end arrow is rendered.
func (*ScrollBar) HasStartArrow ¶
HasStartArrow reports whether a start arrow is rendered.
func (*ScrollBar) ScrollStep ¶
ScrollStep returns scroll step used by wheel and arrow interactions.
func (*ScrollBar) SetArrowStyle ¶
SetArrowStyle sets the arrow endcap style.
func (*ScrollBar) SetArrows ¶
func (s *ScrollBar) SetArrows(arrows ScrollBarArrows) *ScrollBar
SetArrows sets which arrow endcaps are rendered.
func (*ScrollBar) SetAutoHide ¶
SetAutoHide controls whether the scrollBar is hidden when there is nothing to scroll.
func (*ScrollBar) SetGlyphSet ¶
SetGlyphSet applies a glyph set.
func (*ScrollBar) SetLengths ¶
func (s *ScrollBar) SetLengths(lengths ScrollLengths) *ScrollBar
SetLengths sets content and viewport lengths.
func (*ScrollBar) SetScrollStep ¶
SetScrollStep sets scroll step used by wheel and arrow interactions.
func (*ScrollBar) SetThumbGlyph ¶
SetThumbGlyph sets all thumb glyphs to a single symbol.
func (*ScrollBar) SetThumbStyle ¶
SetThumbStyle sets the thumb style.
func (*ScrollBar) SetTrackClickBehavior ¶
func (s *ScrollBar) SetTrackClickBehavior(behavior TrackClickBehavior) *ScrollBar
SetTrackClickBehavior sets behavior used for track clicks.
func (*ScrollBar) SetTrackGlyph ¶
SetTrackGlyph sets the track symbol and visibility.
func (*ScrollBar) SetTrackStyle ¶
SetTrackStyle sets the track style.
func (*ScrollBar) TrackClickBehavior ¶
func (s *ScrollBar) TrackClickBehavior() TrackClickBehavior
TrackClickBehavior returns behavior used for track clicks.
func (*ScrollBar) TrackLengthExcludingArrowHeads ¶
TrackLengthExcludingArrowHeads returns track length excluding arrow cells.
type ScrollBarArrows ¶
type ScrollBarArrows uint8
ScrollBarArrows controls which endcaps are rendered.
const ( ScrollBarArrowsNone ScrollBarArrows = iota ScrollBarArrowsStart ScrollBarArrowsEnd ScrollBarArrowsBoth )
type ScrollLengths ¶
ScrollLengths bundles content and viewport lengths in logical units.
type TextArea ¶
type TextArea struct {
*Box
// contains filtered or unexported fields
}
TextArea implements a simple text editor for multi-line text. Multi-color text is not supported. Word-wrapping is enabled by default but can be turned off or be changed to character-wrapping.
Navigation and Editing ¶
A text area is always in editing mode and no other mode exists. The following keys can be used to move the cursor (subject to what the user's terminal supports and how it is configured):
- Left arrow: Move left.
- Right arrow: Move right.
- Down arrow: Move down.
- Up arrow: Move up.
- Ctrl-A, Home: Move to the beginning of the current line.
- Ctrl-E, End: Move to the end of the current line.
- Ctrl-F, page down: Move down by one page.
- Ctrl-B, page up: Move up by one page.
- Alt-Up arrow: Scroll the page up, leaving the cursor in its position.
- Alt-Down arrow: Scroll the page down, leaving the cursor in its position.
- Alt-Left arrow: Scroll the page to the left, leaving the cursor in its position. Ignored if wrapping is enabled.
- Alt-Right arrow: Scroll the page to the right, leaving the cursor in its position. Ignored if wrapping is enabled.
- Alt-B, Ctrl-Left arrow: Jump to the beginning of the current or previous word.
- Alt-F, Ctrl-Right arrow: Jump to the end of the current or next word.
Words are defined according to Unicode Standard Annex #29. We skip any words that contain only spaces or punctuation.
Entering a character will insert it at the current cursor location. Subsequent characters are shifted accordingly. If the cursor is outside the visible area, any changes to the text will move it into the visible area. The following keys can also be used to modify the text:
- Enter: Insert a newline character (see TextAreaNewLine).
- Tab: Insert a tab character (\t). It will be rendered like TabSize spaces. (This may eventually be changed to behave like regular tabs.)
- Ctrl-H, Backspace: Delete one character to the left of the cursor.
- Ctrl-D, Delete: Delete the character under the cursor (or the first character on the next line if the cursor is at the end of a line).
- Alt-Backspace: Delete the word to the left of the cursor.
- Ctrl-K: Delete everything under and to the right of the cursor until the next newline character.
- Ctrl-W: Delete from the start of the current word to the left of the cursor.
- Ctrl-U: Delete the current line, i.e. everything after the last newline character before the cursor up until the next newline character. This may span multiple visible rows if wrapping is enabled.
Text can be selected by moving the cursor while holding the Shift key, to the extent that this is supported by the user's terminal. The Ctrl-L key can be used to select the entire text. (Ctrl-A already binds to the "Home" key.)
When text is selected:
- Entering a character will replace the selected text with the new character.
- Backspace, delete, Ctrl-H, Ctrl-D: Delete the selected text.
- Ctrl-Q: Copy the selected text into the clipboard, unselect the text.
- Ctrl-X: Copy the selected text into the clipboard and delete it.
- Ctrl-V: Replace the selected text with the clipboard text. If no text is selected, the clipboard text will be inserted at the cursor location.
The Ctrl-Q key was chosen for the default "copy" function to avoid clashing with common Ctrl-C quit bindings in user applications. You may remap keys in your model's Update and implement copying to the clipboard. Note that using your terminal's / operating system's key bindings for copy+paste functionality may not have the expected effect as tview will not be able to handle these keys. Pasting text using your operating system's or terminal's own methods may be very slow as each character will be pasted individually. However, some terminals support pasting text blocks which is supported by the text area, see [Application.EnablePaste] for details.
The default clipboard is an internal text buffer local to this text area instance, i.e. the operating system's clipboard is not used. If you want to implement your own clipboard (or make use of your operating system's clipboard), you can use TextArea.SetClipboard which provides all the functionality needed to implement your own clipboard.
The text area also supports Undo:
- Ctrl-Z: Undo the last change.
- Ctrl-Y: Redo the last Undo change.
Undo does not affect the clipboard.
If the mouse is enabled, the following actions are available:
- Left click: Move the cursor to the clicked position or to the end of the line if past the last character.
- Left double-click: Select the word under the cursor.
- Left click while holding the Shift key: Select text.
- Scroll wheel: Scroll the text.
func NewTextArea ¶
func NewTextArea() *TextArea
NewTextArea returns a new text area. Use TextArea.SetText to set the initial text.
func (*TextArea) GetClipboardText ¶
GetClipboardText returns the current text of the clipboard by calling the pasteFromClipboard function set with TextArea.SetClipboard.
func (*TextArea) GetCursor ¶
GetCursor returns the current cursor position where the first character of the entire text is in row 0, column 0. If the user has selected text, the "from" values will refer to the beginning of the selection and the "to" values to the end of the selection (exclusive). They are the same if there is no selection.
func (*TextArea) GetDisabled ¶
GetDisabled returns whether or not the item is disabled / read-only.
func (*TextArea) GetFieldHeight ¶
GetFieldHeight returns this model's field height.
func (*TextArea) GetFieldWidth ¶
GetFieldWidth returns this model's field width.
func (*TextArea) GetLabelStyle ¶
GetLabelStyle returns the style of the label.
func (*TextArea) GetLabelWidth ¶
GetLabelWidth returns the screen width of the label.
func (*TextArea) GetOffset ¶
GetOffset returns the text's offset, that is, the number of rows and columns skipped during drawing at the top or on the left, respectively. Note that the column offset is ignored if wrapping is enabled.
func (*TextArea) GetSelection ¶
GetSelection returns the currently selected text and its start and end positions within the entire text as a half-open interval. If the returned text is an empty string, the start and end positions are the same and can be interpreted as the cursor position.
Calling this function will result in string allocations as well as a search for text positions. This is expensive if the text has been edited extensively already. Use TextArea.HasSelection first if you are only interested in selected text.
func (*TextArea) GetText ¶
GetText returns the entire text of the text area. Note that this will newly allocate the entire text.
func (*TextArea) GetTextLength ¶
GetTextLength returns the string length of the text in the text area.
func (*TextArea) GetTextStyle ¶
GetTextStyle returns the style of the text.
func (*TextArea) GetWordUnderCursor ¶
GetWordUnderCursor returns the absolute cursor position and the word under the cursor (upto but not including the character under the cursor). A word is something that all of its runes satisfy f(r). The last rune that didn't satisfy f(r) is also returned.
func (*TextArea) HasSelection ¶
HasSelection returns whether the selected text is non-empty.
func (*TextArea) Replace ¶
Replace replaces a section of the text with new text. The start and end positions refer to index positions within the entire text string (as a half-open interval). They may be the same, in which case text is inserted at the given position. If the text is an empty string, text between start and end is deleted. Index positions will be shifted to line up with character boundaries. A "changed" event will be triggered.
Previous selections are cleared. The cursor will be located at the end of the replaced text. Scroll offsets will not be changed. A "moved" event will be triggered.
The effects of this function can be undone (and redone) by the user.
func (*TextArea) Select ¶
Select selects a section of the text. The start and end positions refer to index positions within the entire text string (as a half-open interval). They may be the same, in which case the cursor is placed at the given position. Any previous selection is removed. Scroll offsets will be preserved.
Index positions will be shifted to line up with character boundaries.
func (*TextArea) SetChangedFunc ¶
SetChangedFunc sets a handler which is called whenever the text of the text area has changed.
func (*TextArea) SetClipboard ¶
func (t *TextArea) SetClipboard(copyToClipboard func(string), pasteFromClipboard func() string) *TextArea
SetClipboard allows you to implement your own clipboard by providing a function that is called when the user wishes to store text in the clipboard (copyToClipboard) and a function that is called when the user wishes to retrieve text from the clipboard (pasteFromClipboard).
Providing nil values will cause the default clipboard implementation to be used. Note that the default clipboard is local to this text area instance. Copying text to other widgets will not work.
func (*TextArea) SetDisabled ¶
SetDisabled sets whether or not the item is disabled / read-only.
func (*TextArea) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*TextArea) SetFormAttributes ¶
func (t *TextArea) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
SetFormAttributes sets attributes shared by all form items.
func (*TextArea) SetLabelStyle ¶
SetLabelStyle sets the style of the label.
func (*TextArea) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the model to use the width of the label string.
func (*TextArea) SetMaxLength ¶
SetMaxLength sets the maximum number of bytes allowed in the text area. A value of 0 means there is no limit. If the text area currently contains more bytes than this, it may violate this constraint.
func (*TextArea) SetMovedFunc ¶
SetMovedFunc sets a handler which is called whenever the cursor position or the text selection has changed.
func (*TextArea) SetOffset ¶
SetOffset sets the text's offset, that is, the number of rows and columns skipped during drawing at the top or on the left, respectively. If wrapping is enabled, the column offset is ignored. These values may get adjusted automatically to ensure that some text is always visible.
func (*TextArea) SetPlaceholder ¶
SetPlaceholder sets the styled line to be displayed when the text area is empty.
func (*TextArea) SetSelectedStyle ¶
SetSelectedStyle sets the style of the selected text.
func (*TextArea) SetSize ¶
SetSize sets the screen size of the input element of the text area. The input element is always located next to the label which is always located in the top left corner. If any of the values are 0 or larger than the available space, the available space will be used.
func (*TextArea) SetText ¶
SetText sets the text of the text area. All existing text is deleted and replaced with the new text. Any edits are discarded, no undos are available. This function is typically only used to initialize the text area with a text after it has been created. To clear the text area's text (again, no undos), provide an empty string.
If cursorAtTheEnd is false, the cursor is placed at the start of the text. If it is true, it is placed at the end of the text. For very long texts, placing the cursor at the end can be an expensive operation because the entire text needs to be parsed and laid out.
If you want to set text and preserve undo functionality, use TextArea.Replace instead.
func (*TextArea) SetTextStyle ¶
SetTextStyle sets the style of the text.
func (*TextArea) SetWordWrap ¶
SetWordWrap sets the flag that causes lines that are longer than the available width to be wrapped onto the next line at spaces or after punctuation marks (according to Unicode Standard Annex #14). This flag is ignored if the flag set with TextArea.SetWrap is false. The text area's default is word-wrapping.
type TextView ¶
TextView is a component to display read-only text. The content is represented as styled segments grouped by lines.
func (*TextView) AppendLine ¶
AppendLine appends a new line made of segments.
func (*TextView) AppendSegments ¶
AppendSegments appends styled segments to the last line.
func (*TextView) BatchWriter ¶
func (t *TextView) BatchWriter() TextViewWriter
BatchWriter returns a new writer that can be used to write into the buffer but without Locking/Unlocking the buffer on every write.
func (*TextView) Clear ¶
Clear removes all text from the buffer. This triggers the "changed" callback.
func (*TextView) GetDisabled ¶
GetDisabled returns whether or not the item is disabled / read-only.
func (*TextView) GetFieldHeight ¶
GetFieldHeight returns this model's field height.
func (*TextView) GetFieldWidth ¶
GetFieldWidth returns this model's field width.
func (*TextView) GetOriginalLineCount ¶
GetOriginalLineCount returns the number of logical lines in the current text.
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) GetWrappedLineCount ¶
GetWrappedLineCount returns the number of visual lines, taking wrapping into account.
func (*TextView) Height ¶
Height returns the required height for rendering the text view at the given width when used as a scroll list item.
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.
func (*TextView) SetBackgroundColor ¶
SetBackgroundColor overrides its implementation in Box to set the background color of this model.
func (*TextView) SetChangedFunc ¶
SetChangedFunc sets a handler function which is called when the text of the text view has changed.
func (*TextView) SetDisabled ¶
SetDisabled sets whether or not the item is disabled / read-only.
func (*TextView) SetDoneFunc ¶
SetDoneFunc sets a handler which is called when the user presses on the following keys: Escape, Enter, Tab, Backtab.
func (*TextView) SetFinishedFunc ¶
SetFinishedFunc sets a callback invoked when the user leaves this form item.
func (*TextView) SetFormAttributes ¶
func (t *TextView) SetFormAttributes(labelWidth int, labelColor, bgColor, fieldTextColor, fieldBgColor tcell.Color) FormItem
SetFormAttributes sets attributes shared by all form items.
func (*TextView) SetLabelWidth ¶
SetLabelWidth sets the screen width of the label. A value of 0 will cause the model to use the width of the label string.
func (*TextView) SetMaxLines ¶
SetMaxLines sets the maximum number of logical lines for this text view.
func (*TextView) SetScrollable ¶
SetScrollable sets the flag that decides whether or not the text view is scrollable. If false, text that moves above the text view's top row will be permanently deleted.
func (*TextView) SetTextAlign ¶
SetTextAlign sets the text alignment within the text view. This must be either AlignLeft, AlignCenter, or AlignRight.
func (*TextView) SetTextStyle ¶
SetTextStyle sets the default style for newly written text.
func (*TextView) SetWordWrap ¶
SetWordWrap sets the flag that, if true and if the "wrap" flag is also true, wraps according to Unicode line break opportunities.
func (*TextView) SetWrap ¶
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.
type TextViewWriter ¶
type TextViewWriter struct {
// contains filtered or unexported fields
}
TextViewWriter is a writer that can be used to write to and clear a TextView in batches, i.e. multiple writes with the lock only being acquired once. Don't instantiated this class directly but use the TextView's BatchWriter method instead.
func (TextViewWriter) Clear ¶
func (w TextViewWriter) Clear()
Clear removes all text from the buffer.
func (TextViewWriter) Close ¶
func (w TextViewWriter) Close() error
Close implements io.Closer for the writer by unlocking the original TextView.
func (TextViewWriter) HasFocus ¶
func (w TextViewWriter) HasFocus() bool
HasFocus returns whether the underlying TextView has focus.
type Theme ¶
type Theme struct {
PrimitiveBackgroundColor tcell.Color // Main background color for models.
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.
}
Theme defines the colors used when models are initialized.
type TrackClickBehavior ¶
type TrackClickBehavior uint8
TrackClickBehavior configures behavior when clicking scrollBar track cells outside the thumb.
const ( TrackClickBehaviorPage TrackClickBehavior = iota TrackClickBehaviorJumpToClick )
type TreeMarkers ¶
TreeMarkers are glyphs drawn before node text.
type TreeNode ¶
type TreeNode struct {
// contains filtered or unexported fields
}
TreeNode represents one node in a tree view.
func (*TreeNode) ClearChildren ¶
ClearChildren removes all child nodes from this node.
func (*TreeNode) CollapseAll ¶
CollapseAll collapses this node and all descendent nodes.
func (*TreeNode) GetChildren ¶
GetChildren returns this node's children.
func (*TreeNode) GetLevel ¶
GetLevel returns the node's level within the hierarchy, where 0 corresponds to the root node, 1 corresponds to its children, and so on. This is only guaranteed to be up to date immediately after the tree that contains this node is drawn.
func (*TreeNode) GetReference ¶
GetReference returns this node's reference object.
func (*TreeNode) GetSelectedTextStyle ¶
GetSelectedTextStyle returns the text style for this node when it is selected.
func (*TreeNode) IsExpandable ¶
IsExpandable returns whether this node can be expanded even when there are no loaded child nodes yet.
func (*TreeNode) IsExpanded ¶
IsExpanded returns whether the child nodes of this node are visible.
func (*TreeNode) RemoveChild ¶
RemoveChild removes a child node from this node. If the child node cannot be found, nothing happens.
func (*TreeNode) SetChildren ¶
SetChildren sets this node's child nodes.
func (*TreeNode) SetExpandable ¶
SetExpandable sets whether this node can be expanded even when there are no loaded child nodes yet.
func (*TreeNode) SetExpanded ¶
SetExpanded sets whether or not this node's child nodes should be displayed.
func (*TreeNode) SetIndent ¶
SetIndent sets an additional indentation for this node's text. A value of 0 keeps the text as far left as possible with a minimum of line graphics. Any value greater than that moves the text to the right.
func (*TreeNode) SetReference ¶
SetReference allows you to store a reference of any type in this node. This will allow you to establish a mapping between the TreeView hierarchy and your internal tree structure.
func (*TreeNode) SetSelectable ¶
SetSelectable sets a flag indicating whether this node can be selected by the user.
func (*TreeNode) SetSelectedTextStyle ¶
SetSelectedTextStyle sets the text style for this node when it is selected.
func (*TreeNode) Walk ¶
Walk traverses this node's subtree in depth-first, pre-order (NLR) order and calls the provided callback function on each traversed node (which includes this node) with the traversed node and its parent node (nil for this node). The callback returns whether traversal should continue with the traversed node's child nodes (true) or not recurse any deeper (false).
type TreeView ¶
type TreeView struct {
*Box
// contains filtered or unexported fields
}
TreeView displays tree structures. A tree consists of nodes (TreeNode objects) where each node has zero or more child nodes and exactly one parent node (except for the root node which has no parent node).
The SetRoot() function is used to specify the root of the tree. Other nodes are added locally to the root node or any of its descendents. See the TreeNode documentation for details on node attributes. (You can use SetReference() to store a reference to nodes of your own tree structure.)
Nodes can be selected by calling SetCurrentNode(). The user can navigate the cursor or the tree by using the following keys:
- j, down arrow, right arrow: Move (the cursor) down by one node.
- k, up arrow, left arrow: Move (the cursor) up by one node.
- g, home: Move (the cursor) to the top.
- G, end: Move (the cursor) to the bottom.
- J: Move (the cursor) up one level (if that node is selectable).
- K: Move (the cursor) to the last node one level down (if any).
- Ctrl-F, page down: Move (the cursor) down by one page.
- Ctrl-B, page up: Move (the cursor) up by one page.
Selected nodes emit TreeViewSelectedMsg when the user hits Enter.
The root node corresponds to level 0, its children correspond to level 1, their children to level 2, and so on. Per default, the first level that is displayed is 0, i.e. the root node. You can call SetTopLevel() to hide levels.
If graphics are turned on (see SetGraphics()), lines indicate the tree's hierarchy. Alternative (or additionally), you can set different prefixes using SetPrefixes() for different levels, for example to display hierarchical bullet point lists.
See https://github.com/ayn2op/tview/wiki/TreeView for an example.
func (*TreeView) GetCurrentNode ¶
GetCurrentNode returns the currently selected node or nil of no node is currently selected.
func (*TreeView) GetMarkers ¶
func (t *TreeView) GetMarkers() TreeMarkers
GetMarkers returns the marker strings currently used by this tree view.
func (*TreeView) GetPath ¶
GetPath returns all nodes located on the path from the root to the given node, including the root and the node itself. If there is no root node, nil is returned. If there are multiple paths to the node, a random one is chosen and returned.
func (*TreeView) GetRoot ¶
GetRoot returns the root node of the tree. If no such node was previously set, nil is returned.
func (*TreeView) GetRowCount ¶
GetRowCount returns the number of "visible" nodes. This includes nodes which fall outside the tree view's box but notably does not include the children of collapsed nodes. Note that this value is only up to date after the tree view has been drawn.
func (*TreeView) GetScrollOffset ¶
GetScrollOffset returns the number of node rows that were skipped at the top of the tree view. Note that when the user navigates the tree view, this value is only updated after the tree view has been redrawn.
func (*TreeView) Move ¶
Move moves the cursor (if a node is currently selected) or scrolls the tree view (if there is no cursor), by the given offset (positive values to move/scroll down, negative values to move/scroll up). For cursor changes, the offset refers to the number selectable, visible nodes. For scrolling, the offset refers to the number of visible nodes.
If the offset is 0, nothing happens.
func (*TreeView) SetAlign ¶
SetAlign controls the horizontal alignment of the node texts. If set to true, all texts except that of top-level nodes will be placed in the same column. If set to false, they will indent with the hierarchy.
func (*TreeView) SetCenterCursor ¶
SetCenterCursor controls whether the cursor is kept centered whenever possible.
func (*TreeView) SetCurrentNode ¶
SetCurrentNode sets the currently selected node. Provide nil to clear all cursors. Selected nodes must be visible and selectable, or else the cursor will be changed to the top-most selectable and visible node.
This function does NOT trigger the "changed" callback because the actual node that will be selected is not known until the tree is drawn. Triggering the "changed" callback is thus deferred until the next call to TreeView.Draw.
func (*TreeView) SetGraphics ¶
SetGraphics sets a flag which determines whether or not line graphics are drawn to illustrate the tree's hierarchy.
func (*TreeView) SetGraphicsColor ¶
SetGraphicsColor sets the colors of the lines used to draw the tree structure.
func (*TreeView) SetMarkers ¶
func (t *TreeView) SetMarkers(markers TreeMarkers) *TreeView
SetMarkers sets the strings drawn before node text depending on node state. Expanded is used for nodes with children whose children are visible, Collapsed is used for nodes with children whose children are hidden, and Leaf is used for nodes without children.
func (*TreeView) SetPrefixes ¶
SetPrefixes defines the strings drawn before the nodes' texts. This is a slice of strings where each element corresponds to a node's hierarchy level, i.e. 0 for the root, 1 for the root's children, and so on (levels will cycle).
For example, to display a hierarchical list with bullet points:
treeView.SetGraphics(false).
SetPrefixes([]string{"* ", "- ", "x "})
Deeper levels will cycle through the prefixes.
func (*TreeView) SetTopLevel ¶
SetTopLevel sets the first tree level that is visible with 0 referring to the root, 1 to the root's child nodes, and so on. Nodes above the top level are not displayed.