Expand description
Embeds the TextWrite scripting language into the Fast Text editor.
TextWrite scripts run against the same editor API as Rhai plugins: they
never touch the buffer directly, they describe changes as
EditorActions that the host applies in order. That keeps the scripting
layer decoupled from the editor internals and from the borrow checker.
A script makes the editor globals (selected_text, document_text,
has_selection, file_name, theme, …) available and calls editor
functions to act:
fn wrap_in_quotes() {
if has_selection {
insert("\"" + selected_text + "\"")
} else {
message("Select some text first")
}
}
command_with_desc("Wrap in quotes", "Surround the selection with \"", "wrap_in_quotes")
bind("ctrl+shift+q", "Wrap in quotes")Besides editing actions, a script can restyle the editor: set_theme(name)
switches to a built-in or plugin-defined theme, and define_theme(name, colors) registers a new palette from a map of 0xRRGGBB colors.
ScriptHost loads scripts, remembers the commands, keybindings and themes
they register, and runs a named command against a snapshot of the editor
state.
Structs§
- Script
Host - Loads TextWrite editor scripts and runs their commands.
Enums§
- Value
- A TextWrite runtime value.