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

📄 console.c

📁 arm平台上的uclinux系统全部源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
	     * control chars if defined, don't set	     * bit 8 on output.	     */	    vcd->translate = set_translate(vcd->curstate.flags & FLG_CHRSET				? vcd->curstate.G1_charset				: vcd->curstate.G0_charset);	    vcd->disp_ctrl = 0;	    vcd->toggle_meta = 0;	    ret = 1;	    break;	case 11:	    /* ANSI X3.64-1979 (SCO-ish?)	     * Select first alternate font, let's	     * chars < 32 be displayed as ROM chars.	     */	    vcd->translate = set_translate(IBMPC_MAP);	    vcd->disp_ctrl = 1;	    vcd->toggle_meta = 0;	    ret = 1;	    break;	case 12:	    /* ANSI X3.64-1979 (SCO-ish?)	     * Select second alternate font, toggle	     * high bit before displaying as ROM char.	     */	    vcd->translate = set_translate(IBMPC_MAP);	    vcd->disp_ctrl = 1;	    vcd->toggle_meta = 1;	    ret = 1;	    break;	case 21:	case 22:	    vcd->curstate.flags &= ~FLG_BOLD;	    break;	case 24:	    vcd->curstate.flags &= ~FLG_UNDERLINE;	    break;	case 25:	    vcd->curstate.flags &= ~FLG_FLASH;	    break;	case 27:	    vcd->curstate.flags &= ~FLG_INVERSE;	    break;	case 30:	case 31:	case 32:	case 33:	case 34:	case 35:	case 36:	case 37:	    vcd->curstate.forecol = vcd->par[i]-30;	    break;						/* Foreground colour */	case 38:	    vcd->curstate.forecol = vcd->def_forecol;	    vcd->curstate.flags &= ~FLG_UNDERLINE;	    break;	case 39:	    vcd->curstate.forecol = vcd->def_forecol;	    vcd->curstate.flags &= ~FLG_UNDERLINE;	    break;						/* Default foreground colour */	case 40:	case 41:	case 42:	case 43:	case 44:	case 45:	case 46:	case 47:	    vcd->curstate.backcol = vcd->par[i]-40;	    break;						/* Background colour */	case 49:	    vcd->curstate.backcol = vcd->def_backcol;	    break;						/* Default background colour */	}    }    update_attr (vt);    return ret;}static void respond_string (char *p, struct tty_struct *tty){    while (*p)	tty_insert_flip_char (tty, *p++, 0);    tty_schedule_flip (tty);}static void cursor_report (const struct vt *vt){    char buf[40];    sprintf (buf, "\033[%d;%dR", vt->vcd->curstate.y + (vt->vcd->decom ? vt->vcd->top + 1 : 1),				     vt->vcd->curstate.x + 1);    respond_string (buf, *vt->tty);}static void status_report (struct tty_struct *tty){    respond_string ("\033[0n", tty);}static 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 by ioctl(TIOCLINUX) */int mouse_reporting (void){    return vtdata.fgconsole->vcd->report_mouse;}static inline unsigned long screenpos (const struct vt * const vt, int offset){    int hx, hy;    hx = offset % vtdata.numcolumns;    hy = offset / vtdata.numcolumns;    return vt->vcd->screen.origin + hy * vtdata.screen.sizerow + hx * vtdata.screen.bytespercharh;}void invert_screen (const struct vt * const vt, unsigned int offset, unsigned int count){    struct con_struct *vcd = vt->vcd;    unsigned long *buffer = vcd->driver.buffer_pos(vcd, offset);    unsigned long p, pp;    int i;    for (i = 0; i <= count; i++)	buffer[i] ^= FLG_INVERSE << 24;    if (vt == vtdata.fgconsole) {	int hx, hy, hex, hey;	hx = offset % vtdata.numcolumns;	hy = offset / vtdata.numcolumns;	hex = (offset + count) % vtdata.numcolumns;	hey = (offset + count) / vtdata.numcolumns;	p = vcd->screen.origin + hy * vtdata.screen.sizerow;	pp = p + hx * vtdata.screen.bytespercharh;	for (;hy <= hey; hy ++) {	    for (; hx < ((hy == hey) ? hex + 1 : vtdata.numcolumns); hx ++) {		ll_write_char (pp, *buffer++);		pp += vtdata.screen.bytespercharh;	    }	    hx = 0;	    pp = p += vtdata.screen.sizerow;	}           }}void complement_pos (const struct vt * const vt, unsigned int offset){    static unsigned long old = 0;    static unsigned long p = 0;    unsigned long complement;    switch (vtdata.screen.bitsperpix) {    case 4:	complement = 0x00070700;	break;    case 8:#ifndef HAS_VIDC20	complement = 0x00fcfc00;#else	complement = 0x00070700;#endif	break;    default:	complement = 0;    }    if (p)	ll_write_char (p, old);    if ((int)offset == -1)	p = 0;    else {	old = *vt->vcd->driver.buffer_pos(vt->vcd, offset);	p = screenpos (vt, offset);	ll_write_char (p, old ^ complement);    }}unsigned long screen_word (const struct vt * const vt, unsigned int offset){    return *vt->vcd->driver.buffer_pos (vt->vcd, offset);}int scrw2glyph (unsigned long scr_word){    return scr_word & 255;}unsigned long *screen_pos (const struct vt * const vt, unsigned int offset){    return vt->vcd->driver.buffer_pos (vt->vcd, offset);}void getconsxy (const struct vt * const vt, char *p){    p[0] = vt->vcd->curstate.x;    p[1] = vt->vcd->curstate.y;}void putconsxy (const struct vt * const vt, char *p){    gotoxy (vt->vcd, p[0], p[1]);    set_cursor (vt);}static void csi_J (const struct vt * const vt, int vpar);static void set_mode (const struct vt * const vt, int on_off){    struct con_struct *vcd = vt->vcd;    int i;    for (i = 0; i <= vcd->npar; i++)	if (vcd->ques)	    switch(vcd->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 */		vcd->deccolm = on_off;		csi_J (vt, 2);		gotoxy (vcd, 0, 0);		break;	    case 5:		/* Inverted screen on/off */		if (vcd->decscnm != on_off) {		    vcd->decscnm = on_off;		    invert_screen (vt, 0, vtdata.buffer.totsize);		    update_attr (vt);		}		break;	    case 6:		/* Origin relative/absolute */		vcd->decom = on_off;		gotoxay (vcd, 0, 0);		break;	    case 7:		/* Autowrap on/off */		vcd->decawm = on_off;		break;	    case 8:		/* Autorepeat on/off */		if (on_off)		    set_kbd(decarm);		else		    clr_kbd(decarm);		break;	    case 9:		vcd->report_mouse = on_off ? 1 : 0;		break;	    case 25:		/* Cursor on/off */		vcd->deccm = on_off;		set_cursor (vt);		break;	    case 1000:		vcd->report_mouse = on_off ? 2 : 0;		break;	    }	else	    switch(vcd->par[i]) {	/* ANSI modes set/reset */	    case 3:			/* Monitor (display ctrls) */		vcd->disp_ctrl = on_off;		break;	    case 4:			/* Insert mode on/off */		vcd->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 (const struct vt * const vt){	struct con_struct *vcd = vt->vcd;		switch (vt->vcd->par[0]) {		case 1: /* Set colour for underline mode (implemented as an underline) */		case 2: /* set colour for half intensity mode (unimplemented) */			break;		case 8:			vcd->def_forecol = vcd->curstate.forecol;			vcd->def_backcol = vcd->curstate.backcol;			break;		case 9:			vtdata.screen.blankinterval =				((vcd->par[1] < 60) ? vcd->par[1] : 60) * 60 * HZ;			vt_pokeblankedconsole ();			break;		case 10: /* set bell frequency in Hz */			if (vcd->npar >= 1)				vcd->bell_pitch = vcd->par[1];			else				vcd->bell_pitch = DEFAULT_BELL_PITCH;			break;		case 11: /* set bell duration in msec */			if (vcd->npar >= 1)				vcd->bell_duration = (vcd->par[1] < 2000) ?					vcd->par[1]*HZ/1000 : 0;			else				vcd->bell_duration = DEFAULT_BELL_DURATION;			break;		case 12: { /* bring specified console to the front */			int arg = vcd->par[1];			if (arg >= 1 && vt_allocated(vt_con_data + (arg - 1) ))				vt_updatescreen(vt_con_data + (arg - 1));			break;			}		case 13: /* unblank the screen */			vt_do_unblankscreen ();			break;		case 14: /* set vesa powerdown interval */#if todo			vesa_off_interval = ((vcd->par[1] < 60) ? vcd->par[1] : 60) * 60 * HZ;#endif			break;	}}static void csi_J (const struct vt * const vt, int vpar){    unsigned char endx, endy;    unsigned char startx, starty;    switch (vpar) {    case 0: /* erase from cursor to bottom of screen (including char at (x, y) */	startx = vt->vcd->curstate.x;	starty = vt->vcd->curstate.y;	endx   = vtdata.numcolumns - 1;	endy   = vtdata.numrows - 1;	break;    case 1: /* erase from top of screen to cursor (including char at (x, y) */	startx = 0;	starty = 0;	endx   = vt->vcd->curstate.x;	endy   = vt->vcd->curstate.y;	break;    case 2: /* erase entire screen */	startx = 0;	starty = 0;	endx   = vtdata.numcolumns - 1;	endy   = vtdata.numrows - 1;#if TODO	origin = video_mem_base;	set_origin (currcons);	gotoxy (currcons, x, y);#endif	break;    default:	return;    }    vt->vcd->driver.erase (vt->vcd, startx, starty, endx, endy);    /*vt->vcd->need_wrap = 0; why? We don't move the cursor... */}static void csi_K (const struct vt * const vt, int vpar){    unsigned char endx;    unsigned char startx;    switch(vpar) {    case 0: /* erase from cursor to end of line */	startx = vt->vcd->curstate.x;	endx   = vtdata.numcolumns - 1;	break;    case 1: /* erase from beginning of line to cursor */	startx = 0;	endx   = vt->vcd->curstate.x;	break;    case 2: /* erase entire line */	startx = 0;	endx   = vtdata.numcolumns - 1;	break;    default:	return;    }    vt->vcd->driver.erase(vt->vcd, startx, vt->vcd->curstate.y, endx, vt->vcd->curstate.y);    /*vt->vcd->need_wrap = 0; why? We don't move the cursor... */}static void csi_X (const struct vt * const vt, int vpar) /* erase the following vpar positions */{							 /* not vt100? */    unsigned char countx, county;    unsigned char startx, starty;    if (!vpar)	vpar++;    startx = vt->vcd->curstate.x;    starty = vt->vcd->curstate.y;    countx = 0;    county = 0;#if TODO    vt->vcd->driver.erase(vt->vcd,startx,starty,countx,county);#endif    /*vt->vcd->need_wrap = 0; why? We don't move the cursor... */}static void csi_at (const struct vt * const vt, int nr){    if (nr > vtdata.numcolumns - vt->vcd->curstate.x)	nr = vtdata.numcolumns - vt->vcd->curstate.x;    else if (!nr)	nr = 1;    vt->vcd->driver.insert_char(vt->vcd, nr);}static void csi_L (const struct vt * const vt, int nr){    if (nr > vtdata.numrows - vt->vcd->curstate.y)	nr = vtdata.numrows - vt->vcd->curstate.y;    else if (!nr)	nr = 1;    vt->vcd->driver.scroll_down (vt->vcd, vt->vcd->curstate.y, vt->vcd->bottom, nr);/*  vt->vcd->need_wrap = 0; why? We haven't moved the cursor. */}static void csi_P (const struct vt * const vt, int nr){    if (nr > vtdata.numcolumns)	nr = vtdata.numcolumns;    else if (!nr)	nr = 1;    vt->vcd->driver.delete_char(vt->vcd, nr);}static void csi_M (const struct vt * const vt, int nr){    if (nr > vtdata.numrows)	nr = vtdata.numrows;    else if (!nr)	nr = 1;    vt->vcd->driver.scroll_up (vt->vcd, vt->vcd->curstate.y, vt->vcd->bottom, nr);/*  vt->vcd->need_wrap = 0; why? we haven't moved the cursor. */}enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,	EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,	ESpalette };static void reset_terminal (const struct vt * const vt, int initialising){    struct con_struct *vcd;    vcd = vt->vcd;    vcd->top			= 0;    vcd->bottom 		= vtdata.numrows;    vcd->state			= ESnormal;    vcd->ques			= 0;    vcd->translate		= set_translate (LAT1_MAP);    vcd->curstate.G0_charset	= LAT1_MAP;    vcd->curstate.G1_charset	= GRAF_MAP;    vcd->curstate.flags 	= 0;    vcd->need_wrap		= 0;    vcd->report_mouse		= 0;    vcd->utf			= 0;    vcd->utf_count		= 0;    vcd->disp_ctrl		= 0;    vcd->toggle_meta		= 0;    vcd->decscnm		= 0;    vcd->decom			= 0;    vcd->decawm 		= 1;    vcd->deccm			= 1;    vcd->decim			= 0;    vcd->curstate.forecol	= 7;    vcd->curstate.backcol	= 0;    vcd->def_forecol		= 7;    vcd->def_backcol		= 0;    vcd->tab_stop[0]		= 0x01010100;    vcd->tab_stop[1]		=    vcd->tab_stop[2]		=    vcd->tab_stop[3]		=    vcd->tab_stop[4]		= 0x01010101;    set_kbd (decarm);    clr_kbd (decckm);    clr_kbd(kbdapplic);    clr_kbd(lnm);    vt->kbd->lockstate		= 0;    vt->kbd->ledmode		= LED_SHOW_FLAGS;    vt->kbd->ledflagstate	= vt->kbd->default_ledflagstate;    if (!initialising)	set_leds ();    if (vcd->screen.palette_entries) {	kfree (vcd->screen.palette_entries);	vcd->screen.palette_entries = 0;    }    gotoxy (vcd, 0, 0);    vcd->savedstate = vcd->curstate;    update_attr (vt);    if (!initialising)	csi_J (vt, 2);}static inline void update_palette(const struct vt * const vt){	const unsigned long *palette_entries;	int i;	if (vt->vcd->screen.palette_entries || vt->vtd->vc_mode != KD_GRAPHICS)		palette_entries = default_palette_entries;	else		palette_entries = vt->vcd->screen.palette_entries;	palette_setpixel(0);	for (i = MAX_PIX; i > 3; i -= 4) {		palette_write(*palette_entries++);		palette_write(*palette_entries++);		palette_write(*palette_entries++);		palette_write(*palette_entries++);	}	for (; i > 0; i--)		palette_write(*palette_entries++);

⌨️ 快捷键说明

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