3 static winid_t mainwin = NULL;
7 /* Open the main window. */
8 mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
10 /* It's possible that the main window failed to open. There's
11 nothing we can do without it, so exit. */
18 for(i = 0; i < 256; i++)
19 buffer[i] = (char)glk_char_to_upper(i);
23 frefid_t f = glk_fileref_create_by_prompt(fileusage_BinaryMode, filemode_ReadWrite, 0);
27 strid_t s = glk_stream_open_file(f,
28 filemode_ReadWrite, 0);
29 glk_stream_set_current(s);
31 glk_put_string("Philip en Marijn zijn vet goed.\n");
32 glk_put_buffer(buffer, 256);
34 glk_stream_set_position(s, 0, seekmode_Start);
35 glk_set_window(mainwin);
36 glk_put_char( glk_get_char_stream(s) );
38 g_printerr("Line read: %d\n", glk_get_line_stream(s, buffer, 256));
39 glk_put_string(buffer);
40 int count = glk_get_buffer_stream(s, buffer, 256);
41 g_printerr("Buffer read: %d\n", count);
42 glk_put_buffer(buffer, count);
44 stream_result_t result;
45 glk_stream_close(s, &result);
47 g_printerr("Read count: %d\nWrite count: %d\n", result.readcount,
49 glk_fileref_destroy(f);
53 glk_set_window(mainwin);
55 gchar buffer[256] = "blaat";
58 glk_put_string("prompt> ");
59 glk_request_line_event(mainwin, buffer, 256, 5);
63 printf("Received event:\n");
64 printf("Type: %d\n", ev.type);
65 printf("Win: %d\n", glk_window_get_rock(ev.win));
66 printf("Var1: %d\n", ev.val1);
67 printf("Var2: %d\n", ev.val2);