ViEditor: Implement put/yank registers
This commit is contained in:
parent
04c96f39c5
commit
9278e7d0c4
2 changed files with 18 additions and 8 deletions
|
|
@ -15,7 +15,7 @@ fontdb = { version = "0.16.0", default-features = false }
|
|||
hashbrown = { version = "0.14.1", optional = true, default-features = false }
|
||||
libm = "0.2.8"
|
||||
log = "0.4.20"
|
||||
modit = { version = "0.1.1", optional = true }
|
||||
modit = { version = "0.1.2", optional = true }
|
||||
rangemap = "1.4.0"
|
||||
rustc-hash = { version = "1.1.0", default-features = false }
|
||||
rustybuzz = { version = "0.11.0", default-features = false, features = ["libm"] }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use alloc::string::String;
|
||||
use alloc::{collections::BTreeMap, string::String};
|
||||
use core::cmp;
|
||||
use modit::{Event, Key, Motion, Parser, TextObject, WordIter};
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
|
@ -155,6 +155,7 @@ pub struct ViEditor<'a> {
|
|||
editor: SyntaxEditor<'a>,
|
||||
parser: ViParser,
|
||||
passthrough: bool,
|
||||
registers: BTreeMap<char, (Selection, String)>,
|
||||
search_opt: Option<(String, bool)>,
|
||||
commands: cosmic_undo_2::Commands<Change>,
|
||||
changed: bool,
|
||||
|
|
@ -166,6 +167,7 @@ impl<'a> ViEditor<'a> {
|
|||
editor,
|
||||
parser: ViParser::new(),
|
||||
passthrough: false,
|
||||
registers: BTreeMap::new(),
|
||||
search_opt: None,
|
||||
commands: cosmic_undo_2::Commands::new(),
|
||||
changed: false,
|
||||
|
|
@ -378,16 +380,18 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
finish_change(editor, &mut self.commands, &mut self.changed);
|
||||
return;
|
||||
}
|
||||
Event::Copy => {
|
||||
log::info!("TODO");
|
||||
return;
|
||||
}
|
||||
Event::Delete => Action::Delete,
|
||||
Event::Escape => Action::Escape,
|
||||
Event::Insert(c) => Action::Insert(c),
|
||||
Event::NewLine => Action::Enter,
|
||||
Event::Paste => {
|
||||
log::info!("TODO");
|
||||
Event::Put { register, after } => {
|
||||
if let Some((selection, data)) = self.registers.get(®ister) {
|
||||
editor.start_change();
|
||||
editor.delete_selection();
|
||||
//TODO: handle after/before and select by line
|
||||
editor.insert_string(data, None);
|
||||
finish_change(editor, &mut self.commands, &mut self.changed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Event::Redraw => {
|
||||
|
|
@ -473,6 +477,12 @@ impl<'a> Edit for ViEditor<'a> {
|
|||
}
|
||||
return;
|
||||
}
|
||||
Event::Yank { register } => {
|
||||
if let Some(data) = editor.copy_selection() {
|
||||
self.registers.insert(register, (editor.selection(), data));
|
||||
}
|
||||
return;
|
||||
}
|
||||
Event::Motion(motion) => {
|
||||
match motion {
|
||||
Motion::Around => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue