mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
HexEditor: Add ability to set a selection range
This commit is contained in:
parent
151eb8606d
commit
1b70c5f605
Notes:
sideshowbarker
2024-07-17 14:18:43 +09:00
Author: https://github.com/tslater2006 🔰
Commit: 1b70c5f605
Pull-request: https://github.com/SerenityOS/serenity/pull/12861
Reviewed-by: https://github.com/MacDue
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 15 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue