summaryrefslogtreecommitdiffstats
path: root/widget/src/text_editor.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-17 19:03:58 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-17 19:04:23 +0200
commitd3011992a76e83e12f74402c2ade616cdc7f1497 (patch)
tree50547c123164ef3b28d1e59264ebe9435edd648c /widget/src/text_editor.rs
parent76dc82e8e8b5201ec10f8d00d851c1decf998583 (diff)
downloadiced-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.rs18
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>>)