summaryrefslogtreecommitdiffhomepage
path: root/mixgtk
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-06-17 23:05:13 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-06-17 23:05:13 +0000
commit2ab4463a125621ea92ef93367b1691a4082c6ad1 (patch)
tree25a1cd08db1a4a9dd38b82933c6dc76ac3324750 /mixgtk
parenteb7320cbe1a79e99b6a5c3cc734209a2cfd8e603 (diff)
downloadmdk-2ab4463a125621ea92ef93367b1691a4082c6ad1.tar.gz
mdk-2ab4463a125621ea92ef93367b1691a4082c6ad1.tar.bz2
variables in status bar
Diffstat (limited to 'mixgtk')
-rw-r--r--mixgtk/mixgtk.glade98
-rw-r--r--mixgtk/mixgtk_mixal.c75
2 files changed, 126 insertions, 47 deletions
diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade
index e33233a..23739d2 100644
--- a/mixgtk/mixgtk.glade
+++ b/mixgtk/mixgtk.glade
@@ -1123,54 +1123,66 @@
</widget>
<widget>
- <class>GtkScrolledWindow</class>
- <name>mixal_scrol</name>
- <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
- <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
- <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
- <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
+ <class>GtkEventBox</class>
+ <name>mixal_eventbox</name>
+ <events>GDK_POINTER_MOTION_MASK</events>
<widget>
- <class>GtkCList</class>
- <name>mixal_clist</name>
- <tooltip>Click to toggle breakpoint</tooltip>
- <can_focus>True</can_focus>
- <signal>
- <name>select_row</name>
- <handler>on_mixal_select_row</handler>
- <after>True</after>
- <last_modification_time>Sun, 11 Mar 2001 01:15:28 GMT</last_modification_time>
- </signal>
- <columns>2</columns>
- <column_widths>152,80</column_widths>
- <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
- <show_titles>True</show_titles>
- <shadow_type>GTK_SHADOW_IN</shadow_type>
+ <class>GtkScrolledWindow</class>
+ <name>mixal_scrol</name>
+ <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
+ <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
+ <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
+ <vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<widget>
- <class>GtkLabel</class>
- <child_name>CList:title</child_name>
- <name>label213</name>
- <label>memory</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0.5</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
- </widget>
+ <class>GtkCList</class>
+ <name>mixal_clist</name>
+ <tooltip>Click to toggle breakpoint</tooltip>
+ <can_focus>True</can_focus>
+ <events>GDK_POINTER_MOTION_MASK</events>
+ <signal>
+ <name>select_row</name>
+ <handler>on_mixal_select_row</handler>
+ <after>True</after>
+ <last_modification_time>Sun, 11 Mar 2001 01:15:28 GMT</last_modification_time>
+ </signal>
+ <signal>
+ <name>motion_notify_event</name>
+ <handler>on_mixal_motion_notify_event</handler>
+ <last_modification_time>Sun, 17 Jun 2001 19:44:48 GMT</last_modification_time>
+ </signal>
+ <columns>2</columns>
+ <column_widths>152,80</column_widths>
+ <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
+ <show_titles>True</show_titles>
+ <shadow_type>GTK_SHADOW_IN</shadow_type>
- <widget>
- <class>GtkLabel</class>
- <child_name>CList:title</child_name>
- <name>label214</name>
- <label>source</label>
- <justify>GTK_JUSTIFY_CENTER</justify>
- <wrap>False</wrap>
- <xalign>0.5</xalign>
- <yalign>0.5</yalign>
- <xpad>0</xpad>
- <ypad>0</ypad>
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>CList:title</child_name>
+ <name>label213</name>
+ <label>memory</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>CList:title</child_name>
+ <name>label214</name>
+ <label>source</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
</widget>
</widget>
</widget>
diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c
index 8cbb015..db2218a 100644
--- a/mixgtk/mixgtk_mixal.c
+++ b/mixgtk/mixgtk_mixal.c
@@ -33,6 +33,10 @@
static mix_vm_t *vm_;
static GtkCList *clist_;
static gulong lineno_;
+static GtkStatusbar *status_;
+static gint status_context_;
+static GPtrArray *tips_text_ = NULL;
+
static GdkColor colors_[3][2];
static GdkColormap *colormap_ = NULL;
static const char* default_colors_[3][2] = {
@@ -86,7 +90,11 @@ mixgtk_mixal_init (mix_vm_t *vm)
vm_ = vm;
clist_ = GTK_CLIST (mixgtk_widget_factory_get (MIXGTK_WIDGET_MIXAL));
g_return_val_if_fail (clist_ != NULL, FALSE);
-
+
+ status_ = GTK_STATUSBAR (mixgtk_widget_factory_get (MIXGTK_WIDGET_STATUSBAR));
+ g_return_val_if_fail (status_ != NULL, FALSE);
+ status_context_ = gtk_statusbar_get_context_id (status_, "MIXAL status");
+
/* allocate colors */
colormap_ = gtk_widget_get_colormap (GTK_WIDGET (clist_));
for (i = 0; i < 3; ++i)
@@ -134,6 +142,42 @@ mixgtk_mixal_get_color (mixal_line_t line, mixal_line_zone_t zone)
}
/* load the corresponding mixal file */
+static void
+update_tips_ (const mix_symbol_table_t *table,
+ const gchar *line)
+{
+ enum {SIZE = 256};
+ static gchar BUFFER[256];
+ static const gchar *DELIMITERS = " /+*=-()\t,:\n";
+ if (line)
+ {
+ guint k = 0;
+ gchar *tip = g_strdup ("");
+ gchar *new_tip;
+ gchar **tokens;
+ gchar *text = g_strdup (line);
+ text = g_strdelimit (text, DELIMITERS, ' ');
+ tokens = g_strsplit (g_strstrip (text), " ", -1);
+ while (tokens[k])
+ {
+ if (mix_symbol_table_is_defined (table, tokens[k]))
+ {
+ mix_word_t val = mix_symbol_table_value (table, tokens[k]);
+ snprintf (BUFFER, SIZE, "[ %s = %s%ld ]", tokens[k],
+ mix_word_is_negative (val)? "-" : "+",
+ mix_word_magnitude (val));
+ new_tip = g_strconcat (tip, " ", BUFFER, NULL);
+ g_free (tip);
+ tip = new_tip;
+ }
+ ++k;
+ }
+ g_ptr_array_add (tips_text_, (gpointer)tip);
+ g_strfreev (tokens);
+ g_free (text);
+ }
+}
+
void
mixgtk_mixal_load_file (void)
{
@@ -148,19 +192,21 @@ mixgtk_mixal_load_file (void)
g_assert (clist_);
gtk_clist_clear (clist_);
-
file = mix_vm_get_src_file (vm_);
if (file != NULL)
{
gint k;
mix_address_t addr;
-
+ const mix_symbol_table_t *table = mix_vm_get_symbol_table (vm_);
+
lineno_ = mix_src_file_get_line_no (file);
-
+ if (tips_text_) g_ptr_array_free (tips_text_, TRUE);
+ tips_text_ = g_ptr_array_new ();
gtk_clist_freeze (clist_);
for (k = 0; k < lineno_; ++k)
{
const gchar *line = mix_src_file_get_line (file, k + 1);
+
snprintf (CONT, CONT_SIZE, "%03d: %s", k + 1, line);
addr = mix_vm_get_lineno_address (vm_, k + 1);
if (addr != MIX_VM_CELL_NO)
@@ -174,6 +220,8 @@ mixgtk_mixal_load_file (void)
gtk_clist_append (clist_, TEXT);
gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER
(mix_short_magnitude (addr)));
+ if (table) update_tips_ (table, line);
+
}
gtk_clist_append (clist_, NULL_TEXT);
gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER (MIX_VM_CELL_NO));
@@ -285,3 +333,22 @@ on_mixal_select_row (GtkWidget *w, gint row, gint col, GdkEventButton *e,
}
}
+gint
+on_mixal_motion_notify_event (GtkWidget *list, GdkEventMotion *event,
+ gpointer data)
+{
+ static gint last_row = 0;
+ static guint last_message = 0;
+ gint row = last_row, col = 0;
+ if (gtk_clist_get_selection_info (clist_, event->x, event->y, &row, &col)
+ && row != last_row && tips_text_)
+ {
+ last_row = row;
+ if (last_message)
+ gtk_statusbar_remove (status_, status_context_, last_message);
+ last_message = gtk_statusbar_push
+ (status_, status_context_,
+ (const gchar *)g_ptr_array_index (tips_text_, row));
+ }
+ return FALSE;
+}