aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2017-12-21 14:28:07 -0800
committerRoland Knall <rknall@gmail.com>2017-12-22 13:05:35 +0000
commit9354901dd1794a74d061b9396cfcc6c41584e4fb (patch)
treed89b1dabd4d463f413784306e014e4edd646fcd8
parentcf9d7fb8a5275b96d7682b9f2cf6aec966fa3154 (diff)
Qt: Lighten non-printable byte view characters.
Draw non-printable characters using a lighter foreground color in the byte view. Change-Id: Ib97a1f9f897fa6f78e33ff80c7efea21f68ef2d5 Reviewed-on: https://code.wireshark.org/review/24935 Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r--ui/qt/widgets/byte_view_text.cpp21
-rw-r--r--ui/qt/widgets/byte_view_text.h3
2 files changed, 22 insertions, 2 deletions
diff --git a/ui/qt/widgets/byte_view_text.cpp b/ui/qt/widgets/byte_view_text.cpp
index f6eddd4397..8f637fabc9 100644
--- a/ui/qt/widgets/byte_view_text.cpp
+++ b/ui/qt/widgets/byte_view_text.cpp
@@ -363,6 +363,9 @@ void ByteViewText::drawLine(QPainter *painter, const int offset, const int row_y
// ASCII
if (show_ascii_) {
+ bool in_non_printable = false;
+ int np_start;
+ int np_len;
for (int tvb_pos = offset; tvb_pos <= max_tvb_pos; tvb_pos++) {
/* insert a space every separator_interval_ bytes */
if ((tvb_pos != offset) && ((tvb_pos % separator_interval_) == 0)) {
@@ -378,14 +381,27 @@ void ByteViewText::drawLine(QPainter *painter, const int offset, const int row_y
if (g_ascii_isprint(c)) {
line += c;
+ if (in_non_printable) {
+ in_non_printable = false;
+ addAsciiFormatRange(fmt_list, np_start, np_len, offset, max_tvb_pos, ModeNonPrintable);
+ }
} else {
- // XXX Should we soften the text color as well?
line += UTF8_MIDDLE_DOT;
+ if (!in_non_printable) {
+ in_non_printable = true;
+ np_start = tvb_pos;
+ np_len = 1;
+ } else {
+ np_len++;
+ }
}
if (build_x_pos) {
x_pos_to_column_ += QVector<int>().fill(tvb_pos - offset, fontMetrics().width(line) - x_pos_to_column_.size());
}
}
+ if (in_non_printable) {
+ addAsciiFormatRange(fmt_list, np_start, np_len, offset, max_tvb_pos, ModeNonPrintable);
+ }
addAsciiFormatRange(fmt_list, proto_start_, proto_len_, offset, max_tvb_pos, ModeProtocol);
if (addAsciiFormatRange(fmt_list, field_start_, field_len_, offset, max_tvb_pos, ModeField)) {
offset_mode = ModeOffsetField;
@@ -451,6 +467,9 @@ bool ByteViewText::addFormatRange(QList<QTextLayout::FormatRange> &fmt_list, int
format_range.format.setForeground(ColorUtils::byteViewMarkColor(false));
format_range.format.setBackground(ColorUtils::byteViewMarkColor(true));
break;
+ case ModeNonPrintable:
+ format_range.format.setForeground(offset_normal_fg_);
+ break;
}
fmt_list << format_range;
return true;
diff --git a/ui/qt/widgets/byte_view_text.h b/ui/qt/widgets/byte_view_text.h
index 73f58cb51d..4da15e919f 100644
--- a/ui/qt/widgets/byte_view_text.h
+++ b/ui/qt/widgets/byte_view_text.h
@@ -72,7 +72,8 @@ private:
ModeOffsetNormal,
ModeOffsetField,
ModeHover,
- ModeMarked
+ ModeMarked,
+ ModeNonPrintable
} HighlightMode;
QTextLayout *layout_;