pub struct EditRope { /* private fields */ }
Expand description
A rope with context-aware movements and high-level operations.
Implementations§
source§impl EditRope
impl EditRope
sourcepub fn write_to<T: Write>(&self, writer: T) -> Result<(), Error>
pub fn write_to<T: Write>(&self, writer: T) -> Result<(), Error>
Write the contents of the EditRope to a writer.
sourcepub fn split(
&self,
CharOff: CharOff,
CharOff: CharOff,
inclusive: bool
) -> (EditRope, EditRope, EditRope)
pub fn split( &self, CharOff: CharOff, CharOff: CharOff, inclusive: bool ) -> (EditRope, EditRope, EditRope)
Split the rope into three different parts.
sourcepub fn trim_start(&self) -> EditRope
pub fn trim_start(&self) -> EditRope
Remove leading whitespace from the rope.
sourcepub fn trim_start_matches<F>(&self, matches: F) -> EditRope
pub fn trim_start_matches<F>(&self, matches: F) -> EditRope
Remove matching leading characters from the rope.
sourcepub fn trim_end_matches<F>(&self, matches: F) -> EditRope
pub fn trim_end_matches<F>(&self, matches: F) -> EditRope
Remove matching trailing characters from the rope.
sourcepub fn slice<R: RangeBounds<CharOff>>(&self, range: R) -> EditRope
pub fn slice<R: RangeBounds<CharOff>>(&self, range: R) -> EditRope
Returns a slice of a range within the rope.
sourcepub fn replace<R: RangeBounds<CharOff>>(
&mut self,
range: R,
substitution: EditRope
) -> (CursorChoice, Vec<CursorAdjustment>)
pub fn replace<R: RangeBounds<CharOff>>( &mut self, range: R, substitution: EditRope ) -> (CursorChoice, Vec<CursorAdjustment>)
Replace a range within the rope with some new text.
sourcepub fn repeat(&self, shape: TargetShape, times: usize) -> EditRope
pub fn repeat(&self, shape: TargetShape, times: usize) -> EditRope
Return the rope repeated n times.
sourcepub fn transform(
&self,
start: CharOff,
end: CharOff,
inclusive: bool,
f: impl Fn(EditRope) -> EditRope
) -> EditRope
pub fn transform( &self, start: CharOff, end: CharOff, inclusive: bool, f: impl Fn(EditRope) -> EditRope ) -> EditRope
Transform a range within the rope with function f, and return the updated version.
sourcepub fn changecase(&self, case: &Case) -> EditRope
pub fn changecase(&self, case: &Case) -> EditRope
Change the case of this rope.
sourcepub fn insert(
&mut self,
cursor: &Cursor,
dir: MoveDir1D,
text: EditRope,
style: InsertStyle
) -> (CursorChoice, Vec<CursorAdjustment>)
pub fn insert( &mut self, cursor: &Cursor, dir: MoveDir1D, text: EditRope, style: InsertStyle ) -> (CursorChoice, Vec<CursorAdjustment>)
Insert or replace text before or after a given cursor position.
sourcepub fn paste(
&mut self,
cursor: &Cursor,
dir: MoveDir1D,
text: EditRope,
shape: TargetShape
) -> (CursorChoice, Vec<CursorAdjustment>)
pub fn paste( &mut self, cursor: &Cursor, dir: MoveDir1D, text: EditRope, shape: TargetShape ) -> (CursorChoice, Vec<CursorAdjustment>)
Paste text at a given cursor position.
sourcepub fn trailing_newline(&mut self)
pub fn trailing_newline(&mut self)
Mutably force this rope to contain a trailing newline if it doesn’t already.
sourcepub fn get_char_at_cursor(&self, cursor: &Cursor) -> Option<char>
pub fn get_char_at_cursor(&self, cursor: &Cursor) -> Option<char>
Returns the character (if it exists) at a given cursor position.
sourcepub fn is_blank_line(&self, line: usize) -> bool
pub fn is_blank_line(&self, line: usize) -> bool
Returns true if a line contains only whitespace characters.
sourcepub fn is_blank_range(&self, start: CharOff, end: CharOff) -> bool
pub fn is_blank_range(&self, start: CharOff, end: CharOff) -> bool
Returns true if the inclusive range of bytes contains only whitespace characters.
sourcepub fn len_offset(&self) -> CharOff
pub fn len_offset(&self) -> CharOff
Return the length in number of characters as a CharOff.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Indicates whether or not this rope is empty (contains no characters).
sourcepub fn line_after(&self, line: usize) -> Option<CharOff>
pub fn line_after(&self, line: usize) -> Option<CharOff>
Get the character offset of the start of the following line.
sourcepub fn get_columns(&self, line: usize) -> usize
pub fn get_columns(&self, line: usize) -> usize
Return the number of columns on the given line.
sourcepub fn line_of_offset(&self, off: CharOff) -> usize
pub fn line_of_offset(&self, off: CharOff) -> usize
Return the line number of the given character offset.
sourcepub fn offset_of_line(&self, line: usize) -> CharOff
pub fn offset_of_line(&self, line: usize) -> CharOff
Return the character offset of the start of a given line.
sourcepub fn offset_to_cursor(&self, off: CharOff) -> Cursor
pub fn offset_to_cursor(&self, off: CharOff) -> Cursor
Convert a character offset to a Cursor.
sourcepub fn cursor_to_offset(&self, cursor: &Cursor) -> CharOff
pub fn cursor_to_offset(&self, cursor: &Cursor) -> CharOff
Convert a cursor to a character offset.
sourcepub fn last_offset(&self) -> CharOff
pub fn last_offset(&self) -> CharOff
Return the last character offset in the rope.
sourcepub fn diff(&self, other: &EditRope) -> Vec<CursorAdjustment>
pub fn diff(&self, other: &EditRope) -> Vec<CursorAdjustment>
Compare this rope with a new version, and return a vector of adjustments needed to fix cursors and marks when moving to the new version.
sourcepub fn newlines(&self, offset: CharOff) -> NewlineIterator<'_> ⓘ
pub fn newlines(&self, offset: CharOff) -> NewlineIterator<'_> ⓘ
Returns an iterator over the newlines within this rope following offset
.
sourcepub fn chars(&self, pos: CharOff) -> CharacterIterator<'_> ⓘ
pub fn chars(&self, pos: CharOff) -> CharacterIterator<'_> ⓘ
Returns an iterator over the characters within this rope following position
.
sourcepub fn chars_until(&self, pos: CharOff, end: CharOff) -> CharacterIterator<'_> ⓘ
pub fn chars_until(&self, pos: CharOff, end: CharOff) -> CharacterIterator<'_> ⓘ
Returns an iterator over the characters within this rope following position
.
sourcepub fn get_prefix_word_mut(
&self,
cursor: &mut Cursor,
style: &WordStyle
) -> Option<Self>
pub fn get_prefix_word_mut( &self, cursor: &mut Cursor, style: &WordStyle ) -> Option<Self>
Get the text before the cursor, and update the cursor to point to its start.
sourcepub fn get_prefix_word(
&self,
cursor: &Cursor,
style: &WordStyle
) -> Option<Self>
pub fn get_prefix_word( &self, cursor: &Cursor, style: &WordStyle ) -> Option<Self>
Get the text before the cursor.
sourcepub fn get_cursor_word_mut(
&self,
cursor: &mut Cursor,
style: &WordStyle
) -> Option<Self>
pub fn get_cursor_word_mut( &self, cursor: &mut Cursor, style: &WordStyle ) -> Option<Self>
Trait Implementations§
source§impl AddAssign for EditRope
impl AddAssign for EditRope
source§fn add_assign(&mut self, rhs: EditRope)
fn add_assign(&mut self, rhs: EditRope)
+=
operation. Read moresource§impl CursorMovements<Cursor> for EditRope
impl CursorMovements<Cursor> for EditRope
source§fn range_of_movement(
&self,
cursor: &Cursor,
movement: &MoveType,
count: &Count,
ctx: &CursorMovementsContext<'_, Cursor>
) -> Option<EditRange<Cursor>>
fn range_of_movement( &self, cursor: &Cursor, movement: &MoveType, count: &Count, ctx: &CursorMovementsContext<'_, Cursor> ) -> Option<EditRange<Cursor>>
Given an action’s movement, calculate the affected range base on the cursor’s current position.
source§fn first_word(
&self,
cursor: &Cursor,
_: &CursorMovementsContext<'_, Cursor>
) -> Cursor
fn first_word( &self, cursor: &Cursor, _: &CursorMovementsContext<'_, Cursor> ) -> Cursor
source§impl CursorSearch<Cursor> for EditRope
impl CursorSearch<Cursor> for EditRope
source§fn find_char(
&self,
cursor: &Cursor,
inclusive: bool,
dir: MoveDir1D,
multiline: bool,
needle: char,
count: usize
) -> Option<Cursor>
fn find_char( &self, cursor: &Cursor, inclusive: bool, dir: MoveDir1D, multiline: bool, needle: char, count: usize ) -> Option<Cursor>
source§impl From<EditRope> for RegisterCell
impl From<EditRope> for RegisterCell
source§fn from(s: EditRope) -> RegisterCell
fn from(s: EditRope) -> RegisterCell
source§impl PartialEq<&str> for EditRope
impl PartialEq<&str> for EditRope
source§impl PartialEq for EditRope
impl PartialEq for EditRope
impl Eq for EditRope
Auto Trait Implementations§
impl Freeze for EditRope
impl RefUnwindSafe for EditRope
impl Send for EditRope
impl Sync for EditRope
impl Unpin for EditRope
impl UnwindSafe for EditRope
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> 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> DowncastSync for T
impl<T> DowncastSync for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.