2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2006 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include <libpspp/getl.h>
24 #include <libpspp/alloc.h>
25 #include <libpspp/compiler.h>
26 #include <libpspp/str.h>
32 #include "syntax-editor-source.h"
33 #include "syntax-editor.h"
35 struct syntax_editor_source
37 struct getl_interface parent;
38 const struct syntax_editor *se;
45 always_false (const struct getl_interface *i UNUSED)
50 /* Returns the name of the source */
52 name (const struct getl_interface *i)
54 const struct syntax_editor_source *ses =
55 (const struct syntax_editor_source *) i;
57 return window_name ((const struct editor_window *) ses->se);
61 /* Returns the location within the source */
63 location (const struct getl_interface *i)
65 const struct syntax_editor_source *ses = (const struct syntax_editor_source *) i;
67 return gtk_text_iter_get_line (&ses->i);
72 read_line_from_buffer (struct getl_interface *i,
74 enum getl_syntax *syntax_rules)
77 GtkTextIter next_line;
79 struct syntax_editor_source *ses = (struct syntax_editor_source *) i;
81 if ( gtk_text_iter_compare (&ses->i, &ses->end) >= 0)
85 gtk_text_iter_forward_line (&next_line);
87 text = gtk_text_buffer_get_text (ses->se->buffer,
92 ds_assign_cstr (line, text);
96 gtk_text_iter_forward_line (&ses->i);
103 do_close (struct getl_interface *i )
108 struct getl_interface *
109 create_syntax_editor_source (const struct syntax_editor *se,
114 struct syntax_editor_source *ses = xzalloc (sizeof *ses);
121 ses->parent.interactive = always_false;
122 ses->parent.read = read_line_from_buffer;
123 ses->parent.close = do_close;
125 ses->parent.name = name;
126 ses->parent.location = location;
129 return (struct getl_interface *) ses;