Documentation ¶
Overview ¶
Package tui wraps tview and tcell to create different layouts.
Available layouts are: Table, Preview and Text
Index ¶
- func GetPager() string
- func PagerOut(out string) error
- type CopyFunc
- type CopyKeyFunc
- type Preview
- type PreviewData
- type PreviewOption
- type RefreshFunc
- type Screen
- type SelectedFunc
- type Table
- type TableData
- type TableOption
- func WithColPadding(pad uint) TableOption
- func WithCopyFunc(fn CopyFunc) TableOption
- func WithCopyKeyFunc(fn CopyKeyFunc) TableOption
- func WithMaxColWidth(width uint) TableOption
- func WithRefreshFunc(fn RefreshFunc) TableOption
- func WithSelectedFunc(fn SelectedFunc) TableOption
- func WithTableFooterText(text string) TableOption
- func WithViewModeFunc(fn ViewModeFunc) TableOption
- type Text
- type TextData
- type ViewModeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 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 TableOption ¶
type TableOption func(*Table)
TableOption is a functional option to wrap table properties.
func WithColPadding ¶
func WithColPadding(pad uint) TableOption
WithColPadding sets column padding property of the table.
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 WithMaxColWidth ¶
func WithMaxColWidth(width uint) TableOption
WithMaxColWidth sets max column width property of the table.
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 WithViewModeFunc ¶
func WithViewModeFunc(fn ViewModeFunc) TableOption
WithViewModeFunc sets a func that is triggered when a user press 'v'.
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'.