Skip to content

Commit 98e971d

Browse files
committed
Add hotkeys to change target and base functions
1 parent 4616058 commit 98e971d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

objdiff-gui/src/hotkeys.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,15 @@ const SYMBOL_FILTER_SHORTCUT: KeyboardShortcut = KeyboardShortcut::new(Modifiers
9292
pub fn consume_symbol_filter_shortcut(ctx: &Context) -> bool {
9393
ctx.input_mut(|i| i.consume_shortcut(&SYMBOL_FILTER_SHORTCUT))
9494
}
95+
96+
const CHANGE_TARGET_SHORTCUT: KeyboardShortcut = KeyboardShortcut::new(Modifiers::CTRL, Key::T);
97+
98+
pub fn consume_change_target_shortcut(ctx: &Context) -> bool {
99+
ctx.input_mut(|i| i.consume_shortcut(&CHANGE_TARGET_SHORTCUT))
100+
}
101+
102+
const CHANGE_BASE_SHORTCUT: KeyboardShortcut = KeyboardShortcut::new(Modifiers::CTRL, Key::B);
103+
104+
pub fn consume_change_base_shortcut(ctx: &Context) -> bool {
105+
ctx.input_mut(|i| i.consume_shortcut(&CHANGE_BASE_SHORTCUT))
106+
}

objdiff-gui/src/views/function_diff.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,10 +714,11 @@ pub fn function_diff_ui(
714714
.color(appearance.highlight_color),
715715
);
716716
if right_ctx.map_or(false, |m| m.has_symbol())
717-
&& ui
717+
&& (ui
718718
.button("Change target")
719719
.on_hover_text_at_pointer("Choose a different symbol to use as the target")
720720
.clicked()
721+
|| hotkeys::consume_change_target_shortcut(ui.ctx()))
721722
{
722723
if let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref() {
723724
ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone()));
@@ -791,6 +792,7 @@ pub fn function_diff_ui(
791792
"Choose a different symbol to use as the base",
792793
)
793794
.clicked()
795+
|| hotkeys::consume_change_base_shortcut(ui.ctx())
794796
{
795797
if let Some(symbol_ref) = state.symbol_state.left_symbol.as_ref() {
796798
ret = Some(DiffViewAction::SelectingRight(symbol_ref.clone()));

0 commit comments

Comments
 (0)