Documentation ¶
Index ¶
- Constants
- func MatchLocal(eng *Engine) (bind inputrc.Bind, command func(), prefix bool)
- func MatchMain(eng *Engine) (bind inputrc.Bind, command func(), prefix bool)
- type CursorStyle
- type Engine
- func (m *Engine) ActiveCommand() inputrc.Bind
- func (m *Engine) CancelPending()
- func (m *Engine) Commands() map[string]func()
- func (m *Engine) InputIsTerminator() bool
- func (m *Engine) IsEmacs() bool
- func (m *Engine) IsPending() bool
- func (m *Engine) Local() Mode
- func (m *Engine) Main() Mode
- func (m *Engine) NonIncrementalSearchStart()
- func (m *Engine) NonIncrementalSearchStop()
- func (m *Engine) Pending()
- func (m *Engine) PendingCursor() (restore func())
- func (m *Engine) PrintBinds(keymap string, inputrcFormat bool)
- func (m *Engine) PrintCursor(keymap Mode)
- func (m *Engine) Register(commands map[string]func())
- func (m *Engine) ReloadConfig(opts ...inputrc.Option) (err error)
- func (m *Engine) ResetLocal()
- func (m *Engine) RunPending()
- func (m *Engine) SetLocal(keymap string)
- func (m *Engine) SetMain(keymap string)
- func (m *Engine) UpdateCursor()
- type Mode
Constants ¶
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 ¶
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.
Types ¶
type CursorStyle ¶
type CursorStyle string
CursorStyle is the style of the cursor in a given input mode/submode.
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 ¶
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 ¶
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 ¶
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) IsPending ¶
IsPending returns true when invoked from within the command that also happens to be the next in line of pending commands.
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 ¶
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 ¶
PrintCursor prints the cursor for the given keymap mode, either default value or the one specified in inputrc file.
func (*Engine) Register ¶
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 ¶
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 ¶
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 ¶
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.