summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mixgtk/mixgtk.glade208
-rw-r--r--mixgtk/mixgtk_cmd_dispatcher.c141
-rw-r--r--mixgtk/mixgtk_gen_handlers.c15
-rw-r--r--mixgtk/mixgtk_mixal.c144
-rw-r--r--mixgtk/mixgtk_mixal.h23
-rw-r--r--mixgtk/mixgtk_widgets.h2
-rw-r--r--mixlib/mix_src_file.c13
-rw-r--r--mixlib/mix_vm.c8
-rw-r--r--mixlib/mix_vm.h3
-rw-r--r--mixlib/mix_vm_command.c30
10 files changed, 451 insertions, 136 deletions
diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade
index b1d7927..154e708 100644
--- a/mixgtk/mixgtk.glade
+++ b/mixgtk/mixgtk.glade
@@ -63,6 +63,7 @@
<widget>
<class>GtkMenuItem</class>
<name>file_open</name>
+ <tooltip>Load a MIX file</tooltip>
<accelerator>
<modifiers>GDK_MOD1_MASK</modifiers>
<key>GDK_F3</key>
@@ -73,13 +74,14 @@
<handler>on_file_open_activate</handler>
<last_modification_time>Tue, 20 Feb 2001 22:37:58 GMT</last_modification_time>
</signal>
- <label>_Open...</label>
+ <label>_Load...</label>
<right_justify>False</right_justify>
</widget>
<widget>
<class>GtkMenuItem</class>
<name>file_exit</name>
+ <tooltip>Exit application</tooltip>
<accelerator>
<modifiers>GDK_MOD1_MASK</modifiers>
<key>GDK_Q</key>
@@ -99,8 +101,47 @@
<widget>
<class>GtkMenuItem</class>
<name>debug</name>
- <label>_Debug</label>
+ <label>Debu_g</label>
<right_justify>False</right_justify>
+
+ <widget>
+ <class>GtkMenu</class>
+ <name>debug_menu</name>
+
+ <widget>
+ <class>GtkMenuItem</class>
+ <name>debug_run</name>
+ <accelerator>
+ <modifiers>GDK_MOD1_MASK</modifiers>
+ <key>GDK_R</key>
+ <signal>activate</signal>
+ </accelerator>
+ <signal>
+ <name>activate</name>
+ <handler>on_debug_run_activate</handler>
+ <last_modification_time>Sat, 10 Mar 2001 11:35:16 GMT</last_modification_time>
+ </signal>
+ <label>_Run</label>
+ <right_justify>False</right_justify>
+ </widget>
+
+ <widget>
+ <class>GtkMenuItem</class>
+ <name>debug_next</name>
+ <accelerator>
+ <modifiers>GDK_MOD1_MASK</modifiers>
+ <key>GDK_N</key>
+ <signal>activate</signal>
+ </accelerator>
+ <signal>
+ <name>activate</name>
+ <handler>on_debug_next_activate</handler>
+ <last_modification_time>Sat, 10 Mar 2001 11:35:16 GMT</last_modification_time>
+ </signal>
+ <label>_Next</label>
+ <right_justify>False</right_justify>
+ </widget>
+ </widget>
</widget>
</widget>
@@ -174,6 +215,11 @@
<width>60</width>
<height>24</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:45:00 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -188,6 +234,12 @@
<width>118</width>
<height>22</height>
<can_focus>True</can_focus>
+ <events>GDK_BUTTON_PRESS_MASK</events>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:42:43 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -202,6 +254,11 @@
<width>118</width>
<height>22</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:43:29 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -216,6 +273,11 @@
<width>60</width>
<height>22</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:45:39 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -230,6 +292,11 @@
<width>60</width>
<height>24</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:43:44 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -244,6 +311,11 @@
<width>60</width>
<height>22</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:46:37 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -258,6 +330,11 @@
<width>60</width>
<height>24</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:44:21 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -272,6 +349,11 @@
<width>60</width>
<height>22</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:46:58 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -575,6 +657,11 @@
<width>60</width>
<height>22</height>
<can_focus>True</can_focus>
+ <signal>
+ <name>button_press_event</name>
+ <handler>on_register_click</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:46:05 GMT</last_modification_time>
+ </signal>
<editable>False</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
@@ -746,9 +833,9 @@
<class>GtkCheckButton</class>
<name>over_toggle</name>
<x>288</x>
- <y>156</y>
- <width>72</width>
- <height>24</height>
+ <y>168</y>
+ <width>88</width>
+ <height>16</height>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
@@ -765,7 +852,7 @@
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label105</name>
- <label>MIX</label>
+ <label>_MIX</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -776,7 +863,7 @@
<widget>
<class>GtkScrolledWindow</class>
- <name>mixal_scroll</name>
+ <name>scrolledwindow28</name>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
@@ -785,9 +872,16 @@
<widget>
<class>GtkCList</class>
<name>mixal_clist</name>
+ <tooltip>Click to toggle breakpoint</tooltip>
<can_focus>True</can_focus>
- <columns>3</columns>
- <column_widths>60,114,80</column_widths>
+ <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>
@@ -795,21 +889,8 @@
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
- <name>label168</name>
- <label>address</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>label169</name>
- <label>contents</label>
+ <name>label213</name>
+ <label>memory</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -821,7 +902,7 @@
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
- <name>label170</name>
+ <name>label214</name>
<label>source</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@@ -837,7 +918,7 @@
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label106</name>
- <label>MIXAL</label>
+ <label>MI_XAL</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -882,7 +963,7 @@
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>devices_label</name>
- <label>Devices</label>
+ <label>De_vices</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -933,7 +1014,6 @@
<widget>
<class>GtkText</class>
<name>command_log</name>
- <can_focus>True</can_focus>
<editable>False</editable>
<text></text>
</widget>
@@ -944,6 +1024,7 @@
<name>command_prompt</name>
<tooltip>Enter MIXVM command here</tooltip>
<can_focus>True</can_focus>
+ <has_focus>True</has_focus>
<signal>
<name>activate</name>
<handler>on_mixvm_cmd_entry_activate</handler>
@@ -1029,7 +1110,7 @@
<widget>
<class>GtkButton</class>
- <name>button11</name>
+ <name>word_reset</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>Reset</label>
@@ -1038,7 +1119,7 @@
<widget>
<class>GtkButton</class>
- <name>button12</name>
+ <name>word_ok</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<label>OK</label>
@@ -1047,9 +1128,14 @@
<widget>
<class>GtkButton</class>
- <name>button13</name>
+ <name>word_cancel</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>gtk_widget_hide</handler>
+ <last_modification_time>Sun, 11 Mar 2001 11:56:42 GMT</last_modification_time>
+ </signal>
<label>Cancel</label>
<relief>GTK_RELIEF_NORMAL</relief>
</widget>
@@ -1069,7 +1155,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry31</name>
+ <name>word_decimal</name>
<x>88</x>
<y>32</y>
<width>143</width>
@@ -1083,7 +1169,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry34</name>
+ <name>word_b2</name>
<x>136</x>
<y>64</y>
<width>22</width>
@@ -1111,7 +1197,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry38</name>
+ <name>word_b3</name>
<x>160</x>
<y>64</y>
<width>22</width>
@@ -1125,7 +1211,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry39</name>
+ <name>word_b4</name>
<x>184</x>
<y>64</y>
<width>22</width>
@@ -1139,7 +1225,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry41</name>
+ <name>word_b5</name>
<x>208</x>
<y>64</y>
<width>22</width>
@@ -1152,24 +1238,8 @@
</widget>
<widget>
- <class>GtkLabel</class>
- <name>label60</name>
- <x>16</x>
- <y>34</y>
- <width>67</width>
- <height>20</height>
- <label>Decimal</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>GtkEntry</class>
- <name>entry40</name>
+ <name>word_b1</name>
<x>112</x>
<y>64</y>
<width>22</width>
@@ -1183,7 +1253,7 @@
<widget>
<class>GtkEntry</class>
- <name>entry42</name>
+ <name>word_sign</name>
<x>88</x>
<y>64</y>
<width>16</width>
@@ -1197,12 +1267,12 @@
<widget>
<class>GtkLabel</class>
- <name>label61</name>
- <x>22</x>
- <y>67</y>
- <width>41</width>
- <height>16</height>
- <label>Bytes</label>
+ <name>label60</name>
+ <x>16</x>
+ <y>34</y>
+ <width>67</width>
+ <height>20</height>
+ <label>Decimal</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -1213,12 +1283,12 @@
<widget>
<class>GtkLabel</class>
- <name>label63</name>
- <x>152</x>
- <y>8</y>
- <width>80</width>
+ <name>label61</name>
+ <x>22</x>
+ <y>67</y>
+ <width>41</width>
<height>16</height>
- <label>Register A</label>
+ <label>Bytes</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -1229,12 +1299,12 @@
<widget>
<class>GtkLabel</class>
- <name>label62</name>
- <x>48</x>
+ <name>word_label</name>
+ <x>16</x>
<y>8</y>
- <width>104</width>
+ <width>216</width>
<height>16</height>
- <label>Enter word for:</label>
+ <label>Enter value</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c
index d14c5ee..71b5877 100644
--- a/mixgtk/mixgtk_cmd_dispatcher.c
+++ b/mixgtk/mixgtk_cmd_dispatcher.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_cmd_dispatcher.c :
* Implementation of the functions declared in mixgtk_cmd_dispatcher.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/10 00:49:04 jose"
+ * Last change: Time-stamp: "01/03/12 02:05:43 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -23,6 +23,7 @@
#define _GNU_SOURCE 1
+#include <stdlib.h>
#include <stdio.h>
#include <mixlib/mix_vm_command.h>
#include "mixgtk_cmd_dispatcher.h"
@@ -39,10 +40,24 @@ struct mixgtk_dispatch_
size_t out_buffer_size;
GtkWidget *prompt;
GtkWidget *log;
+ GCompletion *completions;
};
static struct mixgtk_dispatch_ dis_data_ = {NULL};
+/* completions */
+static void
+init_completions_ (void)
+{
+ GList *cmds = NULL;
+ gint k;
+
+ dis_data_.completions = g_completion_new (NULL);
+ for (k = 0; k < MIX_CMD_INVALID; ++k)
+ cmds = g_list_append (cmds, (gpointer) mix_vm_command_to_string (k));
+ g_completion_add_items (dis_data_.completions, cmds);
+}
+
/* global hooks for the command dispatcher */
static void
global_pre_hook_ (mix_vm_cmd_dispatcher_t *dis,
@@ -104,6 +119,61 @@ next_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
mixgtk_mixal_update ();
}
+static void
+linebp_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
+ gpointer data)
+{
+ if (arg && strlen (arg)) mixgtk_mixal_update_bp_at_line (atoi (arg));
+}
+
+static void
+addrbp_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
+ gpointer data)
+{
+ if (arg && strlen (arg)) mixgtk_mixal_update_bp_at_address (atoi (arg));
+}
+
+static void
+allbp_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg,
+ gpointer data)
+{
+ mixgtk_mixal_update_bp_all ();
+}
+
+
+static void
+install_hooks_ (void)
+{
+ mix_vm_cmd_dispatcher_global_pre_hook (dis_data_.dispatcher,
+ global_pre_hook_, NULL);
+ mix_vm_cmd_dispatcher_global_post_hook (dis_data_.dispatcher,
+ global_post_hook_, NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_LOAD, load_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_RUN, run_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_NEXT, next_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_SBP, linebp_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_CBP, linebp_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_SBPA, addrbp_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_CBPA, addrbp_post_hook_,
+ NULL);
+ mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
+ MIX_CMD_CABP, allbp_post_hook_,
+ NULL);
+}
+
/* initialise the command dispatcher */
gboolean
@@ -125,20 +195,11 @@ mixgtk_cmd_dispatcher_init (void)
dis_data_.out = out;
dis_data_.dispatcher = mix_vm_cmd_dispatcher_new (out, out);
mix_vm_cmd_dispatcher_print_time (dis_data_.dispatcher, FALSE);
- mix_vm_cmd_dispatcher_global_pre_hook (dis_data_.dispatcher,
- global_pre_hook_, NULL);
- mix_vm_cmd_dispatcher_global_post_hook (dis_data_.dispatcher,
- global_post_hook_, NULL);
- mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
- MIX_CMD_LOAD, load_post_hook_,
- NULL);
- mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
- MIX_CMD_RUN, run_post_hook_,
- NULL);
- mix_vm_cmd_dispatcher_post_hook (dis_data_.dispatcher,
- MIX_CMD_NEXT, next_post_hook_,
- NULL);
+ install_hooks_ ();
}
+
+ if (!dis_data_.completions) init_completions_ ();
+
return TRUE;
}
@@ -146,7 +207,7 @@ mixgtk_cmd_dispatcher_init (void)
void
mixgtk_cmd_dispatcher_dispatch (const gchar *command)
{
- GtkWidget *entry = mixgtk_widget_factory_get (MIXGTK_WIDGET_PROMPT);
+ GtkWidget *entry = dis_data_.prompt;
g_return_if_fail (command != NULL);
g_assert (entry != NULL);
gtk_entry_set_text (GTK_ENTRY (entry), command);
@@ -177,9 +238,53 @@ void
on_mixvm_cmd_entry_activate (GtkWidget *w, gpointer e)
{
gchar *text;
+ GList *cmds = NULL;
+ gchar *prefix = NULL;
+
text = gtk_entry_get_text (GTK_ENTRY (w));
- mix_vm_cmd_dispatcher_dispatch_text (dis_data_.dispatcher, text);
- gtk_entry_set_text (GTK_ENTRY (w), "");
-}
+ if (mix_vm_command_from_string (g_strchomp (text)) != MIX_CMD_INVALID)
+ {
+ mix_vm_cmd_dispatcher_dispatch_text (dis_data_.dispatcher, text);
+ gtk_entry_set_text (GTK_ENTRY (w), "");
+ return;
+ }
+
+ cmds = g_completion_complete (dis_data_.completions, text, &prefix);
+ if (prefix != NULL)
+ {
+ gtk_entry_set_text (GTK_ENTRY (w), prefix);
+ g_free (prefix);
+ if (g_list_length (cmds) > 1)
+ {
+ gint k = 0;
+ gtk_text_insert (GTK_TEXT (dis_data_.log),
+ NULL, NULL, NULL, "Completions:\n", -1);
+ while (cmds)
+ {
+ ++k;
+ gtk_text_insert (GTK_TEXT (dis_data_.log),
+ NULL, NULL, NULL,
+ (gchar *)(cmds->data), -1);
+ gtk_text_insert (GTK_TEXT (dis_data_.log),
+ NULL, NULL, NULL, " ", -1);
+ if (k%5 == 0)
+ gtk_text_insert (GTK_TEXT (dis_data_.log),
+ NULL, NULL, NULL, "\n", -1);
+
+ cmds = cmds->next;
+ }
+ if (k%5 != 0)
+ gtk_text_insert (GTK_TEXT (dis_data_.log),
+ NULL, NULL, NULL, "\n", -1);
+ }
+ else
+ gtk_entry_append_text (GTK_ENTRY (w), " ");
+ }
+ else
+ {
+ mix_vm_cmd_dispatcher_dispatch_text (dis_data_.dispatcher, text);
+ gtk_entry_set_text (GTK_ENTRY (w), "");
+ }
+}
diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c
index 8f0c07c..eefeae3 100644
--- a/mixgtk/mixgtk_gen_handlers.c
+++ b/mixgtk/mixgtk_gen_handlers.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_gen_handlers.c :
* Implementation of the functions declared in mixgtk_gen_handlers.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/07 23:25:10 jose"
+ * Last change: Time-stamp: "01/03/10 15:51:47 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -68,6 +68,19 @@ on_file_open_activate (GtkWidget *w, gpointer data)
}
void
+on_debug_run_activate (GtkWidget *w, gpointer p)
+{
+ mixgtk_cmd_dispatcher_dispatch (mix_vm_command_to_string (MIX_CMD_RUN));
+}
+
+void
+on_debug_next_activate (GtkWidget *w, gpointer p)
+{
+ mixgtk_cmd_dispatcher_dispatch (mix_vm_command_to_string (MIX_CMD_NEXT));
+}
+
+
+void
on_file_exit_activate (GtkWidget *w, gpointer data)
{
gtk_main_quit ();
diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c
index d3ce72b..eeef239 100644
--- a/mixgtk/mixgtk_mixal.c
+++ b/mixgtk/mixgtk_mixal.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_mixal.c :
* Implementation of the functions declared in mixgtk_mixal.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/10 02:27:52 jose"
+ * Last change: Time-stamp: "01/03/11 02:45:28 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -26,19 +26,41 @@
#include "mixgtk_widgets.h"
#include "mixgtk_mixal.h"
-static const mix_vm_t *vm_;
+
+static mix_vm_t *vm_;
static GtkCList *clist_;
+static GdkColor sel_color_;
+static GdkColor break_color_;
+static GdkColor plain_color_;
static gulong lineno_;
+#define SEL_COLOR_ "lightgrey"
+#define BREAK_COLOR_ "red"
+#define PLAIN_COLOR_ "white"
+
+static gboolean
+init_color_ (GdkColor *c, const gchar *name)
+{
+ static GdkColormap *cmap = NULL;
+ if (!cmap) cmap = gtk_widget_get_colormap (GTK_WIDGET (clist_));
+ return (gdk_color_parse (name, c) &&
+ gdk_colormap_alloc_color (cmap, c, FALSE, TRUE));
+}
/* initialise the mixal widgets */
gboolean
-mixgtk_mixal_init (const mix_vm_t *vm)
+mixgtk_mixal_init (mix_vm_t *vm)
{
g_return_val_if_fail (vm != NULL, FALSE);
vm_ = vm;
clist_ = GTK_CLIST (mixgtk_widget_factory_get (MIXGTK_WIDGET_MIXAL));
g_return_val_if_fail (clist_ != NULL, FALSE);
+
+ /* allocate colors */
+ g_return_val_if_fail (init_color_ (&sel_color_, SEL_COLOR_), FALSE);
+ g_return_val_if_fail (init_color_ (&break_color_, BREAK_COLOR_), FALSE);
+ g_return_val_if_fail (init_color_ (&plain_color_, PLAIN_COLOR_), FALSE);
+
return TRUE;
}
@@ -46,9 +68,10 @@ mixgtk_mixal_init (const mix_vm_t *vm)
void
mixgtk_mixal_load_file (void)
{
- enum {ADDR_SIZE = 10, CONT_SIZE = 20};
+ enum {ADDR_SIZE = 20, CONT_SIZE = 200};
static gchar ADDR[ADDR_SIZE], CONT[CONT_SIZE];
- static const gchar *TEXT[3];
+ static gchar *TEXT[] = {ADDR, CONT};
+ static gchar *NULL_TEXT[] = {NULL, NULL};
const mix_src_file_t *file;
@@ -68,22 +91,24 @@ mixgtk_mixal_load_file (void)
gtk_clist_freeze (clist_);
for (k = 0; k < lineno_; ++k)
{
- TEXT[0] = TEXT[1] = "";
- TEXT[2] = mix_src_file_get_line (file, k + 1);
+ 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)
{
- snprintf (ADDR, ADDR_SIZE, "%04d", mix_short_magnitude (addr));
+ sprintf (ADDR, "%04d: ", mix_short_magnitude (addr));
mix_word_print_to_buffer (mix_vm_get_addr_contents (vm_, addr),
- CONT);
- TEXT[0] = ADDR;
- TEXT[1] = CONT;
+ ADDR + strlen (ADDR));
}
- gtk_clist_append (clist_, (gchar **)TEXT);
+ else
+ ADDR[0] = '\0';
+ gtk_clist_append (clist_, TEXT);
+ gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER
+ (mix_short_magnitude (addr)));
}
- TEXT[0] = TEXT[1] = TEXT[2] = NULL;
- gtk_clist_append (clist_, (gchar **)TEXT);
-
+ gtk_clist_append (clist_, NULL_TEXT);
+ gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER (MIX_VM_CELL_NO));
+ gtk_clist_unselect_row (clist_, 0, 0);
gtk_clist_thaw (clist_);
}
else
@@ -92,24 +117,97 @@ mixgtk_mixal_load_file (void)
/* update the widgets */
+static void
+reset_bg_ (gint row)
+{
+ gint addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, row));
+ gboolean isset = mix_vm_has_breakpoint_at_address (vm_, addr);
+ gtk_clist_set_background (clist_, row,
+ isset ? &break_color_ : &plain_color_);
+}
+
+static void
+select_row_ (gint row)
+{
+ static gint last = -1;
+
+ gtk_clist_set_background (clist_, row, &sel_color_);
+ if (gtk_clist_row_is_visible (clist_, row) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto (clist_, row, 0, 0.25, 0);
+ if (last != -1 && last != row) reset_bg_ (last);
+ last = row;
+}
+
void
mixgtk_mixal_update (void)
{
gint addr = 0;
gint k = 0;
- gchar *addrval = NULL;
g_assert (vm_);
g_assert (clist_);
addr = mix_short_magnitude (mix_vm_get_prog_count (vm_));
- while (k < lineno_)
+ k = gtk_clist_find_row_from_data (clist_, GINT_TO_POINTER (addr));
+ select_row_ (k);
+}
+
+/* breakpoints */
+void
+mixgtk_mixal_update_bp_at_address (guint addr)
+{
+ gint k;
+
+ g_assert (vm_);
+ g_assert (clist_);
+
+ k = gtk_clist_find_row_from_data (clist_, GINT_TO_POINTER (addr));
+ reset_bg_ (k);
+}
+
+void
+mixgtk_mixal_update_bp_at_line (guint line)
+{
+ if ( line < 1 ) return;
+
+ while (line < lineno_)
{
- gtk_clist_get_text (clist_, k, 0, &addrval);
- if (addrval && atoi(addrval) == addr) break;
- ++k;
+ gint addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, line - 1));
+ if (addr != MIX_VM_CELL_NO) break;
+ ++line;
}
- gtk_clist_select_row (clist_, k, 0);
- if (gtk_clist_row_is_visible (clist_, k) != GTK_VISIBILITY_FULL)
- gtk_clist_moveto (clist_, k, 0, 0.25, 0);
+ reset_bg_ (line - 1);
}
+
+void
+mixgtk_mixal_update_bp_all ()
+{
+ gint k, addr;
+ for (k = 0; k < lineno_; ++k) reset_bg_ (k);
+ addr = mix_vm_get_prog_count (vm_);
+ k = gtk_clist_find_row_from_data (clist_, GINT_TO_POINTER (addr));
+ select_row_ (k);
+}
+
+/* callbacks */
+void
+on_mixal_select_row (GtkWidget *w, gint row, gint col, GdkEventButton *e,
+ gpointer data)
+{
+ gboolean isset;
+ gint addr, pc;
+
+ gtk_clist_unselect_row (clist_, row, col);
+ addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, row));
+ pc = mix_vm_get_prog_count (vm_);
+ if (addr < MIX_VM_CELL_NO && addr != pc)
+ {
+ isset = mix_vm_has_breakpoint_at_address (vm_, addr);
+ if (isset)
+ mix_vm_clear_breakpoint_address (vm_, addr);
+ else
+ mix_vm_set_breakpoint_address (vm_, addr);
+ reset_bg_ (row);
+ }
+}
+
diff --git a/mixgtk/mixgtk_mixal.h b/mixgtk/mixgtk_mixal.h
index 076603c..819819a 100644
--- a/mixgtk/mixgtk_mixal.h
+++ b/mixgtk/mixgtk_mixal.h
@@ -1,7 +1,7 @@
/* -*-c-*- ---------------- mixgtk_mixal.h :
* Declarations for functions displaying the mixal source file
* ------------------------------------------------------------------
- * Last change: Time-stamp: <01/03/09 23:57:14 jose>
+ * Last change: Time-stamp: <01/03/11 00:19:30 jose>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -25,21 +25,36 @@
#ifndef MIXGTK_MIXAL_H
#define MIXGTK_MIXAL_H
+#include <gtk/gtk.h>
#include <mixlib/mix_vm.h>
-/* initialise the mixal widgets */
+/* initialise the mixal widget */
extern gboolean
-mixgtk_mixal_init (const mix_vm_t *vm);
+mixgtk_mixal_init (mix_vm_t *vm);
/* load the corresponding mixal file */
extern void
mixgtk_mixal_load_file (void);
-/* update the widgets */
+/* update the widget */
extern void
mixgtk_mixal_update (void);
+/* breakpoints */
+extern void
+mixgtk_mixal_update_bp_at_address (guint addr);
+
+extern void
+mixgtk_mixal_update_bp_at_line (guint line);
+extern void
+mixgtk_mixal_update_bp_all (void);
+
+
+/* callbacks */
+extern void
+on_mixal_select_row (GtkWidget *w, gint row, gint col, GdkEventButton *e,
+ gpointer data);
#endif /* MIXGTK_MIXAL_H */
diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h
index ac221cc..e457518 100644
--- a/mixgtk/mixgtk_widgets.h
+++ b/mixgtk/mixgtk_widgets.h
@@ -1,7 +1,7 @@
/* -*-c-*- ---------------- mixgtk_widgets.h :
* glade-based factory of mixvm widgets
* ------------------------------------------------------------------
- * Last change: Time-stamp: <01/03/09 23:08:10 jose>
+ * Last change: Time-stamp: <01/03/11 14:07:32 jose>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
diff --git a/mixlib/mix_src_file.c b/mixlib/mix_src_file.c
index 1cb6656..4e1489b 100644
--- a/mixlib/mix_src_file.c
+++ b/mixlib/mix_src_file.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mix_src_file.c :
* Implementation of the functions declared in mix_src_file.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/10 03:25:50 jose"
+ * Last change: Time-stamp: "01/03/10 15:23:46 jose"
* ------------------------------------------------------------------
* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
*
@@ -22,6 +22,7 @@
*/
#include <ctype.h>
+#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "mix_src_file.h"
@@ -42,8 +43,8 @@ format_line_ (gchar *line)
gint k = 0;
if (!line) return line;
- if (line[0] == '*' || strlen(line) == 0) return g_strdup (line);
-
+ if (line[0] == '*' || strlen(line) == 0)
+ return g_strdup (line);
if (isspace (line[0]))
{
@@ -64,15 +65,15 @@ format_line_ (gchar *line)
while (line[k] && !isspace (line[k])) ++k;
while (line[k] && isspace (line[k])) ++k;
line[k - 1] = 0;
- rest = (line[k]) ? line + k: "\n";
+ rest = (line[k]) ? line + k: "";
}
else
{
- op = rest = "\n";
+ op = rest = "";
}
- return g_strdup_printf ("%-12s%-6s%s", label, op, rest);
+ return g_strdup_printf ("%-11s %-5s %s", label, op, rest);
}
/* load the source file lines into memory */
diff --git a/mixlib/mix_vm.c b/mixlib/mix_vm.c
index 0a885d8..9a39247 100644
--- a/mixlib/mix_vm.c
+++ b/mixlib/mix_vm.c
@@ -496,6 +496,14 @@ mix_vm_set_breakpoint_address (mix_vm_t *vm, guint address)
return MIX_VM_BP_OK;
}
+gboolean
+mix_vm_has_breakpoint_at_address (const mix_vm_t *vm, guint address)
+{
+ g_return_val_if_fail (vm != NULL, FALSE);
+ if (address >= MIX_VM_CELL_NO) return FALSE;
+ return (bp_is_set_ (vm, address));
+}
+
static gint
clear_break_ (gpointer key, gpointer value, gpointer data)
{
diff --git a/mixlib/mix_vm.h b/mixlib/mix_vm.h
index 95ed742..b64e197 100644
--- a/mixlib/mix_vm.h
+++ b/mixlib/mix_vm.h
@@ -189,6 +189,9 @@ mix_vm_clear_breakpoint (mix_vm_t *vm, guint lineno);
extern gint /* one of MIX_VM_BP_ */
mix_vm_clear_breakpoint_address (mix_vm_t *vm, guint address) ;
+extern gboolean
+mix_vm_has_breakpoint_at_address (const mix_vm_t *vm, guint address);
+
extern void
mix_vm_clear_all_breakpoints (mix_vm_t *vm);
diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c
index 1ef0d7e..90283f0 100644
--- a/mixlib/mix_vm_command.c
+++ b/mixlib/mix_vm_command.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mix_vm_command.c :
* Implementation of the functions declared in mix_vm_command.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "01/03/10 03:21:33 jose"
+ * Last change: Time-stamp: "01/03/11 01:50:17 jose"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -48,6 +48,7 @@ typedef struct
struct mix_vm_cmd_dispatcher_t
{
mix_vm_t *vm; /* the virtual machine */
+ gchar *program; /* the name of the last loaded program */
FILE *out; /* message output file */
FILE *err; /* error output file */
mix_dump_context_t *dump; /* dump context for output */
@@ -193,6 +194,7 @@ mix_vm_cmd_dispatcher_new (FILE *out_fd, /* output messages file */
result->uptime = result->laptime = result->progtime = 0;
result->printtime = TRUE;
result->trace = FALSE;
+ result->program = NULL;
result->eval = mix_eval_new ();
result->dump = mix_dump_context_new (out_fd,
MIX_SHORT_ZERO, MIX_SHORT_ZERO,
@@ -480,6 +482,13 @@ cmd_load_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
perror (NULL);
return TRUE + 1;
}
+
+ if (dis->program != arg)
+ {
+ if (dis->program) g_free (dis->program);
+ dis->program = g_strdup (arg);
+ }
+
mix_eval_set_symbols_from_table (dis->eval,
mix_vm_get_symbol_table (dis->vm));
@@ -496,14 +505,11 @@ cmd_run_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
if (arg != NULL && *arg != '\0' && cmd_load_ (dis, arg) != TRUE)
return TRUE;
- fputs (_("Running ...\n"), dis->out);
-
- if (mix_vm_is_halted (dis->vm))
- {
- mix_vm_reset_program (dis->vm);
- dis->laptime = dis->progtime = 0;
- }
+ if (mix_vm_is_halted (dis->vm)) cmd_load_ (dis, dis->program);
+
+ fputs (_("Running ...\n"), dis->out);
+
switch (run_and_trace_ (dis))
{
case MIX_VM_HALT:
@@ -552,12 +558,8 @@ cmd_next_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
ins_no = atoi (arg);
}
- if (mix_vm_is_halted (dis->vm))
- {
- mix_vm_reset_program (dis->vm);
- dis->laptime = dis->progtime = 0;
- }
-
+ if (mix_vm_is_halted (dis->vm)) cmd_load_ (dis, dis->program);
+
while ( ins_no-- > 0 )
{
if (dis->trace) trace_ (dis);