mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
HexEditor: Added fill selection action.
Added the ability to fill the current selection with a given byte.
This commit is contained in:
parent
f947353a56
commit
c77fe5161c
Notes:
sideshowbarker
2024-07-19 11:31:43 +09:00
Author: https://github.com/xeons
Commit: c77fe5161c
Pull-request: https://github.com/SerenityOS/serenity/pull/689
Reviewed-by: https://github.com/awesomekling
3 changed files with 23 additions and 0 deletions
|
@ -44,6 +44,20 @@ void HexEditor::set_buffer(const ByteBuffer& buffer)
|
|||
update_status();
|
||||
}
|
||||
|
||||
void HexEditor::fill_selection(u8 fill_byte)
|
||||
{
|
||||
if (m_selection_start == -1 || m_selection_end == -1 || (m_selection_end - m_selection_start) < 0 || m_buffer.is_empty())
|
||||
return;
|
||||
|
||||
for (int i = m_selection_start; i <= m_selection_end; i++) {
|
||||
m_tracked_changes.set(i, m_buffer.data()[i]);
|
||||
m_buffer.data()[i] = fill_byte;
|
||||
}
|
||||
|
||||
update();
|
||||
did_change();
|
||||
}
|
||||
|
||||
void HexEditor::set_position(int position)
|
||||
{
|
||||
if (position > m_buffer.size())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue