pub struct VimEditor {Show 26 fields
pub lines: Vec<String>,
pub cursor_row: usize,
pub cursor_col: usize,
pub mode: VimMode,
pub config: VimModeConfig,
pub scroll_offset: usize,
pub visible_height: usize,
pub undo_stack: Vec<Snapshot>,
pub redo_stack: Vec<Snapshot>,
pub unnamed_register: Register,
pub search: SearchState,
pub visual_anchor: Option<(usize, usize)>,
pub pending_count: Option<usize>,
pub pending_operator: Option<Operator>,
pub pending_g: bool,
pub pending_register: bool,
pub use_system_clipboard: bool,
pub pending_find: Option<(FindDirection, bool)>,
pub pending_replace: bool,
pub last_edit: Option<EditRecord>,
pub recording_edit: Vec<KeyEvent>,
pub is_recording: bool,
pub modified: bool,
pub command_line: String,
pub command_active: bool,
pub command_buffer: String,
}Expand description
A self-contained Vim editor instance with its own buffer, cursor, mode, and state. Each view that needs a Vim editor creates its own VimEditor.
Fields§
§lines: Vec<String>§cursor_row: usize§cursor_col: usize§mode: VimMode§config: VimModeConfig§scroll_offset: usize§visible_height: usize§undo_stack: Vec<Snapshot>§redo_stack: Vec<Snapshot>§unnamed_register: Register§search: SearchState§visual_anchor: Option<(usize, usize)>§pending_count: Option<usize>§pending_operator: Option<Operator>§pending_g: bool§pending_register: bool§use_system_clipboard: bool§pending_find: Option<(FindDirection, bool)>§pending_replace: bool§last_edit: Option<EditRecord>§recording_edit: Vec<KeyEvent>§is_recording: bool§modified: bool§command_line: String§command_active: bool§command_buffer: StringImplementations§
Source§impl VimEditor
impl VimEditor
Sourcepub fn handle_key(&mut self, key: KeyEvent) -> EditorAction
pub fn handle_key(&mut self, key: KeyEvent) -> EditorAction
Main input handler. Returns EditorAction to inform the parent.
Source§impl VimEditor
impl VimEditor
pub fn move_left(&mut self, count: usize)
pub fn move_right(&mut self, count: usize)
pub fn move_down(&mut self, count: usize)
pub fn move_up(&mut self, count: usize)
pub fn move_to_line_start(&mut self)
pub fn move_to_first_non_blank(&mut self)
pub fn move_to_line_end(&mut self)
pub fn move_to_top(&mut self)
pub fn move_to_bottom(&mut self)
pub fn move_to_line(&mut self, line_num: usize)
pub fn half_page_down(&mut self)
pub fn half_page_up(&mut self)
pub fn move_word_forward(&mut self, count: usize, big_word: bool)
pub fn move_word_end(&mut self, count: usize, big_word: bool)
pub fn move_word_back(&mut self, count: usize, big_word: bool)
pub fn find_char_forward(&mut self, target: char, before: bool)
pub fn find_char_backward(&mut self, target: char, after: bool)
Sourcepub fn compute_motion_range(
&self,
motion: &Motion,
count: usize,
) -> Option<MotionRange>
pub fn compute_motion_range( &self, motion: &Motion, count: usize, ) -> Option<MotionRange>
Compute the range that a motion covers from current position. Used by operators like d, y, c.
Source§impl VimEditor
impl VimEditor
Sourcepub fn execute_operator(&mut self, op: &Operator, motion: &Motion, count: usize)
pub fn execute_operator(&mut self, op: &Operator, motion: &Motion, count: usize)
Execute operator + motion combination
Sourcepub fn toggle_case_at_cursor(&mut self)
pub fn toggle_case_at_cursor(&mut self)
Toggle case of character at cursor (~)
Sourcepub fn replace_char(&mut self, new_char: char)
pub fn replace_char(&mut self, new_char: char)
Replace character at cursor (r)
Source§impl VimEditor
impl VimEditor
Sourcepub fn start_search(&mut self, forward: bool)
pub fn start_search(&mut self, forward: bool)
Start search mode
Sourcepub fn commit_search(&mut self)
pub fn commit_search(&mut self)
Commit the search and jump to first match
Sourcepub fn cancel_search(&mut self)
pub fn cancel_search(&mut self)
Cancel search
Sourcepub fn jump_to_next_match(&mut self)
pub fn jump_to_next_match(&mut self)
Jump to next match (n)
Sourcepub fn jump_to_prev_match(&mut self)
pub fn jump_to_prev_match(&mut self)
Jump to previous match (N)
Source§impl VimEditor
impl VimEditor
Sourcepub fn enter_visual(&mut self, kind: VisualKind)
pub fn enter_visual(&mut self, kind: VisualKind)
Enter visual mode
Sourcepub fn visual_range(&self) -> Option<((usize, usize), (usize, usize))>
pub fn visual_range(&self) -> Option<((usize, usize), (usize, usize))>
Get the ordered (start, end) of the visual selection
Sourcepub fn visual_delete(&mut self)
pub fn visual_delete(&mut self)
Delete visual selection
Sourcepub fn visual_yank(&mut self)
pub fn visual_yank(&mut self)
Yank visual selection
Sourcepub fn visual_indent(&mut self)
pub fn visual_indent(&mut self)
Indent visual selection
Sourcepub fn visual_dedent(&mut self)
pub fn visual_dedent(&mut self)
Dedent visual selection
Sourcepub fn exit_visual(&mut self)
pub fn exit_visual(&mut self)
Exit visual mode
Source§impl VimEditor
impl VimEditor
pub fn new(content: &str, config: VimModeConfig) -> Self
pub fn new_empty(config: VimModeConfig) -> Self
pub fn set_content(&mut self, content: &str)
pub fn content(&self) -> String
Sourcepub fn selected_text(&self) -> Option<String>
pub fn selected_text(&self) -> Option<String>
Get the visually selected text
pub fn line_count(&self) -> usize
pub fn current_line(&self) -> &str
pub fn current_line_len(&self) -> usize
Sourcepub fn clamp_cursor(&mut self)
pub fn clamp_cursor(&mut self)
Clamp cursor column to valid range for current line
Sourcepub fn ensure_cursor_visible(&mut self)
pub fn ensure_cursor_visible(&mut self)
Ensure scroll keeps cursor visible with scrolloff
pub fn insert_char(&mut self, c: char)
pub fn insert_newline(&mut self)
pub fn backspace(&mut self)
pub fn delete_char_at_cursor(&mut self)
pub fn delete_line(&mut self, row: usize) -> Option<String>
pub fn delete_lines(&mut self, start: usize, count: usize) -> String
pub fn delete_range( &mut self, start_col: usize, end_col: usize, row: usize, ) -> String
pub fn paste_after(&mut self)
pub fn paste_before(&mut self)
pub fn indent_line(&mut self, row: usize)
pub fn dedent_line(&mut self, row: usize)
Sourcepub fn take_count(&mut self) -> usize
pub fn take_count(&mut self) -> usize
Get effective count: pending_count or 1
Sourcepub fn update_command_line(&mut self)
pub fn update_command_line(&mut self)
Update command line based on current mode
pub fn copy_to_system_clipboard(&self, text: &str)
pub fn paste_from_system_clipboard(&mut self)
Auto Trait Implementations§
impl Freeze for VimEditor
impl RefUnwindSafe for VimEditor
impl Send for VimEditor
impl Sync for VimEditor
impl Unpin for VimEditor
impl UnsafeUnpin for VimEditor
impl UnwindSafe for VimEditor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more