3 static winid_t mainwin = NULL;
7 fprintf(stderr, "I'm the interrupt handler!\n");
12 /* Open the main window. */
13 mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
15 /* It's possible that the main window failed to open. There's
16 nothing we can do without it, so exit. */
23 for(i = 0; i < 256; i++)
24 buffer[i] = (char)glk_char_to_upper(i);
26 frefid_t f = glk_fileref_create_temp(fileusage_BinaryMode, 0);
30 strid_t s = glk_stream_open_file(f,
31 filemode_ReadWrite, 0);
32 glk_stream_set_current(s);
35 glk_put_string("Philip en Marijn zijn vet goed.\n");
36 glk_put_buffer(buffer, 256);
38 glk_stream_set_position(s, 0, seekmode_Start);
39 glk_set_window(mainwin);
40 glk_put_char( glk_get_char_stream(s) );
42 g_printerr("Line read: %d\n", glk_get_line_stream(s, buffer, 256));
43 glk_put_string(buffer);
44 int count = glk_get_buffer_stream(s, buffer, 256);
45 g_printerr("Buffer read: %d\n", count);
46 glk_put_buffer(buffer, count);
48 stream_result_t result;
49 glk_stream_close(s, &result);
51 g_printerr("Read count: %d\nWrite count: %d\n", result.readcount,
53 glk_fileref_destroy(f);
57 glk_set_window(mainwin);
59 glk_set_interrupt_handler(&sayit);
64 glk_put_string("prompt> ");
65 glk_request_line_event(mainwin, buffer, 256, 0);
69 printf("Received event:\n");
70 printf("Type: %d\n", ev.type);
71 printf("Win: %d\n", glk_window_get_rock(ev.win));
72 printf("Var1: %d\n", ev.val1);
73 printf("Var2: %d\n", ev.val2);