summaryrefslogtreecommitdiff
path: root/Userland/Applications/HexEditor/HexEditor.cpp
diff options
context:
space:
mode:
authorBrendan Coles <bcoles@gmail.com>2021-05-22 07:44:10 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-05-22 13:13:49 +0430
commitd1623350b5cbc5662ee6147e69d4b5e0b0cbbf6a (patch)
tree979a4fc0df5651c4a9ccf98620065e00275103cb /Userland/Applications/HexEditor/HexEditor.cpp
parentee5cf92b3dd62382e31de72a33996ce99336db5b (diff)
downloadserenity-d1623350b5cbc5662ee6147e69d4b5e0b0cbbf6a.zip
HexEditor: Add 'Select All' action
Diffstat (limited to 'Userland/Applications/HexEditor/HexEditor.cpp')
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp17
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;
}