1 #include <glib/gi18n.h>
2 #include <libchimara/glk.h>
3 #include "chimara-glk-private.h"
7 extern GPrivate *glk_data_key;
10 * garglk_fileref_get_name:
11 * @fref: A file reference.
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
17 * Returns: a string in filename encoding.
20 garglk_fileref_get_name(frefid_t fref)
22 VALID_FILEREF(fref, return NULL);
23 return fref->filename;
27 * garglk_set_program_name:
28 * @name: Name of the Glk program that is running.
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 * — for example, in the title bar of a window. A typical use of this
34 * |[ garglk_set_program_name("SuperGlkFrotz 0.1"); ]|
37 garglk_set_program_name(const char *name)
39 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
40 glk_data->program_name = g_strdup(name);
41 g_object_notify(G_OBJECT(glk_data->self), "program-name");
45 * garglk_set_program_info:
46 * @info: Information about the Glk program that is running.
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 — for example, in an About box. A typical use of
51 * this function would be:
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");
61 garglk_set_program_info(const char *info)
63 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
64 glk_data->program_info = g_strdup(info);
65 g_object_notify(G_OBJECT(glk_data->self), "program-info");
69 * garglk_set_story_name:
70 * @name: Name of the story that the Glk program is currently interpreting.
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 — 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"); ]|
80 garglk_set_story_name(const char *name)
82 g_printerr("garglk_set_story_name(\"%s\");\n", name);
83 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
84 glk_data->story_name = g_strdup(name);
85 g_object_notify(G_OBJECT(glk_data->self), "story-name");
89 * garglk_set_line_terminators:
91 * @keycodes: An array of <code>keycode_</code> constants.
92 * @numkeycodes: The length of @keycodes.
94 * Amends the current line input request of @win to include terminating key
95 * codes. Any of the specified key codes will terminate the line input request
96 * (without printing a newline).
98 * Usually, in the event structure returned from a line input request, @val2 is
99 * zero, but if garglk_set_line_terminators() has been called during that input
100 * request, @val2 will be filled in with the key code that terminated the input
103 * This function only applies to one input request; any subsequent line input
104 * requests on that window are treated normally.
106 * If @numkeycodes is zero, then any previous call to
107 * garglk_set_line_terminators() is cancelled and the input request is treated
110 * <warning><para>This function is not currently implemented.</para></warning>
113 garglk_set_line_terminators(winid_t win, const glui32 *keycodes, glui32 numkeycodes)
115 VALID_WINDOW(win, return);
116 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
118 if(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE) {
119 ILLEGAL(_("Tried to set the line terminators on a window without a line input request."));
123 WARNING(_("Not implemented"));
127 * garglk_unput_string:
128 * @str: a null-terminated string.
130 * Removes @str from the end of the current stream, if indeed it is there. The
131 * stream's write count is decreased accordingly, and the stream's echo stream
132 * is also modified, if it has one.
134 * <warning><para>This function is not currently implemented.</para></warning>
137 garglk_unput_string(char *str)
139 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
140 g_return_if_fail(glk_data->current_stream != NULL);
142 WARNING(_("Not implemented"));
146 * garglk_unput_string_uni:
147 * @str: a zero-terminated array of Unicode code points.
149 * Like garglk_unput_string(), but for Unicode streams.
151 * <warning><para>This function is not currently implemented.</para></warning>
154 garglk_unput_string_uni(glui32 *str)
156 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
157 g_return_if_fail(glk_data->current_stream != NULL);
159 WARNING(_("Not implemented"));
163 * garglk_set_zcolors:
164 * @fg: one of the <code>zcolor_</code> constants.
165 * @bg: one of the <code>zcolor_</code> constants.
167 * Glk works with styles, not specific colors. This is not quite compatible with
168 * the Z-machine, so this Glk extension implements Z-machine style colors.
170 * This function changes the foreground color of the current stream to @fg and
171 * the background color to @bg.
173 * <warning><para>This function is not currently implemented.</para></warning>
176 garglk_set_zcolors(glui32 fg, glui32 bg)
178 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
179 g_return_if_fail(glk_data->current_stream != NULL);
180 g_return_if_fail(glk_data->current_stream->window != NULL);
182 WARNING(_("Not implemented"));
186 apply_reverse_color(GtkTextTag *tag, gpointer data)
188 g_object_set_data( G_OBJECT(tag), "reverse_color", data );
192 * garglk_set_reversevideo:
193 * @reverse: nonzero for reverse colors, zero for normal colors.
195 * If @reverse is not zero, uses the foreground color of the current stream as
196 * its background and vice versa. If @reverse is zero, changes the colors of the
197 * current stream back to normal.
200 garglk_set_reversevideo(glui32 reverse)
202 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
203 g_return_if_fail(glk_data->current_stream != NULL);
204 g_return_if_fail(glk_data->current_stream->window != NULL);
206 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(glk_data->current_stream->window->widget) );
207 GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
208 gtk_text_tag_table_foreach( tags, apply_reverse_color, GINT_TO_POINTER(reverse) );