aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2011-01-19 18:21:21 +0000
committerStephen Fisher <steve@stephen-fisher.com>2011-01-19 18:21:21 +0000
commit347d0a77bf4117d730fd3646d194588d886fc7c0 (patch)
treeeda733125594320f73201acec369bc4e824a153c
parent30b047223abc6075763935ffa0de9491c2f855f3 (diff)
From Cal Turney via enhancement bug #5587: In hex or string searches of the
packet data highlight the target rather than the entire field. svn path=/trunk/; revision=35584
-rw-r--r--cfile.h1
-rw-r--r--file.c3
-rw-r--r--gtk/main.c13
-rw-r--r--gtk/main_proto_draw.c29
4 files changed, 37 insertions, 9 deletions
diff --git a/cfile.h b/cfile.h
index 5789b0d230..fe912bb261 100644
--- a/cfile.h
+++ b/cfile.h
@@ -79,6 +79,7 @@ typedef struct _capture_file {
gboolean case_type; /* TRUE if case-insensitive text search */
gboolean decode_data; /* TRUE if searching protocol tree text */
gboolean summary_data; /* TRUE if searching Info column text */
+ gboolean search_in_progress; /* TRUE if user just clicked OK in the Find dialog or hit <control>N/B */
/* packet data */
union wtap_pseudo_header pseudo_header; /* Packet pseudo_header */
guint8 pd[WTAP_MAX_PACKET_SIZE]; /* Packet data */
diff --git a/file.c b/file.c
index c69e0ea518..65b35b554b 100644
--- a/file.c
+++ b/file.c
@@ -3992,7 +3992,10 @@ find_packet(capture_file *cf,
if (new_fd != NULL) {
#ifdef NEW_PACKET_LIST
/* Find and select */
+ cf->search_in_progress = TRUE;
row = new_packet_list_find_row_from_data(fdata, TRUE);
+ cf->search_in_progress = FALSE;
+ cf->search_pos = 0; /* Reset the position */
#else
/* We found a frame. Find what row it's in. */
row = packet_list_find_row_from_data(new_fd);
diff --git a/gtk/main.c b/gtk/main.c
index 99a3993c27..8d370d6fc3 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1681,14 +1681,13 @@ main_cf_cb_packet_selected(gpointer data)
add_main_byte_views(cf->edt);
main_proto_tree_draw(cf->edt->tree);
- /* The user is searching for a string in the data or a hex value,
- * highlight the field that is found in the tree and hex displays. */
- if((cfile.string || cfile.hex) && cfile.search_pos != 0) {
- highlight_field(cf->edt->tvb, cfile.search_pos,
+ /* Note: Both string and hex value searches in the packet data produce a non-zero
+ search_pos if successful */
+ if(cf->search_in_progress && cf->search_pos != 0) {
+ highlight_field(cf->edt->tvb, cf->search_pos,
(GtkTreeView *)tree_view_gbl, cf->edt->tree);
- cfile.search_pos = 0; /* Reset the position */
- }
-
+ }
+
/* A packet is selected. */
set_menus_for_selected_packet(cf);
}
diff --git a/gtk/main_proto_draw.c b/gtk/main_proto_draw.c
index 2a0ebc827e..5b351d393a 100644
--- a/gtk/main_proto_draw.c
+++ b/gtk/main_proto_draw.c
@@ -579,6 +579,16 @@ highlight_field(tvbuff_t *tvb, gint byte, GtkTreeView *tree_view,
gtk_tree_selection_select_path(gtk_tree_view_get_selection(tree_view),
first_path);
+ /* If the last search was a string or hex search within "Packet data", the entire field might
+ not be highlighted. If the user just clicked on one of the bytes comprising that field, the
+ above call didn't trigger a 'gtk_tree_view_get_selection' event. Call redraw_packet_bytes()
+ to make the highlighting of the entire field visible. */
+ if (!cfile.search_in_progress) {
+ if (cfile.hex || (cfile.string && !(cfile.summary_data || cfile.decode_data))) {
+ redraw_packet_bytes(byte_nb_ptr_gbl, cfile.current_frame, cfile.finfo_selected);
+ }
+ }
+
/* And position the window so the selection is visible.
* Position the selection in the middle of the viewable
* pane. */
@@ -1562,8 +1572,23 @@ packet_hex_print(GtkWidget *bv, const guint8 *pd, frame_data *fd,
if (finfo != NULL) {
- bstart = finfo->start;
- blen = finfo->length;
+
+ if (cfile.search_in_progress) {
+ if (cfile.hex || (cfile.string && !(cfile.summary_data || cfile.decode_data))) {
+ /* In the hex view, only highlight the target bytes or string. The entire
+ field can then be displayed by clicking on any of the bytes in the field. */
+ if (cfile.hex) {
+ blen = strlen(cfile.sfilter)/2;
+ } else {
+ blen = strlen(cfile.sfilter);
+ }
+ bstart = cfile.search_pos - (blen-1);
+ }
+ } else {
+ blen = finfo->length;
+ bstart = finfo->start;
+ }
+
/* bmask = finfo->hfinfo->bitmask << finfo->hfinfo->bitshift; */ /* (value & mask) >> shift */
bmask = finfo->hfinfo->bitmask;
astart = finfo->appendix_start;