mirror of https://github.com/encounter/objdiff.git
Add enter and back hotkeys
This commit is contained in:
parent
123253c322
commit
acc1189150
|
@ -0,0 +1,11 @@
|
|||
use egui::{Context, Key, PointerButton};
|
||||
|
||||
pub fn enter_pressed(ctx: &Context) -> bool {
|
||||
ctx.input_mut(|i| i.key_pressed(Key::Enter) || i.pointer.button_pressed(PointerButton::Extra2))
|
||||
}
|
||||
|
||||
pub fn back_pressed(ctx: &Context) -> bool {
|
||||
ctx.input_mut(|i| {
|
||||
i.key_pressed(Key::Backspace) || i.pointer.button_pressed(PointerButton::Extra1)
|
||||
})
|
||||
}
|
|
@ -4,6 +4,7 @@ mod app;
|
|||
mod app_config;
|
||||
mod config;
|
||||
mod fonts;
|
||||
mod hotkeys;
|
||||
mod jobs;
|
||||
mod update;
|
||||
mod views;
|
||||
|
|
|
@ -7,11 +7,14 @@ use objdiff_core::{
|
|||
};
|
||||
use time::format_description;
|
||||
|
||||
use crate::views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_table},
|
||||
symbol_diff::{DiffViewAction, DiffViewNavigation, DiffViewState},
|
||||
write_text,
|
||||
use crate::{
|
||||
hotkeys,
|
||||
views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_table},
|
||||
symbol_diff::{DiffViewAction, DiffViewNavigation, DiffViewState},
|
||||
write_text,
|
||||
},
|
||||
};
|
||||
|
||||
const BYTES_PER_ROW: usize = 16;
|
||||
|
@ -224,7 +227,7 @@ pub fn data_diff_ui(
|
|||
render_header(ui, available_width, 2, |ui, column| {
|
||||
if column == 0 {
|
||||
// Left column
|
||||
if ui.button("⏴ Back").clicked() {
|
||||
if ui.button("⏴ Back").clicked() || hotkeys::back_pressed(ui.ctx()) {
|
||||
ret = Some(DiffViewAction::Navigate(DiffViewNavigation::symbol_diff()));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,13 +5,16 @@ use objdiff_core::{
|
|||
};
|
||||
use time::format_description;
|
||||
|
||||
use crate::views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_strips},
|
||||
function_diff::FunctionDiffContext,
|
||||
symbol_diff::{
|
||||
match_color_for_symbol, DiffViewAction, DiffViewNavigation, DiffViewState, SymbolRefByName,
|
||||
View,
|
||||
use crate::{
|
||||
hotkeys,
|
||||
views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_strips},
|
||||
function_diff::FunctionDiffContext,
|
||||
symbol_diff::{
|
||||
match_color_for_symbol, DiffViewAction, DiffViewNavigation, DiffViewState,
|
||||
SymbolRefByName, View,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -136,7 +139,7 @@ pub fn extab_diff_ui(
|
|||
if column == 0 {
|
||||
// Left column
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("⏴ Back").clicked() {
|
||||
if ui.button("⏴ Back").clicked() || hotkeys::back_pressed(ui.ctx()) {
|
||||
ret = Some(DiffViewAction::Navigate(DiffViewNavigation::symbol_diff()));
|
||||
}
|
||||
ui.separator();
|
||||
|
|
|
@ -14,12 +14,15 @@ use objdiff_core::{
|
|||
};
|
||||
use time::format_description;
|
||||
|
||||
use crate::views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_strips, render_table},
|
||||
symbol_diff::{
|
||||
match_color_for_symbol, symbol_list_ui, DiffViewAction, DiffViewNavigation, DiffViewState,
|
||||
SymbolDiffContext, SymbolFilter, SymbolRefByName, SymbolViewState, View,
|
||||
use crate::{
|
||||
hotkeys,
|
||||
views::{
|
||||
appearance::Appearance,
|
||||
column_layout::{render_header, render_strips, render_table},
|
||||
symbol_diff::{
|
||||
match_color_for_symbol, symbol_list_ui, DiffViewAction, DiffViewNavigation,
|
||||
DiffViewState, SymbolDiffContext, SymbolFilter, SymbolRefByName, SymbolViewState, View,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -675,7 +678,7 @@ pub fn function_diff_ui(
|
|||
if column == 0 {
|
||||
// Left column
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("⏴ Back").clicked() {
|
||||
if ui.button("⏴ Back").clicked() || hotkeys::back_pressed(ui.ctx()) {
|
||||
ret = Some(DiffViewAction::Navigate(DiffViewNavigation::symbol_diff()));
|
||||
}
|
||||
ui.separator();
|
||||
|
|
|
@ -15,6 +15,7 @@ use regex::{Regex, RegexBuilder};
|
|||
|
||||
use crate::{
|
||||
app::AppStateRef,
|
||||
hotkeys,
|
||||
jobs::{
|
||||
create_scratch::{start_create_scratch, CreateScratchConfig, CreateScratchResult},
|
||||
objdiff::{BuildStatus, ObjDiffResult},
|
||||
|
@ -534,7 +535,7 @@ fn symbol_ui(
|
|||
ret = Some(DiffViewAction::Navigate(result));
|
||||
}
|
||||
});
|
||||
if response.clicked() {
|
||||
if response.clicked() || (selected && hotkeys::enter_pressed(ui.ctx())) {
|
||||
if let Some(section) = section {
|
||||
match section.kind {
|
||||
ObjSectionKind::Code => {
|
||||
|
|
Loading…
Reference in New Issue