aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/register.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-06 07:00:23 +0000
committerBlaž Hrastnik2020-10-13 14:13:56 +0000
commit1dba0f2b1ccc0c6a29e05876b7b7153373221f87 (patch)
tree2114ae0a23fb379c57b7ad1de491fa8406cbaffe /helix-core/src/register.rs
parenteba5b1ef3329bef35fe387b03bdf2f32cdb34761 (diff)
Simple yank/paste registers.
Diffstat (limited to 'helix-core/src/register.rs')
-rw-r--r--helix-core/src/register.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/helix-core/src/register.rs b/helix-core/src/register.rs
new file mode 100644
index 00000000..0be0ce89
--- /dev/null
+++ b/helix-core/src/register.rs
@@ -0,0 +1,21 @@
+use crate::Tendril;
+use once_cell::sync::Lazy;
+use std::{collections::HashMap, sync::RwLock};
+
+// TODO: could be an instance on Editor
+static REGISTRY: Lazy<RwLock<HashMap<char, Vec<String>>>> =
+ Lazy::new(|| RwLock::new(HashMap::new()));
+
+pub fn get(register: char) -> Option<Vec<String>> {
+ let registry = REGISTRY.read().unwrap();
+
+ // TODO: no cloning
+ registry.get(&register).cloned()
+}
+
+// restoring: bool
+pub fn set(register: char, values: Vec<String>) {
+ let mut registry = REGISTRY.write().unwrap();
+
+ registry.insert(register, values);
+}