From 1c345e559710ec6200f7d508629bd24457a20a80 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 22 Mar 2001 03:01:01 +0000 Subject: initial import (sf 0.3beta) --- mixgtk/.cvsignore | 7 + mixgtk/Makefile.am | 31 + mixgtk/mixgtk.c | 91 +++ mixgtk/mixgtk.glade | 1703 ++++++++++++++++++++++++++++++++++++++++ mixgtk/mixgtk_cmd_dispatcher.c | 314 ++++++++ mixgtk/mixgtk_cmd_dispatcher.h | 55 ++ mixgtk/mixgtk_device.c | 155 ++++ mixgtk/mixgtk_device.h | 42 + mixgtk/mixgtk_gen_handlers.c | 95 +++ mixgtk/mixgtk_gen_handlers.h | 46 ++ mixgtk/mixgtk_input.c | 189 +++++ mixgtk/mixgtk_input.h | 49 ++ mixgtk/mixgtk_mixal.c | 213 +++++ mixgtk/mixgtk_mixal.h | 60 ++ mixgtk/mixgtk_mixvm.c | 423 ++++++++++ mixgtk/mixgtk_mixvm.h | 84 ++ mixgtk/mixgtk_widgets.c | 112 +++ mixgtk/mixgtk_widgets.h | 80 ++ 18 files changed, 3749 insertions(+) create mode 100644 mixgtk/.cvsignore create mode 100644 mixgtk/Makefile.am create mode 100644 mixgtk/mixgtk.c create mode 100644 mixgtk/mixgtk.glade create mode 100644 mixgtk/mixgtk_cmd_dispatcher.c create mode 100644 mixgtk/mixgtk_cmd_dispatcher.h create mode 100644 mixgtk/mixgtk_device.c create mode 100644 mixgtk/mixgtk_device.h create mode 100644 mixgtk/mixgtk_gen_handlers.c create mode 100644 mixgtk/mixgtk_gen_handlers.h create mode 100644 mixgtk/mixgtk_input.c create mode 100644 mixgtk/mixgtk_input.h create mode 100644 mixgtk/mixgtk_mixal.c create mode 100644 mixgtk/mixgtk_mixal.h create mode 100644 mixgtk/mixgtk_mixvm.c create mode 100644 mixgtk/mixgtk_mixvm.h create mode 100644 mixgtk/mixgtk_widgets.c create mode 100644 mixgtk/mixgtk_widgets.h (limited to 'mixgtk') diff --git a/mixgtk/.cvsignore b/mixgtk/.cvsignore new file mode 100644 index 0000000..12ed8c2 --- /dev/null +++ b/mixgtk/.cvsignore @@ -0,0 +1,7 @@ +.deps +Makefile +Makefile.in +gmixvm +hello.mix +mixgtk +paper.dev diff --git a/mixgtk/Makefile.am b/mixgtk/Makefile.am new file mode 100644 index 0000000..f8b1bcf --- /dev/null +++ b/mixgtk/Makefile.am @@ -0,0 +1,31 @@ +## Process this file with automake to produce Makefile.in + +# Copyright (C) 2001 Free Software Foundation, Inc. +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +EXTRA_DIST = mixgtk.glade +INCLUDES = -I$(includedir) -DGLADE_FILE=\""$(pkgdatadir)/mixgtk.glade"\"\ + -DLOCAL_GLADE_FILE=\"mixgtk.glade\" +LDADD = $(top_builddir)/mixlib/libmix.a + +if MAKE_GUI +pkgdata_DATA = mixgtk.glade +bin_PROGRAMS = gmixvm +gmixvm_SOURCES = mixgtk.c mixgtk_gen_handlers.h mixgtk_gen_handlers.c \ + mixgtk_cmd_dispatcher.h mixgtk_cmd_dispatcher.c \ + mixgtk_widgets.h mixgtk_widgets.c \ + mixgtk_device.h mixgtk_device.c \ + mixgtk_mixvm.h mixgtk_mixvm.c \ + mixgtk_mixal.h mixgtk_mixal.c \ + mixgtk_input.h mixgtk_input.c +endif + + + diff --git a/mixgtk/mixgtk.c b/mixgtk/mixgtk.c new file mode 100644 index 0000000..1bbc175 --- /dev/null +++ b/mixgtk/mixgtk.c @@ -0,0 +1,91 @@ +/* -*-c-*- -------------- mixgtk.c : + * Main function of the mix gtk front-end + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/14 23:08:50 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include +#include "mixgtk_widgets.h" +#include "mixgtk_cmd_dispatcher.h" +#include "mixgtk_device.h" +#include "mixgtk_mixvm.h" +#include "mixgtk_mixal.h" +#include "mixgtk_input.h" + +int +main(int argc, char *argv[]) +{ + mix_vm_t *vm; + + gtk_init(&argc, &argv); + + mix_init_lib (); + + if (!mixgtk_widget_factory_init (GLADE_FILE) + && !mixgtk_widget_factory_init (LOCAL_GLADE_FILE)) + { + g_error ("Unable to initialise application (using %s and %s)\n", + GLADE_FILE, LOCAL_GLADE_FILE); + return EXIT_FAILURE; + } + + if (!mixgtk_cmd_dispatcher_init ()) + { + g_error ("Unable to initialise application (command dispatcher)\n"); + return EXIT_FAILURE; + } + + vm = mixgtk_cmd_dispatcher_get_vm (); + + if (!mixgtk_device_init (GTK_NOTEBOOK + (mixgtk_widget_factory_get (MIXGTK_WIDGET_DEVICE)), + vm)) + { + g_error ("Unable to initialise application (devices)\n"); + return EXIT_FAILURE; + } + + if (!mixgtk_mixvm_init (vm)) + { + g_error ("Unable to initialise application (mixvm widgets)\n"); + return EXIT_FAILURE; + } + + if (!mixgtk_mixal_init (vm)) + { + g_error ("Unable to initialise application (mixal widgets)\n"); + return EXIT_FAILURE; + } + + if (!mixgtk_input_init ()) + { + g_error ("Unable to initialise application (word input widgets)\n"); + return EXIT_FAILURE; + } + + + gtk_main(); + + mix_release_lib (); + + return EXIT_SUCCESS; +} diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade new file mode 100644 index 0000000..ced029b --- /dev/null +++ b/mixgtk/mixgtk.glade @@ -0,0 +1,1703 @@ + + + + + mixgtk + mixgtk + + src + pixmaps + C + False + False + True + False + False + + + + GtkWindow + main_window + + destroy + on_main_window_destroy + Tue, 20 Feb 2001 21:58:29 GMT + + gmixvm + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 650 + 500 + False + True + True + + + GtkVBox + main_vbox + 2 + False + 2 + + + GtkMenuBar + mainmenubar + GTK_SHADOW_OUT + + 0 + False + True + + + + GtkMenuItem + file + + False + + + GtkMenu + file_menu + + + GtkMenuItem + file_open + Load a MIX file + + GDK_MOD1_MASK + GDK_F3 + activate + + + activate + on_file_open_activate + Tue, 20 Feb 2001 22:37:58 GMT + + + False + + + + GtkMenuItem + file_exit + Exit application + + GDK_MOD1_MASK + GDK_Q + activate + + + activate + on_file_exit_activate + Tue, 20 Feb 2001 22:37:58 GMT + + + False + + + + + + GtkMenuItem + debug + + False + + + GtkMenu + debug_menu + + + GtkMenuItem + debug_run + + GDK_MOD1_MASK + GDK_R + activate + + + activate + on_debug_run_activate + Sat, 10 Mar 2001 11:35:16 GMT + + + False + + + + GtkMenuItem + debug_next + + GDK_MOD1_MASK + GDK_N + activate + + + activate + on_debug_next_activate + Sat, 10 Mar 2001 11:35:16 GMT + + + False + + + + GtkMenuItem + clear_breakpoints + Clear all set breakpoints + + GDK_MOD1_MASK + GDK_C + activate + + + activate + on_clear_breakpoints_activate + Thu, 15 Mar 2001 23:26:49 GMT + + + False + + + + + + GtkMenuItem + help + + True + + + GtkMenu + help_menu + + + GtkMenuItem + about + + activate + on_about_activate + Tue, 13 Mar 2001 01:37:20 GMT + + + True + + + + + + + GtkToolbar + main_toolbar + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + 5 + GTK_TOOLBAR_SPACE_LINE + GTK_RELIEF_NORMAL + True + + 1 + False + False + + + + Placeholder + + + + Placeholder + + + + Placeholder + + + + + GtkVBox + inner_vbox + False + 0 + + 0 + True + True + + + + GtkNotebook + main_notebook + True + True + True + GTK_POS_TOP + False + 2 + 2 + False + + 0 + False + True + + + + GtkFixed + mixvm_widget + 375 + 287 + + + GtkEntry + rJ_entry + 304 + 88 + 60 + 24 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:45:00 GMT + + False + True + 0 + + + + + GtkEntry + rA_entry + 40 + 24 + 120 + 24 + True + + button_press_event + on_register_click + Mon, 12 Mar 2001 23:09:49 GMT + + False + True + 0 + + + + + GtkEntry + rX_entry + 248 + 24 + 120 + 24 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:43:29 GMT + + False + True + 0 + + + + + GtkEntry + rI2_entry + 40 + 144 + 60 + 22 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:45:39 GMT + + False + True + 0 + + + + + GtkEntry + rI1_entry + 40 + 88 + 60 + 24 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:43:44 GMT + + False + True + 0 + + + + + GtkEntry + rI3_entry + 40 + 200 + 60 + 22 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:46:37 GMT + + False + True + 0 + + + + + GtkEntry + rI4_entry + 168 + 88 + 60 + 24 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:44:21 GMT + + False + True + 0 + + + + + GtkEntry + rI6_entry + 168 + 200 + 60 + 22 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:46:58 GMT + + False + True + 0 + + + + + GtkLabel + label100 + 8 + 91 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label102 + 8 + 200 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label101 + 8 + 144 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label103 + 136 + 88 + 32 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label104 + 136 + 144 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label105 + 136 + 200 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label98 + 216 + 24 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label97 + 8 + 24 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkVSeparator + vseparator2 + 0 + 8 + 16 + 263 + + + + GtkHSeparator + hseparator3 + 6 + 1 + 627 + 16 + + + + GtkVSeparator + vseparator3 + 626 + 8 + 16 + 267 + + + + GtkLabel + label99 + 272 + 88 + 31 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkHSeparator + hseparator2 + 6 + 265 + 627 + 16 + + + + GtkLabel + label159 + 8 + 248 + 64 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label158 + 128 + 248 + 64 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label157 + 256 + 248 + 48 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkVSeparator + vseparator1 + 376 + 10 + 16 + 263 + + + + GtkEntry + rI5_entry + 168 + 144 + 60 + 22 + True + + button_press_event + on_register_click + Sun, 11 Mar 2001 11:46:05 GMT + + False + True + 0 + + + + + GtkEntry + loc_entry + 300 + 200 + 40 + 22 + True + False + True + 0 + + + + + GtkLabel + label167 + 256 + 200 + 48 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkButton + loc_arrow + 346 + 202 + 29 + 18 + True + + clicked + on_loc_arrow_clicked + Fri, 09 Mar 2001 20:18:22 GMT + + + GTK_RELIEF_NONE + + + + GtkHSeparator + hseparator1 + 8 + 232 + 377 + 16 + + + + GtkLabel + program_label + 184 + 248 + 56 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + elapsed_label + 64 + 248 + 48 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + uptime_label + 296 + 248 + 72 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkCheckButton + over_toggle + 288 + 168 + 88 + 16 + True + + toggled + on_overflow_toggled + Tue, 06 Mar 2001 21:32:39 GMT + + + False + True + + + + GtkRadioButton + lesser_radio + 264 + 128 + 35 + 24 + Comparison flag: lesser + True + + toggled + on_cmp_l_toggled + Tue, 06 Mar 2001 21:21:51 GMT + + + False + True + cmp_group + + + + GtkRadioButton + equal_radio + 304 + 128 + 31 + 24 + Comparison flag: equal + True + + toggled + on_cmp_e_toggled + Tue, 06 Mar 2001 21:22:04 GMT + + + False + True + cmp_group + + + + GtkRadioButton + greater_radio + 336 + 128 + 32 + 24 + Comparison flag: greater + True + + toggled + on_cmp_g_toggled + Tue, 06 Mar 2001 21:21:40 GMT + + + False + True + cmp_group + + + + GtkScrolledWindow + memory_scroll + 398 + 16 + 225 + 248 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkCList + memory_cells + 195 + 248 + Click cell to change value + True + + select_row + on_memory_cells_select_row + True + Tue, 13 Mar 2001 07:38:52 GMT + + + click_column + on_memory_cells_click_column + Wed, 14 Mar 2001 14:18:57 GMT + + 2 + 53,135 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label165 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label166 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkLabel + Notebook:tab + label105 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkScrolledWindow + mixal_scrol + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + 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 + + + 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 + + + + + + GtkLabel + Notebook:tab + label106 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkNotebook + devices_notebook + 404 + 254 + True + True + True + GTK_POS_RIGHT + True + 2 + 2 + True + + + Placeholder + + + + GtkLabel + Notebook:tab + label156 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkLabel + Notebook:tab + devices_label + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + GtkScrolledWindow + scrolledwindow25 + 2 + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkViewport + viewport1 + GTK_SHADOW_IN + + + GtkVBox + prompt_vbox + False + 0 + + + GtkScrolledWindow + mixlog_scrolledwindow + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkText + command_log + False + + + + + + GtkEntry + command_prompt + Enter MIXVM command here + True + True + + activate + on_mixvm_cmd_entry_activate + Thu, 22 Feb 2001 23:26:28 GMT + + True + True + 0 + + + 0 + False + False + + + + + + + + + GtkStatusbar + main_statusbar + + 0 + False + False + + + + + + + GtkDialog + word_dialog + False + + destroy + gtk_widget_hide + Tue, 13 Mar 2001 00:53:39 GMT + + + destroy_event + gtk_widget_hide + Tue, 13 Mar 2001 00:55:38 GMT + + + delete_event + gtk_widget_hide + Tue, 13 Mar 2001 00:56:33 GMT + + Enter value + GTK_WINDOW_DIALOG + GTK_WIN_POS_MOUSE + True + 250 + False + False + False + + + GtkVBox + Dialog:vbox + dialog-vbox5 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area5 + 10 + 250 + True + 5 + + 0 + False + False + GTK_PACK_END + + + + GtkHButtonBox + hbuttonbox5 + 250 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + False + False + + + + GtkButton + word_reset + True + True + + clicked + on_word_reset_clicked + Mon, 12 Mar 2001 22:40:33 GMT + + + GTK_RELIEF_NORMAL + + + + GtkButton + word_ok + True + True + + clicked + on_word_ok_clicked + Mon, 12 Mar 2001 22:40:45 GMT + + + GTK_RELIEF_NORMAL + + + + GtkButton + word_cancel + True + True + + clicked + on_word_cancel_clicked + Mon, 12 Mar 2001 23:18:49 GMT + + + GTK_RELIEF_NORMAL + + + + + + GtkFixed + word_layout + 250 + 97 + + 0 + False + False + + + + GtkEntry + word_decimal + 88 + 32 + 143 + 22 + True + True + + key_press_event + on_word_dec_key_press + True + Mon, 12 Mar 2001 22:37:13 GMT + + True + True + 11 + 0 + + + + GtkEntry + word_b2 + 136 + 64 + 22 + 22 + True + + key_press_event + on_word_byte_key_press + True + Mon, 12 Mar 2001 22:38:56 GMT + + True + True + 3 + 00 + + + + GtkEntry + word_b3 + 160 + 64 + 22 + 22 + True + + key_press_event + on_word_byte_key_press + True + Mon, 12 Mar 2001 22:39:26 GMT + + True + True + 3 + 00 + + + + GtkEntry + word_b4 + 184 + 64 + 22 + 22 + True + + key_press_event + on_word_byte_key_press + True + Mon, 12 Mar 2001 22:39:50 GMT + + True + True + 3 + 00 + + + + GtkEntry + word_b5 + 208 + 64 + 22 + 22 + True + + key_press_event + on_word_byte_key_press + True + Mon, 12 Mar 2001 22:40:09 GMT + + True + True + 3 + 00 + + + + GtkEntry + word_b1 + 112 + 64 + 22 + 22 + True + True + + key_press_event + on_word_byte_key_press + True + Mon, 12 Mar 2001 22:38:24 GMT + + True + True + 3 + 00 + + + + GtkEntry + word_sign + 88 + 64 + 16 + 24 + True + + key_press_event + on_word_sign_key_press + Tue, 13 Mar 2001 00:15:28 GMT + + True + True + 1 + + + + + + GtkLabel + label61 + 22 + 67 + 41 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + word_label + 16 + 8 + 216 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label60 + 16 + 34 + 67 + 20 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + + GtkWindow + about_dialog + 368 + 99 + False + + delete_event + gtk_widget_hide + Tue, 13 Mar 2001 13:13:42 GMT + + + destroy_event + gtk_widget_hide + Tue, 13 Mar 2001 13:14:02 GMT + + + destroy + gtk_widget_hide + Tue, 13 Mar 2001 13:14:25 GMT + + MDK + GTK_WINDOW_DIALOG + GTK_WIN_POS_CENTER + True + False + False + False + + + GtkLayout + layout1 + 375 + 190 + 200 + 120 + 0 + 0 + + + GtkLabel + label222 + 56 + 16 + 247 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + version_label + 152 + 40 + 56 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label224 + 0 + 64 + 358 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkHSeparator + hseparator4 + 8 + 0 + 356 + 16 + + + + GtkHSeparator + hseparator5 + 8 + 80 + 356 + 16 + + + + GtkVSeparator + vseparator4 + 0 + 7 + 16 + 83 + + + + GtkVSeparator + vseparator5 + 352 + 8 + 16 + 83 + + + + + + GtkDialog + goto_dialog + 190 + 116 + False + + destroy_event + gtk_widget_hide + Wed, 14 Mar 2001 14:39:17 GMT + + + delete_event + gtk_widget_hide + Wed, 14 Mar 2001 14:39:41 GMT + + + destroy + gtk_widget_hide + Wed, 14 Mar 2001 14:40:15 GMT + + Go to memory cell + GTK_WINDOW_DIALOG + GTK_WIN_POS_MOUSE + True + False + False + False + + + GtkVBox + Dialog:vbox + dialog-vbox6 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area6 + 10 + True + 5 + + 0 + False + True + GTK_PACK_END + + + + GtkHButtonBox + hbuttonbox6 + GTK_BUTTONBOX_DEFAULT_STYLE + 30 + 85 + 27 + 7 + 0 + + 0 + True + True + + + + GtkButton + goto_cancel + True + True + + clicked + on_goto_cancel_clicked + Wed, 14 Mar 2001 14:24:59 GMT + + + GTK_RELIEF_NORMAL + + + + GtkButton + goto_ok + True + True + + clicked + on_goto_ok_clicked + Wed, 14 Mar 2001 14:25:23 GMT + + + GTK_RELIEF_NORMAL + + + + + + GtkVBox + vbox1 + 12 + False + 0 + + 0 + False + False + + + + GtkLabel + label225 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + 0 + True + True + + + + + GtkEntry + goto_entry + 44 + True + True + + activate + on_goto_ok_clicked + Wed, 14 Mar 2001 14:52:26 GMT + + True + True + 4 + + + 10 + False + False + + + + + + + diff --git a/mixgtk/mixgtk_cmd_dispatcher.c b/mixgtk/mixgtk_cmd_dispatcher.c new file mode 100644 index 0000000..11acc1d --- /dev/null +++ b/mixgtk/mixgtk_cmd_dispatcher.c @@ -0,0 +1,314 @@ +/* -*-c-*- -------------- mixgtk_cmd_dispatcher.c : + * Implementation of the functions declared in mixgtk_cmd_dispatcher.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/15 16:01:43 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#define _GNU_SOURCE 1 + +#include +#include +#include +#include "mixgtk_cmd_dispatcher.h" +#include "mixgtk_mixvm.h" +#include "mixgtk_mixal.h" + + +/* a mix vm command dispatcher */ +struct mixgtk_dispatch_ +{ + mix_vm_cmd_dispatcher_t *dispatcher; + FILE *out; + char *out_buffer; + size_t out_buffer_size; + GtkWidget *prompt; + GtkWidget *log; + GtkWidget *status; + guint context; + 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, + mix_vm_command_t cmd, const gchar *arg, gpointer data) +{ + if (cmd < MIX_CMD_INVALID) + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + "MIX> ", -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + mix_vm_command_to_string (cmd), -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + " ", -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + arg, -1); + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + "\n", -1); + } + else + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + _("\n*** Invalid command ***\n"), -1); + } +} + +static void +global_post_hook_ (mix_vm_cmd_dispatcher_t *dis, + mix_vm_command_t cmd, const gchar *arg, gpointer data) +{ + fflush (dis_data_.out); + if (cmd < MIX_CMD_INVALID) + { + gtk_text_insert (GTK_TEXT (dis_data_.log), NULL, NULL, NULL, + dis_data_.out_buffer, dis_data_.out_buffer_size); + } + rewind (dis_data_.out); + mixgtk_mixvm_update_vm_widgets (); +} + +static void +load_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg, + gpointer data) +{ + static glong id = -1; + + if (mix_vm_cmd_dispatcher_get_last_result (dis)) + { + gchar *file = g_strdup (arg); + mixgtk_mixal_load_file (); + mixgtk_mixal_update (); + + if (id != -1) + gtk_statusbar_remove (GTK_STATUSBAR (dis_data_.status), + dis_data_.context, (guint)id); + id = + gtk_statusbar_push (GTK_STATUSBAR (dis_data_.status), dis_data_.context, + file); + } +} + +static void +run_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg, + gpointer data) +{ + mixgtk_mixal_update (); +} + +static void +next_post_hook_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg, + gpointer data) +{ + 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 +mixgtk_cmd_dispatcher_init (void) +{ + if (!dis_data_.prompt) + { + dis_data_.prompt = mixgtk_widget_factory_get (MIXGTK_WIDGET_PROMPT); + g_return_val_if_fail (dis_data_.prompt != NULL, FALSE); + dis_data_.log = mixgtk_widget_factory_get (MIXGTK_WIDGET_LOG); + g_return_val_if_fail (dis_data_.log != NULL, FALSE); + } + + if (!dis_data_.dispatcher) + { + FILE *out = open_memstream (&(dis_data_.out_buffer), + &(dis_data_.out_buffer_size)); + g_return_val_if_fail (out != NULL, FALSE); + dis_data_.out = out; + dis_data_.dispatcher = mix_vm_cmd_dispatcher_new (out, out); + mix_vm_cmd_dispatcher_print_time (dis_data_.dispatcher, FALSE); + install_hooks_ (); + } + + if (!dis_data_.status) + { + dis_data_.status = mixgtk_widget_factory_get (MIXGTK_WIDGET_STATUSBAR); + g_return_val_if_fail (dis_data_.status != NULL, FALSE); + dis_data_.context = gtk_statusbar_get_context_id (GTK_STATUSBAR + (dis_data_.status), + "cmd_dis_context"); + } + + if (!dis_data_.completions) init_completions_ (); + + return TRUE; +} + +/* dispatch an externally provided command */ +void +mixgtk_cmd_dispatcher_dispatch (const gchar *command) +{ + GtkWidget *entry = dis_data_.prompt; + g_return_if_fail (command != NULL); + g_assert (entry != NULL); + gtk_entry_set_text (GTK_ENTRY (entry), command); + on_mixvm_cmd_entry_activate (entry, NULL); +} + +/* get times */ +void +mixgtk_cmd_dispatcher_get_times (gint *uptime, gint *progtime, gint *laptime) +{ + if (uptime != NULL) + *uptime = mix_vm_cmd_dispatcher_get_uptime (dis_data_.dispatcher); + if (progtime != NULL) + *progtime = mix_vm_cmd_dispatcher_get_progtime (dis_data_.dispatcher); + if (laptime != NULL) + *laptime = mix_vm_cmd_dispatcher_get_laptime (dis_data_.dispatcher); +} + +/* get the underlying vm */ +extern mix_vm_t * +mixgtk_cmd_dispatcher_get_vm (void) +{ + return (mix_vm_t *) mix_vm_cmd_dispatcher_get_vm (dis_data_.dispatcher); +} + +/* process new command */ +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)); + + 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_cmd_dispatcher.h b/mixgtk/mixgtk_cmd_dispatcher.h new file mode 100644 index 0000000..686ba4d --- /dev/null +++ b/mixgtk/mixgtk_cmd_dispatcher.h @@ -0,0 +1,55 @@ +/* -*-c-*- ---------------- mixgtk_cmd_dispatcher.h : + * functions to access the command dispatcher + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/09 22:08:08 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_CMD_DISPATCHER_H +#define MIXGTK_CMD_DISPATCHER_H + +#include +#include "mixgtk_widgets.h" + +/* initialise the command dispatcher */ +extern gboolean +mixgtk_cmd_dispatcher_init (void); + +/* dispatch an externally provided command */ +extern void +mixgtk_cmd_dispatcher_dispatch (const gchar *command); + +/* get times */ +extern void +mixgtk_cmd_dispatcher_get_times (gint *uptime, gint *progtime, gint *laptime); + +/* get the underlying vm */ +extern mix_vm_t * +mixgtk_cmd_dispatcher_get_vm (void); + +/* make gtk signal callbacks accessible to glade */ +/* new command handler */ +extern void +on_mixvm_cmd_entry_activate (GtkWidget *w, gpointer e); + + + +#endif /* MIXGTK_CMD_DISPATCHER_H */ + diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c new file mode 100644 index 0000000..2e231a4 --- /dev/null +++ b/mixgtk/mixgtk_device.c @@ -0,0 +1,155 @@ +/* -*-c-*- ---------------- mixgtk_device.c : + * actual types for mixgtk devices + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/05 01:13:40 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#define _GNU_SOURCE 1 + +#include +#include +#include "mixgtk_device.h" + +/* device container */ +static GtkNotebook *container_ = NULL; +/* virtual machine */ +static mix_vm_t *vm_ = NULL; + +/* a mixgtk device */ +struct mixgtk_device_t +{ + mix_device_t device; + char *buffer; + size_t buffer_len; + GtkText *widget; + gint pos; +}; + +/* callbacks for output devices */ +static gboolean +write_out_ (mix_device_t *dev, const mix_word_t *block) +{ + struct mixgtk_device_t *gtkdev; + + if (!((DEF_DEV_VTABLE_->write) (dev, block))) return FALSE; + gtkdev = (struct mixgtk_device_t *) dev; + if (gtkdev->buffer_len > 0) + { + gtk_text_insert (gtkdev->widget, NULL, NULL, NULL, + gtkdev->buffer, gtkdev->buffer_len); + rewind (mix_io_to_FILE (gtkdev->device.file)); + gtk_notebook_set_page (container_, gtkdev->pos); + gtk_widget_draw (GTK_WIDGET (container_), NULL); + } + return TRUE; +} + +static mix_device_vtable_t MIXGTK_OUT_VTABLE_; + +/* create a new mixgtk device */ +static struct mixgtk_device_t * +mixgtk_device_new_ (mix_device_type_t type) +{ + struct mixgtk_device_t *dev = NULL; + + g_return_val_if_fail (type < mix_dev_INVALID, NULL); + + if (MODES_[type] == mix_dev_CHAR && FMODES_[type] == mix_io_WRITE) + { + FILE *f; + dev = g_new (struct mixgtk_device_t, 1); + f = open_memstream (&(dev->buffer), &(dev->buffer_len)); + g_assert (f); + dev->device.file = mix_io_new (f); + dev->device.type = type; + dev->device.vtable = &MIXGTK_OUT_VTABLE_; + dev->widget = (GtkText *)gtk_text_new (NULL, NULL); + g_assert (dev->widget); + gtk_text_set_editable (dev->widget, FALSE); + } + return dev; +} + +/* connect a device */ +static void +mixgtk_device_connect_ (struct mixgtk_device_t *dev) +{ + static gint last_pos = 0; + GtkWidget *label = gtk_label_new (DEF_NAMES_[dev->device.type]); + GtkWidget *box = gtk_hbox_new (0, 0); + GtkWidget *scroll = gtk_vscrollbar_new (dev->widget->vadj); + g_assert (label); + g_assert (box); + gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (dev->widget), + TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), scroll, FALSE, FALSE, 0); + dev->pos = last_pos++; + gtk_notebook_insert_page (container_, box, label, dev->pos); + gtk_widget_show (box); + gtk_widget_show (label); + gtk_widget_show (scroll); + gtk_widget_show (GTK_WIDGET (dev->widget)); + gtk_widget_draw (GTK_WIDGET (container_), NULL); + (void) mix_vm_connect_device (vm_, (mix_device_t *)dev); +} + +/* init default devices */ +gboolean +mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) +{ + static mix_device_type_t def_types[] = { + mix_dev_CONSOLE, mix_dev_PRINTER, mix_dev_PAPER_TAPE, mix_dev_INVALID + }; + + gint k = 0; + + g_return_val_if_fail (container != NULL, FALSE); + g_return_val_if_fail (vm != NULL, FALSE); + container_ = container; + vm_ = vm; + + /* remove dummy page from container */ + gtk_notebook_remove_page (container_, 0); + + /* initialise vtables */ + MIXGTK_OUT_VTABLE_.write = write_out_; + MIXGTK_OUT_VTABLE_.read = DEF_DEV_VTABLE_->read; + MIXGTK_OUT_VTABLE_.ioc = DEF_DEV_VTABLE_->ioc; + MIXGTK_OUT_VTABLE_.busy = DEF_DEV_VTABLE_->busy; + + /* connect default devices */ + while (def_types[k] != mix_dev_INVALID) + { + struct mixgtk_device_t *dev = mixgtk_device_new_ (def_types[k]); + if (dev != NULL) + mixgtk_device_connect_ (dev); + ++k; + } + + /* set to first page */ + gtk_notebook_set_page (container_, 0); + + return TRUE; +} + +/* connect a new (file-based) device */ +gboolean +mixgtk_device_connect (mix_device_type_t type, const gchar *name); diff --git a/mixgtk/mixgtk_device.h b/mixgtk/mixgtk_device.h new file mode 100644 index 0000000..7c21238 --- /dev/null +++ b/mixgtk/mixgtk_device.h @@ -0,0 +1,42 @@ +/* -*-c-*- ---------------- mixgtk_device.h : + * Block devices used by mixgtk + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/04 23:43:59 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_DEVICE_H +#define MIXGTK_DEVICE_H + +#include +#include +#include + +/* init default devices */ +extern gboolean +mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm); + + +/* connect a new (file-based) device */ +extern gboolean +mixgtk_device_connect (mix_device_type_t type, const gchar *name); + +#endif /* MIXGTK_DEVICE_H */ + diff --git a/mixgtk/mixgtk_gen_handlers.c b/mixgtk/mixgtk_gen_handlers.c new file mode 100644 index 0000000..9f23310 --- /dev/null +++ b/mixgtk/mixgtk_gen_handlers.c @@ -0,0 +1,95 @@ +/* -*-c-*- -------------- mixgtk_gen_handlers.c : + * Implementation of the functions declared in mixgtk_gen_handlers.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/16 00:30:40 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include "mixgtk_gen_handlers.h" +#include "mixgtk_cmd_dispatcher.h" + +void +on_main_window_destroy (GtkWidget *w, gpointer data) +{ + gtk_main_quit (); +} + +static void +on_file_open_ok_ (GtkWidget *w, gpointer fs) +{ + const gchar *file = gtk_file_selection_get_filename (GTK_FILE_SELECTION (fs)); + gchar *command = g_strdup_printf ("%s %s", + mix_vm_command_to_string (MIX_CMD_LOAD), + file); + gtk_widget_destroy (GTK_WIDGET (fs)); + mixgtk_cmd_dispatcher_dispatch (command); + g_free (command); +} + +static void +on_file_open_destroy_ (GtkWidget *w, gpointer data) +{ + gtk_grab_remove (GTK_WIDGET (w)); +} + +void +on_file_open_activate (GtkWidget *w, gpointer data) +{ + GtkWidget *file = gtk_file_selection_new ("Open program"); + gtk_signal_connect (GTK_OBJECT (file), "destroy", + (GtkSignalFunc) on_file_open_destroy_, + GTK_OBJECT (file)); + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file)->ok_button), + "clicked", (GtkSignalFunc) on_file_open_ok_, + GTK_OBJECT (file)); + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION + (file)->cancel_button), + "clicked", (GtkSignalFunc) gtk_widget_destroy, + GTK_OBJECT (file)); + gtk_widget_show (file); + gtk_grab_add (file); +} + +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 (); +} + + +void +on_clear_breakpoints_activate (GtkWidget *w, gpointer data) +{ + mixgtk_cmd_dispatcher_dispatch (mix_vm_command_to_string (MIX_CMD_CABP)); +} + diff --git a/mixgtk/mixgtk_gen_handlers.h b/mixgtk/mixgtk_gen_handlers.h new file mode 100644 index 0000000..6e0a45d --- /dev/null +++ b/mixgtk/mixgtk_gen_handlers.h @@ -0,0 +1,46 @@ +/* -*-c-*- ---------------- mixgtk_gen_handlers.h : + * general signal handlers declarations + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/16 00:29:45 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_GEN_HANDLERS_H +#define MIXGTK_GEN_HANDLERS_H + +#include + +extern void +on_main_window_destroy (GtkWidget *w, gpointer data); + +extern void +on_file_open_activate (GtkWidget *w, gpointer data); + +extern void +on_file_exit_activate (GtkWidget *w, gpointer data); + +extern void +on_clear_breakpoints_activate (GtkWidget *w, gpointer data); + + + + +#endif /* MIXGTK_GEN_HANDLERS_H */ + diff --git a/mixgtk/mixgtk_input.c b/mixgtk/mixgtk_input.c new file mode 100644 index 0000000..fa98056 --- /dev/null +++ b/mixgtk/mixgtk_input.c @@ -0,0 +1,189 @@ +/* -*-c-*- -------------- mixgtk_input.c : + * Implementation of the functions declared in mixgtk_input.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/13 08:31:20 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include "mixgtk_widgets.h" +#include "mixgtk_input.h" + +enum { + MSG_, SIGN_, B1_, B2_, B3_, B4_, B5_, DEC_, RESET_, OK_, SIZE_ +}; + +static const gchar *WGT_NAMES_[SIZE_] = { + "word_label", "word_sign", "word_b1", "word_b2", "word_b3", + "word_b4", "word_b5", "word_decimal", "word_reset", "word_ok" +}; + +static GtkDialog *dialog_; +static GtkWidget *childs_[SIZE_]; +static input_callback_t callback_; +static gpointer data_; + +/* init */ +extern gboolean +mixgtk_input_init (void) +{ + gint k; + + dialog_ = GTK_DIALOG (mixgtk_widget_factory_get (MIXGTK_WIDGET_WORD_DIALOG)); + g_return_val_if_fail (dialog_ != NULL, FALSE); + for (k = 0; k < SIZE_; ++k) + { + childs_[k] = mixgtk_widget_factory_get_by_name (WGT_NAMES_[k]); + g_return_val_if_fail (childs_[k] != NULL, FALSE); + } + return TRUE; + +} + +static void +set_word_ (mix_word_t word) +{ + enum {SIZE = 50}; + static gchar BUFFER[SIZE] = {0}; + gint k; + gint val = mix_word_magnitude (word); + gboolean neg = mix_word_is_negative (word); + snprintf (BUFFER, SIZE, "%s%d", neg ? "-" : "", val); + gtk_entry_set_text (GTK_ENTRY (childs_[DEC_]), BUFFER); + gtk_entry_set_text (GTK_ENTRY (childs_[SIGN_]), neg ? "-" : "+"); + for (k = 1; k < 6; ++k) + { + mix_byte_t b = mix_word_get_byte (word, k); + snprintf (BUFFER, SIZE, "%d", (int)b); + gtk_entry_set_text (GTK_ENTRY (childs_[SIGN_ + k]), BUFFER); + } +} + + +/* get a word */ +void +mixgtk_input_word (const gchar *message, mix_word_t def, + input_callback_t cb, gpointer data) +{ + gtk_label_set_text (GTK_LABEL (childs_[MSG_]), message); + set_word_ (def); + callback_ = cb; + data_ = data; + gtk_widget_show (childs_[B1_]); + gtk_widget_show (childs_[B2_]); + gtk_widget_show (childs_[B3_]); + gtk_widget_show (GTK_WIDGET (dialog_)); +} + +/* get a short */ +void +mixgtk_input_short (const gchar *message, mix_short_t def, + input_callback_t cb, gpointer data) +{ + gtk_label_set_text (GTK_LABEL (childs_[MSG_]), message); + set_word_ (mix_word_to_short_fast (def)); + callback_ = cb; + data_ = data; + gtk_widget_show (GTK_WIDGET (dialog_)); + gtk_widget_hide (childs_[B1_]); + gtk_widget_hide (childs_[B2_]); + gtk_widget_hide (childs_[B3_]); +} + +#include + +/* dec and bytes input handler */ +gboolean +on_word_dec_key_press (GtkWidget *dec, GdkEvent *event, gpointer *data) +{ + GdkEventKey *key = (GdkEventKey *)event; + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) + { + gchar *text = gtk_entry_get_text (GTK_ENTRY (childs_[DEC_])); + gint val = atoi (text); + set_word_ (mix_word_new (val)); + } + return FALSE; +} + +gboolean +on_word_byte_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) +{ + GdkEventKey *key = (GdkEventKey *)event; + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) + { + mix_byte_t bytes[5]; + gint k; + gchar *s; + mix_word_t w; + + for (k = 0; k < 5; ++k) + { + gchar *text = gtk_entry_get_text (GTK_ENTRY (childs_[B1_ + k])); + bytes[k] = mix_byte_new (atoi (text)); + } + w = mix_bytes_to_word (bytes, 5); + s = gtk_entry_get_text (GTK_ENTRY (childs_[SIGN_])); + if (s && s[0] == '-') mix_word_reverse_sign (w); + set_word_ (w); + } + return FALSE; +} + +gboolean +on_word_sign_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) +{ + GdkEventKey *key = (GdkEventKey *)event; + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) + { + gchar s = key->string[0]; + gchar *txt = gtk_entry_get_text (GTK_ENTRY (childs_[SIGN_])); + gchar c = txt ? txt[0] : '+'; + if ( (s == '+' || s == '-') && s != c) + { + mix_word_t w = + mix_word_new (atoi + (gtk_entry_get_text (GTK_ENTRY (childs_[DEC_])))); + set_word_ (mix_word_negative (w)); + } + } + return FALSE; +} + +void +on_word_ok_clicked (GtkWidget *widget, gpointer *data) +{ + const gchar *text = gtk_entry_get_text (GTK_ENTRY (childs_[DEC_])); + mix_word_t w = mix_word_new (atoi (text)); + callback_ (w, data_); + gtk_widget_hide (GTK_WIDGET (dialog_)); +} + +void +on_word_cancel_clicked (GtkWidget *widget, gpointer *data) +{ + gtk_widget_hide (GTK_WIDGET (dialog_)); +} + +void +on_word_reset_clicked (GtkWidget *w, gpointer *data) +{ + set_word_ (MIX_WORD_ZERO); +} diff --git a/mixgtk/mixgtk_input.h b/mixgtk/mixgtk_input.h new file mode 100644 index 0000000..275894d --- /dev/null +++ b/mixgtk/mixgtk_input.h @@ -0,0 +1,49 @@ +/* -*-c-*- ---------------- mixgtk_input.h : + * Declaration of functions for user input + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/12 23:35:14 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_INPUT_H +#define MIXGTK_INPUT_H + +#include + +/* callback function type */ +typedef void (*input_callback_t)(mix_word_t result, gpointer data); + +/* init */ +extern gboolean +mixgtk_input_init (void); + +/* get a word */ +extern void +mixgtk_input_word (const gchar *message, mix_word_t def, + input_callback_t cb, gpointer data); + +/* get a short */ +extern void +mixgtk_input_short (const gchar *message, mix_short_t def, + input_callback_t cb, gpointer data ); + + +#endif /* MIXGTK_INPUT_H */ + diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c new file mode 100644 index 0000000..b59688d --- /dev/null +++ b/mixgtk/mixgtk_mixal.c @@ -0,0 +1,213 @@ +/* -*-c-*- -------------- mixgtk_mixal.c : + * Implementation of the functions declared in mixgtk_mixal.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/12 23:48:29 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#include +#include "mixgtk_widgets.h" +#include "mixgtk_mixal.h" + + +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 (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; +} + +/* load the corresponding mixal file */ +void +mixgtk_mixal_load_file (void) +{ + enum {ADDR_SIZE = 20, CONT_SIZE = 200}; + static gchar ADDR[ADDR_SIZE], CONT[CONT_SIZE]; + static gchar *TEXT[] = {ADDR, CONT}; + static gchar *NULL_TEXT[] = {NULL, NULL}; + + const mix_src_file_t *file; + + g_assert (vm_); + g_assert (clist_); + + gtk_clist_clear (clist_); + + file = mix_vm_get_src_file (vm_); + if (file != NULL) + { + gint k; + mix_address_t addr; + + lineno_ = mix_src_file_get_line_no (file); + + 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) + { + sprintf (ADDR, "%04d: ", mix_short_magnitude (addr)); + mix_word_print_to_buffer (mix_vm_get_addr_contents (vm_, addr), + ADDR + strlen (ADDR)); + } + else + ADDR[0] = '\0'; + gtk_clist_append (clist_, TEXT); + gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER + (mix_short_magnitude (addr))); + } + 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 + lineno_ = 0; +} + + +/* 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; + + g_assert (vm_); + g_assert (clist_); + + addr = mix_short_magnitude (mix_vm_get_prog_count (vm_)); + 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_) + { + gint addr = GPOINTER_TO_INT (gtk_clist_get_row_data (clist_, line - 1)); + if (addr != MIX_VM_CELL_NO) break; + ++line; + } + 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 new file mode 100644 index 0000000..819819a --- /dev/null +++ b/mixgtk/mixgtk_mixal.h @@ -0,0 +1,60 @@ +/* -*-c-*- ---------------- mixgtk_mixal.h : + * Declarations for functions displaying the mixal source file + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/11 00:19:30 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_MIXAL_H +#define MIXGTK_MIXAL_H + +#include +#include + +/* initialise the mixal widget */ +extern gboolean +mixgtk_mixal_init (mix_vm_t *vm); + +/* load the corresponding mixal file */ +extern void +mixgtk_mixal_load_file (void); + +/* 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_mixvm.c b/mixgtk/mixgtk_mixvm.c new file mode 100644 index 0000000..9c5d9bd --- /dev/null +++ b/mixgtk/mixgtk_mixvm.c @@ -0,0 +1,423 @@ +/* -*-c-*- -------------- mixgtk_mixvm.c : + * Implementation of the functions declared in mixgtk_mixvm.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/14 16:34:31 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include +#include +#include "mixgtk_widgets.h" +#include "mixgtk_mixvm.h" +#include "mixgtk_cmd_dispatcher.h" +#include "mixgtk_input.h" + +/* register widgets */ +#define REGISTER_NO_ (MIXGTK_WIDGET_rI6 - MIXGTK_WIDGET_rA + 1) + +static GtkEntry *reg_entries_[REGISTER_NO_]; +static GtkTooltips *tips_; +static GtkEntry *loc_entry_; +static GtkWidget *goto_; +static GtkEntry *goto_entry_; +static GtkToggleButton *over_button_; +static GtkToggleButton *cmp_buttons_[3]; +static GtkCList *memory_; +static GtkLabel *laptime_; +static GtkLabel *progtime_; +static GtkLabel *uptime_; +static mix_vm_t *vm_; + +#define GOTO_ENTRY_NAME_ "goto_entry" + +static void +update_register_ (mixgtk_widget_id_t reg) +{ + static gchar BUFFER[20]; + mix_word_t tipval = MIX_WORD_ZERO; + switch (reg) + { + case MIXGTK_WIDGET_rA: + tipval = mix_vm_get_rA (vm_); + mix_word_print_to_buffer (tipval, BUFFER); + break; + case MIXGTK_WIDGET_rX: + tipval = mix_vm_get_rX (vm_); + mix_word_print_to_buffer (tipval, BUFFER); + break; + case MIXGTK_WIDGET_rJ: + tipval = mix_short_to_word_fast (mix_vm_get_rJ (vm_)); + mix_short_print_to_buffer (mix_vm_get_rJ (vm_), BUFFER); + break; + case MIXGTK_WIDGET_rI1: + case MIXGTK_WIDGET_rI2: + case MIXGTK_WIDGET_rI3: + case MIXGTK_WIDGET_rI4: + case MIXGTK_WIDGET_rI5: + case MIXGTK_WIDGET_rI6: + { + gint k = reg - MIXGTK_WIDGET_rI1 + 1; + tipval = mix_short_to_word_fast (mix_vm_get_rI (vm_, k)); + mix_short_print_to_buffer (mix_vm_get_rI (vm_, k), BUFFER); + } + break; + default: + g_assert_not_reached (); + } + gtk_entry_set_text (reg_entries_[reg - MIXGTK_WIDGET_rA], BUFFER); + snprintf (BUFFER, 20, "%s%ld", mix_word_is_negative (tipval)? "-" : "", + mix_word_magnitude (tipval)); + gtk_tooltips_set_tip (tips_, + GTK_WIDGET (reg_entries_[reg - MIXGTK_WIDGET_rA]), + BUFFER, NULL); + +} + + +static void +on_mem_adj_change_ (GtkAdjustment *adj) +{ + mixgtk_mixvm_update_cells (); +} + + +/* initialise the mixvm widgets */ +gboolean +mixgtk_mixvm_init (mix_vm_t *vm) +{ + int k; + gchar *text[] = {"", ""}; + GtkWidget *scrol; + GtkAdjustment *adj; + + g_return_val_if_fail (vm != NULL, FALSE); + vm_ = vm; + + tips_ = gtk_tooltips_new (); + + for (k = 0; k < REGISTER_NO_; ++k) + { + reg_entries_[k] = + GTK_ENTRY (mixgtk_widget_factory_get (MIXGTK_WIDGET_rA + k)); + g_return_val_if_fail (reg_entries_[k] != NULL, FALSE); + } + + loc_entry_ = GTK_ENTRY (mixgtk_widget_factory_get (MIXGTK_WIDGET_LOC)); + g_return_val_if_fail (loc_entry_ != NULL, FALSE); + + uptime_ = GTK_LABEL (mixgtk_widget_factory_get (MIXGTK_WIDGET_UPTIME)); + g_return_val_if_fail (uptime_ != NULL, FALSE); + + progtime_ = GTK_LABEL (mixgtk_widget_factory_get (MIXGTK_WIDGET_PROGTIME)); + g_return_val_if_fail (progtime_ != NULL, FALSE); + + laptime_ = GTK_LABEL (mixgtk_widget_factory_get (MIXGTK_WIDGET_LAPTIME)); + g_return_val_if_fail (laptime_ != NULL, FALSE); + + over_button_ = + GTK_TOGGLE_BUTTON (mixgtk_widget_factory_get (MIXGTK_WIDGET_OVER)); + g_return_val_if_fail (over_button_ != NULL, FALSE); + + for (k = 0; k < 3; ++k) + { + cmp_buttons_[k] = + GTK_TOGGLE_BUTTON (mixgtk_widget_factory_get (MIXGTK_WIDGET_CMP_L +k)); + g_return_val_if_fail (cmp_buttons_[k] != NULL, FALSE); + } + + memory_ = GTK_CLIST (mixgtk_widget_factory_get (MIXGTK_WIDGET_CELLS)); + g_return_val_if_fail (memory_ != NULL, FALSE); + gtk_clist_set_column_justification (memory_, 0, GTK_JUSTIFY_CENTER); + gtk_clist_set_column_justification (memory_, 1, GTK_JUSTIFY_CENTER); + gtk_clist_freeze (memory_); + for (k = 0; k< MIX_VM_CELL_NO; ++k) + { + gchar buffer[20]; + sprintf (buffer, "%04d", k); + text[0] = buffer; + gtk_clist_append (memory_, text); + } + gtk_clist_thaw (memory_); + + scrol = mixgtk_widget_factory_get (MIXGTK_WIDGET_CELLS_SCROLL); + g_return_val_if_fail (scrol != NULL, FALSE); + adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrol)); + gtk_signal_connect (GTK_OBJECT (adj), "value_changed", + GTK_SIGNAL_FUNC (on_mem_adj_change_), NULL); + + goto_ = mixgtk_widget_factory_get (MIXGTK_WIDGET_GOTO_DIALOG); + g_return_val_if_fail (goto_ != NULL, FALSE); + + goto_entry_ = GTK_ENTRY (mixgtk_widget_factory_get_by_name + (GOTO_ENTRY_NAME_)); + g_return_val_if_fail (goto_entry_ != NULL, FALSE); + + mixgtk_mixvm_update_vm_widgets (); + + return TRUE; +} + + +/* update register widgets */ +void +mixgtk_mixvm_update_registers (void) +{ + gint k; + for (k = MIXGTK_WIDGET_rA; k <= MIXGTK_WIDGET_rI6; ++k) + update_register_ (k); +} + +/* update the overflow toggle */ +void +mixgtk_mixvm_update_over_toggle (void) +{ + g_assert (over_button_); + gtk_toggle_button_set_active (over_button_, + mix_vm_get_overflow (vm_)); +} + +/* update the comparison flag */ +void +mixgtk_mixvm_update_cmp (void) +{ + gint toggle; + + g_assert (cmp_buttons_); + + toggle = mix_vm_get_cmpflag (vm_); + gtk_toggle_button_set_active (cmp_buttons_[toggle], TRUE); +} + + +/* update the memory cells */ +void +mixgtk_mixvm_update_cells (void) +{ + static gchar BUFFER[20]; + gint k = 0; + + g_assert (memory_); + + gtk_clist_freeze (memory_); + + while (gtk_clist_row_is_visible (memory_, k) == GTK_VISIBILITY_NONE) ++k; + while (gtk_clist_row_is_visible (memory_, k) != GTK_VISIBILITY_NONE) + { + mix_word_print_to_buffer (mix_vm_get_addr_contents (vm_, k), BUFFER); + gtk_clist_set_text (memory_, k, 1, BUFFER); + ++k; + } + + gtk_clist_thaw (memory_); +} + +void +mixgtk_mixvm_update_cells_to_address (gint address) +{ + g_assert (memory_); + g_return_if_fail (address < MIX_VM_CELL_NO); + + gtk_clist_freeze (memory_); + gtk_clist_moveto (memory_, address, 0, 0, 0); + gtk_clist_thaw (memory_); + mixgtk_mixvm_update_cells (); +} + +/* update the loc pointer */ +void +mixgtk_mixvm_update_loc (void) +{ + enum {SIZE = 10 }; + static gchar BUFFER[SIZE]; + mix_short_t locval; + + g_assert (loc_entry_); + + locval = mix_vm_get_prog_count (vm_); + snprintf (BUFFER, SIZE, "%04d", mix_short_magnitude (locval)); + gtk_entry_set_text (loc_entry_, BUFFER); +} + +/* update times */ +void +mixgtk_mixvm_update_times (void) +{ + enum {SIZE = 20 }; + static gchar BUFFER[SIZE]; + gint uptime, progtime, laptime; + + g_assert (uptime_ && progtime_ && laptime_); + mixgtk_cmd_dispatcher_get_times (&uptime, &progtime, &laptime); + snprintf (BUFFER, SIZE, "%d", uptime); + gtk_label_set_text (uptime_, BUFFER); + snprintf (BUFFER, SIZE, "%d", progtime); + gtk_label_set_text (progtime_, BUFFER); + snprintf (BUFFER, SIZE, "%d", laptime); + gtk_label_set_text (laptime_, BUFFER); +} + + +/* update all mixvm widgets */ +void +mixgtk_mixvm_update_vm_widgets (void) +{ + mixgtk_mixvm_update_registers (); + mixgtk_mixvm_update_loc (); + mixgtk_mixvm_update_over_toggle (); + mixgtk_mixvm_update_cmp (); + mixgtk_mixvm_update_cells (); + mixgtk_mixvm_update_times (); +} + + +/* update cmp flag */ +void +on_cmp_e_toggled (GtkWidget *widget, gpointer data) +{ + if (GTK_TOGGLE_BUTTON (widget)->active) + mix_vm_set_cmpflag (vm_, mix_EQ); +} + +void +on_cmp_l_toggled (GtkWidget *widget, gpointer data) +{ + if (GTK_TOGGLE_BUTTON (widget)->active) + mix_vm_set_cmpflag (vm_, mix_LESS); +} + +void +on_cmp_g_toggled (GtkWidget *widget, gpointer data) +{ + if (GTK_TOGGLE_BUTTON (widget)->active) + mix_vm_set_cmpflag (vm_, mix_GREAT); +} + +void +on_overflow_toggled (GtkWidget *widget, gpointer data) +{ + mix_vm_set_overflow (vm_, GTK_TOGGLE_BUTTON (widget)->active); +} + + +void +on_loc_arrow_clicked (GtkWidget *widget, gpointer data) +{ + gint address = mix_short_magnitude (mix_vm_get_prog_count (vm_)); + mixgtk_mixvm_update_cells_to_address (address); +} + + +static void +register_AX_ (mix_word_t w, gpointer reg) +{ + gint k = GPOINTER_TO_INT (reg); + if (k == 0) + mix_vm_set_rA (vm_, w); + else + mix_vm_set_rX (vm_, w); + update_register_ (MIXGTK_WIDGET_rA + k); +} + +static void +register_j_ (mix_word_t w, gpointer data) +{ + if (mix_word_is_negative (w)) mix_word_reverse_sign (w); + mix_vm_set_rJ (vm_, mix_word_to_short_fast (w)); + update_register_ (MIXGTK_WIDGET_rJ); +} + +static void +register_i_ (mix_word_t w, gpointer reg) +{ + mix_vm_set_rI (vm_, GPOINTER_TO_INT (reg), mix_word_to_short_fast (w)); + update_register_ (MIXGTK_WIDGET_rI1 - 1 + GPOINTER_TO_INT (reg)); +} + +gboolean +on_register_click (GtkWidget *w, GdkEvent *e, gpointer data) +{ + enum {SIZE = 20}; + static gchar BUFFER[SIZE]; + gint k; + + if (w == GTK_WIDGET (reg_entries_[0])) + mixgtk_input_word ("Register A", mix_vm_get_rA (vm_), + register_AX_, GINT_TO_POINTER (0)); + else if (w == GTK_WIDGET (reg_entries_[1])) + mixgtk_input_word ("Register X", mix_vm_get_rX (vm_), + register_AX_, GINT_TO_POINTER(1)); + else if (w == GTK_WIDGET (reg_entries_[2])) + mixgtk_input_short ("Register J", mix_vm_get_rJ (vm_), register_j_, NULL); + else for (k = 1; k < 7; ++k) + { + if (w == GTK_WIDGET (reg_entries_[2 + k])) + { + snprintf (BUFFER, SIZE, "Register I%d", k); + mixgtk_input_short (BUFFER, mix_vm_get_rI (vm_, k), + register_i_, GINT_TO_POINTER (k)); + break; + } + } + return FALSE; +} + +static void +mem_cell_ (mix_word_t w, gpointer a) +{ + mix_short_t addr = mix_short_new (GPOINTER_TO_INT (a)); + mix_vm_set_addr_contents (vm_, addr, w); + mixgtk_mixvm_update_cells (); +} + +void +on_memory_cells_select_row (GtkCList *w, gint row, gint col, + GdkEvent *e, gpointer data) +{ + enum {SIZE = 20}; + static gchar BUFFER[SIZE]; + snprintf (BUFFER, SIZE, "Memory cell no. %d", row); + mixgtk_input_word (BUFFER, + mix_vm_get_addr_contents (vm_, mix_short_new (row)), + mem_cell_, GINT_TO_POINTER (row)); +} + +void +on_memory_cells_click_column (GtkCList *w, gint row, gpointer data) +{ + gtk_widget_show (goto_); +} + +void +on_goto_cancel_clicked (GtkWidget *w, gpointer data) +{ + gtk_widget_hide (goto_); +} + +void +on_goto_ok_clicked (GtkWidget *w, gpointer data) +{ + gchar *txt = gtk_entry_get_text (goto_entry_); + mix_short_t addr = mix_short_new (atoi (txt)); + if (addr < MIX_VM_CELL_NO) + { + gtk_widget_hide (goto_); + mixgtk_mixvm_update_cells_to_address (addr); + } +} + diff --git a/mixgtk/mixgtk_mixvm.h b/mixgtk/mixgtk_mixvm.h new file mode 100644 index 0000000..8207d91 --- /dev/null +++ b/mixgtk/mixgtk_mixvm.h @@ -0,0 +1,84 @@ +/* -*-c-*- ---------------- mixgtk_mixvm.h : + * Functions dealing with the mixvm widgets + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/09 22:12:04 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_MIXVM_H +#define MIXGTK_MIXVM_H + +#include + +/* initialise the mixvm widgets */ +extern gboolean +mixgtk_mixvm_init (mix_vm_t *vm); + +/* update register widgets */ +extern void +mixgtk_mixvm_update_registers (void); + +/* update the overflow toggle */ +extern void +mixgtk_mixvm_update_over_toggle (void); + +/* update the comparison flag */ +extern void +mixgtk_mixvm_update_cmp (void); + +/* update the memory cells */ +extern void +mixgtk_mixvm_update_cells (void); + +extern void +mixgtk_mixvm_update_cells_to_address (gint address); + +/* update the loc pointer */ +extern void +mixgtk_mixvm_update_loc (void); + +/* update times */ +extern void +mixgtk_mixvm_update_times (void); + +/* update all mixvm widgets */ +extern void +mixgtk_mixvm_update_vm_widgets (void); + +/* callbacks */ +extern void +on_cmp_e_toggled (GtkWidget *widget, gpointer data); + +extern void +on_cmp_g_toggled (GtkWidget *widget, gpointer data); + +extern void +on_cmp_l_toggled (GtkWidget *widget, gpointer data); + +extern void +on_overflow_toggled (GtkWidget *widget, gpointer data); + +extern void +on_loc_arrow_clicked (GtkWidget *widget, gpointer data); + + + +#endif /* MIXGTK_MIXVM_H */ + diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c new file mode 100644 index 0000000..165da81 --- /dev/null +++ b/mixgtk/mixgtk_widgets.c @@ -0,0 +1,112 @@ +/* -*-c-*- -------------- mixgtk_widgets.c : + * Implementation of the functions declared in mixgtk_widgets.h + * ------------------------------------------------------------------ + * Last change: Time-stamp: "01/03/15 14:42:37 jose" + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + + +#include +#include +#include "mixgtk_widgets.h" + +/* the glade spec */ +static GladeXML *xml_ = NULL; + +/* widget names */ +static const gchar *names_[] = { + "main_window", + "main_statusbar", + "word_dialog", + "about_dialog", + "goto_dialog", + "command_prompt", + "command_log", + "mixal_clist", + "rA_entry", + "rX_entry", + "rJ_entry", + "rI1_entry", + "rI2_entry", + "rI3_entry", + "rI4_entry", + "rI5_entry", + "rI6_entry", + "lesser_radio", + "equal_radio", + "greater_radio", + "over_toggle", + "memory_cells", + "memory_scroll", + "devices_notebook", + "loc_entry", + "elapsed_label", + "program_label", + "uptime_label", + NULL +}; + +#define WIDGET_NO_ (sizeof (names_) / sizeof (names_[0])) + +#define VERSION_LABEL_ "version_label" +#define GPL_TEXT_ "gpl_text" + +GtkWidget *about_; + +/* create a new factory from an xml glade file */ +gboolean +mixgtk_widget_factory_init (const char *glade_file) +{ + GtkWidget *label; + glade_init (); + xml_ = glade_xml_new (glade_file, NULL); + if (!xml_) return FALSE; + glade_xml_signal_autoconnect (xml_); + + about_ = mixgtk_widget_factory_get (MIXGTK_WIDGET_ABOUT_DIALOG); + g_return_val_if_fail (about_ != NULL, FALSE); + label = mixgtk_widget_factory_get_by_name (VERSION_LABEL_); + g_return_val_if_fail (label != NULL, FALSE); + gtk_label_set_text (GTK_LABEL(label), VERSION); + gtk_widget_show (label); + return TRUE; +} + +/* get a widget */ +GtkWidget * +mixgtk_widget_factory_get (mixgtk_widget_id_t widget) +{ + g_return_val_if_fail (widget < WIDGET_NO_, NULL); + return glade_xml_get_widget (xml_, names_[widget]); +} + +/* Get a widget by name */ +GtkWidget * +mixgtk_widget_factory_get_by_name (const gchar *name) +{ + return glade_xml_get_widget (xml_, name); +} + +/* about box */ +void +on_about_activate (GtkWidget *w, gpointer data) +{ + gtk_widget_show (about_); +} diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h new file mode 100644 index 0000000..f20ddc3 --- /dev/null +++ b/mixgtk/mixgtk_widgets.h @@ -0,0 +1,80 @@ +/* -*-c-*- ---------------- mixgtk_widgets.h : + * glade-based factory of mixvm widgets + * ------------------------------------------------------------------ + * Last change: Time-stamp: <01/03/15 14:42:13 jose> + * ------------------------------------------------------------------ + * Copyright (C) 2001 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef MIXGTK_WIDGETS_H +#define MIXGTK_WIDGETS_H + +#include +#include + +/* enumeration of mixvm widget ids */ +typedef enum { + MIXGTK_WIDGET_MAIN, /* main app window */ + MIXGTK_WIDGET_STATUSBAR, + MIXGTK_WIDGET_WORD_DIALOG, /* input dialog for a mix word */ + MIXGTK_WIDGET_ABOUT_DIALOG, + MIXGTK_WIDGET_GOTO_DIALOG, + MIXGTK_WIDGET_PROMPT, /* command prompt */ + MIXGTK_WIDGET_LOG, /* command output */ + MIXGTK_WIDGET_MIXAL, /* mixal source file */ + MIXGTK_WIDGET_rA, + MIXGTK_WIDGET_rX, + MIXGTK_WIDGET_rJ, + MIXGTK_WIDGET_rI1, + MIXGTK_WIDGET_rI2, + MIXGTK_WIDGET_rI3, + MIXGTK_WIDGET_rI4, + MIXGTK_WIDGET_rI5, + MIXGTK_WIDGET_rI6, + MIXGTK_WIDGET_CMP_L, + MIXGTK_WIDGET_CMP_E, + MIXGTK_WIDGET_CMP_G, + MIXGTK_WIDGET_OVER, + MIXGTK_WIDGET_CELLS, + MIXGTK_WIDGET_CELLS_SCROLL, + MIXGTK_WIDGET_DEVICE, + MIXGTK_WIDGET_LOC, + MIXGTK_WIDGET_LAPTIME, + MIXGTK_WIDGET_PROGTIME, + MIXGTK_WIDGET_UPTIME, + MIXGTK_WIDGET_NONE +} mixgtk_widget_id_t; + + +/* create a new factory from an xml glade file */ +extern gboolean +mixgtk_widget_factory_init (const char *glade_file); + + +/* get a widget */ +extern GtkWidget * +mixgtk_widget_factory_get (mixgtk_widget_id_t widget); + +/* Get a widget by name */ +extern GtkWidget * +mixgtk_widget_factory_get_by_name (const gchar *name); + + +#endif /* MIXGTK_WIDGETS_H */ + -- cgit v1.2.3