tui

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 7 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

This section is empty.

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

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{}) 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