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 mode(&self) -> Mode

The current editor mode for the status-bar indicator.

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 exit_insert(&mut self)

Source

pub fn commit_text_buffer(&mut self) -> Option<()>

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

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) -> Option<()>

Source

pub fn active(&self) -> bool

Source

pub fn previous_block_idx(&self) -> usize

Source

pub fn current_block_idx(&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 theme(&self) -> Theme

Source

pub fn set_theme(&mut self, theme: &Theme)

Swaps the colour theme and re-lays out so the new colours take effect.

Source

pub fn modified(&self) -> bool

Source

pub fn selection(&self) -> Option<Selection>

Source

pub fn is_selecting(&self) -> bool

Source

pub fn toggle_selection(&mut self, mode: SelectionMode)

Enters visual selection in mode, or exits if that mode is already active.

Source

pub fn clear_selection(&mut self)

Source

pub fn has_pending_count(&self) -> bool

Source

pub fn push_count_digit(&mut self, digit: u8)

Source

pub fn take_count(&mut self) -> Option<usize>

Consumes the pending count. None means no explicit count was given.

Source

pub fn reset_count(&mut self)

Source

pub fn awaiting_find_target(&self) -> bool

Source

pub fn arm_find(&mut self, direction: Direction, till: bool)

Source

pub fn clear_pending_find(&mut self)

Source

pub fn take_pending_find(&mut self) -> Option<FindKind>

Source

pub fn remember_find(&mut self, target: char, kind: FindKind)

Records a completed find so ; and , can replay it.

Source

pub fn last_find(&self) -> Option<(char, FindKind)>

Source

pub fn awaiting_text_object(&self) -> bool

Source

pub fn arm_text_object(&mut self, kind: TextObjectKind)

Source

pub fn take_text_object(&mut self) -> Option<TextObjectKind>

Source

pub fn clear_pending_text_object(&mut self)

Source

pub fn awaiting_replace(&self) -> bool

Source

pub fn arm_replace(&mut self)

Source

pub fn clear_pending_replace(&mut self)

Source

pub fn pending_operator(&self) -> Option<Operator>

Source

pub fn pending_hint(&self) -> String

A short hint of the in-flight command (e.g. 3d) for the mode indicator.

Source

pub fn set_operator(&mut self, operator: Operator)

Source

pub fn take_operator(&mut self) -> Option<Operator>

Source

pub fn clear_operator(&mut self)

Source

pub fn register(&self) -> &Register

Source

pub fn set_register(&mut self, text: String, linewise: bool)

Source

pub fn mark_undo_point(&mut self)

Records the current content as an undo point, discarding the redo stack.

Source

pub fn undo(&mut self) -> bool

Source

pub fn redo(&mut self) -> bool

Source

pub fn splice(&mut self, range: Range<usize>, replacement: &str)

Replaces range with replacement, re-parses, and leaves the cursor at the edit site. Records an undo point first.

Source

pub fn paste(&mut self, after: bool)

Pastes the register at (or after) the cursor. Linewise registers land on their own line below (p) or above (P).

Source

pub fn selection_range(&self) -> Option<Range<usize>>

Source byte range from anchor to cursor. Charwise includes the character under the cursor; linewise rounds out to whole lines.

Source

pub fn selected_text(&self) -> Option<String>

Source

pub fn flash_yank(&mut self, range: Range<usize>)

Flashes range to acknowledge a yank. The highlight fades on its own after [YANK_FLASH_DURATION].

Source

pub fn yank_flash_range(&self) -> Option<Range<usize>>

The range to flash right now, or None once the flash has elapsed.

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 jump_to_offset(&mut self, offset: usize)

Move the cursor to an arbitrary source byte offset, switching the active block (and its text buffer) when the target lies in another block. Unlike Self::relayout_on_block_change this preserves a precise mid-block target, so it is the primitive every vim motion moves through.

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 (const: unstable) · 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more