pub struct Editor { /* private fields */ }Expand description
A single-line text buffer with a cursor. Multi-line editing is not needed for any current form field (transaction notes are one-line memos today) but could grow in-place later.
Implementations§
Source§impl Editor
impl Editor
pub fn new(mode: EditMode) -> Self
pub fn with_buffer(mode: EditMode, buffer: impl Into<String>) -> Self
pub fn buffer(&self) -> &str
pub fn cursor(&self) -> usize
pub fn mode(&self) -> EditMode
pub fn vim_mode(&self) -> VimMode
pub fn set_mode(&mut self, mode: EditMode)
Sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert a single character at the cursor. In vim mode, insertion
only happens in Insert sub-mode; in emacs mode always.
pub fn delete_backward(&mut self)
pub fn delete_forward(&mut self)
pub fn move_left(&mut self)
pub fn move_right(&mut self)
pub fn move_home(&mut self)
pub fn move_end(&mut self)
Sourcepub fn kill_to_end(&mut self)
pub fn kill_to_end(&mut self)
Delete from the cursor to end-of-line (emacs C-k).
Sourcepub fn kill_word_backward(&mut self)
pub fn kill_word_backward(&mut self)
Delete the word before the cursor (emacs C-w).
pub fn enter_insert_mode(&mut self)
pub fn enter_normal_mode(&mut self)
Sourcepub fn vim_action(&mut self, action: VimAction)
pub fn vim_action(&mut self, action: VimAction)
Execute a vim normal-mode motion or edit by name. Keeping this symbolic rather than key-driven means the event layer can translate key events into these names, and the pure engine is trivial to unit-test.
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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 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>
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