cmdline

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 8 Imported by: 0

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

View Source
const ID = "cmdline"

ID identifies the completions' box in mouse events.

Variables

View Source
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

type Line struct {
	overlay.List
	// contains filtered or unexported fields
}

Line is the open command line.

func New

func New(h Host) *Line

New returns a command line with the edit line cleared.

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.

func (*Line) ContextLine

func (c *Line) ContextLine() (string, string)

func (*Line) Cursor

func (c *Line) Cursor() (int, int)

func (*Line) Indicator

func (c *Line) Indicator() string

func (*Line) Key

func (c *Line) Key(k tea.KeyPressMsg) tea.Cmd

func (*Line) Layout

func (c *Line) Layout() []overlay.Box

Layout draws the completions in a box under the context line: title, what Tab types, and the shortcut.

func (*Line) Mouse

func (c *Line) Mouse(e overlay.MouseEvent) tea.Cmd

func (*Line) Shown

func (c *Line) Shown() []Item

Shown are the completions of what's typed.

func (*Line) Status

func (c *Line) Status() (string, string)

Jump to

Keyboard shortcuts

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