5 #include <libchimara/glk.h>
10 winid_t mainwin = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
14 glk_set_window(mainwin);
15 glk_put_string("Philip en Marijn zijn vet goed.\n");
16 glk_put_string("A veeeeeeeeeeeeeeeeeeeeeeeeeeeery looooooooooooooooooooooooong striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing.\n");
19 for(count = 0; count < 30; count++)
20 glk_put_string("I want to write past the end of this text buffer! ");
23 glk_window_get_size(mainwin, &width, &height);
24 fprintf(stderr, "\nWidth: %d\nHeight: %d\nPress a key in the window, not in the terminal.\n", width, height);
25 glk_request_char_event(mainwin);
28 if(ev.type == evtype_CharInput)
32 glk_window_move_cursor(mainwin, 15, 15);
33 glk_put_string(". . ");
34 glk_window_move_cursor(mainwin, 15, 16);
35 glk_put_string(" . .");
36 glk_window_move_cursor(mainwin, 15, 17);
37 glk_put_string(". . ");
38 glk_window_move_cursor(mainwin, 15, 18);
39 glk_put_string(" . .");
40 fprintf(stderr, "Cursor location test.\nPress another key.\n");
41 glk_request_char_event(mainwin);
44 if(ev.type == evtype_CharInput)
48 char *buffer = calloc(256, sizeof(char));
51 fprintf(stderr, "Line input field until end of line\n");
52 glk_window_move_cursor(mainwin, 10, 18);
53 glk_request_line_event(mainwin, buffer, 256, 0);
56 if(ev.type == evtype_LineInput)
60 fprintf(stderr, "Another line input field until end of line\n");
61 glk_window_move_cursor(mainwin, 10, 20);
62 glk_request_line_event(mainwin, buffer, 256, 0);
65 if(ev.type == evtype_LineInput)
69 fprintf(stderr, "Now edit your previous line input\n");
70 glk_window_move_cursor(mainwin, 10, 22);
71 glk_request_line_event(mainwin, buffer, 256, strlen(buffer));
74 if(ev.type == evtype_LineInput)
78 char *text = calloc(ev.val1 + 1, sizeof(char));
80 strncpy(text, buffer, ev.val1);
82 fprintf(stderr, "Your string was: '%s'.\nPress another key to clear the window and exit.\n", text);
84 glk_request_char_event(mainwin);
87 if(ev.type == evtype_CharInput)
91 glk_window_clear(mainwin);