diff options
author | Brendan Coles <bcoles@gmail.com> | 2021-05-22 07:44:10 +0000 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-05-22 13:13:49 +0430 |
commit | d1623350b5cbc5662ee6147e69d4b5e0b0cbbf6a (patch) | |
tree | 979a4fc0df5651c4a9ccf98620065e00275103cb /Userland/Applications/HexEditor/HexEditor.cpp | |
parent | ee5cf92b3dd62382e31de72a33996ce99336db5b (diff) | |
download | serenity-d1623350b5cbc5662ee6147e69d4b5e0b0cbbf6a.zip |
HexEditor: Add 'Select All' action
Diffstat (limited to 'Userland/Applications/HexEditor/HexEditor.cpp')
-rw-r--r-- | Userland/Applications/HexEditor/HexEditor.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index bf0dab3738..6304cbb8ee 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -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; } |