added esc as close key for stuff

This commit is contained in:
rabite 2019-06-18 20:07:14 +02:00
parent 800982dcfd
commit 89260e4312
4 changed files with 9 additions and 4 deletions

View File

@ -184,7 +184,7 @@ impl Widget for BMPopup {
}
fn on_key(&mut self, key: Key) -> HResult<()> {
match key {
Key::Ctrl('c') => {
Key::Ctrl('c') | Key::Esc => {
self.bookmark_path = None;
return HError::popup_finnished()
},

View File

@ -294,6 +294,7 @@ where
}
fn on_key(&mut self, key: Key) -> HResult<()> {
// this on_key() could have been implmented by some type
let result = FoldableWidgetExt::on_key(self, key);
if let Err(HError::WidgetUndefinedKeyError{key}) = result {
match key {
@ -302,9 +303,11 @@ where
Key::Char('J') => for _ in 0..10 { self.move_down() },
Key::Down | Key::Char('j') => self.move_down(),
Key::Char('t') => self.toggle_fold()?,
Key::Char('g') => self.popup_finnished()?,
Key::Char('g') | Key::Esc => self.popup_finnished()?,
_ => { HError::undefined_key(key)?; },
}
// Key was defined, or _ match would have returned undefined key
return Ok(());
}
result
}

View File

@ -657,7 +657,7 @@ impl Widget for ProcView {
}
fn on_key(&mut self, key: Key) -> HResult<()> {
match key {
Key::Char('w') => {
Key::Char('w') | Key::Esc => {
self.animator.set_stale().log();
self.get_core()?.clear().log();
return Err(HError::PopupFinnished) }

View File

@ -68,7 +68,9 @@ impl FoldableWidgetExt for ListView<Vec<QuickActions>> {
fn on_key(&mut self, key: Key) -> HResult<()> {
match key {
Key::Char('a') |
Key::Char('h') => HError::popup_finnished()?,
Key::Char('h') |
Key::Ctrl('c') |
Key::Esc => HError::popup_finnished()?,
// undefined key causes parent to handle move up/down
Key::Char('j') => HError::undefined_key(key)?,
Key::Char('k') => HError::undefined_key(key)?,