line

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action is what a keypress amounted to, for whoever is driving the input.

const (
	Drawn      Action = iota // the line changed, and wants drawing again
	Accept                   // the line is finished
	Cancel                   // escape, or ctrl+d while a turn runs: stop whatever is running
	Quit                     // ctrl+d on an empty line with nothing running
	Write                    // ctrl+x w: swap whether files in the workspace may be changed
	Shell                    // ctrl+x x: swap whether shell commands may run at all
	Git                      // ctrl+x g: swap whether a repository's own history may be changed
	Background               // ctrl+x b: swap whether commands may leave processes behind
	Restart                  // ctrl+r: start the harness again, carrying the conversation over
)

What a keypress can amount to.

type Frame

type Frame struct {
	Rows   []string // the rows to draw
	Row    int      // the row the cursor is on
	Column int      // the column the cursor is at
	Above  int      // the rows out of sight above
	Below  int      // the rows out of sight below
}

Frame is the visible input rows, cursor position, and clipped row counts.

type History

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

History is the entries typed before, oldest first, one per line of the file with newlines escaped.

func NewHistory

func NewHistory(path string, limit int) *History

NewHistory reads the history file. A missing one is what a first run looks like.

func (*History) Add

func (self *History) Add(line string)

Add records an entry, unless it is blank or the one just entered.

type Input

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

Input edits a line and walks its history.

func NewInput

func NewInput(history *History) *Input

NewInput builds an empty line.

func (*Input) Apply

func (self *Input) Apply(keypress key.Key, running bool) Action

Apply handles one keypress. Ctrl+D cancels a running turn, quits on an empty idle line, and otherwise does nothing.

func (*Input) Frame

func (self *Input) Frame(width int) Frame

Frame lays out the current input at width.

func (*Input) Pending

func (self *Input) Pending() bool

Pending reports whether a mode prefix awaits its command key.

func (*Input) Reset

func (self *Input) Reset()

Reset empties the line and starts the walk through history again.

func (*Input) Text

func (self *Input) Text() string

Text is what has been typed so far.

Jump to

Keyboard shortcuts

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