Documentation
¶
Index ¶
- func AbortSearchAndReturnToNormalMode(s *state.EditorState)
- func BeginNewLineAbove(s *state.EditorState)
- func BeginNewLineBelow(s *state.EditorState)
- func CommitSearchAndReturnToNormalMode(s *state.EditorState)
- func CursorBack(s *state.EditorState)
- func CursorDown(s *state.EditorState)
- func CursorLeft(s *state.EditorState)
- func CursorLineEnd(s *state.EditorState)
- func CursorLineEndIncludeEndOfLineOrFile(s *state.EditorState)
- func CursorLineStart(s *state.EditorState)
- func CursorLineStartNonWhitespace(s *state.EditorState)
- func CursorNextParagraph(s *state.EditorState)
- func CursorNextWordEnd(s *state.EditorState)
- func CursorNextWordStart(s *state.EditorState)
- func CursorPrevParagraph(s *state.EditorState)
- func CursorPrevWordStart(s *state.EditorState)
- func CursorRight(s *state.EditorState)
- func CursorRightIncludeEndOfLineOrFile(s *state.EditorState)
- func CursorStartOfLastLine(s *state.EditorState)
- func CursorUp(s *state.EditorState)
- func DeleteRuneFromMenuSearch(s *state.EditorState)
- func DeleteRuneFromSearchQuery(s *state.EditorState)
- func EmptyAction(s *state.EditorState)
- func EnterInsertMode(s *state.EditorState)
- func EnterInsertModeAtEndOfLine(s *state.EditorState)
- func EnterInsertModeAtNextPos(s *state.EditorState)
- func EnterInsertModeAtStartOfLine(s *state.EditorState)
- func ExecuteSelectedMenuItem(s *state.EditorState)
- func FindNextMatch(s *state.EditorState)
- func FindPrevMatch(s *state.EditorState)
- func HideMenuAndReturnToNormalMode(s *state.EditorState)
- func IndentLine(s *state.EditorState)
- func InsertNewlineAndUpdateAutoIndentWhitespace(s *state.EditorState)
- func InsertTab(s *state.EditorState)
- func JoinLines(s *state.EditorState)
- func MenuSelectionDown(s *state.EditorState)
- func MenuSelectionUp(s *state.EditorState)
- func OutdentLine(s *state.EditorState)
- func Redo(s *state.EditorState)
- func ReturnToNormalMode(s *state.EditorState)
- func ReturnToNormalModeAfterInsert(s *state.EditorState)
- func StartSearchBackward(s *state.EditorState)
- func StartSearchForward(s *state.EditorState)
- func ToggleCaseAtCursor(s *state.EditorState)
- func ToggleVisualModeCharwise(s *state.EditorState)
- func ToggleVisualModeLinewise(s *state.EditorState)
- func Undo(s *state.EditorState)
- type Action
- func AppendRuneToMenuSearch(r rune) Action
- func AppendRuneToSearchQuery(r rune) Action
- func ChangeAWord(clipboardPageNameArg *rune) Action
- func ChangeInnerWord(clipboardPageNameArg *rune) Action
- func ChangeSelection(clipboardPageNameArg *rune, selectionMode selection.Mode, ...) Action
- func ChangeToNextMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, clipboardPageNameArg *rune, ...) Action
- func ChangeToPrevMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, clipboardPageNameArg *rune, ...) Action
- func ChangeToStartOfNextWord(clipboardPageNameArg *rune) Action
- func CopyAWord(clipboardPageNameArg *rune) Action
- func CopyInnerWord(clipboardPageNameArg *rune) Action
- func CopyLines(clipboardPageNameArg *rune) Action
- func CopySelectionAndReturnToNormalMode(clipboardPageNameArg *rune) Action
- func CopyToStartOfNextWord(clipboardPageNameArg *rune) Action
- func CursorStartOfLineNum(countArg *uint64) Action
- func CursorToNextMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, includeChar bool) Action
- func CursorToPrevMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, includeChar bool) Action
- func DeleteAWord(clipboardPageNameArg *rune) Action
- func DeleteDown(clipboardPageNameArg *rune) Action
- func DeleteInnerWord(clipboardPageNameArg *rune) Action
- func DeleteLines(countArg *uint64, clipboardPageNameArg *rune) Action
- func DeleteNextCharInLine(countArg *uint64, clipboardPageNameArg *rune) Action
- func DeletePrevChar(clipboardPageNameArg *rune) Action
- func DeletePrevCharInLine(clipboardPageNameArg *rune) Action
- func DeleteSelection(clipboardPageNameArg *rune, selectionMode selection.Mode, ...) Action
- func DeleteSelectionAndReturnToNormalMode(clipboardPageNameArg *rune, selectionMode selection.Mode, ...) Action
- func DeleteToEndOfLine(clipboardPageNameArg *rune) Action
- func DeleteToNextMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, clipboardPageNameArg *rune, ...) Action
- func DeleteToPrevMatchingChar(inputEvents []*tcell.EventKey, countArg *uint64, clipboardPageNameArg *rune, ...) Action
- func DeleteToStartOfLine(clipboardPageNameArg *rune) Action
- func DeleteToStartOfLineNonWhitespace(clipboardPageNameArg *rune) Action
- func DeleteToStartOfNextWord(clipboardPageNameArg *rune) Action
- func DeleteUp(clipboardPageNameArg *rune) Action
- func IndentSelectionAndReturnToNormalMode(selectionEndLoc state.Locator) Action
- func InsertRune(r rune) Action
- func OutdentSelectionAndReturnToNormalMode(selectionEndLoc state.Locator) Action
- func PasteAfterCursor(clipboardPageNameArg *rune) Action
- func PasteBeforeCursor(clipboardPageNameArg *rune) Action
- func ReplaceCharacter(inputEvents []*tcell.EventKey) Action
- func ScrollDown(config Config) Action
- func ScrollUp(config Config) Action
- func ShowCommandMenu(config Config) Action
- func ShowFileMenu(config Config) Action
- func ToggleCaseInSelectionAndReturnToNormalMode(selectionEndLoc state.Locator) Action
- type ActionBuilder
- type ActionBuilderParams
- type Config
- type EventMatcher
- type Interpreter
- type MacroRecorder
- type Mode
- type ParseResult
- type Parser
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortSearchAndReturnToNormalMode ¶
func AbortSearchAndReturnToNormalMode(s *state.EditorState)
func BeginNewLineAbove ¶
func BeginNewLineAbove(s *state.EditorState)
func BeginNewLineBelow ¶
func BeginNewLineBelow(s *state.EditorState)
func CommitSearchAndReturnToNormalMode ¶
func CommitSearchAndReturnToNormalMode(s *state.EditorState)
func CursorBack ¶
func CursorBack(s *state.EditorState)
func CursorDown ¶
func CursorDown(s *state.EditorState)
func CursorLeft ¶
func CursorLeft(s *state.EditorState)
func CursorLineEnd ¶
func CursorLineEnd(s *state.EditorState)
func CursorLineEndIncludeEndOfLineOrFile ¶
func CursorLineEndIncludeEndOfLineOrFile(s *state.EditorState)
func CursorLineStart ¶
func CursorLineStart(s *state.EditorState)
func CursorLineStartNonWhitespace ¶
func CursorLineStartNonWhitespace(s *state.EditorState)
func CursorNextParagraph ¶
func CursorNextParagraph(s *state.EditorState)
func CursorNextWordEnd ¶
func CursorNextWordEnd(s *state.EditorState)
func CursorNextWordStart ¶
func CursorNextWordStart(s *state.EditorState)
func CursorPrevParagraph ¶
func CursorPrevParagraph(s *state.EditorState)
func CursorPrevWordStart ¶
func CursorPrevWordStart(s *state.EditorState)
func CursorRight ¶
func CursorRight(s *state.EditorState)
func CursorRightIncludeEndOfLineOrFile ¶
func CursorRightIncludeEndOfLineOrFile(s *state.EditorState)
func CursorStartOfLastLine ¶
func CursorStartOfLastLine(s *state.EditorState)
func CursorUp ¶
func CursorUp(s *state.EditorState)
func DeleteRuneFromMenuSearch ¶
func DeleteRuneFromMenuSearch(s *state.EditorState)
func DeleteRuneFromSearchQuery ¶
func DeleteRuneFromSearchQuery(s *state.EditorState)
func EmptyAction ¶
func EmptyAction(s *state.EditorState)
EmptyAction is an action that does nothing.
func EnterInsertMode ¶
func EnterInsertMode(s *state.EditorState)
func EnterInsertModeAtEndOfLine ¶
func EnterInsertModeAtEndOfLine(s *state.EditorState)
func EnterInsertModeAtNextPos ¶
func EnterInsertModeAtNextPos(s *state.EditorState)
func EnterInsertModeAtStartOfLine ¶
func EnterInsertModeAtStartOfLine(s *state.EditorState)
func ExecuteSelectedMenuItem ¶
func ExecuteSelectedMenuItem(s *state.EditorState)
func FindNextMatch ¶
func FindNextMatch(s *state.EditorState)
func FindPrevMatch ¶
func FindPrevMatch(s *state.EditorState)
func HideMenuAndReturnToNormalMode ¶
func HideMenuAndReturnToNormalMode(s *state.EditorState)
func IndentLine ¶
func IndentLine(s *state.EditorState)
func InsertNewlineAndUpdateAutoIndentWhitespace ¶ added in v0.2.0
func InsertNewlineAndUpdateAutoIndentWhitespace(s *state.EditorState)
func InsertTab ¶
func InsertTab(s *state.EditorState)
func JoinLines ¶
func JoinLines(s *state.EditorState)
func MenuSelectionDown ¶
func MenuSelectionDown(s *state.EditorState)
func MenuSelectionUp ¶
func MenuSelectionUp(s *state.EditorState)
func OutdentLine ¶
func OutdentLine(s *state.EditorState)
func Redo ¶
func Redo(s *state.EditorState)
func ReturnToNormalMode ¶
func ReturnToNormalMode(s *state.EditorState)
func ReturnToNormalModeAfterInsert ¶ added in v0.2.0
func ReturnToNormalModeAfterInsert(s *state.EditorState)
func StartSearchBackward ¶
func StartSearchBackward(s *state.EditorState)
func StartSearchForward ¶
func StartSearchForward(s *state.EditorState)
func ToggleCaseAtCursor ¶
func ToggleCaseAtCursor(s *state.EditorState)
func ToggleVisualModeCharwise ¶
func ToggleVisualModeCharwise(s *state.EditorState)
func ToggleVisualModeLinewise ¶
func ToggleVisualModeLinewise(s *state.EditorState)
func Undo ¶
func Undo(s *state.EditorState)
Types ¶
type Action ¶
type Action func(*state.EditorState)
Action is a function that mutates the editor state.
func AppendRuneToMenuSearch ¶
func AppendRuneToSearchQuery ¶
func ChangeAWord ¶
func ChangeInnerWord ¶
func ChangeSelection ¶
func ChangeToNextMatchingChar ¶ added in v0.2.0
func ChangeToPrevMatchingChar ¶ added in v0.2.0
func ChangeToStartOfNextWord ¶ added in v0.2.0
func CopyInnerWord ¶ added in v0.2.0
func CopyToStartOfNextWord ¶ added in v0.2.0
func CursorStartOfLineNum ¶
func CursorToNextMatchingChar ¶ added in v0.2.0
func CursorToPrevMatchingChar ¶ added in v0.2.0
func DeleteAWord ¶
func DeleteDown ¶
func DeleteInnerWord ¶
func DeleteLines ¶ added in v0.2.0
func DeleteNextCharInLine ¶
func DeletePrevChar ¶
func DeletePrevCharInLine ¶
func DeleteSelection ¶ added in v0.2.0
func DeleteToEndOfLine ¶
func DeleteToNextMatchingChar ¶ added in v0.2.0
func DeleteToPrevMatchingChar ¶ added in v0.2.0
func DeleteToStartOfLine ¶
func DeleteToStartOfNextWord ¶ added in v0.2.0
func InsertRune ¶
func PasteAfterCursor ¶
func PasteBeforeCursor ¶
func ReplaceCharacter ¶
func ScrollDown ¶
func ShowCommandMenu ¶
func ShowFileMenu ¶
type ActionBuilder ¶
type ActionBuilder func(p ActionBuilderParams) Action
ActionBuilder is invoked when the input parser accepts a sequence of keypresses matching a rule.
type ActionBuilderParams ¶
type Config ¶
type Config struct {
// InputMode is the current input mode of the editor.
InputMode state.InputMode
// ScrollLines is the number of lines to scroll up or down with Ctrl-U / Ctrl-D.
ScrollLines uint64
// Glob patterns for directories to hide from file search.
DirPatternsToHide []string
// Information about the current selection (visual mode).
// If not in visual mode, the mode will be selection.ModeNone
// and the end locator will be nil.
SelectionMode selection.Mode
SelectionEndLocator state.Locator
}
Config controls how user input is interpreted.
type EventMatcher ¶
type EventMatcher struct {
Wildcard bool // If true, matches every input key.
Key tcell.Key // The kind of key to match (usually tcell.KeyRune)
Rune rune // If the key is tcell.KeyRune, match this rune.
}
EventMatcher matches an input key event.
type Interpreter ¶
type Interpreter struct {
// contains filtered or unexported fields
}
Interpreter translates key events to commands.
func (*Interpreter) InputBufferString ¶ added in v0.2.0
func (inp *Interpreter) InputBufferString(mode state.InputMode) string
InputBufferString returns a string describing buffered input events. It can be displayed to the user to help them understand the input state.
func (*Interpreter) ProcessEvent ¶
func (inp *Interpreter) ProcessEvent(event tcell.Event, config Config) Action
ProcessEvent interprets a terminal input event as an action. (If there is no action, then EmptyAction will be returned.)
type MacroRecorder ¶
type MacroRecorder struct {
// contains filtered or unexported fields
}
MacroRecorder records actions to be replayed later.
func NewMacroRecorder ¶
func NewMacroRecorder() *MacroRecorder
NewMacroRecorder constructs a new macro recorder.
func (*MacroRecorder) ClearLastAction ¶
func (m *MacroRecorder) ClearLastAction()
ClearLastAction resets the "last action" to be replayed.
func (*MacroRecorder) LastAction ¶
func (m *MacroRecorder) LastAction() Action
LastAction returns an action that replays the last action. The "last" action is the sequence of all actions recorded since the recorder was created or last cleared. For example, if the user might press "o" in normal mode to start a new line, type "abc" in insert mode, then return to normal mode. The last action in this case would BOTH start a new line AND insert the text "abc".
func (*MacroRecorder) RecordAction ¶
func (m *MacroRecorder) RecordAction(f Action)
RecordAction records an action to be replayed later.
type Mode ¶
type Mode interface {
// ProcessKeyEvent interprets the key event according to this mode.
// It will return any user-initiated action resulting from the keypress
ProcessKeyEvent(event *tcell.EventKey, macroRecorder *MacroRecorder, config Config) Action
// InputBufferString returns a string describing buffered input events.
// It can be displayed to the user to help them understand the input state.
InputBufferString() string
}
Mode represents an input mode, which is a way of interpreting key events.
type ParseResult ¶
type ParseResult struct {
// Accepted indicates whether the input sequence was accepted.
// The following fields are set only if Accepted is true.
Accepted bool
// Rule is the rule triggered by the sequence of input key events.
Rule Rule
// Input is the sequence of key events that triggered the rule.
Input []*tcell.EventKey
// Count is the parsed count parameter, if provided.
// For example, `5x` (delete five characters) would have count set to 5.
// If provided, the count will always be at least one and at most math.MaxInt64.
// If no count parameter was provided, this will be nil.
Count *uint64
// ClipboardPageName is the name of the page to copy or paste.
// For example `"ap` means "paste clipboard page named 'a'"
// If not provided, this will be nil.
ClipboardPageName *rune
}
ParseResult is the result of parsing an input key event.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses a sequence of input key events based on a set of rules. It parses input incrementally, waiting for a key that will trigger some rule. If the input is rejected by all rules, the parser resets.
func (*Parser) InputBufferString ¶ added in v0.2.0
InputBufferString returns a string describing buffered input events. This can be displayed to the user to help them understand the input state.
func (*Parser) ProcessInput ¶
func (p *Parser) ProcessInput(event *tcell.EventKey) ParseResult
ProcessInput processes an input event key. If a rule accepts the sequence of key presses, the parser returns the accepted sequence, triggered rule, and parsed count parameter. If all rules reject the sequence, the parser resets.
type Rule ¶
type Rule struct {
Name string
Pattern []EventMatcher
ActionBuilder ActionBuilder
SkipMacro bool
}
Rule defines a command that the input parser can recognize. The pattern is a sequence of keypresses that trigger the rule.