2024-07-10 19:47:37 +00:00
|
|
|
internal
|
2024-07-11 12:00:43 +00:00
|
|
|
u32 mem_edit_bg_color_fn(const u8 *data, u64 off, const void *user_data)
|
|
|
|
{
|
|
|
|
const RNTuple_Info *ntinfo = reinterpret_cast<const RNTuple_Info *>(user_data);
|
|
|
|
|
|
|
|
if (ntinfo->header.start <= off && off <= ntinfo->header.end())
|
|
|
|
return IM_COL32(200, 0, 50, 255);
|
|
|
|
if (ntinfo->footer.start <= off && off <= ntinfo->footer.end())
|
|
|
|
return IM_COL32(50, 0, 200, 255);
|
|
|
|
return IM_COL32(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
internal
|
|
|
|
MemoryEditor make_memory_editor(const RNTuple_Info &ntpl_info)
|
2024-07-10 19:41:48 +00:00
|
|
|
{
|
|
|
|
MemoryEditor mem_edit;
|
|
|
|
// mem_edit.ReadOnly = true;
|
|
|
|
mem_edit.Cols = 32;
|
2024-07-11 12:00:43 +00:00
|
|
|
mem_edit.BgColorFn = mem_edit_bg_color_fn;
|
|
|
|
mem_edit.BgColorFnUserData = &ntpl_info;
|
2024-07-10 19:41:48 +00:00
|
|
|
return mem_edit;
|
|
|
|
}
|
|
|
|
|
2024-07-10 19:47:37 +00:00
|
|
|
internal
|
|
|
|
void update_and_render(Arena *arena, App_State &app, f32 delta_time)
|
2024-07-10 17:38:16 +00:00
|
|
|
{
|
2024-07-11 12:00:43 +00:00
|
|
|
(void)delta_time;
|
|
|
|
|
2024-07-10 17:38:16 +00:00
|
|
|
ImGui::SetNextWindowPos({ 0, 0 });
|
|
|
|
ImGui::SetNextWindowSize({ (f32)app.win_data.width, (f32)app.win_data.height });
|
2024-07-10 18:11:42 +00:00
|
|
|
|
|
|
|
Temp scratch = temp_begin(arena);
|
|
|
|
defer { temp_end(scratch); };
|
|
|
|
|
2024-07-11 12:00:43 +00:00
|
|
|
const u64 inspected_max_size = 2048;
|
|
|
|
u64 text_buf_size = min(app.inspected_file_size * 2, inspected_max_size);
|
2024-07-10 19:41:48 +00:00
|
|
|
char *text_buf = arena_push_array_no_zero<char>(scratch.arena, text_buf_size + 1);
|
2024-07-11 12:00:43 +00:00
|
|
|
// Convert file content to human readable
|
|
|
|
// @Speed: maybe do this only when the file changes
|
2024-07-10 19:41:48 +00:00
|
|
|
for (u64 i = 0; i < text_buf_size / 2; ++i)
|
2024-07-10 20:30:49 +00:00
|
|
|
sprintf(&text_buf[2 * i], "%02X", app.inspected_fmem[i]);
|
2024-07-10 19:41:48 +00:00
|
|
|
text_buf[text_buf_size] = 0;
|
2024-07-10 18:11:42 +00:00
|
|
|
|
2024-07-10 19:41:48 +00:00
|
|
|
if (ImGui::Begin("main")) {
|
2024-07-11 12:00:43 +00:00
|
|
|
ImGui::Text("Inspecting RNTuple '%s' (%s)", app.ntpl_name,
|
|
|
|
(const char *)rntuple_description(scratch.arena, app.rntinfo->anchor));
|
|
|
|
|
|
|
|
static MemoryEditor mem_edit = make_memory_editor(*app.rntinfo);
|
2024-07-10 20:30:49 +00:00
|
|
|
mem_edit.DrawWindow("Hex View", app.inspected_fmem, app.inspected_file_size);
|
2024-07-11 12:00:43 +00:00
|
|
|
|
2024-07-10 17:38:16 +00:00
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
}
|