Implement multi-selection copy/cut/paste

This commit is contained in:
Max Brunsfeld
2021-04-13 17:28:51 -07:00
parent 13514aae6c
commit c83f02dd04
2 changed files with 134 additions and 12 deletions
+8 -6
View File
@@ -1,12 +1,11 @@
use pathfinder_geometry::vector::Vector2F;
use std::sync::Arc;
use std::{any::Any, rc::Rc};
use crate::ClipboardItem;
use pathfinder_geometry::vector::Vector2F;
use std::{any::Any, cell::RefCell, rc::Rc, sync::Arc};
struct Platform {
dispatcher: Arc<dyn super::Dispatcher>,
fonts: Arc<dyn super::FontSystem>,
current_clipboard_item: RefCell<Option<ClipboardItem>>,
}
struct Dispatcher;
@@ -24,6 +23,7 @@ impl Platform {
Self {
dispatcher: Arc::new(Dispatcher),
fonts: Arc::new(super::current::FontSystem::new()),
current_clipboard_item: RefCell::new(None),
}
}
}
@@ -74,10 +74,12 @@ impl super::Platform for Platform {
None
}
fn write_to_clipboard(&self, _: ClipboardItem) {}
fn write_to_clipboard(&self, item: ClipboardItem) {
*self.current_clipboard_item.borrow_mut() = Some(item);
}
fn read_from_clipboard(&self) -> Option<ClipboardItem> {
None
self.current_clipboard_item.borrow().clone()
}
}