mirror of https://github.com/helix-editor/helix
Simple yank/paste registers.
parent
eba5b1ef33
commit
1dba0f2b1c
@ -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(®ister).cloned()
|
||||
}
|
||||
|
||||
// restoring: bool
|
||||
pub fn set(register: char, values: Vec<String>) {
|
||||
let mut registry = REGISTRY.write().unwrap();
|
||||
|
||||
registry.insert(register, values);
|
||||
}
|
Loading…
Reference in New Issue