Changed cursor movement logic to move to nearest hex address.

This commit is contained in:
Matthew Budd 2020-08-22 20:48:31 -04:00
parent b01b1c7a4c
commit 66810fdb9d
1 changed files with 30 additions and 4 deletions

View File

@ -891,8 +891,21 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
if (event->matches(QKeySequence::MoveToNextChar))
{
cursorPosX++;
if ( cursorPosX < 32 )
{
if ( cursorPosX % 2 )
{
cursorPosX++;
}
else
{
cursorPosX += 2;
}
}
else
{
cursorPosX++;
}
if ( cursorPosX >= 48 )
{
cursorPosX = 47;
@ -901,8 +914,21 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
}
else if (event->matches(QKeySequence::MoveToPreviousChar))
{
cursorPosX--;
if ( cursorPosX < 33 )
{
if ( cursorPosX % 2 )
{
cursorPosX -= 3;
}
else
{
cursorPosX -= 2;
}
}
else
{
cursorPosX--;
}
if ( cursorPosX < 0 )
{
cursorPosX = 0;