Skip to main content

NoteEditorState

Struct NoteEditorState 

Source
pub struct NoteEditorState<'a> {
    pub content: String,
    pub view: View,
    pub cursor: Cursor,
    pub ast_nodes: Vec<Node>,
    pub virtual_document: VirtualDocument<'a>,
    pub symbols: Symbols,
    /* private fields */
}

Fields§

§content: String§view: View§cursor: Cursor§ast_nodes: Vec<Node>§virtual_document: VirtualDocument<'a>§symbols: Symbols

Implementations§

Source§

impl<'a> NoteEditorState<'a>

Source

pub fn new( content: &str, filename: &str, filepath: &Path, symbols: &Symbols, ) -> Self

Source

pub fn viewport(&self) -> &Viewport

Source

pub fn is_editing(&self) -> bool

Source

pub fn insert_mode(&self) -> bool

Source

pub fn set_insert_mode(&mut self, mode: bool)

Source

pub fn vim_mode(&self) -> bool

Source

pub fn set_vim_mode(&mut self, mode: bool)

Source

pub fn editor_enabled(&self) -> bool

Source

pub fn set_editor_enabled(&mut self, enabled: bool)

Source

pub fn text_buffer(&self) -> Option<&TextBuffer>

Source

pub fn enter_insert(&mut self, block_idx: usize)

Source

pub fn commit_text_buffer(&mut self) -> bool

Write the current text_buffer back to self.content if it was modified, re-parse AST nodes. Returns true if content changed.

Source

pub fn exit_insert(&mut self)

Source

pub fn set_filename(&mut self, name: &str)

Source

pub fn set_filepath(&mut self, path: &Path)

Source

pub fn insert_char(&mut self, c: char)

Source

pub fn delete_char(&mut self)

Source

pub fn active(&self) -> bool

Source

pub fn current_block(&self) -> usize

Source

pub fn set_view(&mut self, view: View)

Source

pub fn resize_viewport(&mut self, size: Size)

Source

pub fn set_active(&mut self, active: bool)

Source

pub fn modified(&self) -> bool

Source

pub fn cursor_word_forward(&mut self)

Source

pub fn cursor_word_backward(&mut self)

Source

pub fn cursor_left(&mut self, amount: usize)

Source

pub fn cursor_right(&mut self, amount: usize)

Source

pub fn cursor_to_end(&mut self)

Source

pub fn cursor_jump(&mut self, idx: usize)

Source

pub fn update_layout(&mut self)

Source

pub fn cursor_up(&mut self, amount: usize)

Source

pub fn cursor_down(&mut self, amount: usize)

Source

pub fn save_to_file(&mut self) -> Result<()>

Trait Implementations§

Source§

impl<'a> Clone for NoteEditorState<'a>

Source§

fn clone(&self) -> NoteEditorState<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for NoteEditorState<'a>

Source§

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

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

impl<'a> Default for NoteEditorState<'a>

Source§

fn default() -> NoteEditorState<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for NoteEditorState<'a>

§

impl<'a> RefUnwindSafe for NoteEditorState<'a>

§

impl<'a> Send for NoteEditorState<'a>

§

impl<'a> Sync for NoteEditorState<'a>

§

impl<'a> Unpin for NoteEditorState<'a>

§

impl<'a> UnsafeUnpin for NoteEditorState<'a>

§

impl<'a> UnwindSafe for NoteEditorState<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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

Source§

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.