walk

package module
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 31 Imported by: 0

README

walk

Walk is based on antonmedv/walk with modifications to enable reuse as a component in other BubbleTea applications, along with some other bugfixes and enhancements.

To use the walk component, install the module using:

go get github.com/ardnew/walk/v2

The original walk command has been refactored into the [cmd/lk] submodule (README.md) and can be installed using:

go get github.com/ardnew/walk/v2/cmd/lk

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Kill

func Kill(status int)

Kill exits the program with the given exit status.

func Version

func Version() string

Types

type FilePath added in v2.3.0

type FilePath struct {
	*list.List
}

type KeyMap added in v2.2.0

type KeyMap struct {
	ForceQuit key.Binding
	Quit      key.Binding
	QuitQ     key.Binding
	Open      key.Binding
	Back      key.Binding
	Up        key.Binding
	Down      key.Binding
	Left      key.Binding
	Right     key.Binding
	Top       key.Binding
	Bottom    key.Binding
	Leftmost  key.Binding
	Rightmost key.Binding
	PageUp    key.Binding
	PageDown  key.Binding
	Home      key.Binding
	End       key.Binding
	VimUp     key.Binding
	VimDown   key.Binding
	VimLeft   key.Binding
	VimRight  key.Binding
	VimTop    key.Binding
	VimBottom key.Binding
	Search    key.Binding
	Preview   key.Binding
	Delete    key.Binding
	Undo      key.Binding
	Yank      key.Binding
}

func NewKeyMap added in v2.2.0

func NewKeyMap() *KeyMap

func (*KeyMap) Default added in v2.2.0

func (k *KeyMap) Default() *KeyMap

type Model

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

func New

func New(options ...Option[*Model]) *Model

New returns a new Model with the given options applied.

func (*Model) AsField added in v2.4.0

func (m *Model) AsField(options ...Option[*field]) *field

func (*Model) Exit

func (m *Model) Exit()

Exit exits the program with the receiver's current exit status.

func (*Model) Field added in v2.3.0

func (m *Model) Field() *field

Field returns the receiver's field used in a form.

func (*Model) Init

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

Init initializes the receiver.

Init is a required method of the Bubble Tea framework's Model interface.

func (*Model) Update

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

Update updates the receiver with the given message and returns the updated Model and any command to pass on to the Bubble Tea runtime.

Update is a required method of the Bubble Tea framework's Model interface.

func (*Model) Value added in v2.2.0

func (m *Model) Value() string

Value returns the path of the currently selected file.

func (*Model) View

func (m *Model) View() string

View returns a string representation of the receiver's current state including all markup, styling, terminal escape sequences, etc.

View is a required method of the Bubble Tea framework's Model interface.

func (*Model) With

func (m *Model) With(options ...Option[*Model]) *Model

With returns the receiver with the given options applied.

func (*Model) WithCommand added in v2.1.0

func (m *Model) WithCommand(cmd string) *Model

WithCommand returns the receiver with the given "open file" command set.

func (*Model) WithIcons

func (m *Model) WithIcons() *Model

WithIcons returns the receiver with file type icons enabled.

func (*Model) WithKeys added in v2.2.0

func (m *Model) WithKeys(keys *KeyMap) *Model

WithKeys returns the receiver with the given key bindings set.

func (*Model) WithPath

func (m *Model) WithPath(path string) *Model

WithPath returns the receiver with the given path set.

func (*Model) WithSize

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

WithSize returns the receiver with the given width and height set.

func (*Model) WithStyle added in v2.1.0

func (m *Model) WithStyle(styles *Styles) *Model

WithStyle returns the receiver with the given rendering attributes set.

type Option

type Option[O Optional] func(O) O

func Caption added in v2.3.0

func Caption(caption string) Option[*field]

Caption returns an Option that sets the caption of a field.

func Command added in v2.1.0

func Command(cmd string) Option[*Model]

Command returns an Option that sets the "open file" command with for a Model.

func Field added in v2.3.0

func Field(options ...Option[*field]) Option[*Model]

Field returns an Option that configures Model as a form field.

This Option must be provided to initialize Model as a form field.

func Heading added in v2.3.0

func Heading(heading string) Option[*field]

Heading returns an Option that sets the heading of a field.

func Icons

func Icons() Option[*Model]

Icons returns an Option that enables file type icons for a Model.

func Key added in v2.3.0

func Key(key string) Option[*field]

Key returns an Option that sets the key of a field.

func Keys added in v2.2.0

func Keys(keys *KeyMap) Option[*Model]

Keys returns an Option that sets the key bindings for a Model.

func Path

func Path(path string) Option[*Model]

Path returns an Option that sets the path for a Model.

func Prompt added in v2.4.0

func Prompt(prompt string) Option[*field]

Prompt returns an Option that sets the prompt of a field.

func Size

func Size(width, height int) Option[*Model]

Size returns an Option that sets the width and height of a Model.

func Style added in v2.1.0

func Style(styles *Styles) Option[*Model]

Style returns an Option that sets the rendering attributes for a Model.

func Validate added in v2.3.0

func Validate(validate func(FilePath) error) Option[*field]

Validate returns an Option that sets the validation function of a field.

func Value added in v2.3.0

func Value(value string) Option[*field]

Value returns an Option that sets the value of a field.

type Optional added in v2.3.0

type Optional interface{ *Model | *field }

Optional is a type with which Option arguments and methods can be applied.

type RunError added in v2.3.0

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

func (*RunError) Error added in v2.3.0

func (e *RunError) Error() string

func (*RunError) Unwrap added in v2.3.0

func (e *RunError) Unwrap() []error

type Styles added in v2.1.0

type Styles struct {
	Warning, Preview, Cursor, Bar, Search, Danger lipgloss.Style
}

func NewStyles added in v2.2.0

func NewStyles() *Styles

func (*Styles) Default added in v2.2.0

func (s *Styles) Default() *Styles

Jump to

Keyboard shortcuts

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