@@ -95,7 +95,7 @@ void HexViewer::createActions()
9595 alignAddressAction = new QAction (tr (" &Align addresses" ), this );
9696 alignAddressAction->setShortcut (tr (" Ctrl+A" ));
9797 alignAddressAction->setCheckable (true );
98- alignAddressAction->setChecked (decodeAsChar );
98+ alignAddressAction->setChecked (alignAddress );
9999 alignAddressAction->setStatusTip (tr (" Align adresses with width of line." ));
100100
101101
@@ -209,10 +209,19 @@ void HexViewer::setSizes()
209209 horBytes = 1 ;
210210 int hb2 = 1 ;
211211 w = width () - frameL - frameR - xData - dataWidth - 2 * charWidth - 8 ;
212- // calculate how many additional bytes can by displayed
212+ // calculate how many additional bytes can be displayed
213213 while (w-sbw >= dataWidth + charWidth) {
214214 ++horBytes;
215- if (horBytes == 2 * hb2) hb2 = horBytes;
215+ if (horBytes == 2 * hb2) {
216+ hb2 = horBytes;
217+ if (decodeAsChar){
218+ if (hb2 == 8 ) w -= EXTRA_SPACING;
219+ if (hb2 >= 8 ){
220+ int scale = int ((lineHeight+1 )/8 );
221+ w -= scale*8 ;
222+ }
223+ }
224+ };
216225 w -= dataWidth + charWidth;
217226 if ((horBytes & 3 ) == 0 ) w -= EXTRA_SPACING;
218227 if ((horBytes & 7 ) == 0 ) w -= EXTRA_SPACING;
@@ -411,14 +420,14 @@ void HexViewer::paintEvent(QPaintEvent* e)
411420 }
412421
413422 // if we are a multiple of 8 bytes we draw one or more decoded characters
414- if ((horBytes%8 ) == 0 ){
423+ if ((horBytes%8 ) == 0 && decodeAsChar ){
415424 x += EXTRA_SPACING;
416425 int scale = int ((lineHeight+1 )/8 );
417426
418427 for (int j = 0 ; j < horBytes; ++j) {
419428 if (address + j >= debuggableSize) break ;
420429 int yy = (j%8 );
421- QColor penClr = Qt::lightGray; // Qt::white;
430+ QColor penClr = (hasFocus && hexMarkAddress==(address + j) )? Qt::cyan : Qt::lightGray; // Qt::white;
422431// if (hexData[address + j] != previousHexData[address + j]) {
423432// penClr = Qt::red;
424433// }
@@ -580,11 +589,13 @@ void HexViewer::keyPressEvent(QKeyEvent* e)
580589 } else if (useMarker && e->key () == Qt::Key_Right) {
581590 setValue = beingEdited & !editedChars;
582591 ++newAddress;
592+ if (!alignAddress && e->modifiers () == Qt::ShiftModifier) ++hexTopAddress;
583593 cursorPosition = 0 ;
584594 } else if (useMarker && e->key () == Qt::Key_Left) {
585595 setValue = beingEdited & !editedChars;
586596 --newAddress;
587- cursorPosition = 0 ;
597+ if (!alignAddress && e->modifiers () == Qt::ShiftModifier) --hexTopAddress;
598+ cursorPosition = 0 ;
588599 } else if (useMarker && e->key () == Qt::Key_Up) {
589600 setValue = beingEdited & !editedChars;
590601 newAddress -= horBytes;
@@ -667,7 +678,7 @@ void HexViewer::keyPressEvent(QKeyEvent* e)
667678 if ((editedChars || useMarker) && (hexMarkAddress != newAddress)) {
668679 if (newAddress < 0 ) newAddress += debuggableSize;
669680 if (newAddress >= debuggableSize) newAddress -= debuggableSize;
670- // influencing hexTopAddress during Key_PageUp/Down might need following 2 lines.
681+ // influencing hexTopAddress during Key_PageUp/Down or SHIFT+left/right might need following 2 lines.
671682 if (hexTopAddress < 0 ) hexTopAddress += debuggableSize;
672683 if (hexTopAddress >= debuggableSize) hexTopAddress -= debuggableSize;
673684
0 commit comments