tui

package
v0.0.0-...-2572d14 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Key0 tcell.Key = iota + 48
	Key1
	Key2
	Key3
	Key4
	Key5
	Key6
	Key7
	Key8
	Key9
)

Defines numeric keys for container actions.

View Source
const (
	KeyShift0 tcell.Key = 41
	KeyShift1 tcell.Key = 33
	KeyShift2 tcell.Key = 64
	KeyShift3 tcell.Key = 35
	KeyShift4 tcell.Key = 36
	KeyShift5 tcell.Key = 37
	KeyShift6 tcell.Key = 94
	KeyShift7 tcell.Key = 38
	KeyShift8 tcell.Key = 42
	KeyShift9 tcell.Key = 40
)

Defines numeric keys for container actions.

View Source
const (
	KeyA tcell.Key = iota + 97
	KeyB
	KeyC
	KeyD
	KeyE
	KeyF
	KeyG
	KeyH
	KeyI
	KeyJ
	KeyK
	KeyL
	KeyM
	KeyN
	KeyO
	KeyP
	KeyQ
	KeyR
	KeyS
	KeyT
	KeyU
	KeyV
	KeyW
	KeyX
	KeyY
	KeyZ
	KeyHelp  = 63
	KeySlash = 47
	KeyColon = 58
	KeySpace = 32
)

Defines char keystrokes.

View Source
const (
	KeyShiftA tcell.Key = iota + 65
	KeyShiftB
	KeyShiftC
	KeyShiftD
	KeyShiftE
	KeyShiftF
	KeyShiftG
	KeyShiftH
	KeyShiftI
	KeyShiftJ
	KeyShiftK
	KeyShiftL
	KeyShiftM
	KeyShiftN
	KeyShiftO
	KeyShiftP
	KeyShiftQ
	KeyShiftR
	KeyShiftS
	KeyShiftT
	KeyShiftU
	KeyShiftV
	KeyShiftW
	KeyShiftX
	KeyShiftY
	KeyShiftZ
)

Define Shift Keys.

Variables

View Source
var NumKeys = map[int]tcell.Key{
	0: Key0,
	1: Key1,
	2: Key2,
	3: Key3,
	4: Key4,
	5: Key5,
	6: Key6,
	7: Key7,
	8: Key8,
	9: Key9,
}

NumKeys tracks number keys.

Functions

func AsKey

func AsKey(evt *tcell.EventKey) tcell.Key

AsKey converts rune to keyboard key.,.

func GetInputValues

func GetInputValues[T AvailableInputTypes](input InputFace, sep string) ([]T, error)

GetInputValues - get values from inputs separated by character

func GetInputValuesByType

func GetInputValuesByType[T AvailableInputTypes](input InputFace, sep string, Type ...T) ([]T, error)

GetInputValuesByType - get values from inputs using auto instantiation

func LayoutWithAlign

func LayoutWithAlign(align int) layoutOptions

LayoutWithAlign - set align for layout

func LayoutWithBorder

func LayoutWithBorder() layoutOptions

LayoutWithBorder - set border for layout

func LayoutWithTitle

func LayoutWithTitle(title string) layoutOptions

LayoutWithTitle - set title for layout

func NewColumns

func NewColumns(cols ...GridItems) *tview.Flex

NewColumns - new group of columns

func NewRows

func NewRows(rows ...GridItems) *tview.Flex

NewRows - new group of rows

func SetInputValues

func SetInputValues[T AvailableInputTypes](input InputFace, values ...T) error

SetInputValues - set values into input field

Types

type ActionHandler

type ActionHandler func(*tcell.EventKey) *tcell.EventKey

ActionHandler handles a keyboard command.

type App

type App struct {
	*tview.Application
	*KeyActions
	Page *Pages
}

App represents an application.

func NewApp

func NewApp() *App

func (*App) QueueUpdate

func (a *App) QueueUpdate(f func())

QueueUpdate queues up a ui action.

func (*App) QueueUpdateDraw

func (a *App) QueueUpdateDraw(f func())

QueueUpdateDraw queues up a ui action and redraw the ui.

func (*App) RunWithCtx

func (a *App) RunWithCtx(ctx context.Context) (err error)

func (*App) Stop

func (a *App) Stop()

Stop application if exists

type AvailableInputTypes

type AvailableInputTypes interface {
	~int | ~uint |
		~int64 | ~uint64 |
		~int32 | ~uint32 |
		~int16 | ~uint16 |
		~int8 | ~uint8 |
		~float32 | ~float64 |
		~string
}

type ButtonHandlerFunc

type ButtonHandlerFunc func(buttonIndex int, buttonLabel string)

type GridItems

type GridItems interface {
	// contains filtered or unexported methods
}

func Column

func Column(Item tview.Primitive, FixedSize int, Proportion int) GridItems

func Row

func Row(Item tview.Primitive, FixedSize int, Proportion int) GridItems

type Input

func NewInput

func NewInput[T AvailableInputTypes](opt InputOPtions) *Input[T]

NewInput - create new input object of type

func NewInputByType

func NewInputByType[T AvailableInputTypes](opt InputOPtions, Type ...T) *Input[T]

NewInputByType - create new input object using auto instantiation

func (*Input[T]) GetInputValues

func (i *Input[T]) GetInputValues(sep string) (ret []T, err error)

GetInputValues - get values from inputs separated by character

func (*Input[T]) SetInputValues

func (i *Input[T]) SetInputValues(values ...T)

type InputFace

type InputFace interface {
	Primitive
	SetText(text string) *tview.InputField
	GetText() string
}

type InputOPtions

type InputOPtions struct {
	Name        string
	Description string
	Title       string
	Label       string
	PlaceHolder string
	FieldWidth  int
	Border      bool
	Action      ActionHandler
}

type KeyAction

type KeyAction struct {
	Description string
	Action      ActionHandler
}

KeyAction represents a keyboard action.

func NewKeyActionWithOpts

func NewKeyActionWithOpts(d string, a ActionHandler) KeyAction

NewKeyActionWithOpts returns a new keyboard action.

type KeyActions

type KeyActions struct {
	// contains filtered or unexported fields
}

KeyActions tracks mappings between keystrokes and actions.

func NewKeyActions

func NewKeyActions() *KeyActions

NewKeyActions returns a new instance.

func NewKeyActionsFromMap

func NewKeyActionsFromMap(mm KeyMap) *KeyActions

NewKeyActionsFromMap construct actions from key map.

func (*KeyActions) Add

func (a *KeyActions) Add(k tcell.Key, ka KeyAction)

Add adds a new key action.

func (*KeyActions) AddActions

func (a *KeyActions) AddActions(aa *KeyActions)

AddActions returns the application actions.

func (*KeyActions) Bulk

func (a *KeyActions) Bulk(aa KeyMap)

Bulk bulk insert key mappings.

func (*KeyActions) Clear

func (a *KeyActions) Clear()

Clear remove all actions.

func (*KeyActions) Delete

func (a *KeyActions) Delete(kk ...tcell.Key)

Delete deletes actions by the given keys.

func (*KeyActions) Get

func (a *KeyActions) Get(key tcell.Key) (KeyAction, bool)

Get fetches an action given a key.

func (*KeyActions) GetActions

func (a *KeyActions) GetActions() *KeyActions

GetActions returns a collection of actions.

func (*KeyActions) HasAction

func (a *KeyActions) HasAction(key tcell.Key) (KeyAction, bool)

HasAction checks if key matches a registered binding.

func (*KeyActions) Len

func (a *KeyActions) Len() int

Len returns action mapping count.

func (*KeyActions) Merge

func (a *KeyActions) Merge(aa *KeyActions)

Merge merges given actions into existing set.

func (*KeyActions) Range

func (a *KeyActions) Range(f RangeFn)

Range ranges over all actions and triggers a given function.

func (*KeyActions) Reset

func (a *KeyActions) Reset(aa *KeyActions)

Reset clears out actions.

func (*KeyActions) Set

func (a *KeyActions) Set(aa *KeyActions)

Set replace actions with new ones.

type KeyMap

type KeyMap map[tcell.Key]KeyAction

KeyMap tracks key to action mappings.

type Layout

type Layout struct {
	*tview.Flex
	*KeyActions
	PrimitiveName
}

func NewLayout

func NewLayout(name string, elements *tview.Flex, opt ...layoutOptions) *Layout

NewLayout - build new layout from rows and columns and additional options

type LayoutParams

type LayoutParams struct {
	Item       tview.Primitive
	FixedSize  int
	Proportion int
}
type Modal struct {
	*tview.Modal
	PrimitiveName
}

func NewModalWindow

func NewModalWindow(opt ModalOptions) *Modal

type ModalOptions

type ModalOptions struct {
	Name         string
	Description  string
	Title        string
	ButtonsNames []string
	ButtonAction ButtonHandlerFunc
}

type NextPrimitive

type NextPrimitive func() Primitive

Primitive represents a UI primitive.

func NewNextPrimitive

func NewNextPrimitive(primitives ...Primitive) NextPrimitive

NextPrimitive - circular loop through primitives

type Pages

type Pages struct {
	*tview.Pages
	*KeyActions
}

Pages represents a stack of view pages.

func NewPages

func NewPages() *Pages

func (*Pages) Add

func (p *Pages) Add(primitives ...Primitive)

Add - add list of pages.

type Panel

type Panel struct {
	*tview.TextView
	*KeyActions
	CacheLine cacheLine
	PrimitiveName
	// contains filtered or unexported fields
}

func NewPanel

func NewPanel(opt PanelOption) *Panel

NewPanel returns a new textview element.

func (*Panel) GetPrintCount

func (p *Panel) GetPrintCount() int64

func (*Panel) HighlightLineByMouse

func (p *Panel) HighlightLineByMouse(event *tcell.EventMouse) (lineNum int)

func (*Panel) HighlightNextLine

func (p *Panel) HighlightNextLine(forward bool, lineOffset int) (highlightedLine int)

func (*Panel) Printf

func (p *Panel) Printf(msg string, keysAndValues ...interface{})

type PanelOption

type PanelOption struct {
	Name         string
	Description  string
	Title        string
	Align        int
	Border       bool
	AutoScroll   bool
	Action       ActionHandler
	ChangeAction func()
}

type Primitive

type Primitive interface {
	tview.Primitive
	Name() string
}

Primitive represents a UI primitive.

type PrimitiveName

type PrimitiveName string

Primitive represents a UI primitive.

func (PrimitiveName) Name

func (p PrimitiveName) Name() string

Name - return name of primitive

type RangeFn

type RangeFn func(tcell.Key, KeyAction)

RangeFn represents a range iteration callback.

Jump to

Keyboard shortcuts

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