diff options
author | 2023-10-27 17:36:54 +0200 | |
---|---|---|
committer | 2023-10-27 17:36:54 +0200 | |
commit | d731996342118dccfd50df8db9607741d162a639 (patch) | |
tree | 9f7db10dea8e6faf25041b19d0fe595acb995e9c /core/src/renderer | |
parent | 3ec5ad42251d4f35861f3bed621223e383742b12 (diff) | |
parent | c8eca4e6bfae82013e6bb08e9d8bf66560b36564 (diff) | |
download | iced-d731996342118dccfd50df8db9607741d162a639.tar.gz iced-d731996342118dccfd50df8db9607741d162a639.tar.bz2 iced-d731996342118dccfd50df8db9607741d162a639.zip |
Merge pull request #2123 from iced-rs/text-editor
`TextEditor` widget (or multi-line text input)
Diffstat (limited to 'core/src/renderer')
-rw-r--r-- | core/src/renderer/null.rs | 91 |
1 files changed, 63 insertions, 28 deletions
diff --git a/core/src/renderer/null.rs b/core/src/renderer/null.rs index 55d58a59..da0f32de 100644 --- a/core/src/renderer/null.rs +++ b/core/src/renderer/null.rs @@ -43,6 +43,7 @@ impl Renderer for Null { impl text::Renderer for Null { type Font = Font; type Paragraph = (); + type Editor = (); const ICON_FONT: Font = Font::DEFAULT; const CHECKMARK_ICON: char = '0'; @@ -58,19 +59,17 @@ impl text::Renderer for Null { fn load_font(&mut self, _font: Cow<'static, [u8]>) {} - fn create_paragraph(&self, _text: Text<'_, Self::Font>) -> Self::Paragraph { - } - - fn resize_paragraph( - &self, - _paragraph: &mut Self::Paragraph, - _new_bounds: Size, + fn fill_paragraph( + &mut self, + _paragraph: &Self::Paragraph, + _position: Point, + _color: Color, ) { } - fn fill_paragraph( + fn fill_editor( &mut self, - _paragraph: &Self::Paragraph, + _editor: &Self::Editor, _position: Point, _color: Color, ) { @@ -88,47 +87,83 @@ impl text::Renderer for Null { impl text::Paragraph for () { type Font = Font; - fn content(&self) -> &str { - "" + fn with_text(_text: Text<'_, Self::Font>) -> Self {} + + fn resize(&mut self, _new_bounds: Size) {} + + fn compare(&self, _text: Text<'_, Self::Font>) -> text::Difference { + text::Difference::None } - fn text_size(&self) -> Pixels { - Pixels(16.0) + fn horizontal_alignment(&self) -> alignment::Horizontal { + alignment::Horizontal::Left } - fn font(&self) -> Self::Font { - Font::default() + fn vertical_alignment(&self) -> alignment::Vertical { + alignment::Vertical::Top } - fn line_height(&self) -> text::LineHeight { - text::LineHeight::default() + fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point> { + None } - fn shaping(&self) -> text::Shaping { - text::Shaping::default() + fn min_bounds(&self) -> Size { + Size::ZERO } - fn horizontal_alignment(&self) -> alignment::Horizontal { - alignment::Horizontal::Left + fn hit_test(&self, _point: Point) -> Option<text::Hit> { + None } +} - fn vertical_alignment(&self) -> alignment::Vertical { - alignment::Vertical::Top +impl text::Editor for () { + type Font = Font; + + fn with_text(_text: &str) -> Self {} + + fn cursor(&self) -> text::editor::Cursor { + text::editor::Cursor::Caret(Point::ORIGIN) } - fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point> { + fn cursor_position(&self) -> (usize, usize) { + (0, 0) + } + + fn selection(&self) -> Option<String> { + None + } + + fn line(&self, _index: usize) -> Option<&str> { None } + fn line_count(&self) -> usize { + 0 + } + + fn perform(&mut self, _action: text::editor::Action) {} + fn bounds(&self) -> Size { Size::ZERO } - fn min_bounds(&self) -> Size { - Size::ZERO + fn update( + &mut self, + _new_bounds: Size, + _new_font: Self::Font, + _new_size: Pixels, + _new_line_height: text::LineHeight, + _new_highlighter: &mut impl text::Highlighter, + ) { } - fn hit_test(&self, _point: Point) -> Option<text::Hit> { - None + fn highlight<H: text::Highlighter>( + &mut self, + _font: Self::Font, + _highlighter: &mut H, + _format_highlight: impl Fn( + &H::Highlight, + ) -> text::highlighter::Format<Self::Font>, + ) { } } |