From 0bb501a6554bd54540abada98936d1f5ce8ae4c1 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 17 Jan 2018 10:32:11 -0800 Subject: [PATCH] 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 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/widgets/byte_view_text.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp index 04ac6ec7f9..58a0a6f75b 100644 --- a/ui/qt/widgets/byte_view_text.cpp +++ b/ui/qt/widgets/byte_view_text.cpp @@ -500,16 +500,17 @@ bool ByteViewText::addHexFormatRange(QList &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); } -- 2.34.1