mail/status: add "general" shortcut section

jmap-eventsource
Manos Pitsidianakis 2020-11-11 17:45:39 +02:00
parent aa73bd71c3
commit 60350eaa88
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 24 additions and 7 deletions

View File

@ -1360,7 +1360,11 @@ impl Component for Listing {
}
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let mut map = self.component.get_shortcuts(context);
let mut map = if let Some(s) = self.status.as_ref() {
s.get_shortcuts(context)
} else {
self.component.get_shortcuts(context)
};
let mut config_map = context.settings.shortcuts.listing.key_values();
if self.focus != ListingFocus::Menu {
config_map.remove("open_mailbox");
@ -1761,6 +1765,7 @@ impl Listing {
/* Set to dummy */
self.component = Offline(OfflineListing::new((account_hash, 0)));
}
self.status = None;
self.set_dirty(true);
context
.replies

View File

@ -33,11 +33,12 @@ pub struct AccountStatus {
impl fmt::Display for AccountStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "status")
write!(f, "{}", AccountStatus::DESCRIPTION)
}
}
impl AccountStatus {
pub const DESCRIPTION: &'static str = "status";
pub fn new(account_pos: usize, theme_default: ThemeAttribute) -> AccountStatus {
let default_cell = {
let mut ret = Cell::with_char(' ');
@ -397,27 +398,30 @@ impl Component for AccountStatus {
context.dirty_areas.push_back(area);
}
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
let shortcuts = self.get_shortcuts(context);
match *event {
UIEvent::Resize => {
self.dirty = true;
}
UIEvent::Input(Key::Left) if self.cursor.0 != 0 => {
UIEvent::Input(ref key)
if shortcut!(key == shortcuts["general"]["scroll_left"]) && self.cursor.0 != 0 =>
{
self.cursor.0 -= 1;
self.dirty = true;
return true;
}
UIEvent::Input(Key::Right) => {
UIEvent::Input(ref key) if shortcut!(key == shortcuts["general"]["scroll_right"]) => {
self.cursor.0 = self.cursor.0 + 1;
self.dirty = true;
return true;
}
UIEvent::Input(Key::Up) => {
UIEvent::Input(ref key) if shortcut!(key == shortcuts["general"]["scroll_up"]) => {
self.cursor.1 = self.cursor.1.saturating_sub(1);
self.dirty = true;
return true;
}
UIEvent::Input(Key::Down) => {
UIEvent::Input(ref key) if shortcut!(key == shortcuts["general"]["scroll_down"]) => {
self.cursor.1 = self.cursor.1 + 1;
self.dirty = true;
return true;
@ -433,6 +437,14 @@ impl Component for AccountStatus {
false
}
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
let config_map: IndexMap<&'static str, Key> =
context.settings.shortcuts.general.key_values();
let mut ret: ShortcutMaps = Default::default();
ret.insert("general", config_map);
ret
}
fn is_dirty(&self) -> bool {
self.dirty
}