pub struct CodeEditor { /* private fields */ }Expand description
A source code editor: monospaced, no wrapping, line numbers, colors for the
language, Tab and Shift+Tab to indent, and Enter keeping the indentation. Ctrl or Cmd
with Enter is left to shortcuts, so a surrounding Playground can run the
code. Diagnostics mark their lines and underline what they cover.
use ravenrs_reactive::State;
use ravenrs_widgets::{CodeDiagnostic, CodeEditor, Ui};
let source = State::new("fn main() {\n println!(\"hi\");\n}".to_owned());
let editor = CodeEditor::new(source.binding())
.diagnostics(vec![CodeDiagnostic::error(2, 5, 8, "unknown macro")])
.rows(8);
let mut ui = Ui::new(editor, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl CodeEditor
impl CodeEditor
Sourcepub fn new(value: Binding<String>) -> Self
pub fn new(value: Binding<String>) -> Self
An editor of value, as Rust, with line numbers and an indent of 4 spaces.
Sourcepub fn language(self, language: CodeLanguage) -> Self
pub fn language(self, language: CodeLanguage) -> Self
The language it colors.
Sourcepub fn line_numbers(self, shown: bool) -> Self
pub fn line_numbers(self, shown: bool) -> Self
Shows or hides the line numbers.
Sourcepub fn diagnostics(self, diagnostics: Vec<CodeDiagnostic>) -> Self
pub fn diagnostics(self, diagnostics: Vec<CodeDiagnostic>) -> Self
Marks these places.
Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Takes the height its parent gives, instead of Self::rows.
Trait Implementations§
Source§impl Debug for CodeEditor
impl Debug 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
Mutably borrows from an owned value. Read more
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.