📄 testterminfo.c
字号:
printf("01234"); gocurs(nextline++, 0); if (magic_cookie_glitch <= 0) printf("all the above fonts should begin in column 0"); else printf("all the above fonts should begin in column %d", magic_cookie_glitch); if (pause_for_input() == 'r') goto again;}/* test parameterized scrolling */void tst_Pscroll(top, bot)register int top, bot;{ register int fullscreen =(top == 0) &&(bot == lines - 1);again: if (parm_index) { clearscreen(); gocurs(bot, 0); printf("multi-line(parmeterized) scrolling(parm_index)"); putp(tparm(parm_index, 1)); gocurs(bot, 0); printf("up"); putp(tparm(parm_index, 1)); gocurs(bot, 0); printf("the"); gocurs(bot, 0); putp(tparm(parm_index, 1)); gocurs(bot, 0); printf("screen"); gocurs(bot, 0); putp(tparm(parm_index, bot -(top + 2))); gocurs(bot, 0); if (pause_for_input() == 'r') goto again; if (parm_index && scroll_reverse && parm_rindex) { gocurs(10, 0); printf("reverse scrolling(parm_rindex)"); gocurs(top, 0); putp(tparm(parm_rindex, 2)); gocurs(10, 0); if (scroll_forward && memory_above && fullscreen) printf("the message should(may) have returned"); else { if (fullscreen) printf("the top 2 lines must be blank."); else printf("the top 2 lines in the scrolling region must be blank"); } if (pause_for_input() == 'r') goto again; } }}/* test parameterized cursor left/right */void tst_Plr(){ register int i, col;again: if (parm_left_cursor && parm_right_cursor) { clearscreen(); printf("Test parm_left and parm_right cursor"); gocurs(2, 0); i = columns - 1; col = 0; for(;;) { printf("%1d", col % 10); --i; col += i; if (i <= 0) break; putp(tparm(parm_right_cursor, i - 1)); printf("%1d", col % 10); putp(tparm(parm_left_cursor, i)); --i; col -= i; } if (pause_for_input() == 'r') goto again; }}/* test parameterized cursor up/down */void tst_Pud(){ register int i, row;again: if (parm_up_cursor && parm_down_cursor && carriage_return) { clearscreen(); printf(" Test parm_up and parm_down cursor"); i = lines; row = 0; for(;;) { putp(carriage_return); printf("%2d", row); --i; row += i; if (i <= 0) break; putp(tparm(parm_down_cursor, i)); putp(carriage_return); printf("%2d", row); --i; row -= i; if (i <= 0) break; putp(tparm(parm_up_cursor, i)); } if (pause_for_input() == 'r') goto again; }}tst_sanity(){again: clearscreen(); printf("sanity testing\r\n\n"); if (lines <= 0) printf("terminal has %d lines?\r\n",lines); if (columns <= 0) printf("terminal has %d columns?\r\n",columns); if (enter_ca_mode && !exit_ca_mode) printf("enter_cursor_address_mode given without exit_ca_mode\n\r"); else if (!enter_ca_mode && exit_ca_mode) printf("exit_cursor_address_mode given without enter_ca_mode\n\r"); if (enter_insert_mode && !exit_insert_mode) printf("enter_insert_mode given without exit_insert_mode\n\r"); else if (!enter_insert_mode && exit_insert_mode) printf("exit_insert_mode given without enter_insert_mode\n\r"); if (enter_delete_mode && !exit_delete_mode) printf("enter_delete_mode given without exit_delete_mode\n\r"); else if (!enter_delete_mode && exit_delete_mode) printf("exit_delete_mode given without enter_delete_mode\n\r"); if (enter_standout_mode && !exit_standout_mode) printf("enter_standout_mode given without exit_standout_mode\n\r"); else if (!enter_standout_mode && exit_standout_mode) printf("exit_standout_mode given without enter_standout_mode\n\r"); if (enter_underline_mode && !exit_underline_mode) printf("enter_underline_mode given without exit_underline_mode\n\r"); else if (!enter_underline_mode && exit_underline_mode) printf("exit_underline_mode given without enter_underline_mode\n\r"); if (enter_xon_mode && !exit_xon_mode) printf("enter_xon_mode given without exit_xon_mode\n\r"); else if (!enter_xon_mode && exit_xon_mode) printf("exit_xon_mode given without enter_xon_mode\n\r"); if (enter_am_mode && !exit_am_mode) printf("enter_am_mode given without exit_am_mode\n\r"); else if (!enter_am_mode && exit_am_mode) printf("exit_am_mode given without enter_am_mode\n\r"); if (enter_alt_charset_mode && !exit_alt_charset_mode) printf("enter_alt_charset_mode given without exit_alt_charset_mode\n\r"); else if (!enter_alt_charset_mode && exit_alt_charset_mode) printf("exit_alt_charset_mode given without enter_alt_charset_mode\n\r"); if (has_status_line) { if (!to_status_line) printf("has status line, but no way to get to it!\r\n"); if (!from_status_line) printf("has status line, but no way to get from it!\r\n"); } else { if (to_status_line) /* others? */ printf("no status line, but a way is defined to get to it!\r\n"); if (from_status_line) /* others? */ printf("no status line, but a way is defined to get from it!\r\n"); } if (pause_for_input() == 'r') goto again;}tst_CAenter(){again: if (enter_ca_mode) { clearscreen(); printf("Testing 'enter_ca_mode'."); putp(enter_ca_mode); printf("cursor address mode begun."); if (pause_for_input() == 'r') goto again; }}tst_clear(){again: dumb_clear_screen(); if (clear_screen) { printf("Clear Screen Test"); putp(clear_screen); printf("Screen was cleared and cursor should have gone home\r\n"); } else printf("No clear_screen!\r\n"); if (pause_for_input() == 'r') goto again;}tst_home(){again: dumb_clear_screen(); if (cursor_home) { printf("Going"); putp(cursor_home); printf("Home"); } else printf("No cursor_home\r\n"); if (pause_for_input() == 'r') goto again; dumb_clear_screen();}tst_CM(){ register int i;again: dumb_clear_screen(); if (cursor_address) { for(i = 0; i < columns; i++) { putp(tparm(cursor_address, 10, i)); printf("%c\r\n",((i & 07) + '0')); } if (cursor_home) putp(cursor_home); else putp(tparm(cursor_address, 0, 0)); for(i = 0; i < 10; i++) printf("%d\r\n", i); putp(tparm(cursor_address, 12, 10)); printf("Cursor address test"); putp(tparm(cursor_address, 14, 10)); printf("Line 10 should count across the screen 0-7"); if (pause_for_input() == 'r') goto again; dumb_clear_screen(); for(i = 0; i < lines; i++) { putp(tparm(cursor_address, i, columns / 2)); printf("%d", i); } if (cursor_home) putp(cursor_home); else putp(tparm(cursor_address, 0, 0)); for(i = 0; i < columns / 2; i++) printf("%1d", i % 10); putp(tparm(cursor_address, 1, 0)); printf("Cursor address test"); putp(tparm(cursor_address, 3, 0)); printf("Screen should"); putp(tparm(cursor_address, 4, 0)); printf("have a line"); putp(tparm(cursor_address, 5, 0)); printf("counting down"); putp(tparm(cursor_address, 6, 0)); printf("the middle"); } else printf("No cursor_address.\n\r"); if (pause_for_input() == 'r') goto again;}/* clear to the end of the screen */tst_eos(){ register int i;again: dumb_clear_screen(); if (clr_eos) { if (!cursor_address && !cursor_home) { printf("need either cursor_address or cursor_home to test clr_eos!\n\r"); if (pause_for_input() == 'r') goto again; return; } for(i = 0; i < lines; i++) printf("\r\n1234"); if (cursor_address) { putp(tparm(cursor_address, lines / 2, 0)); printf("wxyz"); } else if (cursor_home) { putp(cursor_home); for(i = 0; i < lines / 2; i--) printf("\r\n"); printf ("wxyz"); } printf(" testing clear to end of screen between x and y"); if (pause_for_input() == 'r') goto again; if (cursor_address) putp(tparm(cursor_address, lines / 2, 2)); else if (cursor_home) { putp(cursor_home); for(i = 0; i < lines / 2; i--) printf("\r\n"); printf ("xy"); } putp(clr_eos); } else printf("No clr_eos\r\n"); if (pause_for_input() == 'r') goto again;}/* test cursor_right */tst_right(){ register int i;again: clearscreen(); if (cursor_right) { printf("01234567890123456789012345678901234567890\n\r1\n\r2\n\r3\n\r4\n\r5\t"); printf("Drawing Forwards from 10,0 to 10,40, moving right once between each"); printf("\n\r6\n\r7\n\r8\n\r9\n\r"); for(i = 0; i < 20; i++) { printf("%d", i % 10); putp(cursor_right); } } else printf("No cursor_right.\r\n"); if (pause_for_input() == 'r') goto again;}/* test cursor_down */tst_down(){ register int i;again: clearscreen(); if (cursor_down) { gohome(); printf("012345678901234567890123456789012\r\n"); for(i=1; i<19; ) printf("%d\r\n",i++); dumb_gocurs(5,5); printf("Drawing cursor_down diagonally from 6,20 to 18,32"); dumb_gocurs(6,20); for(i = 0; i < 12; i++) { printf("%d", i % 10); putp(cursor_down); } printf("%d", i % 10); putp(cursor_down); } else printf("No cursor_down.\r\n"); if (pause_for_input() == 'r') goto again;}/* testing cursor_left */tst_left(){ register int i;again: clearscreen(); if (cursor_left) { printf("01234567890123456789012345678901234567890\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9"); dumb_gocurs(5,10); printf("Drawing backwards from 10,20 to 10,0, using cursor_left"); dumb_gocurs(10,20); for(i = 0; i < 20; i++) { printf("%d", i % 10); putp(cursor_left); putp(cursor_left); } printf("%d", i % 10); putp(cursor_left); } else printf("No cursor_left.\r\n"); if (pause_for_input() == 'r') goto again;}tst_up(){ register int i;again: clearscreen(); if (cursor_up) { printf("01234567890123456789012345678901234567890\r\n"); for(i=1; i<19; ) printf("%d\r\n",i++); dumb_gocurs(5, 25); if (cursor_left) printf("Drawing cursor_up from 18,20 to 1,20"); else printf("Drawing cursor_up diagonally from 18,20 to 1,40"); dumb_gocurs(18, 20); for(i = 0; i < 17; i++) { printf("%d", i % 10); if (cursor_left) putp(cursor_left); putp(cursor_up); } printf("%d", i % 10); if (cursor_left) putp(cursor_left); } else printf("No cursor_up.\r\n"); if (pause_for_input() == 'r') goto again;}/* test horizontal positioning(column addressing) */tst_hpa(){ register int i;again: if (column_address) { clearscreen(); printf("Drawing down column 10 using column_address"); for(i = 1; i < lines; i++) { dumb_gocurs(i, 0); putp(tparm(column_address, 10)); (void) putchar('x'); } dumb_gocurs(lines - 1, 0); printf("0123456789"); if (pause_for_input() == 'r') goto again; } }/* test vertical positioning(row address) */tst_vpa(){ register int i;again: if (row_address) { clearscreen(); dumb_gocurs(0, 5); printf("Drawing across row 10 using row_address"); for(i = 0; i < columns; i++) { dumb_gocurs(0, i); putp(tparm(row_address, 10)); (void) putchar('x'); } for(i = 0; i < 10; ++i) { gocurs(i, 0); printf("%d", i); } if (pause_for_input() == 'r') goto again; }}/* test carriage return */tst_cr(){again: clearscreen(); if (carriage_return) { gocurs(10, 25); printf("Carriage"); putp(carriage_return); printf("Return"); } else printf("No carriage_return\n\r"); if (pause_for_input() == 'r') goto again;}tst_ll(){again: if (cursor_to_ll) { clearscreen(); gocurs(10, 25); printf("Going"); putp(cursor_to_ll); printf("Home-DOWN"); if (pause_for_input() == 'r') goto again; }}/* testing repeat char */tst_rep(){again: if (repeat_char) { clearscreen(); gocurs(0, 0); printf("testing repeat character"); gocurs(1, 0); putp(tparm(repeat_char, '_', 20)); gocurs(2, 0); printf("____________________"); gocurs(3, 0); printf("the above two lines should be identical"); if (pause_for_input() == 'r') goto again; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -