Struct cosmic_text::ViEditor

source ·
pub struct ViEditor<'syntax_system, 'buffer> { /* private fields */ }

Implementations§

source§

impl<'syntax_system, 'buffer> ViEditor<'syntax_system, 'buffer>

source

pub fn new(editor: SyntaxEditor<'syntax_system, 'buffer>) -> Self

source

pub fn update_theme(&mut self, theme_name: &str) -> bool

Modifies the theme of the SyntaxEditor, returning false if the theme is missing

source

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

source

pub fn background_color(&self) -> Color

Get the default background color

source

pub fn foreground_color(&self) -> Color

Get the default foreground (text) color

source

pub fn cursor_color(&self) -> Color

Get the default cursor color

source

pub fn selection_color(&self) -> Color

Get the default selection color

source

pub fn theme(&self) -> &SyntaxTheme

Get the current syntect theme

source

pub fn changed(&self) -> bool

Get changed flag

source

pub fn set_changed(&mut self, changed: bool)

Set changed flag

source

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.

source

pub fn set_passthrough(&mut self, passthrough: bool)

Set passthrough mode (true will turn off vi features)

source

pub fn parser(&self) -> &ViParser

Get current vi parser

source

pub fn redo(&mut self)

Redo a change

source

pub fn undo(&mut self)

Undo a change

source

pub fn draw<F>( &self, font_system: &mut FontSystem, cache: &mut SwashCache, f: F, )
where F: FnMut(i32, i32, u32, u32, Color),

Trait Implementations§

source§

impl<'syntax_system, 'buffer> Debug for ViEditor<'syntax_system, 'buffer>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'syntax_system, 'buffer> Edit<'buffer> for ViEditor<'syntax_system, 'buffer>

source§

fn buffer_ref(&self) -> &BufferRef<'buffer>

Get the internal BufferRef
source§

fn buffer_ref_mut(&mut self) -> &mut BufferRef<'buffer>

Get the internal BufferRef
source§

fn cursor(&self) -> Cursor

Get the current cursor
source§

fn set_cursor(&mut self, cursor: Cursor)

Set the current cursor
source§

fn selection(&self) -> Selection

Get the current selection position
source§

fn set_selection(&mut self, selection: Selection)

Set the current selection position
source§

fn auto_indent(&self) -> bool

Get the current automatic indentation setting
source§

fn set_auto_indent(&mut self, auto_indent: bool)

Enable or disable automatic indentation
source§

fn tab_width(&self) -> u16

Get the current tab width
source§

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 ignored
source§

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)

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

Insert text at specified cursor with specified attrs_list
source§

fn copy_selection(&self) -> Option<String>

Copy selection
source§

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

Apply a change
source§

fn start_change(&mut self)

Start collecting change
source§

fn finish_change(&mut self) -> Option<Change>

Get completed change
source§

fn action(&mut self, font_system: &mut FontSystem, action: Action)

Perform an Action on the editor
source§

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,

Mutably borrows self together with an FontSystem for more convenient methods
source§

fn with_buffer<F: FnOnce(&Buffer) -> T, T>(&self, f: F) -> T

Get the internal Buffer
source§

fn with_buffer_mut<F: FnOnce(&mut Buffer) -> T, T>(&mut self, f: F) -> T

Get the internal Buffer, mutably
source§

fn redraw(&self) -> bool

Get the Buffer redraw flag
source§

fn set_redraw(&mut self, redraw: bool)

Set the Buffer redraw flag
source§

fn selection_bounds(&self) -> Option<(Cursor, Cursor)>

Get the bounds of the current selection
source§

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<'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> 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> 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> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.