Documentation
¶
Index ¶
- Constants
- Variables
- func MergeStyle(a, b tcell.Style) tcell.Style
- func ModelInRect(m Model, x, y int) bool
- 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 PrintStyled(screen tcell.Screen, text string, x, y, skipWidth, maxWidth int, ...) (start, end, printedWidth int)
- func PrintWithStyle(screen tcell.Screen, text string, x, y, maxWidth int, alignment Alignment, ...) (int, int)
- func WordWrap(text string, width int) []string
- type Alignment
- type Application
- type ApplicationOption
- type BorderSet
- type Borders
- type Box
- func (b *Box) BackgroundColor() tcell.Color
- func (b *Box) Blur()
- func (b *Box) BorderPadding() (top, bottom, left, right int)
- func (b *Box) BorderSet() BorderSet
- func (b *Box) Borders() Borders
- func (b *Box) Focus(delegate func(m Model))
- func (b *Box) Footer() 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
- func (b *Box) View(screen tcell.Screen)
- type Button
- func (b *Button) Disabled() bool
- func (b *Button) Label() 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
- func (b *Button) View(screen tcell.Screen)
- type ButtonExitMsg
- type ButtonSelectedMsg
- type Checkbox
- func (c *Checkbox) Checked() bool
- func (c *Checkbox) Disabled() bool
- func (c *Checkbox) Focus(delegate func(m Model))
- func (c *Checkbox) GetFieldHeight() int
- func (c *Checkbox) GetFieldWidth() int
- func (c *Checkbox) Label() string
- 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
- func (c *Checkbox) View(screen tcell.Screen)
- type Cmd
- type FocusMsg
- 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) *Form
- func (f *Form) AddPasswordField(label, value string, fieldWidth int, mask rune) *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) 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
- func (f *Form) View(screen tcell.Screen)
- type FormCancelMsg
- type FormItem
- type FormSubmitMsg
- type GlyphSet
- type InitMsg
- type InputField
- func (i *InputField) Blur()
- func (i *InputField) Disabled() bool
- func (i *InputField) FieldStyle() tcell.Style
- func (i *InputField) FieldWidth() int
- func (i *InputField) Focus(delegate func(m Model))
- func (i *InputField) GetFieldHeight() int
- func (i *InputField) GetFieldWidth() int
- func (i *InputField) HasFocus() bool
- func (i *InputField) Label() string
- func (i *InputField) LabelStyle() tcell.Style
- 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) Text() string
- func (i *InputField) Update(msg Msg) Cmd
- func (i *InputField) View(screen tcell.Screen)
- type InputFieldChangedMsg
- type KeyMsg
- type Line
- type LineBuilder
- type Model
- type MouseAction
- type MouseMsg
- type Msg
- type PasteMsg
- type ResizeMsg
- type ScrollBar
- 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
- func (s *ScrollBar) View(screen tcell.Screen)
- type ScrollBarArrows
- type ScrollLengths
- type Segment
- type Style
- type TextArea
- func (t *TextArea) Disabled() bool
- 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) GetFieldHeight() int
- func (t *TextArea) GetFieldWidth() int
- func (t *TextArea) GetSelection() (text string, start int, end int)
- func (t *TextArea) GetTextLength() int
- func (t *TextArea) GetWordUnderCursor(f func(rune) bool) (int, string, rune)
- func (t *TextArea) HasSelection() bool
- func (t *TextArea) Label() string
- func (t *TextArea) LabelStyle() tcell.Style
- func (t *TextArea) LabelWidth() int
- func (t *TextArea) LineCount(limit int) int
- func (t *TextArea) Offset() (row, column int)
- 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) SetVisibleSize(width, height int)
- func (t *TextArea) SetWordWrap(wrapOnWords bool) *TextArea
- func (t *TextArea) SetWrap(wrap bool) *TextArea
- func (t *TextArea) Text() string
- func (t *TextArea) TextStyle() tcell.Style
- func (t *TextArea) Update(msg Msg) Cmd
- func (t *TextArea) View(screen tcell.Screen)
- 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) Disabled() bool
- func (t *TextView) Focus(delegate func(m Model))
- func (t *TextView) GetFieldHeight() int
- func (t *TextView) GetFieldWidth() int
- func (t *TextView) GetOriginalLineCount() int
- func (t *TextView) GetScrollOffset() (row, column int)
- func (t *TextView) GetWrappedLineCount() int
- func (t *TextView) HasFocus() bool
- func (t *TextView) Height(width int) int
- func (t *TextView) Label() string
- func (t *TextView) Lines() []Line
- 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) Text() string
- func (t *TextView) Update(msg Msg) Cmd
- func (t *TextView) View(screen tcell.Screen)
- func (t *TextView) Write(p []byte) (n int, err error)
- type TextViewWriter
- type Theme
- type TrackClickBehavior
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 MergeStyle ¶
MergeStyle layers b on top of a and returns the result, merging every style component. Colors (foreground, background, underline) set on b — i.e. not tcell.ColorDefault — override a's; otherwise a's are kept. The underline style and hyperlink set on b likewise win over a's. Boolean attributes (bold, dim, italic, blink, reverse, strikethrough) are the union of both.
func ModelInRect ¶
ModelInRect reports whether x,y is inside m's rectangle.
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 PrintStyled ¶
func PrintStyled(screen tcell.Screen, text string, x, y, skipWidth, maxWidth int, alignment Alignment, style tcell.Style, maintainBackground bool) (start, end, printedWidth int)
PrintStyled works like Print but it takes a style instead of just a foreground color. The skipWidth parameter specifies the number of cells skipped at the beginning of the text. It returns the start index, end index (exclusively), and screen width of the text actually printed. If maintainBackground is "true", the existing screen background is not changed (i.e. the style's background color is ignored).
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.
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(options ...ApplicationOption) *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) 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.
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 ApplicationOption ¶
type ApplicationOption func(*Application)
func WithScreen ¶
func WithScreen(screen tcell.Screen) ApplicationOption
func WithoutCatchPanics ¶
func WithoutCatchPanics() ApplicationOption
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.
func (*Box) BackgroundColor ¶
BackgroundColor returns the box's background color.
func (*Box) BorderPadding ¶
BorderPadding returns the configured border padding.
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.
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 ButtonExitMsg ¶
type ButtonSelectedMsg ¶
type ButtonSelectedMsg struct {
Label string
}
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.
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 FocusMsg ¶
type FocusMsg = *tcell.EventFocus
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).
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, and a field width (a value of 0 extends it as far as possible). Handle InputFieldChangedMsg to react to text changes.
func (*Form) AddPasswordField ¶
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 a mask character. Handle InputFieldChangedMsg to react to text changes.
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 FormCancelMsg struct{}
type FormItem ¶
type FormItem interface {
Model
// Label returns the item's label text.
Label() 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
// Disabled returns whether or not the item is disabled / read-only.
Disabled() bool
}
FormItem is the interface all form items must implement to be able to be included in a form.
type FormSubmitMsg ¶
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 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 and InputField.SetMaskCharacter to hide input from onlookers (e.g. for password input). Handle InputFieldChangedMsg to react to text changes.
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.
func (*InputField) Disabled ¶
func (i *InputField) Disabled() bool
Disabled returns whether or not the item is disabled / read-only.
func (*InputField) FieldStyle ¶
func (i *InputField) FieldStyle() tcell.Style
FieldStyle returns the style of the input area (when no placeholder is shown).
func (*InputField) FieldWidth ¶
func (i *InputField) FieldWidth() int
FieldWidth returns this model's field width.
func (*InputField) Focus ¶
func (i *InputField) Focus(delegate func(m Model))
Focus is called when this model receives focus.
func (*InputField) GetFieldHeight ¶
func (i *InputField) GetFieldHeight() int
GetFieldHeight returns this model's field height.
func (*InputField) GetFieldWidth ¶
func (i *InputField) GetFieldWidth() int
GetFieldWidth implements FormItem.
func (*InputField) HasFocus ¶
func (i *InputField) HasFocus() bool
HasFocus returns whether or not this model has focus.
func (*InputField) Label ¶
func (i *InputField) Label() string
Label returns the text to be displayed before the input area.
func (*InputField) LabelStyle ¶
func (i *InputField) LabelStyle() tcell.Style
LabelStyle returns the style of the label.
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. It does not emit InputFieldChangedMsg; only user edits do.
func (*InputField) Text ¶
func (i *InputField) Text() string
Text returns the current text of the input field.
func (*InputField) Update ¶
func (i *InputField) Update(msg Msg) Cmd
Update handles input events for this model.
func (*InputField) View ¶
func (i *InputField) View(screen tcell.Screen)
View draws this model onto the screen.
type InputFieldChangedMsg ¶
type InputFieldChangedMsg struct {
// Text is the field's text after the change.
Text string
}
InputFieldChangedMsg is emitted by an InputField when its text changes in response to user input.
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 Model ¶
type Model interface {
// Update receives messages when this model has focus.
Update(Msg) Cmd
// View draws this model onto the screen.
View(tcell.Screen)
// 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 ResizeMsg ¶
type ResizeMsg = *tcell.EventResize
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) GetFieldHeight ¶
GetFieldHeight returns this model's field height.
func (*TextArea) GetFieldWidth ¶
GetFieldWidth returns this model's field width.
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) GetTextLength ¶
GetTextLength returns the string length of the text in the text area.
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) LabelStyle ¶
LabelStyle returns the style of the label.
func (*TextArea) LabelWidth ¶
LabelWidth returns the screen width of the label.
func (*TextArea) LineCount ¶
LineCount returns the number of visual lines, honoring the current wrap settings and last drawn width. Returns at least 1.
If limit > 0, scanning stops once more than limit lines are found and the result is capped at limit+1 (so the caller can detect overflow in O(limit) work). Pass limit <= 0 for the exact count.
If the text area hasn't been drawn yet (no known width), only explicit newlines are counted.
func (*TextArea) Offset ¶
Offset 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) 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) SetVisibleSize ¶
SetVisibleSize sets the inner width and/or height used for cursor clamping and scroll math before the next draw. Pass 0 (or negative) for a dimension to leave it unchanged.
Needed when the caller resizes the text area externally on a text change (e.g. an auto-growing input): otherwise scroll updates on the same keystroke would use stale dimensions.
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.
func (*TextArea) 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.
func (*TextArea) Text ¶
Text returns the entire text of the text area. Note that this will newly allocate the entire text.
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) 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 )