mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
HexEditor: Fix half byte offset bug
If you had made a change to the first 4 bits of a byte and then changed your offset via keyboard or menu option it would change the last 4 bits of the new offset the next time you made a change and would not show that the byte had been changed at the new offset.
This commit is contained in:
parent
a76b02f741
commit
465a33443c
1 changed files with 7 additions and 0 deletions
|
@ -50,6 +50,7 @@ void HexEditor::set_position(int position)
|
|||
return;
|
||||
|
||||
m_position = position;
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(position);
|
||||
update_status();
|
||||
}
|
||||
|
@ -288,6 +289,7 @@ void HexEditor::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Up) {
|
||||
if (m_position - bytes_per_row() >= 0) {
|
||||
m_position -= bytes_per_row();
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(m_position);
|
||||
update();
|
||||
update_status();
|
||||
|
@ -298,6 +300,7 @@ void HexEditor::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Down) {
|
||||
if (m_position + bytes_per_row() < m_buffer.size()) {
|
||||
m_position += bytes_per_row();
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(m_position);
|
||||
update();
|
||||
update_status();
|
||||
|
@ -308,6 +311,7 @@ void HexEditor::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Left) {
|
||||
if (m_position - 1 >= 0) {
|
||||
m_position--;
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(m_position);
|
||||
update();
|
||||
update_status();
|
||||
|
@ -318,6 +322,7 @@ void HexEditor::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Right) {
|
||||
if (m_position + 1 < m_buffer.size()) {
|
||||
m_position++;
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(m_position);
|
||||
update();
|
||||
update_status();
|
||||
|
@ -328,6 +333,7 @@ void HexEditor::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Backspace) {
|
||||
if (m_position > 0) {
|
||||
m_position--;
|
||||
m_byte_position = 0;
|
||||
scroll_position_into_view(m_position);
|
||||
update();
|
||||
update_status();
|
||||
|
@ -374,6 +380,7 @@ void HexEditor::text_mode_keydown_event(GKeyEvent& event)
|
|||
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_position++;
|
||||
m_byte_position = 0;
|
||||
update();
|
||||
update_status();
|
||||
did_change();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue