3 /* Global current stream */
4 static strid_t current_stream = NULL;
5 /* List of streams currently in existence */
6 static GList *stream_list = NULL;
8 /* Internal function: create a window stream to go with window. */
10 window_stream_new(winid_t window)
12 /* Create stream and connect it to window */
13 strid_t s = g_new0(struct glk_stream_struct, 1);
14 s->file_mode = filemode_Write;
15 s->stream_type = STREAM_TYPE_WINDOW;
17 /* Add it to the global stream list */
18 stream_list = g_list_prepend(stream_list, s);
19 s->stream_list = stream_list;
25 * glk_stream_set_current:
26 * @str: An output stream, or NULL.
28 * Sets the current stream to @str, or to nothing if @str is #NULL.
31 glk_stream_set_current(strid_t str)
33 if(str != NULL && str->file_mode != filemode_Write)
35 g_warning("glk_stream_set_current: "
36 "Cannot set current stream to non output stream");
45 * @s: A null-terminated string in Latin-1 encoding.
47 * Prints @s to the current stream.
50 glk_put_string(char *s)
55 switch(current_stream->stream_type)
57 case STREAM_TYPE_WINDOW:
58 utf8 = g_convert(s, -1, "UTF-8", "ISO-8859-1", NULL, NULL, &error);
62 g_warning("glk_put_string: "
63 "Error during latin1->utf8 conversion: %s",
69 GtkTextBuffer *buffer = gtk_text_view_get_buffer(
70 GTK_TEXT_VIEW(current_stream->window->widget) );
73 gtk_text_buffer_get_end_iter(buffer, &iter);
75 gtk_text_buffer_insert(buffer, &iter, utf8, -1);
80 g_warning("glk_put_string: "
81 "Writing to this kind of stream unsupported.");