#include <glade/glade.h>
#include <gtk/gtk.h>
#include <libpspp/message.h>
-
+#include <libpspp/getl.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,
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);
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)
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",
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)
}
-/* 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,
}
-/* 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,
}
#endif
+
+
+
+