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

📄 console.c

📁 LINUX1.0内核源代码,学习LINUX编程的一定要看。
💻 C
📖 第 1 页 / 共 4 页
字号:
}static void lf(int currcons){	if (y+1<bottom) {		y++;		pos += video_size_row;		return;	} else 		scrup(currcons,top,bottom);	need_wrap = 0;}static void ri(int currcons){	if (y>top) {		y--;		pos -= video_size_row;		return;	} else		scrdown(currcons,top,bottom);	need_wrap = 0;}static inline void cr(int currcons){	pos -= x<<1;	need_wrap = x = 0;}static inline void bs(int currcons){	if (x) {		pos -= 2;		x--;		need_wrap = 0;	}}static inline void del(int currcons){#if 0	if (x) {		if (!need_wrap) {    /* this is not the right condition */		        pos -= 2;			x--;		}		*(unsigned short *)pos = video_erase_char;		need_wrap = 0;	}#endif}static void csi_J(int currcons, int vpar){	unsigned long count;	unsigned long start;	switch (vpar) {		case 0:	/* erase from cursor to end of display */			count = (scr_end-pos)>>1;			start = pos;			break;		case 1:	/* erase from start to cursor */			count = ((pos-origin)>>1)+1;			start = origin;			break;		case 2: /* erase whole display */			count = video_num_columns * video_num_lines;			start = origin;			break;		default:			return;	}	__asm__("cld\n\t"		"rep\n\t"		"stosw\n\t"		: /* no output */		:"c" (count),		"D" (start),"a" (video_erase_char)		:"cx","di");	need_wrap = 0;}static void csi_K(int currcons, int vpar){	long count;	long start;	switch (vpar) {		case 0:	/* erase from cursor to end of line */			count = video_num_columns-x;			start = pos;			break;		case 1:	/* erase from start of line to cursor */			start = pos - (x<<1);			count = x+1;			break;		case 2: /* erase whole line */			start = pos - (x<<1);			count = video_num_columns;			break;		default:			return;	}	__asm__("cld\n\t"		"rep\n\t"		"stosw\n\t"		: /* no output */		:"c" (count),		"D" (start),"a" (video_erase_char)		:"cx","di");	need_wrap = 0;}/* *  I hope this works. The monochrome part is untested. */static void update_attr(int currcons){	attr = color;	if (can_do_color) {		if (underline)			attr = (attr & 0xf0) | ulcolor;		else if (intensity == 0)			attr = (attr & 0xf0) | halfcolor;	}	if (reverse ^ decscnm)		attr = (attr & 0x88) | (((attr >> 4) | (attr << 4)) & 0x77);	if (blink)		attr ^= 0x80;	if (intensity == 2)		attr ^= 0x08;	if (!can_do_color) {		if (underline)			attr = (attr & 0xf8) | 0x01;		else if (intensity == 0)			attr = (attr & 0xf0) | 0x08;	}	if (decscnm)		video_erase_char = (((color & 0x88) | (((color >> 4) | (color << 4)) & 0x77)) << 8) | ' ';	else		video_erase_char = (color << 8) | ' ';}static void default_attr(int currcons){	intensity = 1;	underline = 0;	reverse = 0;	blink = 0;	color = def_color;}static void csi_m(int currcons){	int i;	for (i=0;i<=npar;i++)		switch (par[i]) {			case 0:	/* all attributes off */				default_attr(currcons);				break;			case 1:				intensity = 2;				break;			case 2:				intensity = 0;				break;			case 4:				underline = 1;				break;			case 5:				blink = 1;				break;			case 7:				reverse = 1;				break;			case 21:			case 22:				intensity = 1;				break;			case 24:				underline = 0;				break;			case 25:				blink = 0;				break;			case 27:				reverse = 0;				break;			case 39:				color = (def_color & 0x0f) | background;				break;			case 49:				color = (def_color & 0xf0) | foreground;				break;			default:				if (par[i] >= 30 && par[i] <= 37)					color = color_table[par[i]-30]						| background; 				else if (par[i] >= 40 && par[i] <= 47)					color = (color_table[par[i]-40]<<4)						| foreground;				break;		}	update_attr(currcons);}static void respond_string(char * p, int currcons, struct tty_struct * tty){	while (*p) {		put_tty_queue(*p, &tty->read_q);		p++;	}	TTY_READ_FLUSH(tty);}static void respond_num(unsigned int n, int currcons, struct tty_struct * tty){	char buff[3];	int i = 0;	do {		buff[i++] = (n%10)+'0';		n /= 10;	} while(n && i < 3);	/* We'll take no chances */	while (i--) {		put_tty_queue(buff[i], &tty->read_q);	}	/* caller must flush */}static void cursor_report(int currcons, struct tty_struct * tty){	put_tty_queue('\033', &tty->read_q);	put_tty_queue('[', &tty->read_q);	respond_num(y + (decom ? top+1 : 1), currcons, tty);	put_tty_queue(';', &tty->read_q);	respond_num(x+1, currcons, tty);	put_tty_queue('R', &tty->read_q);	TTY_READ_FLUSH(tty);}static inline void status_report(int currcons, struct tty_struct * tty){	respond_string("\033[0n", currcons, tty);	/* Terminal ok */}static inline void respond_ID(int currcons, struct tty_struct * tty){	respond_string(VT102ID, currcons, tty);}static void invert_screen(int currcons) {	unsigned char *p;	if (can_do_color)		for (p = (unsigned char *)origin+1; p < (unsigned char *)scr_end; p+=2)			*p = (*p & 0x88) | (((*p >> 4) | (*p << 4)) & 0x77);	else		for (p = (unsigned char *)origin+1; p < (unsigned char *)scr_end; p+=2)			*p ^= *p & 0x07 == 1 ? 0x70 : 0x77;}static void set_mode(int currcons, int on_off){	int i;	for (i=0; i<=npar; i++)		if (ques) switch(par[i]) {	/* DEC private modes set/reset */			case 1:			/* Cursor keys send ^[Ox/^[[x */				if (on_off)					set_kbd(decckm);				else					clr_kbd(decckm);				break;			case 3:	/* 80/132 mode switch unimplemented */				csi_J(currcons,2);				gotoxy(currcons,0,0);				break;			case 5:			/* Inverted screen on/off */				if (decscnm != on_off) {					decscnm = on_off;					invert_screen(currcons);					update_attr(currcons);				}				break;			case 6:			/* Origin relative/absolute */				decom = on_off;				gotoxy(currcons,0,0);				break;			case 7:			/* Autowrap on/off */				decawm = on_off;				break;			case 8:			/* Autorepeat on/off */				if (on_off)					set_kbd(decarm);				else					clr_kbd(decarm);				break;			case 25:		/* Cursor on/off */				deccm = on_off;				set_cursor(currcons);				break;		} else switch(par[i]) {		/* ANSI modes set/reset */			case 4:			/* Insert Mode on/off */				decim = on_off;				break;			case 20:		/* Lf, Enter == CrLf/Lf */				if (on_off)					set_kbd(lnm);				else					clr_kbd(lnm);				break;		}}static void setterm_command(int currcons){	switch(par[0]) {		case 1:	/* set color for underline mode */			if (can_do_color && par[1] < 16) {				ulcolor = color_table[par[1]];				if (underline)					update_attr(currcons);			}			break;		case 2:	/* set color for half intensity mode */			if (can_do_color && par[1] < 16) {				halfcolor = color_table[par[1]];				if (intensity == 0)					update_attr(currcons);			}			break;		case 8:	/* store colors as defaults */			def_color = attr;			default_attr(currcons);			update_attr(currcons);			break;		case 9:	/* set blanking interval */			blankinterval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;			break;	}}static void insert_char(int currcons){	unsigned int i = x;	unsigned short tmp, old = video_erase_char;	unsigned short * p = (unsigned short *) pos;	while (i++ < video_num_columns) {		tmp = *p;		*p = old;		old = tmp;		p++;	}	need_wrap = 0;}static void insert_line(int currcons){	scrdown(currcons,y,bottom);	need_wrap = 0;}static void delete_char(int currcons){	unsigned int i = x;	unsigned short * p = (unsigned short *) pos;	while (++i < video_num_columns) {		*p = *(p+1);		p++;	}	*p = video_erase_char;	need_wrap = 0;}static void delete_line(int currcons){	scrup(currcons,y,bottom);	need_wrap = 0;}static void csi_at(int currcons, unsigned int nr){	if (nr > video_num_columns)		nr = video_num_columns;	else if (!nr)		nr = 1;	while (nr--)		insert_char(currcons);}static void csi_L(int currcons, unsigned int nr){	if (nr > video_num_lines)		nr = video_num_lines;	else if (!nr)		nr = 1;	while (nr--)		insert_line(currcons);}static void csi_P(int currcons, unsigned int nr){	if (nr > video_num_columns)		nr = video_num_columns;	else if (!nr)		nr = 1;	while (nr--)		delete_char(currcons);}static void csi_M(int currcons, unsigned int nr){	if (nr > video_num_lines)		nr = video_num_lines;	else if (!nr)		nr=1;	while (nr--)		delete_line(currcons);}static void save_cur(int currcons){	saved_x		= x;	saved_y		= y;	s_intensity	= intensity;	s_underline	= underline;	s_blink		= blink;	s_reverse	= reverse;	s_charset	= charset;	s_color		= color;	saved_G0	= G0_charset;	saved_G1	= G1_charset;}static void restore_cur(int currcons){	gotoxy(currcons,saved_x,saved_y);	intensity	= s_intensity;	underline	= s_underline;	blink		= s_blink;	reverse		= s_reverse;	charset		= s_charset;	color		= s_color;	G0_charset	= saved_G0;	G1_charset	= saved_G1;	translate	= charset ? G1_charset : G0_charset;	update_attr(currcons);	need_wrap = 0;}enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey, 	EShash, ESsetG0, ESsetG1, ESignore };static void reset_terminal(int currcons, int do_clear){	top		= 0;	bottom		= video_num_lines;	state		= ESnormal;	ques		= 0;	translate	= NORM_TRANS;	G0_charset	= NORM_TRANS;	G1_charset	= GRAF_TRANS;	charset		= 0;	need_wrap	= 0;	decscnm		= 0;	decom		= 0;	decawm		= 1;	deccm		= 1;	decim		= 0;	set_kbd(decarm);	clr_kbd(decckm);	clr_kbd(kbdapplic);	clr_kbd(lnm);	kbd_table[currcons].lockstate = 0;	kbd_table[currcons].ledstate = kbd_table[currcons].default_ledstate;	set_leds();	default_attr(currcons);	update_attr(currcons);	tab_stop[0]	= 0x01010100;	tab_stop[1]	=	tab_stop[2]	=	tab_stop[3]	=

⌨️ 快捷键说明

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