pub struct CodeEditor { /* private fields */ }Expand description
Native code editing surface with line numbers, indentation metadata, syntax-highlight preview and pluggable diagnostics.
The current MVP deliberately reuses Liora’s native Input editing core and
CodeBlock highlighter instead of embedding a Web editor runtime. Future
diagnostics providers can update set_diagnostics without changing the UI.
Implementations§
Source§impl CodeEditor
impl CodeEditor
Sourcepub fn new(value: impl Into<SharedString>, cx: &mut Context<'_, Self>) -> Self
pub fn new(value: impl Into<SharedString>, cx: &mut Context<'_, Self>) -> Self
Creates CodeEditor initialized from the supplied value.
Sourcepub fn entity(value: impl Into<SharedString>, cx: &mut App) -> Entity<Self>
pub fn entity(value: impl Into<SharedString>, cx: &mut App) -> Entity<Self>
Creates a GPUI entity that owns this component state across render passes.
Sourcepub fn value(&self, cx: &App) -> SharedString
pub fn value(&self, cx: &App) -> SharedString
Returns the serialized value used by forms, configuration, or persistence.
Sourcepub fn set_value(
&mut self,
value: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_value( &mut self, value: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Updates the stored value value and keeps the existing component identity.
Sourcepub fn language(self, language: impl Into<CodeLanguage>) -> Self
pub fn language(self, language: impl Into<CodeLanguage>) -> Self
Sets the language identifier used for code display.
Sourcepub fn set_language(
&mut self,
language: impl Into<CodeLanguage>,
cx: &mut Context<'_, Self>,
)
pub fn set_language( &mut self, language: impl Into<CodeLanguage>, cx: &mut Context<'_, Self>, )
Updates the stored language value and keeps the existing component identity.
Sourcepub fn line_numbers(self, enabled: bool) -> Self
pub fn line_numbers(self, enabled: bool) -> Self
Sets the line numbers value used by the component.
Sourcepub fn height(self, height: impl Into<Pixels>) -> Self
pub fn height(self, height: impl Into<Pixels>) -> Self
Sets the component height token used during GPUI layout.
Sourcepub fn diagnostics(
self,
diagnostics: impl IntoIterator<Item = CodeDiagnostic>,
) -> Self
pub fn diagnostics( self, diagnostics: impl IntoIterator<Item = CodeDiagnostic>, ) -> Self
Sets the diagnostics value used by the component.
Sourcepub fn set_diagnostics(
&mut self,
diagnostics: impl IntoIterator<Item = CodeDiagnostic>,
cx: &mut Context<'_, Self>,
)
pub fn set_diagnostics( &mut self, diagnostics: impl IntoIterator<Item = CodeDiagnostic>, cx: &mut Context<'_, Self>, )
Updates the stored diagnostics value and keeps the existing component identity.
Sourcepub fn diagnostics_provider(
self,
provider: impl Fn(&str) -> Vec<CodeDiagnostic> + 'static,
) -> Self
pub fn diagnostics_provider( self, provider: impl Fn(&str) -> Vec<CodeDiagnostic> + 'static, ) -> Self
Performs the diagnostics provider operation used by this component.
Sourcepub fn set_diagnostics_provider(
&mut self,
provider: impl Fn(&str) -> Vec<CodeDiagnostic> + 'static,
cx: &mut Context<'_, Self>,
)
pub fn set_diagnostics_provider( &mut self, provider: impl Fn(&str) -> Vec<CodeDiagnostic> + 'static, cx: &mut Context<'_, Self>, )
Updates the stored diagnostics provider value and keeps the existing component identity.
Sourcepub fn clear_diagnostics_provider(&mut self, cx: &mut Context<'_, Self>)
pub fn clear_diagnostics_provider(&mut self, cx: &mut Context<'_, Self>)
Clears the current diagnostics provider state.
Sourcepub fn on_change(
self,
callback: impl Fn(&str, &mut Context<'_, CodeEditor>) + 'static,
) -> Self
pub fn on_change( self, callback: impl Fn(&str, &mut Context<'_, CodeEditor>) + 'static, ) -> Self
Registers a callback that runs when change occurs.
Sourcepub fn set_on_change(
&mut self,
callback: impl Fn(&str, &mut Context<'_, CodeEditor>) + 'static,
cx: &mut Context<'_, Self>,
)
pub fn set_on_change( &mut self, callback: impl Fn(&str, &mut Context<'_, CodeEditor>) + 'static, cx: &mut Context<'_, Self>, )
Updates the stored on change value and keeps the existing component identity.
Sourcepub fn indent_unit(&self) -> String
pub fn indent_unit(&self) -> String
Performs the indent unit operation used by this component.
Sourcepub fn register_key_bindings(cx: &mut App)
pub fn register_key_bindings(cx: &mut App)
Registers GPUI key bindings required for keyboard interaction.
Trait Implementations§
Source§impl Focusable for CodeEditor
impl Focusable for CodeEditor
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Source§impl Render for CodeEditor
impl Render for CodeEditor
Auto Trait Implementations§
impl !RefUnwindSafe for CodeEditor
impl !Send for CodeEditor
impl !Sync for CodeEditor
impl !UnwindSafe for CodeEditor
impl Freeze for CodeEditor
impl Unpin for CodeEditor
impl UnsafeUnpin for CodeEditor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more