@@ -387,7 +387,7 @@ void CLightningFastViewerWidget::calculateHexLayout()
387387 LineLayout optimalLayout;
388388
389389 // Try increasingly larger values (multiples of 4) until we exceed viewport width
390- for (int candidate = 4 ; candidate <= 64 ; candidate += 4 )
390+ for (int candidate = 4 ; candidate <= 128 ; candidate += 4 )
391391 {
392392 optimalLayout = calculateHexLineLayout (candidate, _nDigits);
393393 const int lineWidth = optimalLayout.asciiStart + optimalLayout.asciiWidth ;
@@ -406,19 +406,14 @@ CLightningFastViewerWidget::LineLayout CLightningFastViewerWidget::calculateHexL
406406{
407407 LineLayout layout;
408408
409- layout.hexStart = _charWidth * (nDigits + Layout::OFFSET_SUFFIX_CHARS) + Layout::LEFT_MARGIN_PIXELS ;
410- layout.hexWidth = _charWidth * (bytesPerLine * Layout::HEX_CHARS_PER_BYTE + Layout::HEX_MIDDLE_EXTRA_SPACE * ((bytesPerLine - 1 ) / 8 ));
411- layout.asciiStart = layout.hexStart + layout.hexWidth + _charWidth * Layout::HEX_ASCII_SEPARATOR_CHARS;
412- layout.asciiWidth = _charWidth * (bytesPerLine + Layout::HEX_ASCII_SEPARATOR_CHARS) ;
409+ layout.hexStart = Layout::LEFT_MARGIN_PIXELS + (nDigits + Layout::OFFSET_SUFFIX_CHARS) * _charWidth ;
410+ layout.hexWidth = (bytesPerLine * Layout::HEX_CHARS_PER_BYTE + Layout::HEX_MIDDLE_EXTRA_SPACE * ((bytesPerLine - 1 ) / 8 )) * _charWidth ;
411+ layout.asciiStart = layout.hexStart + layout.hexWidth + Layout::HEX_ASCII_SEPARATOR_CHARS * _charWidth ;
412+ layout.asciiWidth = bytesPerLine * _charWidth ;
413413
414414 return layout;
415415}
416416
417- void CLightningFastViewerWidget::calculateTextLayout ()
418- {
419- // No special layout needed for text mode, but we could add margins here
420- }
421-
422417void CLightningFastViewerWidget::drawHexLine (QPainter& painter, qsizetype offset, int y, const QFontMetrics& fm)
423418{
424419 if (offset >= _data.size ())
@@ -504,10 +499,10 @@ void CLightningFastViewerWidget::drawTextLine(QPainter& painter, int lineIndex,
504499 if (lineIndex < 0 || lineIndex >= static_cast <int >(_lineOffsets.size ()))
505500 return ;
506501
507- int hScroll = horizontalScrollBar ()->value ();
502+ const int hScroll = horizontalScrollBar ()->value ();
508503
509- int lineStart = _lineOffsets[lineIndex];
510- int lineLen = _lineLengths[lineIndex];
504+ const int lineStart = _lineOffsets[lineIndex];
505+ const int lineLen = _lineLengths[lineIndex];
511506 QString lineText = _text.mid (lineStart, lineLen);
512507
513508 // Draw the line character by character to handle selection
@@ -537,8 +532,6 @@ void CLightningFastViewerWidget::updateScrollBars()
537532{
538533 if (_mode == HEX)
539534 calculateHexLayout ();
540- else
541- calculateTextLayout ();
542535
543536 const int visibleLines = viewport ()->height () / _lineHeight;
544537 verticalScrollBar ()->setRange (0 , qMax (0 , totalLines () - visibleLines));
@@ -583,9 +576,12 @@ CLightningFastViewerWidget::Region CLightningFastViewerWidget::regionAtPos(const
583576{
584577 int x = pos.x () + horizontalScrollBar ()->value ();
585578
586- if (x < _hexStart) return REGION_OFFSET;
587- if (x < _asciiStart - _charWidth * Layout::HEX_ASCII_SEPARATOR_CHARS) return REGION_HEX;
588- if (x >= _asciiStart) return REGION_ASCII;
579+ if (x < _hexStart)
580+ return REGION_OFFSET;
581+ if (x < _asciiStart - _charWidth * Layout::HEX_ASCII_SEPARATOR_CHARS)
582+ return REGION_HEX;
583+ if (x >= _asciiStart)
584+ return REGION_ASCII;
589585 return REGION_NONE;
590586}
591587
@@ -620,7 +616,7 @@ qsizetype CLightningFastViewerWidget::hexPosToOffset(const QPoint& pos) const
620616 }
621617 else if (region == REGION_ASCII)
622618 {
623- int relX = x - _asciiStart;
619+ const int relX = x - _asciiStart;
624620 byteInLine = relX / _charWidth;
625621 byteInLine = qBound (0 , byteInLine, _bytesPerLine - 1 );
626622 }
0 commit comments