/* ** subtest_xt(test_list, status, ch) ** ** (xt) glitch */ static void subtest_xt( struct test_list *t, int *state, int *ch) { int tabat; /* the tab spacing we end up with */ int cc; tabat = set_tab ? 8 : init_tabs; if (!over_strike && (tabat > 0)) { ptext("(xt) should not "); put_cr(); ptext("(xt) should"); cc = char_count; while (cc < 16) { putchp('\t'); cc = ((cc / tabat) + 1) * tabat; } putln("be set."); sprintf(temp, "(xt) Destructive-tab is %s in the data base.", dest_tabs_magic_smso ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
/* ** subtest_os(test_list, status, ch) ** ** test over strike mode (os) */ static void subtest_os( struct test_list *t, int *state, int *ch) { ptext("(os) should be true, not false."); put_cr(); ptextln("(os) should be false."); sprintf(temp, "(os) over-strike is %s in the data base. ", over_strike ? "true" : "false"); ptext(temp); generic_done_message(t, state, ch); }
static void fresh_line(void) { /* clear the line for a new function key line */ if (over_strike) { put_crlf(); } else { put_cr(); if (clr_eol) { tc_putp(clr_eol); } else { put_str(" \r"); } } }
/* ** 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. "); }
/* ** putchp(character) ** ** Send one character to the terminal. ** This function does translation of control characters. */ void putchp(int c) { switch (c) { case '\b': if (translate_mode && cursor_left) { tt_putp(cursor_left); } else { tt_putp(TM_cursor_left); } char_count--; break; case 7: if (translate_mode && bell) { tt_putp(bell); } else { tt_putp(TM_bell); } break; case '\f': if (translate_mode && form_feed) { tt_putp(form_feed); } else { tt_putp(TM_form_feed); } char_count = 0; line_count++; break; case '\n': put_crlf(); break; case '\r': put_cr(); break; case '\t': if (translate_mode && tab) { tt_putp(tab); } else { tt_putp(TM_tab); } char_count = ((char_count / 8) + 1) * 8; break; default: put_this(c); char_count++; break; } }
/* ** subtest_xhp(test_list, status, ch) ** ** (xhp) erase does not clear standout mode */ static void subtest_xhp( struct test_list *t, int *state, int *ch) { if (enter_standout_mode) { put_crlf(); put_mode(enter_standout_mode); put_str("Stand out"); put_mode(exit_standout_mode); put_cr(); ptextln("If any part of this line is standout then (xhp) should be set."); sprintf(temp, "(xhp) Erase-standout-glitch is %s in the data base", ceol_standout_glitch ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
/* ** subtest_eo(test_list, status, ch) ** ** (eo) erase overstrike */ static void subtest_eo( struct test_list *t, int *state, int *ch) { if (transparent_underline || over_strike || underline_char) { ptext("(eo) should "); if (underline_char) { ucprint("not"); } else { uprint("not"); } put_cr(); ptextln("(eo) should be set"); sprintf(temp, "\n(eo) Erase-overstrike is %s in the data base", erase_overstrike ? "true" : "false"); ptextln(temp); generic_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); } }
/* ** 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); }
void reset_init(void) { /* send the reset and init strings */ int i; ptext("Terminal reset"); i = char_count; put_name(reset_1string, " (rs1)"); put_name(reset_2string, " (rs2)"); /* run the reset file */ if (reset_file && reset_file[0]) { FILE *fp; int ch; can_test("rf", FLAG_TESTED); if ((fp = fopen(reset_file, "r"))) { /* send the reset file */ sprintf(temp, " (rf) %s", reset_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open reset file (rf) %s", reset_file); ptextln(temp); } } put_name(reset_3string, " (rs3)"); if (i != char_count) { put_crlf(); } ptext(" init"); put_name(init_1string, " (is1)"); put_name(init_2string, " (is2)"); if (set_tab && clear_all_tabs && init_tabs != 8) { put_crlf(); tc_putp(clear_all_tabs); for (char_count = 0; char_count < columns; char_count++) { put_this(' '); if ((char_count & 7) == 7) { tc_putp(set_tab); } } put_cr(); } /* run the initialization file */ if (init_file && init_file[0]) { FILE *fp; int ch; can_test("if", FLAG_TESTED); if ((fp = fopen(init_file, "r"))) { /* send the init file */ sprintf(temp, " (if) %s", init_file); ptextln(temp); while (1) { ch = getc(fp); if (ch == EOF) break; put_this(ch); } fclose(fp); } else { sprintf(temp, "\nCannot open init file (if) %s", init_file); ptextln(temp); } } if (init_prog) { can_test("iprog", FLAG_TESTED); (void) system(init_prog); } put_name(init_3string, " (is3)"); fflush(stdout); }
static int found_exit(char *keybuf, int hx, int cc) { /* return true if the user wants to exit */ int j; char *s; if (scan_mode) { if (*keybuf == '\0') { return TRUE; } } else { int k; /* break is a special case */ if (*keybuf == '\0') { fresh_line(); tty_set(); ptext("Hit X to exit: "); if (wait_here() == 'X') { return TRUE; } keys_tested(0, 1, hx); tty_raw(cc, char_mask); return FALSE; } /* is this the end? */ for (k = 0; (j = (keybuf[k] & STRIP_PARITY)); k++) { if (end_funky(j)) { return TRUE; } } j = TRUE; /* does he need an updated list? */ for (k = 0; keybuf[k]; k++) { j &= (keybuf[k] & STRIP_PARITY) == '?'; } if (j || end_state == '?') { keys_tested(0, 1, hx); tty_raw(cc, char_mask); end_state = 0; return FALSE; } } put_cr(); if (hx) { s = hex_expand_to(keybuf, 10); } else { s = expand_to(keybuf, 10); } sprintf(temp, "%s Unknown", s); put_str(temp); for (j = 0; j < MAX_FK_UNK; j++) { if (j == funk) { fk_length[funk] = expand_chars; if ((fk_unknown[funk] = (char *) malloc(strlen(s) + 1))) { strcpy(fk_unknown[funk++], s); } break; } if (fk_length[j] == expand_chars) { if (!strcmp(fk_unknown[j], s)) { break; } } } return FALSE; }
static int found_match(char *s, int hx, int cc) { /* return true if this string is a match */ int j, f; alloc_strings(); if (!*s) { return 0; } if (scan_mode) { for (j = f = 0; scan_down[j]; j++) { if (scan_length[j] == 0) { continue; } if (!strncmp(s, scan_down[j], scan_length[j])) { if (!f) { /* first match */ put_cr(); if (hx) { put_str(hex_expand_to(s, 10)); } else { put_str(expand_to(s, 10)); } f = 1; } (void) end_funky(scan_name[j][0]); put_str(" "); put_str(scan_name[j]); scan_tested[j] = 1; s += scan_length[j]; if (strncmp(s, scan_up[j], scan_length[j])) { put_str(" scan down"); } else { s += scan_length[j]; } if (!*s) { break; } j = -1; } if (!strncmp(s, scan_up[j], scan_length[j])) { if (!f) { /* first match */ put_cr(); if (hx) { put_str(hex_expand_to(s, 10)); } else { put_str(expand_to(s, 10)); } f = 1; } put_str(" "); put_str(scan_name[j]); put_str(" scan up"); s += scan_length[j]; if (!*s) { break; } j = -1; } } } else { for (j = f = 0; j < key_count; j++) { if (fkval[j] && !strcmp(s, fkval[j])) { char outbuf[256]; if (!f) { /* first match */ put_cr(); if (hx) { put_str(hex_expand_to(s, 10)); } else { put_str(expand_to(s, 10)); } f = 1; } sprintf(outbuf, " (%s)", fk_name[j]); put_str(outbuf); if (fk_label[j]) { sprintf(outbuf, " <%s>", fk_label[j]); put_str(outbuf); } fk_tested[j] = 1; } } } if (end_state == '?') { keys_tested(0, 1, hx); tty_raw(cc, char_mask); end_state = 0; } return f; }
/* ** 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++; } } }