Implement Copy and Paste actions for text::Editor

This commit is contained in:
Héctor Ramón Jiménez 2023-09-16 15:40:16 +02:00
parent c6d0443627
commit d051f21597
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
4 changed files with 24 additions and 5 deletions

View file

@ -12,6 +12,7 @@ use crate::core::{
};
use std::cell::RefCell;
use std::sync::Arc;
pub use crate::style::text_editor::{Appearance, StyleSheet};
pub use text::editor::{Action, Motion};
@ -253,10 +254,14 @@ where
Update::Edit(action) => {
shell.publish(on_edit(action));
}
Update::Copy => todo!(),
Update::Copy => {
if let Some(selection) = self.content.selection() {
clipboard.write(selection);
}
}
Update::Paste => {
if let Some(_contents) = clipboard.read() {
todo!()
if let Some(contents) = clipboard.read() {
shell.publish(on_edit(Action::Paste(Arc::new(contents))));
}
}
}