Struct cosmic_text::ViEditor
source · pub struct ViEditor<'syntax_system, 'buffer> { /* private fields */ }
Implementations§
source§impl<'syntax_system, 'buffer> ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> ViEditor<'syntax_system, 'buffer>
pub fn new(editor: SyntaxEditor<'syntax_system, 'buffer>) -> Self
sourcepub fn update_theme(&mut self, theme_name: &str) -> bool
pub fn update_theme(&mut self, theme_name: &str) -> bool
Modifies the theme of the SyntaxEditor
, returning false if the theme is missing
sourcepub fn load_text<P: AsRef<Path>>(
&mut self,
font_system: &mut FontSystem,
path: P,
attrs: Attrs<'_>,
) -> Result<()>
pub fn load_text<P: AsRef<Path>>( &mut self, font_system: &mut FontSystem, path: P, attrs: Attrs<'_>, ) -> Result<()>
Load text from a file, and also set syntax to the best option
sourcepub fn background_color(&self) -> Color
pub fn background_color(&self) -> Color
Get the default background color
sourcepub fn foreground_color(&self) -> Color
pub fn foreground_color(&self) -> Color
Get the default foreground (text) color
sourcepub fn cursor_color(&self) -> Color
pub fn cursor_color(&self) -> Color
Get the default cursor color
sourcepub fn selection_color(&self) -> Color
pub fn selection_color(&self) -> Color
Get the default selection color
sourcepub fn theme(&self) -> &SyntaxTheme
pub fn theme(&self) -> &SyntaxTheme
Get the current syntect theme
sourcepub fn set_changed(&mut self, changed: bool)
pub fn set_changed(&mut self, changed: bool)
Set changed flag
sourcepub fn save_point(&mut self)
pub fn save_point(&mut self)
Set current change as the save (or pivot) point.
A pivot point is the last saved index. Anything before or after the pivot indicates that the editor has been changed or is unsaved.
Undoing changes down to the pivot point sets the editor as unchanged. Redoing changes up to the pivot point sets the editor as unchanged.
Undoing or redoing changes beyond the pivot point sets the editor to changed.
sourcepub fn set_passthrough(&mut self, passthrough: bool)
pub fn set_passthrough(&mut self, passthrough: bool)
Set passthrough mode (true will turn off vi features)
pub fn draw<F>( &self, font_system: &mut FontSystem, cache: &mut SwashCache, f: F, )
Trait Implementations§
source§impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer>
source§fn buffer_ref(&self) -> &BufferRef<'buffer>
fn buffer_ref(&self) -> &BufferRef<'buffer>
BufferRef
source§fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
BufferRef
source§fn set_cursor(&mut self, cursor: Cursor)
fn set_cursor(&mut self, cursor: Cursor)
source§fn set_selection(&mut self, selection: Selection)
fn set_selection(&mut self, selection: Selection)
source§fn auto_indent(&self) -> bool
fn auto_indent(&self) -> bool
source§fn set_auto_indent(&mut self, auto_indent: bool)
fn set_auto_indent(&mut self, auto_indent: bool)
source§fn set_tab_width(&mut self, font_system: &mut FontSystem, tab_width: u16)
fn set_tab_width(&mut self, font_system: &mut FontSystem, tab_width: u16)
tab_width
of 0 is not allowed, and will be ignoredsource§fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
fn shape_as_needed(&mut self, font_system: &mut FontSystem, prune: bool)
source§fn delete_range(&mut self, start: Cursor, end: Cursor)
fn delete_range(&mut self, start: Cursor, end: Cursor)
source§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
source§fn copy_selection(&self) -> Option<String>
fn copy_selection(&self) -> Option<String>
source§fn delete_selection(&mut self) -> bool
fn delete_selection(&mut self) -> bool
source§fn apply_change(&mut self, change: &Change) -> bool
fn apply_change(&mut self, change: &Change) -> bool
source§fn start_change(&mut self)
fn start_change(&mut self)
source§fn finish_change(&mut self) -> Option<Change>
fn finish_change(&mut self) -> Option<Change>
source§fn action(&mut self, font_system: &mut FontSystem, action: Action)
fn action(&mut self, font_system: &mut FontSystem, action: Action)
source§fn cursor_position(&self) -> Option<(i32, i32)>
fn cursor_position(&self) -> Option<(i32, i32)>
source§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,
self
together with an FontSystem
for more convenient methodssource§fn with_buffer_mut<F: FnOnce(&mut Buffer) -> T, T>(&mut self, f: F) -> T
fn with_buffer_mut<F: FnOnce(&mut Buffer) -> T, T>(&mut self, f: F) -> T
Buffer
, mutablysource§fn set_redraw(&mut self, redraw: bool)
fn set_redraw(&mut self, redraw: bool)
Buffer
redraw flagAuto Trait Implementations§
impl<'syntax_system, 'buffer> Freeze for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> RefUnwindSafe for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !Send for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !Sync for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> Unpin for ViEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !UnwindSafe for ViEditor<'syntax_system, '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
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>
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>
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