void outputTest(WINDOW *win) { WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; nl(); wclear(win); mvwaddstr(win, 1, 1, "You should now have a screen in the upper " "left corner, and this text should have wrapped"); waddstr(win,"\nThis text should be down\n"); waddstr(win, "and broken into two here ^"); Continue(win); wclear(win); wattron(win, A_BOLD); mvwaddstr(win, 1, 1, "A new window will appear with this text in it"); mvwaddstr(win, 8, 1, "Press any key to continue"); wrefresh(win); wgetch(win); getbegyx(win, by, bx); if (LINES < 24 || COLS < 75) { mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a"); mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; } #ifdef A_COLOR if (has_colors()) { init_pair(3, COLOR_BLUE, COLOR_WHITE); wbkgd(win1, COLOR_PAIR(3)); } else #endif wbkgd(win1, A_NORMAL); wclear(win1); mvwaddstr(win1, 5, 1, "This text should appear; using overlay option"); copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); box(win1, ACS_VLINE, ACS_HLINE); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); wclear(win1); wattron(win1, A_BLINK); mvwaddstr(win1, 4, 1, "This blinking text should appear in only the second window"); wattroff(win1, A_BLINK); mvwin(win1, by, bx); overlay(win, win1); mvwin(win1, 14, 25); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); delwin(win1); } clear(); wclear(win); wrefresh(win); mvwaddstr(win, 6, 2, "This line shouldn't appear"); mvwaddstr(win, 4, 2, "Only half of the next line is visible"); mvwaddstr(win, 5, 2, "Only half of the next line is visible"); wmove(win, 6, 1); wclrtobot(win); wmove(win, 5, 20); wclrtoeol(win); mvwaddstr(win, 8, 2, "This line also shouldn't appear"); wmove(win, 8, 1); winsdelln(win, -1); Continue(win); wmove(win, 5, 9); ch = winch(win); wclear(win); wmove(win, 6, 2); waddstr(win, "The next char should be l: "); winsch(win, ch); Continue(win); mvwinsstr(win, 6, 2, "A1B2C3D4E5"); Continue(win); wmove(win, 5, 1); winsdelln(win, 1); mvwaddstr(win, 5, 2, "The lines below should have moved down"); Continue(win); wclear(win); wmove(win, 2, 2); wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); mvwaddstr(win, 10, 1, "Enter a string: "); wrefresh(win); echo(); wscanw(win, "%s", Buffer); printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); mvaddstr(10, 1, "Enter a string: "); scanw("%s", Buffer); wclear(win); curs_set(2); mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode"); Continue(win); wclear(win); curs_set(0); mvwaddstr(win, 1, 1, "The cursor should have disappeared"); Continue(win); wclear(win); curs_set(1); mvwaddstr(win, 1, 1, "The cursor should be normal"); Continue(win); #ifdef A_COLOR if (has_colors()) { wclear(win); mvwaddstr(win, 1, 1, "Colors should change after you press a key"); Continue(win); init_pair(1, COLOR_RED, COLOR_WHITE); wrefresh(win); } #endif werase(win); mvwaddstr(win, 1, 1, "Information About Your Terminal"); mvwaddstr(win, 3, 1, termname()); mvwaddstr(win, 4, 1, longname()); if (termattrs() & A_BLINK) mvwaddstr(win, 5, 1, "This terminal claims to support blinking."); else mvwaddstr(win, 5, 1, "This terminal does NOT support blinking."); mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); wrefresh(win); mvwinnstr(win, 7, 5, Buffer, 18); mvaddstr(LINES - 2, 10, Buffer); refresh(); Continue(win); }
static void outputTest(WINDOW *win) { WINDOW *win1; char Buffer[80]; chtype ch; int by, bx; #if !HAVE_TIGETSTR #if HAVE_TGETENT char tc_buffer[4096]; char tc_parsed[4096]; char *area_pointer = tc_parsed; tgetent(tc_buffer, getenv("TERM")); #else #define tgetstr(a,b) 0 #endif #endif /* !HAVE_TIGETSTR */ nl(); wclear(win); MvWAddStr(win, 1, 1, "You should now have a screen in the upper left corner, and this text should have wrapped"); mvwin(win, 2, 1); waddstr(win, "\nThis text should be down\n"); waddstr(win, "and broken into two here ^"); Continue(win); wclear(win); wattron(win, A_BOLD); MvWAddStr(win, 1, 1, "A new window will appear with this text in it"); MvWAddStr(win, 8, 1, "Press any key to continue"); wrefresh(win); wgetch(win); getbegyx(win, by, bx); if (LINES < 24 || COLS < 75) { MvWAddStr(win, 5, 1, "Some tests have been skipped as they require a"); MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS"); Continue(win); } else { win1 = newwin(10, 50, 14, 25); if (win1 == NULL) { endwin(); return; } #ifdef A_COLOR if (has_colors()) { init_pair(3, COLOR_BLUE, COLOR_WHITE); wbkgd(win1, (chtype) COLOR_PAIR(3)); } else wbkgd(win1, A_NORMAL); #else wbkgd(win1, A_NORMAL); #endif wclear(win1); MvWAddStr(win1, 5, 1, "This text should appear; using overlay option"); copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE); #if defined(PDCURSES) && !defined(XCURSES) box(win1, 0xb3, 0xc4); #else box(win1, ACS_VLINE, ACS_HLINE); #endif wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); wclear(win1); wattron(win1, A_BLINK); MvWAddStr(win1, 4, 1, "This blinking text should appear in only the second window"); wattroff(win1, A_BLINK); mvwin(win1, by, bx); overlay(win, win1); mvwin(win1, 14, 25); wmove(win1, 8, 26); wrefresh(win1); wgetch(win1); delwin(win1); } clear(); wclear(win); wrefresh(win); MvWAddStr(win, 6, 2, "This line shouldn't appear"); MvWAddStr(win, 4, 2, "Only half of the next line is visible"); MvWAddStr(win, 5, 2, "Only half of the next line is visible"); wmove(win, 6, 1); wclrtobot(win); wmove(win, 5, 20); wclrtoeol(win); MvWAddStr(win, 8, 2, "This line also shouldn't appear"); wmove(win, 8, 1); wdeleteln(win); Continue(win); wmove(win, 5, 9); ch = winch(win); wclear(win); wmove(win, 6, 2); waddstr(win, "The next char should be l: "); winsch(win, ch); Continue(win); #if HAVE_WINSSTR (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5"); Continue(win); #endif wmove(win, 5, 1); winsertln(win); MvWAddStr(win, 5, 2, "The lines below should have moved down"); Continue(win); wclear(win); wmove(win, 2, 2); wprintw(win, "This is a formatted string in a window: %d %s\n", 42, "is it"); MvWAddStr(win, 10, 1, "Enter a string: "); wrefresh(win); noraw(); echo(); *Buffer = 0; wscanw(win, "%s", Buffer); printw("This is a formatted string in stdscr: %d %s\n", 42, "is it"); MvAddStr(10, 1, "Enter a string: "); *Buffer = 0; scanw("%s", Buffer); if (TIGETSTR("cvvis", "vs") != 0) { wclear(win); curs_set(2); MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)"); Continue(win); } if (TIGETSTR("civis", "vi") != 0) { wclear(win); curs_set(0); MvWAddStr(win, 1, 1, "The cursor should have disappeared (invisible)"); Continue(win); } if (TIGETSTR("cnorm", "ve") != 0) { wclear(win); curs_set(1); MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)"); Continue(win); } #ifdef A_COLOR if (has_colors()) { wclear(win); MvWAddStr(win, 1, 1, "Colors should change after you press a key"); Continue(win); init_pair(1, COLOR_RED, COLOR_WHITE); wrefresh(win); } #endif werase(win); #if HAVE_TERMNAME MvWAddStr(win, 1, 1, "Information About Your Terminal"); MvWAddStr(win, 3, 1, termname()); MvWAddStr(win, 4, 1, longname()); if (termattrs() & A_BLINK) MvWAddStr(win, 5, 1, "This terminal supports blinking."); else MvWAddStr(win, 5, 1, "This terminal does NOT support blinking."); #endif (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16); wrefresh(win); (void) mvwinnstr(win, 7, 5, Buffer, 18); MvAddStr(LINES - 2, 10, Buffer); refresh(); Continue(win); }
int output_result(WINDOW *mainwin,size_t size,unsigned int **result) { size_t iter,iter_x,iter_y,page = 0,pages,page_items; unsigned int mainwin_size_x,mainwin_size_y; WINDOW **subwins; getmaxyx(mainwin,mainwin_size_y,mainwin_size_x); page_items = (mainwin_size_x/(size+3))*(mainwin_size_y/(size+3)); pages = calc_pages(parray_length((void **)result),page_items); if(!pages){ wclear(mainwin); mvwinsstr(mainwin,1,1,"empty result"); wrefresh(mainwin); return 1; } subwins = malloc(sizeof(WINDOW *)*page_items); if(!subwins)return 0; iter = 0; iter_y = 0; while(iter_y != mainwin_size_y/(size+3)){ iter_x = 0; while(iter_x != mainwin_size_x/(size+3)){ subwins[iter] = subwin(mainwin,size+2,size+2,iter_y*(size+3),iter_x*(size+3)); if(!subwins[iter]){ while(iter--)delwin(subwins[iter]); free(subwins); return 0; } iter_x++; iter++; } iter_y++; } goto REWRITE_BOARD; while(1){ int getf = wgetch(mainwin); switch(getf){ case '\n': case 'q': iter = 0; while(iter != page_items)delwin(subwins[iter++]); free(subwins); wclear(mainwin); wrefresh(mainwin); return (getf == '\n'?1:2); case 'j': if(page < pages-1){ page++; goto REWRITE_BOARD; } break; case 'k': if(page){ page--; goto REWRITE_BOARD; } break; REWRITE_BOARD: wclear(mainwin); iter = 0; while(iter != page_items && result[page_items*page+iter]){ iter_x = 0; while(iter_x != size){ mvwaddch(subwins[iter],result[page_items*page+iter][iter_x]+1,iter_x+1,'*'); iter_x++; } wborder(subwins[iter],'|','|','-','-','+','+','+','+'); iter++; } wrefresh(mainwin); break; } } }
/* * mvinsstr -- * Do an insert-string on the line at (y, x). */ int mvinsstr(int y, int x, const char *str) { return mvwinsstr(stdscr, y, x, str); }