Trait iced_core::text::editor::Editor

source ·
pub trait Editor: Sized + Default {
    type Font: Copy + PartialEq + Default;

    // Required methods
    fn with_text(text: &str) -> Self;
    fn cursor(&self) -> Cursor;
    fn cursor_position(&self) -> (usize, usize);
    fn selection(&self) -> Option<String>;
    fn line(&self, index: usize) -> Option<&str>;
    fn line_count(&self) -> usize;
    fn perform(&mut self, action: Action);
    fn bounds(&self) -> Size;
    fn min_bounds(&self) -> Size;
    fn update(
        &mut self,
        new_bounds: Size,
        new_font: Self::Font,
        new_size: Pixels,
        new_line_height: LineHeight,
        new_highlighter: &mut impl Highlighter
    );
    fn highlight<H: Highlighter>(
        &mut self,
        font: Self::Font,
        highlighter: &mut H,
        format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font>
    );
}
Expand description

A component that can be used by widgets to edit multi-line text.

Required Associated Types§

source

type Font: Copy + PartialEq + Default

The font of the Editor.

Required Methods§

source

fn with_text(text: &str) -> Self

Creates a new Editor laid out with the given text.

source

fn cursor(&self) -> Cursor

Returns the current Cursor of the Editor.

source

fn cursor_position(&self) -> (usize, usize)

Returns the current cursor position of the Editor.

Line and column, respectively.

source

fn selection(&self) -> Option<String>

Returns the current selected text of the Editor.

source

fn line(&self, index: usize) -> Option<&str>

Returns the text of the given line in the Editor, if it exists.

source

fn line_count(&self) -> usize

Returns the amount of lines in the Editor.

source

fn perform(&mut self, action: Action)

Performs an Action on the Editor.

source

fn bounds(&self) -> Size

Returns the current boundaries of the Editor.

source

fn min_bounds(&self) -> Size

Returns the minimum boundaries to fit the current contents of the Editor.

source

fn update( &mut self, new_bounds: Size, new_font: Self::Font, new_size: Pixels, new_line_height: LineHeight, new_highlighter: &mut impl Highlighter )

Updates the Editor with some new attributes.

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Editor for ()

§

type Font = Font

source§

fn with_text(_text: &str) -> Self

source§

fn cursor(&self) -> Cursor

source§

fn cursor_position(&self) -> (usize, usize)

source§

fn selection(&self) -> Option<String>

source§

fn line(&self, _index: usize) -> Option<&str>

source§

fn line_count(&self) -> usize

source§

fn perform(&mut self, _action: Action)

source§

fn bounds(&self) -> Size

source§

fn min_bounds(&self) -> Size

source§

fn update( &mut self, _new_bounds: Size, _new_font: Self::Font, _new_size: Pixels, _new_line_height: LineHeight, _new_highlighter: &mut impl Highlighter )

source§

fn highlight<H: Highlighter>( &mut self, _font: Self::Font, _highlighter: &mut H, _format_highlight: impl Fn(&H::Highlight) -> Format<Self::Font> )

Implementors§