summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-16 15:40:16 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-16 15:40:16 +0200
commitd051f21597bb333ac10183aaa3214a292e9aa365 (patch)
tree0735e31bae1fefcf004ebba199bd5ec759040605 /graphics
parentc6d0443627c22dcf1576303e5a426aa3622f1b7d (diff)
downloadiced-d051f21597bb333ac10183aaa3214a292e9aa365.tar.gz
iced-d051f21597bb333ac10183aaa3214a292e9aa365.tar.bz2
iced-d051f21597bb333ac10183aaa3214a292e9aa365.zip
Implement `Copy` and `Paste` actions for `text::Editor`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/text/editor.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs
index 1e375a25..1890cb82 100644
--- a/graphics/src/text/editor.rs
+++ b/graphics/src/text/editor.rs
@@ -398,6 +398,17 @@ impl editor::Editor for Editor {
editor
.action(font_system.raw(), cosmic_text::Action::Insert(c));
}
+ Action::Paste(text) => {
+ editor.insert_string(&text, None);
+
+ // TODO: Fix cosmic-text
+ // Cursor should be marked as moved after `insert_string`.
+ let cursor = editor.cursor();
+
+ editor
+ .buffer_mut()
+ .shape_until_cursor(font_system.raw(), cursor);
+ }
Action::Enter => {
editor.action(font_system.raw(), cosmic_text::Action::Enter);
}