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

📄 vt100.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
	if (dim_level > 0) {		dim_level =0;		for (i = 0; i < nfbdev; i++)			fbbm_set_dimmer(&fbdev[i], 0);	}	splx(s);}auto_dimmer_on(){	register int s, i;#ifdef CPU_SINGLE	s = spl4();#endif	dimmer_counter = dim_cnt;	dim_level =0;	for (i = 0; i < nfbdev; i++)		fbbm_set_dimmer(&fbdev[i], dim_level);	a_dim_on = 1;	splx(s);}auto_dimmer_off(){	register int s, i;#ifdef CPU_SINGLE	s = spl4();#endif	dimmer_counter = dim_cnt;	dim_level =0;	for (i = 0; i < nfbdev; i++)		fbbm_set_dimmer(&fbdev[i], dim_level);	a_dim_on = 0;	splx(s);}#endif /* IPC_MRX *//* *  The routine `_putc(sp, c)' only prints a character c with the cursor *  attributes by using `copy_char(x, y, c, attributes)'. *  And when IRM (terminal insertion-replacement mode) is set, the characters *  righthand side of the cursor are shifted right and lost when they passed *  beyond the right margin. *  The position is specified by the sp pointer of the structure SCREEN. * */static_putc(sp, c, kanji)	register SCREEN	*sp;	unsigned int c;{	if (sp->s_term_mode & IRM) {		vt_flush(&(sp->s_csr));		move_chars(sp->s_csr.csr_x, sp->s_csr.csr_y, 			   rit_m - sp->s_csr.csr_x - ((kanji)? 1: 0),			   sp->s_csr.csr_x + ((kanji) ? 2: 1));		copy_char(sp, c, kanji);	}	if (fp) {		fbuf[fp++] = c;		fpn += kanji + 1;	} else {		fbuf[fp++] = c;		fpp = sp->s_csr.csr_p;		fpa = sp->s_csr.csr_attributes;		fpn = kanji + 1;	}}/* *  Scroll up and down in the scroll region. *  New oriented line must be cleared with terminal mode, that is whether *  the screen is reverse mode or not. */scroll_up(top, bottom, revsw, fcol, bcol)	int top;	int bottom;	int revsw;	int fcol;	int bcol;{	move_lines(top + 1, bottom - top, top);	clear_lines(bottom, 1, revsw, fcol, bcol);}scroll_down(top, bottom, revsw, fcol, bcol)	int top;	int bottom;	int revsw;	int fcol;	int bcol;{	move_lines(top, bottom - top, top + 1);	clear_lines(top, 1, revsw, fcol, bcol);}/* *  Back space *  back_space(sp) moves cursor next to left at current cursor position. *  The cursor can not move beyond left or right margin. */back_space(sp)	register SCREEN *sp;{	register struct cursor *spc = &sp->s_csr;	cursor_off();	if (spc->csr_x > LFT_M) {		spc->csr_x -= 1;		spc->csr_p.x -= char_w;	}	cursor_on(&spc->csr_p);}/* *  Tab stop *  next_tab_stop(sp) moves cursor to next tab stop. */next_tab_stop(sp)	register SCREEN *sp;{	register int i;	cursor_off();	for (i = sp->s_csr.csr_x + 1; i < rit_m; i++)		if (sp->s_tab_pos[i] == 1)			break;	sp->s_csr.csr_x = min(i, rit_m);	sp->s_csr.csr_p.x = (sp->s_csr.csr_x - 1) * char_w + x_ofst;	cursor_on(&sp->s_csr.csr_p);}/* *  Carriage return *  carriage_ret(sp) moves cursor at beginning of the current line. */carriage_ret(sp)	register SCREEN *sp;{	cursor_off();	sp->s_csr.csr_x = LFT_M;	sp->s_csr.csr_p.x = x_ofst;	cursor_on(&sp->s_csr.csr_p);}/* *  Bell */staticbell(){#ifdef news1800	static int port;	if (port == 0)		port = port_create("port_cons_bell");	kbd_ioctl(port, KIOCBELL, &bell_len);#else	kbd_ioctl(SCC_KEYBOARD, KIOCBELL, &bell_len);#endif	return (0);}intPutchar(c, eob)	unsigned int c;{	register SCREEN *sp = &screen;	unsigned int sftjis_to_jis();	c &= 0xff;	if (eob) {		vt_flush(&(sp->s_csr));		return(0);	}	if (c == 0x1b) {	/*  c == esc */		vt_flush(&(sp->s_csr));		recover(sp);		sp->s_current_stat |= ESCAPE;		return;	} else if (sp->s_current_stat & ESCAPE) {		(*sp->s_esc_handler)(sp, c);		return;	} else if (sp->s_current_stat & SKANJI) {		c = sftjis_to_jis(first_code, c);		if (sp->s_current_stat & JKANJI) {			addch(sp, c);		} else {			sp->s_current_stat |= JKANJI;			addch(sp, c);			sp->s_current_stat &= ~JKANJI;		}		sp->s_current_stat &= ~SKANJI;		goto set_csr;	} else if (sp->s_current_stat & EKANJI) {		c = (c & 0x7f) | (first_code << 8);		if (sp->s_current_stat & JKANJI) {			addch(sp, c);		} else {			sp->s_current_stat |= JKANJI;			addch(sp, c);			sp->s_current_stat &= ~JKANJI;		}		sp->s_current_stat &= ~EKANJI;		goto set_csr;	} else if (sp->s_current_stat & JKANJI) {		jiskanji(sp, c);		goto set_csr;	} else if (sp->s_current_stat & EKANA) {			sp->s_current_stat &= ~EKANA;			addch(sp, c);		goto set_csr;	}	if (c < 0x20) {		/*  control code	*/		vt_flush(&(sp->s_csr));		switch (c) {		case  0x00:	/*  ignore  */			break;		case  0x07:	/*  bell  */			bell();			break;		case  0x08:	/*  back space  */			back_space(sp);			break;		case  0x09:	/*  tabulation  */			next_tab_stop(sp);			break;		case  0x0a:	/*  line feed  */		case  0x0b:	/*  vertical feed  */		case  0x0c:	/*  form feed  */			esc_index(sp);			break;		case  0x0d:	/*  carriage return  */			carriage_ret(sp);			break;		case  0x0e:	/*  shift out  */			break;		case  0x0f:	/*  shift in  */			break;		case  0x11:	/*  xon  */			break;		case  0x13:	/*  xoff  */			break;		case  0x18:	/*  cancel  */			sp->s_current_stat &= ~ESCAPE;			break;		case  0x1b:	/*  escape  */ 			/*	NOT REACHED	*/			recover(sp);			sp->s_current_stat |= ESCAPE;			break;		case  0x7f:	/*  delete  */			break;		default:			break;		}	} else {		switch (tmode) {#ifdef KM_SJIS		case KM_SJIS:			if ((c >= JVR1S && c <= JVR1E) || 				(c >= JVR2S && c <= JVR2E)) {				sp->s_current_stat |= SKANJI;				first_code = c;			}			else				addch(sp, c);			break;#endif#ifdef KM_EUC		case KM_EUC:			if (c >= CS1S && c <= CS1E) {				sp->s_current_stat |= EKANJI;				first_code = c & 0x7f;			}			else if (c == SS2)				sp->s_current_stat |= EKANA;			else				addch(sp, c);			break;#endif#ifdef KM_JIS		case KM_JIS:#endif#ifdef KM_ASCII		case KM_ASCII:#endif		default:			addch(sp, c);		}	}set_csr:	cursor_on(&sp->s_csr.csr_p);		/*  altered	*/	return ;}/* *  A printable character is printed in this routine by using *  the routine `_putc()'. *  Anyway, a character is printed in replacement mode or insertion *  mode and if the terminal is autowrap then it takes place wrapping *  and if cursor is bottom margin of the scroll region then it takes *  place scroll up. *  The escape sequence handling is another routine. * */addch(sp, c)	register SCREEN	*sp;	unsigned int c;{	register struct cursor *spc = &(sp->s_csr);	register struct region *spr = &(sp->s_region);	if (spc->csr_x >= rit_m ||		((sp->s_current_stat & JKANJI) && (spc->csr_x >= rit_m - 1))) {		vt_flush(spc);		if (sp->s_term_mode & DECAWM) {			if ((sp->s_current_stat & WRAP) || (spc->csr_x == rit_m					&& sp->s_current_stat & JKANJI)) {				if (spc->csr_y == spr->btm_margin) {					cursor_off();					scroll_up(spr->top_margin,						  spr->btm_margin,						  sp->s_term_mode & DECSCNM,						  sp->s_plane, sp->s_bgcol);					cursor_on(&(spc->csr_p));				} else if (spc->csr_y < btm_m) {					spc->csr_y += 1;					spc->csr_p.y += char_h;				}				spc->csr_x = LFT_M;				spc->csr_p.x = x_ofst;				addch(sp, c);				return;			}			sp->s_current_stat |= WRAP;		}		if (sp->s_current_stat & JKANJI) {			if (spc->csr_x != rit_m) {				_putc(sp, c, 1);			}		} else {			_putc(sp, c, 0);		}		if (spc->csr_x < rit_m) {			spc->csr_x += 1;			spc->csr_p.x += char_w;		}		return ;	}	if (sp->s_current_stat & JKANJI) {		_putc(sp, c, 1);		spc->csr_x++;		spc->csr_p.x += char_w;	} else {		_putc(sp, c, 0);	}	spc->csr_x++;	/*  altered   */	spc->csr_p.x += char_w;	sp->s_current_stat &= ~WRAP;	return ;}

⌨️ 快捷键说明

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