add KEY_ESC

This commit is contained in:
silverweed 2024-11-13 11:54:12 +01:00
parent ea357d9708
commit dbe9fd7b29
3 changed files with 11 additions and 1 deletions

View file

@ -63,6 +63,7 @@ void glfw_init_key_mapping(Viewer &viewer)
viewer.glfw_key_mapping[GLFW_KEY_LEFT_SHIFT] = KEY_SHIFT;
viewer.glfw_key_mapping[GLFW_KEY_KP_ADD] = KEY_PLUS;
viewer.glfw_key_mapping[GLFW_KEY_KP_SUBTRACT] = KEY_MINUS;
viewer.glfw_key_mapping[GLFW_KEY_ESCAPE] = KEY_ESC;
}
internal
@ -165,7 +166,7 @@ void run_main_loop(GLFWwindow *window, Arena *arena, App_State &app)
app.inspected_file.size = file_size(app.inspected_file.stream);
}
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS || glfwWindowShouldClose(window)) {
if ((app.user_input.key_state[KEY_ESC] & KEY_STATE_IS_DOWN) || glfwWindowShouldClose(window)) {
app.should_quit = true;
break;
}

View file

@ -295,6 +295,9 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthStretch, sizes.WindowWidth * 0.25);
ImGui::TableNextColumn();
// Hex view
// -------------------------------
// Absolute byte offset into inspected_file.mem that has been hovered last.
// 0 means "invalid", otherwise the actual offset is `hovered_off - 1`.
u64 hovered_off = app.viewer.mem_edit.MouseHovered * (app.viewer.mem_edit.MouseHoveredAddr + 1);
@ -307,6 +310,9 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
ImGui::TableNextColumn();
const ImGuiColorEditFlags edit_flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoLabel;
// Sections legend
// -------------------------------
// Unique sections: just display a button that jumps to the start of it and show their size
for (u32 i = 0; i < Sec_COUNT; ++i) {
Byte_Range range = get_section_range(app, static_cast<Section_Id>(i));
@ -378,6 +384,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
ImGui::SameLine();
ImGui::Text("%s", to_pretty_size(scratch.arena, app.rndata.tot_page_list_size).c());
// Misc information
// -------------------------------
ImGui::Separator();
String8 root_version_str = push_str8f(scratch.arena, "%u.%u.%u",
@ -410,6 +417,7 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
}
ImGui::Checkbox("Highlight ZSTD headers", &app.viewer.highlight_zstd_headers);
// Hover info
// ---------------------------------
ImGui::Separator();

View file

@ -11,6 +11,7 @@ enum Input_Key {
KEY_SHIFT,
KEY_PLUS,
KEY_MINUS,
KEY_ESC,
KEY_COUNT
};