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