field

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 6 Imported by: ? 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

Line editor every text field of the toolkit types into, driven by the actions of the text context of the keymap that the prompt answers too

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {

	// Whether a line break typed or pasted stays one, the newline action breaking the line
	Multiline bool
	// Whether the text shows as dots
	Masked bool
	// contains filtered or unexported fields
}

Editable text with a caret, the readline keys of the text context, undo and redo

func New

func New(text string) *Field

Field holding text with the caret at its end

func (*Field) Action

func (f *Field) Action(id string) (tea.Cmd, bool)

Carries out an action of the text context, reporting whether the field answers it, with the command it needs such as a clipboard read

func (*Field) Cursor

func (f *Field) Cursor() int

Caret as a rune offset of the text

func (*Field) Empty

func (f *Field) Empty() bool

Whether the field holds no text

func (*Field) Insert

func (f *Field) Insert(text string) bool

Puts text in at the caret as typed, a selected whole text replaced, reporting whether anything went in

func (*Field) Line

func (f *Field) Line(width int) (string, int)

One row of the text in width cells scrolled to keep the caret in view, the caret column in it

func (*Field) SelectAll

func (f *Field) SelectAll()

Marks the whole text selected, the next typing replacing it and the next move or delete dropping the mark

func (*Field) SetCursor

func (f *Field) SetCursor(at int)

Moves the caret to a rune offset of the text

func (*Field) SetValue

func (f *Field) SetValue(text string)

Replaces the text with the caret at its end, the text it replaced kept on the undo trail

func (*Field) Take

func (f *Field) Take(msg tea.Msg) bool

Takes typed text, a paste and the clipboard answer the paste key asked for, reporting whether the text changed

func (*Field) Value

func (f *Field) Value() string

Text typed so far

func (*Field) Vertical

func (f *Field) Vertical(step int) bool

Moves the caret a line up or down keeping its column, false when the text has no line there

func (*Field) Whole

func (f *Field) Whole() bool

Whether the whole text reads as selected, so typing replaces it

func (*Field) Wrapped

func (f *Field) Wrapped(room int) (lines []string, cx, cy int)

Text as rows of at most room cells, broken at line breaks and wrapped, with the column and row of the caret

Jump to

Keyboard shortcuts

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