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

📄 ecutcap.c

📁 一个通讯程序源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*+-------------------------------------------------------------------------	ecutcap.c -- termcap stuff	wht@n4hgf.Mt-Park.GA.US  Defined functions:	tcap_blink_off()	tcap_blink_on()	tcap_bold_off()	tcap_bold_on()	tcap_clear_area_char(count,clrch)	tcap_clear_screen()	tcap_curbotleft()	tcap_curleft(count)	tcap_curright(count)	tcap_cursor(y,x)	tcap_delete_chars(count)	tcap_delete_lines(count)	tcap_draw_box(y,x,height,width,title,title_x)	tcap_draw_box_primitive(y,x,height,width)	tcap_eeod()	tcap_eeol()	tcap_gets(buf,bufsize,delim,wait_for_key)	tcap_horiz_rule(count)	tcap_init()	tcap_insert_chars(count)	tcap_insert_lines(count)	tcap_putc(character)	tcap_stand_end()	tcap_stand_out()	tcap_underscore_off()	tcap_underscore_on()	tcap_vbell()	tcap_vertical_rule(y,x,count)--------------------------------------------------------------------------*//*+:EDITS:*//*:09-10-1992-13:59-wht@n4hgf-ECU release 3.20 *//*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA *//*:03-10-1992-13:25-wht@n4hgf2-quick sanity check on ttype features *//*:02-24-1992-06:50-root@n4hgf-getenv COLUMNS not COLS *//*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 *//*:05-01-1991-04:05-wht@n4hgf-try to catch tbetz tc= infinite loop early *//*:03-20-1991-16:25-root@n4hgf-environment LINES/COLS overrides termcap li/co *//*:11-28-1990-14:52-wht@n4hgf-tcap support for non-ansi console *//*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */#include "ecu.h"#include "ecukey.h"#include "pc_scr.h"uint tcap_LINES;uint tcap_COLS;static char *tc_blink_on = "";static char *tc_blink_off = "";static char *tc_bold_on = "";static char *tc_bold_off = "";static char *tc_clear = "";static char *tc_curleft = "";static char *tc_curright = "";static char *tc_delchar = "";static char *tc_delline = "";static char *tc_eeod = "";static char *tc_eeol = "";static char *tc_inschar = "";static char *tc_insline = "";static char *tc_move = "";static char *tc_standout = "";static char *tc_standend = "";static char *tc_underscore_on = "";static char *tc_underscore_off = "";static char *tc_vbell = "";static char *tc_lastline = "";static char tc_strbuf[768];		/* absolutely blunderous overkill */static int tc_standout_width;char *tgetstr();char *tgoto();char *getenv();void tcap_cursor();void tcap_stand_out();void tcap_stand_end();/*+-------------------------------------------------------------------------	tcap_init() - get termcap variables--------------------------------------------------------------------------*/voidtcap_init(){	char termbuf[1024];	char *cptr;	if(!ttype || !*ttype)	{		fprintf(stderr,"invalid or missing TERM environment variable\r\n");		termecu(TERMECU_CURSES_ERROR);	}	if(tgetent(termbuf,ttype) > 0)	{		tcap_LINES = tgetnum("li");		tcap_COLS = tgetnum("co");#ifdef linux		if((tcap_LINES == 25) && (strcmp(ttype,"console")==0))			tcap_LINES = 24;#endif		if(cptr = getenv("LINES"))			/* environment override ... */			tcap_LINES = atoi(cptr);		/* ... for termcap systems */		if(cptr = getenv("COLUMNS"))			tcap_COLS = atoi(cptr);		if((tc_standout_width = tgetnum("sg")) < 0)			tc_standout_width = 0;		cptr = tc_strbuf;		tc_standout         = tgetstr("so",&cptr);		tc_standend         = tgetstr("se",&cptr);		tc_clear            = tgetstr("cl",&cptr);		tc_curleft          = tgetstr("kl",&cptr);		tc_curright         = tgetstr("kr",&cptr);		tc_delchar 			= tgetstr("dc",&cptr);		tc_delline          = tgetstr("dl",&cptr);		tc_eeod             = tgetstr("cd",&cptr);		tc_eeol             = tgetstr("ce",&cptr);		tc_inschar 			= tgetstr("ic",&cptr);		tc_insline          = tgetstr("al",&cptr);		tc_move             = tgetstr("cm",&cptr);		tc_vbell            = tgetstr("vb",&cptr);		tc_lastline         = tgetstr("ll",&cptr);		tc_underscore_on    = tgetstr("us",&cptr);		tc_underscore_off   = tgetstr("ue",&cptr);		if(!tc_underscore_on || !tc_underscore_off)		{			tc_underscore_on = tc_standout;			tc_underscore_off = tc_standend;		}		tc_bold_on          = tc_standout;			/* for now */		tc_bold_off         = tc_standend;			/* for now */		if(!tc_bold_on || !tc_bold_off)		{			tc_bold_on = tc_standout;			tc_bold_off = tc_standend;		}		tc_blink_on         = tgetstr("mb",&cptr);	/* "XENIX extension" */		tc_blink_off        = tgetstr("me",&cptr);	/* "XENIX extension" */		if(!*tc_clear || !*tc_move)		{			fprintf(stderr,"Terminal type '%s' does not have the beef.\r\n",				ttype);			fprintf(stderr,"Try again with a screen-oriented terminal.\n");			termecu(TERMECU_CURSES_ERROR);		}		return;	}	fprintf(stderr,"Cannot find terminal type '%s' or entry in error\r\n",		ttype);	termecu(TERMECU_CURSES_ERROR);}	/* end of tcap_init *//*+-------------------------------------------------------------------------	tcap_putc(character) - utility rotuine for tputs--------------------------------------------------------------------------*/voidtcap_putc(character)char character;{	rcvrdisp(&character,1);}	/* end of tcap_putc *//*+-------------------------------------------------------------------------	tcap_horiz_rule(count) - horizontal rule starting at current position--------------------------------------------------------------------------*/voidtcap_horiz_rule(count)register count;{	while(count--)		tcap_putc(sHR);	rcvrdisp_actual2();}	/* end of tcap_horiz_rule *//*+-------------------------------------------------------------------------	tcap_vertical_rule(y,x,count) - vertical rule starting at y,x--------------------------------------------------------------------------*/voidtcap_vertical_rule(y,x,count)int y;register x;register count;{	while(count--)	{		tcap_cursor(y++,x);		tcap_putc(sVR);	}	rcvrdisp_actual2();		}	/* end of tcap_vertical_rule *//*+-------------------------------------------------------------------------	tcap_draw_box_primitive(y,x,height,width) - ruled box--------------------------------------------------------------------------*/voidtcap_draw_box_primitive(y,x,height,width)register y;int x;int height;int width;{	register i;	tcap_cursor(y,x);	tcap_putc(sTL);	if((i = width - 2) > 0)		tcap_horiz_rule(i);	tcap_putc(sTR);	if((i = height - 2) > 0)	{		tcap_vertical_rule(y + 1,x + width - 1,i);		tcap_vertical_rule(y + 1,x,i);	}	tcap_cursor(y + height - 1,x);	tcap_putc(sBL);	if((i = width - 2) > 0)		tcap_horiz_rule(i);	tcap_putc(sBR);	rcvrdisp_actual2();}	/* end of tcap_draw_box_primitive *//*+-------------------------------------------------------------------------	tcap_draw_box(y,x,height,width,title,title_x)--------------------------------------------------------------------------*/voidtcap_draw_box(y,x,height,width,title,title_x)int y;int x;int height;int width;char *title;int title_x;{	register stand = (title_x < 0);	if(stand)		title_x = -title_x;	tcap_draw_box_primitive(y,x,height,width);	tcap_cursor(y,x + title_x);	tcap_putc('[');	if(stand)		tcap_stand_out();	ff(se," %s ",title);	if(stand)		tcap_stand_end();	tcap_putc(']');	rcvrdisp_actual2();}	/* end of tcap_draw_box *//*+-------------------------------------------------------------------------	tcap_cursor(y,x)--------------------------------------------------------------------------*/voidtcap_cursor(y,x)uint y;uint x;{	if(y >= tcap_LINES)		y = tcap_LINES - 1;	if(x >= tcap_COLS)		x = tcap_COLS - 1;	tputs(tgoto(tc_move,x,y),1,tcap_putc);	rcvrdisp_actual2();}	/* end of tcap_cursor *//*+-------------------------------------------------------------------------	tcap_curleft(count) - move cursor left--------------------------------------------------------------------------*/voidtcap_curleft(count)

⌨️ 快捷键说明

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