shortcuts tidiness
- Unflatten shortcuts configuration table. Shortcuts now have to be defined in levels: [shortcuts.general] ... [shortcuts.pager] ... - Add shortcuts for thread view - Sort alphabetically in help viewjmap
parent
678889d706
commit
1063bb73b5
|
@ -64,28 +64,33 @@
|
||||||
#play_sound = true # default, optional
|
#play_sound = true # default, optional
|
||||||
#sound_file = PATH # optional
|
#sound_file = PATH # optional
|
||||||
|
|
||||||
#[shortcuts]
|
##shortcuts
|
||||||
# Compact mail listing defaults:
|
# Compact mail listing defaults:
|
||||||
#open_thread = '\n'
|
#[shortcuts.compact_listing]
|
||||||
#exit_thread = 'i'
|
#exit_thread = 'i'
|
||||||
|
#
|
||||||
|
#[shortcuts.contact-list]
|
||||||
#create_contact = 'c'
|
#create_contact = 'c'
|
||||||
#edit_contact = 'e'
|
#edit_contact = 'e'
|
||||||
|
|
||||||
# Mail listing defaults
|
# Mail listing defaults
|
||||||
#prev_page = PageUp,
|
#[shortcuts.listing]
|
||||||
#next_page = PageDown,
|
#prev_page = "PageUp"
|
||||||
#prev_folder = 'K',
|
#next_page = "PageDown"
|
||||||
#next_folder = 'J',
|
#prev_folder = 'K'
|
||||||
#prev_account = 'l',
|
#next_folder = 'J'
|
||||||
#next_account = 'h',
|
#prev_account = 'l'
|
||||||
#new_mail = 'm',
|
#next_account = 'h'
|
||||||
|
#new_mail = 'm'
|
||||||
|
#set_seen = 'n'
|
||||||
|
|
||||||
# Pager defaults
|
# Pager defaults
|
||||||
|
|
||||||
#scroll_up = 'k',
|
#[shortcuts.pager]
|
||||||
#scroll_down = 'j',
|
#scroll_up = 'k'
|
||||||
#page_up = PageUp,
|
#scroll_down = 'j'
|
||||||
#page_down = PageDown,
|
#page_up = "PageUp"
|
||||||
|
#page_down = "PageDown"
|
||||||
|
|
||||||
#[composing]
|
#[composing]
|
||||||
# required for sending e-mail
|
# required for sending e-mail
|
||||||
|
|
|
@ -1009,19 +1009,19 @@ impl Component for ThreadView {
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Char('p')) => {
|
UIEvent::Input(ref key) if *key == shortcuts["toggle_mailview"] => {
|
||||||
self.show_mailview = !self.show_mailview;
|
self.show_mailview = !self.show_mailview;
|
||||||
self.initiated = false;
|
self.initiated = false;
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Char('t')) => {
|
UIEvent::Input(ref key) if *key == shortcuts["toggle_threadview"] => {
|
||||||
self.show_thread = !self.show_thread;
|
self.show_thread = !self.show_thread;
|
||||||
self.initiated = false;
|
self.initiated = false;
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Ctrl('r')) => {
|
UIEvent::Input(ref key) if *key == shortcuts["reverse_thread_order"] => {
|
||||||
self.reversed = !self.reversed;
|
self.reversed = !self.reversed;
|
||||||
let expanded_hash = self.entries[self.expanded_pos].index.1;
|
let expanded_hash = self.entries[self.expanded_pos].index.1;
|
||||||
self.initiate(Some(expanded_hash), context);
|
self.initiate(Some(expanded_hash), context);
|
||||||
|
@ -1029,7 +1029,7 @@ impl Component for ThreadView {
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Char('h')) => {
|
UIEvent::Input(ref key) if *key == shortcuts["collapse_subtree"] => {
|
||||||
let current_pos = self.current_pos();
|
let current_pos = self.current_pos();
|
||||||
self.entries[current_pos].hidden = !self.entries[current_pos].hidden;
|
self.entries[current_pos].hidden = !self.entries[current_pos].hidden;
|
||||||
self.entries[current_pos].dirty = true;
|
self.entries[current_pos].dirty = true;
|
||||||
|
@ -1095,43 +1095,9 @@ impl Component for ThreadView {
|
||||||
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
|
fn get_shortcuts(&self, context: &Context) -> ShortcutMaps {
|
||||||
let mut map = self.mailview.get_shortcuts(context);
|
let mut map = self.mailview.get_shortcuts(context);
|
||||||
//FIXME
|
//FIXME
|
||||||
let config_map = context.settings.shortcuts.compact_listing.key_values();
|
let config_map = context.settings.shortcuts.envelope_view.key_values();
|
||||||
|
|
||||||
map.insert(
|
map.insert(ThreadView::DESCRIPTION, config_map);
|
||||||
ThreadView::DESCRIPTION,
|
|
||||||
[
|
|
||||||
("reverse thread order", Key::Ctrl('r')),
|
|
||||||
("toggle_mailview", Key::Char('p')),
|
|
||||||
("toggle_subthread visibility", Key::Char('h')),
|
|
||||||
(
|
|
||||||
"prev_page",
|
|
||||||
if let Some(key) = config_map.get("prev_page") {
|
|
||||||
(*key).clone()
|
|
||||||
} else {
|
|
||||||
Key::PageUp
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"next_page",
|
|
||||||
if let Some(key) = config_map.get("next_page") {
|
|
||||||
(*key).clone()
|
|
||||||
} else {
|
|
||||||
Key::PageDown
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"exit_thread",
|
|
||||||
if let Some(key) = config_map.get("exit_thread") {
|
|
||||||
(*key).clone()
|
|
||||||
} else {
|
|
||||||
Key::Char('i')
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
||||||
.iter()
|
|
||||||
.cloned()
|
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
|
|
||||||
map
|
map
|
||||||
}
|
}
|
||||||
|
|
|
@ -1461,10 +1461,12 @@ impl Component for Tabbed {
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.help_curr_views = children_maps;
|
|
||||||
let mut max_length = 5;
|
let mut max_length = 5;
|
||||||
let mut max_width = "Use Up, Down, Left, Right to scroll.".len() + 3;
|
let mut max_width = "Use Up, Down, Left, Right to scroll.".len() + 3;
|
||||||
for (desc, shortcuts) in self.help_curr_views.iter() {
|
|
||||||
|
let mut shortcuts = children_maps.iter().collect::<Vec<_>>();
|
||||||
|
shortcuts.sort_by_key(|(k, _)| *k);
|
||||||
|
for (desc, shortcuts) in shortcuts.iter() {
|
||||||
max_length += shortcuts.len() + 3;
|
max_length += shortcuts.len() + 3;
|
||||||
max_width = std::cmp::max(
|
max_width = std::cmp::max(
|
||||||
max_width,
|
max_width,
|
||||||
|
@ -1500,7 +1502,7 @@ impl Component for Tabbed {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let mut idx = 0;
|
let mut idx = 0;
|
||||||
for (desc, shortcuts) in self.help_curr_views.iter() {
|
for (desc, shortcuts) in shortcuts.iter() {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
desc,
|
desc,
|
||||||
&mut self.help_content,
|
&mut self.help_content,
|
||||||
|
@ -1537,6 +1539,7 @@ impl Component for Tabbed {
|
||||||
}
|
}
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
self.help_curr_views = children_maps;
|
||||||
copy_area(
|
copy_area(
|
||||||
grid,
|
grid,
|
||||||
&self.help_content,
|
&self.help_content,
|
||||||
|
|
|
@ -4,17 +4,19 @@ use fnv::FnvHashMap;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
pub struct Shortcuts {
|
pub struct Shortcuts {
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
pub general: GeneralShortcuts,
|
pub general: GeneralShortcuts,
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
pub listing: ListingShortcuts,
|
pub listing: ListingShortcuts,
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
pub composing: ComposingShortcuts,
|
pub composing: ComposingShortcuts,
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
pub compact_listing: CompactListingShortcuts,
|
pub compact_listing: CompactListingShortcuts,
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
pub contact_list: ContactListShortcuts,
|
pub contact_list: ContactListShortcuts,
|
||||||
#[serde(flatten)]
|
#[serde(default)]
|
||||||
|
pub envelope_view: EnvelopeViewShortcuts,
|
||||||
|
#[serde(default)]
|
||||||
pub pager: PagerShortcuts,
|
pub pager: PagerShortcuts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ macro_rules! shortcut_key_values {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shortcut_key_values! { "compact_listing",
|
shortcut_key_values! { "compact-listing",
|
||||||
/// Shortcut listing for a mail listing in compact mode.
|
/// Shortcut listing for a mail listing in compact mode.
|
||||||
pub struct CompactListingShortcuts {
|
pub struct CompactListingShortcuts {
|
||||||
open_thread: Key |> "Open thread." |> Key::Char('\n'),
|
open_thread: Key |> "Open thread." |> Key::Char('\n'),
|
||||||
|
@ -118,3 +120,15 @@ shortcut_key_values! { "composing",
|
||||||
edit_mail: Key |> "Edit mail." |> Key::Char('e')
|
edit_mail: Key |> "Edit mail." |> Key::Char('e')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shortcut_key_values! { "envelope-view",
|
||||||
|
pub struct EnvelopeViewShortcuts {
|
||||||
|
reverse_thread_order: Key |> "reverse thread order" |> Key::Ctrl('r'),
|
||||||
|
toggle_mailview: Key |> "toggle mail view visibility" |> Key::Char('p'),
|
||||||
|
toggle_threadview: Key |> "toggle thread view visibility" |> Key::Char('t'),
|
||||||
|
collapse_subtree: Key |> "collapse thread branches" |> Key::Char('h'),
|
||||||
|
exit_thread: Key |> "exit thread" |> Key::Char('i'),
|
||||||
|
prev_page: Key |> "Go to previous page." |> Key::PageUp,
|
||||||
|
next_page: Key |> "Go to next page." |> Key::PageDown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue