Documentation ¶
Index ¶
- type Banner
- type ListItem
- type Modal
- type ModalLayout
- func (m *ModalLayout) AddDynamicModal(modal Modal, size ModalSize)
- func (m *ModalLayout) AddFixedModal(modal Modal, height, width uint, size ModalSize)
- func (m *ModalLayout) Blur()
- func (m *ModalLayout) Draw(screen tcell.Screen)
- func (m *ModalLayout) Focus(delegate func(p cview.Primitive))
- func (m *ModalLayout) GetFocusable() cview.Focusable
- func (m *ModalLayout) GetGridSize() []int
- func (m *ModalLayout) GetRect() (int, int, int, int)
- func (m *ModalLayout) GetVisible() bool
- func (m *ModalLayout) Grid() *cview.Grid
- func (m *ModalLayout) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
- func (m *ModalLayout) MouseHandler() ...
- func (m *ModalLayout) RemoveModal(modal Modal)
- func (m *ModalLayout) SetGridXSize(grid []int) error
- func (m *ModalLayout) SetGridYSize(grid []int) error
- func (m *ModalLayout) SetRect(x, y, width, height int)
- func (m *ModalLayout) SetVisible(v bool)
- type ModalSize
- type NavBar
- func (n *NavBar) AddButton(button *cview.Button, key tcell.Key)
- func (n *NavBar) Blur()
- func (n *NavBar) Draw(screen tcell.Screen)
- func (n *NavBar) Focus(delegate func(p cview.Primitive))
- func (n *NavBar) GetFocusable() cview.Focusable
- func (n *NavBar) GetRect() (int, int, int, int)
- func (n *NavBar) GetVisible() bool
- func (n *NavBar) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
- func (n *NavBar) MouseHandler() ...
- func (n *NavBar) SetRect(x, y, width, height int)
- func (n *NavBar) SetVisible(v bool)
- type NavBarColors
- type ScrollList
- func (s *ScrollList) AddItem(i ListItem)
- func (s *ScrollList) AddItems(i ...ListItem)
- func (s *ScrollList) Blur()
- func (s *ScrollList) Clear()
- func (s *ScrollList) Draw(screen tcell.Screen)
- func (s *ScrollList) Focus(delegate func(p cview.Primitive))
- func (s *ScrollList) GetItems() []ListItem
- func (s *ScrollList) GetSelectedIndex() int
- func (s *ScrollList) HasFocus() bool
- func (s *ScrollList) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
- func (s *ScrollList) MouseHandler() ...
- func (s *ScrollList) SetBlurFunc(blur func(key tcell.Key))
- func (s *ScrollList) SetBorder(b bool) *cview.Box
- func (s *ScrollList) SetIndexChangedFunc(indexChanged func(int) bool)
- func (s *ScrollList) SetRect(x, y, w, h int)
- func (s *ScrollList) SetSelected(index int)
- type Selectable
- type Selection
- type Sort
- type Table
- func (t *Table) AddRow(index int, content ...string) *Table
- func (t *Table) Clear(headers bool) *Table
- func (t *Table) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
- func (t *Table) SetAddCellFunc(cellFunc func(cell *cview.TableCell, header bool, col int)) *Table
- func (t *Table) SetColumnExpansions(expansions []int)
- func (t *Table) SetColumnWidths(widths []int)
- func (t *Table) SetColumns(columns []string) *Table
- func (t *Table) SetShowIndex(index bool)
- func (t *Table) SetSort(column int, sort Sort) *Table
- func (t *Table) SetSortFunc(sortFunc func(column string, sort Sort)) *Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Banner ¶
type Banner struct { *cview.Grid //Selectable are all primitives that can be navigated and selected inside Banner. Selectable []Selectable // contains filtered or unexported fields }
Banner combines grid layout and form-movement. To use, configure grid and add elements to it. To allow some item to be selected, add it to Banner.Selectable. Order in this array is same as with selections. Only buttons are supported as selectables. Most of the logic has been copied cview.Form.
type ListItem ¶
ListItem is an item that can be used in ScrollList. Additional SetSelected is required since item doesn't receive focus on selection but still gets to change its visual style.
type Modal ¶
type Modal interface { //Primitive cview.Primitive //SetDoneFunc sets function that get's called when modal wants to close itself SetDoneFunc(doneFunc func()) //Setvisible tells modal to show or hide itself SetVisible(visible bool) }
Modal interface is primitive that is drawn on top of other views and get's destroyed when it's ready
type ModalLayout ¶
type ModalLayout struct {
// contains filtered or unexported fields
}
ModalLayout is a grid layout that draws modal on center of grid. To add ordinary items to layout, get grid with Grid() function. Layout consists of 10 columns and rows, each one of size -1. This can be changed with SetGridSize, but size must still 10. Modal is drawn on middle 4 cells Use AddModal and RemoveModal to manage modals. Only single modal can be shown at a time.
func NewModalLayout ¶
func NewModalLayout() *ModalLayout
NewModalLayout creates new modal layout. Default grid is [-1, -1, -1, -1, -1]. This can be modified by accessing grid with ModalLayout.Grid()
func (*ModalLayout) AddDynamicModal ¶
func (m *ModalLayout) AddDynamicModal(modal Modal, size ModalSize)
AddDynamicModal adds modal of dynamic size
func (*ModalLayout) AddFixedModal ¶
func (m *ModalLayout) AddFixedModal(modal Modal, height, width uint, size ModalSize)
AddFixedModal adds modal of fixed size. Size parameter controls how many rows and columns are used for modal
func (*ModalLayout) Blur ¶
func (m *ModalLayout) Blur()
func (*ModalLayout) Draw ¶
func (m *ModalLayout) Draw(screen tcell.Screen)
func (*ModalLayout) Focus ¶
func (m *ModalLayout) Focus(delegate func(p cview.Primitive))
func (*ModalLayout) GetFocusable ¶
func (m *ModalLayout) GetFocusable() cview.Focusable
func (*ModalLayout) GetGridSize ¶
func (m *ModalLayout) GetGridSize() []int
GetGridSize returns grid that's in use
func (*ModalLayout) GetVisible ¶
func (m *ModalLayout) GetVisible() bool
func (*ModalLayout) Grid ¶
func (m *ModalLayout) Grid() *cview.Grid
GetGrid returns underlying grid that items are added to
func (*ModalLayout) InputHandler ¶
func (m *ModalLayout) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
func (*ModalLayout) MouseHandler ¶
func (m *ModalLayout) MouseHandler() func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive)
func (*ModalLayout) RemoveModal ¶
func (m *ModalLayout) RemoveModal(modal Modal)
RemoveModal removes modal
func (*ModalLayout) SetGridXSize ¶
func (m *ModalLayout) SetGridXSize(grid []int) error
SetGrixXSize sets grid in horizontal direction
func (*ModalLayout) SetGridYSize ¶
func (m *ModalLayout) SetGridYSize(grid []int) error
SetGrixYSize sets grid in vertical direction
func (*ModalLayout) SetRect ¶
func (m *ModalLayout) SetRect(x, y, width, height int)
func (*ModalLayout) SetVisible ¶
func (m *ModalLayout) SetVisible(v bool)
type ModalSize ¶
type ModalSize int
ModalSize describes both horizontal & vertical size for modal
const ( //ModalSizeSmall creates modal of 1/5 size of layout, or 2 columns ModalSizeSmall ModalSize = 2 //ModalSizeMedium creates modal of 2/5 size of layout, or 4 columns ModalSizeMedium ModalSize = 3 //ModalSizeMedium creates modal of 3/5 size of layout, or 6 columns ModalSizeLarge ModalSize = 4 )
type NavBar ¶
type NavBar struct {
// contains filtered or unexported fields
}
NavBar implements navigation bar with multiple buttons. Buttons can be added one by one, each one having their own callbacks. In addition, optional DoneFunc is called with label of the selected button.
func NewNavBar ¶
func NewNavBar(colors *NavBarColors, doneFunc func(label string)) *NavBar
NewNavBar creates new navigation bar. DoneFunc is called with buttons label whenever user clicks some button. DoneFunc can be set nil.
func (*NavBar) AddButton ¶
AddButton adds a new button to right side of existing buttons. Key is used to print and highlight key to user
func (*NavBar) GetFocusable ¶
func (*NavBar) GetVisible ¶
func (*NavBar) InputHandler ¶
func (*NavBar) MouseHandler ¶
func (n *NavBar) MouseHandler() func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive)
func (*NavBar) SetVisible ¶
type NavBarColors ¶
type NavBarColors struct {}
NacBarColors are colors that fully describe navbar look
type ScrollList ¶
type ScrollList struct { *cview.Grid *cview.ContextMenu // Padding is num of rows or relative expansion, see cview.Grid.SetColumns() for usage Padding int ItemHeight int // PreInputHandler is called before actual InputHandler, if any. PreInputHandler func(event *tcell.EventKey, setFocus func(p cview.Primitive)) // contains filtered or unexported fields }
ScrollGrid is a list that can have more items than it can currently show. It allows user to scroll items. It also manages rows dynamically. Use Padding and ItemHeight to change grid size. Use Up/Down + (vim: j/k/g/G) to navigate between items and Enter to select item.
func NewScrollList ¶
func NewScrollList(selectFunc func(index int)) *ScrollList
NewScrollList creates new scroll grid. selectFunc is called whenever user presses Enter on some item. SelectFunc can be nil.
func (*ScrollList) AddItems ¶
func (s *ScrollList) AddItems(i ...ListItem)
AddItems appends multiple items
func (*ScrollList) Blur ¶
func (s *ScrollList) Blur()
func (*ScrollList) Draw ¶
func (s *ScrollList) Draw(screen tcell.Screen)
func (*ScrollList) Focus ¶
func (s *ScrollList) Focus(delegate func(p cview.Primitive))
func (*ScrollList) GetItems ¶
func (s *ScrollList) GetItems() []ListItem
func (*ScrollList) GetSelectedIndex ¶
func (s *ScrollList) GetSelectedIndex() int
func (*ScrollList) HasFocus ¶
func (s *ScrollList) HasFocus() bool
func (*ScrollList) InputHandler ¶
func (s *ScrollList) InputHandler() func(event *tcell.EventKey, setFocus func(p cview.Primitive))
func (*ScrollList) MouseHandler ¶
func (s *ScrollList) MouseHandler() func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive)
MouseHandler returns the mouse handler for this primitive.
func (*ScrollList) SetBlurFunc ¶
func (s *ScrollList) SetBlurFunc(blur func(key tcell.Key))
func (*ScrollList) SetIndexChangedFunc ¶
func (s *ScrollList) SetIndexChangedFunc(indexChanged func(int) bool)
SetIndexChangedFunc sets a function that gets called every time list index is about to change. New index is passed to function. If it returns true, index changes. If false, index is being retained.
func (*ScrollList) SetRect ¶
func (s *ScrollList) SetRect(x, y, w, h int)
func (*ScrollList) SetSelected ¶
func (s *ScrollList) SetSelected(index int)
SetSelected sets active index. First item is 0. If value is out of bounds, do nothing.
type Selectable ¶
type Selectable interface { cview.Primitive // SetBlurFunc sets blur function that gets called upon blurring primitive SetBlurFunc(func(key tcell.Key)) }
Selectable is a primitive that's able to set blur func
type Table ¶
Table extends cview.Table with some helpers for managing rows. In addition it provides sorting capabilities.
func (*Table) Clear ¶
Clear clears the content of the table. If headers==true, remove headers as well
func (*Table) InputHandler ¶
Inputhandler handles header row inputs
func (*Table) SetAddCellFunc ¶
SetAddCellFunc add function callback that gets called every time a new cell is added with flag of whether the cell is in header row. Use this to modify e.g. style of the cell when it gets added to table.
func (*Table) SetColumnExpansions ¶
SetColumnExpansions sets how each column will expand / shrink when changing terminal size. If index is included as first row, it must be included in here.
func (*Table) SetColumnWidths ¶
SetColumnWidths sets each columns maximum width. If index is included as first row, it must be included in here.
func (*Table) SetColumns ¶
SetColumns set column header names. This will clear the table
func (*Table) SetShowIndex ¶
SetShowIndex configure whether first column in table is item index. If set, first item is in index 1. Changing this does not update existing data. Thus data needs to be cleared and rows added again for changes to take effect