Skip to content

Commit

Permalink
workaround crossterm bug: crossterm-rs/crossterm#421
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Apr 21, 2020
1 parent ac8cae6 commit 72a1f94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/components/changes.rs
Expand Up @@ -237,7 +237,8 @@ impl Component for ChangesComponent {
}
true
}
keys::STATUS_RESET_FILE => {
keys::STATUS_RESET_FILE_1
| keys::STATUS_RESET_FILE_2 => {
self.is_working_dir
&& self.dispatch_reset_workdir()
}
Expand Down
13 changes: 11 additions & 2 deletions src/keys.rs
Expand Up @@ -7,12 +7,17 @@ const fn no_mod(code: KeyCode) -> KeyEvent {
}
}

const fn with_mod(
code: KeyCode,
modifiers: KeyModifiers,
) -> KeyEvent {
KeyEvent { code, modifiers }
}

pub const FOCUS_WORKDIR: KeyEvent = no_mod(KeyCode::Char('1'));
pub const FOCUS_STAGE: KeyEvent = no_mod(KeyCode::Char('2'));
pub const FOCUS_RIGHT: KeyEvent = no_mod(KeyCode::Right);
pub const FOCUS_LEFT: KeyEvent = no_mod(KeyCode::Left);
pub const STATUS_RESET_FILE: KeyEvent = no_mod(KeyCode::Char('D'));
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
pub const EXIT_1: KeyEvent = no_mod(KeyCode::Esc);
pub const EXIT_POPUP: KeyEvent = no_mod(KeyCode::Esc);
pub const EXIT_2: KeyEvent = no_mod(KeyCode::Char('q'));
Expand All @@ -21,3 +26,7 @@ pub const OPEN_COMMIT: KeyEvent = no_mod(KeyCode::Char('c'));
pub const OPEN_HELP: KeyEvent = no_mod(KeyCode::Char('h'));
pub const MOVE_UP: KeyEvent = no_mod(KeyCode::Up);
pub const MOVE_DOWN: KeyEvent = no_mod(KeyCode::Down);
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
pub const STATUS_RESET_FILE_1: KeyEvent = no_mod(KeyCode::Char('D'));
pub const STATUS_RESET_FILE_2: KeyEvent =
with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT);

0 comments on commit 72a1f94

Please sign in to comment.