/* ** uprint(string) ** ** underline string for (ul) test */ static void uprint(const char *s) { if (s) { while (*s) { put_str("_\b"); putchp(*s++); } } }
/* ** 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_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); }
/* ** subtest_tbc(test_list, status, ch) ** ** test clear tabs (tbc) */ static void subtest_tbc( struct test_list *t, int *state, int *ch) { int tabat; /* the tab spacing we end up with */ int i; if (clear_all_tabs && !set_tab) { ptext("(tbc) Clear-all-tabs is defined but (hts) set-tab is not. "); ptext("Once the tabs are cleared there is no way to set them. "); } else if (clear_all_tabs) { tabat = set_tab ? 8 : init_tabs; tc_putp(clear_all_tabs); ptext("Clear tabs (tbc)"); go_home(); put_crlf(); putchp('\t'); putchp('T'); go_home(); put_newlines(2); for (i = 0; i < columns; i++) { if (i == tabat) { putchp('T'); } else { putchp('.'); } } go_home(); ptext("\n\n\nIf the above two lines have T's in the same column then (tbc) has failed. "); } else { ptext("(tbc) Clear-all-tabs is not defined. "); } generic_done_message(t, state, ch); }
static void report_cap(const char *tag, const char *s) { /* expand the cap or print *** missing *** */ int i; ptext(tag); for (i = char_count; i < 13; i++) { putchp(' '); } put_str(" = "); if (s) { putln(expand(s)); } else { putln("*** missing ***"); } }
/* ** ptext(string) ** ** Output a string but do not assume the terminal will wrap to a ** new line. Break the line at a word boundary then send a CR LF. ** This is more esthetic on 40 column terminals. */ void ptext(const char *s) { const char *t; while (*s) { for (t = s + 1; *t > ' '; t++); if ((char_count != 0) && ((t - s) + char_count >= columns)) { put_crlf(); while (*s == ' ') s++; } while (s < t) { putchp(*s++); } } }
/* ** pad_standard(test_list, status, ch) ** ** Run a single cap pad test. */ static void pad_standard( struct test_list *t, int *state, int *ch) { const char *long_name; char *cap; int l = 2, i; char tbuf[128]; if ((cap = get_string_cap_byname(t->caps_done, &long_name))) { sprintf(tbuf, "(%s) %s, start testing", t->caps_done, long_name); if (skip_pad_test(t, state, ch, tbuf)) { return; } i = 1; pad_test_startup(1); do { if (i >= columns) { page_loop(); l++; i = 1; } tt_putp(cap); putchp(letter); i++; } while(still_testing()); pad_test_shutdown(t, 0); if (l >= lines) { home_down(); } else { put_crlf(); } ptextln(no_visual); } else { CAP_NOT_FOUND; /* Note: get_string_cap_byname() always sets long_name */ sprintf(temp, "(%s) %s, not present. ", t->caps_done, long_name); ptext(temp); } pad_done_message(t, state, ch); }
/* ** subtest_in(test_list, status, ch) ** ** (in) insert null glitch */ static void subtest_in( struct test_list *t, int *state, int *ch) { if (enter_insert_mode && exit_insert_mode) { ptextln("\nTesting (in) with (smir) and (rmir)"); putln("\tIf these two lines line up ..."); put_str("\tIf these two lines line up ..."); put_cr(); tc_putp(enter_insert_mode); putchp(' '); tc_putp(exit_insert_mode); ptext("\nthen (in) should be set. "); sprintf(temp, "(in) Insert-null-glitch is %s in the data base.", insert_null_glitch ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
void put_columns(const char *s, int len, int w) { /* put out s in column format */ int l; if (char_count + w > columns) { put_crlf(); } l = char_count % w; if (l) { while (l < w) { putchp(' '); l++; } } if (char_count && char_count + len >= columns) { put_crlf(); } l = char_count; put_str(s); char_count = l + len; }
/* ** 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); }
/* ** subtest_hts(test_list, status, ch) ** ** (ht) and set tabs with (hts) */ static void subtest_hts( struct test_list *t, int *state, int *ch) { int tabat; /* the tab spacing we end up with */ int i; tabat = init_tabs; if (set_tab) { ptext("Tabs set with (hts)"); put_crlf(); for (i = 1; i < columns; i++) { if (i % 8 == 1) { tc_putp(set_tab); } putchp(' '); } tabat = 8; } else { sprintf(temp, "(hts) Set-tabs not defined. (it) Initial-tabs at %d", init_tabs); ptext(temp); } go_home(); put_newlines(2); if (tabat <= 0) { tabat = 8; } for (i = tabat; i < columns; i += tabat) { putchp('\t'); putchp('T'); } go_home(); put_newlines(3); for (i = 1; i < columns; i++) { putchp('.'); } go_home(); put_newlines(3); for (i = tabat; i < columns; i += tabat) { putchp('\t'); putchp('T'); } go_home(); put_newlines(4); putchp('.'); for (i = 2; i < columns; i++) { if (i % tabat == 1) { putchp('T'); } else { putchp('.'); } } go_home(); put_newlines(5); if (set_tab) { ptextln("If the last two lines are not the same then (hts) has failed."); } else if (init_tabs > 0) { ptextln("If the last two lines are not the same then (it) is wrong."); } else { ptextln("If the last two lines are the same then maybe you do have tabs and (it) should be changed."); } generic_done_message(t, state, ch); }
/* ** 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(); } }
void putln(const char *s) { /* output a string followed by a CR LF */ for (; *s; putchp(*s++)); put_crlf(); }
void put_str(const char *s) { /* send the string to the terminal */ for (; *s; putchp(*s++)); }
/* ** move_to(from-row, from-column, to-row, to-column, selection) ** ** move the cursor from (rf, cf) to (rt, ct) using sel */ static void move_to( int rf, int cf, int rt, int ct, int sel) { char *s; if (sel & 16) { /* use (cup) */ s = TPARM_2(cursor_address, rt, ct); tputs(s, lines, tc_putch); return; } if (sel & 8) { /* use (hpa) (vpa) */ if (column_address) { s = TPARM_1(column_address, ct); tputs(s, 1, tc_putch); cf = ct; } if (row_address) { s = TPARM_1(row_address, rt); tputs(s, 1, tc_putch); rf = rt; } } if (sel & 4) { /* parameterized relative cursor movement */ if (parm_right_cursor) if (cf < ct) { s = TPARM_1(parm_right_cursor, ct - cf); tputs(s, ct - cf, tc_putch); cf = ct; } if (parm_left_cursor) if (cf > ct) { s = TPARM_1(parm_left_cursor, cf - ct); tputs(s, cf - ct, tc_putch); cf = ct; } if (parm_down_cursor) if (rf < rt) { s = TPARM_1(parm_down_cursor, rt - rf); tputs(s, rt - rf, tc_putch); rf = rt; } if (parm_up_cursor) if (rf > rt) { s = TPARM_1(parm_up_cursor, rf - rt); tputs(s, rf - rt, tc_putch); rf = rt; } } if (sel & 2) { if (cursor_left) while (cf > ct) { tc_putp(cursor_left); cf--; } /* do vertical motion next. Just in case cursor_down has a side effect of changing the column. This could happen if the tty handler translates NL to CRNL. */ if (cursor_down) while (rf < rt) { tc_putp(cursor_down); rf++; } if (cursor_up) while (rf > rt) { tc_putp(cursor_up); rf--; } if (cursor_right) while (cf < ct) { tc_putp(cursor_right); cf++; } } /* last chance */ if (rf > rt) { if (can_go_home) { /* a bit drastic but ... */ go_home(); cf = 0; rf = 0; } else if (cursor_up) { while (rf > rt) { tc_putp(cursor_up); rf--; } } } if (ct == 0 && rt > rf) { put_crlf(); cf = 0; rf++; } if (ct == 0 && cf != 0) { put_cr(); cf = 0; } while (rf < rt) { put_lf(); rf++; } while (cf > ct) { put_str("\b"); cf--; } if (cursor_right) { while (cf < ct) { tc_putp(cursor_right); cf++; } } else { /* go ahead and trash my display */ while (cf < ct) { putchp(' '); cf++; } } }