示例#1
0
/*
**	funkey_local(test_list, status, ch)
**
**	Test program local function keys (pfloc)
*/
static void
funkey_local(
		TestList * t,
		int *state,
		int *ch)
{
    if (pkey_local) {
	int fk = 1;

	/* test local function key */
	sprintf(temp,
		"(pfloc) Set function key %d to execute a clear and print \"Done!\"", fk);
	ptextln(temp);
	sprintf(temp, "%sDone!", liberated(clear_screen));
	tc_putp(TPARM_2(pkey_local, fk, temp));
	sprintf(temp, "Hit function key %d.  Then hit return.", fk);
	ptextln(temp);
	(void) wait_here();
	flush_input();
	if (key_f1 && pkey_xmit) {
	    tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
	}
    } else {
	ptextln("Function key execute local (pfloc), not present.");
    }

    generic_done_message(t, state, ch);
}
示例#2
0
/*
**	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);
}
示例#3
0
/*
**	funkey_keys(test_list, status, ch)
**
**	Test function keys
*/
static void
funkey_keys(
	       TestList * t,
	       int *state,
	       int *ch)
{
    char keybuf[256];

    if (keypad_xmit) {
	tc_putp(keypad_xmit);
    }
    keys_tested(1, 1, hex_out);	/* also clears screen */
    keybuf[0] = '\0';
    end_state = 0;
    if (scan_mode) {
	fkmax = scan_max;
    }
    tty_raw(0, char_mask);
    while (end_state != 'd') {
	read_key(keybuf, sizeof(keybuf));
	fresh_line();
	if (found_match(keybuf, hex_out, 0)) {
	    continue;
	}
	if (found_exit(keybuf, hex_out, 0)) {
	    break;
	}
    }
    if (keypad_local) {
	tc_putp(keypad_local);
    }
    keys_tested(0, 0, hex_out);
    ptext("Function key test ");
    generic_done_message(t, state, ch);
}
示例#4
0
/*
**	bye_kids(exit-condition)
**
**	Shutdown the terminal, clear the signals, and exit
*/
void
bye_kids(int n)
{				/* reset the tty and exit */
	ignoresig();
	if (send_reset_init) {
		if (exit_ca_mode) {
			tc_putp(exit_ca_mode);
		}
		if (initial_stty_query(TTY_XON_XOFF)) {
			if (enter_xon_mode) {
				tc_putp(enter_xon_mode);
			}
		} else if (exit_xon_mode) {
			tc_putp(exit_xon_mode);
		}
	}
	if (debug_fp) {
		fclose(debug_fp);
	}
	if (log_fp) {
		fclose(log_fp);
	}
	tty_reset();
	fclose(stdin);
	fclose(stdout);
	fclose(stderr);
	if (not_a_tty)
		sleep(1);
	exit(n);
}
示例#5
0
文件: fun.c 项目: SamB/debian-tack
/*
**	funkey_label(test_list, status, ch)
**
**	Test labels (nlab) (smln) (pln) (rmln) (lw) (lh)
*/
static void
funkey_label(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i;
	char outbuf[256];

	if (num_labels == -1) {
		ptextln("Your terminal has no labels. (nlab)");
	} else {
		sprintf(temp, "Your terminal has %d labels (nlab) that are %d characters wide (lw) and %d lines high (lh)",
			num_labels, label_width, label_height);
		ptext(temp);
		ptextln(" Testing (smln) (pln) (rmln)");
		if (label_on) {
			tc_putp(label_on);
		}
		if (label_width <= 0) {
			label_width = sizeof(outbuf) - 1;
		}
		for (i = 1; i <= num_labels; i++) {
			sprintf(outbuf, "L%d..............................", i);
			outbuf[label_width] = '\0';
			tc_putp(TPARM_2(plab_norm, i, outbuf));
		}
		if (label_off) {
			ptext("Hit any key to remove the labels: ");
			(void) wait_here();
			tc_putp(label_off);
		}
	}
	generic_done_message(t, state, ch);
}
示例#6
0
/*
**	funkey_meta(test_list, status, ch)
**
**	Test meta key (km) (smm) (rmm)
*/
static void
funkey_meta(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (has_meta_key) {
	int i, j, k, len;
	char outbuf[256];

	put_crlf();
	if (char_mask != ALLOW_PARITY) {
	    if (tty_meta_prep()) {
		ptext("\nHit any key to continue > ");
		(void) wait_here();
		put_crlf();
	    }
	}
	ptext("Begin meta key test. (km) (smm) (rmm)  Hit any key");
	ptext(" with the meta key.  The character will be");
	ptext(" displayed in hex.  If the meta key is working");
	ptext(" then the most significant bit will be set.  Type");
	ptextln(" 'end' to exit.");
	tty_raw(1, ALLOW_PARITY);
	tc_putp(meta_on);

	for (i = j = k = len = 0; i != 'e' || j != 'n' || k != 'd';) {
	    i = j;
	    j = k;
	    k = getchp(ALLOW_PARITY);
	    if (k == EOF) {
		break;
	    }
	    if ((len += 3) >= columns) {
		put_crlf();
		len = 3;
	    }
	    sprintf(outbuf, "%02X ", k);
	    put_str(outbuf);
	    k &= STRIP_PARITY;
	}
	tc_putp(meta_off);
	put_crlf();
	tty_set();
	put_crlf();
    } else {
	ptext("(km) Has-meta-key is not set.  ");
    }
    generic_done_message(t, state, ch);
}
示例#7
0
/*
**	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);
}
示例#8
0
/*
**	probe_enq_ok()
**
**	does the terminal do enq/ack handshaking?
*/
static void 
probe_enq_ok(void)
{
	int tc, len, ulen;

	put_str("Testing ENQ/ACK, standby...");
	fflush(stdout);
	can_test("u8 u9", FLAG_TESTED);

	tty_ENQ = user9 ? user9 : "\005";
	tc_putp(tty_ENQ);
	event_start(TIME_SYNC);	/* start the timer */
	read_key(tty_ACK, TTY_ACK_SIZE - 1);

	if (event_time(TIME_SYNC) > 400000 || tty_ACK[0] == '\0') {
		/* These characters came from the user.  Sigh. */
		tty_can_sync = SYNC_FAILED;
		ptext("\nThis program expects the ENQ sequence to be");
		ptext(" answered with the ACK character.  This will help");
		ptext(" the program reestablish synchronization when");
		ptextln(" the terminal is overrun with data.");
		ptext("\nENQ sequence from (u9): ");
		putln(expand(tty_ENQ));
		ptext("ACK received: ");
		putln(expand(tty_ACK));
		len = user8 ? strlen(user8) : 0;
		sprintf(temp, "Length of ACK %d.  Expected length of ACK %d.",
			(int) strlen(tty_ACK), len);
		ptextln(temp);
		if (len) {
			temp[0] = user8[len - 1];
			temp[1] = '\0';
			ptext("Terminating character found in (u8): ");
			putln(expand(temp));
		}
		return;
	}

	tty_can_sync = SYNC_TESTED;
	if ((len = strlen(tty_ACK)) == 1) {
		/* single character acknowledge string */
		ACK_terminator = tty_ACK[0];
		ACK_length = 4096;
		return;
	}
	tc = tty_ACK[len - 1];
	if (user8) {
		ulen = strlen(user8);
		if (tc == user8[ulen - 1]) {
			/* ANSI style acknowledge string */
			ACK_terminator = tc;
			ACK_length = 4096;
			return;
		}
	}
	/* fixed length acknowledge string */
	ACK_length = len;
	ACK_terminator = -2;
}
示例#9
0
void
put_name(const char *cap, const char *name)
{				/* send the cap name followed by the cap */
	if (cap) {
		ptext(name);
		tc_putp(cap);
	}
}
示例#10
0
/*
**	subtest_msgr(test_list, status, ch)
**
**	(msgr) move in sgr mode
*/
static void
subtest_msgr(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i;

	if (cursor_address &&
		((enter_standout_mode && exit_standout_mode) ||
		(enter_alt_charset_mode && exit_alt_charset_mode))) {
		put_crlf();
		i = line_count + 1;
		tputs(tparm(cursor_address, i, 0), lines, tc_putch);
		put_mode(enter_alt_charset_mode);
		put_crlf();
		/*
		   some versions of the wy-120 can not clear lines or
		   screen when in alt charset mode.  If (el) and (ed)
		   are defined then I can test them.  If they are not
		   defined then they can not break (msgr)
		*/
		tc_putp(clr_eos);
		tc_putp(clr_eol);
		put_mode(exit_alt_charset_mode);
		put_mode(enter_standout_mode);
		putchp('X');
		tputs(tparm(cursor_address, i + 2, 1), lines, tc_putch);
		putchp('X');
		tputs(tparm(cursor_address, i + 3, 2), lines, tc_putch);
		putchp('X');
		tputs(tparm(cursor_address, i + 4, 3), lines, tc_putch);
		putchp('X');
		put_mode(exit_standout_mode);
		put_crlf();
		tc_putp(clr_eos);	/* OK if missing */
		put_crlf();
		ptextln("If you see a diagonal line of standout X's then (msgr) should be true.  If any of the blanks are standout then (msgr) should be false.");
		sprintf(temp, "(msgr) Move-in-SGR-mode is %s in the data base",
			move_standout_mode ? "true" : "false");
		ptextln(temp);
	} else {
		ptextln("(smso) (rmso) (smacs) (rmacs) missing; (msgr) Move-in-SGR-mode not tested.");
	}
	generic_done_message(t, state, ch);
}
示例#11
0
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (pkey_xmit) {
	int i;
	int fk = 1;
	char mm[256];

	/* test program function key */
	sprintf(temp,
		"(pfx) Set function key %d to transmit abc\\n", fk);
	ptextln(temp);
	tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
	sprintf(temp, "Hit function key %d\n", fk);
	ptextln(temp);

	memset(mm, 0, (size_t) 4);
	for (i = 0; i < 4; ++i) {
	    int cc = getchp(STRIP_PARITY);
	    if (cc == EOF)
		break;
	    mm[i] = (char) cc;
	}
	mm[i] = '\0';

	put_crlf();
	if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
	    sprintf(temp, "Error string received was: %s", expand(mm));
	    ptextln(temp);
	} else {
	    putln("Thank you\n");
	}
	flush_input();
	if (key_f1) {
	    tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
	}
    } else {
	ptextln("Function key transmit (pfx), not present.");
    }
    generic_done_message(t, state, ch);
}
示例#12
0
int
getchp(int mask)
{				/* read a character with scan mode conversion */
	if (scan_mode) {
		tc_putp(req_for_input);
		fflush(stdout);
		return scan_key();
	} else
		return getnext(mask);
}
示例#13
0
/*
**	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);
}
示例#14
0
/*
**	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);
}
示例#15
0
/*
**	ucprint(string)
**
**	underline string for (uc) test
*/
static void
ucprint(const char *s)
{
	if (s) {
		while (*s) {
			putchp(*s++);
			putchp('\b');
			tc_putp(underline_char);
		}
	}
}
示例#16
0
/*
**	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);
	}
}
示例#17
0
/*
**	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);
}
示例#18
0
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");
	}
    }
}
示例#19
0
/*
**	printer_on(test_list, status, ch)
**
**	Test printer on/off (mc4) (mc5) (mc5i)
*/
static void
printer_on(
	      TestList * t,
	      int *state,
	      int *ch)
{
    if (!prtr_on || !prtr_off) {
	ptextln("Printer on/off missing. (mc5) (mc4)");
    } else if (prtr_silent) {
	ptextln("Your printer is silent. (mc5i) is set.");
	tc_putp(prtr_on);
	ptextln("This line should be on the printer but not your screen. (mc5)");
	tc_putp(prtr_off);
	ptextln("This line should be only on the screen. (mc4)");
    } else {
	ptextln("Your printer is not silent. (mc5i) is reset.");
	tc_putp(prtr_on);
	ptextln("This line should be on the printer and the screen. (mc5)");
	tc_putp(prtr_off);
	ptextln("This line should only be on the screen. (mc4)");
    }
    generic_done_message(t, state, ch);
}
示例#20
0
文件: fun.c 项目: SamB/debian-tack
/*
**	funkey_prog(test_list, status, ch)
**
**	Test program function keys (pfx)
*/
static void
funkey_prog(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, fk;
	char mm[256];

	fk = 1;	/* use function key 1 for now */
	if (pkey_xmit) {
		/* test program function key */
		sprintf(temp,
			"(pfx) Set function key %d to transmit abc\\n", fk);
		ptextln(temp);
		tc_putp(TPARM_2(pkey_xmit, fk, "abc\n"));
		sprintf(temp, "Hit function key %d\n", fk);
		ptextln(temp);
		for (i = 0; i < 4; ++i)
			mm[i] = (char) getchp(STRIP_PARITY);
		mm[i] = '\0';
		put_crlf();
		if (mm[0] != 'a' || mm[1] != 'b' || mm[2] != 'c') {
			sprintf(temp, "Error string received was: %s", expand(mm));
			ptextln(temp);
		} else {
			putln("Thank you\n");
		}
		flush_input();
		if (key_f1) {
			tc_putp(TPARM_2(pkey_xmit, fk, key_f1));
		}
	} else {
		ptextln("Function key transmit (pfx), not present.");
	}
	generic_done_message(t, state, ch);
}
示例#21
0
/*
**	printer_mc0(test_list, status, ch)
**
**	Test screen print (mc0)
*/
static void
printer_mc0(
	       TestList * t,
	       int *state,
	       int *ch)
{
    if (print_screen) {
	ptext("I am going to send the contents of the screen to");
	ptext(" the printer, then wait for a keystroke from you.");
	ptext("  All of the text that appears on the screen");
	ptextln(" should be printed. (mc0)");
	tc_putp(print_screen);
    } else {
	ptext("(mc0) Print-screen is not present.  ");
    }
    generic_done_message(t, state, ch);
}
示例#22
0
int
getnext(int mask)
{				/* get the next character without scan mode
				   conversion */
	int ch;
	unsigned char buf;

	tc_putp(req_for_input);
	fflush(stdout);
	if (nodelay_read)
		while (1) {
			ch = read(fileno(stdin), &buf, 1);
			if (ch == -1)
				return EOF;
			if (ch == 1)
				return buf;
		}
	ch = getchar();
	if (ch == EOF)
		return EOF;
	return ch & mask;
}
示例#23
0
/*
**	subtest_bw(test_list, status, ch)
**
**	test auto left margin (bw)
*/
static void
subtest_bw(
	struct test_list *t,
	int *state,
	int *ch)
{
	int i, j;

	if (over_strike) {
		/* test (bw) */
		ptext("\n(bw) should ");
		i = char_count;
		ptextln("not be set.");
		for (j = i; j < columns; j++)
			put_str("\b");
		put_str("@@@");
		put_crlf();
		sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
			auto_left_margin ? "true" : "false");
		ptextln(temp);
	} else {
		/* test (bw) */
		ptextln("(bw) should not be set.");
		for (i = 12; i < columns; i++)
			put_str("\b");
		if (delete_character) {
			for (i = 0; i < 4; i++)
				tc_putp(delete_character);
		} else {
			put_str("   ");
		}
		put_crlf();
		sprintf(temp, "(bw) Auto-left-margin is %s in the data base",
			auto_left_margin ? "true" : "false");
		ptextln(temp);
	}
	generic_done_message(t, state, ch);
}
示例#24
0
/*
**	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);
}
示例#25
0
/*
**	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);
}
示例#26
0
/*
**	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();
}
示例#27
0
/*
**	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++;
		}
	}
}
示例#28
0
/*
**	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);
}
示例#29
0
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);
}