/* ** crum_os(test_list, status, ch) ** ** (cup) test Cursor position on overstrike terminals */ static void crum_os( struct test_list *t, int *state, int *ch) { int i; if (cursor_address && over_strike) { put_clear(); for (i = 0; i < columns - 2; i++) { tc_putch('|'); } for (i = 1; i < lines - 2; i++) { put_crlf(); tc_putch('_'); } for (i = 0; i < columns - 2; i++) { tputs(TPARM_2(cursor_address, 0, i), lines, tc_putch); tc_putch('+'); } for (i = 0; i < lines - 2; i++) { tputs(TPARM_2(cursor_address, i, 0), lines, tc_putch); tc_putch(']'); tc_putch('_'); } go_home(); put_newlines(3); ptext(" All the characters should look the same. "); generic_done_message(t, state, ch); put_clear(); } }
static void line_pattern(void) { /* put up a pattern that will help count the number of lines */ int i; put_clear(); if (over_strike) { for (i = 0; i < 100; i++) { int j; if (i) { put_crlf(); } for (j = i / 10; j; j--) { put_this(' '); } put_this('0' + ((i + 1) % 10)); } } else { /* I assume it will scroll */ for (i = 100; i; i--) { sprintf(temp, "\r\n%d", i); put_str(temp); } } }
/* ** subtest_dadb(test_list, status, ch) ** ** (da) (db) data above, (db) data below */ static void subtest_dadb( struct test_list *t, int *state, int *ch) { if (can_clear_screen && scroll_reverse && scroll_forward) { put_clear(); if (scroll_reverse) ptext("(da) Data-above should be set\r"); home_down(); if (scroll_forward) ptext("(db) Data-below should be set\r"); tc_putp(scroll_forward); go_home(); tc_putp(scroll_reverse); tc_putp(scroll_reverse); home_down(); tc_putp(scroll_forward); go_home(); ptextln("\n\n\n\n\nIf the top line is blank then (da) should be false."); ptextln("If the bottom line is blank then (db) should be false."); sprintf(temp, "\n(da) Data-above is %s, and (db) Data-below is %s, in the data base.", memory_above ? "true" : "false", memory_below ? "true" : "false"); ptextln(temp); line_count = lines; } else { ptextln("(da) Data-above, (db) Data-below not tested, scrolls or (clear) is missing."); } generic_done_message(t, state, ch); }
/* ** sync_clear(test_list, status, ch) ** ** How many clear-screens/second? */ static void sync_clear( struct test_list *t, int *state, int *ch) { int j; if (!clear_screen) { ptext("Terminal can not clear-screen. "); generic_done_message(t, state, ch); return; } if (skip_pad_test(t, state, ch, "(clear) Start clear-screen performance test")) { return; } pad_test_startup(0); repeats = 20; do { sprintf(temp, "%d", test_complete); put_str(temp); for (j = 0; j < repeats; j++) { put_clear(); } } while(still_testing()); pad_test_shutdown(t, 0); j = sliding_scale(tx_count[0], 1000000, usec_run_time); if (j > tty_clear_rate) { tty_clear_rate = j; } sprintf(temp, "%d clear-screens per second. ", j); ptext(temp); generic_done_message(t, state, ch); }
/* ** subtest_am(test_list, status, ch) ** ** test automatic margins (am) */ static void subtest_am( struct test_list *t, int *state, int *ch) { int i, j; if (!can_go_home) { ptextln("(am) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); ptext("\n(am) should "); i = char_count; ptext("not be set"); go_home(); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); go_home(); put_newlines(2); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); } else { put_clear(); go_home(); ptext("\n(am) should not be set"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(am) should be set "); go_home(); put_str(" \n\n"); sprintf(temp, "(am) is %s in the data base", auto_right_margin ? "true" : "false"); ptextln(temp); } ptext("Automatic-right-margin "); generic_done_message(t, state, ch); }
/* ** subtest_smam(test_list, status, ch) ** ** test enter automatic margins mode (smam) */ static void subtest_smam( struct test_list *t, int *state, int *ch) { int i, j; if (!enter_am_mode) { ptext("(smam) not present. "); } else if (!can_go_home) { ptext("(smam) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); tc_putp(enter_am_mode); ptext("\n(smam) will "); i = char_count; ptext("not set (am)"); go_home(); for (j = -i; j < columns; j++) put_this(' '); put_str("@@@"); put_newlines(2); } else { put_clear(); go_home(); tc_putp(enter_am_mode); ptext("\n(smam) will not set (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(smam) will set (am) "); go_home(); put_str(" "); put_newlines(2); } ptext("Enter-automatic-margins "); generic_done_message(t, state, ch); }
/* ** subtest_rmam(test_list, status, ch) ** ** test exit automatic margins mode (rmam) */ static void subtest_rmam( struct test_list *t, int *state, int *ch) { int j; if (!exit_am_mode) { ptext("(rmam) not present. "); } else if (!can_go_home) { ptext("(rmam) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am)"); go_home(); put_newlines(2); } else { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am) "); go_home(); put_str(" "); go_home(); put_newlines(2); } ptext("Exit-automatic-margins "); generic_done_message(t, state, ch); }
static void column_pattern(void) { /* put up a pattern that will help count the number of columns */ int i, j; put_clear(); for (i = 0; i < 20; i++) { for (j = 1; j < 10; j++) { put_this('0' + j); } put_this('.'); } }
/* ** display_it(selection, text) ** ** print the display using sel */ static void display_it( int sel, char *txt) { int i, done_line; put_clear(); go_home(); put_newlines(2); ptextln(" The top line should be alternating <'s and >'s"); ptextln(" The left side should be alternating A's and V's"); ptext(" Testing "); ptext(txt); put_cr(); /* horizontal */ move_to(done_line = line_count, 0, 0, 2, sel); for (i = 4; i < columns - 2; i += 2) { putchp('>'); move_to(0, i - 1, 0, i, sel); } putchp('>'); i -= 2; move_to(0, i + 1, 0, i - 1, sel); for (; i > 2; i -= 2) { putchp('<'); move_to(0, i, 0, i - 3, sel); } putchp('<'); /* vertical */ move_to(0, 2, 0, 0, sel); for (i = 2; i < lines - 1; i += 2) { putchp('V'); move_to(i - 2, 1, i, 0, sel); } putchp('V'); i -= 2; move_to(i, 1, i + 1, 0, sel); for (; i > 0; i -= 2) { putchp('A'); move_to(i + 1, 1, i - 1, 0, sel); } putchp('A'); move_to(i + 1, 1, 0, 0, sel); /* go home first */ move_to(0, 0, done_line + 1, 3, sel); put_str(txt); put_str(" Done. "); }
/* ** subtest_mir(test_list, status, ch) ** ** (mir) move in insert mode */ static void subtest_mir( struct test_list *t, int *state, int *ch) { int i; char *s; if (enter_insert_mode && exit_insert_mode && cursor_address) { put_clear(); i = line_count; put_str("\nXXX\nXXX\nXXX\nXXX"); tc_putp(enter_insert_mode); s = tparm(cursor_address, i + 1, 0); tputs(s, lines, tc_putch); putchp('X'); s = tparm(cursor_address, i + 2, 1); tputs(s, lines, tc_putch); putchp('X'); s = tparm(cursor_address, i + 3, 2); tputs(s, lines, tc_putch); putchp('X'); s = tparm(cursor_address, i + 4, 3); tputs(s, lines, tc_putch); putchp('X'); tc_putp(exit_insert_mode); put_newlines(2); ptextln("If you see a 4 by 4 block of X's then (mir) should be true."); sprintf(temp, "(mir) Move-in-insert-mode is %s in the data base", move_insert_mode ? "true" : "false"); ptextln(temp); } else { ptext("(mir) Move-in-insert-mode not tested, "); if (!enter_insert_mode) { ptext("(smir) "); } if (!exit_insert_mode) { ptext("(rmir) "); } if (!cursor_address) { ptext("(cup) "); } ptext("not present. "); } generic_done_message(t, state, ch); }
/* ** pad_test_startup() ** ** Do the stuff needed to begin a test. */ void pad_test_startup( int do_clear) { if (do_clear) { put_clear(); } repeats = augment; raw_characters_sent = 0; test_complete = ttp = char_count = tt_delay_used = 0; letter = letters[letter_number = 0]; if (pad_test_duration <= 0) { pad_test_duration = 1; } tt_delay_max = pad_test_duration * 1000; set_alarm_clock(pad_test_duration); event_start(TIME_TEST); }
/* ** crum_clear(test_list, status, ch) ** ** (clear) test Clear screen */ static void crum_clear( struct test_list *t, int *state, int *ch) { int i; if (clear_screen) { for (i = lines; i > 1; i--) { putln("garbage"); } put_clear(); ptextln("This line should start in the home position."); ptext("The rest of the screen should be clear. "); } else { ptextln("(clear) Clear screen is not defined. "); } generic_done_message(t, state, ch); }
/* ** subtest_cbt(test_list, status, ch) ** ** (cbt) back tab */ static void subtest_cbt( struct test_list *t, int *state, int *ch) { int i; if (back_tab) { put_clear(); ptext("Back-tab (cbt)"); go_home(); put_crlf(); for (i = 1; i < columns; i++) { putchp(' '); } for (i = 0; i < columns; i += 8) { tc_putp(back_tab); putchp('T'); tc_putp(back_tab); } go_home(); put_newlines(2); for (i = 1; i < columns; i++) { if (i % 8 == 1) { putchp('T'); } else { putchp(' '); } } go_home(); put_newlines(3); ptextln("The preceding two lines should be the same."); } else { ptextln("(cbt) Back-tab not present"); } generic_done_message(t, state, ch); }
/* ** crum_home(test_list, status, ch) ** ** (home) test Home cursor */ static void crum_home( struct test_list *t, int *state, int *ch) { if (cursor_home) { put_clear(); put_newlines(lines / 2); go_home(); put_crlf(); ptext("The bottom line should have text."); go_home(); put_newlines(lines - 1); ptext("This line is on the bottom."); go_home(); ptextln("This line starts in the home position."); put_crlf(); } else { ptextln("(home) Home cursor is not defined. "); } generic_done_message(t, state, ch); }
/* ** crum_ll(test_list, status, ch) ** ** (ll) test Last line */ static void crum_ll( struct test_list *t, int *state, int *ch) { /* (ll) may be simulated with (cup). Don't complain if (cup) is present. */ if (cursor_to_ll) { put_clear(); put_str("This line could be anywhere."); tc_putp(cursor_to_ll); ptext("This line should be on the bottom"); go_home(); put_crlf(); } else if (cursor_address) { return; } else { ptextln("(ll) Move to last line is not defined. "); } generic_done_message(t, state, ch); }
/* ** subtest_xenl(test_list, status, ch) ** ** (xenl) eat newline glitch */ static void subtest_xenl( struct test_list *t, int *state, int *ch) { int i, j, k; if (over_strike) { /* test (xenl) on overstrike terminals */ if (!can_go_home || !can_clear_screen) { ptextln("(xenl) Newline-glitch not tested, can't home cursor and clear."); generic_done_message(t, state, ch); return; } put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); ptext("\nreset (xenl). Does "); i = char_count; put_str("not ignore CR, does "); k = char_count; put_str("not ignore LF"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_cr(); for (j = 0; j < i; j++) putchp(' '); put_str("@@@\n@@"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); for (j = 0; j < k; j++) putchp(' '); put_str("@@@\r@@"); tty_set(); go_home(); put_newlines(4); sprintf(temp, "(xenl) Newline-glitch is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } else { /* test (xenl) when (os) is reset */ if (!can_go_home) { ptextln("(xenl) Newline-glitch not tested, can't home cursor"); generic_done_message(t, state, ch); return; } /* (xenl) test */ put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); for (j = 0; j < columns; j++) put_this(' '); put_cr(); ptext("(xenl) should be set. Does not ignore CR"); go_home(); put_crlf(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); /* test (cud1) */ ptext("(xenl) should be set. Ignores (cud1)"); go_home(); put_newlines(3); if (scroll_forward && cursor_down && strcmp(scroll_forward, cursor_down)) { for (j = 0; j < columns; j++) put_this(' '); put_ind(); /* test (ind) */ ptext("(xenl) should be set. Ignores (ind)"); go_home(); put_newlines(5); } tty_set(); ptextln("If you don't see text above telling you to set it, (xenl) should be false"); sprintf(temp, "(xenl) Newline-glitch is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } generic_done_message(t, state, ch); }
/* ** curses_setup(exec_name) ** ** Startup ncurses */ void curses_setup( char *exec_name) { int status; static TERMTYPE term; char tty_filename[2048]; tty_init(); /** See if the terminal is in the terminfo data base. This call has two useful benefits, 1) it returns the filename of the terminfo entry, and 2) it searches only terminfo's. This allows us to abort before ncurses starts scanning the termcap file. **/ if ((status = _nc_read_entry(tty_basename, tty_filename, &term)) == 0) { const TERMTYPE *fallback = _nc_fallback(tty_basename); if (fallback) { term = *fallback; sprintf(tty_filename, "(fallback)%s", tty_basename); status = 1; } else { fprintf(stderr, "Terminal not found: TERM=%s\n", tty_basename); show_usage(exec_name); exit(1); } } if (status == -1) { fprintf(stderr, "Terminfo database is inaccessible\n"); exit(1); } /** This call will load the terminfo data base and set the cur-term variable. Only terminals that actually exist will get here so its OK to ignore errors. This is a good thing since ncurses does not permit (os) or (gn) to be set. **/ setupterm(tty_basename, 1, &status); /** Get the current terminal definitions. This must be done before getting the baudrate. **/ _nc_get_curterm(&cur_term->Nttyb); tty_baud_rate = baudrate(); tty_cps = (tty_baud_rate << 1) / tty_frame_size; /* set up the defaults */ replace_mode = TRUE; scan_mode = 0; char_count = 0; select_delay_type = debug_level = 0; char_mask = (meta_on && meta_on[0] == '\0') ? ALLOW_PARITY : STRIP_PARITY; /* Don't change the XON/XOFF modes yet. */ select_xon_xoff = initial_stty_query(TTY_XON_XOFF) ? 1 : needs_xon_xoff; fflush(stdout); /* flush any output */ tty_set(); go_home(); /* set can_go_home */ put_clear(); /* set can_clear_screen */ if (send_reset_init) { reset_init(); } /* I assume that the reset and init strings may not have the correct pads. (Because that part of the test comes much later.) Because of this, I allow the terminal some time to catch up. */ fflush(stdout); /* waste some time */ sleep(1); /* waste more time */ charset_can_test(); can_test("lines cols cr nxon rf if iprog rmp smcup rmcup", FLAG_CAN_TEST); edit_init(); /* initialize the edit data base */ if (send_reset_init && enter_ca_mode) { tc_putp(enter_ca_mode); put_clear(); /* just in case we switched pages */ } put_crlf(); ptext("Using terminfo from: "); ptextln(tty_filename); put_crlf(); if (tty_can_sync == SYNC_NEEDED) { verify_time(); } display_basic(); }
/* ** keys_tested(first-time, show-help, hex-output) ** ** Display a list of the keys not tested. */ static void keys_tested( int first_time, int show_help, int hex_output) { int i, l; char outbuf[256]; alloc_strings(); put_clear(); tty_set(); flush_input(); if (got_labels) { putln("Function key labels:"); for (i = 0; i < key_count; ++i) { if (fk_label[i]) { sprintf(outbuf, "%s %s", fk_name[i] ? fk_name[i] : "??", fk_label[i]); put_columns(outbuf, (int) strlen(outbuf), 16); } } put_newlines(2); } if (funk) { putln("The following keys are not defined:"); for (i = 0; i < funk; ++i) { put_columns(fk_unknown[i], fk_length[i], 16); } put_mode(exit_attribute_mode); put_newlines(2); } if (first_time) { putln("The following keys are defined:"); } else { putln("The following keys have not been tested:"); } if (scan_mode) { for (i = 0; scan_down[i]; i++) { if (!scan_tested[i]) { if (hex_output) { strcpy(outbuf, hex_expand_to(scan_down[i], 3)); } else { strcpy(outbuf, expand(scan_down[i])); } l = expand_chars; if (hex_output) { strcat(outbuf, hex_expand_to(scan_up[i], 3)); } else { strcat(outbuf, expand(scan_up[i])); } expand_chars += l; l = (int) strlen(scan_name[i]); if (((char_count + 16) & ~15) + ((expand_chars + 7) & ~7) + l >= columns) { put_crlf(); } else if (char_count + 24 > columns) { put_crlf(); } else if (char_count) { putchp(' '); } put_columns(outbuf, expand_chars, 16); put_columns(scan_name[i], l, 8); } } } else { for (i = 0; i < key_count; i++) { if (!fk_tested[i] && fk_name[i] != 0) { if (hex_output) { strcpy(outbuf, hex_expand_to(fkval[i], 3)); } else { strcpy(outbuf, expand(fkval[i])); } l = (int) strlen(fk_name[i]); if (((char_count + 16) & ~15) + ((expand_chars + 7) & ~7) + l >= columns) { put_crlf(); } else if (char_count + 24 > columns) { put_crlf(); } else if (char_count) { putchp(' '); } put_columns(outbuf, expand_chars, 16); put_columns(fk_name[i], l, 8); } } } put_newlines(2); if (show_help) { ptextln("Hit any function key. Type 'end' to quit. Type ? to update the display."); put_crlf(); } }
/* ** crum_move(test_list, status, ch) ** ** (*) test all cursor move commands */ static void crum_move( struct test_list *t, int *state, int *ch) { char buf[80]; int n; switch (n = (t->flags & 15)) { case 0: sprintf(buf, " (cr) (nel) (cub1)%s", cursor_home ? " (home)" : (cursor_up ? " (cuu1)" : "")); break; case 1: sprintf(buf, "%s%s%s%s", cursor_left ? " (cub1)" : "", cursor_down ? " (cud1)" : "", cursor_right ? " (cuf1)" : "", cursor_up ? " (cuu1)" : ""); if (buf[0] == '\0') { ptext(" (cub1) (cud1) (cuf1) (cuu1) not defined."); } break; case 2: sprintf(buf, "%s%s%s%s", parm_left_cursor ? " (cub)" : "", parm_down_cursor ? " (cud)" : "", parm_right_cursor ? " (cuf)" : "", parm_up_cursor ? " (cuu)" : ""); if (buf[0] == '\0') { ptext(" (cub) (cud) (cuf) (cuu) not defined."); } break; case 3: sprintf(buf, "%s%s", row_address ? " (vpa)" : "", column_address ? " (hpa)" : ""); if (buf[0] == '\0') { ptext(" (vpa) (hpa) not defined."); } break; case 4: if (!cursor_address) { ptext(" (cup) not defined. "); generic_done_message(t, state, ch); return; } strcpy(buf, " (cup)"); break; } if (buf[0] == '\0') { put_str(" Done. "); } else { can_test(buf, FLAG_TESTED); strcpy(crum_text[n], &buf[2]); crum_text[n][strlen(buf) - 3] = '\0'; display_it(1 << n, buf); } *ch = wait_here(); if (*ch != 'r') { put_clear(); } }