Documentation
¶
Overview ¶
Package lineedit is the one-line text editor behind every text field of the UI. It depends on nothing in package ui, so components in their own packages can edit the shared line.
Index ¶
- Constants
- func Caret(rows []Row, buf []rune, pos int) (row, col int)
- func IsWordKey(key string) bool
- func RowWidth(buf []rune, from, to int) int
- func Typed(k tea.KeyPressMsg) string
- type Area
- type Line
- func (l *Line) CanPoint() bool
- func (l *Line) Clear()
- func (l *Line) DeleteBack(from int)
- func (l *Line) Head() string
- func (l *Line) Insert(text string)
- func (l *Line) IsFormula() bool
- func (l *Line) Key(k tea.KeyPressMsg)
- func (l *Line) Set(text string)
- func (l *Line) SetCaret(x int)
- func (l *Line) Tail() string
- func (l *Line) Text() string
- type Row
Constants ¶
const Indent = 2
Indent is how far a wrapped line's continuation rows are indented.
Variables ¶
This section is empty.
Functions ¶
func Caret ¶ added in v0.3.0
Caret is the row the caret is on among rows, and its column there, continuation rows' indent included.
func IsWordKey ¶ added in v0.3.0
IsWordKey reports whether key moves or deletes by word or to the start of the line, so a field can pass it on to Key.
func Typed ¶
func Typed(k tea.KeyPressMsg) string
Typed returns the printable text of a key press, if any.
Types ¶
type Area ¶ added in v0.3.0
type Area struct {
Line
// contains filtered or unexported fields
}
Area is the multi-line editor of a notebook's cells: Line's text and caret, with line breaks, soft-wrapped to a width so no text is ever hidden. A line longer than the width breaks before a pipe (|) where it can, then after a space, then anywhere; the rows it continues on are indented by Indent. Up and Down, Home and End move by those rows.
func (*Area) InsertText ¶ added in v0.3.0
InsertText types text at the caret, line breaks included; a tab is two spaces, and other control characters are dropped.
func (*Area) Key ¶ added in v0.3.0
func (a *Area) Key(k tea.KeyPressMsg, width int) bool
Key applies an editing key at width, reporting whether it was one. Enter breaks the line, keeping its indent.
func (*Area) Offset ¶ added in v0.3.0
Offset is the caret as a byte offset into the text, what a completer or checker is given.
type Line ¶
Line is the one-line text editor behind every text field: the entry typed into a cell (ENTER, EDIT), prompts on the context line, and the search fields of the find bar and the pickers. Only one of them is edited at a time, so they share it; a component with several fields keeps the others' text itself and loads a field here to edit it.
func (*Line) CanPoint ¶
CanPoint reports whether the text before the caret ends where a cell reference may follow.
func (*Line) DeleteBack ¶ added in v0.3.0
DeleteBack deletes from index from up to the caret.
func (*Line) Insert ¶
Insert types text at the caret. Line breaks and tabs become spaces, and other control characters are dropped.