pub struct Editor { /* private fields */ }Implementations§
Source§impl Editor
impl Editor
pub fn new() -> Self
pub fn with_content(content: String) -> Self
pub fn content(&self) -> &str
pub fn cursor(&self) -> usize
pub fn scroll_offset(&self) -> usize
pub fn vertical_scroll(&self) -> usize
Sourcepub fn cursor_line_col(&self) -> (usize, usize)
pub fn cursor_line_col(&self) -> (usize, usize)
Returns (line, col) of the cursor where col is the display width within the line.
pub fn line_count(&self) -> usize
Sourcepub fn visual_cursor(&self) -> usize
pub fn visual_cursor(&self) -> usize
Visual cursor column within the current line.
pub fn undo(&mut self) -> bool
pub fn redo(&mut self) -> bool
pub fn insert_char(&mut self, c: char)
pub fn insert_newline(&mut self)
pub fn delete_back(&mut self)
pub fn delete_forward(&mut self)
pub fn move_left(&mut self)
Sourcepub fn move_left_in_line(&mut self)
pub fn move_left_in_line(&mut self)
Move cursor left by one char, but not past the start of the current line. Used by vim Esc (EnterNormalMode) which should not cross line boundaries.
pub fn move_right(&mut self)
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Move cursor left by one word (to previous word boundary).
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Move cursor right by one word (to next word boundary).
pub fn move_up(&mut self)
pub fn move_down(&mut self)
Sourcepub fn delete_char_at_cursor(&mut self)
pub fn delete_char_at_cursor(&mut self)
Delete character under cursor (vim x). Does nothing at end of content.
Sourcepub fn delete_line(&mut self)
pub fn delete_line(&mut self)
Delete the current line (vim dd).
Sourcepub fn clear_line(&mut self)
pub fn clear_line(&mut self)
Clear the current line’s content but keep the line (vim cc).
Sourcepub fn insert_str(&mut self, s: &str)
pub fn insert_str(&mut self, s: &str)
Insert a string at cursor (single undo snapshot). Used for paste.
Sourcepub fn open_line_below(&mut self)
pub fn open_line_below(&mut self)
Insert a new line below current and move cursor there (vim o).
Sourcepub fn open_line_above(&mut self)
pub fn open_line_above(&mut self)
Insert a new line above current and move cursor there (vim O).
Sourcepub fn move_to_first_non_blank(&mut self)
pub fn move_to_first_non_blank(&mut self)
Move cursor to first non-whitespace character on current line (vim ^).
Sourcepub fn move_to_first_line(&mut self)
pub fn move_to_first_line(&mut self)
Move cursor to start of first line (vim gg).
Sourcepub fn move_to_last_line(&mut self)
pub fn move_to_last_line(&mut self)
Move cursor to start of last line (vim G).
Sourcepub fn move_word_forward_end(&mut self)
pub fn move_word_forward_end(&mut self)
Move cursor forward to end of current/next word (vim e).
Sourcepub fn update_scroll(&mut self, visible_width: usize)
pub fn update_scroll(&mut self, visible_width: usize)
Update horizontal scroll for the current line.
Sourcepub fn update_vertical_scroll(&mut self, visible_height: usize)
pub fn update_vertical_scroll(&mut self, visible_height: usize)
Update vertical scroll to keep cursor visible within visible_height lines.
Sourcepub fn set_cursor_by_col(&mut self, col: usize)
pub fn set_cursor_by_col(&mut self, col: usize)
Set cursor by display column (single-line editors / mouse click).
Sourcepub fn set_cursor_by_position(&mut self, line: usize, col: usize)
pub fn set_cursor_by_position(&mut self, line: usize, col: usize)
Set cursor by (line, col) position (multi-line editors / mouse click).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Editor
impl RefUnwindSafe for Editor
impl Send for Editor
impl Sync for Editor
impl Unpin for Editor
impl UnsafeUnpin for Editor
impl UnwindSafe for Editor
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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