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

📄 vt100.c

📁 它是运用于通讯网络的C语言源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	case 'i': /* Printing */	default:		/* IGNORED */		break;  }  /* Process functions with zero, one, two or more arguments */  switch(c) {	case 'A':	case 'B':	case 'C':	case 'D': /* Cursor motion */		if ((f = escparms[0]) == 0) f = 1;		x = vt_win->curx;		y = vt_win->cury;		x += f * ((c == 'C') - (c == 'D'));		if (x < 0) x = 0;		if (x >= vt_win->xs) x = vt_win->xs - 1;		if (c == 'B') { /* Down. */			y += f;			if (y >= vt_win->ys) y = vt_win->ys - 1;			if (y == newy2 + 1) y = newy2;		}		if (c == 'A') { /* Up. */			y -= f;	 		if (y < 0) y = 0;			if (y == newy1 - 1) y = newy1;		}			wlocate(vt_win, x, y);		break;	case 'H':	case 'f': /* Set cursor position */		if ((y = escparms[0]) == 0) y = 1;		if ((x = escparms[1]) == 0) x = 1;		wlocate(vt_win, x - 1, y - 1);		break;	case 'm': /* Set attributes */		  /* Without argument, esc-parms[0] is 0 */		if (ptr < 0) ptr = 0;  		attr = wgetattr((vt_win));		for (f = 0; f <= ptr; f++) {		    if (escparms[f] >= 30 && escparms[f] <= 37)			wsetfgcol(vt_win, escparms[f] - 30);		    if (escparms[f] >= 40 && escparms[f] <= 47)			wsetbgcol(vt_win, escparms[f] - 40);		    switch(escparms[f]) {			case 0:				attr = A_NORMAL;				wsetfgcol(vt_win, vt_fg);				wsetbgcol(vt_win, vt_bg);				break;			case 4:				attr |= A_UNDERLINE;				break;			case 7:				attr |= A_REVERSE;				break;			case 1:				attr |= A_BOLD;				break;			case 5:				attr |= A_BLINK;				break;			case 22: /* Bold off */				attr &= ~A_BOLD;				break;			case 24: /* Not underlined */				attr &=~A_UNDERLINE;				break;			case 25: /* Not blinking */				attr &= ~A_BLINK;				break;			case 27: /* Not reverse */				attr &= ~A_REVERSE;				break;			case 39: /* Default fg color */				wsetfgcol(vt_win, vt_fg);				break;			case 49: /* Default bg color */				wsetbgcol(vt_win, vt_bg);				break;						    }		}		wsetattr(vt_win, attr);		break;	case 'L': /* Insert lines */		if ((x = escparms[0]) == 0) x = 1;		for(f = 0; f < x; f++)			winsline(vt_win);		break;		case 'M': /* Delete lines */		if ((x = escparms[0]) == 0) x = 1;		for(f = 0; f < x; f++)			wdelline(vt_win);		break;		case 'P': /* Delete Characters */		if ((x = escparms[0]) == 0) x = 1;		for(f = 0; f < x; f++)			wdelchar(vt_win);		break;		case '@': /* Insert Characters */				if ((x = escparms[0]) == 0) x = 1;		for(f = 0; f < x; f++)			winschar(vt_win);		break;		case 'r': /* Set scroll region */		if ((newy1 = escparms[0]) == 0) newy1 = 1;		if ((newy2 = escparms[1]) == 0) newy2 = vt_win->ys;		newy1-- ; newy2--;		if (newy1 < 0) newy1 = 0;		if (newy2 < 0) newy2 = 0;		if (newy1 >= vt_win->ys) newy1 = vt_win->ys - 1;		if (newy2 >= vt_win->ys) newy2 = vt_win->ys - 1;		wsetregion(vt_win, newy1, newy2);		break;	case 'y': /* Self test modes */	default:		/* IGNORED */		break;  }  /* Ok, our escape sequence is all done */  esc_s = 0;  ptr = -2;  return;		}  /* * ESC [ ? ... seen. */static void state3(c)int c;{  /* See if a number follows */  if (c >= '0' && c <= '9') {	if (ptr < 0) ptr = 0;	escparms[ptr] = 10*(escparms[ptr]) + c - '0';	return;  }  /* ESC [ ? number seen */  if (ptr < 0) {	esc_s = 0;	return;  }  switch(c) {	case 'h':		switch(escparms[0]) {			case 7: /* Auto wrap on (automatic margins) */				vt_win->wrap = 1;				break;			case 6: /* Set scroll region */				if (newy1 < 0) newy1 = 0;				if (newy2 < 0) newy2 = 0;				if (newy1 >= vt_win->ys) newy1 = vt_win->ys - 1;				if (newy2 >= vt_win->ys) newy2 = vt_win->ys - 1;				wsetregion(vt_win, newy1, newy2);				break;			case 1: /* Cursor keys in appl. mode */				vt_cursor = APPL;				if (vt_keyb) vt_keyb(vt_keypad, vt_cursor);				break;			case 25: /* Cursor on */				wcursor(vt_win, CNORMAL);				break;				default: /* Mostly set up functions */				/* IGNORED */				break;		}		break;	case 'l':		switch(escparms[0]) {			case 7: /* Auto wrap off */				vt_win->wrap = 0;				break;			case 6: /* Whole screen mode */				newy1 = 0;				newy2 = vt_win->ys - 1;				wresetregion(vt_win);				break;			case 1: /* Cursor keys in cursor pos. mode */				vt_cursor = NORMAL;				if (vt_keyb) vt_keyb(vt_keypad, vt_cursor);				break;			case 25: /* Cursor off */				wcursor(vt_win, CNONE);				break;			default: /* Mostly set up functions */				/* IGNORED */				break;		}		break;	case 'i': /* Printing */	case 'n': /* Request printer status */	default:		/* IGNORED */		break;  }  esc_s = 0;  ptr = -2;  return;}/* * ESC ( Seen. */static void state4(c)int c;{  /* Switch Character Sets. */  /* IGNORED */  esc_s = 0;}/* * ESC ) Seen. */static void state5(c)int c;{  /* Switch Character Sets. */  /* IGNORED */  esc_s = 0;}/* * ESC # Seen. */static void state6(c)int c;{  /* Double Height and Double width character sets */  /* IGNORED */  esc_s = 0;}/* * ESC P Seen. */static void state7(c)int c;{  /*   * Device dependant control strings. The Minix virtual console package   * uses these sequences. We can only turn cursor on or off, because   * that's the only one supported in termcap. The rest is ignored.   */  static char buf[17];  static int pos = 0;  static int state = 0;  if (c == ESC) {  	state = 1;  	return;  }  if (state == 1) {  	buf[pos] = 0;  	pos = 0;  	state = 0;  	esc_s = 0;  	if (c != '\\') return;  	/* Process string here! */  	if (!strcmp(buf, "cursor.on")) wcursor(vt_win, CNORMAL);  	if (!strcmp(buf, "cursor.off")) wcursor(vt_win, CNONE);  	if (!strcmp(buf, "linewrap.on")) {  		vt_wrap = -1;  		vt_win->wrap = 1;  	}  	if (!strcmp(buf, "linewrap.off")) {  		vt_wrap = -1;  		vt_win->wrap = 0;  	}  	return;  }  if (pos > 15) return;  buf[pos++] = c;}void vt_out(ch)int ch;{  int f;  short x;  unsigned char c;  if (!ch) return;  if (ptr == -2) { /* Initialize */	ptr = -1;	for(f = 0; f < 8; f++) escparms[f] = 0;  }  c = (unsigned char)ch;    if (vt_docap == 2) /* Literal. */	fputc(c, vt_capfp);  switch(esc_s) {	case 0: /* Normal character */		switch(c) {			case '\r': /* Carriage return */				wputc(vt_win, c);				if (vt_addlf) {					wputc(vt_win, '\n');					if (vt_docap == 1)						fputc('\n', vt_capfp);				}				break;			case '\t': /* Non - destructive TAB */				x = ((vt_win->curx / 8) + 1) * 8;				wlocate(vt_win, x, vt_win->cury);				if (vt_docap == 1) fputc(c, vt_capfp);				break;			case 013: /* Old Minix: CTRL-K = up */				wlocate(vt_win, vt_win->curx, vt_win->cury - 1);				break;			case '\f': /* Form feed: clear screen. */				winclr(vt_win);				wlocate(vt_win, 0, 0);				break;			case 14:			case 15:  /* Change character set. Not supported. */				break;			case ESC: /* Begin escape sequence */				esc_s = 1;				break;			case '\n': /* Printable by wputc too */			case '\b':			case 7: /* Bell */			default: /* Printable character */				wputc(vt_win, c);				if (vt_docap == 1)					fputc(c, vt_capfp);				break;		}		break;	case 1: /* ESC seen */		state1(c);		break;	case 2: /* ESC [ ... seen */		state2(c);		break;	case 3:		state3(c);		break;	case 4:		state4(c);		break;	case 5:		state5(c);		break;	case 6:		state6(c);		break;	case 7:		state7(c);		break;	  }}/* Translate keycode to escape sequence. */void vt_send(c)int c;{  char s[2];  int f;  /* Special key? */  if (c < 256) {	/* Translate backapce key? */	if (c == K_ERA) c = vt_bs;	s[0] = c;	s[1] = 0;	v_termout(s);	return;  }  /* Look up code in translation table. */  for(f = 0; vt_keys[f].code; f++)	if (vt_keys[f].code == c) break;  if (vt_keys[f].code == 0) return;  /* Now send appropriate escape code. */  v_termout("\033");  if (vt_type == VT100) {	if (vt_cursor == NORMAL)		v_termout(vt_keys[f].vt100_st);	else		v_termout(vt_keys[f].vt100_app);  } else	v_termout(vt_keys[f].ansi);}

⌨️ 快捷键说明

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