Skip to main content

App

Struct App 

Source
pub struct App {
Show 22 fields pub core: MathypadCore, pub scroll_offset: usize, pub mode: Mode, pub result_animations: Vec<Option<ResultAnimation>>, pub file_path: Option<PathBuf>, pub has_unsaved_changes: bool, pub show_unsaved_dialog: bool, pub show_save_as_dialog: bool, pub save_as_input: String, pub save_as_and_quit: bool, pub separator_position: u16, pub is_dragging_separator: bool, pub is_hovering_separator: bool, pub copy_flash_animations: Vec<Option<ResultAnimation>>, pub copy_flash_is_result: Vec<bool>, pub last_click_time: Option<Instant>, pub last_click_position: Option<(u16, u16)>, pub show_welcome_dialog: bool, pub welcome_scroll_offset: usize, pub pending_normal_command: Option<char>, pub command_line: String, pub command_cursor: usize,
}
Expand description

Main application state for the mathematical notepad

Fields§

§core: MathypadCore

Core calculation and text state (shared with web UI)

§scroll_offset: usize§mode: Mode§result_animations: Vec<Option<ResultAnimation>>§file_path: Option<PathBuf>§has_unsaved_changes: bool§show_unsaved_dialog: bool§show_save_as_dialog: bool§save_as_input: String§save_as_and_quit: bool§separator_position: u16§is_dragging_separator: bool§is_hovering_separator: bool§copy_flash_animations: Vec<Option<ResultAnimation>>§copy_flash_is_result: Vec<bool>§last_click_time: Option<Instant>§last_click_position: Option<(u16, u16)>§show_welcome_dialog: bool§welcome_scroll_offset: usize§pending_normal_command: Option<char>§command_line: String§command_cursor: usize

Implementations§

Source§

impl App

Source

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

Insert a character at the current cursor position

Source

pub fn delete_char(&mut self)

Delete the character before the cursor

Source

pub fn delete_word(&mut self)

Delete the word before the cursor (Ctrl+W behavior)

Source

pub fn new_line(&mut self)

Insert a new line at the cursor position

Source

pub fn move_cursor_up(&mut self)

Move cursor up one line

Source

pub fn move_cursor_down(&mut self)

Move cursor down one line

Source

pub fn move_cursor_left(&mut self)

Move cursor left one character

Source

pub fn move_cursor_right(&mut self)

Move cursor right one character

Source

pub fn delete_line(&mut self)

Delete the entire current line (vim ‘dd’ command)

Source

pub fn delete_char_at_cursor(&mut self)

Delete character at cursor position (vim ‘x’ command)

Source

pub fn move_word_forward(&mut self)

Move cursor forward by one word (vim ‘w’ command) A word is a sequence of alphanumeric characters or underscores

Source

pub fn move_word_backward(&mut self)

Move cursor backward by one word (vim ‘b’ command)

Source

pub fn move_word_forward_big(&mut self)

Move cursor forward by one WORD (vim ‘W’ command) A WORD is a sequence of non-whitespace characters

Source

pub fn move_word_backward_big(&mut self)

Move cursor backward by one WORD (vim ‘B’ command)

Source

pub fn delete_word_forward(&mut self)

Delete from cursor to the end of the current word (vim ‘dw’ command)

Source

pub fn delete_word_backward(&mut self)

Delete from cursor to the beginning of the previous word (vim ‘db’ command)

Source

pub fn delete_word_forward_big(&mut self)

Delete from cursor to the end of the current WORD (vim ‘dW’ command)

Source

pub fn delete_word_backward_big(&mut self)

Delete from cursor to the beginning of the previous WORD (vim ‘dB’ command)

Source

pub fn update_result(&mut self, line_index: usize)

Update the calculation result for a given line

Source

pub fn recalculate_all(&mut self)

Recalculate all lines in the notebook

Source

pub fn update_animations(&mut self)

Update all animations and remove completed ones

Source

pub fn get_result_animation( &self, line_index: usize, ) -> Option<&ResultAnimation>

Get the animation for a specific line

Source

pub fn save(&mut self) -> Result<(), Error>

Save the current content to the file

Source

pub fn save_as(&mut self, path: PathBuf) -> Result<(), Error>

Save the current content to a new file

Source

pub fn set_file_path(&mut self, path: Option<PathBuf>)

Set the file path (used when loading a file)

Source

pub fn show_save_as_dialog(&mut self, quit_after_save: bool)

Show the save as dialog

Source

pub fn save_as_from_dialog(&mut self) -> Result<bool, Error>

Try to save with the current save-as filename

Source

pub fn update_separator_position(&mut self, mouse_x: u16, terminal_width: u16)

Update separator position based on mouse column position

Source

pub fn is_mouse_over_separator(&self, mouse_x: u16, terminal_width: u16) -> bool

Check if mouse position is over the separator (within a few columns for easier dragging)

Source

pub fn start_dragging_separator(&mut self)

Start dragging the separator

Source

pub fn stop_dragging_separator(&mut self)

Stop dragging the separator

Source

pub fn set_separator_hover(&mut self, hovering: bool)

Set hover state for the separator

Source

pub fn copy_to_clipboard( &mut self, text: &str, line_index: usize, is_result: bool, ) -> Result<(), String>

Copy text to clipboard and start flash animation

Source

pub fn is_double_click(&mut self, mouse_x: u16, mouse_y: u16) -> bool

Check if a click is a double-click

Source

pub fn get_copy_flash_animation( &self, line_index: usize, ) -> Option<&ResultAnimation>

Get the copy flash animation for a specific line

Trait Implementations§

Source§

impl Default for App

Source§

fn default() -> App

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

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl UnwindSafe for App

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<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

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.