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

📄 console.c

📁 linux和2410结合开发 用他可以生成2410所需的zImage文件
💻 C
📖 第 1 页 / 共 5 页
字号:
				break;			case 7:				reverse = 1;				break;			case 10: /* ANSI X3.64-1979 (SCO-ish?)				  * Select primary font, don't display				  * control chars if defined, don't set				  * bit 8 on output.				  */				translate = set_translate(charset == 0						? G0_charset						: G1_charset,currcons);				disp_ctrl = 0;				toggle_meta = 0;				break;			case 11: /* ANSI X3.64-1979 (SCO-ish?)				  * Select first alternate font, lets				  * chars < 32 be displayed as ROM chars.				  */				translate = set_translate(IBMPC_MAP,currcons);				disp_ctrl = 1;				toggle_meta = 0;				break;			case 12: /* ANSI X3.64-1979 (SCO-ish?)				  * Select second alternate font, toggle				  * high bit before displaying as ROM char.				  */				translate = set_translate(IBMPC_MAP,currcons);				disp_ctrl = 1;				toggle_meta = 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 38: /* ANSI X3.64-1979 (SCO-ish?)				  * Enables underscore, white foreground				  * with white underscore (Linux - use				  * default foreground).				  */				color = (def_color & 0x0f) | background;				underline = 1;				break;			case 39: /* ANSI X3.64-1979 (SCO-ish?)				  * Disable underline option.				  * Reset colour to default? It did this				  * before...				  */				color = (def_color & 0x0f) | background;				underline = 0;				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(const char * p, struct tty_struct * tty){	while (*p) {		tty_insert_flip_char(tty, *p, 0);		p++;	}	con_schedule_flip(tty);}static void cursor_report(int currcons, struct tty_struct * tty){	char buf[40];	sprintf(buf, "\033[%d;%dR", y + (decom ? top+1 : 1), x+1);	respond_string(buf, tty);}static inline void status_report(struct tty_struct * tty){	respond_string("\033[0n", tty);	/* Terminal ok */}static inline void respond_ID(struct tty_struct * tty){	respond_string(VT102ID, tty);}void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry){	char buf[8];	sprintf(buf, "\033[M%c%c%c", (char)(' ' + butt), (char)('!' + mrx),		(char)('!' + mry));	respond_string(buf, tty);}/* invoked via ioctl(TIOCLINUX) and through set_selection */int mouse_reporting(void){	int currcons = fg_console;	return report_mouse;}/* console_sem is held */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 */				deccolm = on_off;#if 0				(void) vc_resize(video_num_lines, deccolm ? 132 : 80);				/* this alone does not suffice; some user mode				   utility has to change the hardware regs */#endif				break;			case 5:			/* Inverted screen on/off */				if (decscnm != on_off) {					decscnm = on_off;					invert_screen(currcons, 0, screenbuf_size, 0);					update_attr(currcons);				}				break;			case 6:			/* Origin relative/absolute */				decom = on_off;				gotoxay(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 9:				report_mouse = on_off ? 1 : 0;				break;			case 25:		/* Cursor on/off */				deccm = on_off;				break;			case 1000:				report_mouse = on_off ? 2 : 0;				break;		} else switch(par[i]) {		/* ANSI modes set/reset */			case 3:			/* Monitor (display ctrls) */				disp_ctrl = on_off;				break;			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;		}}/* console_sem is held */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;			if (hi_font_mask == 0x100)				def_color >>= 1;			default_attr(currcons);			update_attr(currcons);			break;		case 9:	/* set blanking interval */#ifdef CONFIG_CONSOLE_PM // bushi			blankinterval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;			poke_blanked_console();#endif			break;		case 10: /* set bell frequency in Hz */			if (npar >= 1)				bell_pitch = par[1];			else				bell_pitch = DEFAULT_BELL_PITCH;			break;		case 11: /* set bell duration in msec */			if (npar >= 1)				bell_duration = (par[1] < 2000) ?					par[1]*HZ/1000 : 0;			else				bell_duration = DEFAULT_BELL_DURATION;			break;		case 12: /* bring specified console to the front */			if (par[1] >= 1 && vc_cons_allocated(par[1]-1))				set_console(par[1] - 1);			break;		case 13: /* unblank the screen */#ifdef CONFIG_CONSOLE_PM // bushi			poke_blanked_console();#endif			break;		case 14: /* set vesa powerdown interval */#ifdef CONFIG_CONSOLE_PM // bushi			vesa_off_interval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ;#endif			break;	}}/* console_sem is held */static void csi_at(int currcons, unsigned int nr){	if (nr > video_num_columns - x)		nr = video_num_columns - x;	else if (!nr)		nr = 1;	insert_char(currcons, nr);}/* console_sem is held */static void csi_L(int currcons, unsigned int nr){	if (nr > video_num_lines - y)		nr = video_num_lines - y;	else if (!nr)		nr = 1;	scrdown(currcons,y,bottom,nr);	need_wrap = 0;}/* console_sem is held */static void csi_P(int currcons, unsigned int nr){	if (nr > video_num_columns - x)		nr = video_num_columns - x;	else if (!nr)		nr = 1;	delete_char(currcons, nr);}/* console_sem is held */static void csi_M(int currcons, unsigned int nr){	if (nr > video_num_lines - y)		nr = video_num_lines - y;	else if (!nr)		nr=1;	scrup(currcons,y,bottom,nr);	need_wrap = 0;}/* console_sem is held (except via vc_init->reset_terminal */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;}/* console_sem is held */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	= set_translate(charset ? G1_charset : G0_charset,currcons);	update_attr(currcons);	need_wrap = 0;}static int con_write_ctrl_ESnormal(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESesc(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESnonstd(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESpalette(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESsquare(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESgetpars(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESgotpars(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESpercent(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESfunckey(int, struct tty_struct *, unsigned int);static int con_write_ctrl_EShash(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESsetG0(int, struct tty_struct *, unsigned int);static int con_write_ctrl_ESsetG1(int, struct tty_struct *, unsigned int);enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,	EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,	ESpalette };/* console_sem is held (except via vc_init()) */static void reset_terminal(int currcons, int do_clear){	top		= 0;	bottom		= video_num_lines;	vc_state	= con_write_ctrl_ESnormal;	ques		= 0;	translate	= set_translate(LAT1_MAP,currcons);	G0_charset	= LAT1_MAP;	G1_charset	= GRAF_MAP;	charset		= 0;	need_wrap	= 0;	report_mouse	= 0;	utf             = 0;	utf_count       = 0;	disp_ctrl	= 0;	toggle_meta	= 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].slockstate = 0;	kbd_table[currcons].ledmode = LED_SHOW_FLAGS;	kbd_table[currcons].ledflagstate = kbd_table[currcons].default_ledflagstate;	set_leds();	cursor_type = CUR_DEFAULT;	complement_mask = s_complement_mask;	default_attr(currcons);	update_attr(currcons);	tab_stop[0]	= 0x01010100;	tab_stop[1]	=	tab_stop[2]	=	tab_stop[3]	=	tab_stop[4]	= 0x01010101;	bell_pitch = DEFAULT_BELL_PITCH;	bell_duration = DEFAULT_BELL_DURATION;	gotoxy(currcons,0,0);	save_cur(currcons);	if (do_clear)	    csi_J(currcons,2);}/* console_sem is held */static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c){	/*	 *  Control characters can be used in the _middle_	 *  of an escape sequence.	 */	switch (c) {	case 0:		return;	case 7:		if (bell_duration)			kd_mksound(bell_pitch, bell_duration);		return;	case 8:		bs(currcons);		return;	case 9:		pos -= (x << 1);		while (x < video_num_columns - 1) {			x++;			if (tab_stop[x >> 5] & (1 << (x & 31)))				break;		}		pos += (x << 1);		return;	case 10: case 11: case 12:		lf(currcons);		if (!is_kbd(lnm))			return;	case 13:		cr(currcons);		return;	case 14:		charset = 1;		translate = set_translate(G1_charset,currcons);		disp_ctrl = 1;		return;	case 15:		charset = 0;		translate = set_translate(G0_charset,currcons);		disp_ctrl = 0;		return;	case 24: case 26:		vc_state = con_write_ctrl_ESnormal;		return;	case 27:		vc_state = con_write_ctrl_ESesc;		return;	case 127:		del(currcons);		return;	case 128+27:		vc_state = con_write_ctrl_ESsquare;		return;	}	vc_state(currcons, tty, c);}static int con_write_utf(int currcons, int c){	unsigned int chr;	/* Combine UTF-8 into Unicode */	/* Incomplete characters silently ignored */	if (c < 0x80) {		utf_count = 0;		return c;	}	if (utf_count > 0 && (c & 0xc0) == 0x80) {		chr = (utf_char << 6) | (c & 0x3f);		utf_count--;		if (utf_count == 0)			return chr;	} else {		unsigned int count;		if ((c & 0xe0) == 0xc0) {			count = 1;			chr = (c & 0x1f);		} else if ((c & 0xf0) == 0xe0) {			count = 2;			chr = (c & 0x0f);		} else if ((c & 0xf8) == 0xf0) {			count = 3;			chr = (c & 0x07);		} else if ((c & 0xfc) == 0xf8) {			count = 4;			chr = (c & 0x03);		} else if ((c & 0xfe) == 0xfc) {			count = 5;			chr = (c & 0x01);		} else {			count = 0;			chr = 0;		}		utf_count = count;	}	utf_char = chr;	return -1;}static int con_write_ctrl_ESnormal(int currcons, struct tty_struct *tty, unsigned int c){	return 0;}static int con_write_ctrl_ESesc(int currcons, struct tty_struct *tty, unsigned int c){	vc_state = con_write_ctrl_ESnormal;	switch (c) {	case '[':		vc_state = con_write_ctrl_ESsquare;		break;	case ']':		vc_state = con_write_ctrl_ESnonstd;		break;	case '%':		vc_state = con_write_ctrl_ESpercent;		break;	case 'E':		cr(currcons);		lf(currcons);		break;	case 'M':		ri(currcons);		break;	case 'D':		lf(currcons);		break;	case 'H':		tab_stop[x >> 5] |= (1 << (x & 31));		break;	case 'Z':		respond_ID(tty);		break;	case '7':		save_cur(currcons);		break;	case '8':		restore_cur(currcons);		return 1;	case '(':		vc_state = con_write_ctrl_ESsetG0;		break;	case ')':		vc_state = con_write_ctrl_ESsetG1;		break;	case '#':		vc_state = con_write_ctrl_EShash;		break;	case 'c':		reset_terminal(currcons,1);		return 1;	case '>':  /* Numeric keypad */		clr_kbd(kbdapplic);

⌨️ 快捷键说明

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