- Timestamp:
- 09/17/08 18:32:17 (2 months ago)
- Files:
-
- 1 modified
-
trunk/payloads/libpayload/curses/tinycurses.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/payloads/libpayload/curses/tinycurses.c
r3578 r3579 4 4 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de> 5 5 * Copyright (C) 2008 Ulf Jordan <jordan@chalmers.se> 6 * Copyright (C) 2008 coresystems GmbH 6 7 * 7 8 * Redistribution and use in source and binary forms, with or without … … 194 195 /* D */ int clearok(WINDOW *win, bool flag) { win->_clear = flag; return OK; } 195 196 // int color_content(short color, short *r, short *g, short *b) {} 196 // int curs_set(int) {} 197 int curs_set(int on) 198 { 199 if (curses_flags & F_ENABLE_SERIAL) { 200 // TODO 201 } 202 203 if (curses_flags & F_ENABLE_CONSOLE) { 204 video_console_cursor_enable(on); 205 } 206 207 return OK; 208 } 197 209 // int def_prog_mode(void) {} 198 210 // int def_shell_mode(void) {} … … 253 265 return win; 254 266 } 255 int doupdate(void) { /* TODO */ return( *(int *)0); }267 int doupdate(void) { /* TODO */ return(0); } 256 268 // WINDOW * dupwin (WINDOW *) {} 257 269 /* D */ int echo(void) { SP->_echo = TRUE; return OK; } … … 282 294 WINDOW *initscr(void) 283 295 { 284 int x, y,i;296 int i; 285 297 286 298 // newterm(name, stdout, stdin); … … 306 318 // TODO: curscr, newscr? 307 319 308 for (y = 0; y <= stdscr->_maxy; y++) { 309 for (x = 0; x <= stdscr->_maxx; x++) { 310 stdscr->_line[y].text[x].chars[0] = ' '; 311 stdscr->_line[y].text[x].attr = A_NORMAL; 312 } 313 } 320 werase(stdscr); 314 321 315 322 return stdscr; … … 474 481 } 475 482 // int vwscanw (WINDOW *, NCURSES_CONST char *,va_list) {} 476 // int waddch (WINDOW *, const chtype) {}477 483 int waddch(WINDOW *win, const chtype ch) 478 484 { … … 481 487 // SetChar2(wch, ch); 482 488 489 if (win->_line[win->_cury].firstchar == _NOCHANGE || 490 win->_line[win->_cury].firstchar > win->_curx) 491 win->_line[win->_cury].firstchar = win->_curx; 492 483 493 win->_line[win->_cury].text[win->_curx].chars[0] = 484 494 ((ch) & (chtype)A_CHARTEXT); … … 487 497 win->_line[win->_cury].text[win->_curx].attr |= 488 498 ((ch) & (chtype)A_ATTRIBUTES); 499 500 if (win->_line[win->_cury].lastchar == _NOCHANGE || 501 win->_line[win->_cury].lastchar < win->_curx) 502 win->_line[win->_cury].lastchar = win->_curx; 503 489 504 win->_curx++; // FIXME 490 505 … … 507 522 if (n < 0) 508 523 n = strlen(astr); 524 525 if (win->_line[win->_cury].firstchar == _NOCHANGE || 526 win->_line[win->_cury].firstchar > win->_curx) 527 win->_line[win->_cury].firstchar = win->_curx; 509 528 510 529 while ((n-- > 0) && (*str != '\0')) { … … 522 541 // } 523 542 } 543 544 if (win->_line[win->_cury].lastchar == _NOCHANGE || 545 win->_line[win->_cury].lastchar < win->_curx) 546 win->_line[win->_cury].lastchar = win->_curx; 547 524 548 return code; 525 549 } … … 604 628 win->_line[y].text[x].attr = WINDOW_ATTRS(win); 605 629 } 630 // Should we check instead? 631 win->_line[y].firstchar = 0; 632 win->_line[y].lastchar = win->_maxx; 606 633 } 607 634 return OK; … … 682 709 for (y = 0; y <= win->_maxy; y++) { 683 710 711 if (win->_line[y].firstchar == _NOCHANGE) 712 continue; 713 684 714 /* Position the serial cursor */ 685 715 686 716 if (curses_flags & F_ENABLE_SERIAL) 687 serial_set_cursor(win->_begy + y, win->_begx); 688 689 for (x = 0; x <= win->_maxx; x++) { 717 serial_set_cursor(win->_begy + y, win->_begx + 718 win->_line[y].firstchar); 719 720 for (x = win->_line[y].firstchar; x <= win->_line[y].lastchar; x++) { 690 721 attr_t attr = win->_line[y].text[x].attr; 691 722 … … 735 766 736 767 serial_putchar(ch); 768 737 769 } 738 770 … … 769 801 } 770 802 } 771 } 803 win->_line[y].firstchar = _NOCHANGE; 804 win->_line[y].lastchar = _NOCHANGE; 805 } 806 807 if (curses_flags & F_ENABLE_SERIAL) 808 serial_set_cursor(win->_begy + win->_cury, win->_begx + win->_curx); 809 810 if (curses_flags & F_ENABLE_CONSOLE) 811 video_console_set_cursor(win->_begx + win->_curx, win->_begy + win->_cury); 772 812 773 813 return OK; … … 814 854 int wscrl(WINDOW *win, int n) 815 855 { 856 int x, y; 857 816 858 if (!win->_scroll) 817 859 return ERR; 818 860 819 if (n != 0) { 820 int x, y; 821 822 for (y = 0; y <= (win->_maxy - n); y++) { 823 for (x = 0; x <= win->_maxx; x++) { 861 if (n == 0) 862 return OK; 863 864 for (y = 0; y <= (win->_maxy - n); y++) { 865 win->_line[y].firstchar = win->_line[y + n].firstchar; 866 win->_line[y].lastchar = win->_line[y + n].lastchar; 867 for (x = 0; x <= win->_maxx; x++) { 868 if ((win->_line[y].text[x].chars[0] != win->_line[y + n].text[x].chars[0]) || 869 (win->_line[y].text[x].attr != win->_line[y + n].text[x].attr)) { 870 if (win->_line[y].firstchar == _NOCHANGE) 871 win->_line[y].firstchar = x; 872 873 win->_line[y].lastchar = x; 874 824 875 win->_line[y].text[x].chars[0] = win->_line[y + n].text[x].chars[0]; 825 876 win->_line[y].text[x].attr = win->_line[y + n].text[x].attr; 826 877 } 827 878 } 828 829 for (y = (win->_maxy+1 - n); y <= win->_maxy; y++) { 830 for (x = 0; x <= win->_maxx; x++) { 879 } 880 881 for (y = (win->_maxy+1 - n); y <= win->_maxy; y++) { 882 for (x = 0; x <= win->_maxx; x++) { 883 if ((win->_line[y].text[x].chars[0] != ' ') || 884 (win->_line[y].text[x].attr != A_NORMAL)) { 885 if (win->_line[y].firstchar == _NOCHANGE) 886 win->_line[y].firstchar = x; 887 888 win->_line[y].lastchar = x; 889 831 890 win->_line[y].text[x].chars[0] = ' '; 832 891 win->_line[y].text[x].attr = A_NORMAL; 833 892 } 834 893 } 835 836 // _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd); 837 // _nc_synchook(win); 838 } 894 } 895 896 // _nc_scroll_window(win, n, win->_regtop, win->_regbottom, win->_nc_bkgd); 897 // _nc_synchook(win); 898 839 899 return OK; 840 900 }
