tui

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tui wraps tview and tcell to create different layouts.

Available layouts are: Table, Preview and Text

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPager added in v0.2.0

func GetPager() string

GetPager returns configured pager.

func IsDumbTerminal added in v1.2.0

func IsDumbTerminal() bool

IsDumbTerminal checks TERM/WT_SESSION environment variable and returns true if they indicate a dumb terminal.

Dumb terminal indicates terminal with limited capability. It may not provide support for special character sequences, e.g., no handling of ANSI escape sequences.

func IsNotTTY added in v1.3.0

func IsNotTTY() bool

IsNotTTY returns true if the stdout file descriptor is not a TTY.

func PagerOut added in v0.2.0

func PagerOut(out string) error

PagerOut outputs to configured pager if possible.

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

type MoveHandlerFunc func(state string) error

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

type PreviewData struct {
	Key      string
	Menu     string
	Contents func(string) interface{}
}

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

type RefreshTableStateFunc func(row, col int, val string)

RefreshTableStateFunc is used to refresh the table state.

type Screen

type Screen struct {
	*tview.Application
}

Screen is a shell screen.

func NewScreen

func NewScreen() *Screen

NewScreen creates a new screen.

func (*Screen) Paint

func (s *Screen) Paint(root tview.Primitive) error

Paint paints UI to the screen.

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.

func NewTable

func NewTable(opts ...TableOption) *Table

NewTable constructs a new table layout.

func (*Table) Paint

func (t *Table) Paint(data TableData) error

Paint paints the table layout. First row is treated as a table header.

type TableData

type TableData [][]string

TableData is the data to be displayed in a table.

func (TableData) Get added in v1.3.0

func (td TableData) Get(r, c int) string

Get returns the value of the cell at the given row and column.

func (TableData) GetIndex added in v1.3.0

func (td TableData) GetIndex(key string) int

GetIndex returns the index of the specified column.

func (TableData) Update added in v1.3.0

func (td TableData) Update(r, c int, val string)

Update updates the data at 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.

func NewText

func NewText() *Text

NewText constructs a new text view layout.

func (*Text) Render

func (tv *Text) Render(td TextData) error

Render renders the text layout.

type TextData

type TextData string

TextData is the data to be shown in text 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'.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL