internal u32 mem_edit_bg_color_fn(const u8 *data, u64 off, const void *user_data) { const RNTuple_Info *ntinfo = reinterpret_cast(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) { MemoryEditor mem_edit; // mem_edit.ReadOnly = true; mem_edit.Cols = 32; mem_edit.BgColorFn = mem_edit_bg_color_fn; mem_edit.BgColorFnUserData = &ntpl_info; return mem_edit; } internal void update_and_render(Arena *arena, App_State &app, f32 delta_time) { (void)delta_time; ImGui::SetNextWindowPos({ 0, 0 }); ImGui::SetNextWindowSize({ (f32)app.win_data.width, (f32)app.win_data.height }); Temp scratch = temp_begin(arena); defer { temp_end(scratch); }; const u64 inspected_max_size = 2048; u64 text_buf_size = min(app.inspected_file_size * 2, inspected_max_size); char *text_buf = arena_push_array_no_zero(scratch.arena, text_buf_size + 1); // Convert file content to human readable // @Speed: maybe do this only when the file changes for (u64 i = 0; i < text_buf_size / 2; ++i) sprintf(&text_buf[2 * i], "%02X", app.inspected_fmem[i]); text_buf[text_buf_size] = 0; if (ImGui::Begin("main")) { 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); mem_edit.DrawWindow("Hex View", app.inspected_fmem, app.inspected_file_size); ImGui::End(); } }