From 2ab4463a125621ea92ef93367b1691a4082c6ad1 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 17 Jun 2001 23:05:13 +0000 Subject: variables in status bar --- mixgtk/mixgtk.glade | 98 +++++++++++++++++++++++++++++---------------------- mixgtk/mixgtk_mixal.c | 75 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 126 insertions(+), 47 deletions(-) (limited to 'mixgtk') 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 @@ - GtkScrolledWindow - mixal_scrol - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS + GtkEventBox + mixal_eventbox + GDK_POINTER_MOTION_MASK - GtkCList - mixal_clist - Click to toggle breakpoint - True - - select_row - on_mixal_select_row - True - Sun, 11 Mar 2001 01:15:28 GMT - - 2 - 152,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN + GtkScrolledWindow + mixal_scrol + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS - GtkLabel - CList:title - label213 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - + GtkCList + mixal_clist + Click to toggle breakpoint + True + GDK_POINTER_MOTION_MASK + + select_row + on_mixal_select_row + True + Sun, 11 Mar 2001 01:15:28 GMT + + + motion_notify_event + on_mixal_motion_notify_event + Sun, 17 Jun 2001 19:44:48 GMT + + 2 + 152,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN - - GtkLabel - CList:title - label214 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 + + GtkLabel + CList:title + label213 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label214 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + 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; +} -- cgit v1.2.3