Struct Editor
pub struct Editor<'buffer> { /* private fields */ }Expand description
A wrapper of [Buffer] for easy editing
Implementations§
§impl<'buffer> Editor<'buffer>
impl<'buffer> Editor<'buffer>
pub fn new(buffer: impl Into<BufferRef<'buffer>>) -> Editor<'buffer>
pub fn new(buffer: impl Into<BufferRef<'buffer>>) -> Editor<'buffer>
Create a new Editor with the provided [Buffer]
pub fn draw<F>(
&mut self,
font_system: &mut FontSystem,
cache: &mut SwashCache,
text_color: Color,
cursor_color: Color,
selection_color: Color,
selected_text_color: Color,
callback: F,
)
pub fn draw<F>( &mut self, font_system: &mut FontSystem, cache: &mut SwashCache, text_color: Color, cursor_color: Color, selection_color: Color, selected_text_color: Color, callback: F, )
Draw the editor
Automatically resolves any pending dirty state before drawing.
Trait Implementations§
§impl<'buffer> Edit<'buffer> for Editor<'buffer>
impl<'buffer> Edit<'buffer> for Editor<'buffer>
§fn buffer_ref(&self) -> &BufferRef<'buffer>
fn buffer_ref(&self) -> &BufferRef<'buffer>
Get the internal
BufferRef§fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
Get the internal
BufferRef§fn set_cursor(&mut self, cursor: Cursor)
fn set_cursor(&mut self, cursor: Cursor)
Set the current cursor
§fn set_selection(&mut self, selection: Selection)
fn set_selection(&mut self, selection: Selection)
Set the current selection position
§fn auto_indent(&self) -> bool
fn auto_indent(&self) -> bool
Get the current automatic indentation setting
§fn set_auto_indent(&mut self, auto_indent: bool)
fn set_auto_indent(&mut self, auto_indent: bool)
Enable or disable automatic indentation
§fn set_tab_width(&mut self, tab_width: u16)
fn set_tab_width(&mut self, tab_width: u16)
Set the current tab width. A
tab_width of 0 is not allowed, and will be ignored§fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
Shape lines until scroll, after adjusting scroll if the cursor moved
§fn delete_range(&mut self, start: Cursor, end: Cursor)
fn delete_range(&mut self, start: Cursor, end: Cursor)
Delete text starting at start Cursor and ending at end Cursor
§fn insert_at(
&mut self,
cursor: Cursor,
data: &str,
attrs_list: Option<AttrsList>,
) -> Cursor
fn insert_at( &mut self, cursor: Cursor, data: &str, attrs_list: Option<AttrsList>, ) -> Cursor
Insert text at specified cursor with specified
attrs_list§fn copy_selection(&self) -> Option<String>
fn copy_selection(&self) -> Option<String>
Copy selection
§fn delete_selection(&mut self) -> bool
fn delete_selection(&mut self) -> bool
Delete selection, adjusting cursor and returning true if there was a selection
§fn apply_change(&mut self, change: &Change) -> bool
fn apply_change(&mut self, change: &Change) -> bool
Apply a change
§fn start_change(&mut self)
fn start_change(&mut self)
Start collecting change
§fn finish_change(&mut self) -> Option<Change>
fn finish_change(&mut self) -> Option<Change>
Get completed change
§fn action(&mut self, font_system: &mut FontSystem, action: Action)
fn action(&mut self, font_system: &mut FontSystem, action: Action)
Perform an Action on the editor
§fn cursor_position(&self) -> Option<(i32, i32)>
fn cursor_position(&self) -> Option<(i32, i32)>
Get X and Y position of the top left corner of the cursor
§fn borrow_with<'font_system>(
&'font_system mut self,
font_system: &'font_system mut FontSystem,
) -> BorrowedWithFontSystem<'font_system, Self>where
Self: Sized,
fn borrow_with<'font_system>(
&'font_system mut self,
font_system: &'font_system mut FontSystem,
) -> BorrowedWithFontSystem<'font_system, Self>where
Self: Sized,
Mutably borrows
self together with an FontSystem for more convenient methods§fn with_buffer<F, T>(&self, f: F) -> T
fn with_buffer<F, T>(&self, f: F) -> T
Get the internal
Buffer§fn with_buffer_mut<F, T>(&mut self, f: F) -> T
fn with_buffer_mut<F, T>(&mut self, f: F) -> T
Get the internal
Buffer, mutably§fn set_redraw(&mut self, redraw: bool)
fn set_redraw(&mut self, redraw: bool)
Set the
Buffer redraw flag§fn selection_bounds(&self) -> Option<(Cursor, Cursor)>
fn selection_bounds(&self) -> Option<(Cursor, Cursor)>
Get the bounds of the current selection
§fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>)
fn insert_string(&mut self, data: &str, attrs_list: Option<AttrsList>)
Insert a string at the current cursor or replacing the current selection with the given
attributes, or with the previous character’s attributes if None is given.
Auto Trait Implementations§
impl<'buffer> Freeze for Editor<'buffer>
impl<'buffer> RefUnwindSafe for Editor<'buffer>
impl<'buffer> Send for Editor<'buffer>
impl<'buffer> Sync for Editor<'buffer>
impl<'buffer> Unpin for Editor<'buffer>
impl<'buffer> UnsafeUnpin for Editor<'buffer>
impl<'buffer> !UnwindSafe for Editor<'buffer>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.§fn as_any(&self) -> &(dyn Any + 'static)
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.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more