Expand description
The Fast Text plugin system.
Plugins are small Rhai scripts that register named
commands and keybindings. They describe edits as EditorActions rather
than touching the editor directly, so they are safe, sandboxed, and easy to
apply from any frontend.
Example plugin:
// Wrap the selection in quotes.
fn quote_selection() {
insert("\"" + selected_text + "\"");
}
command_with_desc("Wrap in quotes", "Surround the selection with \"", "quote_selection");
bind("ctrl+shift+q", "Wrap in quotes");Globals available to scripts: cursor, selection_start, selection_end,
has_selection, selected_text, line, col, doc_len, line_count,
file_name, language.
Structs§
- Command
Info - Metadata about a registered command.
- Editor
Context - A snapshot of the editor, exposed to scripts as global constants.
- KeySpec
- A key plus its modifier state, as written in a plugin, e.g.
ctrl+shift+k. - Plugin
Host - Loads Rhai plugins and runs their commands against the editor.
Enums§
- Cursor
Style - The shape of the terminal cursor.
- Editor
Action - A movement or edit a plugin wants performed.
- Editor
Command - An editor command that every frontend understands.
- KeyName
- A key, independent of any particular terminal backend.
Constants§
- COMMANDS
- Every command, with its stable id, human title and default binding.
Functions§
- command_
for - The binding in
default_bindings()for this key, if any. - command_
from_ name - Resolves a stable id or a human title (case- and separator-insensitive).
- command_
id - The stable id of a command (
"save","file_finder"). - command_
title - A command’s human title (
"Save As…"). - default_
bindings - The default key bindings, in table order.
- default_
shortcut - The display spelling of a command’s default binding, e.g.
Ctrl+P.