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

📄 testterminfo.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*	Copyright (c) 1984 AT&T	*//*	  All Rights Reserved  	*//*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*//*	The copyright notice above does not evidence any   	*//*	actual or intended publication of such source code.	*/#ifndef lintstatic	char sccsid[] = "@(#)testterminfo.c 1.1 92/07/30 SMI"; /* from S5R3 1.9 */#endif/*    Terminfo entry tester.  Exercises terminal capabilities as defined in    the terminfo entry to test their definition and use.    Original program by Alan Robertson    Further modified by Tony Hansen and Ernie Rice.    Originally based on a similar program written by Warren Montgomery    for testing his terminal database.sanity tests to add:    auto_left_margin w/o cursor_left    tabs    status line    The following characteristics are not tested yet.    The starred ones probably won't every be.    bools	auto_left_margin	beehive_glitch	ceol_standout_glitch	eat_newline_glitch	* generic_type	* hardcopy	has_meta_key	move_insert_mode	move_standout_mode	* overstrike	* teleray_glitch	* tilde_glitch	* xon_xoff    ints	init_tabs	lines_of_memory	* padding_baud_rate	* virtual_terminal    strings	back_tab	clear_all_tabs	* command_character	cursor_invisible	cursor_mem_address	cursor_normal	cursor_visible	* down_half_line	* enter_secure_mode	* enter_proteced_mode	* form_feed	init_?string	init_file	insert_padding	key_*	keypad_local	keypad_xmit	lab_f*	* meta_off	* meta_on	newline	pad_char	pkey_key	pkey_local	* print_screen	* prtr_off	* prtr_on	reset_?string	reset_file	restore_cursor	save_cursor	set_tab	* set_window	tab	underline_char	* up_half_line	* init_prog	* prtr_non	* char_padding	* acs_chars*/#include <stdio.h>#include <signal.h>#include <curses.h>#include <term.h>extern char *getenv();extern char *tparm();extern void exit();extern unsigned sleep();int	manual = 1;/* The exiting routine */onintr(sig)int sig;{	(void) signal(SIGINT, SIG_DFL);	(void) signal(SIGQUIT, SIG_DFL);	(void) signal(SIGHUP, SIG_DFL);	if (exit_ca_mode) {		printf("testing exit_ca_mode");		(void) fflush(stdout);		(void) getchar();		putp(exit_ca_mode);		printf("exited ca mode\r\n");		(void) fflush(stdout);	}	reset_shell_mode();	printf("\n\n");	if (sig == 0) printf("Exiting normally.\n");	exit(0);}/* Pause a moment for the user to see the results. */int pause_for_input(){	int ch;	(void) fflush(stdout);	if (manual) ch = getchar();	else ch = ' ';	if (ch == 'q' || ch == 'Q') onintr(0);	return ch;}/* clear the screen the stupid way, assuming nothing */void dumb_clear_screen(){	register int i;	printf("\r");	for (i=0; i <= lines + 10;i++) printf("\n\r");	(void) fflush(stdout);}/* clear the screen */void clearscreen(){	if (clear_screen) putp(clear_screen);	else if (cursor_home && clr_eos) {		putp(cursor_home);		putp(clr_eos);	}	else dumb_clear_screen();}/* move the cursor to the given coordinates, but don't assume as much *//* about what's available for use */void dumb_gocurs(x, y)register int x, y;{	if (cursor_address) putp(tparm(cursor_address, x, y));	else if (cursor_home && cursor_down && cursor_right) {		putp(cursor_home);		while (--y) putp(cursor_down);		while (--x) putp(cursor_right);	}	else {		printf("Cannot perform dumb_gocurs\n\r");		(void) fflush(stdout);	}}/* move the cursor to the given coordinates, doing it somewhat optimally */void gocurs(x, y)register int x, y;{	if (cursor_address) putp(tparm(cursor_address, x, y));	else if (column_address && row_address) {		putp(tparm(column_address, y));		putp(tparm(row_address, x));	}	else if (cursor_home &&		(cursor_down || parm_down_cursor || column_address) &&		(cursor_right || parm_right_cursor || row_address) ) {		putp(cursor_home);		if (parm_down_cursor) {			if (y > 0) putp(tparm(parm_down_cursor, y-1));		}		else if (column_address) putp(tparm(column_address, y));		else while (--y) putp(cursor_down);		if (parm_right_cursor) {			if (x > 0) putp(tparm(parm_right_cursor, x-1));		}		else if (row_address) putp(tparm(row_address, x));		else while (--x) putp(cursor_right);	}	else dumb_gocurs(x,y);}/* move the cursor home, using only home or cursor_address */void gohome(){	if (cursor_home) putp(cursor_home);	else if (cursor_address) putp(tparm(cursor_address, 0, 0));}/* Underline the string. */void uprint(sp)register char *sp;{	if (cursor_left)		while (*sp) {			(void) putchar('_');			putp(cursor_left);			(void) putchar(*sp++);		}	else {		printf("Cannot perform uprint without cursor_left\r\n");		(void) fflush(stdout);	}}/* test insert/delete line */void tst_idline(){	register int i;again:	if (insert_line) {		clearscreen();		for(i = 0; i < lines; i++) {			gocurs(i,0);			printf("Line %d",i);		}				gocurs(0,10);		printf("inserting 5 lines after line 2");		gocurs(3,10);		for(i = 0; i < 5; i++) putp(insert_line);		if (pause_for_input() == 'r') goto again;	}	if (delete_line) {		gocurs(0,10);		printf("deleting 5 lines after line 2...");		gocurs(3,10);		for(i = 0; i < 5; i++) putp(delete_line);		gocurs(3,10);		if (memory_below)			printf("the last line number should(may) be > %d",lines-6);		else			printf("the last line number must be = %d",lines-6);		if (pause_for_input() == 'r') goto again;	}	(void) fflush(stdout);}/* test parameterized insert/delete line */void tst_Pidline(){	register int i;again:	if (parm_insert_line) {		clearscreen();		for(i = 0; i < lines; i++) {			gocurs(i, 0);			printf("Line %d", i);		}		gocurs(0, 10);		printf("inserting 5 lines after line 2(using parm_insert_line)");		gocurs(3, 10);		putp(tparm(parm_insert_line, 5));		if (pause_for_input() == 'r') goto again;	}	if (parm_delete_line) {		gocurs(0, 10);		printf("deleting 5 lines after line 2	(using parm_delete_line)");		gocurs(3, 10);		putp(tparm(parm_delete_line, 5));		gocurs(3, 10);		if (memory_below) printf("the last line number should(may) be > %d", lines - 6);		else printf("the last line number must be = %d", lines - 6);		if (pause_for_input() == 'r') goto again;	}}/* test scrolling forward and reverse */void tst_scroll(top, bot, pause)register int top, bot;int pause;{	register int i, fullscreen =(top == 0) &&(bot == lines - 1);again:	if (scroll_forward) {		clearscreen();		gocurs(bot, 0);		printf("scrolling");		putp(scroll_forward);		gocurs(bot, 0);		printf("up");		putp(scroll_forward);		gocurs(bot, 0);		printf("the");		putp(scroll_forward);		gocurs(bot, 0);		printf("screen");		for(i = 0; i < bot -(top + 3); ++i) {			gocurs(bot, 0);			putp(scroll_forward);		}		if (pause_for_input() == 'r') goto again;	}	if (scroll_reverse) {		gocurs(10, 0);		printf("reverse scrolling");		gocurs(top, 0);		putp(scroll_reverse);		gocurs(top, 0);		putp(scroll_reverse);		gocurs(10, 0);		if (scroll_forward && memory_above && fullscreen) printf("the message should(may) have returned");		else {			if (fullscreen)			printf("the top 2 lines must be blank.");			else			printf("the top 2 lines in the scrolling region must be blank");		}		if (pause_for_input() == 'r' && pause) goto again;	}}/* test change scrolling region */void tst_csr(){    register int top, bot;again:	top = 2;	bot = lines - 3;	if (change_scroll_region &&(scroll_forward || scroll_reverse)) {		clearscreen();		gocurs(0, 0);		printf("test change scrolling region");		gocurs(top - 1, 0);		printf("this line won't scroll");		gocurs(bot + 1, 0);		printf("neither will this one");		putp(tparm(change_scroll_region, top, bot));		tst_scroll(top, bot);		putp(tparm(change_scroll_region, 0, lines - 1));		if (pause_for_input() == 'r') goto again;	}}/* test attribute settings */void tst_attr(){    register int nextline;    char tempbuffer[80];again:	nextline = 1;	tempbuffer[0] = '\0';	clearscreen();	printf("testing font changes");	if (enter_standout_mode) {		gocurs(nextline++, 0);		putp(enter_standout_mode);		printf("standout text");		putp(exit_standout_mode);	}	if (enter_underline_mode) {		gocurs(nextline++, 0);		putp(enter_underline_mode);		printf("underlined text");		putp(exit_underline_mode);	}	if (enter_bold_mode) {		gocurs(nextline++, 0);		putp(enter_bold_mode);		printf("bold text");		putp(exit_attribute_mode);	}	if (enter_blink_mode) {		gocurs(nextline++, 0);		putp(enter_blink_mode);		printf("blinking  text");		putp(exit_attribute_mode);	}	if (enter_dim_mode) {		gocurs(nextline++, 0);		putp(enter_dim_mode);		printf("dim witted text");		putp(exit_attribute_mode);	}	if (enter_reverse_mode) {		gocurs(nextline++, 0);		putp(enter_reverse_mode);		printf("Reverse Video Text");		putp(exit_attribute_mode);	}	if (enter_alt_charset_mode) {		gocurs(nextline++, 0);		putp(enter_alt_charset_mode);		printf("alternate");		putp(exit_alt_charset_mode);	}	/* Now all in the same line */	gocurs(nextline++, 0);	if (enter_standout_mode) {		putp(enter_standout_mode);		printf("standout");		(void) strcat(tempbuffer, "standout");		putp(exit_standout_mode);	}	if (enter_underline_mode) {		putp(enter_underline_mode);		printf("underlined");		(void) strcat(tempbuffer, "underlined");		putp(exit_underline_mode);	}	if (enter_bold_mode) {		putp(enter_bold_mode);		printf("bold");		(void) strcat(tempbuffer, "bold");		putp(exit_attribute_mode);	}	if (enter_blink_mode) {		putp(enter_blink_mode);		printf("blinking");		(void) strcat(tempbuffer, "blinking");		putp(exit_attribute_mode);	}	if (enter_dim_mode) {		putp(enter_dim_mode);		printf("dim");		(void) strcat(tempbuffer, "dim");		putp(exit_attribute_mode);	}	if (enter_reverse_mode) {		putp(enter_reverse_mode);		printf("Reverse");		(void) strcat(tempbuffer, "Reverse");		putp(exit_attribute_mode);	}	if (enter_alt_charset_mode) {		putp(enter_alt_charset_mode);		printf("alternate");		(void) strcat(tempbuffer, "alternate");		putp(exit_alt_charset_mode);	}	gocurs(nextline++, 0);	printf(tempbuffer);	if (set_attributes) {		gocurs(nextline++, 0);		printf("with sgr:");		putp(tparm(set_attributes,1,0,0,0,0,0,0,0,0));/* 1 = 3+5 */		printf("standout,");		putp(tparm(set_attributes,0,1,0,0,0,0,0,0,0));/* 2 */		printf("underline,");		putp(tparm(set_attributes,0,0,1,0,0,0,0,0,0));/* 3 */		printf("reverse,");		putp(tparm(set_attributes,0,0,0,1,0,0,0,0,0));/* 4 */		printf("blink,");		putp(tparm(set_attributes,0,0,0,0,1,0,0,0,0));/* 5 */		printf("dim,");		putp(tparm(set_attributes,0,0,0,0,0,1,0,0,0));/* 6 = 3+5 */		printf("bold,");		putp(tparm(set_attributes,0,0,0,0,0,0,1,0,0));/* 7 */		printf("invis,");		putp(tparm(set_attributes,0,0,0,0,0,0,0,1,0));/* 8 */		printf("protect,");		putp(tparm(set_attributes,0,0,0,0,0,0,0,0,1));/* 9 */		printf("altchar,");		putp(tparm(set_attributes,0,0,0,0,0,0,0,0,0));		printf("off");		gocurs(nextline++, 0);		printf("w/o  sgr:standout,underline,reverse,blink,dim,bold,invis,protect,altchar,off");	}	gocurs(nextline++, 0);

⌨️ 快捷键说明

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