listing: do not clear selection after action
Clear selection only when Escape is pressed, not after action is completed. The user might want to perform further actions on the selection. Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>pull/341/head
parent
7952006870
commit
61a0c3c27f
|
@ -467,6 +467,9 @@ you can use the following commands on entries and selections to modify them:
|
||||||
and
|
and
|
||||||
.Ic ignore_tags
|
.Ic ignore_tags
|
||||||
for how to set tag colors and tag visibility)
|
for how to set tag colors and tag visibility)
|
||||||
|
You can clear the selection with the
|
||||||
|
.Aq Esc
|
||||||
|
key.
|
||||||
.Sh PAGER
|
.Sh PAGER
|
||||||
You can open an e-mail entry by pressing
|
You can open an e-mail entry by pressing
|
||||||
.ShortcutPeriod Enter listing open_entry
|
.ShortcutPeriod Enter listing open_entry
|
||||||
|
|
|
@ -1661,14 +1661,21 @@ impl Component for Listing {
|
||||||
| Action::Listing(a @ ListingAction::Tag(_)) => {
|
| Action::Listing(a @ ListingAction::Tag(_)) => {
|
||||||
let focused = self.component.get_focused_items(context);
|
let focused = self.component.get_focused_items(context);
|
||||||
self.component.perform_action(context, focused, a);
|
self.component.perform_action(context, focused, a);
|
||||||
|
let should_be_unselected: bool = matches!(
|
||||||
|
a,
|
||||||
|
ListingAction::Delete
|
||||||
|
| ListingAction::MoveTo(_)
|
||||||
|
| ListingAction::MoveToOtherAccount(_, _)
|
||||||
|
);
|
||||||
let mut row_updates: SmallVec<[EnvelopeHash; 8]> = SmallVec::new();
|
let mut row_updates: SmallVec<[EnvelopeHash; 8]> = SmallVec::new();
|
||||||
for (k, v) in self.component.selection().iter_mut() {
|
for (k, v) in self.component.selection().iter_mut() {
|
||||||
if *v {
|
if *v {
|
||||||
*v = false;
|
*v = !should_be_unselected;
|
||||||
row_updates.push(*k);
|
row_updates.push(*k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.component.row_updates().extend(row_updates);
|
self.component.row_updates().extend(row_updates);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
@ -1867,6 +1874,7 @@ impl Component for Listing {
|
||||||
&& self.component.modifier_command().is_some() =>
|
&& self.component.modifier_command().is_some() =>
|
||||||
{
|
{
|
||||||
self.component.set_modifier_command(Some(Modifier::Union));
|
self.component.set_modifier_command(Some(Modifier::Union));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key)
|
UIEvent::Input(ref key)
|
||||||
if !self.component.unfocused()
|
if !self.component.unfocused()
|
||||||
|
@ -1875,6 +1883,7 @@ impl Component for Listing {
|
||||||
{
|
{
|
||||||
self.component
|
self.component
|
||||||
.set_modifier_command(Some(Modifier::Difference));
|
.set_modifier_command(Some(Modifier::Difference));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key)
|
UIEvent::Input(ref key)
|
||||||
if !self.component.unfocused()
|
if !self.component.unfocused()
|
||||||
|
@ -1885,12 +1894,14 @@ impl Component for Listing {
|
||||||
{
|
{
|
||||||
self.component
|
self.component
|
||||||
.set_modifier_command(Some(Modifier::Intersection));
|
.set_modifier_command(Some(Modifier::Intersection));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key)
|
UIEvent::Input(ref key)
|
||||||
if self.component.unfocused()
|
if self.component.unfocused()
|
||||||
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["next_entry"]) =>
|
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["next_entry"]) =>
|
||||||
{
|
{
|
||||||
self.component.next_entry(context);
|
self.component.next_entry(context);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key)
|
UIEvent::Input(ref key)
|
||||||
if self.component.unfocused()
|
if self.component.unfocused()
|
||||||
|
@ -1899,9 +1910,26 @@ impl Component for Listing {
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
self.component.prev_entry(context);
|
self.component.prev_entry(context);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
_ => {}
|
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt(''))
|
||||||
|
if !self.component.unfocused() =>
|
||||||
|
{
|
||||||
|
// Clear selection.
|
||||||
|
let row_updates: SmallVec<[EnvelopeHash; 8]> =
|
||||||
|
self.component.get_focused_items(context);
|
||||||
|
for h in &row_updates {
|
||||||
|
if let Some(val) = self.component.selection().get_mut(h) {
|
||||||
|
*val = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.component.row_updates().extend(row_updates);
|
||||||
|
self.component.set_dirty(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_ => return false,
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else if self.focus == ListingFocus::Menu {
|
} else if self.focus == ListingFocus::Menu {
|
||||||
match *event {
|
match *event {
|
||||||
|
|
|
@ -2019,21 +2019,6 @@ impl Component for CompactListing {
|
||||||
UIEvent::Resize => {
|
UIEvent::Resize => {
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Esc)
|
|
||||||
if !self.unfocused()
|
|
||||||
&& self
|
|
||||||
.rows
|
|
||||||
.selection
|
|
||||||
.values()
|
|
||||||
.cloned()
|
|
||||||
.any(std::convert::identity) =>
|
|
||||||
{
|
|
||||||
for v in self.rows.selection.values_mut() {
|
|
||||||
*v = false;
|
|
||||||
}
|
|
||||||
self.set_dirty(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
UIEvent::Input(Key::Esc) if !self.unfocused() && !self.filter_term.is_empty() => {
|
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_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
|
||||||
self.refresh_mailbox(context, false);
|
self.refresh_mailbox(context, false);
|
||||||
|
|
|
@ -1468,19 +1468,6 @@ impl Component for ConversationsListing {
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
UIEvent::Input(Key::Esc)
|
|
||||||
if !self.unfocused()
|
|
||||||
&& self
|
|
||||||
.rows
|
|
||||||
.selection
|
|
||||||
.values()
|
|
||||||
.cloned()
|
|
||||||
.any(std::convert::identity) =>
|
|
||||||
{
|
|
||||||
self.rows.clear_selection();
|
|
||||||
self.set_dirty(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Char(''))
|
UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Char(''))
|
||||||
if !self.unfocused() && !&self.filter_term.is_empty() =>
|
if !self.unfocused() && !&self.filter_term.is_empty() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1718,19 +1718,6 @@ impl Component for PlainListing {
|
||||||
UIEvent::Resize => {
|
UIEvent::Resize => {
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Esc)
|
|
||||||
if !self.unfocused()
|
|
||||||
&& self
|
|
||||||
.rows
|
|
||||||
.selection
|
|
||||||
.values()
|
|
||||||
.cloned()
|
|
||||||
.any(std::convert::identity) =>
|
|
||||||
{
|
|
||||||
self.rows.clear_selection();
|
|
||||||
self.set_dirty(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
UIEvent::Input(Key::Esc) if !self.unfocused() && !self.filter_term.is_empty() => {
|
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_coordinates((self.new_cursor_pos.0, self.new_cursor_pos.1));
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
|
|
|
@ -1585,21 +1585,6 @@ impl Component for ThreadListing {
|
||||||
UIEvent::Resize => {
|
UIEvent::Resize => {
|
||||||
self.set_dirty(true);
|
self.set_dirty(true);
|
||||||
}
|
}
|
||||||
UIEvent::Input(Key::Esc)
|
|
||||||
if !self.unfocused()
|
|
||||||
&& self
|
|
||||||
.rows
|
|
||||||
.selection
|
|
||||||
.values()
|
|
||||||
.cloned()
|
|
||||||
.any(std::convert::identity) =>
|
|
||||||
{
|
|
||||||
for v in self.rows.selection.values_mut() {
|
|
||||||
*v = false;
|
|
||||||
}
|
|
||||||
self.set_dirty(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key)
|
UIEvent::Input(ref key)
|
||||||
if !self.unfocused()
|
if !self.unfocused()
|
||||||
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["select_entry"]) =>
|
&& shortcut!(key == shortcuts[Shortcuts::LISTING]["select_entry"]) =>
|
||||||
|
|
Loading…
Reference in New Issue