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

@ -890,9 +890,22 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
printf("Hex Window Key Press: 0x%x \n", event->key() );
if (event->matches(QKeySequence::MoveToNextChar))
{
if ( cursorPosX < 32 )
{
if ( cursorPosX % 2 )
{
cursorPosX++;
}
else
{
cursorPosX += 2;
}
}
else
{
cursorPosX++;
}
if ( cursorPosX >= 48 )
{
cursorPosX = 47;
@ -900,9 +913,22 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
resetCursor();
}
else if (event->matches(QKeySequence::MoveToPreviousChar))
{
if ( cursorPosX < 33 )
{
if ( cursorPosX % 2 )
{
cursorPosX -= 3;
}
else
{
cursorPosX -= 2;
}
}
else
{
cursorPosX--;
}
if ( cursorPosX < 0 )
{
cursorPosX = 0;