keymap

package
v0.0.0-...-8aadb99 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Editor.
	Emacs         = "emacs"
	EmacsMeta     = "emacs-meta"
	EmacsCtrlX    = "emacs-ctlx"
	EmacsStandard = "emacs-standard"

	ViInsert  = "vi-insert"
	Vi        = "vi"
	ViCommand = "vi-command"
	ViMove    = "vi-move"
	Visual    = "vi-visual"
	ViOpp     = "vi-opp"

	// Completion and search.
	Isearch    = "isearch"
	MenuSelect = "menu-select"
)

These are the root keymaps used in the readline shell. Their functioning is similar to how ZSH organizes keymaps.

Variables

This section is empty.

Functions

func MatchLocal

func MatchLocal(eng *Engine) (bind inputrc.Bind, command func(), prefix bool)

MatchLocal incrementally attempts to match cached input keys against the local keymap. Returns the bind if matched, the corresponding command, and if we only matched by prefix.

func MatchMain

func MatchMain(eng *Engine) (bind inputrc.Bind, command func(), prefix bool)

MatchMain incrementally attempts to match cached input keys against the local keymap. Returns the bind if matched, the corresponding command, and if we only matched by prefix.

Types

type CursorStyle

type CursorStyle string

CursorStyle is the style of the cursor in a given input mode/submode.

func (CursorStyle) String

func (c CursorStyle) String() string

String - Implements fmt.Stringer.

type Engine

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

Engine is used to manage the main and local keymaps for the shell.

func NewEngine

func NewEngine(keys *core.Keys, i *core.Iterations, opts ...inputrc.Option) (*Engine, *inputrc.Config)

NewEngine is a required constructor for the keymap modes manager. It initializes the keymaps to their defaults or configured values.

func (*Engine) ActiveCommand

func (m *Engine) ActiveCommand() inputrc.Bind

ActiveCommand returns the sequence/command currently being ran.

func (*Engine) CancelPending

func (m *Engine) CancelPending()

CancelPending is used by commands that have been registering themselves as waiting for a pending operator, but have actually been called twice in a row (eg. dd/yy in Vim mode). This removes those commands from queue.

func (*Engine) Commands

func (m *Engine) Commands() map[string]func()

Commands returns the map of all command functions available to the shell. This includes the builtin commands (emacs/Vim/history/completion/etc), as well as any functions added by the user through Keymap.Register(). The keys of this map are the names of each corresponding command function.

func (*Engine) InputIsTerminator

func (m *Engine) InputIsTerminator() bool

InputIsTerminator returns true when current input keys are one of the configured or builtin "terminators", which can be configured in .inputrc with the isearch-terminators variable.

func (*Engine) IsEmacs

func (m *Engine) IsEmacs() bool

IsEmacs returns true if the main keymap is one of the emacs modes.

func (*Engine) IsPending

func (m *Engine) IsPending() bool

IsPending returns true when invoked from within the command that also happens to be the next in line of pending commands.

func (*Engine) Local

func (m *Engine) Local() Mode

Local returns the local keymap.

func (*Engine) Main

func (m *Engine) Main() Mode

Main returns the local keymap.

func (*Engine) NonIncrementalSearchStart

func (m *Engine) NonIncrementalSearchStart()

NonIncrementalSearchStart is used to notify the keymap dispatchers that are using a minibuffer, and that the set of valid commands should be restrained to a few ones (self-insert/abort/rubout...).

func (*Engine) NonIncrementalSearchStop

func (m *Engine) NonIncrementalSearchStop()

NonIncrementalSearchStop notifies the keymap dispatchers that we stopped editing a non-incremental search minibuffer.

func (*Engine) Pending

func (m *Engine) Pending()

Pending registers a command as waiting for another command to run first, such as yank/delete/change actions, which accept/require a movement command.

func (*Engine) PendingCursor

func (m *Engine) PendingCursor() (restore func())

PendingCursor changes the cursor to pending mode, and returns a function to call once done with it.

func (*Engine) PrintBinds

func (m *Engine) PrintBinds(keymap string, inputrcFormat bool)

PrintBinds displays a list of currently bound commands (and their sequences) to the screen. If inputrcFormat is true, it displays it formatted such that the output can be reused in an .inputrc file.

func (*Engine) PrintCursor

func (m *Engine) PrintCursor(keymap Mode)

PrintCursor prints the cursor for the given keymap mode, either default value or the one specified in inputrc file.

func (*Engine) Register

func (m *Engine) Register(commands map[string]func())

Register adds command functions to the list of available commands. Each key of the map should be a unique name, not yet used by any other builtin/user command, in order not to "overload" the builtins.

func (*Engine) ReloadConfig

func (m *Engine) ReloadConfig(opts ...inputrc.Option) (err error)

ReloadConfig parses all valid .inputrc configurations and immediately updates/reloads all related settings (editing mode, variables behavior, etc.)

func (*Engine) ResetLocal

func (m *Engine) ResetLocal()

ResetLocal deactivates the local keymap of the shell.

func (*Engine) RunPending

func (m *Engine) RunPending()

RunPending runs any command with pending execution.

func (*Engine) SetLocal

func (m *Engine) SetLocal(keymap string)

SetLocal sets the local keymap of the shell. Valid builtin keymaps are: - vi-opp, vi-visual. (used in commands like yank, change, delete, etc.) - isearch, menu-select (used in search and completion).

func (*Engine) SetMain

func (m *Engine) SetMain(keymap string)

SetMain sets the main keymap of the shell. Valid builtin keymaps are: - emacs, emacs-meta, emacs-ctlx, emacs-standard. - vi, vi-insert, vi-command, vi-move.

func (*Engine) UpdateCursor

func (m *Engine) UpdateCursor()

UpdateCursor reprints the cursor corresponding to the current keymaps.

type Mode

type Mode string

Mode is a root keymap mode for the shell. To each of these keymap modes is bound a keymap.

Jump to

Keyboard shortcuts

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