Documentation ¶
Index ¶
- Constants
- func SetLightTheme()
- type Binding
- type Event
- type SortMetadata
- type TabView
- type TermWindow
- func (w *TermWindow) AddOnClearCallback(f func(Event))
- func (w *TermWindow) AddOnExitCallback(f func(Event))
- func (w *TermWindow) AddOnSortCallback(f func(Event))
- func (w *TermWindow) AddOnTabSwitchCallback(f func(Event))
- func (w *TermWindow) Destroy()
- func (w *TermWindow) Init() error
- func (w *TermWindow) SetState(s string)
- func (w *TermWindow) Start()
- func (w *TermWindow) ViewAtTab(i int) TabView
Constants ¶
const ( KeyTabLeft = "<Left>" KeyTabRight = "<Right>" KeyScrollDown = "<Down>" KeyScrollUp = "<Up>" KeyQuit = "q" KeyFilter = "/" KeyCancel = "<Escape>" KeyDeleteChar = "<Backspace>" KeyF1 = "<F1>" KeyF2 = "<F2>" KeyF3 = "<F3>" KeyF4 = "<F4>" KeyF5 = "<F5>" KeyF6 = "<F6>" KeyF7 = "<F7>" KeyF8 = "<F8>" KeyF9 = "<F9>" KeyF10 = "<F10>" KeyF11 = "<F11>" KeyF12 = "<F12>" KeyInsert = "<Insert>" KeyDelete = "<Delete>" KeyHome = "<Home>" KeyEnd = "<End>" KeyPgup = "<PageUp>" KeyPgdn = "<PageDown>" KeyCtrlSpace = "<C-<Space>>" KeyCtrlA = "<C-a>" KeyCtrlB = "<C-b>" KeyCtrlC = "<C-c>" KeyCtrlD = "<C-d>" KeyCtrlE = "<C-e>" KeyCtrlF = "<C-f>" KeyCtrlG = "<C-g>" KeyBackspace = "<C-<Backspace>>" KeyTab = "<Tab>" KeyCtrlJ = "<C-j>" KeyCtrlK = "<C-k>" KeyCtrlL = "<C-l>" KeyEnter = "<Enter>" KeyCtrlN = "<C-n>" KeyCtrlO = "<C-o>" KeyCtrlP = "<C-p>" KeyCtrlQ = "<C-q>" KeyCtrlR = "<C-r>" KeyCtrlS = "<C-s>" KeyCtrlT = "<C-t>" KeyCtrlU = "<C-u>" KeyCtrlV = "<C-v>" KeyCtrlW = "<C-w>" KeyCtrlX = "<C-x>" KeyCtrlY = "<C-y>" KeyCtrlZ = "<C-z>" KeyCtrl4 = "<C-4>" KeyCtrl5 = "<C-5>" KeyCtrl6 = "<C-6>" KeyCtrl7 = "<C-7>" Any = "<Any>" )
gui supported keys.
const ( TabPaneTopX = 0 TabPaneTopY = 0 TabPaneBottomX = 50 TabPaneBottomY = 5 VersionTopX = 50 VersionTopY = 0 VersionBottomX = 110 VersionBottomY = 5 FilterTopX = 24 FilterTopY = 4 FilterBottomX = 200 FilterBottomY = 7 FilterExitTopX = 0 FilterExitTopY = 4 FilterExitBottomX = 24 FilterExitBottomY = 7 SortPanelTopX = 0 SortPanelTopY = 8 SortPanelBottomX = 23 NotificationBottomX = 75 NotificationBottomY = 75 )
gui widgets positions
Variables ¶
This section is empty.
Functions ¶
func SetLightTheme ¶
func SetLightTheme()
SetLightTheme changes the basic colors of the tui lib to darker colors which are better visible on lighter background. This should be called before any tui widget created.
Types ¶
type Binding ¶
type Binding struct {
// contains filtered or unexported fields
}
Binding encapsulates a keybinding with its given callback function.
type Event ¶
type Event struct {
Payload interface{}
}
Event is used on passing data to callback functions. Usually the payload is the key at which the event occurred. If the payload is different, callback functions should mention it in its documentation.
type SortMetadata ¶
SortMetadata is the payload for event used on sort. Carries extra information for the sort event.
type TabView ¶
type TabView interface { // Filter filters the view. The event passed to the function. // contains the full text of the new filter. Filter(Event) // OnScrollEvent is called when an scroll event occurs. The key on which // the scroll event occurred is passed to the function. OnScrollEvent(Event) // Update is never called by the termWindow. It should only by used // if the user wants to update the contents of the view. // If this function is called from a different go-routine than the termWindow, // then this function should use a lock when updating the contents. // The lock should be the same as the widget that is to be rendered. // Every widget in termui comes with a lock (which is used when the widget // is rendered). The same lock should be used in the update function. Update(interface{}) // Resize should resize the view. The new terminal width and height // are passed as arguments to the function. Resize(int, int) // Widgets returns the items to be rendered by the gui. // The widgets will be rendered in the order as they were passed, // i.e. widget at index 0 is rendered first, widget at last index // is rendered as last. Widgets() []tui.Drawable // ItemsList returns the list of items to be sorted. ItemsList() []string }
TabView is the interface that wraps all methods needed by gui.
type TermWindow ¶
type TermWindow struct {
// contains filtered or unexported fields
}
TermWindow represents terminal gui handling multiple tabs with different data.
func NewTermWindow ¶
func NewTermWindow(onDataUpdate <-chan struct{}, views []TabView, viewNames []string, clearTabs []int, exitView TabView) *TermWindow
NewTermWindow returns an instance of <*TermWindow> you can also set the theme of gui (however the gui cannot change the supplied views so it's up to the user to set the color of each view).
func (*TermWindow) AddOnClearCallback ¶
func (w *TermWindow) AddOnClearCallback(f func(Event))
AddOnClearCallback registers a single function that will be called on clear event. The Event payload is the tab at which the event occurred.
func (*TermWindow) AddOnExitCallback ¶
func (w *TermWindow) AddOnExitCallback(f func(Event))
AddOnExitCallback registers a single function that will be called on gui exit.
func (*TermWindow) AddOnSortCallback ¶
func (w *TermWindow) AddOnSortCallback(f func(Event))
AddOnClearCallback registers a single function that will be called on sort event. The Event payload is of type SortMetadata.
func (*TermWindow) AddOnTabSwitchCallback ¶
func (w *TermWindow) AddOnTabSwitchCallback(f func(Event))
AddOnTabSwitchCallback registers a single function that will be called on each tab switch (left or right). The payload of the Event is the new tab index.
func (*TermWindow) SetState ¶
func (w *TermWindow) SetState(s string)
SetState sets the connection state, version and build date text to the state paragraph.
func (*TermWindow) Start ¶
func (w *TermWindow) Start()
Start starts the gui main loop to listen for event. The gui starts rendering the view at index 0. if no view is present panics.
func (*TermWindow) ViewAtTab ¶
func (w *TermWindow) ViewAtTab(i int) TabView
ViewAtTab returns the tableView at index. if out of bounds panics.