struct lex_reader *
-lex_reader_for_gtk_text_buffer (GtkTextBuffer *buffer, GtkTextIter start, GtkTextIter stop)
+lex_reader_for_gtk_text_buffer (GtkTextBuffer *buffer,
+ GtkTextIter start, GtkTextIter stop,
+ enum lex_syntax_mode syntax_mode)
{
struct lex_gtk_text_buffer_reader *r = xmalloc (sizeof *r);
lex_reader_init (&r->reader, &lex_gtk_text_buffer_reader_class);
+ r->reader.syntax = syntax_mode;
r->buffer = buffer;
g_object_ref (buffer);
GtkTextIter stop)
{
PsppireWindow *win = PSPPIRE_WINDOW (sw);
- struct lex_reader *reader = lex_reader_for_gtk_text_buffer (GTK_TEXT_BUFFER (sw->buffer), start, stop);
+ struct lex_reader *reader = lex_reader_for_gtk_text_buffer (
+ GTK_TEXT_BUFFER (sw->buffer), start, stop, sw->syntax_mode);
lex_reader_set_file_name (reader, psppire_window_get_filename (win));
+static void
+on_syntax (GAction *action, GVariant *param, PsppireSyntaxWindow *sw)
+{
+ g_action_change_state (action, param);
+ GVariant *new_state = g_action_get_state (action);
+
+ const gchar *what = g_variant_get_string (new_state, NULL);
+ if (0 == g_strcmp0 (what, "auto"))
+ sw->syntax_mode = LEX_SYNTAX_AUTO;
+ else if (0 == g_strcmp0 (what, "interactive"))
+ sw->syntax_mode = LEX_SYNTAX_INTERACTIVE;
+ else if (0 == g_strcmp0 (what, "batch"))
+ sw->syntax_mode = LEX_SYNTAX_BATCH;
+ else
+ g_warn_if_reached ();
+}
+
+
/* Append ".sps" to FILENAME if necessary.
The returned result must be freed when no longer required.
*/
NULL);
window->encoding = NULL;
+ window->syntax_mode = LEX_SYNTAX_AUTO;
window->cliptext = NULL;
window->dispose_has_run = FALSE;
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (run_to_end));
}
+ {
+ GSimpleAction *act_syntax = g_simple_action_new_stateful ("syntax", G_VARIANT_TYPE_STRING,
+ g_variant_new_string ("auto"));
+ g_signal_connect (act_syntax, "activate", G_CALLBACK (on_syntax), window);
+ g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (act_syntax));
+ }
+
gtk_menu_shell_append (GTK_MENU_SHELL (menubar),
create_windows_menu (GTK_WINDOW (window)));
#include <gtksourceview/gtksource.h>
+#include "language/lexer/lexer.h"
+
G_BEGIN_DECLS
#define PSPPIRE_SYNTAX_WINDOW_TYPE (psppire_syntax_window_get_type ())
/* <private> */
GtkSourceBuffer *buffer; /* The buffer which contains the text */
- struct lexer *lexer; /* Lexer to parse syntax */
gchar *encoding; /* File's encoding. */
GtkWidget *sb;
guint text_context;
+ enum lex_syntax_mode syntax_mode;
GtkPrintSettings *print_settings;
GtkSourcePrintCompositor *compositor;
<attribute name="action">win.run-to-end</attribute>
</item>
</section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">A_uto Syntax</attribute>
+ <attribute name="target">auto</attribute>
+ <attribute name="action">win.syntax</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Interactive Syntax</attribute>
+ <attribute name="target">interactive</attribute>
+ <attribute name="action">win.syntax</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Batch Syntax</attribute>
+ <attribute name="target">batch</attribute>
+ <attribute name="action">win.syntax</attribute>
+ </item>
+ </section>
</submenu>
</menu>
<object class="GtkScrolledWindow" id="scrolledwindow8">