Documentation
¶
Index ¶
- Variables
- func Clamp(v, a, b int) int
- func DrawQuickCharStr(s tcell.Screen, x, y int, str string, quickCharIdx int, style tcell.Style) int
- func DrawRect(s tcell.Screen, x, y, width, height int, char rune, style tcell.Style)
- func DrawRectOutline(s tcell.Screen, x, y, _width, _height int, ul, ur, bl, br, hor, vert rune, ...)
- func DrawRectOutlineDefault(s tcell.Screen, x, y, width, height int, style tcell.Style)
- func DrawStr(s tcell.Screen, x, y int, str string, style tcell.Style) int
- func DrawWindow(s tcell.Screen, x, y, width, height int, title string, theme *Theme)
- func Max(a, b int) int
- func Min(a, b int) int
- func QuickCharInString(s string, idx int) rune
- type Align
- type Button
- func (b *Button) Draw(s tcell.Screen)
- func (b *Button) GetMinSize() (int, int)
- func (c *Button) GetPos() (int, int)
- func (b *Button) GetSize() (int, int)
- func (b *Button) HandleEvent(event tcell.Event) bool
- func (c *Button) SetFocused(v bool)
- func (c *Button) SetPos(x, y int)
- func (b *Button) SetSize(width, height int)
- func (c *Button) SetTheme(theme *Theme)
- type Component
- type FileSelectorDialog
- func (d *FileSelectorDialog) Draw(s tcell.Screen)
- func (d *FileSelectorDialog) GetMinSize() (int, int)
- func (c *FileSelectorDialog) GetPos() (int, int)
- func (c *FileSelectorDialog) GetSize() (int, int)
- func (d *FileSelectorDialog) HandleEvent(event tcell.Event) bool
- func (d *FileSelectorDialog) SetCancelCallback(callback func())
- func (d *FileSelectorDialog) SetFocused(v bool)
- func (d *FileSelectorDialog) SetPos(x, y int)
- func (d *FileSelectorDialog) SetSize(width, height int)
- func (d *FileSelectorDialog) SetTheme(theme *Theme)
- type InputField
- func (f *InputField) Delete(forward bool)
- func (f *InputField) Draw(s tcell.Screen)
- func (f *InputField) GetCursorPos() int
- func (c *InputField) GetMinSize() (int, int)
- func (c *InputField) GetPos() (int, int)
- func (c *InputField) GetSize() (int, int)
- func (f *InputField) HandleEvent(event tcell.Event) bool
- func (f *InputField) Insert(contents []byte)
- func (f *InputField) SetCursorPos(offset int)
- func (f *InputField) SetFocused(v bool)
- func (c *InputField) SetPos(x, y int)
- func (c *InputField) SetSize(width, height int)
- func (f *InputField) SetStyle(style tcell.Style)
- func (c *InputField) SetTheme(theme *Theme)
- func (f *InputField) String() string
- type Item
- type ItemEntry
- type ItemSeparator
- type Label
- type Menu
- func (m *Menu) ActivateItemUnderCursor()
- func (m *Menu) AddItem(item Item)
- func (m *Menu) AddItems(items []Item)
- func (m *Menu) CursorDown()
- func (m *Menu) CursorUp()
- func (m *Menu) Draw(s tcell.Screen)
- func (m *Menu) GetMinSize() (int, int)
- func (m *Menu) GetName() string
- func (c *Menu) GetPos() (int, int)
- func (m *Menu) GetQuickCharIdx() int
- func (m *Menu) GetShortcut() string
- func (m *Menu) GetSize() (int, int)
- func (m *Menu) HandleEvent(event tcell.Event) bool
- func (m *Menu) SetFocused(v bool)
- func (c *Menu) SetPos(x, y int)
- func (m *Menu) SetSize(width, height int)
- func (c *Menu) SetTheme(theme *Theme)
- type MenuBar
- func (b *MenuBar) ActivateMenuUnderCursor()
- func (b *MenuBar) AddMenu(menu *Menu)
- func (b *MenuBar) CursorLeft()
- func (b *MenuBar) CursorRight()
- func (b *MenuBar) Draw(s tcell.Screen)
- func (b *MenuBar) GetMenuXPos(idx int) int
- func (b *MenuBar) GetMinSize() (int, int)
- func (c *MenuBar) GetPos() (int, int)
- func (c *MenuBar) GetSize() (int, int)
- func (b *MenuBar) HandleEvent(event tcell.Event) bool
- func (b *MenuBar) SetFocused(v bool)
- func (c *MenuBar) SetPos(x, y int)
- func (c *MenuBar) SetSize(width, height int)
- func (c *MenuBar) SetTheme(theme *Theme)
- type MessageDialog
- func (d *MessageDialog) Draw(s tcell.Screen)
- func (d *MessageDialog) GetMinSize() (int, int)
- func (c *MessageDialog) GetPos() (int, int)
- func (c *MessageDialog) GetSize() (int, int)
- func (d *MessageDialog) HandleEvent(event tcell.Event) bool
- func (d *MessageDialog) SetFocused(v bool)
- func (d *MessageDialog) SetMessage(message string)
- func (c *MessageDialog) SetPos(x, y int)
- func (d *MessageDialog) SetSize(width, height int)
- func (d *MessageDialog) SetTheme(theme *Theme)
- type MessageDialogKind
- type Panel
- func (p *Panel) Draw(s tcell.Screen)
- func (p *Panel) EachLeaf(rightMost bool, f func(*Panel) bool)
- func (p *Panel) GetMinSize() (int, int)
- func (c *Panel) GetPos() (int, int)
- func (c *Panel) GetSize() (int, int)
- func (p *Panel) HandleEvent(event tcell.Event) bool
- func (p *Panel) IsLeaf() bool
- func (p *Panel) SetFocused(v bool)
- func (c *Panel) SetPos(x, y int)
- func (p *Panel) SetSize(width, height int)
- func (p *Panel) SetTheme(theme *Theme)
- func (p *Panel) UpdateSplits()
- type PanelContainer
- func (c *PanelContainer) ClearSelected() Component
- func (c *PanelContainer) DeleteSelected() Component
- func (c *PanelContainer) Draw(s tcell.Screen)
- func (c *PanelContainer) FloatSelected()
- func (c *PanelContainer) GetFloatingFocused() bool
- func (c *PanelContainer) GetMinSize() (int, int)
- func (c *PanelContainer) GetPos() (int, int)
- func (c *PanelContainer) GetSelected() Component
- func (c *PanelContainer) GetSize() (int, int)
- func (c *PanelContainer) HandleEvent(event tcell.Event) bool
- func (c *PanelContainer) IsRootSelected() bool
- func (c *PanelContainer) SelectNext()
- func (c *PanelContainer) SelectPrev()
- func (c *PanelContainer) SetFloatingFocused(v bool) bool
- func (c *PanelContainer) SetFocused(v bool)
- func (c *PanelContainer) SetPos(x, y int)
- func (c *PanelContainer) SetSelected(item Component)
- func (c *PanelContainer) SetSize(width, height int)
- func (c *PanelContainer) SetTheme(theme *Theme)
- func (c *PanelContainer) SplitSelected(kind SplitKind, item Component)
- func (c *PanelContainer) SwapNeighborsSelected()
- func (c *PanelContainer) UnfloatSelected(kind SplitKind) bool
- type PanelKind
- type SplitKind
- type Tab
- type TabContainer
- func (c *TabContainer) AddTab(name string, child Component)
- func (c *TabContainer) Draw(s tcell.Screen)
- func (c *TabContainer) FocusTab(idx int)
- func (c *TabContainer) GetMinSize() (int, int)
- func (c *TabContainer) GetPos() (int, int)
- func (c *TabContainer) GetSelectedTabIdx() int
- func (c *TabContainer) GetSize() (int, int)
- func (c *TabContainer) GetTab(idx int) *Tab
- func (c *TabContainer) GetTabCount() int
- func (c *TabContainer) HandleEvent(event tcell.Event) bool
- func (c *TabContainer) RemoveTab(idx int) bool
- func (c *TabContainer) SetFocused(v bool)
- func (c *TabContainer) SetPos(x, y int)
- func (c *TabContainer) SetSize(width, height int)
- func (c *TabContainer) SetTheme(theme *Theme)
- type TextEdit
- func (t *TextEdit) ChangeLineDelimiters(crlf bool)
- func (t *TextEdit) Delete(forwards bool)
- func (t *TextEdit) Draw(s tcell.Screen)
- func (t *TextEdit) GetCursor() buffer.Cursor
- func (t *TextEdit) GetLineDelimiter() string
- func (c *TextEdit) GetMinSize() (int, int)
- func (c *TextEdit) GetPos() (int, int)
- func (t *TextEdit) GetSelectedBytes() []byte
- func (c *TextEdit) GetSize() (int, int)
- func (t *TextEdit) HandleEvent(event tcell.Event) bool
- func (t *TextEdit) Insert(contents string)
- func (t *TextEdit) ScrollToCursor()
- func (t *TextEdit) SetContents(contents []byte)
- func (t *TextEdit) SetCursor(newCursor buffer.Cursor)
- func (t *TextEdit) SetFocused(v bool)
- func (c *TextEdit) SetPos(x, y int)
- func (c *TextEdit) SetSize(width, height int)
- func (c *TextEdit) SetTheme(theme *Theme)
- type Theme
Constants ¶
This section is empty.
Variables ¶
var DefaultTheme = Theme{
"Normal": tcell.Style{}.Foreground(tcell.ColorSilver).Background(tcell.ColorBlack),
"Button": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorSilver),
"InputField": tcell.Style{}.Foreground(tcell.ColorSilver).Background(tcell.ColorBlack),
"MenuBar": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorDarkGray),
"MenuBarFocused": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorLightGray),
"Menu": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorSilver),
"MenuSelected": tcell.Style{}.Foreground(tcell.ColorSilver).Background(tcell.ColorBlack),
"TabContainer": tcell.Style{}.Foreground(tcell.ColorGray).Background(tcell.ColorBlack),
"TabContainerFocused": tcell.Style{}.Foreground(tcell.ColorSilver).Background(tcell.ColorBlack),
"TextEdit": tcell.Style{}.Foreground(tcell.ColorSilver).Background(tcell.ColorBlack),
"TextEditSelected": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorSilver),
"Window": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorDarkGray),
"WindowHeader": tcell.Style{}.Foreground(tcell.ColorBlack).Background(tcell.ColorSilver),
}
DefaultTheme uses only the first 16 colors present in most colored terminals.
Functions ¶
func Clamp ¶
Clamp keeps `v` within `a` and `b` numerically. `a` must be smaller than `b`. Returns clamped `v`.
func DrawQuickCharStr ¶
func DrawQuickCharStr(s tcell.Screen, x, y int, str string, quickCharIdx int, style tcell.Style) int
DrawQuickCharStr renders a string very similar to how DrawStr works, but stylizes the quick char (the rune at `quickCharIdx`) with an underline. Returned is the number of columns that were drawn to the screen.
func DrawRect ¶
DrawRect renders a filled box at `x` and `y`, of size `width` and `height`. Will not call `Show()`.
func DrawRectOutline ¶
func DrawRectOutline(s tcell.Screen, x, y, _width, _height int, ul, ur, bl, br, hor, vert rune, style tcell.Style)
DrawRectOutline draws only the outline of a rectangle, using `ul`, `ur`, `bl`, and `br` for the corner runes, and `hor` and `vert` for the horizontal and vertical runes, respectively.
func DrawRectOutlineDefault ¶
func DrawRectOutlineDefault(s tcell.Screen, x, y, width, height int, style tcell.Style)
DrawRectOutlineDefault calls DrawRectOutline with the default edge runes.
func DrawStr ¶
DrawStr will render each character of a string at `x` and `y`. Returned is the number of columns that were drawn to the screen.
func DrawWindow ¶
DrawWindow draws a window-like object at x and y as the top-left corner. This window has an optional title. The Theme values "WindowHeader" and "Window" are used.
func QuickCharInString ¶
QuickCharInString is used for finding the "quick char" in a string. The rune is always made lowercase. A rune of value zero is returned if the index was less than zero, or greater or equal to, the number of runes in s.
Types ¶
type Align ¶
type Align uint8
Align defines the text alignment of a label.
const ( // AlignLeft is the normal text alignment where text is aligned to the left // of its bounding box. AlignLeft Align = iota // AlignRight causes text to be aligned to the right of its bounding box. AlignRight // AlignJustify causes text to be left-aligned, but also spaced so that it // fits the entire box where it is being rendered. AlignJustify )
type Button ¶
type Button struct { Text string Callback func() // contains filtered or unexported fields }
func (*Button) GetMinSize ¶
func (*Button) HandleEvent ¶
func (*Button) SetFocused ¶
func (c *Button) SetFocused(v bool)
type Component ¶
type Component interface { // A component knows its position and size, which is used to draw itself in // its bounding rectangle. Draw(tcell.Screen) // Components can be focused, which may affect how it handles events or draws. // For example, when a button is focused, the Return key may be pressed to // activate the button. SetFocused(bool) // Applies the theme to the component and all of its children. SetTheme(*Theme) // Get position of the Component. GetPos() (x, y int) // Set position of the Component. SetPos(x, y int) // Returns the smallest size the Component can be. GetMinSize() (w, h int) // Get size of the Component. GetSize() (w, h int) // Set size of the component. If size is smaller than minimum, minimum is // used, instead. SetSize(w, h int) // HandleEvent tells the Component to handle the provided event. The Component // should only handle events if it is focused. An event can optionally be // handled. If an event is handled, the function should return true. If the // event went unhandled, the function should return false. HandleEvent(tcell.Event) bool }
A Component refers generally to the behavior of a UI "component". Components include buttons, input fields, and labels. It is expected that after constructing a component, to call the SetPos() function, and possibly SetSize() as well.
Many components implement their own `New...()` function. In those constructor functions, it is good practice for that component to set its size to be its minimum size.
type FileSelectorDialog ¶
type FileSelectorDialog struct { Title string MustExist bool // Whether the dialog should have a user select an existing file. FilesChosenCallback func([]string) // Returns slice of filenames selected. nil if user canceled. // contains filtered or unexported fields }
A FileSelectorDialog is a WindowContainer with an input and buttons for selecting files. It can be used to open zero or more existing files, or select one non-existant file (for saving).
func NewFileSelectorDialog ¶
func NewFileSelectorDialog(screen *tcell.Screen, title string, mustExist bool, theme *Theme, filesChosenCallback func([]string), cancelCallback func()) *FileSelectorDialog
func (*FileSelectorDialog) Draw ¶
func (d *FileSelectorDialog) Draw(s tcell.Screen)
func (*FileSelectorDialog) GetMinSize ¶
func (d *FileSelectorDialog) GetMinSize() (int, int)
func (*FileSelectorDialog) HandleEvent ¶
func (d *FileSelectorDialog) HandleEvent(event tcell.Event) bool
func (*FileSelectorDialog) SetCancelCallback ¶
func (d *FileSelectorDialog) SetCancelCallback(callback func())
func (*FileSelectorDialog) SetFocused ¶
func (d *FileSelectorDialog) SetFocused(v bool)
func (*FileSelectorDialog) SetPos ¶
func (d *FileSelectorDialog) SetPos(x, y int)
func (*FileSelectorDialog) SetSize ¶
func (d *FileSelectorDialog) SetSize(width, height int)
func (*FileSelectorDialog) SetTheme ¶
func (d *FileSelectorDialog) SetTheme(theme *Theme)
type InputField ¶
type InputField struct { Buffer []byte // contains filtered or unexported fields }
An InputField is a single-line input box.
func NewInputField ¶
func NewInputField(screen *tcell.Screen, placeholder []byte, style tcell.Style) *InputField
func (*InputField) Delete ¶
func (f *InputField) Delete(forward bool)
func (*InputField) Draw ¶
func (f *InputField) Draw(s tcell.Screen)
func (*InputField) GetCursorPos ¶
func (f *InputField) GetCursorPos() int
func (*InputField) GetMinSize ¶
func (*InputField) HandleEvent ¶
func (f *InputField) HandleEvent(event tcell.Event) bool
func (*InputField) Insert ¶
func (f *InputField) Insert(contents []byte)
func (*InputField) SetCursorPos ¶
func (f *InputField) SetCursorPos(offset int)
SetCursorPos sets the cursor position offset. Offset is clamped to possible values. The InputField is scrolled to show the new cursor position. The offset is in runes.
func (*InputField) SetFocused ¶
func (f *InputField) SetFocused(v bool)
func (*InputField) SetStyle ¶
func (f *InputField) SetStyle(style tcell.Style)
func (*InputField) String ¶
func (f *InputField) String() string
type Item ¶
type Item interface { GetName() string // Returns a character/rune index of the name of the item. GetQuickCharIdx() int // A Shortcut is a string of the modifiers+key name of the action that must be pressed // to trigger the shortcut. For example: "Ctrl+Alt+X". The order of the modifiers is // very important. Letters are case-sensitive. See the KeyEvent.Name() function of tcell // for information. An empty string implies no shortcut. GetShortcut() string }
Item is an interface implemented by ItemEntry and ItemMenu to be listed in Menus.
type ItemEntry ¶
type ItemEntry struct { Name string QuickChar int // Character/rune index of Name Shortcut string Callback func() }
ItemEntry is a listing in a Menu with a name and callback.
func (*ItemEntry) GetQuickCharIdx ¶
func (*ItemEntry) GetShortcut ¶
type ItemSeparator ¶
type ItemSeparator struct{}
An ItemSeparator is like a blank Item that cannot actually be selected. It is useful for separating items in a Menu.
func (*ItemSeparator) GetName ¶
func (i *ItemSeparator) GetName() string
GetName returns an empty string.
func (*ItemSeparator) GetQuickCharIdx ¶
func (i *ItemSeparator) GetQuickCharIdx() int
func (*ItemSeparator) GetShortcut ¶
func (i *ItemSeparator) GetShortcut() string
type Label ¶
A Label is a component for rendering text. Text can be rendered easily without a Label, but this component forces the text to fit within its bounding box and allows for left-align, right-align, and justify.
func (*Label) GetMinSize ¶
func (*Label) SetFocused ¶
func (c *Label) SetFocused(v bool)
type Menu ¶
type Menu struct { Name string QuickChar int // Character/rune index of Name Items []Item // contains filtered or unexported fields }
A Menu contains one or more ItemEntry or ItemMenus.
func (*Menu) ActivateItemUnderCursor ¶
func (m *Menu) ActivateItemUnderCursor()
func (*Menu) CursorDown ¶
func (m *Menu) CursorDown()
func (*Menu) GetMinSize ¶
func (*Menu) GetQuickCharIdx ¶
func (*Menu) GetShortcut ¶
func (*Menu) HandleEvent ¶
HandleEvent will handle events for a Menu and may propogate them to sub-menus. Returns true if the event was handled.
func (*Menu) SetFocused ¶
SetFocused does not do anything for a Menu.
type MenuBar ¶
type MenuBar struct {
// contains filtered or unexported fields
}
A MenuBar is a horizontal list of menus.
func NewMenuBar ¶
func (*MenuBar) ActivateMenuUnderCursor ¶
func (b *MenuBar) ActivateMenuUnderCursor()
func (*MenuBar) CursorLeft ¶
func (b *MenuBar) CursorLeft()
func (*MenuBar) CursorRight ¶
func (b *MenuBar) CursorRight()
func (*MenuBar) Draw ¶
func (b *MenuBar) Draw(s tcell.Screen)
Draw renders the MenuBar and its sub-menus.
func (*MenuBar) GetMenuXPos ¶
GetMenuXPos returns the X position of the name of Menu at `idx` visually.
func (*MenuBar) GetMinSize ¶
func (*MenuBar) HandleEvent ¶
HandleEvent will propogate events to sub-menus and returns true if any of them handled the event.
func (*MenuBar) SetFocused ¶
SetFocused highlights the MenuBar and focuses any sub-menus.
type MessageDialog ¶
type MessageDialog struct { Title string Kind MessageDialogKind Callback func(string) // contains filtered or unexported fields }
func NewMessageDialog ¶
func NewMessageDialog(title string, message string, kind MessageDialogKind, options []string, theme *Theme, callback func(string)) *MessageDialog
func (*MessageDialog) Draw ¶
func (d *MessageDialog) Draw(s tcell.Screen)
func (*MessageDialog) GetMinSize ¶
func (d *MessageDialog) GetMinSize() (int, int)
func (*MessageDialog) HandleEvent ¶
func (d *MessageDialog) HandleEvent(event tcell.Event) bool
func (*MessageDialog) SetFocused ¶
func (d *MessageDialog) SetFocused(v bool)
func (*MessageDialog) SetMessage ¶
func (d *MessageDialog) SetMessage(message string)
func (*MessageDialog) SetSize ¶
func (d *MessageDialog) SetSize(width, height int)
func (*MessageDialog) SetTheme ¶
func (d *MessageDialog) SetTheme(theme *Theme)
type MessageDialogKind ¶
type MessageDialogKind uint8
const ( MessageKindNormal MessageDialogKind = iota MessageKindWarning MessageKindError )
type Panel ¶
type Panel struct { Parent *Panel Left Component Right Component SplitAt int Kind PanelKind // contains filtered or unexported fields }
A Panel represents a container for a split view between two items. The Kind tells how to interpret the Left and Right fields. The SplitAt is the column between 0 and width or height, representing the position of the split between the Left and Right, respectively.
If the Kind is equal to PanelKindEmpty, then both Left and Right are nil. If the Kind is equal to PanelKindSingle, then only Left has value,
and its value will NOT be of type Panel. The SplitAt will not be used, as the Left will take up the whole space.
If the Kind is equal to PanelKindSplitVert, then both Left and Right will
have value, and they will both have to be of type Panel. The split will be represented vertically, and the SplitAt spans 0 to height; top to bottom, respectively.
If the Kind is equal to PanelKindSplitHor, then both Left and Right will
have value, and they will both have to be of type Panel. The split will be represented horizontally, and the SplitAt spans 0 to width; left to right.
func (*Panel) EachLeaf ¶
EachLeaf visits the entire tree, and calls function `f` at each leaf Panel. If the function `f` returns true, then visiting stops. if `rtl` is true, the tree is traversed in right-most order. The default is to traverse in left-most order.
The caller of this function can safely assert that Panel's Kind is always either `PanelKindSingle` or `PanelKindEmpty`.
func (*Panel) GetMinSize ¶
GetMinSize returns the combined minimum sizes of the Panel's children.
func (*Panel) HandleEvent ¶
HandleEvent propogates the event to all children, calling HandleEvent() on left-most items. As usual: returns true if handled, false if unhandled. This function relies on the behavior of the child Components to only handle events if they are focused.
func (*Panel) IsLeaf ¶
IsLeaf returns whether the Panel is a leaf or not. A leaf is a panel with Kind `PanelKindEmpty` or `PanelKindSingle`.
func (*Panel) SetFocused ¶
SetFocused sets this Panel's Focused field to `v`. Then, if the Panel's Kind is PanelKindSingle, it sets its child (not a Panel) focused to `v`, also.
func (*Panel) SetSize ¶
SetSize sets the Panel size to the given width, and height. It will not check against GetMinSize() because it may be costly to do so. SetSize clamps the Panel's SplitAt to be within the new size of the Panel.
func (*Panel) UpdateSplits ¶
func (p *Panel) UpdateSplits()
UpdateSplits uses the position and size of the Panel, along with its Weight and Kind, to appropriately size and place its children. It calls UpdateSplits() on its child Panels.
type PanelContainer ¶
type PanelContainer struct {
// contains filtered or unexported fields
}
func NewPanelContainer ¶
func NewPanelContainer(theme *Theme) *PanelContainer
func (*PanelContainer) ClearSelected ¶
func (c *PanelContainer) ClearSelected() Component
ClearSelected makes the selected Panel empty, but does not delete it from the tree.
func (*PanelContainer) DeleteSelected ¶
func (c *PanelContainer) DeleteSelected() Component
DeleteSelected deletes the selected Panel and returns its child Component. If the selected Panel is the root Panel, ClearSelected() is called, instead.
func (*PanelContainer) Draw ¶
func (c *PanelContainer) Draw(s tcell.Screen)
func (*PanelContainer) FloatSelected ¶
func (c *PanelContainer) FloatSelected()
FloatSelected makes the selected Panel floating. This function does not focus the newly floated Panel. To focus the floating panel, call SetFloatingFocused().
func (*PanelContainer) GetFloatingFocused ¶
func (c *PanelContainer) GetFloatingFocused() bool
GetFloatingFocused returns true if a floating window is selected or focused.
func (*PanelContainer) GetMinSize ¶
func (c *PanelContainer) GetMinSize() (int, int)
func (*PanelContainer) GetPos ¶
func (c *PanelContainer) GetPos() (int, int)
func (*PanelContainer) GetSelected ¶
func (c *PanelContainer) GetSelected() Component
func (*PanelContainer) GetSize ¶
func (c *PanelContainer) GetSize() (int, int)
func (*PanelContainer) HandleEvent ¶
func (c *PanelContainer) HandleEvent(event tcell.Event) bool
func (*PanelContainer) IsRootSelected ¶
func (c *PanelContainer) IsRootSelected() bool
func (*PanelContainer) SelectNext ¶
func (c *PanelContainer) SelectNext()
func (*PanelContainer) SelectPrev ¶
func (c *PanelContainer) SelectPrev()
func (*PanelContainer) SetFloatingFocused ¶
func (c *PanelContainer) SetFloatingFocused(v bool) bool
SetFloatingFocused sets whether the floating Panels are focused. When true, the current Panel will be unselected and the front floating Panel will become the new selected if there any floating windows. If false, the same, but the last selected non-floating Panel will become focused.
The returned boolean is whether floating windows were able to be focused. If there are no floating windows when trying to focus them, this will inevitably return false, for example.
func (*PanelContainer) SetFocused ¶
func (c *PanelContainer) SetFocused(v bool)
func (*PanelContainer) SetPos ¶
func (c *PanelContainer) SetPos(x, y int)
func (*PanelContainer) SetSelected ¶
func (c *PanelContainer) SetSelected(item Component)
func (*PanelContainer) SetSize ¶
func (c *PanelContainer) SetSize(width, height int)
func (*PanelContainer) SetTheme ¶
func (c *PanelContainer) SetTheme(theme *Theme)
func (*PanelContainer) SplitSelected ¶
func (c *PanelContainer) SplitSelected(kind SplitKind, item Component)
SplitSelected splits the selected Panel with the given Component `item`. The type of split (vertical or horizontal) is determined with the `kind`. If `item` is nil, the new Panel will be of kind empty.
func (*PanelContainer) SwapNeighborsSelected ¶
func (c *PanelContainer) SwapNeighborsSelected()
SwapNeighborsSelected swaps two Left and Right child Panels of a vertical or horizontally split Panel. This is necessary to achieve a "split top" or "split left" effect, as Panels only split open to the bottom or right.
func (*PanelContainer) UnfloatSelected ¶
func (c *PanelContainer) UnfloatSelected(kind SplitKind) bool
UnfloatSelected moves any selected floating Panel to the normal tree that is accessible in the standard focus mode. This function will cause focus to go to the normal tree if there are no remaining floating windows after the operation.
Like SetFloatingFocused(), the boolean returned is whether the PanelContainer is focusing floating windows after the operation.
type SplitKind ¶
type SplitKind uint8
const ( SplitVertical SplitKind = SplitKind(PanelKindSplitVert) + iota SplitHorizontal )
type TabContainer ¶
type TabContainer struct {
// contains filtered or unexported fields
}
A TabContainer organizes children by showing only one of them at a time.
func NewTabContainer ¶
func NewTabContainer(theme *Theme) *TabContainer
func (*TabContainer) AddTab ¶
func (c *TabContainer) AddTab(name string, child Component)
func (*TabContainer) Draw ¶
func (c *TabContainer) Draw(s tcell.Screen)
Draw will draws the border of the BoxContainer, then it draws its child component.
func (*TabContainer) FocusTab ¶
func (c *TabContainer) FocusTab(idx int)
FocusTab sets the visible tab to the one at `idx`. FocusTab clamps `idx` between 0 and tab_count - 1. If no tabs are present, the function does nothing.
func (*TabContainer) GetMinSize ¶
func (*TabContainer) GetSelectedTabIdx ¶
func (c *TabContainer) GetSelectedTabIdx() int
func (*TabContainer) GetTab ¶
func (c *TabContainer) GetTab(idx int) *Tab
func (*TabContainer) GetTabCount ¶
func (c *TabContainer) GetTabCount() int
func (*TabContainer) HandleEvent ¶
func (c *TabContainer) HandleEvent(event tcell.Event) bool
HandleEvent forwards the event to the child Component and returns whether it was handled.
func (*TabContainer) RemoveTab ¶
func (c *TabContainer) RemoveTab(idx int) bool
RemoveTab deletes the tab at `idx`. Returns true if the tab was found, false otherwise.
func (*TabContainer) SetFocused ¶
func (c *TabContainer) SetFocused(v bool)
SetFocused calls SetFocused on the visible child Component.
func (*TabContainer) SetPos ¶
func (c *TabContainer) SetPos(x, y int)
SetPos sets the position of the container and updates the child Component.
func (*TabContainer) SetSize ¶
func (c *TabContainer) SetSize(width, height int)
SetSize sets the size of the container and updates the size of the child Component.
func (*TabContainer) SetTheme ¶
func (c *TabContainer) SetTheme(theme *Theme)
SetTheme sets the theme.
type TextEdit ¶
type TextEdit struct { Buffer buffer.Buffer Highlighter *buffer.Highlighter LineNumbers bool // Whether to render line numbers (and therefore the column) Dirty bool // Whether the buffer has been edited UseHardTabs bool // When true, tabs are '\t' TabSize int // How many spaces to indent by IsCRLF bool // Whether the file's line endings are CRLF (\r\n) or LF (\n) FilePath string // Will be empty if the file has not been saved yet // contains filtered or unexported fields }
TextEdit is a field for line-based editing. It features syntax highlighting tools, is autocomplete ready, and contains the various information about content being edited.
func NewTextEdit ¶
New will initialize the buffer using the given 'contents'. If the 'filePath' or 'FilePath' is empty, it can be assumed that the TextEdit has no file association, or it is unsaved.
func (*TextEdit) ChangeLineDelimiters ¶
Changes a file's line delimiters. If `crlf` is true, then line delimiters are replaced with Windows CRLF (\r\n). If `crlf` is false, then line delimtiers are replaced with Unix LF (\n). The TextEdit `IsCRLF` variable is updated with the new value.
func (*TextEdit) Delete ¶
Delete with `forwards` false will backspace, destroying the character before the cursor, while Delete with `forwards` true will delete the character after (or on) the cursor. In insert mode, forwards is always true.
func (*TextEdit) Draw ¶
func (t *TextEdit) Draw(s tcell.Screen)
Draw renders the TextEdit component.
func (*TextEdit) GetLineDelimiter ¶
GetLineDelimiter returns "\r\n" for a CRLF buffer, or "\n" for an LF buffer.
func (*TextEdit) GetMinSize ¶
func (*TextEdit) GetSelectedBytes ¶
GetSelectedBytes returns a byte slice of the region of the buffer that is currently selected. If the returned string is empty, then nothing was selected. The slice returned may or may not be a copy of the buffer, so do not write to it.
func (*TextEdit) HandleEvent ¶
HandleEvent allows the TextEdit to handle `event` if it chooses, returns whether the TextEdit handled the event.
func (*TextEdit) Insert ¶
Writes `contents` at the cursor position. Line delimiters and tab character supported. Any other control characters will be printed. Overwrites any active selection.
func (*TextEdit) ScrollToCursor ¶
func (t *TextEdit) ScrollToCursor()
Scroll the screen if the cursor is out of view.
func (*TextEdit) SetContents ¶
SetContents applies the string to the internal buffer of the TextEdit component. The string is determined to be either CRLF or LF based on line-endings.
func (*TextEdit) SetFocused ¶
SetFocused sets whether the TextEdit is focused. When focused, the cursor is set visible and its position is updated on every event.
type Theme ¶
type Theme map[string]tcell.Style
A Theme is a map of string names to styles. Themes can be passed by reference to components to set their styles. Some components will depend upon the basic keys, but most components may use keys specific to their component. If a theme value cannot be found, then the `DefaultTheme` value will be used, instead. An updated list of theme keys can be found on the default theme.