cmdline

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package cmdline is a command line widget.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config(config func(*Cmdline) widget.Keymap)

Config sets the cmdline keymap function.

func ConfigCompletion

func ConfigCompletion(config func(*Completion) widget.Keymap)

ConfigCompletion sets a completion keymap function.

func LoadHistory

func LoadHistory(path string) error

LoadHistory loads from a path and append to history maps of a key as the file name.

func SaveHistory

func SaveHistory(path string) error

SaveHistory saves the history to a path.

Types

type Cmdline

type Cmdline struct {
	*widget.TextBox

	History *History
	// contains filtered or unexported fields
}

Cmdline is one line text box with a specified mode.

func New

func New(m Mode, filer widget.Widget) *Cmdline

New creates a new cmdline with a specified mode and a history list box. These widget size based on the filer widget.

func (*Cmdline) Disconnect

func (c *Cmdline) Disconnect()

Disconnect a completion widget.

func (*Cmdline) Draw

func (c *Cmdline) Draw()

Draw the cmdline and the completion or the histry list box

func (*Cmdline) DrawLine

func (c *Cmdline) DrawLine()

DrawLine draws the cmdline.

func (*Cmdline) Exit

func (c *Cmdline) Exit()

Exit the cmdline and add a cmdline text to the history.

func (*Cmdline) Input

func (c *Cmdline) Input(key string)

Input to the text box or widget keymaps.

func (*Cmdline) Next

func (c *Cmdline) Next() widget.Widget

Next returns a completion widget.

func (*Cmdline) Resize

func (c *Cmdline) Resize(x, y, width, height int)

Resize the cmdline and the history list box.

func (*Cmdline) ResizeRelative

func (c *Cmdline) ResizeRelative(x, y, width, height int)

ResizeRelative resizes relative to cmdline current sizes.

func (*Cmdline) Run

func (c *Cmdline) Run()

Run the cmdline mode and add a cmdline text to the history.

func (*Cmdline) StartCompletion

func (c *Cmdline) StartCompletion()

StartCompletion starts a completion based on the cmdline text.

type Completion

type Completion struct {
	*widget.ListBox
	// contains filtered or unexported fields
}

Completion is a list box displays completions of the cmdline text.

func NewCompletion

func NewCompletion(x, y, width, height int, cmdline *Cmdline) *Completion

NewCompletion creates a new completion list box.

func (*Completion) Disconnect

func (c *Completion) Disconnect()

Disconnect do noting.

func (*Completion) Exit

func (c *Completion) Exit()

Exit the completion.

func (*Completion) Input

func (c *Completion) Input(key string)

Input to the completion or to the cmdline and exits.

func (*Completion) InsertCompletion

func (c *Completion) InsertCompletion()

InsertCompletion inserts a selected completion to the cmdline and exits the completion.

func (*Completion) Next

func (c *Completion) Next() widget.Widget

Next returns nil.

type History

type History struct {
	*widget.ListBox
	// contains filtered or unexported fields
}

History is the cmdline mode history.

func NewHistory

func NewHistory(x, y, width, height int, cmdline *Cmdline) *History

NewHistory creates a new history list box.

func (*History) CursorDown

func (h *History) CursorDown()

CursorDown downs the history list box cursor and sets a text to the cmdline.

func (*History) CursorUp

func (h *History) CursorUp()

CursorUp ups the history list box cursor and sets a text to the cmdline.

func (*History) Delete

func (h *History) Delete()

Delete a history content on the cursor.

func (*History) MoveCursor

func (h *History) MoveCursor(amount int)

MoveCursor moves the history list box cursor and sets a text to the cmdline.

type Mode

type Mode interface {
	String() string // uses as a history map name
	Prompt() string // is displayed at the beginning
	Draw(*Cmdline)
	Run(*Cmdline)
}

Mode describes a cmdline mode.

Jump to

Keyboard shortcuts

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