Struct modalkit::editing::buffer::EditBuffer
source · pub struct EditBuffer<I: ApplicationInfo> { /* private fields */ }
Expand description
A text buffer.
Implementations§
source§impl<I> EditBuffer<I>where
I: ApplicationInfo,
impl<I> EditBuffer<I>where
I: ApplicationInfo,
sourcepub fn from_rope(id: I::ContentId, text: EditRope) -> Self
pub fn from_rope(id: I::ContentId, text: EditRope) -> Self
Create a new buffer given its initial contents as an EditRope.
sourcepub fn from_str(id: I::ContentId, text: &str) -> Self
pub fn from_str(id: I::ContentId, text: &str) -> Self
Create a new buffer given its initial contents.
sourcepub fn set_text<T: Into<EditRope>>(&mut self, t: T)
pub fn set_text<T: Into<EditRope>>(&mut self, t: T)
Replace the contents of this buffer with t
.
This also resets buffer-associated state, like marks and history.
sourcepub fn append_text<T: Into<EditRope>>(&mut self, t: T) -> Range<usize>
pub fn append_text<T: Into<EditRope>>(&mut self, t: T) -> Range<usize>
Append text to this buffer.
sourcepub fn reset(&mut self) -> EditRope
pub fn reset(&mut self) -> EditRope
Clear the buffer of its current content, and return it.
This also resets buffer-associated state, like marks and history.
sourcepub fn reset_text(&mut self) -> String
pub fn reset_text(&mut self) -> String
Clear the buffer of its current content, and return it as a String.
This also resets buffer-associated state, like marks and history.
sourcepub fn get_completions(&self, gid: CursorGroupId) -> Option<CompletionList>
pub fn get_completions(&self, gid: CursorGroupId) -> Option<CompletionList>
Get completion candidates for the give cursor group to show the user.
sourcepub fn get_cursor_word(
&self,
gid: CursorGroupId,
style: &WordStyle,
) -> Option<String>
pub fn get_cursor_word( &self, gid: CursorGroupId, style: &WordStyle, ) -> Option<String>
Returns the text currently that the cursor group’s leader is currently positioned over.
sourcepub fn get_selected_word(&self, gid: CursorGroupId) -> Option<String>
pub fn get_selected_word(&self, gid: CursorGroupId) -> Option<String>
Returns the text currently selected by the cursor group’s leader.
sourcepub fn set_group(&mut self, gid: CursorGroupId, group: CursorGroup)
pub fn set_group(&mut self, gid: CursorGroupId, group: CursorGroup)
Set the leader and member of a cursor group.
sourcepub fn set_leader(&mut self, id: CursorGroupId, cursor: Cursor)
pub fn set_leader(&mut self, id: CursorGroupId, cursor: Cursor)
Move the Cursor for the leader of a cursor group.
sourcepub fn get_leader(&mut self, id: CursorGroupId) -> Cursor
pub fn get_leader(&mut self, id: CursorGroupId) -> Cursor
Get the Cursor for the leader of a cursor group.
sourcepub fn get_followers(&self, id: CursorGroupId) -> Vec<Cursor>
pub fn get_followers(&self, id: CursorGroupId) -> Vec<Cursor>
Get the cursors of the followers within a cursor group.
sourcepub fn get_follower_selections(&self, id: CursorGroupId) -> Option<Selections>
pub fn get_follower_selections(&self, id: CursorGroupId) -> Option<Selections>
Get the Selections for the followers within a cursor group.
sourcepub fn get_leader_selection(&mut self, id: CursorGroupId) -> Option<Selection>
pub fn get_leader_selection(&mut self, id: CursorGroupId) -> Option<Selection>
Get the Selection for the leader of a cursor group.
sourcepub fn get_group_selections(&self, id: CursorGroupId) -> Option<Selections>
pub fn get_group_selections(&self, id: CursorGroupId) -> Option<Selections>
Get the Selections for everyone within a cursor group.
sourcepub fn create_group(&mut self) -> CursorGroupId
pub fn create_group(&mut self) -> CursorGroupId
Create a new cursor group.
sourcepub fn lines(&self, line: usize) -> LineIterator<'_> ⓘ
pub fn lines(&self, line: usize) -> LineIterator<'_> ⓘ
Iterate over the lines in the buffer starting at line
.
sourcepub fn lines_at(&self, line: usize, column: usize) -> LineIterator<'_> ⓘ
pub fn lines_at(&self, line: usize, column: usize) -> LineIterator<'_> ⓘ
Iterate over the lines in the buffer starting at column
within line
.
sourcepub fn get_columns(&self, y: usize) -> usize
pub fn get_columns(&self, y: usize) -> usize
Returns how many columns are on a given line.
sourcepub fn get_line_info<T: Send + Sync + 'static>(&self, line: usize) -> Option<&T>
pub fn get_line_info<T: Send + Sync + 'static>(&self, line: usize) -> Option<&T>
Fetch a reference to the information of type T
on a given line.
sourcepub fn get_line_info_mut<T: Send + Sync + 'static>(
&mut self,
line: usize,
) -> Option<&mut T>
pub fn get_line_info_mut<T: Send + Sync + 'static>( &mut self, line: usize, ) -> Option<&mut T>
Fetch a mutable reference to the information of type T
on a given line.
sourcepub fn set_line_info<T: Send + Sync + 'static>(&mut self, line: usize, info: T)
pub fn set_line_info<T: Send + Sync + 'static>(&mut self, line: usize, info: T)
Update the information of type T
on a given line.
sourcepub fn clamp_state(
&self,
state: &mut CursorState,
ctx: &(CursorGroupId, &'_ ViewportContext<Cursor>, &'_ EditContext),
)
pub fn clamp_state( &self, state: &mut CursorState, ctx: &(CursorGroupId, &'_ ViewportContext<Cursor>, &'_ EditContext), )
Clamp the line and column of the cursors in a CursorState so that they refer to a valid point within the buffer.
sourcepub fn clamp(
&self,
cursor: &mut Cursor,
ctx: &(CursorGroupId, &'_ ViewportContext<Cursor>, &'_ EditContext),
)
pub fn clamp( &self, cursor: &mut Cursor, ctx: &(CursorGroupId, &'_ ViewportContext<Cursor>, &'_ EditContext), )
Clamp the line and column of a cursor so that it refers to a valid point within the buffer.
sourcepub fn selection_intervals(&self, gid: CursorGroupId) -> HighlightInfo
pub fn selection_intervals(&self, gid: CursorGroupId) -> HighlightInfo
Returns an IntervalTree containing the selections for a cursor group.
sourcepub fn follower_intervals(&self, gid: CursorGroupId) -> FollowersInfo
pub fn follower_intervals(&self, gid: CursorGroupId) -> FollowersInfo
Returns an IntervalTree containing the followers of a cursor group.