Graham Bloice's patch to support inverse video rather than boldface
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 8 Sep 2000 09:50:08 +0000 (09:50 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 8 Sep 2000 09:50:08 +0000 (09:50 +0000)
highlighting of the bytes, in the hex dump window, corresponding to a
selected field.

Also, make "remember_ptree_widget()" static, as it's not used outside
"gtk/proto_draw.c".

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2399 f5534014-38df-0310-8fa8-9805f1628bb7

AUTHORS
doc/ethereal.pod.template
file.c
gtk/gui_prefs.c
gtk/main.c
gtk/packet_win.c
gtk/packet_win.h
gtk/proto_draw.c
gtk/proto_draw.h
prefs.c
prefs.h

diff --git a/AUTHORS b/AUTHORS
index c5fd09669eda025048a18adb0afe4030be2f4449..4ea1ba1315b243aa7b1ae3e19c8f2d026e8f8ccd 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -306,6 +306,9 @@ Graham Bloice <graham.bloice@trihedral.com> {
        Win32 Makefile improvements
        Support for "Update list of packets in real time" during capture
        on Win32
+       Support for inverse video rather than boldface highlighting of
+       the bytes, in the hex dump window, corresponding to a selected
+       field
 }
 
 Ralf Schneider <ralf.schneider@alcatel.se> {
index b80400c9853c0de01a8eaa7486ab3c25cf7b5f56..be82ab2e8f9625b4afbb8f8180eb0510103271dd 100644 (file)
@@ -513,6 +513,8 @@ the rest of the list or tree without changing the selection
 until you press the space bar. If the selection bar has a "select"
 behavior, the arrow keys will move the selection bar and change
 the selection to the new item in the packet list or protocol tree.
+The highlight method in the hex dump display for the selected protocol
+item can be set to use either inverse video, or bold characters.
 
 =item Fonts
 
diff --git a/file.c b/file.c
index 32895d7a52892ddf3061887abf4bd8f6b9b4d080..ff03a4c6c94fdd67f49f4bb4d6beae648a2bf2c2 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.213 2000/09/07 05:33:49 gram Exp $
+ * $Id: file.c,v 1.214 2000/09/08 09:49:17 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -1557,7 +1557,8 @@ select_packet(capture_file *cf, int row)
   clear_tree_and_hex_views();
   proto_tree_draw(cf->protocol_tree, tree_view);
   packet_hex_print(GTK_TEXT(byte_view), cf->pd, cf->current_frame->cap_len,
-                       -1, -1, cf->current_frame->flags.encoding);
+                       -1, -1, cf->current_frame->flags.encoding,
+                       prefs.gui_hex_dump_highlight_style);
 
   /* A packet is selected. */
   set_menus_for_selected_packet(TRUE);
index 3342571314383b0a9dc7508c41e30e5307ff4a55..2010dc5120ce0e80ad2c3df2c851fcc47ffc1105 100644 (file)
@@ -1,7 +1,7 @@
 /* gui_prefs.c
  * Dialog box for GUI preferences
  *
- * $Id: gui_prefs.c,v 1.16 2000/08/24 03:16:47 gram Exp $
+ * $Id: gui_prefs.c,v 1.17 2000/09/08 09:50:01 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -61,6 +61,7 @@ static void fetch_colors(void);
 #define PTREE_SEL_BROWSE_KEY           "ptree_sel_browse"
 #define PTREE_LINE_STYLE_KEY           "ptree_line_style"
 #define PTREE_EXPANDER_STYLE_KEY       "ptree_expander_style"
+#define HEX_DUMP_HIGHLIGHT_STYLE_KEY   "hex_dump_highlight_style"
 
 #define FONT_DIALOG_PTR_KEY    "font_dialog_ptr"
 #define FONT_CALLER_PTR_KEY    "font_caller_ptr"
@@ -97,6 +98,12 @@ static const enum_val expander_style_vals[] = {
        { NULL,       0 }
 };
 
+static const enum_val highlight_style_vals[] = {
+       { "Bold",     0 },
+       { "Inverse",  1 },
+       { NULL,       0 }
+};
+
 /* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
    the "Colors..." dialog, so that we know that they (probably) changed
    colors, and therefore that the "apply" function needs to recolor
@@ -119,7 +126,7 @@ gui_prefs_show(void)
        font_changed = FALSE;
 
        /* Main vertical box */
-       main_vb = gtk_vbox_new(FALSE, 5);
+       main_vb = gtk_vbox_new(FALSE, 7);
        gtk_container_border_width( GTK_CONTAINER(main_vb), 5 );
 
        /* Main table */
@@ -153,11 +160,16 @@ gui_prefs_show(void)
            "Protocol-tree expander style:", expander_style_vals,
            prefs.gui_ptree_expander_style);
 
+       /* Hex Dump highlight style */
+       create_option_menu(main_vb, HEX_DUMP_HIGHLIGHT_STYLE_KEY, main_tb, 5,
+           "Hex dump highlight style:", highlight_style_vals,
+           prefs.gui_hex_dump_highlight_style);
+
        /* "Font..." button - click to open a font selection dialog box. */
        font_bt = gtk_button_new_with_label("Font...");
        gtk_signal_connect(GTK_OBJECT(font_bt), "clicked",
            GTK_SIGNAL_FUNC(font_browse_cb), NULL);
-       gtk_table_attach_defaults( GTK_TABLE(main_tb), font_bt, 1, 2, 5, 6 );
+       gtk_table_attach_defaults( GTK_TABLE(main_tb), font_bt, 1, 2, 6, 7 );
 
        /* "Colors..." button - click to open a color selection dialog box. */
        color_bt = gtk_button_new_with_label("Colors...");
@@ -362,6 +374,9 @@ gui_prefs_fetch(GtkWidget *w)
        prefs.gui_ptree_expander_style = fetch_enum_value(
            gtk_object_get_data(GTK_OBJECT(w), PTREE_EXPANDER_STYLE_KEY),
            expander_style_vals);
+       prefs.gui_hex_dump_highlight_style = fetch_enum_value(
+           gtk_object_get_data(GTK_OBJECT(w), HEX_DUMP_HIGHLIGHT_STYLE_KEY),
+           highlight_style_vals);
 
        if (colors_changed)
            fetch_colors();
@@ -386,6 +401,7 @@ gui_prefs_apply(GtkWidget *w)
        set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
        set_ptree_line_style_all(prefs.gui_ptree_line_style);
        set_ptree_expander_style_all(prefs.gui_ptree_expander_style);
+       set_hex_dump_highlight_style_all(prefs.gui_hex_dump_highlight_style);
        if (colors_changed)
                update_marked_frames();
        if (font != NULL) {
index 2f9c2233dde263c79205fdf679c5273abf856024..1e3591a089e70cd236c0eb83f9cdb6b9f11cfe22 100644 (file)
@@ -1,6 +1,6 @@
 /* main.c
  *
- * $Id: main.c,v 1.153 2000/08/23 21:05:11 deniel Exp $
+ * $Id: main.c,v 1.154 2000/09/08 09:50:03 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -573,7 +573,8 @@ tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer user
        }
 
        packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len, 
-               finfo->start, finfo->length, cfile.current_frame->flags.encoding);
+               finfo->start, finfo->length, cfile.current_frame->flags.encoding,
+               prefs.gui_hex_dump_highlight_style);
 }
 
 static void
@@ -583,7 +584,8 @@ tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column, gpointer us
        finfo_selected = NULL;
        set_menus_for_selected_tree_row(FALSE);
        packet_hex_print(GTK_TEXT(byte_view), cfile.pd, cfile.current_frame->cap_len, 
-               -1, -1, cfile.current_frame->flags.encoding);
+               -1, -1, cfile.current_frame->flags.encoding,
+               prefs.gui_hex_dump_highlight_style);
 }
 
 void collapse_all_cb(GtkWidget *widget, gpointer data) {
index 33bd71c0902ca22afd608d39356cc104419b6d2d..8fd9fb58727f8a7b5ebd9e502d107b0716a4f519 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet_win.c,v 1.12 2000/08/21 08:09:13 guy Exp $
+ * $Id: packet_win.c,v 1.13 2000/09/08 09:50:06 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -80,6 +80,7 @@ struct PacketWinData {
        GtkWidget  *tree_view;
        GtkWidget  *bv_scrollw;
        GtkWidget  *byte_view;
+       field_info *finfo_selected;
 };
 
 /* List of all the packet-detail windows popped up. */
@@ -195,8 +196,10 @@ create_new_window ( char *Title, gint tv_size, gint bv_size){
   /* draw the protocol tree & print hex data */
   proto_tree_draw(DataPtr->protocol_tree, tree_view);
   packet_hex_print( GTK_TEXT(byte_view), DataPtr->pd,
-               DataPtr->cap_len, -1, -1, DataPtr->encoding);
+               DataPtr->cap_len, -1, -1, DataPtr->encoding,
+               prefs.gui_hex_dump_highlight_style);
                
+  DataPtr->finfo_selected = NULL;
   gtk_widget_show(main_w);
 }
 
@@ -225,11 +228,11 @@ new_tree_view_select_row_cb(GtkCTree *ctree, GList *node, gint column,
        finfo = gtk_ctree_node_get_row_data( ctree, GTK_CTREE_NODE(node) );
        if (!finfo) return;
 
-       finfo_selected = finfo;
+       DataPtr->finfo_selected = finfo;
 
        packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
                DataPtr->cap_len, finfo->start, finfo->length,
-               DataPtr->encoding);
+               DataPtr->encoding, prefs.gui_hex_dump_highlight_style);
 
 }
 
@@ -243,8 +246,10 @@ new_tree_view_unselect_row_cb(GtkCTree *ctree, GList *node, gint column,
        
        struct PacketWinData *DataPtr = (struct PacketWinData*)user_data;
 
+       DataPtr->finfo_selected = NULL;
        packet_hex_print(GTK_TEXT(DataPtr->byte_view), DataPtr->pd,
-               DataPtr->cap_len, -1, -1, DataPtr->encoding);
+               DataPtr->cap_len, -1, -1, DataPtr->encoding,
+               prefs.gui_hex_dump_highlight_style);
 }
 
 /* Functions called from elsewhere to act on all popup packet windows. */
@@ -265,3 +270,19 @@ destroy_packet_wins(void)
                gtk_widget_destroy(DataPtr->main);
        }
 }
+
+static void
+set_hex_dump_highlight_style_cb(gpointer data, gpointer user_data)
+{
+       struct PacketWinData *DataPtr = (struct PacketWinData *)data;
+
+       set_hex_dump_highlight_style(DataPtr->byte_view,
+               DataPtr->finfo_selected, *(gint *)user_data);
+}
+
+/* Set the hex dump highlight style of all the popup packet windows. */
+void
+set_hex_dump_highlight_style_packet_wins(gboolean style)
+{
+       g_list_foreach(detail_windows, set_hex_dump_highlight_style_cb, &style);
+}
index 0371d11c7a3d49d3717e0ced037da57d0ea8a1f2..42391ec99b8a68b84f46eca4e5a7867ea8861e99 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet_win.h,v 1.4 2000/08/21 08:09:14 guy Exp $
+ * $Id: packet_win.h,v 1.5 2000/09/08 09:50:07 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -28,5 +28,6 @@
 #define __PACKET_WIN_H__
 
 extern void new_window_cb(GtkWidget *w);
+void set_hex_dump_highlight_style_packet_wins(gboolean style);
 
 #endif
index 67239304b52756f58463c8d6b24f46394e7f0430..3e05ef43bffde9cb4868b9673654634c488c4778 100644 (file)
@@ -1,7 +1,7 @@
-/* gtkpacket.c
+/* proto_draw.c
  * Routines for GTK+ packet display
  *
- * $Id: proto_draw.c,v 1.18 2000/08/21 08:09:16 guy Exp $
+ * $Id: proto_draw.c,v 1.19 2000/09/08 09:50:07 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -47,6 +47,7 @@
 
 #include "prefs.h"
 #include "proto_draw.h"
+#include "packet_win.h"
 #include "gtkglobals.h"
 
 #define BYTE_VIEW_WIDTH    16
@@ -57,6 +58,27 @@ extern GdkFont      *m_r_font, *m_b_font;
 static void
 proto_tree_draw_node(GNode *node, gpointer data);
 
+/* Set the highlight style of a given byte view window. */
+void
+set_hex_dump_highlight_style(GtkWidget *bv, field_info *finfo, gboolean style)
+{
+  if (finfo != NULL) {
+    packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len, 
+                    finfo->start, finfo->length,
+                    cfile.current_frame->flags.encoding, style);
+  } else {
+    packet_hex_print(GTK_TEXT(bv), cfile.pd, cfile.current_frame->cap_len, 
+                    -1, -1, cfile.current_frame->flags.encoding, style);
+  }
+}
+
+void
+set_hex_dump_highlight_style_all(gboolean style)
+{
+  set_hex_dump_highlight_style(byte_view, finfo_selected, style);
+  set_hex_dump_highlight_style_packet_wins(style);
+}
+
 void
 create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
                GtkWidget **bv_scrollw_p, int pos)
@@ -86,12 +108,15 @@ create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
 
 void
 packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
-               char_enc encoding) {
+               char_enc encoding, gboolean style) {
   gint     i = 0, j, k, cur;
   guchar   line[128], hexchars[] = "0123456789abcdef", c = '\0';
   GdkFont *cur_font, *new_font;
   gint    bend = -1;
 
+  GdkColor *fg, *bg;
+  gboolean reverse, newreverse;
+
   /* Freeze the text for faster display */
   gtk_text_freeze(bv);
 
@@ -111,68 +136,175 @@ packet_hex_print(GtkText *bv, guint8 *pd, gint len, gint bstart, gint blen,
   while (i < len) {
     /* Print the line number */
     sprintf(line, "%04x  ", i);
-    gtk_text_insert(bv, m_r_font, NULL, NULL, line, -1);
-    /* Do we start in bold? */
-    cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
-    j   = i;
-    k   = i + BYTE_VIEW_WIDTH;
-    cur = 0;
-    /* Print the hex bit */
-    while (i < k) {
-      if (i < len) {
-        line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
-        line[cur++] = hexchars[pd[i] & 0x0f];
-      } else {
-        line[cur++] = ' '; line[cur++] = ' ';
+    
+    /* Display with inverse video ? */
+    if (style) {
+      gtk_text_insert(bv, m_r_font, &BLACK, &WHITE, line, -1);
+      /* Do we start in reverse? */
+      reverse = i >= bstart && i < bend;
+      fg = reverse ? &WHITE : &BLACK;
+      bg = reverse ? &BLACK : &WHITE;
+      j   = i;
+      k   = i + BYTE_VIEW_WIDTH;
+      cur = 0;
+      /* Print the hex bit */
+      while (i < k) {
+       if (i < len) {
+         line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
+         line[cur++] = hexchars[pd[i] & 0x0f];
+       } else {
+         line[cur++] = ' '; line[cur++] = ' ';
+       }
+       i++;
+       newreverse = i >= bstart && i < bend;
+       /* Have we gone from reverse to plain? */
+       if (reverse && (reverse != newreverse)) {
+         gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+         fg = &BLACK;
+         bg = &WHITE;
+         cur = 0;
+       }
+       /* Inter byte space if not at end of line */
+       if (i < k) {
+         line[cur++] = ' ';
+         /* insert a space every BYTE_VIEW_SEP bytes */
+         if( ( i % BYTE_VIEW_SEP ) == 0 ) {
+           line[cur++] = ' ';
+         }
+       }
+       /* Have we gone from plain to reversed? */
+       if (!reverse && (reverse != newreverse)) {
+         gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+         fg = &WHITE;
+         bg = &BLACK;
+         cur = 0;
+       }
+       reverse = newreverse;
       }
-      line[cur++] = ' ';
-      i++;
-      /* insert a space every BYTE_VIEW_SEP bytes */
-      if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
-      /* Did we cross a bold/plain boundary? */
-      new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
-      if (cur_font != new_font) {
-        gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
-        cur_font = new_font;
-        cur = 0;
+      /* Print remaining part of line */
+      gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+      cur = 0;
+      /* Print some space at the end of the line */
+      line[cur++] = ' '; line[cur++] = ' '; line[cur++] = ' ';
+      gtk_text_insert(bv, m_r_font, &BLACK, &WHITE, line, cur);
+      cur = 0;
+
+      /* Print the ASCII bit */
+      i = j;
+      /* Do we start in reverse? */
+      reverse = i >= bstart && i < bend;
+      fg = reverse ? &WHITE : &BLACK;
+      bg = reverse ? &BLACK : &WHITE;
+      while (i < k) {
+       if (i < len) {
+         if (encoding == CHAR_ASCII) {
+           c = pd[i];
+         }
+         else if (encoding == CHAR_EBCDIC) {
+           c = EBCDIC_to_ASCII1(pd[i]);
+         }
+         else {
+                 g_assert_not_reached();
+         }
+         line[cur++] = (isprint(c)) ? c : '.';
+       } else {
+         line[cur++] = ' ';
+       }
+       i++;
+       newreverse = i >= bstart && i < bend;
+       /* Have we gone from reverse to plain? */
+       if (reverse && (reverse != newreverse)) {
+         gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+         fg = &BLACK;
+         bg = &WHITE;
+         cur = 0;
+       }
+       if (i < k) {
+         /* insert a space every BYTE_VIEW_SEP bytes */
+         if( ( i % BYTE_VIEW_SEP ) == 0 ) {
+           line[cur++] = ' ';
+         }
+       }
+       /* Have we gone from plain to reversed? */
+       if (!reverse && (reverse != newreverse)) {
+         gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+         fg = &WHITE;
+         bg = &BLACK;
+         cur = 0;
+       }
+       reverse = newreverse;
       }
+      /* Print remaining part of line */
+      gtk_text_insert(bv, m_r_font, fg, bg, line, cur);
+      cur = 0;
+      line[cur++] = '\n';
+      line[cur]   = '\0';
+      gtk_text_insert(bv, m_r_font, &BLACK, &WHITE, line, -1);
     }
-    line[cur++] = ' ';
-    gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
-
-    cur = 0;
-    i = j;
-    /* Print the ASCII bit */
-    cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
-    while (i < k) {
-      if (i < len) {
-             if (encoding == CHAR_ASCII) {
-               c = pd[i];
-             }
-             else if (encoding == CHAR_EBCDIC) {
-               c = EBCDIC_to_ASCII1(pd[i]);
-             }
-             else {
-                     g_assert_not_reached();
-             }
-              line[cur++] = (isprint(c)) ? c : '.';
-      } else {
-        line[cur++] = ' ';
+    else {
+      gtk_text_insert(bv, m_r_font, NULL, NULL, line, -1);
+      /* Do we start in bold? */
+      cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
+      j   = i;
+      k   = i + BYTE_VIEW_WIDTH;
+      cur = 0;
+      /* Print the hex bit */
+      while (i < k) {
+       if (i < len) {
+         line[cur++] = hexchars[(pd[i] & 0xf0) >> 4];
+         line[cur++] = hexchars[pd[i] & 0x0f];
+       } else {
+         line[cur++] = ' '; line[cur++] = ' ';
+       }
+       line[cur++] = ' ';
+       i++;
+       /* insert a space every BYTE_VIEW_SEP bytes */
+       if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
+       /* Did we cross a bold/plain boundary? */
+       new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
+       if (cur_font != new_font) {
+         gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
+         cur_font = new_font;
+         cur = 0;
+       }
       }
-      i++;
-      /* insert a space every BYTE_VIEW_SEP bytes */
-      if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
-      /* Did we cross a bold/plain boundary? */
-      new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
-      if (cur_font != new_font) {
-        gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
-        cur_font = new_font;
-        cur = 0;
+      line[cur++] = ' ';
+      gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
+
+      cur = 0;
+      i = j;
+      /* Print the ASCII bit */
+      cur_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
+      while (i < k) {
+       if (i < len) {
+         if (encoding == CHAR_ASCII) {
+           c = pd[i];
+         }
+         else if (encoding == CHAR_EBCDIC) {
+           c = EBCDIC_to_ASCII1(pd[i]);
+         }
+         else {
+                 g_assert_not_reached();
+         }
+         line[cur++] = (isprint(c)) ? c : '.';
+       } else {
+         line[cur++] = ' ';
+       }
+       i++;
+       /* insert a space every BYTE_VIEW_SEP bytes */
+       if( ( i % BYTE_VIEW_SEP ) == 0 ) line[cur++] = ' ';
+       /* Did we cross a bold/plain boundary? */
+       new_font = (i >= bstart && i < bend) ? m_b_font : m_r_font;
+       if (cur_font != new_font) {
+         gtk_text_insert(bv, cur_font, NULL, NULL, line, cur);
+         cur_font = new_font;
+         cur = 0;
+       }
       }
+      line[cur++] = '\n';
+      line[cur]   = '\0';
+      gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
     }
-    line[cur++] = '\n';
-    line[cur]   = '\0';
-    gtk_text_insert(bv, cur_font, NULL, NULL, line, -1);
   }
 
   /* scroll text into position */
@@ -197,7 +329,7 @@ static GList *ptree_widgets;
 /* Add a protocol tree widget to the list of protocol tree widgets. */
 static void forget_ptree_widget(GtkWidget *ptreew, gpointer data);
 
-void
+static void
 remember_ptree_widget(GtkWidget *ptreew)
 {
   ptree_widgets = g_list_append(ptree_widgets, ptreew);
@@ -208,7 +340,7 @@ remember_ptree_widget(GtkWidget *ptreew)
                     GTK_SIGNAL_FUNC(forget_ptree_widget), NULL);
 }
 
-/* Remove a scrolled window from the list of scrolled windows. */
+/* Remove a protocol tree widget from the list of protocol tree widgets. */
 static void
 forget_ptree_widget(GtkWidget *ptreew, gpointer data)
 {
index 59c305efb75bbe25559a81510d4bbde5921df8b9..96fb55c89be2dce7b3423444ee41b7221e22b030 100644 (file)
@@ -1,7 +1,7 @@
 /* gtkpacket.h
  * Definitions for GTK+ packet display structures and routines
  *
- * $Id: proto_draw.h,v 1.7 2000/08/21 08:09:16 guy Exp $
+ * $Id: proto_draw.h,v 1.8 2000/09/08 09:50:08 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #ifndef __GTKPACKET_H__
 #define __GTKPACKET_H__
 
+void set_hex_dump_highlight_style(GtkWidget *bv, field_info *finfo,
+    gboolean style);
+void set_hex_dump_highlight_style_all(gboolean);
 void create_byte_view(gint bv_size, GtkWidget *pane, GtkWidget **byte_view_p,
                GtkWidget **bv_scrollw_p, int pos);
-void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc);
+void packet_hex_print(GtkText *, guint8 *, gint, gint, gint, char_enc, gboolean);
 
 #define E_TREEINFO_FIELD_INFO_KEY "tree_info_finfo"
 
@@ -39,7 +42,6 @@ void proto_tree_draw(proto_tree *protocol_tree, GtkWidget *tree_view);
 void expand_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);
 void collapse_all_tree(proto_tree *protocol_tree, GtkWidget *tree_view);
 
-void remember_ptree_widget(GtkWidget *);
 void set_ptree_sel_browse_all(gboolean);
 void set_ptree_line_style_all(gint style);
 void set_ptree_expander_style_all(gint style);
diff --git a/prefs.c b/prefs.c
index 7fb73a0f229e4f748de04ca4882ce7b096f9f4a6..4ad21abe050d8be4247956bb424b9a5b30dc1c54 100644 (file)
--- a/prefs.c
+++ b/prefs.c
@@ -1,7 +1,7 @@
 /* prefs.c
  * Routines for handling preferences
  *
- * $Id: prefs.c,v 1.39 2000/08/21 21:24:03 deniel Exp $
+ * $Id: prefs.c,v 1.40 2000/09/08 09:49:20 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -79,6 +79,8 @@ gchar *gui_ptree_line_style_text[] =
 gchar  *gui_ptree_expander_style_text[] =
        { "NONE", "SQUARE", "TRIANGLE", "CIRCULAR", NULL };
 
+gchar  *gui_hex_dump_highlight_style_text[] =
+       { "BOLD", "INVERSE", NULL };
 
 /*
  * List of modules with preference settings.
@@ -527,6 +529,7 @@ read_prefs(int *gpf_errno_return, char **gpf_path_return,
     prefs.gui_ptree_sel_browse = FALSE;
     prefs.gui_ptree_line_style = 0;
     prefs.gui_ptree_expander_style = 1;
+    prefs.gui_hex_dump_highlight_style = 1;
 #ifdef WIN32
     prefs.gui_font_name = g_strdup("-*-lucida console-medium-r-*-*-*-100-*-*-*-*-*-*");
 #else
@@ -753,6 +756,7 @@ prefs_set_pref(char *prefarg)
 #define PRS_GUI_PTREE_SEL_BROWSE "gui.protocol_tree_sel_browse"
 #define PRS_GUI_PTREE_LINE_STYLE "gui.protocol_tree_line_style"
 #define PRS_GUI_PTREE_EXPANDER_STYLE "gui.protocol_tree_expander_style"
+#define PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE "gui.hex_dump_highlight_style"
 #define PRS_GUI_FONT_NAME "gui.font_name"
 #define PRS_GUI_MARKED_FG "gui.marked_frame.fg"
 #define PRS_GUI_MARKED_BG "gui.marked_frame.bg"
@@ -870,6 +874,9 @@ set_pref(gchar *pref_name, gchar *value)
   } else if (strcmp(pref_name, PRS_GUI_PTREE_EXPANDER_STYLE) == 0) {
          prefs.gui_ptree_expander_style =
                  find_index_from_string_array(value, gui_ptree_expander_style_text, 1);
+  } else if (strcmp(pref_name, PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE) == 0) {
+         prefs.gui_hex_dump_highlight_style =
+                 find_index_from_string_array(value, gui_hex_dump_highlight_style_text, 1);
   } else if (strcmp(pref_name, PRS_GUI_FONT_NAME) == 0) {
          if (prefs.gui_font_name != NULL)
                g_free(prefs.gui_font_name);
@@ -1135,6 +1142,10 @@ write_prefs(char **pf_path_return)
   fprintf(pf, PRS_GUI_PTREE_EXPANDER_STYLE ": %s\n",
                  gui_ptree_expander_style_text[prefs.gui_ptree_expander_style]);
 
+  fprintf(pf, "\n# Hex dump highlight style. One of: BOLD, INVERSE\n");
+  fprintf(pf, PRS_GUI_HEX_DUMP_HIGHLIGHT_STYLE ": %s\n",
+                 gui_hex_dump_highlight_style_text[prefs.gui_hex_dump_highlight_style]);
+
   fprintf(pf, "\n# Font name for packet list, protocol tree, and hex dump panes.\n");
   fprintf(pf, PRS_GUI_FONT_NAME ": %s\n", prefs.gui_font_name);
 
@@ -1189,6 +1200,7 @@ copy_prefs(e_prefs *dest, e_prefs *src)
   dest->gui_ptree_sel_browse = src->gui_ptree_sel_browse;
   dest->gui_ptree_line_style = src->gui_ptree_line_style;
   dest->gui_ptree_expander_style = src->gui_ptree_expander_style;
+  dest->gui_hex_dump_highlight_style = src->gui_hex_dump_highlight_style;
   dest->gui_font_name = g_strdup(src->gui_font_name);
   dest->gui_marked_fg = src->gui_marked_fg;
   dest->gui_marked_bg = src->gui_marked_bg;
diff --git a/prefs.h b/prefs.h
index 10f8dd2901e61b698051495bf6121e761ed18171..783f34db56c9b2e399147c39f3e66b3d5dbd832e 100644 (file)
--- a/prefs.h
+++ b/prefs.h
@@ -1,7 +1,7 @@
 /* prefs.h
  * Definitions for preference handling routines
  *
- * $Id: prefs.h,v 1.23 2000/08/21 21:24:04 deniel Exp $
+ * $Id: prefs.h,v 1.24 2000/09/08 09:49:21 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -46,6 +46,7 @@ typedef struct _e_prefs {
   gboolean gui_ptree_sel_browse;
   gint     gui_ptree_line_style;
   gint     gui_ptree_expander_style;
+  gboolean gui_hex_dump_highlight_style;
   gchar   *gui_font_name;
   GdkColor gui_marked_fg;
   GdkColor gui_marked_bg;