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 */
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);
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);
}
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. */
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;