1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:37:44 +00:00

HexEditor: Add 'Select All' action

This commit is contained in:
Brendan Coles 2021-05-22 07:44:10 +00:00 committed by Ali Mohammad Pur
parent ee5cf92b3d
commit d1623350b5
3 changed files with 22 additions and 4 deletions

View file

@ -558,6 +558,19 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
}
}
void HexEditor::select_all()
{
highlight(0, m_buffer.size());
set_position(0);
}
void HexEditor::highlight(int start, int end)
{
m_selection_start = start;
m_selection_end = end;
set_position(start);
}
int HexEditor::find_and_highlight(ByteBuffer& needle, int start)
{
if (m_buffer.is_empty())
@ -571,9 +584,7 @@ int HexEditor::find_and_highlight(ByteBuffer& needle, int start)
dbgln("find_and_highlight: start={} raw_offset={} relative_offset={}", start, raw_offset, relative_offset);
auto end_of_match = relative_offset + needle.size();
set_position(relative_offset);
m_selection_start = relative_offset;
m_selection_end = end_of_match;
highlight(relative_offset, end_of_match);
return end_of_match;
}