Added stubs for all Gargoyle extensions and documented them
[rodin/chimara.git] / libchimara / garglk.c
1 #include <glib/gi18n.h>
2 #include <libchimara/glk.h>
3 #include "chimara-glk-private.h"
4 #include "stream.h"
5 #include "fileref.h"
6
7 extern GPrivate *glk_data_key;
8
9 /**
10  * garglk_fileref_get_name:
11  * @fref: A file reference.
12  *
13  * Gets the actual disk filename that @fref refers to, in the platform's
14  * native filename encoding. The string is owned by @fref and must not be
15  * changed or freed.
16  *
17  * Returns: a string in filename encoding.
18  */
19 char * 
20 garglk_fileref_get_name(frefid_t fref)
21 {
22         VALID_FILEREF(fref, return NULL);
23         return fref->filename;
24 }
25
26 /**
27  * garglk_set_program_name:
28  * @name: Name of the Glk program that is running.
29  *
30  * This function is used to let the library know the name of the currently
31  * running Glk program, in case it wants to display this information somewhere
32  * &mdash; for example, in the title bar of a window. A typical use of this
33  * function would be:
34  * |[ garglk_set_program_name("SuperGlkFrotz 0.1"); ]|
35  *
36  * <warning><para>This function is not currently implemented.</para></warning>
37  */
38 void 
39 garglk_set_program_name(const char *name)
40 {
41         WARNING(_("Not implemented"));
42 }
43
44 /**
45  * garglk_set_program_info:
46  * @info: Information about the Glk program that is running.
47  *
48  * This function is used to provide the library with additional information
49  * about the currently running Glk program, in case it wants to display this
50  * information somewhere &mdash; for example, in an About box. A typical use of
51  * this function would be:
52  * |[ 
53  * garglk_set_program_info("SuperGlkFrotz, version 0.1\n"
54  *     "Original Frotz by Stefan Jokisch\n"
55  *     "Unix port by Jim Dunleavy and David Griffith\n"
56  *     "Glk port by Tor Andersson\n"
57  *     "Animation, networking, and evil AI by Sven Metcalfe");
58  * ]|
59  *
60  * <warning><para>This function is not currently implemented.</para></warning>
61  */
62 void 
63 garglk_set_program_info(const char *info)
64 {
65         WARNING(_("Not implemented"));
66 }
67
68 /**
69  * garglk_set_story_name:
70  * @name: Name of the story that the Glk program is currently interpreting.
71  *
72  * If the Glk program running is an interactive fiction interpreter, then this
73  * function can be used to let the library know the name of the story currently
74  * loaded in the interpreter, in case it wants to display this information
75  * anywhere &mdash; for example, in the title bar of a window. A typical use of
76  * this function would be:
77  * |[ garglk_set_story_name("Lighan Ses Lion, el Zarf"); ]|
78  *
79  * <warning><para>This function is not currently implemented.</para></warning>
80  */
81 void 
82 garglk_set_story_name(const char *name)
83 {
84         WARNING(_("Not implemented"));
85 }
86
87 /**
88  * garglk_set_line_terminators:
89  * @win: A window.
90  * @keycodes: An array of <code>keycode_</code> constants.
91  * @numkeycodes: The length of @keycodes.
92  *
93  * Amends the current line input request of @win to include terminating key
94  * codes. Any of the specified key codes will terminate the line input request 
95  * (without printing a newline). 
96  *
97  * Usually, in the event structure returned from a line input request, @val2 is
98  * zero, but if garglk_set_line_terminators() has been called during that input
99  * request, @val2 will be filled in with the key code that terminated the input
100  * request.
101  *
102  * This function only applies to one input request; any subsequent line input
103  * requests on that window are treated normally.
104  *
105  * If @numkeycodes is zero, then any previous call to 
106  * garglk_set_line_terminators() is cancelled and the input request is treated
107  * normally.
108  *
109  * <warning><para>This function is not currently implemented.</para></warning>
110  */
111 void 
112 garglk_set_line_terminators(winid_t win, const glui32 *keycodes, glui32 numkeycodes)
113 {
114         VALID_WINDOW(win, return);
115         g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
116         
117         if(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE) {
118                 ILLEGAL(_("Tried to set the line terminators on a window without a line input request."));
119                 return;
120         }
121
122         WARNING(_("Not implemented"));
123 }
124
125 /**
126  * garglk_unput_string:
127  * @str: a null-terminated string.
128  *
129  * Removes @str from the end of the current stream, if indeed it is there. The
130  * stream's write count is decreased accordingly, and the stream's echo stream
131  * is also modified, if it has one.
132  *
133  * <warning><para>This function is not currently implemented.</para></warning>
134  */
135 void 
136 garglk_unput_string(char *str)
137 {
138         ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
139         g_return_if_fail(glk_data->current_stream != NULL);
140
141         WARNING(_("Not implemented"));
142 }
143
144 /**
145  * garglk_unput_string_uni:
146  * @str: a zero-terminated array of Unicode code points.
147  *
148  * Like garglk_unput_string(), but for Unicode streams.
149  *
150  * <warning><para>This function is not currently implemented.</para></warning>
151  */
152 void 
153 garglk_unput_string_uni(glui32 *str)
154 {
155         ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
156         g_return_if_fail(glk_data->current_stream != NULL);
157         
158         WARNING(_("Not implemented"));
159 }
160
161 /**
162  * garglk_set_zcolors:
163  * @fg: one of the <code>zcolor_</code> constants.
164  * @bg: one of the <code>zcolor_</code> constants.
165  *
166  * Glk works with styles, not specific colors. This is not quite compatible with
167  * the Z-machine, so this Glk extension implements Z-machine style colors.
168  *
169  * This function changes the foreground color of the current stream to @fg and 
170  * the background color to @bg.
171  *
172  * <warning><para>This function is not currently implemented.</para></warning>
173  */
174 void 
175 garglk_set_zcolors(glui32 fg, glui32 bg)
176 {
177         ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
178         g_return_if_fail(glk_data->current_stream != NULL);
179         g_return_if_fail(glk_data->current_stream->window != NULL);
180         
181         WARNING(_("Not implemented"));
182 }
183
184 static void
185 apply_reverse_color(GtkTextTag *tag, gpointer data)
186 {
187         g_object_set_data( G_OBJECT(tag), "reverse_color", data );
188 }
189
190 /**
191  * garglk_set_reversevideo:
192  * @reverse: nonzero for reverse colors, zero for normal colors.
193  *
194  * If @reverse is not zero, uses the foreground color of the current stream as
195  * its background and vice versa. If @reverse is zero, changes the colors of the
196  * current stream back to normal.
197  */
198 void 
199 garglk_set_reversevideo(glui32 reverse)
200 {
201         ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
202         g_return_if_fail(glk_data->current_stream != NULL);
203         g_return_if_fail(glk_data->current_stream->window != NULL);
204
205         GtkTextTagTable *tags = gtk_text_buffer_get_tag_table( GTK_TEXT_BUFFER(glk_data->current_stream->window->widget) );
206         gtk_text_tag_table_foreach( tags, apply_reverse_color, GINT_TO_POINTER(reverse) );
207 }