Trait cosmic::iced_core::text::Editor

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

    // Required methods
    fn with_text(text: &str) -> Self;
    fn is_empty(&self) -> bool;
    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_wrapping: Wrapping,
        new_highlighter: &mut impl Highlighter,
    );
    fn highlight<H>(
        &mut self,
        font: Self::Font,
        highlighter: &mut H,
        format_highlight: impl Fn(&<H as Highlighter>::Highlight) -> Format<Self::Font>,
    )
       where H: Highlighter;
}
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 is_empty(&self) -> bool

Returns true if the Editor has no contents.

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_wrapping: Wrapping, new_highlighter: &mut impl Highlighter, )

Updates the Editor with some new attributes.

source

fn highlight<H>( &mut self, font: Self::Font, highlighter: &mut H, format_highlight: impl Fn(&<H as Highlighter>::Highlight) -> Format<Self::Font>, )
where H: Highlighter,

Runs a text Highlighter in the Editor.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Editor for ()

source§

type Font = Font

source§

fn with_text(_text: &str)

source§

fn is_empty(&self) -> bool

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: <() as Editor>::Font, _new_size: Pixels, _new_line_height: LineHeight, _new_wrapping: Wrapping, _new_highlighter: &mut impl Highlighter, )

source§

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

Implementors§