Undo/redo support

This commit is contained in:
Jeremy Soller 2023-11-13 13:31:46 -07:00
parent f76f83565c
commit c84a256376
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
4 changed files with 63 additions and 4 deletions

View file

@ -120,6 +120,7 @@ pub enum Message {
Paste,
PasteValue(String),
Quit,
Redo,
Save,
SelectAll,
SyntaxTheme(usize, bool),
@ -128,6 +129,7 @@ pub enum Message {
Todo,
ToggleContextPage(ContextPage),
ToggleWordWrap,
Undo,
VimBindings(bool),
}
@ -689,6 +691,13 @@ impl Application for App {
//TODO: prompt for save?
return window::close();
}
Message::Redo => match self.active_tab() {
Some(tab) => {
let mut editor = tab.editor.lock().unwrap();
editor.redo();
}
None => {}
},
Message::Save => {
let mut title_opt = None;
@ -785,6 +794,13 @@ impl Application for App {
self.config.word_wrap = !self.config.word_wrap;
return self.save_config();
}
Message::Undo => match self.active_tab() {
Some(tab) => {
let mut editor = tab.editor.lock().unwrap();
editor.undo();
}
None => {}
},
Message::VimBindings(vim_bindings) => {
self.config.vim_bindings = vim_bindings;
return self.save_config();