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
21 #include <libpspp/getl.h>
22 #include <libpspp/alloc.h>
23 #include <libpspp/compiler.h>
24 #include <libpspp/str.h>
30 #include "syntax-editor-source.h"
31 #include "syntax-editor.h"
33 struct syntax_editor_source
35 struct getl_interface parent;
36 const struct syntax_editor *se;
43 always_false (const struct getl_interface *i UNUSED)
48 /* Returns the name of the source */
50 name (const struct getl_interface *i)
52 const struct syntax_editor_source *ses =
53 (const struct syntax_editor_source *) i;
55 return window_name ((struct window_editor *) ses->se);
59 /* Returns the location within the source */
61 location (const struct getl_interface *i)
63 const struct syntax_editor_source *ses = (const struct syntax_editor_source *) i;
65 return gtk_text_iter_get_line (&ses->i);
70 read_line_from_buffer (struct getl_interface *i,
72 enum getl_syntax *syntax_rules)
75 GtkTextIter next_line;
77 struct syntax_editor_source *ses = (struct syntax_editor_source *) i;
79 if ( gtk_text_iter_compare (&ses->i, &ses->end) >= 0)
82 gtk_text_buffer_get_iter_at_line ( ses->se->buffer,
84 1 + gtk_text_iter_get_line (&ses->i)
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 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 = close;
125 ses->parent.name = name;
126 ses->parent.location = location;
129 return (struct getl_interface *) ses;