pub trait Editor: Sized + Default {
type Font: Copy + PartialEq + Default;
Show 20 methods
// Required methods
fn with_text(text: &str) -> Self;
fn is_empty(&self) -> bool;
fn cursor(&self) -> Cursor;
fn selection(&self) -> Selection;
fn copy(&self) -> Option<String>;
fn line(&self, index: usize) -> Option<Line<'_>>;
fn line_count(&self) -> usize;
fn perform(&mut self, action: Action);
fn move_to(&mut self, cursor: Cursor);
fn bounds(&self) -> Size;
fn min_bounds(&self) -> Size;
fn hint_factor(&self) -> Option<f32>;
fn update(
&mut self,
new_bounds: Size,
new_font: Self::Font,
new_size: Pixels,
new_line_height: LineHeight,
new_wrapping: Wrapping,
new_alignment: Alignment,
new_hint_factor: Option<f32>,
new_highlighter: &mut impl Highlighter,
);
fn overwrite(&mut self, new_text: &str);
fn highlight<H: Highlighter>(
&mut self,
font: Self::Font,
highlighter: &mut H,
format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font>,
);
fn font(&self) -> Self::Font;
fn text_size(&self) -> Pixels;
fn line_height(&self) -> LineHeight;
// Provided methods
fn lines(&self) -> impl Iterator<Item = Line<'_>> { ... }
fn text(&self) -> String { ... }
}Expand description
A component that can be used by widgets to edit multi-line text.
Required Associated Types§
Required Methods§
Sourcefn line(&self, index: usize) -> Option<Line<'_>>
fn line(&self, index: usize) -> Option<Line<'_>>
Returns the text of the given line in the Editor, if it exists.
Sourcefn line_count(&self) -> usize
fn line_count(&self) -> usize
Returns the amount of lines in the Editor.
Sourcefn min_bounds(&self) -> Size
fn min_bounds(&self) -> Size
Returns the minimum boundaries to fit the current contents of
the Editor.
Sourcefn hint_factor(&self) -> Option<f32>
fn hint_factor(&self) -> Option<f32>
Returns the hint factor of the Editor.
Sourcefn update(
&mut self,
new_bounds: Size,
new_font: Self::Font,
new_size: Pixels,
new_line_height: LineHeight,
new_wrapping: Wrapping,
new_alignment: Alignment,
new_hint_factor: Option<f32>,
new_highlighter: &mut impl Highlighter,
)
fn update( &mut self, new_bounds: Size, new_font: Self::Font, new_size: Pixels, new_line_height: LineHeight, new_wrapping: Wrapping, new_alignment: Alignment, new_hint_factor: Option<f32>, new_highlighter: &mut impl Highlighter, )
Updates the Editor with some new attributes.
Sourcefn highlight<H: Highlighter>(
&mut self,
font: Self::Font,
highlighter: &mut H,
format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font>,
)
fn highlight<H: Highlighter>( &mut self, font: Self::Font, highlighter: &mut H, format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font>, )
Runs a text Highlighter in the Editor.
Sourcefn line_height(&self) -> LineHeight
fn line_height(&self) -> LineHeight
Returns the current LineHeight of the Editor.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.