pub struct EditorCore { /* private fields */ }Expand description
Editor Core state
EditorCore aggregates all underlying editor components, including:
- LineIndex: Rope-backed canonical text buffer with fast line access
- LayoutEngine: Soft wrapping and text layout calculation
- IntervalTree: Style interval management
- FoldingManager: Code folding management
- Cursor & Selection: Cursor and selection state
§Example
use editor_core::EditorCore;
let mut core = EditorCore::new("Hello\nWorld", 80);
assert_eq!(core.line_count(), 2);
assert_eq!(core.get_text(), "Hello\nWorld");Implementations§
Source§impl EditorCore
impl EditorCore
Sourcepub fn get_headless_grid_styled(
&self,
start_visual_row: usize,
count: usize,
) -> HeadlessGrid
pub fn get_headless_grid_styled( &self, start_visual_row: usize, count: usize, ) -> HeadlessGrid
Get styled headless grid snapshot (by visual line).
- Supportsoft wrapping (based
layout_engine) Cell.styleswillinterval_tree+style_layersmerged from- Supportcode folding (based
folding_manager)
Note: This API is not responsible for mapping StyleId to specific colors.
Sourcepub fn get_minimap_grid(
&self,
start_visual_row: usize,
count: usize,
) -> MinimapGrid
pub fn get_minimap_grid( &self, start_visual_row: usize, count: usize, ) -> MinimapGrid
Get a lightweight minimap snapshot (by visual line).
Compared with Self::get_headless_grid_styled, this API returns aggregated per-line
summaries instead of per-character cells, which is intended for minimap-like overviews.
Sourcepub fn get_headless_grid_composed(
&self,
start_visual_row: usize,
count: usize,
) -> ComposedGrid
pub fn get_headless_grid_composed( &self, start_visual_row: usize, count: usize, ) -> ComposedGrid
Get a decoration-aware composed grid snapshot (by composed visual line).
This is an optional snapshot path that injects:
- inline virtual text (
DecorationPlacement::{Before,After}), e.g. inlay hints - above-line virtual text (
DecorationPlacement::AboveLine), e.g. code lens
Notes:
- Wrapping is still computed from the underlying document text only.
- Virtual text can therefore extend past the viewport width; hosts may clip.
- Each
ComposedCellcarries its origin (DocumentvsVirtual) so hosts can map interactions back to document offsets without re-implementing layout.
Source§impl EditorCore
impl EditorCore
Sourcepub fn text_range(&self, start: usize, len: usize) -> String
pub fn text_range(&self, start: usize, len: usize) -> String
Get a text range by character offset and length.
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
Get total line count
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
Get total character count
Sourcepub fn set_word_boundary_ascii_boundary_chars(&mut self, boundary_chars: &str)
pub fn set_word_boundary_ascii_boundary_chars(&mut self, boundary_chars: &str)
Override the ASCII word-boundary character set used by editor-friendly “word” operations.
Sourcepub fn reset_word_boundary_defaults(&mut self)
pub fn reset_word_boundary_defaults(&mut self)
Reset word-boundary configuration to the default (ASCII identifier-like words).
Sourcepub fn cursor_position(&self) -> Position
pub fn cursor_position(&self) -> Position
Get cursor position
Sourcepub fn secondary_selections(&self) -> &[Selection]
pub fn secondary_selections(&self) -> &[Selection]
Get secondary selections/cursors (multi-cursor)
Sourcepub fn line_index(&self) -> &LineIndex
pub fn line_index(&self) -> &LineIndex
Get the canonical line index and text access facade.
Sourcepub fn layout_engine(&self) -> &LayoutEngine
pub fn layout_engine(&self) -> &LayoutEngine
Get the current layout engine state.
Sourcepub fn interval_tree(&self) -> &IntervalTree
pub fn interval_tree(&self) -> &IntervalTree
Get the base style interval tree.
Sourcepub fn style_layers(&self) -> &BTreeMap<StyleLayerId, IntervalTree>
pub fn style_layers(&self) -> &BTreeMap<StyleLayerId, IntervalTree>
Get all style layers.
Sourcepub fn style_layer(&self, layer: StyleLayerId) -> Option<&IntervalTree>
pub fn style_layer(&self, layer: StyleLayerId) -> Option<&IntervalTree>
Get one style layer by id.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Get the current diagnostics list.
Sourcepub fn decorations(&self) -> &BTreeMap<DecorationLayerId, Vec<Decoration>>
pub fn decorations(&self) -> &BTreeMap<DecorationLayerId, Vec<Decoration>>
Get all decoration layers.
Sourcepub fn decorations_for_layer(&self, layer: DecorationLayerId) -> &[Decoration]
pub fn decorations_for_layer(&self, layer: DecorationLayerId) -> &[Decoration]
Get all decorations for a given layer.
Sourcepub fn document_symbols(&self) -> &DocumentOutline
pub fn document_symbols(&self) -> &DocumentOutline
Get the current document outline.
Sourcepub fn folding_manager(&self) -> &FoldingManager
pub fn folding_manager(&self) -> &FoldingManager
Get the folding manager as a read-only view.
Sourcepub fn viewport_width(&self) -> usize
pub fn viewport_width(&self) -> usize
Get the current viewport width in cells.
Sourcepub fn invalidate_visual_row_index_cache(&mut self)
pub fn invalidate_visual_row_index_cache(&mut self)
Invalidate cached visual-row index (wrap/folding derived mapping).
Sourcepub fn visual_line_count(&self) -> usize
pub fn visual_line_count(&self) -> usize
Get total visual line count (considering soft wrapping + folding).
Sourcepub fn visual_to_logical_line(&self, visual_line: usize) -> (usize, usize)
pub fn visual_to_logical_line(&self, visual_line: usize) -> (usize, usize)
Map visual line number back to (logical_line, visual_in_logical), considering folding.
Sourcepub fn logical_position_to_visual(
&self,
logical_line: usize,
column: usize,
) -> Option<(usize, usize)>
pub fn logical_position_to_visual( &self, logical_line: usize, column: usize, ) -> Option<(usize, usize)>
Convert logical coordinates (line, column) to visual coordinates (visual line number, in-line x cell offset), considering folding.
Sourcepub fn logical_position_to_visual_allow_virtual(
&self,
logical_line: usize,
column: usize,
) -> Option<(usize, usize)>
pub fn logical_position_to_visual_allow_virtual( &self, logical_line: usize, column: usize, ) -> Option<(usize, usize)>
Convert logical coordinates (line, column) to visual coordinates (visual line number, in-line x cell offset), considering folding.
Difference from logical_position_to_visual is that it allows column
to exceed the line end: the exceeding part is treated as ' ' (width=1) virtual spaces, suitable for rectangular selection / column editing.
Sourcepub fn visual_position_to_logical(
&self,
visual_row: usize,
x_in_cells: usize,
) -> Option<Position>
pub fn visual_position_to_logical( &self, visual_row: usize, x_in_cells: usize, ) -> Option<Position>
Convert visual coordinates (global visual row + x in cells) back to logical (line, column).
visual_rowis the global visual row (after soft wrapping and folding).x_in_cellsis the cell offset within that visual row (0-based).
Returns None if layout information is unavailable.