diff options
author | Stephen Fisher <steve@stephen-fisher.com> | 2011-01-19 18:21:21 +0000 |
---|---|---|
committer | Stephen Fisher <steve@stephen-fisher.com> | 2011-01-19 18:21:21 +0000 |
commit | 347d0a77bf4117d730fd3646d194588d886fc7c0 (patch) | |
tree | eda733125594320f73201acec369bc4e824a153c /gtk | |
parent | 30b047223abc6075763935ffa0de9491c2f855f3 (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
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main.c | 13 | ||||
-rw-r--r-- | gtk/main_proto_draw.c | 29 |
2 files changed, 33 insertions, 9 deletions
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; |