📄 testterminfo.c
字号:
/* testing erase chars */tst_ech(){again: if (erase_chars) { clearscreen(); gocurs(0, 0); printf("testing erase multiple characters"); gocurs(1, 0); printf("012345678901234567890123456789"); gocurs(1, 4); putp(tparm(erase_chars, 16)); gocurs(2, 0); printf("0123 0123456789"); gocurs(3, 0); printf(" 1234567890123456"); gocurs(4, 0); printf("the two lines should be identical, with 16 blanks"); if (pause_for_input() == 'r') goto again; }}/* testing parm'd delete char */tst_Pdch(){again: if (parm_dch) { clearscreen(); gocurs(0, 0); printf("testing parm_dch(delete multiple characters)"); gocurs(1, 0); printf("testing paaaaaaaaaaaaaaaaaaaaarm_dch(delete multiple characters)"); gocurs(1, 9); putp(tparm(parm_dch, 20)); gocurs(2, 0); printf("The above two lines should now be identical"); if (pause_for_input() == 'r') goto again; }}/* test auto_right_margin and auto_left_margin */tst_am(){ register char *ch;again: if (auto_right_margin) { clearscreen(); gocurs(5, columns - 7); printf("cursor wraps"); gocurs(7, 0); printf("wraps under wraps"); if (pause_for_input() == 'r') goto again; } if (auto_left_margin) { clearscreen(); printf("auto left margin test"); gocurs(7, 4); for(ch = "wrap left"; *ch; ch++) { (void) putchar(*ch); putp(cursor_left); } if (pause_for_input() == 'r') goto again; }}/* testing clear to end of line */tst_eol(){again: if (clr_eol) { clearscreen(); gocurs(10, 0); printf("clearing everything after clear"); gocurs(11, 0); printf("clearing everything after clear"); gocurs(10, 5); putp(clr_eol); if (pause_for_input() == 'r') goto again; }}/* ring the bell */tst_bell(){again: if (bell) { clearscreen(); printf("beep beep beep"); putp(bell); sleep(1); putp(bell); sleep(1); putp(bell); if (pause_for_input() == 'r') goto again; }}/* flash the screen */tst_flash(){again: if (flash_screen) { clearscreen(); gocurs(lines / 2,(columns - 40) / 2); printf("press any key to flash the screen"); (void) pause_for_input(); putp(flash_screen); printf(" -- WOW!"); gocurs(1 + lines / 2, 0); printf("the above line should read:"); gocurs(2 + lines / 2,(columns - 40) / 2); printf("press any key to flash the screen -- WOW!"); if (pause_for_input() == 'r') goto again; }}/* insert chars */tst_ich(){ register int i; if (insert_character ||(enter_insert_mode && exit_insert_mode) ) { clearscreen(); gocurs(10, 0); printf("Testing insert character."); if (insert_null_glitch) { printf(" These won't move unless pushed"); printf("These move when you push them"); } else printf(" These move too"); printf("\r\nTyped characters will insert, ^G to end"); gocurs(10, 4); if (enter_insert_mode) putp(enter_insert_mode); (void) fflush(stdout); if (manual) { while ((i = getchar()) != '') { if (insert_character) putp(insert_character); (void) putchar(i); if (insert_padding) putp(insert_padding); (void) fflush(stdout); } } else { if (insert_character) putp(insert_character); (void) putchar(' '); if (insert_padding) putp(insert_padding); (void) fflush(stdout); } if (exit_insert_mode) putp(exit_insert_mode); }}/* testing parm'd insert chars */tst_Pich(){again: if (parm_ich) { clearscreen(); gocurs(0, 0); printf("testing parm_ich(insert multiple characters)"); gocurs(0, 7); if (enter_insert_mode) putp(enter_insert_mode); fflush(stdout); putp(tparm(parm_ich, 20)); if (exit_insert_mode) putp(exit_insert_mode); gocurs(1, 0); printf("testing parm_ich(insert multiple characters)"); gocurs(2, 0); printf("The above two lines should be identical"); if (pause_for_input() == 'r') goto again; }}/* testing delete char */tst_dch(){ register int i; if (delete_character) { clearscreen(); gocurs(10, 0); printf("Testing delete character."); if (insert_null_glitch) { printf(" All of these characters, including the wrap to the new line, should move"); printf(" These won't move"); } else printf(" These move too"); printf("\r\nType characters to delete, ^G to end"); gocurs(10, 4); if (enter_delete_mode) putp(enter_delete_mode); (void) fflush(stdout); if (manual) { while ((i = getchar()) != '') { putp(delete_character); (void) fflush(stdout); } } else putp(delete_character); (void) fflush(stdout); if (exit_delete_mode) putp(exit_delete_mode); }}/* testing transparent underline */tst_tul(){again: if (transparent_underline) { clearscreen(); if (erase_overstrike) { gocurs(4, 0); uprint("Underlined_Characters"); gocurs(6, 0); uprint("These won't wind up underlined"); gocurs(6, 0); printf("These won't wind up underlined"); } else { gocurs(6, 0); erase_overstrike = 1; uprint("..............................."); erase_overstrike = 0; gocurs(6, 0); printf("These characters are underlined"); } if (pause_for_input() == 'r') goto again; }}/* testing status line */tst_sl(){ register int i;again: if (has_status_line && to_status_line && from_status_line) { clearscreen(); gocurs(0, 0); printf("Testing "); putp(tparm(to_status_line, 0)); printf("Testing "); putp(from_status_line); printf("Status "); putp(tparm(to_status_line, 8)); printf("Status "); putp(from_status_line); printf("Line"); putp(tparm(to_status_line, 15)); printf("Line"); putp(from_status_line); if (pause_for_input() == 'r') goto again; clearscreen(); gocurs(0, 0); printf("More status line testing(width=%d)", width_status_line); putp(tparm(to_status_line, 0)); if (width_status_line < 0) width_status_line = columns; for(i = 0; i < width_status_line; ++i) printf("%1d", i % 10); putp(from_status_line); if (pause_for_input() == 'r') goto again; clearscreen(); if (status_line_esc_ok && clr_eol) { gocurs(0, 0); printf("Testing status line escapes"); putp(tparm(to_status_line, width_status_line / 2)); putp(clr_eol); putp(from_status_line); gocurs(1, 0); printf("the last column remaining should be %d", (width_status_line / 2) - 2); if (pause_for_input() == 'r') goto again; putp(tparm(to_status_line, 0)); putp(clr_eol); putp(from_status_line); if (pause_for_input() == 'r') goto again; } if (dis_status_line) { clearscreen(); gocurs(0, 0); printf("testing disable status line"); putp(dis_status_line); if (pause_for_input() == 'r') goto again; } }}/* programming labels */tst_pln(){ register int i, j, k; char label[512];again: if (plab_norm) { clearscreen(); gocurs(0, 0); printf("Programming function key labels:"); gocurs(1, 0); printf("There should be %d labels which are %d rows high and %d columns wide", num_labels, label_height, label_width); for(i = 1; i <= num_labels; ++i) { for(j = 0; j < label_height; ++j) for(k = 0; k < label_width; ++k) label[j * label_width + k] = '0' +(k % 10); label[label_width * label_height] = '\0'; putp(tparm(plab_norm, i, label)); } if (pause_for_input() == 'r') goto again; clearscreen(); gocurs(0, 0); printf("clearing function labels"); for(i = 1; i <= num_labels; ++i) putp(tparm(plab_norm, i, "")); if (pause_for_input() == 'r') goto again; }}/* programming the pf keys */tst_pfk(){again: if (pkey_xmit) { clearscreen(); gocurs(0, 0); printf("programming function key 1 to transmit 'who|wc'"); putp(tparm(pkey_xmit, 1, "who|wc\n")); gocurs(1, 0); printf("You'll have to check this out later..."); if (pause_for_input() == 'r') goto again; }}main(argc, argv)int argc;char **argv;{ char *termtype; /* the terminal type */ char *progname; char *startingpoint = NULL; progname = argv[0]; if (argc >= 2 && argv[1][0] == '-') { startingpoint = &argv[1][1]; argc--; argv++; } if (argc == 2) termtype = argv[1]; else if (argc == 1) termtype = getenv("TERM"); else { fprintf(stderr, "Usage: %s [-start] [terminal-type]\r\n", progname); exit(1); } if (newterm(termtype, stdout, stdin) == NULL) { fprintf(stderr, "Cannot initialize terminal type %s!\r\n", argv[0], termtype); exit(2); } noecho(); nonl(); cbreak(); (void) signal(SIGINT, onintr); (void) signal(SIGQUIT, onintr); (void) signal(SIGHUP, onintr); tst_CAenter(); if (startingpoint != NULL) { if (strcmp(startingpoint, "a") == 0) { manual = 0; goto Ssanity; } if (strcmp(startingpoint, "sanity") == 0) goto Ssanity; if (strcmp(startingpoint, "clear") == 0) goto Sclear; if (strcmp(startingpoint, "home") == 0) goto Shome; if (strcmp(startingpoint, "cup") == 0) goto Scup; if (strcmp(startingpoint, "eos") == 0) goto Seos; if (strcmp(startingpoint, "cuf") == 0) goto Scuf; if (strcmp(startingpoint, "cud") == 0) goto Scud; if (strcmp(startingpoint, "cul") == 0) goto Scul; if (strcmp(startingpoint, "cuu") == 0) goto Scuu; if (strcmp(startingpoint, "hpa") == 0) goto Shpa; if (strcmp(startingpoint, "vpa") == 0) goto Svpa; if (strcmp(startingpoint, "pculr") == 0) goto Spculr; if (strcmp(startingpoint, "pcuud") == 0) goto Spcuud; if (strcmp(startingpoint, "cr") == 0) goto Scr; if (strcmp(startingpoint, "ll") == 0) goto Sll; if (strcmp(startingpoint, "rep") == 0) goto Srep; if (strcmp(startingpoint, "ech") == 0) goto Sech; if (strcmp(startingpoint, "pdch") == 0) goto Spdch; if (strcmp(startingpoint, "am") == 0) goto Sam; if (strcmp(startingpoint, "eol") == 0) goto Seol; if (strcmp(startingpoint, "index") == 0) goto Sindex; if (strcmp(startingpoint, "csr") == 0) goto Scsr; if (strcmp(startingpoint, "pindex") == 0) goto Spindex; if (strcmp(startingpoint, "bell") == 0) goto Sbell; if (strcmp(startingpoint, "flash") == 0) goto Sflash; if (strcmp(startingpoint, "ich") == 0) goto Sich; if (strcmp(startingpoint, "pich") == 0) goto Spich; if (strcmp(startingpoint, "dch") == 0) goto Sdch; if (strcmp(startingpoint, "idl") == 0) goto Sidl; if (strcmp(startingpoint, "pidl") == 0) goto Spidl; if (strcmp(startingpoint, "tul") == 0) goto Stul; if (strcmp(startingpoint, "sl") == 0) goto Ssl; if (strcmp(startingpoint, "pln") == 0) goto Spln; if (strcmp(startingpoint, "sgr") == 0) goto Ssgr; if (strcmp(startingpoint, "pfk") == 0) goto Spfk; fprintf(stderr, "%s: unknown starting point '%s'.\n\r", progname, startingpoint); }Ssanity: tst_sanity();Sclear: tst_clear();Shome: tst_home();Scup: tst_CM();Seos: tst_eos(); /* clearscreen() can now be used safely. */Scuf: tst_right();Scud: tst_down(); /* dumbgocurs() can now be used safely */Scul: tst_left();Scuu: tst_up();Shpa: tst_hpa();Svpa: tst_vpa();Spculr: tst_Plr();Spcuud: tst_Pud(); /* gocurs() can now be used safely */Scr: tst_cr();Sll: tst_ll();Srep: tst_rep();Sech: tst_ech();Spdch: tst_Pdch();Sam: tst_am();Seol: tst_eol();Sindex: tst_scroll(0, lines - 1);Scsr: tst_csr();Spindex: tst_Pscroll(0, lines - 1);Sbell: tst_bell();Sflash: tst_flash();Sich: tst_ich();Spich: tst_Pich();Sdch: tst_dch();Sidl: tst_idline();Spidl: tst_Pidline();Stul: tst_tul();Ssl: tst_sl();Spln: tst_pln();Ssgr: tst_attr();Spfk: tst_pfk(); onintr(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -