Qt: Fix bits highlighting in the byte view.

When the byte view is set to "Show bytes as bits" make sure we highlight
all eight bits instead of just two.

Change-Id: I1ece65032fa32f7274f4e7383e538b92e8fa4f65
Reviewed-on: https://code.wireshark.org/review/25354
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2018-01-17 10:32:11 -08:00 committed by Anders Broman
parent 0aad2bbc36
commit 0bb501a655
1 changed files with 5 additions and 4 deletions

View File

@ -500,16 +500,17 @@ bool ByteViewText::addHexFormatRange(QList<QTextLayout::FormatRange> &fmt_list,
if (mark_start < 0 || mark_length < 1) return false;
if (mark_start > max_tvb_pos && mark_end < tvb_offset) return false;
int chars_per_byte = recent.gui_bytes_view == BYTES_HEX ? 3 : 9;
int chars_per_byte = recent.gui_bytes_view == BYTES_HEX ? 2 : 8;
int chars_plus_pad = chars_per_byte + 1;
int byte_start = qMax(tvb_offset, mark_start) - tvb_offset;
int byte_end = qMin(max_tvb_pos, mark_end) - tvb_offset;
int fmt_start = offsetChars() + 1 // offset + spacing
+ (byte_start / separator_interval_)
+ (byte_start * chars_per_byte);
+ (byte_start * chars_plus_pad);
int fmt_length = offsetChars() + 1 // offset + spacing
+ (byte_end / separator_interval_)
+ (byte_end * chars_per_byte)
+ 2 // Both the high and low nibbles.
+ (byte_end * chars_plus_pad)
+ chars_per_byte
- fmt_start;
return addFormatRange(fmt_list, fmt_start, fmt_length, mode);
}