tui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 9 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 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 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 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.

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 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 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