Skip to main content

Editor

Struct Editor 

Source
pub struct Editor { /* private fields */ }

Implementations§

Source§

impl Editor

Source

pub fn new() -> Self

Source

pub fn with_content(content: String) -> Self

Source

pub fn content(&self) -> &str

Source

pub fn cursor(&self) -> usize

Source

pub fn scroll_offset(&self) -> usize

Source

pub fn vertical_scroll(&self) -> usize

Source

pub fn cursor_line_col(&self) -> (usize, usize)

Returns (line, col) of the cursor where col is the display width within the line.

Source

pub fn line_count(&self) -> usize

Source

pub fn visual_cursor(&self) -> usize

Visual cursor column within the current line.

Source

pub fn undo(&mut self) -> bool

Source

pub fn redo(&mut self) -> bool

Source

pub fn insert_char(&mut self, c: char)

Source

pub fn insert_newline(&mut self)

Source

pub fn delete_back(&mut self)

Source

pub fn delete_forward(&mut self)

Source

pub fn move_left(&mut self)

Source

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.

Source

pub fn move_right(&mut self)

Source

pub fn move_word_left(&mut self)

Move cursor left by one word (to previous word boundary).

Source

pub fn move_word_right(&mut self)

Move cursor right by one word (to next word boundary).

Source

pub fn move_up(&mut self)

Source

pub fn move_down(&mut self)

Source

pub fn move_home(&mut self)

Move to start of current line.

Source

pub fn move_end(&mut self)

Move to end of current line.

Source

pub fn delete_char_at_cursor(&mut self)

Delete character under cursor (vim x). Does nothing at end of content.

Source

pub fn delete_line(&mut self)

Delete the current line (vim dd).

Source

pub fn clear_line(&mut self)

Clear the current line’s content but keep the line (vim cc).

Source

pub fn insert_str(&mut self, s: &str)

Insert a string at cursor (single undo snapshot). Used for paste.

Source

pub fn open_line_below(&mut self)

Insert a new line below current and move cursor there (vim o).

Source

pub fn open_line_above(&mut self)

Insert a new line above current and move cursor there (vim O).

Source

pub fn move_to_first_non_blank(&mut self)

Move cursor to first non-whitespace character on current line (vim ^).

Source

pub fn move_to_first_line(&mut self)

Move cursor to start of first line (vim gg).

Source

pub fn move_to_last_line(&mut self)

Move cursor to start of last line (vim G).

Source

pub fn move_word_forward_end(&mut self)

Move cursor forward to end of current/next word (vim e).

Source

pub fn update_scroll(&mut self, visible_width: usize)

Update horizontal scroll for the current line.

Source

pub fn update_vertical_scroll(&mut self, visible_height: usize)

Update vertical scroll to keep cursor visible within visible_height lines.

Source

pub fn set_cursor_by_col(&mut self, col: usize)

Set cursor by display column (single-line editors / mouse click).

Source

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§

Source§

impl Clone for Editor

Source§

fn clone(&self) -> Editor

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Editor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Editor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.