1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:17:44 +00:00

HexEditor: Add ability to set a selection range

This commit is contained in:
Timothy Slater 2022-03-03 08:20:47 -06:00 committed by Ali Mohammad Pur
parent 151eb8606d
commit 1b70c5f605
2 changed files with 15 additions and 0 deletions

View file

@ -2,6 +2,7 @@
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
* Copyright (c) 2022, Timothy Slater <tslater2006@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -111,7 +112,19 @@ void HexEditor::set_position(size_t position)
scroll_position_into_view(position);
update_status();
}
void HexEditor::set_selection(size_t position, size_t length)
{
if (position > m_document->size() || position + length > m_document->size())
return;
m_position = position;
m_cursor_at_low_nibble = false;
m_selection_start = position;
m_selection_end = position + length;
reset_cursor_blink_state();
scroll_position_into_view(position);
update_status();
}
bool HexEditor::save_as(NonnullRefPtr<Core::File> new_file)
{
if (m_document->type() == HexDocument::Type::File) {