1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2006 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include <libpspp/getl.h>
21 #include <libpspp/compiler.h>
22 #include <libpspp/str.h>
28 #include "syntax-editor-source.h"
29 #include "psppire-syntax-window.h"
33 struct syntax_editor_source
35 struct getl_interface parent;
36 GtkTextBuffer *buffer;
44 always_false (const struct getl_interface *i UNUSED)
49 /* Returns the name of the source */
51 name (const struct getl_interface *i)
53 const struct syntax_editor_source *ses = (const struct syntax_editor_source *) i;
58 /* Returns the location within the source */
60 location (const struct getl_interface *i)
62 const struct syntax_editor_source *ses = (const struct syntax_editor_source *) i;
64 return gtk_text_iter_get_line (&ses->i);
69 read_line_from_buffer (struct getl_interface *i,
73 GtkTextIter next_line;
75 struct syntax_editor_source *ses = (struct syntax_editor_source *) i;
77 if ( gtk_text_iter_compare (&ses->i, &ses->end) >= 0)
81 gtk_text_iter_forward_line (&next_line);
83 text = gtk_text_buffer_get_text (ses->buffer,
88 ds_assign_cstr (line, text);
92 gtk_text_iter_forward_line (&ses->i);
99 do_close (struct getl_interface *i )
104 struct getl_interface *
105 create_syntax_editor_source (GtkTextBuffer *buffer,
111 struct syntax_editor_source *ses = xzalloc (sizeof *ses);
113 ses->buffer = buffer;
119 ses->parent.interactive = always_false;
120 ses->parent.read = read_line_from_buffer;
121 ses->parent.close = do_close;
123 ses->parent.name = name;
124 ses->parent.location = location;
127 return (struct getl_interface *) ses;