ui: clear selection with Esc

This commit is contained in:
Manos Pitsidianakis 2020-02-10 00:10:19 +02:00
parent e26ed83331
commit aab6b02db2
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710
4 changed files with 36 additions and 3 deletions

View File

@ -522,9 +522,6 @@ impl ListingTrait for CompactListing {
self.filtered_order.clear();
self.filter_term = filter_term.to_string();
self.row_updates.clear();
for v in self.selection.values_mut() {
*v = false;
}
let account = &context.accounts[self.cursor_pos.0];
match account.search(&self.filter_term, self.sort, self.cursor_pos.1) {
@ -1343,6 +1340,16 @@ impl Component for CompactListing {
UIEvent::Resize => {
self.dirty = true;
}
UIEvent::Input(Key::Esc)
if !self.unfocused
&& self.selection.values().cloned().any(std::convert::identity) =>
{
for v in self.selection.values_mut() {
*v = false;
}
self.dirty = true;
return true;
}
UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => {
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
self.refresh_mailbox(context, false);

View File

@ -100,6 +100,7 @@ impl MailListingTrait for ConversationsListing {
from: crate::conf::value(context, "mail.listing.conversations.from"),
date: crate::conf::value(context, "mail.listing.conversations.date"),
padding: crate::conf::value(context, "mail.listing.conversations.padding"),
selected: crate::conf::value(context, "mail.listing.compact.selected"),
unseen: crate::conf::value(context, "mail.listing.conversations.unseen"),
unseen_padding: crate::conf::value(
context,
@ -196,6 +197,10 @@ impl ListingTrait for ConversationsListing {
let fg_color = if thread.unseen() > 0 {
self.color_cache.unseen.fg
} else if self.cursor_pos.2 == idx {
self.color_cache.highlighted.fg
} else if self.selection[&thread_hash] {
self.color_cache.selected.fg
} else {
self.color_cache.theme_default.fg
};
@ -1294,6 +1299,16 @@ impl Component for ConversationsListing {
}
_ => {}
},
UIEvent::Input(Key::Esc)
if !self.unfocused
&& self.selection.values().cloned().any(std::convert::identity) =>
{
for v in self.selection.values_mut() {
*v = false;
}
self.dirty = true;
return true;
}
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Char(''))
if !self.unfocused && !&self.filter_term.is_empty() =>
{

View File

@ -1171,6 +1171,16 @@ impl Component for PlainListing {
UIEvent::Resize => {
self.dirty = true;
}
UIEvent::Input(Key::Esc)
if !self.unfocused
&& self.selection.values().cloned().any(std::convert::identity) =>
{
for v in self.selection.values_mut() {
*v = false;
}
self.dirty = true;
return true;
}
UIEvent::Input(Key::Esc) if !self.unfocused && !self.filter_term.is_empty() => {
self.set_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
self.set_dirty(true);

View File

@ -527,6 +527,7 @@ impl Component for ThreadListing {
if self.length == 0 && self.dirty {
clear_area(grid, area, self.color_cache.theme_default);
context.dirty_areas.push_back(area);
return;
}
/* Render the mail body in a pager, basically copy what HSplit does */