HexEditor: Ignore control keys in text mode

The HexEditor now ignores control key events in text mode.
Previously null bytes were written.
This commit is contained in:
Gal Horowitz 2020-12-29 17:35:02 +02:00 committed by Andreas Kling
parent fea498e9ac
commit 35c4338625
Notes: sideshowbarker 2024-07-19 00:25:12 +09:00

View File

@ -447,8 +447,11 @@ void HexEditor::text_mode_keydown_event(GUI::KeyEvent& event)
ASSERT(m_position >= 0);
ASSERT(m_position < static_cast<int>(m_buffer.size()));
if (event.code_point() == 0) // This is a control key
return;
m_tracked_changes.set(m_position, m_buffer.data()[m_position]);
m_buffer.data()[m_position] = (u8)event.text().characters()[0]; // save the first 4 bits, OR the new value in the last 4
m_buffer.data()[m_position] = event.code_point();
if (m_position + 1 < static_cast<int>(m_buffer.size()))
m_position++;
m_byte_position = 0;