cmdline

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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: "w!", Title: "Write anyway", Desc: "Save even if the file changed on disk since it was opened; :w! name replaces name"},
	{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 History added in v0.3.0

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

History is the lines run on the command line, oldest first. It lasts as long as the session: each `012 serve` session has its own.

func (*History) Add added in v0.3.0

func (h *History) Add(line string)

Add puts line at the end of the history, moving it there if it's already in it.

func (*History) Lines added in v0.3.0

func (h *History) Lines() []string

Lines are the lines in the history, oldest first.

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)
	// History is the lines run this session, for Up and Down.
	History() *History
}

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