pub struct MathypadCore {
pub text_lines: Vec<String>,
pub cursor_line: usize,
pub cursor_col: usize,
pub results: Vec<Option<String>>,
pub variables: HashMap<String, String>,
}Expand description
Core application state containing text, results, and variables This is UI-agnostic and can be used by both TUI and web implementations
Fields§
§text_lines: Vec<String>The text content of each line
cursor_line: usizeCurrent cursor line position (0-indexed)
cursor_col: usizeCurrent cursor column position (0-indexed, in characters)
results: Vec<Option<String>>Evaluation results for each line (None means no result or error)
variables: HashMap<String, String>Variable storage (variable_name -> value_string)
Implementations§
Source§impl MathypadCore
impl MathypadCore
Sourcepub fn from_lines(lines: Vec<String>) -> Self
pub fn from_lines(lines: Vec<String>) -> Self
Create a MathypadCore from a list of text lines
Sourcepub fn insert_char(&mut self, c: char)
pub fn insert_char(&mut self, c: char)
Insert a character at the current cursor position
Sourcepub fn delete_char(&mut self)
pub fn delete_char(&mut self)
Delete the character before the cursor
Sourcepub fn update_result(&mut self, line_index: usize)
pub fn update_result(&mut self, line_index: usize)
Update the result for a specific line
Sourcepub fn recalculate_all(&mut self)
pub fn recalculate_all(&mut self)
Recalculate all results and variables
Sourcepub fn move_cursor_to(&mut self, line: usize, col: usize)
pub fn move_cursor_to(&mut self, line: usize, col: usize)
Move cursor to a specific position
Sourcepub fn current_line(&self) -> &str
pub fn current_line(&self) -> &str
Get the current line content
Sourcepub fn current_result(&self) -> Option<&str>
pub fn current_result(&self) -> Option<&str>
Get the result for the current line
Sourcepub fn set_content(&mut self, content: &str)
pub fn set_content(&mut self, content: &str)
Set text content from a string (splitting into lines)
Sourcepub fn get_content(&self) -> String
pub fn get_content(&self) -> String
Get content as a single string
Sourcepub fn update_content_with_line_references(&mut self, new_content: &str)
pub fn update_content_with_line_references(&mut self, new_content: &str)
Update content with line reference updating (for incremental edits) This detects line insertions/deletions and updates references accordingly
Trait Implementations§
Source§impl Clone for MathypadCore
impl Clone for MathypadCore
Source§fn clone(&self) -> MathypadCore
fn clone(&self) -> MathypadCore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more