tui

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(model *Model) (err error)

func GetPreferenceId

func GetPreferenceId(extension string, script string, name string) string

func NewCopyTextCmd

func NewCopyTextCmd(text string) tea.Cmd

func NewEditCmd

func NewEditCmd(path string) tea.Cmd

func NewErrorCmd

func NewErrorCmd(err error) func() tea.Msg

func NewExecCmd

func NewExecCmd(command string) tea.Cmd

func NewOpenUrlCmd

func NewOpenUrlCmd(Url string) tea.Cmd

func NewPushCmd

func NewPushCmd(c Page) tea.Cmd

func NewReloadPageCmd

func NewReloadPageCmd(with map[string]app.ScriptInputWithValue) tea.Cmd

func NewRunScriptCmd

func NewRunScriptCmd(extension string, script string, with map[string]app.ScriptInputWithValue) tea.Cmd

func PopCmd

func PopCmd() tea.Msg

Types

type Action

type Action struct {
	Cmd      tea.Cmd
	Shortcut string
	Title    string
}

func NewAction

func NewAction(scriptAction app.ScriptAction) Action

func (Action) Binding

func (a Action) Binding() key.Binding

type ActionList

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

func NewActionList

func NewActionList() ActionList

func (*ActionList) Blur

func (al *ActionList) Blur()

func (*ActionList) Clear added in v0.0.9

func (al *ActionList) Clear()

func (*ActionList) Focus

func (al *ActionList) Focus() tea.Cmd

func (ActionList) Focused

func (al ActionList) Focused() bool

func (*ActionList) SetActions

func (al *ActionList) SetActions(actions ...Action)

func (*ActionList) SetSize

func (al *ActionList) SetSize(w, h int)

func (*ActionList) SetTitle

func (al *ActionList) SetTitle(title string)

func (ActionList) Update

func (al ActionList) Update(msg tea.Msg) (ActionList, tea.Cmd)

func (ActionList) View

func (al ActionList) View() string

type Checkbox

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

func NewCheckbox

func NewCheckbox(formItem app.ScriptInput) Checkbox

func (*Checkbox) Blur

func (cb *Checkbox) Blur()

func (*Checkbox) Focus

func (cb *Checkbox) Focus() tea.Cmd

func (*Checkbox) Height

func (cb *Checkbox) Height() int

func (*Checkbox) SetWidth

func (cb *Checkbox) SetWidth(width int)

func (*Checkbox) Toggle

func (cb *Checkbox) Toggle()

func (Checkbox) Update

func (cb Checkbox) Update(msg tea.Msg) (FormInput, tea.Cmd)

func (Checkbox) Value

func (cb Checkbox) Value() any

func (Checkbox) View

func (cb Checkbox) View() string

type CommandOutput

type CommandOutput string

type Config

type Config struct {
	Height int

	RootItems []app.RootItem `yaml:"rootItems"`
}

type CopyTextMsg

type CopyTextMsg struct {
	Text string
}

type Detail

type Detail struct {
	Style lipgloss.Style
	// contains filtered or unexported fields
}

func NewDetail

func NewDetail(title string) *Detail

func (*Detail) Init

func (d *Detail) Init() tea.Cmd

func (*Detail) SetActions

func (c *Detail) SetActions(actions ...Action)

func (*Detail) SetContent

func (d *Detail) SetContent(content string)

func (*Detail) SetDetail

func (d *Detail) SetDetail(detail app.Detail) tea.Cmd

func (*Detail) SetIsLoading

func (d *Detail) SetIsLoading(isLoading bool) tea.Cmd

func (*Detail) SetSize

func (c *Detail) SetSize(width, height int)

func (Detail) SideBarVisible

func (c Detail) SideBarVisible() bool

func (Detail) Update

func (c Detail) Update(msg tea.Msg) (Page, tea.Cmd)

func (*Detail) View

func (c *Detail) View() string

type DetailMsg

type DetailMsg string
type DropDown struct {
	// contains filtered or unexported fields
}

func NewDropDown

func NewDropDown(formItem app.ScriptInput) DropDown
func (d *DropDown) Blur()
func (d *DropDown) Focus() tea.Cmd
func (dd DropDown) HasMatch() bool
func (dd *DropDown) Height() int
func (dd *DropDown) SetWidth(width int)
func (d *DropDown) Update(msg tea.Msg) (FormInput, tea.Cmd)
func (d DropDown) Value() any
func (dd DropDown) View() string
type DropDownItem struct {
	// contains filtered or unexported fields
}
func (d DropDownItem) FilterValue() string
func (d DropDownItem) ID() string
func (d DropDownItem) Render(width int, selected bool) string

type ExecCommandMsg

type ExecCommandMsg struct {
	Exec      string
	Directory string
	OnSuccess string
	Env       []string
}

func (ExecCommandMsg) OnSuccessMsg added in v0.0.9

func (msg ExecCommandMsg) OnSuccessMsg(output string) tea.Msg

type Filter

type Filter struct {
	Width, Height int
	Query         string
	Background    lipgloss.TerminalColor
	Less          func(i, j FilterItem) bool

	DrawLines bool
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter() Filter

func (*Filter) CursorDown

func (m *Filter) CursorDown()

func (*Filter) CursorUp

func (m *Filter) CursorUp()

func (*Filter) FilterItems

func (f *Filter) FilterItems(query string)

func (Filter) Init

func (m Filter) Init() tea.Cmd

func (Filter) Selection

func (f Filter) Selection() FilterItem

func (*Filter) SetItems

func (f *Filter) SetItems(items []FilterItem)

func (*Filter) SetSize

func (f *Filter) SetSize(width, height int)

func (Filter) Update

func (f Filter) Update(msg tea.Msg) (Filter, tea.Cmd)

func (Filter) View

func (m Filter) View() string

type FilterItem

type FilterItem interface {
	FilterValue() string
	Render(width int, selected bool) string
	ID() string
}
type Footer struct {
	Width int
	// contains filtered or unexported fields
}

func NewFooter

func NewFooter(title string) Footer

func (*Footer) SetBindings

func (f *Footer) SetBindings(bindings ...key.Binding)

func (Footer) View

func (f Footer) View() string

type Form

type Form struct {
	Name string
	// contains filtered or unexported fields
}

func NewForm

func NewForm(name string, title string, items []FormItem) *Form

func (*Form) CurrentItem added in v0.0.9

func (c *Form) CurrentItem() FormInput

func (Form) Init

func (c Form) Init() tea.Cmd

func (*Form) ScrollViewport added in v0.0.9

func (c *Form) ScrollViewport()

func (*Form) SetIsLoading

func (c *Form) SetIsLoading(isLoading bool) tea.Cmd

func (*Form) SetSize

func (c *Form) SetSize(width, height int)

func (Form) Update

func (c Form) Update(msg tea.Msg) (Page, tea.Cmd)

func (*Form) View

func (c *Form) View() string

type FormInput

type FormInput interface {
	Focus() tea.Cmd
	Blur()

	Height() int
	Value() any

	SetWidth(int)
	Update(tea.Msg) (FormInput, tea.Cmd)
	View() string
}

type FormItem

type FormItem struct {
	Title string
	Id    string
	FormInput
}

func NewFormItem

func NewFormItem(param app.ScriptInput) FormItem
type Header struct {
	Width int
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader() Header

func (*Header) Focus

func (h *Header) Focus() tea.Cmd

func (Header) Init

func (h Header) Init() tea.Cmd

func (*Header) SetIsLoading

func (h *Header) SetIsLoading(isLoading bool) tea.Cmd

func (Header) Update

func (h Header) Update(msg tea.Msg) (Header, tea.Cmd)

func (Header) Value

func (h Header) Value() string

func (Header) View

func (c Header) View() string

type IsLoadingMsg added in v0.0.9

type IsLoadingMsg struct{}

type KeyStore

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

func LoadKeyStore added in v0.0.9

func LoadKeyStore(preferencePath string) (*KeyStore, error)

func (KeyStore) GetPreference

func (k KeyStore) GetPreference(extension string, script string, name string) (ScriptPreference, bool)

func (*KeyStore) Save added in v0.0.9

func (k *KeyStore) Save() (err error)

func (*KeyStore) SetPreference

func (k *KeyStore) SetPreference(preferences ...ScriptPreference) error

type List

type List struct {
	Dynamic     bool
	ShowPreview bool
	// contains filtered or unexported fields
}

func NewList

func NewList(title string) *List

func (*List) FilterItems

func (c *List) FilterItems(query string) tea.Cmd

func (*List) Init

func (c *List) Init() tea.Cmd

func (List) Query

func (c List) Query() string

func (*List) SetIsLoading

func (c *List) SetIsLoading(isLoading bool) tea.Cmd

func (*List) SetItems

func (c *List) SetItems(items []ListItem) tea.Cmd

func (*List) SetSize

func (c *List) SetSize(width, height int)

func (*List) Update

func (c *List) Update(msg tea.Msg) (Page, tea.Cmd)

func (List) View

func (c List) View() string

type ListItem

type ListItem struct {
	Id          string
	Title       string
	Subtitle    string
	Preview     string
	PreviewCmd  func() string
	Accessories []string
	Actions     []Action
}

func ParseScriptItem

func ParseScriptItem(scriptItem app.ScriptItem) ListItem

func (ListItem) FilterValue

func (i ListItem) FilterValue() string

func (ListItem) ID

func (i ListItem) ID() string

func (ListItem) Render

func (i ListItem) Render(width int, selected bool) string

type Model

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

func NewModel

func NewModel(config *Config, extensions ...app.Extension) *Model

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (Model) IsFullScreen added in v0.0.9

func (m Model) IsFullScreen() bool

func (*Model) Pop

func (m *Model) Pop()

func (*Model) Push

func (m *Model) Push(page Page) tea.Cmd

func (*Model) Reset added in v0.0.9

func (m *Model) Reset()

func (*Model) SetRoot added in v0.0.9

func (m *Model) SetRoot(root Page)

func (*Model) SetSize

func (m *Model) SetSize(width, height int)

func (*Model) Update

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

func (*Model) View

func (m *Model) View() string

type OpenUrlMsg

type OpenUrlMsg struct {
	Url string
}

type Page added in v0.0.9

type Page interface {
	Init() tea.Cmd
	Update(tea.Msg) (Page, tea.Cmd)
	View() string
	SetSize(width, height int)
}

func NewRootList added in v0.0.9

func NewRootList(rootItems ...app.RootItem) Page

type PreferenceForm added in v0.0.9

type PreferenceForm struct {
	*Form
	// contains filtered or unexported fields
}

func NewPreferenceForm added in v0.0.9

func NewPreferenceForm(extension app.Extension, script app.Command) *PreferenceForm

func (*PreferenceForm) Update added in v0.0.9

func (p *PreferenceForm) Update(msg tea.Msg) (Page, tea.Cmd)

type PreviewContentMsg

type PreviewContentMsg string

type ReloadPageMsg

type ReloadPageMsg struct {
	With map[string]app.ScriptInputWithValue
}

type RunScriptMsg

type RunScriptMsg struct {
	Extension string
	Script    string
	With      map[string]app.ScriptInputWithValue
	OnSuccess string
}

func (RunScriptMsg) OnSuccessCmd

func (msg RunScriptMsg) OnSuccessCmd() tea.Cmd

type ScriptPreference

type ScriptPreference struct {
	Name      string `json:"name"`
	Script    string `json:"script"`
	Extension string `json:"extension"`
	Value     any    `json:"value"`
}

type ScriptRunner

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

func NewScriptRunner

func NewScriptRunner(extension app.Extension, script app.Command, with map[string]app.ScriptInputWithValue) *ScriptRunner

func (*ScriptRunner) CheckMissingParameters

func (c *ScriptRunner) CheckMissingParameters() []FormItem

func (*ScriptRunner) Init

func (c *ScriptRunner) Init() tea.Cmd

func (ScriptRunner) Preferences

func (c ScriptRunner) Preferences() map[string]app.ScriptInputWithValue

func (*ScriptRunner) Run

func (c *ScriptRunner) Run() tea.Cmd

func (ScriptRunner) ScriptCmd

func (c ScriptRunner) ScriptCmd() tea.Msg

func (*ScriptRunner) SetSize

func (c *ScriptRunner) SetSize(width, height int)

func (*ScriptRunner) Update

func (c *ScriptRunner) Update(msg tea.Msg) (Page, tea.Cmd)

func (*ScriptRunner) View

func (c *ScriptRunner) View() string

type ShowPrefMsg added in v0.0.9

type ShowPrefMsg struct {
	Extension string
	Script    string
}

type Styles

type Styles struct {
	Bold   lipgloss.Style
	Faint  lipgloss.Style
	Italic lipgloss.Style
}

type SubmitMsg

type SubmitMsg struct {
	Name   string
	Values map[string]any
}

type TextArea

type TextArea struct {
	textarea.Model
}

func NewTextArea

func NewTextArea(formItem app.ScriptInput) TextArea

func (*TextArea) Height

func (ta *TextArea) Height() int

func (*TextArea) SetWidth

func (ta *TextArea) SetWidth(w int)

func (*TextArea) Update

func (ta *TextArea) Update(msg tea.Msg) (FormInput, tea.Cmd)

func (*TextArea) Value

func (ta *TextArea) Value() any

type TextInput

type TextInput struct {
	textinput.Model
	// contains filtered or unexported fields
}

func NewTextInput

func NewTextInput(formItem app.ScriptInput) TextInput

func (*TextInput) Height

func (ti *TextInput) Height() int

func (*TextInput) SetWidth

func (ti *TextInput) SetWidth(width int)

func (*TextInput) Update

func (ti *TextInput) Update(msg tea.Msg) (FormInput, tea.Cmd)

func (*TextInput) Value

func (ti *TextInput) Value() any

func (TextInput) View

func (ti TextInput) View() string

Jump to

Keyboard shortcuts

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