simplify key bindings further

This commit is contained in:
Stephan Dilly 2020-08-29 00:24:34 +02:00
parent 5445594018
commit 19177ec9bb
7 changed files with 14 additions and 41 deletions

View File

@ -22,7 +22,6 @@
exit: ( code: Char('c'), modifiers: ( bits: 2,),),
exit_popup: ( code: Esc, modifiers: ( bits: 0,),),
close_msg: ( code: Enter, modifiers: ( bits: 0,),),
open_commit: ( code: Char('c'), modifiers: ( bits: 0,),),
open_commit_editor: ( code: Char('E'), modifiers: ( bits: 0,),),
open_help: ( code: F(1), modifiers: ( bits: 0,),),
@ -43,7 +42,6 @@
edit_file: ( code: Char('I'), modifiers: ( bits: 0,),),
status_toggle_item: ( code: Enter, modifiers: ( bits: 0,),),
status_stage_all: ( code: Char('a'), modifiers: ( bits: 0,),),
status_reset_item: ( code: Char('U'), modifiers: ( bits: 0,),),
@ -53,12 +51,10 @@
stashing_toggle_untracked: ( code: Char('u'), modifiers: ( bits: 0,),),
stashing_toggle_index: ( code: Char('m'), modifiers: ( bits: 0,),),
stash_apply: ( code: Enter, modifiers: ( bits: 0,),),
stash_open: ( code: Char('l'), modifiers: ( bits: 0,),),
stash_drop: ( code: Char('D'), modifiers: ( bits: 0,),),
cmd_bar_toggle: ( code: Char('.'), modifiers: ( bits: 0,),),
log_commit_details: ( code: Enter, modifiers: ( bits: 0,),),
log_tag_commit: ( code: Char('t'), modifiers: ( bits: 0,),),
commit_amend: ( code: Char('A'), modifiers: ( bits: 0,),),
copy: ( code: Char('y'), modifiers: ( bits: 0,),),

View File

@ -267,7 +267,7 @@ impl Component for ChangesComponent {
.borrow_mut()
.push_back(InternalEvent::OpenCommit);
Ok(true)
} else if e == self.key_config.status_toggle_item {
} else if e == self.key_config.enter {
try_or_popup!(
self,
"staging error:",

View File

@ -73,7 +73,7 @@ impl Component for MsgComponent {
fn event(&mut self, ev: Event) -> Result<bool> {
if self.visible {
if let Event::Key(e) = ev {
if e == self.key_config.close_msg {
if e == self.key_config.enter {
self.hide();
}
}

View File

@ -32,7 +32,6 @@ pub struct KeyConfig {
pub focus_below: KeyEvent,
pub exit: KeyEvent,
pub exit_popup: KeyEvent,
pub close_msg: KeyEvent,
pub open_commit: KeyEvent,
pub open_commit_editor: KeyEvent,
pub open_help: KeyEvent,
@ -49,17 +48,14 @@ pub struct KeyConfig {
pub enter: KeyEvent,
pub edit_file: KeyEvent,
pub status_stage_all: KeyEvent,
pub status_toggle_item: KeyEvent,
pub status_reset_item: KeyEvent,
pub status_ignore_file: KeyEvent,
pub stashing_save: KeyEvent,
pub stashing_toggle_untracked: KeyEvent,
pub stashing_toggle_index: KeyEvent,
pub stash_apply: KeyEvent,
pub stash_open: KeyEvent,
pub stash_drop: KeyEvent,
pub cmd_bar_toggle: KeyEvent,
pub log_commit_details: KeyEvent,
pub log_tag_commit: KeyEvent,
pub commit_amend: KeyEvent,
pub copy: KeyEvent,
@ -84,7 +80,6 @@ impl Default for KeyConfig {
focus_below: KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::empty()},
exit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::CONTROL},
exit_popup: KeyEvent { code: KeyCode::Esc, modifiers: KeyModifiers::empty()},
close_msg: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
open_commit: KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::empty()},
open_commit_editor: KeyEvent { code: KeyCode::Char('e'), modifiers:KeyModifiers::CONTROL},
open_help: KeyEvent { code: KeyCode::Char('h'), modifiers: KeyModifiers::empty()},
@ -100,18 +95,15 @@ impl Default for KeyConfig {
shift_down: KeyEvent { code: KeyCode::Down, modifiers: KeyModifiers::SHIFT},
enter: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
edit_file: KeyEvent { code: KeyCode::Char('e'), modifiers: KeyModifiers::empty()},
status_toggle_item: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
status_stage_all: KeyEvent { code: KeyCode::Char('a'), modifiers: KeyModifiers::empty()},
status_reset_item: KeyEvent { code: KeyCode::Char('D'), modifiers: KeyModifiers::SHIFT},
status_ignore_file: KeyEvent { code: KeyCode::Char('i'), modifiers: KeyModifiers::empty()},
stashing_save: KeyEvent { code: KeyCode::Char('s'), modifiers: KeyModifiers::empty()},
stashing_toggle_untracked: KeyEvent { code: KeyCode::Char('u'), modifiers: KeyModifiers::empty()},
stashing_toggle_index: KeyEvent { code: KeyCode::Char('i'), modifiers: KeyModifiers::empty()},
stash_apply: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
stash_open: KeyEvent { code: KeyCode::Right, modifiers: KeyModifiers::empty()},
stash_drop: KeyEvent { code: KeyCode::Char('D'), modifiers: KeyModifiers::SHIFT},
cmd_bar_toggle: KeyEvent { code: KeyCode::Char('.'), modifiers: KeyModifiers::empty()},
log_commit_details: KeyEvent { code: KeyCode::Enter, modifiers: KeyModifiers::empty()},
log_tag_commit: KeyEvent { code: KeyCode::Char('t'), modifiers: KeyModifiers::empty()},
commit_amend: KeyEvent { code: KeyCode::Char('a'), modifiers: KeyModifiers::CONTROL},
copy: KeyEvent { code: KeyCode::Char('y'), modifiers: KeyModifiers::empty()},

View File

@ -253,10 +253,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!(
"Add hunk [{}]",
get_hint(key_config.status_toggle_item),
),
format!("Add hunk [{}]", get_hint(key_config.enter),),
"adds selected hunk to stage",
CMD_GROUP_DIFF,
)
@ -277,10 +274,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!(
"Remove hunk [{}]",
get_hint(key_config.close_msg),
),
format!("Remove hunk [{}]", get_hint(key_config.enter),),
"removes selected hunk from stage",
CMD_GROUP_DIFF,
)
@ -294,7 +288,7 @@ pub mod commands {
}
pub fn close_msg(key_config: &SharedKeyConfig) -> CommandText {
CommandText::new(
format!("Close [{}]", get_hint(key_config.close_msg),),
format!("Close [{}]", get_hint(key_config.enter),),
"close msg popup (e.g msg)",
CMD_GROUP_GENERAL,
)
@ -379,10 +373,7 @@ pub mod commands {
}
pub fn stage_item(key_config: &SharedKeyConfig) -> CommandText {
CommandText::new(
format!(
"Stage Item [{}]",
get_hint(key_config.stash_apply),
),
format!("Stage Item [{}]", get_hint(key_config.enter),),
"stage currently selected file or entire path",
CMD_GROUP_CHANGES,
)
@ -399,10 +390,7 @@ pub mod commands {
}
pub fn unstage_item(key_config: &SharedKeyConfig) -> CommandText {
CommandText::new(
format!(
"Unstage Item [{}]",
get_hint(key_config.stash_apply),
),
format!("Unstage Item [{}]", get_hint(key_config.enter),),
"unstage currently selected file or entire path",
CMD_GROUP_CHANGES,
)
@ -467,7 +455,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!("Confirm [{}]", get_hint(key_config.close_msg),),
format!("Confirm [{}]", get_hint(key_config.enter),),
"resets the file in question",
CMD_GROUP_GENERAL,
)
@ -509,7 +497,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!("Stash [{}]", get_hint(key_config.close_msg),),
format!("Stash [{}]", get_hint(key_config.enter),),
"save files to stash",
CMD_GROUP_STASHING,
)
@ -518,7 +506,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!("Apply [{}]", get_hint(key_config.stash_apply),),
format!("Apply [{}]", get_hint(key_config.enter),),
"apply selected stash",
CMD_GROUP_STASHES,
)
@ -545,10 +533,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!(
"Details [{}]",
get_hint(key_config.log_commit_details),
),
format!("Details [{}]", get_hint(key_config.enter),),
"open details of selected commit",
CMD_GROUP_LOG,
)
@ -575,7 +560,7 @@ pub mod commands {
key_config: &SharedKeyConfig,
) -> CommandText {
CommandText::new(
format!("Tag [{}]", get_hint(key_config.close_msg),),
format!("Tag [{}]", get_hint(key_config.enter),),
"tag commit",
CMD_GROUP_LOG,
)

View File

@ -200,7 +200,7 @@ impl Component for Revlog {
self.update()?;
return Ok(true);
} else if let Event::Key(k) = ev {
if k == self.key_config.log_commit_details {
if k == self.key_config.enter {
self.commit_details.toggle_visible()?;
self.update()?;
return Ok(true);

View File

@ -149,7 +149,7 @@ impl Component for StashList {
}
if let Event::Key(k) = ev {
if k == self.key_config.stash_apply {
if k == self.key_config.enter {
self.apply_stash()
} else if k == self.key_config.stash_drop {
self.drop_stash()