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.