pub struct CodeEditor<A = ()> { /* private fields */ }Expand description
Code-oriented editor backed by an ailloli_ui_editor::Document signal.
Edits synchronize the document version/dirty flag, update the supplied
signal, refresh syntax/search/folds, and then invoke the optional change
handler. Defaults come from CodeEditorConfig; optional prop vectors
replace their corresponding session models when enabled. The default wrap
mode is no-wrap, so long lines scroll horizontally. Overflowing axes paint
interactive overlay scrollbars whose thumbs can be dragged from the exact
pressed point and whose track clicks center the thumb; those interactions
never move the caret. Editing
and keyboard navigation follow the caret on both axes and preserve three
visible lines below it by default. A caret already in the safe region never
moves the viewport. Clicks never move the viewport, and pointer selection
auto-scrolls only outside the text viewport.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new())));
let _ = editor;Implementations§
Source§impl<A: 'static> CodeEditor<A>
impl<A: 'static> CodeEditor<A>
Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().height(40.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_width(40.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_width(320.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_height(24.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_height(240.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().margin(8.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().padding(8.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_basis(80.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().align_self(AlignItems::Center);
let _ = widget;Source§impl<A: 'static> CodeEditor<A>
impl<A: 'static> CodeEditor<A>
Sourcepub fn new(document: impl Into<Signal<Document>>) -> Self
pub fn new(document: impl Into<Signal<Document>>) -> Self
Creates a code editor bound to shared document state.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new())));
let _ = editor;Sourcepub fn language(self, language: EditorLanguage) -> Self
pub fn language(self, language: EditorLanguage) -> Self
Forces one language instead of document/path-derived resolution.
§Examples
use ailloli_ui_editor::{Document, DocumentId, EditorLanguage};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).language(EditorLanguage::Rust);
let _ = editor;Sourcepub fn theme(self, theme: CodeTheme) -> Self
pub fn theme(self, theme: CodeTheme) -> Self
Replaces code colors and synchronizes generic editor background/foreground.
§Examples
use ailloli_ui_editor::{CodeTheme, Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).theme(CodeTheme::dark());
let _ = editor;Sourcepub fn gutter(self, gutter: GutterConfig) -> Self
pub fn gutter(self, gutter: GutterConfig) -> Self
Replaces gutter enablement, width, line-number, fold, and diagnostic settings.
§Examples
use ailloli_ui_editor::{Document, DocumentId, GutterConfig};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).gutter(GutterConfig::default());
let _ = editor;Sourcepub fn features(self, features: CodeEditorFeatureFlags) -> Self
pub fn features(self, features: CodeEditorFeatureFlags) -> Self
Replaces syntax/search/diagnostic/folding/symbol feature flags.
Disabled features clear or skip the corresponding retained model.
§Examples
use ailloli_ui_editor::{CodeEditorFeatureFlags, Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).features(CodeEditorFeatureFlags::default());
let _ = editor;Sourcepub fn line_numbers(self, enabled: bool) -> Self
pub fn line_numbers(self, enabled: bool) -> Self
Enables/disables line numbers and ensures the gutter is enabled when true.
Passing false hides line numbers but deliberately does not disable a
gutter that may still show folds or diagnostics.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).line_numbers(false);
let _ = editor;Sourcepub fn wrap_mode(self, wrap_mode: EditorWrapMode) -> Self
pub fn wrap_mode(self, wrap_mode: EditorWrapMode) -> Self
Selects soft wrapping or horizontal no-wrap behavior.
§Examples
use ailloli_ui_editor::{Document, DocumentId, EditorWrapMode};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).wrap_mode(EditorWrapMode::SoftWrap);
let _ = editor;Sourcepub fn scrollbars(self, enabled: bool) -> Self
pub fn scrollbars(self, enabled: bool) -> Self
Shows or hides editor-engine scrollbars without disabling scrolling.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).scrollbars(false);
let _ = editor;Sourcepub fn scrollbar_style(self, style: EditorScrollbarStyle) -> Self
pub fn scrollbar_style(self, style: EditorScrollbarStyle) -> Self
Replaces editor scrollbar colors and logical-pixel geometry.
§Examples
use ailloli_ui_editor::{Document, DocumentId, EditorScrollbarStyle};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).scrollbar_style(EditorScrollbarStyle::default());
let _ = editor;Sourcepub fn initial_scroll(self, x: f32, y: f32) -> Self
pub fn initial_scroll(self, x: f32, y: f32) -> Self
Sets initial x/y scroll offsets in logical pixels.
Each coordinate is floored at zero; negative and NaN values become
zero. The offsets are reapplied when an external document replacement is
observed, then normal editor metrics clamp them during frame building.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).initial_scroll(12.0, 24.0);
let _ = editor;Sourcepub fn search_query(self, query: SearchQuery) -> Self
pub fn search_query(self, query: SearchQuery) -> Self
Supplies the retained search query when search is enabled.
§Examples
use ailloli_ui_editor::{Document, DocumentId, SearchQuery};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).search_query(SearchQuery::new("fn"));
let _ = editor;Sourcepub fn search_active_match(self, active_match: usize) -> Self
pub fn search_active_match(self, active_match: usize) -> Self
Requests the active match index for the supplied search query.
Out-of-range handling is delegated to the editor search state.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).search_active_match(0);
let _ = editor;Sourcepub fn diagnostics(self, diagnostics: Vec<Diagnostic>) -> Self
pub fn diagnostics(self, diagnostics: Vec<Diagnostic>) -> Self
Replaces local/LSP diagnostics when diagnostics are enabled.
Empty clears diagnostics; ranges remain UTF-8 byte ranges governed by the editor model.
§Examples
use ailloli_ui_editor::{Diagnostic, DiagnosticSeverity, Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let diagnostic = Diagnostic::new(0..1, DiagnosticSeverity::Warning, "check");
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::from_string("x")))).diagnostics(vec![diagnostic]);
let _ = editor;Sourcepub fn active_diagnostic(self, active_diagnostic: usize) -> Self
pub fn active_diagnostic(self, active_diagnostic: usize) -> Self
Requests one diagnostic index as active.
The value is forwarded without range validation; missing indexes simply produce no active diagnostic decoration/hit.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).active_diagnostic(0);
let _ = editor;Sourcepub fn fold_regions(self, fold_regions: Vec<FoldRegion>) -> Self
pub fn fold_regions(self, fold_regions: Vec<FoldRegion>) -> Self
Replaces fold-region geometry when folding is enabled.
If IDs and line bounds match retained regions, their current collapsed state wins so a parent rebuild does not reopen user-toggled folds.
§Examples
use ailloli_ui_editor::{Document, DocumentId, FoldRegion};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).fold_regions(vec![FoldRegion::new(0, 2)]);
let _ = editor;Sourcepub fn symbol_summary(self, summary: CodeFileSummary) -> Self
pub fn symbol_summary(self, summary: CodeFileSummary) -> Self
Supplies a precomputed symbol graph when symbol support is enabled.
The current widget retains this metadata but has no symbol navigation UI; it does not alter paint output yet.
§Examples
use ailloli_ui_editor::{CodeFileSummary, Document, DocumentId, DocumentVersion, EditorLanguage};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let summary = CodeFileSummary { document_id: DocumentId(1), path: None, language: EditorLanguage::Rust, version: DocumentVersion(0), symbols: vec![], edges: vec![] };
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).symbol_summary(summary);
let _ = editor;Sourcepub fn initial_selection(self, anchor: usize, caret: usize) -> Self
pub fn initial_selection(self, anchor: usize, caret: usize) -> Self
Sets initial anchor/caret UTF-8 byte offsets.
Values are independently clamped to document byte length on first build, but are not ordered or validated as UTF-8 character boundaries.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::from_string("hello")))).initial_selection(0, 5);
let _ = editor;Sourcepub fn caret_follow_margin_lines(self, lines: f32) -> Self
pub fn caret_follow_margin_lines(self, lines: f32) -> Self
Sets the visible-line safety margin kept below the revealed caret.
The default is three lines. The margin applies to edits, paste, undo, redo, IME changes, and keyboard navigation. Reveal always adds only the distance by which the caret crosses the safe boundary; pointer clicks never request caret following. Negative values become zero and non-finite values restore the default.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(
DocumentId(1),
TextBuffer::new(),
)))
.caret_follow_margin_lines(5.0);
let _ = editor;Sourcepub fn on_document_change(self, f: impl Fn(Document) -> A + 'static) -> Self
pub fn on_document_change(self, f: impl Fn(Document) -> A + 'static) -> Self
Maps each edited document into an application action.
The handler runs only after a text-changing edit has synchronized the document, not for selection, scroll, or external prop updates.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
enum Action { Changed(Document) }
let editor: CodeEditor<Action> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).on_document_change(Action::Changed);
let _ = editor;Sourcepub fn on_document_change_ctx(
self,
f: impl Fn(&mut EventCtx<A>, Document) + 'static,
) -> Self
pub fn on_document_change_ctx( self, f: impl Fn(&mut EventCtx<A>, Document) + 'static, ) -> Self
Handles edited documents with mutable runtime event-context access.
§Examples
use ailloli_ui_editor::{Document, DocumentId};
use ailloli_ui_runtime::component::State;
use ailloli_ui_text::TextBuffer;
use ailloli_ui_widgets::editor::CodeEditor;
let editor: CodeEditor<()> = CodeEditor::new(State::new(Document::new(DocumentId(1), TextBuffer::new()))).on_document_change_ctx(|_ctx, _document| {});
let _ = editor;Trait Implementations§
Source§impl<A: 'static> IntoView<A> for CodeEditor<A>
Converts the builder into a retained code-editor component with layout hints.
impl<A: 'static> IntoView<A> for CodeEditor<A>
Converts the builder into a retained code-editor component with layout hints.