Skip to content

Commit

Permalink
Goto address in memory editor
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jun 9, 2024
1 parent 11b7f36 commit b8189af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions platforms/desktop-shared/imgui/memory_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ MemEditor::MemEditor()
m_gray_out_zeros = true;
m_preview_data_type = 0;
m_preview_endianess = 0;
m_jump_to_address = -1;
}

MemEditor::~MemEditor()
Expand Down Expand Up @@ -233,6 +234,13 @@ void MemEditor::Draw(uint8_t* mem_data, int mem_size, int base_display_addr)
}
}

if (m_jump_to_address >= 0 && m_jump_to_address < mem_size)
{
ImGui::SetScrollY((m_jump_to_address / m_bytes_per_row) * character_size.y);
m_selection_start = m_selection_end = m_jump_to_address;
m_jump_to_address = -1;
}

ImGui::EndTable();

}
Expand Down Expand Up @@ -316,8 +324,7 @@ void MemEditor::HandleSelection(int address, int row)

void MemEditor::JumpToAddress(int address)
{
ImVec2 character_size = ImGui::CalcTextSize("0");
ImGui::SetScrollY((address / m_bytes_per_row) * character_size.y);
m_jump_to_address = address;
}

void MemEditor::DrawCursors(int mem_size, int base_display_addr)
Expand Down
1 change: 1 addition & 0 deletions platforms/desktop-shared/imgui/memory_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class MemEditor
bool m_gray_out_zeros;
int m_preview_data_type;
int m_preview_endianess;
int m_jump_to_address;
};

#endif /* MEM_EDITOR_H */

0 comments on commit b8189af

Please sign in to comment.