Documentation ¶
Overview ¶
Package tui wraps tview and tcell to create different layouts.
Available layouts are: Table, Preview and Text
Index ¶
- func GetPager() string
- func IsDumbTerminal() bool
- func IsNotTTY() bool
- func PagerOut(out string) error
- type CopyFunc
- type CopyKeyFunc
- type MoveFunc
- type MoveHandlerFunc
- type Preview
- type PreviewData
- type PreviewOption
- type RefreshFunc
- type RefreshTableStateFunc
- type Screen
- type SelectedFunc
- type Table
- type TableData
- type TableOption
- func WithCopyFunc(fn CopyFunc) TableOption
- func WithCopyKeyFunc(fn CopyKeyFunc) TableOption
- func WithFixedColumns(cols uint) TableOption
- func WithMoveFunc(fn MoveFunc) TableOption
- func WithRefreshFunc(fn RefreshFunc) TableOption
- func WithSelectedFunc(fn SelectedFunc) TableOption
- func WithTableFooterText(text string) TableOption
- func WithTableHelpText(text string) TableOption
- func WithTableStyle(style TableStyle) TableOption
- func WithViewModeFunc(fn ViewModeFunc) TableOption
- type TableStyle
- type Text
- type TextData
- type ViewModeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDumbTerminal ¶ added in v1.2.0
func IsDumbTerminal() bool
IsDumbTerminal checks TERM environment variable and returns true if it is set to dumb.
Dumb terminal indicates terminal with limited capability. It may not provide support for special character sequences, e.g., no handling of ANSI escape sequences.
Types ¶
type CopyFunc ¶
type CopyFunc func(row, column int, data interface{})
CopyFunc is fired when a user press 'c' character in the table cell.
type CopyKeyFunc ¶
type CopyKeyFunc func(row, column int, data interface{})
CopyKeyFunc is fired when a user press 'CTRL+K' character in the table cell.
type MoveFunc ¶ added in v1.4.0
type MoveFunc func(row, col int) func() (key string, actions []string, handler MoveHandlerFunc, status string, refresh RefreshTableStateFunc)
MoveFunc is fired when a user press 'm' character in the table cell.
type MoveHandlerFunc ¶ added in v1.4.0
MoveHandlerFunc is a handler for move action.
type Preview ¶
type Preview struct {
// contains filtered or unexported fields
}
Preview is the preview layout.
It contains 2 tables internally, viz: sidebar and contents.
func NewPreview ¶
func NewPreview(opts ...PreviewOption) *Preview
NewPreview constructs a new preview layout.
func (*Preview) Paint ¶
func (pv *Preview) Paint(pd []PreviewData) error
Paint paints the preview layout.
type PreviewData ¶
PreviewData is the data to be shown in preview layout.
type PreviewOption ¶
type PreviewOption func(*Preview)
PreviewOption is a functional option that wraps preview properties.
func WithContentTableOpts ¶
func WithContentTableOpts(opts ...TableOption) PreviewOption
WithContentTableOpts sets contents table options.
func WithInitialText ¶
func WithInitialText(text string) PreviewOption
WithInitialText sets initial text that is displayed in the contents screen.
func WithPreviewFooterText ¶
func WithPreviewFooterText(text string) PreviewOption
WithPreviewFooterText sets footer text that is displayed after the preview layout.
func WithSidebarSelectedFunc ¶
func WithSidebarSelectedFunc(fn SelectedFunc) PreviewOption
WithSidebarSelectedFunc sets a function that is called when any option in sidebar is selected.
type RefreshFunc ¶ added in v1.0.0
type RefreshFunc func()
RefreshFunc is fired when a user press 'CTRL+R' or `F5` character in the table.
type RefreshTableStateFunc ¶ added in v1.4.0
RefreshTableStateFunc is used to refresh the table state.
type SelectedFunc ¶
type SelectedFunc func(row, column int, data interface{})
SelectedFunc is fired when a user press enter key in the table cell.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a table layout.
type TableData ¶
type TableData [][]string
TableData is the data to be displayed in a table.
func (TableData) Get ¶ added in v1.3.0
Get returns the value of the cell at the given row and column.
type TableOption ¶
type TableOption func(*Table)
TableOption is a functional option to wrap table properties.
func WithCopyFunc ¶
func WithCopyFunc(fn CopyFunc) TableOption
WithCopyFunc sets a func that is triggered when a user press 'c'.
func WithCopyKeyFunc ¶
func WithCopyKeyFunc(fn CopyKeyFunc) TableOption
WithCopyKeyFunc sets a func that is triggered when a user press 'CTRL+K'.
func WithFixedColumns ¶ added in v1.2.0
func WithFixedColumns(cols uint) TableOption
WithFixedColumns sets the number of columns that are locked (do not scroll right).
func WithMoveFunc ¶ added in v1.4.0
func WithMoveFunc(fn MoveFunc) TableOption
WithMoveFunc sets a func that is triggered when an action button is pressed.
func WithRefreshFunc ¶ added in v1.0.0
func WithRefreshFunc(fn RefreshFunc) TableOption
WithRefreshFunc sets a func that is triggered when a user press 'CTRL+R' or 'F5'.
func WithSelectedFunc ¶
func WithSelectedFunc(fn SelectedFunc) TableOption
WithSelectedFunc sets a func that is triggered when table row is selected.
func WithTableFooterText ¶
func WithTableFooterText(text string) TableOption
WithTableFooterText sets footer text that is displayed after the table.
func WithTableHelpText ¶ added in v1.4.0
func WithTableHelpText(text string) TableOption
WithTableHelpText sets the help text for the view.
func WithTableStyle ¶ added in v1.1.0
func WithTableStyle(style TableStyle) TableOption
WithTableStyle sets the style of the table.
func WithViewModeFunc ¶
func WithViewModeFunc(fn ViewModeFunc) TableOption
WithViewModeFunc sets a func that is triggered when a user press 'v'.
type TableStyle ¶ added in v1.1.0
type TableStyle struct { SelectionBackground string SelectionForeground string SelectionTextIsBold bool }
TableStyle sets the style of the table.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text is the text view layout.
type ViewModeFunc ¶
type ViewModeFunc func(row, col int, data interface{}) (func() interface{}, func(data interface{}) (string, error))
ViewModeFunc sets view mode handler func which gets triggered when a user press 'v'.