Skip to main content

fast_text_plugin/
lib.rs

1//! The Fast Text plugin system.
2//!
3//! Plugins are small [Rhai](https://rhai.rs) scripts that register named
4//! commands and keybindings. They describe edits as [`EditorAction`]s rather
5//! than touching the editor directly, so they are safe, sandboxed, and easy to
6//! apply from any frontend.
7//!
8//! Example plugin:
9//!
10//! ```rhai
11//! // Wrap the selection in quotes.
12//! fn quote_selection() {
13//!     insert("\"" + selected_text + "\"");
14//! }
15//! command_with_desc("Wrap in quotes", "Surround the selection with \"", "quote_selection");
16//! bind("ctrl+shift+q", "Wrap in quotes");
17//! ```
18//!
19//! Globals available to scripts: `cursor`, `selection_start`, `selection_end`,
20//! `has_selection`, `selected_text`, `line`, `col`, `doc_len`, `line_count`,
21//! `file_name`, `language`.
22
23mod action;
24mod host;
25mod key;
26
27pub use action::{CursorStyle, EditorAction};
28pub use host::{CommandInfo, EditorContext, PluginHost};
29pub use key::{KeyName, KeySpec};