Added the ability to run syntax from the syntax editor.
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 17 Dec 2006 00:01:04 +0000 (00:01 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 17 Dec 2006 00:01:04 +0000 (00:01 +0000)
13 files changed:
po/de.po
po/pspp.pot
src/ui/gui/ChangeLog
src/ui/gui/automake.mk
src/ui/gui/message-dialog.c
src/ui/gui/psppire-dict.c
src/ui/gui/psppire-dict.h
src/ui/gui/psppire.c
src/ui/gui/psppire.glade
src/ui/gui/syntax-editor-source.c [new file with mode: 0644]
src/ui/gui/syntax-editor-source.h [new file with mode: 0644]
src/ui/gui/syntax-editor.c
src/ui/gui/syntax-editor.h [new file with mode: 0644]

index 1f7613666af4c973889688d3bb5448b2f200b457..1232884e2d566302c92c953d44265b6829ba8280 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -10,7 +10,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PSPP 0.4.2\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
 msgstr ""
 "Project-Id-Version: PSPP 0.4.2\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2006-12-16 13:22+0900\n"
+"POT-Creation-Date: 2006-12-16 15:49+0900\n"
 "PO-Revision-Date: 2006-05-26 17:49+0800\n"
 "Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
 "Language-Team: German <pspp-dev@gnu.org>\n"
 "PO-Revision-Date: 2006-05-26 17:49+0800\n"
 "Last-Translator: John Darrington <john@darrington.wattle.id.au>\n"
 "Language-Team: German <pspp-dev@gnu.org>\n"
@@ -4165,8 +4165,8 @@ msgstr ""
 msgid "Style of bevel around the custom entry button"
 msgstr ""
 
 msgid "Style of bevel around the custom entry button"
 msgstr ""
 
-#: src/ui/gui/menu-actions.c:63 src/ui/gui/syntax-editor.c:60
-#: src/ui/gui/syntax-editor.c:82
+#: src/ui/gui/menu-actions.c:63 src/ui/gui/syntax-editor.c:64
+#: src/ui/gui/syntax-editor.c:86
 msgid "Untitled"
 msgstr "Unbetitelt"
 
 msgid "Untitled"
 msgstr "Unbetitelt"
 
@@ -4186,8 +4186,8 @@ msgstr "Systemedatein (*.sav)"
 msgid "Portable Files (*.por) "
 msgstr "Tragbardatein (*.por)"
 
 msgid "Portable Files (*.por) "
 msgstr "Tragbardatein (*.por)"
 
-#: src/ui/gui/menu-actions.c:239 src/ui/gui/syntax-editor.c:121
-#: src/ui/gui/syntax-editor.c:377
+#: src/ui/gui/menu-actions.c:239 src/ui/gui/syntax-editor.c:125
+#: src/ui/gui/syntax-editor.c:416
 msgid "All Files"
 msgstr "Alle Datei"
 
 msgid "All Files"
 msgstr "Alle Datei"
 
@@ -4211,6 +4211,11 @@ msgstr "Datei Fehler"
 msgid "PSPP Error"
 msgstr "PSPP Fehler"
 
 msgid "PSPP Error"
 msgstr "PSPP Fehler"
 
+#: src/ui/gui/message-dialog.c:149
+#, c-format
+msgid "%s (line %d) %s"
+msgstr ""
+
 #: src/ui/gui/missing-val-dialog.c:117 src/ui/gui/missing-val-dialog.c:162
 msgid "Incorrect value for variable type"
 msgstr "Unpassend Wert für Variable"
 #: src/ui/gui/missing-val-dialog.c:117 src/ui/gui/missing-val-dialog.c:162
 msgid "Incorrect value for variable type"
 msgstr "Unpassend Wert für Variable"
@@ -4219,7 +4224,7 @@ msgstr "Unpassend Wert für Variable"
 msgid "Incorrect range specification"
 msgstr "Falshe Spannweitebeschreibung"
 
 msgid "Incorrect range specification"
 msgstr "Falshe Spannweitebeschreibung"
 
-#: src/ui/gui/psppire.c:71
+#: src/ui/gui/psppire.c:74
 msgid "Sorry. The help system hasn't yet been implemented."
 msgstr "Es gibt noch nicht kein Helpsysteme. Schade!"
 
 msgid "Sorry. The help system hasn't yet been implemented."
 msgstr "Es gibt noch nicht kein Helpsysteme. Schade!"
 
@@ -4566,27 +4571,27 @@ msgstr ""
 msgid "Criteria"
 msgstr ""
 
 msgid "Criteria"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:59
+#: src/ui/gui/syntax-editor.c:63
 #, c-format
 msgid "Save contents of syntax editor to %s?"
 msgstr ""
 
 #, c-format
 msgid "Save contents of syntax editor to %s?"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:107
+#: src/ui/gui/syntax-editor.c:111
 #, fuzzy
 msgid "Save Syntax"
 msgstr "Speichern unter"
 
 #, fuzzy
 msgid "Save Syntax"
 msgstr "Speichern unter"
 
-#: src/ui/gui/syntax-editor.c:115 src/ui/gui/syntax-editor.c:371
+#: src/ui/gui/syntax-editor.c:119 src/ui/gui/syntax-editor.c:410
 #, fuzzy
 msgid "Syntax Files (*.sps) "
 msgstr "Systemedatein (*.sav)"
 
 #, fuzzy
 msgid "Syntax Files (*.sps) "
 msgstr "Systemedatein (*.sav)"
 
-#: src/ui/gui/syntax-editor.c:276
+#: src/ui/gui/syntax-editor.c:312
 #, fuzzy, c-format
 msgid "%s --- PSPP Syntax Editor"
 msgstr "PSPP Dateiaufbereiter"
 
 #, fuzzy, c-format
 msgid "%s --- PSPP Syntax Editor"
 msgstr "PSPP Dateiaufbereiter"
 
-#: src/ui/gui/syntax-editor.c:363
+#: src/ui/gui/syntax-editor.c:402
 msgid "Open Syntax"
 msgstr ""
 
 msgid "Open Syntax"
 msgstr ""
 
index 707b5310a3d8b22d9516d46d4c6786a8d572acb0..63c5b73d05b5d8fb04d16d5fa1fdfd682d6973fd 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: pspp-dev@gnu.org\n"
-"POT-Creation-Date: 2006-12-16 13:22+0900\n"
+"POT-Creation-Date: 2006-12-16 15:49+0900\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -4160,8 +4160,8 @@ msgstr ""
 msgid "Style of bevel around the custom entry button"
 msgstr ""
 
 msgid "Style of bevel around the custom entry button"
 msgstr ""
 
-#: src/ui/gui/menu-actions.c:63 src/ui/gui/syntax-editor.c:60
-#: src/ui/gui/syntax-editor.c:82
+#: src/ui/gui/menu-actions.c:63 src/ui/gui/syntax-editor.c:64
+#: src/ui/gui/syntax-editor.c:86
 msgid "Untitled"
 msgstr ""
 
 msgid "Untitled"
 msgstr ""
 
@@ -4181,8 +4181,8 @@ msgstr ""
 msgid "Portable Files (*.por) "
 msgstr ""
 
 msgid "Portable Files (*.por) "
 msgstr ""
 
-#: src/ui/gui/menu-actions.c:239 src/ui/gui/syntax-editor.c:121
-#: src/ui/gui/syntax-editor.c:377
+#: src/ui/gui/menu-actions.c:239 src/ui/gui/syntax-editor.c:125
+#: src/ui/gui/syntax-editor.c:416
 msgid "All Files"
 msgstr ""
 
 msgid "All Files"
 msgstr ""
 
@@ -4206,6 +4206,11 @@ msgstr ""
 msgid "PSPP Error"
 msgstr ""
 
 msgid "PSPP Error"
 msgstr ""
 
+#: src/ui/gui/message-dialog.c:149
+#, c-format
+msgid "%s (line %d) %s"
+msgstr ""
+
 #: src/ui/gui/missing-val-dialog.c:117 src/ui/gui/missing-val-dialog.c:162
 msgid "Incorrect value for variable type"
 msgstr ""
 #: src/ui/gui/missing-val-dialog.c:117 src/ui/gui/missing-val-dialog.c:162
 msgid "Incorrect value for variable type"
 msgstr ""
@@ -4214,7 +4219,7 @@ msgstr ""
 msgid "Incorrect range specification"
 msgstr ""
 
 msgid "Incorrect range specification"
 msgstr ""
 
-#: src/ui/gui/psppire.c:71
+#: src/ui/gui/psppire.c:74
 msgid "Sorry. The help system hasn't yet been implemented."
 msgstr ""
 
 msgid "Sorry. The help system hasn't yet been implemented."
 msgstr ""
 
@@ -4552,25 +4557,25 @@ msgstr ""
 msgid "Criteria"
 msgstr ""
 
 msgid "Criteria"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:59
+#: src/ui/gui/syntax-editor.c:63
 #, c-format
 msgid "Save contents of syntax editor to %s?"
 msgstr ""
 
 #, c-format
 msgid "Save contents of syntax editor to %s?"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:107
+#: src/ui/gui/syntax-editor.c:111
 msgid "Save Syntax"
 msgstr ""
 
 msgid "Save Syntax"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:115 src/ui/gui/syntax-editor.c:371
+#: src/ui/gui/syntax-editor.c:119 src/ui/gui/syntax-editor.c:410
 msgid "Syntax Files (*.sps) "
 msgstr ""
 
 msgid "Syntax Files (*.sps) "
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:276
+#: src/ui/gui/syntax-editor.c:312
 #, c-format
 msgid "%s --- PSPP Syntax Editor"
 msgstr ""
 
 #, c-format
 msgid "%s --- PSPP Syntax Editor"
 msgstr ""
 
-#: src/ui/gui/syntax-editor.c:363
+#: src/ui/gui/syntax-editor.c:402
 msgid "Open Syntax"
 msgstr ""
 
 msgid "Open Syntax"
 msgstr ""
 
index daa4de7d19ddb1803efefb990cc4b9b6f4044dbf..70931061c0570534744760d686471dcba4382110 100644 (file)
@@ -1,3 +1,15 @@
+Sun Dec 17 08:26:10 WST 2006 John Darrington <john@darrington.wattle.id.au>
+
+       * syntax-editor-source.c syntax-editor-source.h syntax-editor.h: 
+       New files. 
+
+       * message-dialog.c :  Now reports the filename and line number in 
+       error messages.
+       
+       * psppire.c psppire.glade syntax-editor.c: Added the ability to run 
+       syntax from the syntax editor.
+
+       
 Sat Dec 16 14:13:07 2006  Ben Pfaff  <blp@gnu.org>
 
        * psppire-data-store.c (geometry_get_justification): Don't assume
 Sat Dec 16 14:13:07 2006  Ben Pfaff  <blp@gnu.org>
 
        * psppire-data-store.c (geometry_get_justification): Don't assume
index 2e537cfdb7f48340d07d3f86dc5d7be2fa38633c..53738069d6227591fd2320c34b3558b4d86a9ab1 100644 (file)
@@ -8,13 +8,19 @@ src_ui_gui_psppire_LDFLAGS = \
        -export-dynamic 
 
 src_ui_gui_psppire_LDADD = \
        -export-dynamic 
 
 src_ui_gui_psppire_LDADD = \
+       lib/gtksheet/libgtksheet.a \
+       src/language/liblanguage.a \
+       src/ui/libuicommon.a \
+       src/output/charts/libcharts.a \
+       src/output/liboutput.a \
+       src/math/libpspp_math.a  \
+       src/math/linreg/libpspp_linreg.a  \
+       lib/linreg/liblinreg.a  \
+       lib/gsl-extras/libgsl-extras.a  \
+       src/data/libdata.a \
+       src/libpspp/libpspp.a \
        $(GTK_LIBS) \
        $(GLADE_LIBS) \
        $(GTK_LIBS) \
        $(GLADE_LIBS) \
-       $(top_builddir)/lib/gtksheet/libgtksheet.a \
-       $(top_builddir)/src/ui/libuicommon.a \
-       $(top_builddir)/src/math/libpspp_math.a \
-       $(top_builddir)/src/data/libdata.a \
-       $(top_builddir)/src/libpspp/libpspp.a \
        $(top_builddir)/gl/libgl.a \
        @LIBINTL@ @LIBREADLINE@
 
        $(top_builddir)/gl/libgl.a \
        @LIBINTL@ @LIBREADLINE@
 
@@ -60,6 +66,9 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/sort-cases-dialog.c \
        src/ui/gui/sort-cases-dialog.h \
        src/ui/gui/syntax-editor.c \
        src/ui/gui/sort-cases-dialog.c \
        src/ui/gui/sort-cases-dialog.h \
        src/ui/gui/syntax-editor.c \
+       src/ui/gui/syntax-editor.h \
+       src/ui/gui/syntax-editor-source.c \
+       src/ui/gui/syntax-editor-source.h \
        src/ui/gui/val-labs-dialog.c \
        src/ui/gui/val-labs-dialog.h \
        src/ui/gui/var-sheet.c \
        src/ui/gui/val-labs-dialog.c \
        src/ui/gui/val-labs-dialog.h \
        src/ui/gui/var-sheet.c \
index 1a4a00a01703e825bcb0782999533290c29c6564..8b910ce242a093d74fa4451c4f50c372b1688ce7 100644 (file)
@@ -136,7 +136,7 @@ popup_message(const struct msg *m)
       msg = _("PSPP Error");
       break;
     };
       msg = _("PSPP Error");
       break;
     };
-  
+
   parent = GTK_WINDOW(get_widget_assert(xml, "data_editor"));
 
   dialog = gtk_message_dialog_new(parent,
   parent = GTK_WINDOW(get_widget_assert(xml, "data_editor"));
 
   dialog = gtk_message_dialog_new(parent,
@@ -144,10 +144,13 @@ popup_message(const struct msg *m)
                                  message_type,
                                  GTK_BUTTONS_CLOSE,
                                  msg);
                                  message_type,
                                  GTK_BUTTONS_CLOSE,
                                  msg);
-  
+
   gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
   gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
-                                           "%s", m->text);
-    
+                                           _("%s (line %d) %s"),
+                                          m->where.file_name,
+                                          m->where.line_number,
+                                          m->text);
+
   gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
 
   gtk_dialog_run(GTK_DIALOG(dialog));
   gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
 
   gtk_dialog_run(GTK_DIALOG(dialog));
index 59378fc968352b8a839533d21a043817e0e5c23e..ae047d311336f84e3541de5c384caf3fe500fb97 100644 (file)
@@ -200,26 +200,9 @@ static const struct dict_callbacks gui_callbacks =
 static void
 psppire_dict_init (PsppireDict *psppire_dict)
 {
 static void
 psppire_dict_init (PsppireDict *psppire_dict)
 {
-  psppire_dict->dict = dict_create ();
-
-  dict_set_callbacks (psppire_dict->dict, &gui_callbacks, psppire_dict);
-
   psppire_dict->stamp = g_random_int();
 }
 
   psppire_dict->stamp = g_random_int();
 }
 
-/**
- * psppire_dict_new:
- * @returns: a new #PsppireDict object
- *
- * Creates a new #PsppireDict.
- */
-PsppireDict*
-psppire_dict_new (void)
-{
-  return g_object_new (G_TYPE_PSPPIRE_DICT, NULL);
-}
-
-
 /**
  * psppire_dict_new_from_dict:
  * @returns: a new #PsppireDict object
 /**
  * psppire_dict_new_from_dict:
  * @returns: a new #PsppireDict object
@@ -232,6 +215,8 @@ psppire_dict_new_from_dict (struct dictionary *d)
   PsppireDict *new_dict = g_object_new (G_TYPE_PSPPIRE_DICT, NULL);
   new_dict->dict = d;
 
   PsppireDict *new_dict = g_object_new (G_TYPE_PSPPIRE_DICT, NULL);
   new_dict->dict = d;
 
+  dict_set_callbacks (new_dict->dict, &gui_callbacks, new_dict);
+
   return new_dict;
 }
 
   return new_dict;
 }
 
index 3aac1ced4d5f3d47c47ef2b70c00173e8e179a34..5d24198fa3371e3aef1921e0dd97e626269da755 100644 (file)
@@ -66,7 +66,6 @@ struct _PsppireDictClass
 
 /* -- PsppireDict --- */
 GType          psppire_dict_get_type (void);
 
 /* -- PsppireDict --- */
 GType          psppire_dict_get_type (void);
-PsppireDict*     psppire_dict_new (void);
 PsppireDict*     psppire_dict_new_from_dict (struct dictionary *d);
 void           psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
 PsppireDict*     psppire_dict_new_from_dict (struct dictionary *d);
 void           psppire_dict_set_name (PsppireDict* s, gint idx, const gchar *name);
 void           psppire_dict_delete_var (PsppireDict *s, gint idx);
index 19a2eabe06d24eb0d161403f09bf7df017199077..3614224510472520d8a315ea3a9db17c9e718904 100644 (file)
 
 #include <libpspp/version.h>
 #include <libpspp/copyleft.h>
 
 #include <libpspp/version.h>
 #include <libpspp/copyleft.h>
+#include <data/file-handle-def.h>
 #include <data/format.h>
 #include <data/settings.h>
 #include <data/file-name.h>
 #include <data/format.h>
 #include <data/settings.h>
 #include <data/file-name.h>
+#include <data/procedure.h>
 #include <libpspp/getl.h>
 #include <libpspp/getl.h>
+#include <language/lexer/lexer.h>
 
 #include <getopt.h>
 #include <gtk/gtk.h>
 
 #include <getopt.h>
 #include <gtk/gtk.h>
@@ -77,7 +80,10 @@ PsppireVarStore *var_store = 0;
 
 void create_icon_factory (void);
 
 
 void create_icon_factory (void);
 
-static struct source_stream *the_source_stream ;
+struct source_stream *the_source_stream ;
+struct lexer *the_lexer;
+struct dataset * the_dataset = NULL;
+
 
 int 
 main(int argc, char *argv[]) 
 
 int 
 main(int argc, char *argv[]) 
@@ -118,13 +124,21 @@ main(int argc, char *argv[])
 
   fmt_init();
   settings_init();
 
   fmt_init();
   settings_init();
+  fh_init ();
   the_source_stream = create_source_stream (
                          fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
                          );
 
   the_source_stream = create_source_stream (
                          fn_getenv_default ("STAT_INCLUDE_PATH", include_path)
                          );
 
+  the_lexer = lex_create (the_source_stream);
+
+  the_dataset = create_dataset ();
+
   message_dialog_init (the_source_stream);
 
   message_dialog_init (the_source_stream);
 
-  the_dictionary = psppire_dict_new();
+  the_dictionary =
+    psppire_dict_new_from_dict (
+                               dataset_dict (the_dataset)
+                               );
 
   bind_textdomain_codeset(PACKAGE, "UTF-8");
 
 
   bind_textdomain_codeset(PACKAGE, "UTF-8");
 
index b7a49bee1d2f16678c73dbf40313b30fee7c102b..b0f997275b96cb1f65b935410d47adc31958d9ba 100644 (file)
                <widget class="GtkMenu" id="run1_menu">
 
                  <child>
                <widget class="GtkMenu" id="run1_menu">
 
                  <child>
-                   <widget class="GtkMenuItem" id="all1">
+                   <widget class="GtkMenuItem" id="run_all">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">All</property>
                      <property name="use_underline">True</property>
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">All</property>
                      <property name="use_underline">True</property>
                  </child>
 
                  <child>
                  </child>
 
                  <child>
-                   <widget class="GtkMenuItem" id="selection1">
+                   <widget class="GtkMenuItem" id="run_selection">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">Selection</property>
                      <property name="use_underline">True</property>
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">Selection</property>
                      <property name="use_underline">True</property>
                  </child>
 
                  <child>
                  </child>
 
                  <child>
-                   <widget class="GtkMenuItem" id="current_line1">
+                   <widget class="GtkMenuItem" id="run_current_line">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">Current Line</property>
                      <property name="use_underline">True</property>
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">Current Line</property>
                      <property name="use_underline">True</property>
                  </child>
 
                  <child>
                  </child>
 
                  <child>
-                   <widget class="GtkMenuItem" id="to_end1">
+                   <widget class="GtkMenuItem" id="run_to_end">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">To End</property>
                      <property name="use_underline">True</property>
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">To End</property>
                      <property name="use_underline">True</property>
diff --git a/src/ui/gui/syntax-editor-source.c b/src/ui/gui/syntax-editor-source.c
new file mode 100644 (file)
index 0000000..53478d2
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+    PSPPIRE --- A Graphical User Interface for PSPP
+    Copyright (C) 2006  Free Software Foundation
+
+    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., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA. */
+
+
+#include <libpspp/getl.h>
+#include <libpspp/alloc.h>
+#include <libpspp/compiler.h>
+#include <libpspp/str.h>
+
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include "syntax-editor-source.h"
+#include "syntax-editor.h"
+
+struct syntax_editor_source
+  {
+    struct getl_interface parent;
+    const struct syntax_editor *se;
+    GtkTextIter i;
+    GtkTextIter end;
+  };
+
+
+static bool
+always_false (const struct getl_interface *i UNUSED)
+{
+  return false;
+}
+
+/* Returns the name of the source */
+static const char *
+name (const struct getl_interface *i)
+{
+  const struct syntax_editor_source *ses =
+    (const struct syntax_editor_source *) i;
+
+  return ses->se->name;
+}
+
+
+/* Returns the location within the source */
+static int
+location (const struct getl_interface *i)
+{
+  const struct syntax_editor_source *ses = (const struct syntax_editor_source *) i;
+
+  return gtk_text_iter_get_line (&ses->i);
+}
+
+
+static bool
+read_line_from_buffer (struct getl_interface *i,
+                      struct string *line,
+                      enum getl_syntax *syntax_rules)
+{
+  gchar *text;
+  GtkTextIter next_line;
+
+  struct syntax_editor_source *ses = (struct syntax_editor_source *) i;
+
+  if ( gtk_text_iter_compare (&ses->i, &ses->end) >= 0)
+    return false;
+
+  gtk_text_buffer_get_iter_at_line ( ses->se->buffer,
+                                    &next_line,
+                                    1 + gtk_text_iter_get_line (&ses->i)
+                                    );
+
+  text = gtk_text_buffer_get_text (ses->se->buffer,
+                                  &ses->i, &next_line,
+                                  FALSE);
+  g_strchomp (text);
+
+  ds_assign_cstr (line, text);
+
+  g_free (text);
+
+  gtk_text_iter_forward_line (&ses->i);
+
+  return true;
+}
+
+
+static void
+close (struct getl_interface *i )
+{
+  free (i);
+}
+
+struct getl_interface *
+create_syntax_editor_source (const struct syntax_editor *se,
+                            GtkTextIter start,
+                            GtkTextIter stop
+                            )
+{
+  struct syntax_editor_source *ses = xzalloc (sizeof *ses);
+
+  ses->se = se;
+  ses->i = start;
+  ses->end = stop;
+
+
+  ses->parent.interactive = always_false;
+  ses->parent.read = read_line_from_buffer;
+  ses->parent.close = close;
+
+  ses->parent.name = name;
+  ses->parent.location = location;
+
+
+  return (struct getl_interface *) ses;
+}
diff --git a/src/ui/gui/syntax-editor-source.h b/src/ui/gui/syntax-editor-source.h
new file mode 100644 (file)
index 0000000..9b1f455
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+    PSPPIRE --- A Graphical User Interface for PSPP
+    Copyright (C) 2006  Free Software Foundation
+
+    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., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA. */
+
+#ifndef SYNTAX_EDITOR_SOURCE_H
+#define SYNTAX_EDITOR_SOURCE_H
+
+#include <gtk/gtk.h>
+struct getl_interface;
+
+struct syntax_editor;
+
+struct getl_interface *
+create_syntax_editor_source (const struct syntax_editor *se,
+                            GtkTextIter start,
+                            GtkTextIter stop
+                            );
+
+
+
+#endif
index fe880cbeec34471dffd93929bb80322cdca00f6e..20f6e1b09456547e1f7f9f9dedb5ec06b820bec8 100644 (file)
 #include <glade/glade.h>
 #include <gtk/gtk.h>
 #include <libpspp/message.h>
 #include <glade/glade.h>
 #include <gtk/gtk.h>
 #include <libpspp/message.h>
-
+#include <libpspp/getl.h>
 #include "helper.h"
 
 #include "helper.h"
 
-extern GladeXML *xml;
 
 
-struct syntax_editor
-{
-  GtkWidget *window;      /* The top level window of the editor */
-  GtkTextBuffer *buffer;  /* The buffer which contains the text */
-  gchar *name;            /* The name of this syntax buffer/editor */
-};
+
+#include <language/command.h>
+#include <data/procedure.h>
+#include "syntax-editor.h"
+#include "syntax-editor-source.h"
+
+extern struct source_stream *the_source_stream ;
+extern struct lexer *the_lexer;
+extern struct dataset *the_dataset;
+
+extern GladeXML *xml;
 
 static gboolean save_editor_to_file (struct syntax_editor *se,
                                     const gchar *filename,
 
 static gboolean save_editor_to_file (struct syntax_editor *se,
                                     const gchar *filename,
@@ -188,6 +192,29 @@ on_quit (GtkMenuItem *menuitem, gpointer    user_data)
   return FALSE;
 }
 
   return FALSE;
 }
 
+static void
+on_run_all (GtkMenuItem *menuitem, gpointer user_data)
+{
+  GtkTextIter begin, end;
+  struct syntax_editor *se = user_data;
+
+  gtk_text_buffer_get_iter_at_line (se->buffer, &begin, 0);
+  gtk_text_buffer_get_iter_at_line (se->buffer, &end, -1);
+
+  getl_append_source (the_source_stream,
+                     create_syntax_editor_source (se, begin, end));
+  for (;;)
+    {
+      int result = cmd_parse (the_lexer, the_dataset,
+                             proc_has_source (the_dataset)
+                             ? CMD_STATE_DATA : CMD_STATE_INITIAL);
+
+      if (result == CMD_EOF || result == CMD_FINISH)
+       break;
+    }
+}
+
+
 void
 new_syntax_window (GtkMenuItem     *menuitem,
                   gpointer         user_data);
 void
 new_syntax_window (GtkMenuItem     *menuitem,
                   gpointer         user_data);
@@ -198,8 +225,9 @@ static void open_syntax_window (GtkMenuItem *menuitem,
                                gpointer user_data);
 
 
                                gpointer user_data);
 
 
-/* Create a new syntax editor with NAME.
-   If NAME is NULL, a name will be automatically assigned
+/*
+  Create a new syntax editor with NAME.
+  If NAME is NULL, a name will be automatically assigned
 */
 static struct syntax_editor *
 new_syntax_editor (const gchar *name)
 */
 static struct syntax_editor *
 new_syntax_editor (const gchar *name)
@@ -245,6 +273,12 @@ new_syntax_editor (const gchar *name)
                    G_CALLBACK(on_syntax_save_as),
                    se);
 
                    G_CALLBACK(on_syntax_save_as),
                    se);
 
+
+  g_signal_connect (get_widget_assert (new_xml,"run_all"),
+                   "activate",
+                   G_CALLBACK(on_run_all),
+                   se);
+
   g_object_unref (new_xml);
 
   g_signal_connect (se->window, "delete-event",
   g_object_unref (new_xml);
 
   g_signal_connect (se->window, "delete-event",
@@ -253,7 +287,9 @@ new_syntax_editor (const gchar *name)
   return se;
 }
 
   return se;
 }
 
-/* Callback for the File->New->Syntax menuitem */
+/*
+   Callback for the File->New->Syntax menuitem
+*/
 void
 new_syntax_window (GtkMenuItem     *menuitem,
                   gpointer         user_data)
 void
 new_syntax_window (GtkMenuItem     *menuitem,
                   gpointer         user_data)
@@ -280,8 +316,10 @@ set_window_title_from_filename (struct syntax_editor *se,
 }
 
 
 }
 
 
-/* Save BUFFER to the file called FILENAME.
-   If successful, clears the buffer's modified flag */
+/*
+  Save BUFFER to the file called FILENAME.
+  If successful, clears the buffer's modified flag
+*/
 static gboolean
 save_editor_to_file (struct syntax_editor *se,
                     const gchar *filename,
 static gboolean
 save_editor_to_file (struct syntax_editor *se,
                     const gchar *filename,
@@ -317,7 +355,8 @@ save_editor_to_file (struct syntax_editor *se,
 }
 
 
 }
 
 
-/* Loads the buffer from the file called FILENAME
+/*
+  Loads the buffer from the file called FILENAME
 */
 static gboolean
 load_editor_from_file (struct syntax_editor *se,
 */
 static gboolean
 load_editor_from_file (struct syntax_editor *se,
@@ -423,3 +462,7 @@ on_syntax1_activate   (GtkMenuItem     *menuitem,
 }
 #endif
 
 }
 #endif
 
+
+
+
+
diff --git a/src/ui/gui/syntax-editor.h b/src/ui/gui/syntax-editor.h
new file mode 100644 (file)
index 0000000..038e106
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+    PSPPIRE --- A Graphical User Interface for PSPP
+    Copyright (C) 2006  Free Software Foundation
+
+    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., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA. */
+
+
+#ifndef SYNTAX_EDITOR_H
+#define SYNTAX_EDITOR_H
+
+#include <gtk/gtk.h>
+
+
+
+struct syntax_editor
+{
+  GtkWidget *window;      /* The top level window of the editor */
+  GtkTextBuffer *buffer;  /* The buffer which contains the text */
+  gchar *name;            /* The name of this syntax buffer/editor */
+};
+
+
+#endif