pub struct Editor { /* private fields */ }Expand description
A multi-line text editor component.
Defaults to Emacs-style bindings (Ctrl+A, Ctrl+E, Ctrl+K, etc.).
Call set_vim_mode_enabled to opt into
vim-style modal editing (Normal/Insert mode with hjkl, dd, yy, etc.).
Supports undo/redo, kill-ring (yank/yank-pop), history navigation, word-wise movement, and paste detection for large inserts.
Implementations§
Source§impl Editor
impl Editor
Sourcepub fn vim_mode_enabled(&self) -> bool
pub fn vim_mode_enabled(&self) -> bool
Returns true if vim modal editing is enabled.
Sourcepub fn set_vim_mode_enabled(&mut self, enabled: bool)
pub fn set_vim_mode_enabled(&mut self, enabled: bool)
Enable or disable vim modal editing.
When enabled the editor starts in Normal mode; press i to insert,
Escape to return to Normal. When disabled, Emacs-style bindings
are always active.
Sourcepub fn cursor_grapheme(&self) -> usize
pub fn cursor_grapheme(&self) -> usize
Current cursor position in grapheme indices.
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Replace the entire text buffer and move the cursor to the end.
Sourcepub fn push_history(&mut self)
pub fn push_history(&mut self)
Append the current text to the history ring buffer.
History is capped at max_history items (default 100). The history
index is reset so subsequent Up/Down navigation starts from the newest
entry.
Trait Implementations§
Source§impl Component for Editor
impl Component for Editor
Source§fn render(&self, width: u16) -> Result<Rendered, RenderError>
fn render(&self, width: u16) -> Result<Rendered, RenderError>
Source§fn handle_input(&mut self, event: &Event) -> InputResult
fn handle_input(&mut self, event: &Event) -> InputResult
Source§fn as_focusable(&self) -> Option<&dyn Focusable>
fn as_focusable(&self) -> Option<&dyn Focusable>
Focusable reference, if supported.Source§fn as_focusable_mut(&mut self) -> Option<&mut dyn Focusable>
fn as_focusable_mut(&mut self) -> Option<&mut dyn Focusable>
Focusable reference, if supported.Source§fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
fn render_rect(&self, rect: Rect) -> Result<Rendered, RenderError>
Source§fn wants_key_release(&self) -> bool
fn wants_key_release(&self) -> bool
true if this component wants to receive
KeyEventKind::Release events in addition to Press / Repeat. Read more