Changeset 2821 for libcaca/trunk/examples/event.c
- Timestamp:
- Sep 27, 2008, 3:12:46 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/examples/event.c
r2299 r2821 21 21 #endif 22 22 23 #include "cucul.h"24 23 #include "caca.h" 25 24 26 static c ucul_canvas_t *cv;25 static caca_canvas_t *cv; 27 26 static caca_display_t *dp; 28 27 … … 34 33 int i, h, quit; 35 34 36 cv = c ucul_create_canvas(80, 24);35 cv = caca_create_canvas(80, 24); 37 36 if(cv == NULL) 38 37 { … … 48 47 } 49 48 50 h = c ucul_get_canvas_height(cv) - 1;49 h = caca_get_canvas_height(cv) - 1; 51 50 52 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);53 c ucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, ' ');51 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); 52 caca_draw_line(cv, 0, 0, caca_get_canvas_width(cv) - 1, 0, ' '); 54 53 55 c ucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, ' ');56 c ucul_put_str(cv, 0, h, "type \"quit\" to exit");54 caca_draw_line(cv, 0, h, caca_get_canvas_width(cv) - 1, h, ' '); 55 caca_put_str(cv, 0, h, "type \"quit\" to exit"); 57 56 58 57 caca_refresh_display(dp); … … 92 91 while(ret); 93 92 94 c ucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);95 c ucul_clear_canvas(cv);93 caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK); 94 caca_clear_canvas(cv); 96 95 97 96 /* Print current event */ 98 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLUE);99 c ucul_draw_line(cv, 0, 0, cucul_get_canvas_width(cv) - 1, 0, ' ');97 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); 98 caca_draw_line(cv, 0, 0, caca_get_canvas_width(cv) - 1, 0, ' '); 100 99 print_event(0, 0, events); 101 100 102 c ucul_draw_line(cv, 0, h, cucul_get_canvas_width(cv) - 1, h, ' ');103 c ucul_printf(cv, 0, h, "type \"quit\" to exit: %s", quit_string[quit]);101 caca_draw_line(cv, 0, h, caca_get_canvas_width(cv) - 1, h, ' '); 102 caca_printf(cv, 0, h, "type \"quit\" to exit: %s", quit_string[quit]); 104 103 105 104 /* Print previous events */ 106 c ucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);105 caca_set_color_ansi(cv, CACA_WHITE, CACA_BLACK); 107 106 for(i = 1; i < h && caca_get_event_type(&events[i]); i++) 108 107 print_event(0, i, events + i); … … 114 113 free(events); 115 114 caca_free_display(dp); 116 c ucul_free_canvas(cv);115 caca_free_canvas(cv); 117 116 118 117 return 0; … … 126 125 { 127 126 case CACA_EVENT_NONE: 128 c ucul_printf(cv, x, y, "CACA_EVENT_NONE");127 caca_printf(cv, x, y, "CACA_EVENT_NONE"); 129 128 break; 130 129 case CACA_EVENT_KEY_PRESS: 131 130 character = caca_get_event_key_ch(ev); 132 c ucul_printf(cv, x, y, "CACA_EVENT_KEY_PRESS 0x%02x (%c)", character,131 caca_printf(cv, x, y, "CACA_EVENT_KEY_PRESS 0x%02x (%c)", character, 133 132 (character > 0x1f && character < 0x80) ? character : '?'); 134 133 break; 135 134 case CACA_EVENT_KEY_RELEASE: 136 135 character = caca_get_event_key_ch(ev); 137 c ucul_printf(cv, x, y, "CACA_EVENT_KEY_RELEASE 0x%02x (%c)", character,136 caca_printf(cv, x, y, "CACA_EVENT_KEY_RELEASE 0x%02x (%c)", character, 138 137 (character > 0x1f && character < 0x80) ? character : '?'); 139 138 break; 140 139 case CACA_EVENT_MOUSE_MOTION: 141 c ucul_printf(cv, x, y, "CACA_EVENT_MOUSE_MOTION %u %u",140 caca_printf(cv, x, y, "CACA_EVENT_MOUSE_MOTION %u %u", 142 141 caca_get_event_mouse_x(ev), caca_get_event_mouse_y(ev)); 143 142 break; 144 143 case CACA_EVENT_MOUSE_PRESS: 145 c ucul_printf(cv, x, y, "CACA_EVENT_MOUSE_PRESS %u",144 caca_printf(cv, x, y, "CACA_EVENT_MOUSE_PRESS %u", 146 145 caca_get_event_mouse_button(ev)); 147 146 break; 148 147 case CACA_EVENT_MOUSE_RELEASE: 149 c ucul_printf(cv, x, y, "CACA_EVENT_MOUSE_RELEASE %u",148 caca_printf(cv, x, y, "CACA_EVENT_MOUSE_RELEASE %u", 150 149 caca_get_event_mouse_button(ev)); 151 150 break; 152 151 case CACA_EVENT_RESIZE: 153 c ucul_printf(cv, x, y, "CACA_EVENT_RESIZE %u %u",152 caca_printf(cv, x, y, "CACA_EVENT_RESIZE %u %u", 154 153 caca_get_event_resize_width(ev), 155 154 caca_get_event_resize_height(ev)); 156 155 break; 157 156 case CACA_EVENT_QUIT: 158 c ucul_printf(cv, x, y, "CACA_EVENT_QUIT");157 caca_printf(cv, x, y, "CACA_EVENT_QUIT"); 159 158 break; 160 159 default: 161 c ucul_printf(cv, x, y, "CACA_EVENT_UNKNOWN");160 caca_printf(cv, x, y, "CACA_EVENT_UNKNOWN"); 162 161 } 163 162 }
Note: See TracChangeset
for help on using the changeset viewer.