Documentation
¶
Overview ¶
Package cmdline is the command line (: with vim keys, or from the palette): what's typed on the context line, with completions from the command registry in a box under it. It knows the UI only through Host; what a line means (vim's file commands, a cell to go to, a command by name) is the host's to carry out.
Index ¶
- Constants
- Variables
- type Host
- type Item
- type Line
- func (c *Line) Changed()
- func (c *Line) ContextLine() (string, string)
- func (c *Line) Cursor() (int, int)
- func (c *Line) Indicator() string
- func (c *Line) Key(k tea.KeyPressMsg) tea.Cmd
- func (c *Line) Layout() []overlay.Box
- func (c *Line) Mouse(e overlay.MouseEvent) tea.Cmd
- func (c *Line) Shown() []Item
- func (c *Line) Status() (string, string)
Constants ¶
const ID = "cmdline"
ID identifies the completions' box in mouse events.
Variables ¶
var FileWords = []Item{
{Word: "w", Title: "Write", Desc: "Save the sheet; :w name saves it as name, :w name.csv downloads it"},
{Word: "q", Title: "Quit", Desc: "Close 012, asking about unsaved changes"},
{Word: "q!", Title: "Quit without saving", Desc: "Close 012, discarding unsaved changes"},
{Word: "wq", Title: "Write and quit", Desc: "Save the sheet, then close 012"},
{Word: "x", Title: "Write if changed and quit", Desc: "Save the sheet if it changed, then close 012"},
{Word: "e", Title: "Edit a file", Desc: "Open a sheet or import a file: :e name"},
}
FileWords are vim's file commands.
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host interface {
Theme() *theme.Theme
Size() (width, height int)
// Line is the shared edit line the command is typed in.
Line() *lineedit.Line
// Close closes the open overlay.
Close()
// Commands are the registered commands to complete, by title.
Commands() []Item
// Run carries out a command line and reports whether it was one.
Run(text string) (tea.Cmd, bool)
// Fail shows an error.
Fail(msg string)
}
Host is what the command line needs of the UI.
type Item ¶
type Item struct {
Word string // what Tab puts on the line: "w", or a command's ID
Title string
Desc string
Key string // the command's shortcut
Off bool // unavailable right now
}
Item is a completion: a file command or a registered command.
type Line ¶
Line is the open command line.
func (*Line) Changed ¶
func (c *Line) Changed()
Changed completes what's typed: file commands, then commands whose ID or title starts with it, then those that contain it. Nothing is completed once a file command's argument follows.