mirror of https://github.com/encounter/objdiff.git
Add scroll hotkeys
This commit is contained in:
parent
e448630f36
commit
76f1952cff
|
@ -1,4 +1,4 @@
|
||||||
use egui::{Context, Key, PointerButton};
|
use egui::{style::ScrollAnimation, vec2, Context, Key, PointerButton};
|
||||||
|
|
||||||
pub fn enter_pressed(ctx: &Context) -> bool {
|
pub fn enter_pressed(ctx: &Context) -> bool {
|
||||||
ctx.input_mut(|i| i.key_pressed(Key::Enter) || i.pointer.button_pressed(PointerButton::Extra2))
|
ctx.input_mut(|i| i.key_pressed(Key::Enter) || i.pointer.button_pressed(PointerButton::Extra2))
|
||||||
|
@ -9,3 +9,36 @@ pub fn back_pressed(ctx: &Context) -> bool {
|
||||||
i.key_pressed(Key::Backspace) || i.pointer.button_pressed(PointerButton::Extra1)
|
i.key_pressed(Key::Backspace) || i.pointer.button_pressed(PointerButton::Extra1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn up_pressed(ctx: &Context) -> bool {
|
||||||
|
ctx.input_mut(|i| i.key_pressed(Key::ArrowUp) || i.key_pressed(Key::W))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn down_pressed(ctx: &Context) -> bool {
|
||||||
|
ctx.input_mut(|i| i.key_pressed(Key::ArrowDown) || i.key_pressed(Key::S))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page_up_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::PageUp)) }
|
||||||
|
|
||||||
|
pub fn page_down_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::PageDown)) }
|
||||||
|
|
||||||
|
pub fn home_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::Home)) }
|
||||||
|
|
||||||
|
pub fn end_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::End)) }
|
||||||
|
|
||||||
|
pub fn check_scroll_hotkeys(ui: &mut egui::Ui) {
|
||||||
|
let ui_height = ui.available_rect_before_wrap().height();
|
||||||
|
if up_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, ui_height / 10.0), ScrollAnimation::none());
|
||||||
|
} else if down_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, -ui_height / 10.0), ScrollAnimation::none());
|
||||||
|
} else if page_up_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, ui_height), ScrollAnimation::none());
|
||||||
|
} else if page_down_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, -ui_height), ScrollAnimation::none());
|
||||||
|
} else if home_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, f32::INFINITY), ScrollAnimation::none());
|
||||||
|
} else if end_pressed(ui.ctx()) {
|
||||||
|
ui.scroll_with_delta_animation(vec2(0.0, -f32::INFINITY), ScrollAnimation::none());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -179,6 +179,8 @@ fn data_table_ui(
|
||||||
let left_diffs = left_section.map(|(_, section)| split_diffs(§ion.data_diff));
|
let left_diffs = left_section.map(|(_, section)| split_diffs(§ion.data_diff));
|
||||||
let right_diffs = right_section.map(|(_, section)| split_diffs(§ion.data_diff));
|
let right_diffs = right_section.map(|(_, section)| split_diffs(§ion.data_diff));
|
||||||
|
|
||||||
|
hotkeys::check_scroll_hotkeys(ui);
|
||||||
|
|
||||||
render_table(ui, available_width, 2, config.code_font.size, total_rows, |row, column| {
|
render_table(ui, available_width, 2, config.code_font.size, total_rows, |row, column| {
|
||||||
let i = row.index();
|
let i = row.index();
|
||||||
let address = i * BYTES_PER_ROW;
|
let address = i * BYTES_PER_ROW;
|
||||||
|
|
|
@ -235,6 +235,8 @@ pub fn extab_diff_ui(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hotkeys::check_scroll_hotkeys(ui);
|
||||||
|
|
||||||
// Table
|
// Table
|
||||||
render_strips(ui, available_width, 2, |ui, column| {
|
render_strips(ui, available_width, 2, |ui, column| {
|
||||||
if column == 0 {
|
if column == 0 {
|
||||||
|
|
|
@ -435,6 +435,7 @@ fn asm_table_ui(
|
||||||
};
|
};
|
||||||
if left_len.is_some() && right_len.is_some() {
|
if left_len.is_some() && right_len.is_some() {
|
||||||
// Joint view
|
// Joint view
|
||||||
|
hotkeys::check_scroll_hotkeys(ui);
|
||||||
render_table(
|
render_table(
|
||||||
ui,
|
ui,
|
||||||
available_width,
|
available_width,
|
||||||
|
|
|
@ -649,6 +649,8 @@ pub fn symbol_list_ui(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hotkeys::check_scroll_hotkeys(ui);
|
||||||
|
|
||||||
ui.scope(|ui| {
|
ui.scope(|ui| {
|
||||||
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
ui.style_mut().override_text_style = Some(egui::TextStyle::Monospace);
|
||||||
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
|
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
|
||||||
|
|
Loading…
Reference in New Issue