5 #include <libchimara/glk.h>
6 #include <libchimara/garglk.h>
18 char stringbuffer[128];
21 /* Define some custom styles */
22 glk_stylehint_set(wintype_AllTypes, style_User1, stylehint_TextColor, 0x00FF0000);
24 mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
28 statuswin = glk_window_open(mainwin, winmethod_Above | winmethod_Fixed, 3, wintype_TextGrid, 1);
30 glk_set_window(mainwin);
32 char *buffer = calloc(256, sizeof(char));
35 glk_put_string("Welcome to the style test\n");
36 glk_request_line_event(mainwin, buffer, 255, 0);
37 while(strncmp(buffer, "quit", 4))
40 if(ev.type == evtype_LineInput)
42 if( !strncmp(buffer, "help", 4) ) {
45 else if( !strncmp(buffer, "style", 4) ) {
48 else if( !strncmp(buffer, "link", 4) ) {
51 else if( !strncmp(buffer, "mouse", 4) ) {
55 glk_put_string("Huh?\n");
57 glk_request_line_event(mainwin, buffer, 255, 0);
59 else if(ev.type == evtype_Hyperlink)
61 glk_cancel_line_event(mainwin, NULL);
62 snprintf(stringbuffer, 128, "Link %d was clicked\n", ev.val1);
63 glk_put_string(stringbuffer);
64 glk_request_line_event(mainwin, buffer, 255, 0);
66 else if(ev.type == evtype_MouseInput)
68 glk_cancel_line_event(mainwin, NULL);
69 snprintf(stringbuffer, 128, "Mouse click: x=%d, y=%d\n", ev.val1, ev.val2);
70 glk_put_string(stringbuffer);
71 glk_request_line_event(mainwin, buffer, 255, 0);
75 glk_cancel_line_event(mainwin, NULL);
76 glk_window_clear(mainwin);
82 glk_set_style(style_Normal);
83 glk_put_string("Normal\n");
85 glk_set_style(style_Emphasized);
86 glk_put_string("Emphasized\n");
88 glk_set_style(style_Preformatted);
89 glk_put_string("Preformatted\n");
91 glk_set_style(style_Header);
92 glk_put_string("Header\n");
94 glk_set_style(style_Subheader);
95 glk_put_string("Subheader\n");
97 glk_set_style(style_Alert);
98 glk_put_string("Alert\n");
100 glk_set_style(style_Note);
101 glk_put_string("Note\n");
103 glk_set_style(style_BlockQuote);
104 glk_put_string("BlockQuote\n");
106 glk_set_style(style_Input);
107 glk_put_string("Input\n");
109 glk_set_style(style_User1);
110 glk_put_string("User1\n");
112 glk_set_style(style_User2);
113 glk_put_string("User2\n");
115 glk_set_style(style_Header);
116 garglk_set_zcolors(0xFF0000, 0x00FFFF);
117 glk_put_string("Zcolor test\n");
119 glk_set_style(style_Normal);
120 garglk_set_zcolors(0x000000, 0xFFFFFF);
125 glk_set_window(mainwin);
126 glk_set_hyperlink(1);
127 glk_put_string("This is link 1\n");
128 glk_set_hyperlink(2);
129 glk_put_string("This is link 2\n");
130 glk_set_hyperlink(0);
132 glk_set_window(statuswin);
133 glk_set_hyperlink(3);
134 glk_window_move_cursor(statuswin, 0, 0);
135 glk_put_string("This is link 3\n");
136 glk_set_hyperlink(4);
137 glk_window_move_cursor(statuswin, 0, 1);
138 glk_put_string("This is link 4\n");
139 glk_set_hyperlink(0);
141 glk_request_hyperlink_event(mainwin);
142 glk_request_hyperlink_event(statuswin);
144 glk_set_window(mainwin);
149 glk_set_window(statuswin);
150 glk_window_move_cursor(statuswin, 0, 0);
151 glk_put_string("Click me......\n");
152 glk_request_mouse_event(statuswin);
153 glk_set_window(mainwin);
158 glk_put_string("The following commands are supported:\n - help (this help text)\n - style (perform style test)\n - link (perform hyperlink test)\n - mouse (perform mouse test)\n - quit (quit the program)\n");