Skip to content

Commit

Permalink
added G and gg keybindings for kill signal list
Browse files Browse the repository at this point in the history
  • Loading branch information
LlinksRechts committed Dec 7, 2020
1 parent ba42921 commit 88cff32
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ pub struct App {
pub config_path: Option<PathBuf>,
}

#[cfg(target_os = "windows")]
const MAX_SIGNAL: usize = 1;
#[cfg(target_os = "linux")]
const MAX_SIGNAL: usize = 64;
#[cfg(target_os = "macos")]
const MAX_SIGNAL: usize = 31;

impl App {
pub fn reset(&mut self) {
// Reset multi
Expand Down Expand Up @@ -1056,22 +1063,9 @@ impl App {

pub fn on_page_down(&mut self) {
if self.delete_dialog_state.is_showing_dd {
let max_signal;
#[cfg(target_os = "windows")]
{
max_signal = 1;
}
#[cfg(target_os = "linux")]
{
max_signal = 64;
}
#[cfg(target_os = "macos")]
{
max_signal = 31;
}
let mut new_signal = match self.delete_dialog_state.selected_signal {
KillSignal::CANCEL => 8,
KillSignal::KILL(signal) => min(signal + 8, max_signal),
KillSignal::KILL(signal) => min(signal + 8, MAX_SIGNAL),
};
if new_signal > 31 && new_signal < 42 {
new_signal += 2;
Expand Down Expand Up @@ -1319,6 +1313,23 @@ impl App {
}
'u' => self.on_page_up(),
'd' => self.on_page_down(),
'g' => {
let mut is_first_g = true;
if let Some(second_char) = self.second_char {
if self.awaiting_second_char && second_char == 'g' {
is_first_g = false;
self.awaiting_second_char = false;
self.second_char = None;
self.skip_to_first();
}
}

if is_first_g {
self.awaiting_second_char = true;
self.second_char = Some('g');
}
}
'G' => self.skip_to_last(),
_ => {}
}
} else if self.is_config_open {
Expand Down Expand Up @@ -2124,6 +2135,8 @@ impl App {
} else if self.is_config_open {
} else if self.help_dialog_state.is_showing_help {
self.help_dialog_state.scroll_state.current_scroll_index = 0;
} else if self.delete_dialog_state.is_showing_dd {
self.delete_dialog_state.selected_signal = KillSignal::CANCEL;
}
}

Expand Down Expand Up @@ -2205,6 +2218,8 @@ impl App {
.scroll_state
.max_scroll_index
.saturating_sub(1);
} else if self.delete_dialog_state.is_showing_dd {
self.delete_dialog_state.selected_signal = KillSignal::KILL(MAX_SIGNAL);
}
}

Expand Down

0 comments on commit 88cff32

Please sign in to comment.