pub struct CodeEditor { /* private fields */ }Expand description
High-level code editor managing buffer state, multi-cursors, and view rendering.
Implementations§
Source§impl CodeEditor
impl CodeEditor
Sourcepub fn new(content: &str, language: Language) -> Self
pub fn new(content: &str, language: Language) -> Self
Constructs a new code editor with initial source code and language syntax.
Sourcepub fn highlighter(&self) -> &SyntaxHighlighter
pub fn highlighter(&self) -> &SyntaxHighlighter
Accesses the active syntax highlighter.
Sourcepub fn highlighter_mut(&mut self) -> &mut SyntaxHighlighter
pub fn highlighter_mut(&mut self) -> &mut SyntaxHighlighter
Accesses the active syntax highlighter mutably.
Sourcepub fn set_language(&mut self, language: Language)
pub fn set_language(&mut self, language: Language)
Changes the syntax language and re-parses the AST.
Sourcepub fn reparse(&mut self)
pub fn reparse(&mut self)
Re-parses the document incrementally with the active Tree-Sitter grammar.
Sourcepub fn buffer(&self) -> &LineBuffer
pub fn buffer(&self) -> &LineBuffer
Accesses the underlying line buffer.
Sourcepub fn cursors(&self) -> &MultiCursor
pub fn cursors(&self) -> &MultiCursor
Accesses the active cursors.
Sourcepub fn cursors_mut(&mut self) -> &mut MultiCursor
pub fn cursors_mut(&mut self) -> &mut MultiCursor
Accesses the active cursors mutably.
Sourcepub fn ime(&self) -> &ImeComposition
pub fn ime(&self) -> &ImeComposition
Returns the active IME composition state.
Sourcepub fn ime_mut(&mut self) -> &mut ImeComposition
pub fn ime_mut(&mut self) -> &mut ImeComposition
Mutably accesses the IME composition state.
Sourcepub fn set_tab_size(&mut self, size: usize)
pub fn set_tab_size(&mut self, size: usize)
Configures tab size.
Sourcepub fn wrap_column(&self) -> Option<usize>
pub fn wrap_column(&self) -> Option<usize>
Returns the soft-wrap column limit, if enabled.
Sourcepub fn set_wrap_column(&mut self, wrap: Option<usize>)
pub fn set_wrap_column(&mut self, wrap: Option<usize>)
Configures soft-wrap column limit.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Total number of lines in the buffer.
Sourcepub fn insert_char(&mut self, ch: char)
pub fn insert_char(&mut self, ch: char)
Inserts a character at all active cursors (or handles Enter with auto-indentation).
Sourcepub fn insert_newline(&mut self)
pub fn insert_newline(&mut self)
Inserts a newline with automatic indentation calculated from the syntax engine.
Sourcepub fn insert_text(&mut self, text: &str)
pub fn insert_text(&mut self, text: &str)
Inserts text at all cursor positions atomically in descending document order.
Sourcepub fn delete_backwards(&mut self)
pub fn delete_backwards(&mut self)
Performs backspace deletion at all active cursors atomically in descending document order.
Sourcepub fn move_right(&mut self, select: bool)
pub fn move_right(&mut self, select: bool)
Moves all active cursors right by 1 character.
Sourcepub fn move_to_line_start(&mut self, select: bool)
pub fn move_to_line_start(&mut self, select: bool)
Moves all active cursors to the start of their respective line.
Sourcepub fn move_to_line_end(&mut self, select: bool)
pub fn move_to_line_end(&mut self, select: bool)
Moves all active cursors to the end of their respective line.
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Selects all text in the document.
Sourcepub fn toggle_fold(&mut self, line: usize)
pub fn toggle_fold(&mut self, line: usize)
Toggles code folding on the specified line.
Sourcepub fn render(&self) -> NodeBlueprint
pub fn render(&self) -> NodeBlueprint
Renders a complete code editor view blueprint with default styling.
Sourcepub fn render_blueprint(&self, class_style: &str) -> NodeBlueprint
pub fn render_blueprint(&self, class_style: &str) -> NodeBlueprint
Renders a complete code editor view blueprint with line numbering gutter and syntax tokens.
Sourcepub fn render_virtualized(
&self,
scroll_top: f32,
viewport_height: f32,
line_height: f32,
class_style: &str,
) -> NodeBlueprint
pub fn render_virtualized( &self, scroll_top: f32, viewport_height: f32, line_height: f32, class_style: &str, ) -> NodeBlueprint
Renders a virtualized viewport slice of the code editor.
Only the lines currently visible in the scroll viewport (plus an overscan margin) are laid out and styled into DOM blueprint nodes. Spacer containers at the top and bottom maintain the exact natural scroll height of the entire document.