- Timestamp:
- Aug 2, 2009, 1:09:42 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca_conio.c
r3602 r3607 37 37 static int unget_ch = -1; 38 38 static int kbhit_ch = -1; 39 static char pass_buffer[BUFSIZ]; 40 static char cgets_buffer[BUFSIZ]; 39 static char pass_buffer[8 + 1]; 41 40 42 41 static void conio_init(void); … … 44 43 static void conio_fini(void); 45 44 46 int caca_conio_directvideo ;47 int caca_conio__wscroll ;45 int caca_conio_directvideo = 0; 46 int caca_conio__wscroll = 1; 48 47 49 48 /** \brief DOS conio.h cgets() equivalent */ 50 49 char * caca_conio_cgets(char *str) 51 50 { 52 conio_init(); 53 54 /* TODO: implement this function */ 55 cgets_buffer[0] = '\0'; 56 57 return cgets_buffer; 51 int len = ((uint8_t *)str)[0]; 52 int pos = 0; 53 54 conio_init(); 55 56 while (pos < len) 57 { 58 int ch = caca_conio_getch(); 59 if (ch == '\n' || ch == '\r') 60 break; 61 str[2 + pos] = (char)(uint8_t)ch; 62 /* FIXME: handle scrolling */ 63 caca_put_char(cv, caca_wherex(cv), caca_wherey(cv), ch); 64 caca_gotoxy(cv, caca_wherex(cv) + 1, caca_wherey(cv)); 65 pos++; 66 } 67 68 str[2 + pos] = '\0'; 69 str[1] = (char)(uint8_t)pos; 70 71 conio_refresh(); 72 73 return str + 2; 58 74 } 59 75 … … 75 91 conio_init(); 76 92 93 /* FIXME: must work within the currently active text window */ 77 94 caca_clear_canvas(cv); 78 95 caca_gotoxy(cv, 0, 0); … … 89 106 conio_init(); 90 107 108 /* FIXME: handle scrolling */ 91 109 va_start(args, format); 92 110 ret = caca_vprintf(cv, caca_wherex(cv), caca_wherey(cv), format, args); … … 103 121 int caca_conio_cputs(const char *str) 104 122 { 105 conio_init(); 106 107 /* TODO: implement this function */ 108 109 return 0; 110 } 111 112 /** \brief DOS conio.h cscanf() equivalent */ 123 int ch; 124 125 conio_init(); 126 127 while ((ch = (uint8_t)*str++)) 128 { 129 /* FIXME: handle windows, scrolling, '\n' and '\r' */ 130 caca_put_char(cv, caca_wherex(cv), caca_wherey(cv), ch); 131 caca_gotoxy(cv, caca_wherex(cv) + 1, caca_wherey(cv)); 132 } 133 134 conio_refresh(); 135 136 return ch; 137 } 138 139 /** \brief DOS stdio.h cscanf() equivalent */ 113 140 int caca_conio_cscanf(char *format, ...) 114 141 { … … 198 225 char * caca_conio_getpass(const char *prompt) 199 226 { 200 conio_init(); 201 202 /* TODO: implement this function */ 203 pass_buffer[0] = '\0'; 227 int pos = 0; 228 229 conio_init(); 230 231 while (pos < 8) 232 { 233 int ch = caca_conio_getch(); 234 if (ch == '\n' || ch == '\r') 235 break; 236 pass_buffer[pos] = (char)(uint8_t)ch; 237 pos++; 238 } 239 240 pass_buffer[pos] = '\0'; 241 242 conio_refresh(); 204 243 205 244 return pass_buffer; … … 296 335 int destleft, int desttop) 297 336 { 298 conio_init(); 299 300 /* TODO: implement this function */ 301 302 return 0; 337 caca_canvas_t *tmp; 338 339 conio_init(); 340 341 if (left < 1 || top < 1 || left > right || top > bottom 342 || destleft < 1 || desttop < 1 || destleft > right 343 || desttop > bottom || right > caca_get_canvas_width(cv) 344 || bottom > caca_get_canvas_width(cv)) 345 return 0; 346 347 tmp = caca_create_canvas(right - left + 1, bottom - top + 1); 348 caca_blit(tmp, 1 - left, 1 - top, cv, NULL); 349 caca_blit(cv, destleft - 1, desttop - 1, tmp, NULL); 350 351 conio_refresh(); 352 353 return 1; 303 354 } 304 355 … … 343 394 conio_init(); 344 395 345 /* TODO: implement this function */ 346 347 return 0; 396 /* FIXME: handle scrolling, windows */ 397 caca_put_char(cv, caca_wherex(cv), caca_wherey(cv), ch); 398 caca_gotoxy(cv, caca_wherex(cv) + 1, caca_wherey(cv)); 399 400 return ch; 348 401 } 349 402 … … 363 416 conio_init(); 364 417 365 /* TODO: implement this function */ 418 switch(cur_t) 419 { 420 case CACA_CONIO__NOCURSOR: 421 caca_set_cursor(dp, 0); 422 break; 423 case CACA_CONIO__SOLIDCURSOR: 424 case CACA_CONIO__NORMALCURSOR: 425 caca_set_cursor(dp, 1); 426 break; 427 } 428 429 conio_refresh(); 366 430 } 367 431
Note: See TracChangeset
for help on using the changeset viewer.