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.
Trait Implementations§
source§impl<'a, I> Editable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
impl<'a, I> Editable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
source§fn editor_command(
&mut self,
act: &EditorAction,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn editor_command( &mut self, act: &EditorAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§impl<'a, I> EditorActions<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
impl<'a, I> EditorActions<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
source§fn edit(
&mut self,
action: &EditAction,
target: &EditTarget,
ictx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn edit( &mut self, action: &EditAction, target: &EditTarget, ictx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn mark(
&mut self,
name: Mark,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn mark( &mut self, name: Mark, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn complete(
&mut self,
comptype: &CompletionType,
selection: &CompletionSelection,
display: &CompletionDisplay,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn complete( &mut self, comptype: &CompletionType, selection: &CompletionSelection, display: &CompletionDisplay, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn insert_text(
&mut self,
act: &InsertTextAction,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn insert_text( &mut self, act: &InsertTextAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn selection_command(
&mut self,
act: &SelectionAction,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn selection_command( &mut self, act: &SelectionAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn cursor_command(
&mut self,
act: &CursorAction,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn cursor_command( &mut self, act: &CursorAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§fn history_command(
&mut self,
act: &HistoryAction,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> EditResult<EditInfo, I>
fn history_command( &mut self, act: &HistoryAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>
source§impl<'a, I> Jumpable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), I> for EditBuffer<I>where
I: ApplicationInfo,
impl<'a, I> Jumpable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), I> for EditBuffer<I>where
I: ApplicationInfo,
source§fn jump(
&mut self,
list: PositionList,
dir: MoveDir1D,
count: usize,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext)
) -> UIResult<usize, I>
fn jump( &mut self, list: PositionList, dir: MoveDir1D, count: usize, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext) ) -> UIResult<usize, I>
source§impl<'a, I> Searchable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
impl<'a, I> Searchable<(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), Store<I>, I> for EditBuffer<I>where
I: ApplicationInfo,
source§fn search(
&mut self,
dir: MoveDirMod,
count: Count,
ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext),
store: &mut Store<I>
) -> UIResult<EditInfo, I>
fn search( &mut self, dir: MoveDirMod, count: Count, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> UIResult<EditInfo, I>
Auto Trait Implementations§
impl<I> Freeze for EditBuffer<I>
impl<I> !RefUnwindSafe for EditBuffer<I>
impl<I> Send for EditBuffer<I>where
I: Send,
impl<I> Sync for EditBuffer<I>
impl<I> Unpin for EditBuffer<I>
impl<I> !UnwindSafe for EditBuffer<I>
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.