⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fun.c

📁 ncurses-5.4
💻 C
📖 第 1 页 / 共 2 页
字号:
		}		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);}inttty_meta_prep(void){				/* print a warning before the meta key test */	if (not_a_tty) {		return 0;	}	if (initial_stty_query(TTY_8_BIT)) {		return 0;	}	ptext("The meta key test must be run with the");	ptext(" terminal set for 8 data bits.  Two stop bits");	ptext(" may also be needed for correct display.  I will");	ptext(" transmit 8 bit data but if the terminal is set for");	ptextln(" 7 bit data, garbage may appear on the screen.");	return 1;}/***	funkey_meta(test_list, status, ch)****	Test meta key (km) (smm) (rmm)*/static voidfunkey_meta(	struct test_list *t,	int *state,	int *ch){	int i, j, k, len;	char outbuf[256];	if (has_meta_key) {		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);}/***	funkey_label(test_list, status, ch)****	Test labels (nlab) (smln) (pln) (rmln) (lw) (lh)*/static voidfunkey_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(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);}/***	funkey_prog(test_list, status, ch)****	Test program function keys (pfx)*/static voidfunkey_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(pkey_xmit, fk, "abc\n"));		sprintf(temp, "Hit function key %d\n", fk);		ptextln(temp);		for (i = 0; i < 4; ++i)			mm[i] = 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(pkey_xmit, fk, key_f1));		}	} else {		ptextln("Function key transmit (pfx), not present.");	}	generic_done_message(t, state, ch);}/***	funkey_local(test_list, status, ch)****	Test program local function keys (pfloc)*/static voidfunkey_local(	struct test_list *t,	int *state,	int *ch){	int fk;	fk = 1;	if (pkey_local) {		/* 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(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(pkey_xmit, fk, key_f1));		}	} else {		ptextln("Function key execute local (pfloc), not present.");	}	generic_done_message(t, state, ch);}/***	printer_on(test_list, status, ch)****	Test printer on/off (mc4) (mc5) (mc5i)*/static voidprinter_on(	struct test_list *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);}/***	printer_mc0(test_list, status, ch)****	Test screen print (mc0)*/static voidprinter_mc0(	struct test_list *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);}static voidline_pattern(void){				/* put up a pattern that will help count the				   number of lines */	int i, j;	put_clear();	if (over_strike) {		for (i = 0; i < 100; i++) {			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);		}	}}static voidcolumn_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('.');	}}/***	report_help()****	Print the help text for the echo tests*/static voidreport_help(int crx){	ptextln("The following commands may also be entered:");	ptextln(" clear   clear screen.");	ptextln(" columns print a test pattern to help count screen width.");	ptextln(" lines   print a test pattern to help count screen length.");	ptextln(" end     exit.");	ptextln(" echo    redisplay last report.");	if (crx) {		ptextln(" hex     redisplay last report in hex.");	} else {		ptextln(" hex     toggle hex display mode.");	}	ptextln(" help    display this list.");	ptextln(" high    toggle forced high bit (0x80).");	ptextln(" scan    toggle scan mode.");	ptextln(" one     echo one character after <cr> or <lf> as is. (report mode)");	ptextln(" two     echo two characters after <cr> or <lf> as is.");	ptextln(" all     echo all characters after <cr> or <lf> as is. (echo mode)");}/***	tools_report(testlist, state, ch)****	Run the echo tool and report tool*/voidtools_report(	struct test_list *t,	int *state GCC_UNUSED,	int *pch GCC_UNUSED){	int i, j, ch, crp, crx, high_bit, save_scan_mode, hex_display;	char buf[1024];	char txt[8];	hex_display = hex_out;	put_clear();	if ((crx = (t->flags & 255)) == 1) {		ptext("Characters after a CR or LF will be echoed as");		ptextln(" is.  All other characters will be expanded.");		report_help(crx);	} else {	/* echo test */		ptextln("Begin echo test.");		report_help(crx);	}	txt[sizeof(txt) - 1] = '\0';	save_scan_mode = scan_mode;	tty_raw(1, char_mask);	for (i = crp = high_bit = 0;;) {		ch = getchp(char_mask);		if (ch == EOF) {			break;		}		if (i >= (int) sizeof(buf) - 1) {			i = 0;		}		buf[i++] = ch;		buf[i] = '\0';		for (j = 0; j < (int) sizeof(txt) - 1; j++) {			txt[j] = txt[j + 1];		}		txt[sizeof(txt) - 1] = ch & STRIP_PARITY;		if (crx == 0) {	/* echo test */			if (hex_display) {				ptext(hex_expand_to(&buf[i - 1], 3));			} else {				tc_putch(ch | high_bit);			}		} else /* status report test */		if (ch == '\n' || ch == '\r') {			put_crlf();			crp = 0;		} else if (crp++ < crx) {			tc_putch(ch | high_bit);		} else {			put_str(expand(&buf[i - 1]));		}		if (!strncmp(&txt[sizeof(txt) - 7], "columns", 7)) {			column_pattern();			buf[i = 0] = '\0';			crp = 0;		}		if (!strncmp(&txt[sizeof(txt) - 5], "lines", 5)) {			line_pattern();			buf[i = 0] = '\0';			crp = 0;		}		if (!strncmp(&txt[sizeof(txt) - 5], "clear", 5)) {			put_clear();			buf[i = 0] = '\0';			crp = 0;		}		if (!strncmp(&txt[sizeof(txt) - 4], "high", 4)) {			high_bit ^= 0x80;			if (high_bit) {				ptextln("\nParity bit set");			} else {				ptextln("\nParity bit reset");			}		}		if (!strncmp(&txt[sizeof(txt) - 4], "help", 4)) {			put_crlf();			report_help(crx);		}		if (!strncmp(&txt[sizeof(txt) - 4], "echo", 4)) {			/* display the last status report */			/* clear bypass condition on Tek terminals */			put_crlf();			if (i >= 4) {				buf[i -= 4] = '\0';			}			put_str(expand(buf));		}		if (save_scan_mode &&			!strncmp(&txt[sizeof(txt) - 4], "scan", 4)) {			/* toggle scan mode */			scan_mode = !scan_mode;		}		if (!strncmp(&txt[sizeof(txt) - 3], "end", 3))			break;		if (!strncmp(&txt[sizeof(txt) - 3], "hex", 3)) {			if (crx) {				/* display the last status report in hex */				/* clear bypass condition on Tek terminals */				put_crlf();				if (i >= 3) {					buf[i -= 3] = '\0';				}				put_str(hex_expand_to(buf, 3));			} else {				hex_display = !hex_display;			}		}		if (!strncmp(&txt[sizeof(txt) - 3], "two", 3))			crx = 2;		if (!strncmp(&txt[sizeof(txt) - 3], "one", 3))			crx = 1;		if (!strncmp(&txt[sizeof(txt) - 3], "all", 3))			crx = 0;	}	scan_mode = save_scan_mode;	put_crlf();	tty_set();	if (crx) {		ptextln("End of status report test.");	} else {		ptextln("End of echo test.");	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -