pub struct Editor { /* private fields */ }Expand description
Unicode grapheme-safe bounded multiline editor state.
Implementations§
Source§impl Editor
impl Editor
Sourcepub fn with_limit(
text: impl Into<String>,
max_bytes: usize,
) -> Result<Self, EditorError>
pub fn with_limit( text: impl Into<String>, max_bytes: usize, ) -> Result<Self, EditorError>
Creates an editor with an explicit byte bound.
§Errors
Rejects a zero limit or initial text larger than the limit.
Sourcepub const fn cursor_byte(&self) -> usize
pub const fn cursor_byte(&self) -> usize
Returns the cursor UTF-8 byte offset.
Sourcepub fn cursor_display_column(&self) -> usize
pub fn cursor_display_column(&self) -> usize
Returns the display-cell cursor column within the current logical line.
Sourcepub fn insert_char(&mut self, character: char) -> Result<(), EditorError>
pub fn insert_char(&mut self, character: char) -> Result<(), EditorError>
Sourcepub fn insert_paste(&mut self, text: &str) -> Result<(), EditorError>
pub fn insert_paste(&mut self, text: &str) -> Result<(), EditorError>
Inserts one bounded paste atomically at the cursor.
§Errors
Rejects the entire paste without mutation when it would exceed the bound.
Sourcepub fn insert_newline(&mut self) -> Result<(), EditorError>
pub fn insert_newline(&mut self) -> Result<(), EditorError>
Sourcepub fn move_right(&mut self)
pub fn move_right(&mut self)
Moves right by one extended grapheme cluster.
Sourcepub fn move_word_left(&mut self)
pub fn move_word_left(&mut self)
Moves to the beginning of the preceding Unicode word.
Sourcepub fn move_word_right(&mut self)
pub fn move_word_right(&mut self)
Moves to the end of the following Unicode word.
Sourcepub fn move_home_or_previous_line(&mut self)
pub fn move_home_or_previous_line(&mut self)
Moves to the current line start, or the preceding line start when already there.
Sourcepub fn move_end_or_next_line(&mut self)
pub fn move_end_or_next_line(&mut self)
Moves to the current line end, or the following line end when already there.
Sourcepub fn move_up(&mut self)
pub fn move_up(&mut self)
Moves one logical line upward while preserving display column when possible.
Sourcepub fn move_down(&mut self)
pub fn move_down(&mut self)
Moves one logical line downward while preserving display column when possible.
Sourcepub fn delete_backward(&mut self) -> bool
pub fn delete_backward(&mut self) -> bool
Deletes one extended grapheme cluster before the cursor.
Sourcepub fn delete_forward(&mut self) -> bool
pub fn delete_forward(&mut self) -> bool
Deletes one extended grapheme cluster after the cursor.
Sourcepub fn delete_word_backward(&mut self) -> bool
pub fn delete_word_backward(&mut self) -> bool
Deletes the preceding Unicode word and intervening whitespace.
Sourcepub fn delete_word_forward(&mut self) -> bool
pub fn delete_word_forward(&mut self) -> bool
Deletes the following Unicode word and leading separators.
Sourcepub fn kill_to_line_start(&mut self) -> bool
pub fn kill_to_line_start(&mut self) -> bool
Deletes from the cursor to the logical line start and stores it for yanking.
Sourcepub fn kill_to_line_end(&mut self) -> bool
pub fn kill_to_line_end(&mut self) -> bool
Deletes from the cursor to the logical line end and stores it for yanking.
Sourcepub fn has_kill_buffer(&self) -> bool
pub fn has_kill_buffer(&self) -> bool
Returns whether a previous word or line kill can be yanked.
Sourcepub fn yank(&mut self) -> Result<bool, EditorError>
pub fn yank(&mut self) -> Result<bool, EditorError>
Inserts the most recently killed text at the cursor.
§Errors
Rejects insertion when it would exceed the configured byte bound.
Sourcepub fn submit(&mut self) -> Option<String>
pub fn submit(&mut self) -> Option<String>
Submits non-whitespace contents, records history, and clears the editor.
Sourcepub fn previous_history(&mut self) -> bool
pub fn previous_history(&mut self) -> bool
Replaces the current draft with the previous submitted history item.
Sourcepub fn next_history(&mut self) -> bool
pub fn next_history(&mut self) -> bool
Moves toward the current draft in submitted history navigation.
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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