diff options
author | 2023-09-17 19:03:58 +0200 | |
---|---|---|
committer | 2023-09-17 19:04:23 +0200 | |
commit | d3011992a76e83e12f74402c2ade616cdc7f1497 (patch) | |
tree | 50547c123164ef3b28d1e59264ebe9435edd648c /widget/src/text_editor.rs | |
parent | 76dc82e8e8b5201ec10f8d00d851c1decf998583 (diff) | |
download | iced-d3011992a76e83e12f74402c2ade616cdc7f1497.tar.gz iced-d3011992a76e83e12f74402c2ade616cdc7f1497.tar.bz2 iced-d3011992a76e83e12f74402c2ade616cdc7f1497.zip |
Implement basic syntax highlighting with `syntect` in `editor` example
Diffstat (limited to 'widget/src/text_editor.rs')
-rw-r--r-- | widget/src/text_editor.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index b17e1156..03adbb59 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -81,6 +81,24 @@ where self.padding = padding.into(); self } + + pub fn highlight<H: text::Highlighter>( + self, + settings: H::Settings, + ) -> TextEditor<'a, H, Message, Renderer> { + TextEditor { + content: self.content, + font: self.font, + text_size: self.text_size, + line_height: self.line_height, + width: self.width, + height: self.height, + padding: self.padding, + style: self.style, + on_edit: self.on_edit, + highlighter_settings: settings, + } + } } pub struct Content<R = crate::Renderer>(RefCell<Internal<R>>) |