pub struct EditBuffer { /* private fields */ }Expand description
Shared Pi-style flat text editing model used by the widget and chat editors.
Implementations§
Source§impl EditBuffer
impl EditBuffer
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Returns the number of logical newline-delimited lines.
Sourcepub fn cursor_line(&self) -> usize
pub fn cursor_line(&self) -> usize
Returns the zero-based logical cursor line.
Sourcepub fn cursor_column(&self) -> u16
pub fn cursor_column(&self) -> u16
Returns the cursor’s cell column within its logical line.
Sourcepub fn logical_lines(
&self,
) -> impl DoubleEndedIterator<Item = &str> + Clone + FusedIterator + '_
pub fn logical_lines( &self, ) -> impl DoubleEndedIterator<Item = &str> + Clone + FusedIterator + '_
Iterates logical lines without allocating.
Sourcepub fn replace_external(&mut self, text: &str, cursor_at_start: bool)
pub fn replace_external(&mut self, text: &str, cursor_at_start: bool)
Replaces text without creating an undo entry, for history browsing.
Sourcepub fn set_cursor_line_column(&mut self, line: usize, column: u16)
pub fn set_cursor_line_column(&mut self, line: usize, column: u16)
Places the cursor on a logical line and cell column.
Sourcepub fn set_cursor_visual_row(
&mut self,
row: usize,
column: u16,
width_limit: u16,
)
pub fn set_cursor_visual_row( &mut self, row: usize, column: u16, width_limit: u16, )
Places the cursor on a visual row and cell column.
Sourcepub fn replace_range(&mut self, range: Range<usize>, replacement: &str)
pub fn replace_range(&mut self, range: Range<usize>, replacement: &str)
Replaces a byte range as one undoable edit. A non-empty range that touches an atomic marker widens to the whole marker, so partial replacements can never tear a unit apart.
Sourcepub fn insert_text(&mut self, text: &str) -> BufferOutcome
pub fn insert_text(&mut self, text: &str) -> BufferOutcome
Inserts sanitized text at the cursor.
Text is inserted verbatim; hosts that collapse large pastes into
compact chips stage them through EditBuffer::insert_reference.
Sourcepub fn expanded_text(&self) -> String
pub fn expanded_text(&self) -> String
Returns text with every atomic reference expanded to its payload.
Sourcepub fn insert_reference(&mut self, marker: &str, payload: &str) -> BufferOutcome
pub fn insert_reference(&mut self, marker: &str, payload: &str) -> BufferOutcome
Inserts an atomic reference at the cursor: marker is displayed,
navigated, and deleted as one unit, and expands to payload in the
submitted text. marker must be a single line.
The unit is tracked by position, not by content: typed text that
happens to equal marker stays ordinary text.
Sourcepub fn atom_ranges(&self) -> SmallVec<(usize, usize), 4>
pub fn atom_ranges(&self) -> SmallVec<(usize, usize), 4>
Byte ranges of atomic markers present in the text, ascending. Slice
EditBuffer::text with a range to recover the marker.
Sourcepub fn clear_after_submit(&mut self) -> String
pub fn clear_after_submit(&mut self) -> String
Returns expanded text and resets the buffer after submission.
Sourcepub fn handle(
&mut self,
key: Key,
width: u16,
page_rows: usize,
) -> BufferOutcome
pub fn handle( &mut self, key: Key, width: u16, page_rows: usize, ) -> BufferOutcome
Applies a decoded editor key at the given layout width.
Sourcepub fn rows(
&self,
width_limit: u16,
max_rows: usize,
) -> SmallVec<VisualRow<'_>, 8>
pub fn rows( &self, width_limit: u16, max_rows: usize, ) -> SmallVec<VisualRow<'_>, 8>
Returns the visible visual rows.
Keyboard editing keeps the cursor in view. A manual viewport scroll remains detached until the next editing command.
Sourcepub fn scroll_rows(&self, delta: i32, width_limit: u16, max_rows: usize) -> bool
pub fn scroll_rows(&self, delta: i32, width_limit: u16, max_rows: usize) -> bool
Moves the visible row window without moving the cursor.
Returns whether the clamped viewport offset changed.
Sourcepub fn visual_height(&self, width: u16, max_rows: usize) -> usize
pub fn visual_height(&self, width: u16, max_rows: usize) -> usize
Returns the clipped visual row count.
Sourcepub fn at_visual_start(&self) -> bool
pub fn at_visual_start(&self) -> bool
Reports whether the cursor is at the document’s visual start.
Sourcepub fn at_visual_end(&self) -> bool
pub fn at_visual_end(&self) -> bool
Reports whether the cursor is at the document’s visual end.
Trait Implementations§
Source§impl Clone for EditBuffer
impl Clone for EditBuffer
Source§fn clone(&self) -> EditBuffer
fn clone(&self) -> EditBuffer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EditBuffer
impl Debug for EditBuffer
Auto Trait Implementations§
impl !Freeze for EditBuffer
impl !RefUnwindSafe for EditBuffer
impl !Sync for EditBuffer
impl Send for EditBuffer
impl Unpin for EditBuffer
impl UnsafeUnpin for EditBuffer
impl UnwindSafe for EditBuffer
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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