Skip to main content

Crate fast_text_plugin

Crate fast_text_plugin 

Source
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§

CommandInfo
Metadata about a registered command.
EditorContext
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.
PluginHost
Loads Rhai plugins and runs their commands against the editor.

Enums§

CursorStyle
The shape of the terminal cursor.
EditorAction
A movement or edit a plugin wants performed.
EditorCommand
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.