pub struct SyntaxEditor<'syntax_system, 'buffer> { /* private fields */ }
Expand description
A wrapper of Editor
with syntax highlighting provided by SyntaxSystem
Implementations§
Source§impl<'syntax_system, 'buffer> SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> SyntaxEditor<'syntax_system, 'buffer>
Sourcepub fn new(
buffer: impl Into<BufferRef<'buffer>>,
syntax_system: &'syntax_system SyntaxSystem,
theme_name: &str,
) -> Option<Self>
pub fn new( buffer: impl Into<BufferRef<'buffer>>, syntax_system: &'syntax_system SyntaxSystem, theme_name: &str, ) -> Option<Self>
Create a new SyntaxEditor
with the provided [Buffer
], SyntaxSystem
, and theme name.
A good default theme name is “base16-eighties.dark”.
Returns None if theme not found
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<()>
Sourcepub fn syntax_by_extension(&mut self, extension: &str)
pub fn syntax_by_extension(&mut self, extension: &str)
Set syntax highlighting by file extension
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 draw<F>(
&self,
font_system: &mut FontSystem,
cache: &mut SwashCache,
f: F,
)
pub fn draw<F>( &self, font_system: &mut FontSystem, cache: &mut SwashCache, f: F, )
Draw the editor
Trait Implementations§
Source§impl<'syntax_system, 'buffer> Debug for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> Debug for SyntaxEditor<'syntax_system, 'buffer>
Source§impl<'buffer> Edit<'buffer> for SyntaxEditor<'_, 'buffer>
impl<'buffer> Edit<'buffer> for SyntaxEditor<'_, 'buffer>
Source§fn buffer_ref(&self) -> &BufferRef<'buffer>
fn buffer_ref(&self) -> &BufferRef<'buffer>
Get the internal
BufferRef
Source§fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>
Get the internal
BufferRef
Source§fn set_cursor(&mut self, cursor: Cursor)
fn set_cursor(&mut self, cursor: Cursor)
Set the current cursor
Source§fn set_selection(&mut self, selection: Selection)
fn set_selection(&mut self, selection: Selection)
Set the current selection position
Source§fn auto_indent(&self) -> bool
fn auto_indent(&self) -> bool
Get the current automatic indentation setting
Source§fn set_auto_indent(&mut self, auto_indent: bool)
fn set_auto_indent(&mut self, auto_indent: bool)
Enable or disable automatic indentation
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)
Set the current tab width. A
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)
Shape lines until scroll, after adjusting scroll if the cursor moved
Source§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
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
Insert text at specified cursor with specified
attrs_list
Source§fn copy_selection(&self) -> Option<String>
fn copy_selection(&self) -> Option<String>
Copy selection
Source§fn delete_selection(&mut self) -> bool
fn delete_selection(&mut self) -> bool
Delete selection, adjusting cursor and returning true if there was a selection
Source§fn apply_change(&mut self, change: &Change) -> bool
fn apply_change(&mut self, change: &Change) -> bool
Apply a change
Source§fn start_change(&mut self)
fn start_change(&mut self)
Start collecting change
Source§fn finish_change(&mut self) -> Option<Change>
fn finish_change(&mut self) -> Option<Change>
Get completed change
Source§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
Source§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
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,
Mutably borrows
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
Get the internal
Buffer
, mutablySource§fn set_redraw(&mut self, redraw: bool)
fn set_redraw(&mut self, redraw: bool)
Set the
Buffer
redraw flagAuto Trait Implementations§
impl<'syntax_system, 'buffer> Freeze for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> RefUnwindSafe for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !Send for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !Sync for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> Unpin for SyntaxEditor<'syntax_system, 'buffer>
impl<'syntax_system, 'buffer> !UnwindSafe for SyntaxEditor<'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
Mutably borrows from an owned value. Read more