⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcurs.c

📁 ncurses-5.4
💻 C
📖 第 1 页 / 共 2 页
字号:
	wclrtobot(win);	if (c >= KEY_MIN)	    wprintw(win, "Key Pressed: %s", keyname(c));	else if (isprint(c))	    wprintw(win, "Key Pressed: %c", c);	else	    wprintw(win, "Key Pressed: %s", unctrl(c));#if defined(PDCURSES)	if (c == KEY_MOUSE) {	    int button = 0;	    request_mouse_pos();	    if (BUTTON_CHANGED(1))		button = 1;	    else if (BUTTON_CHANGED(2))		button = 2;	    else if (BUTTON_CHANGED(3))		button = 3;	    else		button = 0;	    wmove(win, 4, 18);	    wprintw(win, "Button %d: ", button);	    if (MOUSE_MOVED)		wprintw(win, "moved: ");	    else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_PRESSED)		wprintw(win, "pressed: ");	    else if ((BUTTON_STATUS(button) & BUTTON_ACTION_MASK) == BUTTON_DOUBLE_CLICKED)		wprintw(win, "double: ");	    else		wprintw(win, "released: ");	    wprintw(win, " Position: Y: %d X: %d", MOUSE_Y_POS, MOUSE_X_POS);	}#endif	wrefresh(win);	if (c == ' ')	    break;    }#if 0    nodelay(win, TRUE);    wgetch(win);    nodelay(win, FALSE);#endif#if defined(PDCURSES)    mouse_set(0L);#endif    refresh();    repeat = 0;    do {	static const char *fmt[] = {	    "%d %10s",	    "%d %[a-zA-Z]s",	    "%d %[][a-zA-Z]s",	    "%d %[^0-9]"	};	const char *format = fmt[repeat % SIZEOF(fmt)];	wclear(win);	mvwaddstr(win, 3, 2, "The window should have moved");	mvwaddstr(win, 4, 2,		  "This text should have appeared without you pressing a key");	mvwprintw(win, 6, 2,		  "Scanning with format \"%s\"", format);	mvwin(win, 2 + 2 * (repeat % 4), 1 + 2 * (repeat % 4));	erase();	refresh();	wrefresh(win);	echo();	noraw();	num = 0;	*buffer = 0;	answered = mvwscanw(win, 7, 6, strdup(format), &num, buffer);	mvwprintw(win, 8, 6,		  "String: %s Number: %d (%d values read)",		  buffer, num, answered);	Continue(win);	++repeat;    } while (answered > 0);}static voidoutputTest(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");    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, 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);    mvwinsstr(win, 6, 2, "A1B2C3D4E5");    Continue(win);    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") != 0) {	wclear(win);	curs_set(2);	mvwaddstr(win, 1, 1, "The cursor should appear as a block (visible)");	Continue(win);    }    if (tigetstr("civis") != 0) {	wclear(win);	curs_set(0);	mvwaddstr(win, 1, 1,		  "The cursor should have disappeared (invisible)");	Continue(win);    }    if (tigetstr("cnorm") != 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);    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.");    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);}#if defined(PDCURSES) && !defined(XCURSES)static voidresizeTest(WINDOW *dummy GCC_UNUSED){    WINDOW *win1;    savetty();    clear();    refresh();#  if defined(OS2)    resize_term(50, 120);#  else    resize_term(50, 80);#  endif    win1 = newwin(10, 50, 14, 25);    if (win1 == NULL) {	endwin();	return;    }#ifdef A_COLOR    if (has_colors()) {	init_pair(3, COLOR_BLUE, COLOR_WHITE);	wattrset(win1, COLOR_PAIR(3));    }#endif    wclear(win1);    mvwaddstr(win1, 1, 1, "The screen may now have 50 lines");    Continue(win1);    wclear(win1);    resetty();    mvwaddstr(win1, 1, 1, "The screen should now be reset");    Continue(win1);    delwin(win1);    clear();    refresh();}#endifstatic voidpadTest(WINDOW *dummy GCC_UNUSED){    WINDOW *pad, *spad;    pad = newpad(50, 100);    wattron(pad, A_REVERSE);    mvwaddstr(pad, 5, 2, "This is a new pad");    wattrset(pad, A_NORMAL);    mvwaddstr(pad, 8, 0,	      "The end of this line should be truncated here:except  now");    mvwaddstr(pad, 11, 1, "This line should not appear.It will now");    wmove(pad, 10, 1);    wclrtoeol(pad);    mvwaddstr(pad, 10, 1, " Press any key to continue");    prefresh(pad, 0, 0, 0, 0, 10, 45);    keypad(pad, TRUE);    raw();    wgetch(pad);    spad = subpad(pad, 12, 25, 6, 52);    mvwaddstr(spad, 2, 2, "This is a new subpad");    box(spad, 0, 0);    prefresh(pad, 0, 0, 0, 0, 15, 75);    keypad(pad, TRUE);    raw();    wgetch(pad);    mvwaddstr(pad, 35, 2, "This is displayed at line 35 in the pad");    mvwaddstr(pad, 40, 1, " Press any key to continue");    prefresh(pad, 30, 0, 0, 0, 10, 45);    keypad(pad, TRUE);    raw();    wgetch(pad);    delwin(pad);}static voiddisplay_menu(int old_option, int new_option){    register size_t i;    attrset(A_NORMAL);    mvaddstr(3, 20, "PDCurses Test Program");    for (i = 0; i < MAX_OPTIONS; i++)	mvaddstr(5 + i, 25, command[i].text);    if (old_option != (-1))	mvaddstr(5 + old_option, 25, command[old_option].text);    attrset(A_REVERSE);    mvaddstr(5 + new_option, 25, command[new_option].text);    attrset(A_NORMAL);    mvaddstr(13, 3,	     "Use Up and Down Arrows to select - Enter to run - Q to quit");    refresh();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -