editors

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructEditor

func ConstructEditor[T any](name string, obj *T, extraSpec map[string]any, activeAndFocussedFunc func() (bool, bool)) (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) 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) GetName

func (e *Composite) GetName() string

GetName returns the name of the editor.

func (*Composite) GetPane

func (e *Composite) GetPane(
	renderer ui.ConstrainedRenderer,
	visible func() bool,
	inputConfig input.InputConfig,
	stylesheet styling.Stylesheet,
	cursorController ui.CursorLocationRequestHandler,
) (ui.Pane, error)

GetPane constructs a pane for this composite editor (including all subeditors).

func (*Composite) GetSummary added in v0.9.7

func (e *Composite) GetSummary() edit.SummaryEntry

func (*Composite) GetType added in v0.9.7

func (e *Composite) GetType() string

GetType asserts that this is a composite editor.

func (*Composite) IsActiveAndFocussed added in v0.9.7

func (e *Composite) IsActiveAndFocussed() (bool, bool)

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 EventEditor

type EventEditor struct {
	Active       bool
	Original     *model.Event
	TmpEventInfo model.Event
	CursorPos    int

	Mode input.TextEditMode
}

func (*EventEditor) Activate

func (e *EventEditor) Activate(event *model.Event)

func (*EventEditor) AddRune

func (e *EventEditor) AddRune(newRune rune)

func (*EventEditor) BackspaceRune

func (e *EventEditor) BackspaceRune()

func (*EventEditor) BackspaceToBeginning

func (e *EventEditor) BackspaceToBeginning()

func (*EventEditor) Clear

func (e *EventEditor) Clear()

func (*EventEditor) DeleteRune

func (e *EventEditor) DeleteRune()

func (*EventEditor) DeleteToEnd

func (e *EventEditor) DeleteToEnd()

func (*EventEditor) GetMode

func (e *EventEditor) GetMode() input.TextEditMode

func (*EventEditor) MoveCursorLeft

func (e *EventEditor) MoveCursorLeft()

func (*EventEditor) MoveCursorNextWordBeginning

func (e *EventEditor) MoveCursorNextWordBeginning()

func (*EventEditor) MoveCursorNextWordEnd

func (e *EventEditor) MoveCursorNextWordEnd()

func (*EventEditor) MoveCursorPastEnd

func (e *EventEditor) MoveCursorPastEnd()

func (*EventEditor) MoveCursorPrevWordBeginning

func (e *EventEditor) MoveCursorPrevWordBeginning()

func (*EventEditor) MoveCursorRight

func (e *EventEditor) MoveCursorRight()

func (*EventEditor) MoveCursorRightA

func (e *EventEditor) MoveCursorRightA()

func (*EventEditor) MoveCursorToBeginning

func (e *EventEditor) MoveCursorToBeginning()

func (*EventEditor) MoveCursorToEnd

func (e *EventEditor) MoveCursorToEnd()

func (*EventEditor) SetMode

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

type StringEditor

type StringEditor struct {
	Name string

	Content           string
	CursorPos         int
	Mode              input.TextEditMode
	ActiveAndFocussed func() (bool, bool)

	QuitCallback func()

	CommitFn func(string)
}

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) 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) GetMode

func (e StringEditor) GetMode() input.TextEditMode

GetMode returns the current mode of the editor.

func (StringEditor) GetName

func (e StringEditor) GetName() string

GetName returns the name of the editor.

func (*StringEditor) GetPane

func (e *StringEditor) GetPane(
	renderer ui.ConstrainedRenderer,
	visible func() bool,
	inputConfig input.InputConfig,
	stylesheet styling.Stylesheet,
	cursorController ui.CursorLocationRequestHandler,
) (ui.Pane, error)

GetPane returns a UI pane representing the editor.

func (*StringEditor) GetSummary added in v0.9.7

func (e *StringEditor) GetSummary() edit.SummaryEntry

func (*StringEditor) GetType added in v0.9.7

func (e *StringEditor) GetType() string

GetType asserts that this is a string editor.

func (StringEditor) IsActiveAndFocussed added in v0.9.7

func (e StringEditor) IsActiveAndFocussed() (bool, bool)

IsActiveAndFocussed ...

func (*StringEditor) MoveCursorLeft

func (e *StringEditor) MoveCursorLeft()

MoveCursorLeft moves the cursor one rune to the left.

func (*StringEditor) MoveCursorNextWordBeginning

func (e *StringEditor) MoveCursorNextWordBeginning()

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

func (*StringEditor) MoveCursorNextWordEnd

func (e *StringEditor) MoveCursorNextWordEnd()

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

func (*StringEditor) MoveCursorPastEnd

func (e *StringEditor) MoveCursorPastEnd()

MoveCursorPastEnd moves the cursor past the end of the string.

func (*StringEditor) MoveCursorPrevWordBeginning

func (e *StringEditor) MoveCursorPrevWordBeginning()

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

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) 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()
	MoveCursorRightA()
	MoveCursorNextWordBeginning()
	MoveCursorPrevWordBeginning()
	MoveCursorNextWordEnd()
	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