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,

source

pub fn from_rope(id: I::ContentId, text: EditRope) -> Self

Create a new buffer given its initial contents as an EditRope.

source

pub fn from_str(id: I::ContentId, text: &str) -> Self

Create a new buffer given its initial contents.

source

pub fn new(id: I::ContentId) -> Self

Create a new empty buffer.

source

pub fn id(&self) -> I::ContentId

Get this buffer’s content identifier.

source

pub fn is_blank(&self) -> bool

Indicates whether this buffer contains only whitespace.

source

pub fn get(&self) -> &EditRope

Return a reference to the contents of this buffer.

source

pub fn get_text(&self) -> String

Return the contents of this buffer as a String.

source

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.

source

pub fn append_text<T: Into<EditRope>>(&mut self, t: T) -> Range<usize>

Append text to this buffer.

source

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.

source

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.

source

pub fn get_completions(&self, gid: CursorGroupId) -> Option<CompletionList>

Get completion candidates for the give cursor group to show the user.

source

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.

source

pub fn get_selected_word(&self, gid: CursorGroupId) -> Option<String>

Returns the text currently selected by the cursor group’s leader.

source

pub fn set_group(&mut self, gid: CursorGroupId, group: CursorGroup)

Set the leader and member of a cursor group.

source

pub fn set_leader(&mut self, id: CursorGroupId, cursor: Cursor)

Move the Cursor for the leader of a cursor group.

source

pub fn get_leader(&mut self, id: CursorGroupId) -> Cursor

Get the Cursor for the leader of a cursor group.

source

pub fn get_followers(&self, id: CursorGroupId) -> Vec<Cursor>

Get the cursors of the followers within a cursor group.

source

pub fn get_follower_selections(&self, id: CursorGroupId) -> Option<Selections>

Get the Selections for the followers within a cursor group.

source

pub fn get_leader_selection(&mut self, id: CursorGroupId) -> Option<Selection>

Get the Selection for the leader of a cursor group.

source

pub fn get_group_selections(&self, id: CursorGroupId) -> Option<Selections>

Get the Selections for everyone within a cursor group.

source

pub fn create_group(&mut self) -> CursorGroupId

Create a new cursor group.

source

pub fn lines(&self, line: usize) -> LineIterator<'_>

Iterate over the lines in the buffer starting at line.

source

pub fn lines_at(&self, line: usize, column: usize) -> LineIterator<'_>

Iterate over the lines in the buffer starting at column within line.

source

pub fn get_lines(&self) -> usize

Returns how many lines are within this buffer.

source

pub fn get_columns(&self, y: usize) -> usize

Returns how many columns are on a given line.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn selection_intervals(&self, gid: CursorGroupId) -> HighlightInfo

Returns an IntervalTree containing the selections for a cursor group.

source

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,

source§

fn editor_command( &mut self, act: &EditorAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Execute an editor action.
source§

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>

Perform an editing operation over the targeted text.
source§

fn mark( &mut self, name: Mark, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Create or update a cursor mark based on the leader’s cursor position.
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>

Complete the text before the cursor group leader.
source§

fn insert_text( &mut self, act: &InsertTextAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Insert text relative to the current cursor position.
source§

fn selection_command( &mut self, act: &SelectionAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Modify the current selection.
source§

fn cursor_command( &mut self, act: &CursorAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Perform an action over a cursor group.
source§

fn history_command( &mut self, act: &HistoryAction, ctx: &(CursorGroupId, &'a ViewportContext<Cursor>, &'a EditContext), store: &mut Store<I> ) -> EditResult<EditInfo, I>

Move to a different point in the buffer’s editing history.
source§

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>

Move through a PositionList in MoveDir1D direction count times. Read more
source§

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>

Search for the nth result in MoveDirMod direction.

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>
where <I as ApplicationInfo>::ContentId: Sync, I: Sync,

§

impl<I> Unpin for EditBuffer<I>
where <I as ApplicationInfo>::ContentId: Unpin, I: Unpin,

§

impl<I> !UnwindSafe for EditBuffer<I>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Any for T
where T: Any,