4 static winid_t mainwin = NULL;
8 fprintf(stderr, "I'm the interrupt handler!\n");
13 /* Open the main window. */
14 mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
16 /* It's possible that the main window failed to open. There's
17 nothing we can do without it, so exit. */
24 for(i = 0; i < 256; i++)
25 buffer[i] = (char)glk_char_to_upper(i);
27 frefid_t f = glk_fileref_create_temp(fileusage_BinaryMode, 0);
31 strid_t s = glk_stream_open_file(f,
32 filemode_ReadWrite, 0);
33 glk_stream_set_current(s);
36 glk_put_string("Philip en Marijn zijn vet goed.\n");
37 glk_put_buffer(buffer, 256);
39 glk_stream_set_position(s, 0, seekmode_Start);
40 glk_set_window(mainwin);
41 glk_put_char( glk_get_char_stream(s) );
43 g_printerr("Line read: %d\n", glk_get_line_stream(s, buffer, 256));
44 glk_put_string(buffer);
45 int count = glk_get_buffer_stream(s, buffer, 256);
46 g_printerr("Buffer read: %d\n", count);
47 glk_put_buffer(buffer, count);
49 stream_result_t result;
50 glk_stream_close(s, &result);
52 g_printerr("Read count: %d\nWrite count: %d\n", result.readcount,
54 glk_fileref_destroy(f);
58 glk_set_window(mainwin);
60 glk_set_interrupt_handler(&sayit);
65 glk_put_string("prompt> ");
66 glk_request_line_event(mainwin, buffer, 256, 0);
70 printf("Received event:\n");
71 printf("Type: %d\n", ev.type);
72 printf("Win: %d\n", glk_window_get_rock(ev.win));
73 printf("Var1: %d\n", ev.val1);
74 printf("Var2: %d\n", ev.val2);