5 #include <libchimara/glk.h>
6 #include <libchimara/garglk.h>
11 winid_t mainwin = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
15 glk_set_window(mainwin);
16 glui32 width, height, x, y;
17 glk_window_get_size(mainwin, &width, &height);
18 if(height < 4 || width < 22)
20 glk_put_string("Window not big enough");
24 char *buffer = calloc(256, sizeof(char));
27 garglk_set_reversevideo(1);
28 for(y=0; y<height; y++) {
29 snprintf(buffer, 256, "%02d\n", y);
30 glk_put_string(buffer);
32 garglk_set_reversevideo(0);
34 glk_set_style(style_Emphasized);
35 for(y=0; y<height; y++) {
36 snprintf(buffer, 256, "%02d", y);
37 glk_window_move_cursor(mainwin, (y+1)*width-2, 0);
38 glk_put_string(buffer);
40 glk_set_style(style_Normal);
42 glk_window_move_cursor(mainwin, 2, 0);
44 glk_window_move_cursor(mainwin, width-3, 0);
46 glk_window_move_cursor(mainwin, 2, height-1);
48 glk_window_move_cursor(mainwin, width-3, height-1);
54 glk_window_move_cursor(mainwin, x, y - 1);
55 glk_put_string("Enter text, or 'quit'");
56 glk_window_move_cursor(mainwin, x, y);
57 glk_request_line_event(mainwin, buffer, 21, 0);
58 while(strncmp(buffer, "quit", 4))
61 if(ev.type == evtype_LineInput)
63 glk_window_move_cursor(mainwin, x, y + 1);
65 glk_window_move_cursor(mainwin, x, y + 1);
66 glk_put_buffer(buffer, ev.val1);
67 glk_window_move_cursor(mainwin, x, y);
68 glk_request_line_event(mainwin, buffer, 21, 0);
71 glk_cancel_line_event(mainwin, NULL);
72 glk_window_clear(mainwin);