Skip to main content

CodeEditor

Struct CodeEditor 

Source
pub struct CodeEditor { /* private fields */ }
Expand description

High-level code editor managing buffer state, multi-cursors, and view rendering.

Implementations§

Source§

impl CodeEditor

Source

pub fn new(content: &str, language: Language) -> Self

Constructs a new code editor with initial source code and language syntax.

Source

pub fn highlighter(&self) -> &SyntaxHighlighter

Accesses the active syntax highlighter.

Source

pub fn highlighter_mut(&mut self) -> &mut SyntaxHighlighter

Accesses the active syntax highlighter mutably.

Source

pub fn language(&self) -> Language

Returns the active syntax language.

Source

pub fn set_language(&mut self, language: Language)

Changes the syntax language and re-parses the AST.

Source

pub fn reparse(&mut self)

Re-parses the document incrementally with the active Tree-Sitter grammar.

Source

pub fn buffer(&self) -> &LineBuffer

Accesses the underlying line buffer.

Source

pub fn cursors(&self) -> &MultiCursor

Accesses the active cursors.

Source

pub fn cursors_mut(&mut self) -> &mut MultiCursor

Accesses the active cursors mutably.

Source

pub fn ime(&self) -> &ImeComposition

Returns the active IME composition state.

Source

pub fn ime_mut(&mut self) -> &mut ImeComposition

Mutably accesses the IME composition state.

Source

pub fn tab_size(&self) -> usize

Returns the configured tab size (in spaces).

Source

pub fn set_tab_size(&mut self, size: usize)

Configures tab size.

Source

pub fn wrap_column(&self) -> Option<usize>

Returns the soft-wrap column limit, if enabled.

Source

pub fn set_wrap_column(&mut self, wrap: Option<usize>)

Configures soft-wrap column limit.

Source

pub fn line_count(&self) -> usize

Total number of lines in the buffer.

Source

pub fn text(&self) -> String

Serializes entire buffer content to a String.

Source

pub fn set_text(&mut self, text: &str)

Replaces entire buffer content and resets history.

Source

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

Inserts a character at all active cursors (or handles Enter with auto-indentation).

Source

pub fn insert_newline(&mut self)

Inserts a newline with automatic indentation calculated from the syntax engine.

Source

pub fn insert_text(&mut self, text: &str)

Inserts text at all cursor positions atomically in descending document order.

Source

pub fn delete_backwards(&mut self)

Performs backspace deletion at all active cursors atomically in descending document order.

Source

pub fn undo(&mut self)

Undoes the last recorded transaction.

Source

pub fn redo(&mut self)

Redoes the last undone transaction.

Source

pub fn move_left(&mut self, select: bool)

Moves all active cursors left by 1 character.

Source

pub fn move_right(&mut self, select: bool)

Moves all active cursors right by 1 character.

Source

pub fn move_up(&mut self, select: bool)

Moves all active cursors up by 1 line.

Source

pub fn move_down(&mut self, select: bool)

Moves all active cursors down by 1 line.

Source

pub fn move_to_line_start(&mut self, select: bool)

Moves all active cursors to the start of their respective line.

Source

pub fn move_to_line_end(&mut self, select: bool)

Moves all active cursors to the end of their respective line.

Source

pub fn select_all(&mut self)

Selects all text in the document.

Source

pub fn toggle_fold(&mut self, line: usize)

Toggles code folding on the specified line.

Source

pub fn is_folded(&self, line: usize) -> bool

Checks if the line is currently folded.

Source

pub fn render(&self) -> NodeBlueprint

Renders a complete code editor view blueprint with default styling.

Source

pub fn render_blueprint(&self, class_style: &str) -> NodeBlueprint

Renders a complete code editor view blueprint with line numbering gutter and syntax tokens.

Source

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.

Trait Implementations§

Source§

impl Clone for CodeEditor

Source§

fn clone(&self) -> Self

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 Debug for CodeEditor

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.