editors

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package editors contains the editors for the different data types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructEditor

func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor *Composite, onWrite func(any) error) (edit.Editor, error)

ConstructEditor constructs a new editor...

Types

type Composite

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

Composite implements Editor

func (*Composite) AddQuitCallback

func (e *Composite) AddQuitCallback(f func())

AddQuitCallback adds a callback that is called when the editor is quit.

func (*Composite) CreateInputProcessor added in v0.9.8

func (e *Composite) CreateInputProcessor(cfg input.InputConfig) (input.ModalInputProcessor, error)

CreateInputProcessor creates an input processor for the editor.

func (*Composite) EnterField

func (e *Composite) EnterField()

EnterField changes the editor to enter the currently selected field, e.g. such that input processing is deferred to the field.

func (*Composite) GetActiveFieldID added in v0.9.8

func (e *Composite) GetActiveFieldID() EditorID

GetActiveFieldID returns the ID of the currently active field.

func (*Composite) GetFieldOrder added in v0.9.8

func (e *Composite) GetFieldOrder() []EditorID

GetFieldOrder returns the order of the fields.

func (*Composite) GetFields added in v0.9.8

func (e *Composite) GetFields() map[EditorID]edit.Editor

GetFields returns the subeditors of this composite editor.

func (*Composite) GetID added in v0.9.8

func (e *Composite) GetID() string

GetID returns the ID of the editor.

func (*Composite) GetStatus added in v0.9.8

func (e *Composite) GetStatus() edit.EditorStatus

GetStatus informs on whether the editor is active and focussed.

"active" here means that the editor is in use, i.e. the user is currently editing within the editor. "focussed" means that the editor is the one currently receiving input, i.e. that it is the "lowestmost" active editor.

E.g. when there is merely a single string editor, it must be active and focused. E.g. when there is a composite editor it must be active but the focus may lie with it or with a child editor.

func (*Composite) GetType added in v0.9.7

func (e *Composite) GetType() string

GetType asserts that this is a composite editor.

func (*Composite) IsInField added in v0.9.8

func (e *Composite) IsInField() bool

IsInField informs on whether the editor is currently in a field.

func (*Composite) Quit

func (e *Composite) Quit()

Quit quits all subeditors and calls the quit callback.

func (*Composite) SwitchToNextField

func (e *Composite) SwitchToNextField()

SwitchToNextField switches to the next field (wrapping araound, if necessary)

func (*Composite) SwitchToPrevField

func (e *Composite) SwitchToPrevField()

SwitchToPrevField switches to the previous field (wrapping araound, if necessary)

func (*Composite) Write

func (e *Composite) Write()

Write writes the content of the editor back to the underlying data structure by calling the write functions of all subeditors.

type EditorID added in v0.9.8

type EditorID = string

An EditorID is a unique identifier for an editor within a composite editor.

type StringEditor

type StringEditor struct {
	ID string

	Content   string
	CursorPos int
	Mode      input.TextEditMode
	StatusFn  func() edit.EditorStatus

	QuitCallback func()

	CommitFn func(string)
	// contains filtered or unexported fields
}

StringEditor ...

func (*StringEditor) AddQuitCallback

func (e *StringEditor) AddQuitCallback(f func())

AddQuitCallback adds a callback that is called when the editor is quit.

func (*StringEditor) AddRune

func (e *StringEditor) AddRune(newRune rune)

AddRune adds a rune at the cursor position.

func (*StringEditor) BackspaceRune

func (e *StringEditor) BackspaceRune()

BackspaceRune deletes the rune before the cursor position.

func (*StringEditor) BackspaceToBeginning

func (e *StringEditor) BackspaceToBeginning()

BackspaceToBeginning deletes all runes before the cursor position.

func (*StringEditor) Clear

func (e *StringEditor) Clear()

Clear deletes all runes in the editor.

func (*StringEditor) CreateInputProcessor added in v0.9.8

func (e *StringEditor) CreateInputProcessor(cfg input.InputConfig) (input.ModalInputProcessor, error)

CreateInputProcessor creates an input processor for the editor.

func (*StringEditor) DeleteEverything added in v0.9.11

func (e *StringEditor) DeleteEverything()

DeleteEverything deletes all runes in the editor.

func (*StringEditor) DeleteRune

func (e *StringEditor) DeleteRune()

DeleteRune deletes the rune at the cursor position.

func (*StringEditor) DeleteToEnd

func (e *StringEditor) DeleteToEnd()

DeleteToEnd deletes all runes after the cursor position.

func (StringEditor) GetContent

func (e StringEditor) GetContent() string

GetContent returns the current (edited) contents.

func (StringEditor) GetCursorPos

func (e StringEditor) GetCursorPos() int

GetCursorPos returns the current cursor position in the string, 0 being

func (*StringEditor) GetFieldCount

func (e *StringEditor) GetFieldCount() int

func (StringEditor) GetID added in v0.9.8

func (e StringEditor) GetID() string

GetID returns the ID of the editor.

func (StringEditor) GetMode

func (e StringEditor) GetMode() input.TextEditMode

GetMode returns the current mode of the editor.

func (StringEditor) GetStatus added in v0.9.8

func (e StringEditor) GetStatus() edit.EditorStatus

GetStatus ...

func (*StringEditor) GetType added in v0.9.7

func (e *StringEditor) GetType() string

GetType asserts that this is a string editor.

func (*StringEditor) MoveCursorLeft

func (e *StringEditor) MoveCursorLeft()

MoveCursorLeft moves the cursor one rune to the left.

func (*StringEditor) MoveCursorPastEnd

func (e *StringEditor) MoveCursorPastEnd()

MoveCursorPastEnd moves the cursor past the end of the string.

func (*StringEditor) MoveCursorRight

func (e *StringEditor) MoveCursorRight()

MoveCursorRight moves the cursor one rune to the right.

func (*StringEditor) MoveCursorToBeginning

func (e *StringEditor) MoveCursorToBeginning()

MoveCursorToBeginning moves the cursor to the beginning of the string.

func (*StringEditor) MoveCursorToEnd

func (e *StringEditor) MoveCursorToEnd()

MoveCursorToEnd moves the cursor to the end of the string.

func (*StringEditor) MoveCursorToNextWordBeginning added in v0.9.8

func (e *StringEditor) MoveCursorToNextWordBeginning()

MoveCursorToNextWordBeginning moves the cursor one rune to the right, or to the end of the string if already at the end.

func (*StringEditor) MoveCursorToNextWordEnd added in v0.9.8

func (e *StringEditor) MoveCursorToNextWordEnd()

MoveCursorToNextWordEnd moves the cursor to the end of the next word.

func (*StringEditor) MoveCursorToPrevWordBeginning added in v0.9.8

func (e *StringEditor) MoveCursorToPrevWordBeginning()

MoveCursorToPrevWordBeginning moves the cursor one rune to the left, or to the beginning of the string if already at the beginning.

func (*StringEditor) Quit

func (e *StringEditor) Quit()

Quit the editor.

func (*StringEditor) SetMode

func (e *StringEditor) SetMode(m input.TextEditMode)

SetMode sets the current mode of the editor.

func (*StringEditor) Write

func (e *StringEditor) Write()

Write commits the current contents of the editor.

type StringEditorControl

type StringEditorControl interface {
	SetMode(m input.TextEditMode)
	DeleteRune()
	BackspaceRune()
	BackspaceToBeginning()
	DeleteToEnd()
	Clear()
	MoveCursorToBeginning()
	MoveCursorToEnd()
	MoveCursorPastEnd()
	MoveCursorLeft()
	MoveCursorRight()
	MoveCursorToNextWordBeginning()
	MoveCursorToPrevWordBeginning()
	MoveCursorToNextWordEnd()
	AddRune(newRune rune)
}

StringEditorControl allows manipulation of a string editor.

Jump to

Keyboard shortcuts

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