tuigo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Unlicense Imports: 12 Imported by: 4

README

tuigo

a terminal UI framework written in Go using the bubbletea library.

see example/ for an example usage of tuigo. the scheme below shows roughly the structure of the API.

%%{
  init: {
    'theme': 'base', 
    'themeVariables': { 
        'fontFamily': 'monospace',
        'primaryColor': '#4C2FAD',
        'primaryTextColor': '#FFFFFF',
        'lineColor': '#E840E0',
        'primaryBorderColor': '#E840E0'
      }
    }
}%%

classDiagram
class tuigo["tuigo"]
class tui_utils["tuigo/utils"]
class tui_field["tuigo"]
class tui_component["tuigo"]

tuigo <-- tui_utils : initial state
tuigo <-- tui_field : mapping from states to fields
tuigo : NewApp(utils.State, map[utils.State]Field, bool) App
tuigo : App

tui_utils : Label() string
tui_utils : Next() utils.State
tui_utils : Prev() utils.State
tui_utils : utils.State

tui_field : NewField(string, bool, bool) Field
tui_field : Field

tui_component : Field.AddElement(&component) Field
tui_component : NewButton(string, utils.ButtonType, tea.Msg) button.Model
tui_component : NewSelector([]string, bool) selector.Model
tui_component : NewRadio(string) radio.Model
tui_component : NewInput(string, string, string, utils.InputType) button.Model

tui_field <-- tui_component : populate the field with interactive components

TODO

  • customizable theme
  • more components
  • grid structure
  • key help menu
  • field validator
  • unit tests

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewButton added in v1.0.0

func NewButton(label string, btnType utils.ButtonType, msg tea.Msg) button.Model

func NewInput added in v1.0.0

func NewInput(label, def, placeholder string, inputtype utils.InputType) input.Model

func NewRadio added in v1.0.0

func NewRadio(label string) radio.Model

func NewSelector added in v1.0.0

func NewSelector(options []string, multiselect bool) selector.Model

Types

type Actor added in v1.0.0

type Actor interface {
	Action() tea.Msg
}

type App

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

func NewApp added in v1.0.0

func NewApp(state utils.State, fields map[utils.State]Field, enable_debug bool) App

func (App) AddField added in v1.0.0

func (m App) AddField(st utils.State, f Field) App

func (App) Init added in v1.0.0

func (m App) Init() tea.Cmd

func (App) Update added in v1.0.0

func (m App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (App) View added in v1.0.0

func (m App) View() string

type Field added in v1.0.0

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

func NewField added in v1.0.0

func NewField(label string, isFirstField bool, isLastField bool) Field

func (Field) AddElement added in v1.0.0

func (f Field) AddElement(element component.Viewer) Field

func (*Field) FocusFirst added in v1.0.0

func (f *Field) FocusFirst()

func (*Field) FocusLast added in v1.0.0

func (f *Field) FocusLast()

func (*Field) FocusNext added in v1.0.0

func (f *Field) FocusNext()

func (*Field) FocusPrev added in v1.0.0

func (f *Field) FocusPrev()

func (Field) GetControls added in v1.0.0

func (f Field) GetControls() []component.Viewer

func (Field) GetFocusers added in v1.0.0

func (f Field) GetFocusers() []component.Focuser

func (Field) GetViewersWithoutControls added in v1.0.0

func (f Field) GetViewersWithoutControls() []component.Viewer

func (Field) Init added in v1.0.0

func (f Field) Init() tea.Cmd

func (Field) Update added in v1.0.0

func (f Field) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Field) View added in v1.0.0

func (f Field) View() string

type Messenger added in v1.0.0

type Messenger interface {
	Message() string
}

type State added in v1.0.0

type State interface {
	Label() string
	Next() State
	Prev() State
}

Directories

Path Synopsis
ui
app

Jump to

Keyboard shortcuts

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