pub struct EditorState {
pub content: String,
pub cursor: usize,
pub cursor_line: usize,
pub cursor_col: usize,
pub history: Vec<String>,
pub history_idx: Option<usize>,
pub scroll_offset: usize,
/* private fields */
}Expand description
Multi-line editor state with cursor management.
Fields§
§content: String§cursor: usize§cursor_line: usize§cursor_col: usize§history: Vec<String>§history_idx: Option<usize>§scroll_offset: usizeImplementations§
Source§impl EditorState
impl EditorState
pub fn new() -> Self
pub fn insert_char(&mut self, c: char)
pub fn insert_newline(&mut self)
pub fn insert_paste(&mut self, text: &str)
pub fn delete_back(&mut self)
pub fn delete_forward(&mut self)
pub fn move_left(&mut self)
pub fn move_right(&mut self)
pub fn move_up(&mut self) -> bool
pub fn move_down(&mut self) -> bool
pub fn move_home(&mut self)
pub fn move_end(&mut self)
pub fn move_word_left(&mut self)
pub fn move_word_right(&mut self)
pub fn delete_word_back(&mut self)
pub fn delete_to_start(&mut self)
pub fn delete_to_end(&mut self)
pub fn clear(&mut self)
pub fn set_content(&mut self, text: &str)
pub fn content(&self) -> &str
pub fn is_empty(&self) -> bool
pub fn line_count(&self) -> usize
pub fn visual_line_count_with_summary( &self, inner_width: u16, summarize_paste: bool, ) -> usize
pub fn visual_line_count(&self, inner_width: u16) -> usize
pub fn push_history(&mut self)
pub fn history_prev(&mut self)
pub fn history_next(&mut self)
Sourcepub fn cursor_screen_position(&self, area: Rect) -> (u16, u16)
pub fn cursor_screen_position(&self, area: Rect) -> (u16, u16)
Calculate cursor position relative to a render area, accounting for soft wraps.
Trait Implementations§
Source§impl Clone for EditorState
impl Clone for EditorState
Source§fn clone(&self) -> EditorState
fn clone(&self) -> EditorState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EditorState
impl Debug for EditorState
Auto Trait Implementations§
impl Freeze for EditorState
impl RefUnwindSafe for EditorState
impl Send for EditorState
impl Sync for EditorState
impl Unpin for EditorState
impl UnsafeUnpin for EditorState
impl UnwindSafe for EditorState
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,
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>
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