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

📄 pcvt_out.c

📁 freebsd v4.4内核源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* * Copyright (c) 1992, 1995 Hellmuth Michaelis and Joerg Wunsch. * * Copyright (c) 1992, 1993 Brian Dunford-Shore. * * All rights reserved. * * This code is derived from software contributed to Berkeley by * William Jolitz and Don Ahn. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by Hellmuth Michaelis, *	Brian Dunford-Shore and Joerg Wunsch. * 4. The name authors may not be used to endorse or promote products *    derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * * @(#)pcvt_out.c, 3.20, Last Edit-Date: [Sun Apr  2 18:59:11 1995] * *//*---------------------------------------------------------------------------* * *	pcvt_out.c	VT220 Terminal Emulator *	--------------------------------------- *	-hm	------------ Release 3.00 -------------- *	-hm	integrating NetBSD-current patches *	-hm	integrating patch from Thomas Gellekum *	-hm	bugfix: clear last line when hpmode 28lines and force 24 *	-hm	right fkey labels after soft/hard reset *	-hm	patch from Joerg for comconsole operation *	-hm	patch from Lon Willet to preserve the initial cursor shape *	-hm	if FAT_CURSOR is defined, you get the old cursor type back .. *	-hm	patch from Lon Willett regarding winsize settings *	-hm	applying patch from Joerg fixing Crtat bug, non VGA startup bug *	-hm	setting variable color for CGA and MDA/HGC in coldinit *	-hm	fixing bug initializing cursor position on startup *	-hm	fixing support for EGA boards in vt_coldinit() * *---------------------------------------------------------------------------*/#include "vt.h"#if NVT > 0#define PCVT_INCLUDE_VT_SELATTR	/* get inline function from pcvt_hdr.h */#include <i386/isa/pcvt/pcvt_hdr.h>	/* global include */#include <vm/vm.h>#include <vm/vm_param.h>#include <vm/pmap.h>extern u_short csd_ascii[];	/* pcvt_tbl.h */extern u_short csd_supplemental[];static void write_char (struct video_state *svsp, int attrib, int ch);static void check_scroll ( struct video_state *svsp );static void hp_entry ( U_char ch, struct video_state *svsp );static void vt_coldinit ( void );static void wrfkl ( int num, u_char *string, struct video_state *svsp );static void writefkl ( int num, u_char *string, struct video_state *svsp );/*---------------------------------------------------------------------------* *	do character set transformation and write to display memory (inline) *---------------------------------------------------------------------------*/#define video (svsp->Crtat + svsp->cur_offset)static __inline void write_char (svsp, attrib, ch)struct	video_state *svsp;u_short	attrib, ch;		/* XXX inefficient interface */{	if ((ch >= 0x20) && (ch <= 0x7f))	/* use GL if ch >= 0x20 */	{		if(!svsp->ss)		/* single shift G2/G3 -> GL ? */		{			*video = attrib | (*svsp->GL)[ch-0x20];		}		else		{			*video = attrib | (*svsp->Gs)[ch-0x20];			svsp->ss = 0;		}	}	else	{		svsp->ss = 0;		if(ch >= 0x80)			/* display controls C1 */		{			if(ch >= 0xA0)		/* use GR if ch >= 0xA0 */			{				*video = attrib | (*svsp->GR)[ch-0xA0];			}			else			{				if(vgacs[svsp->vga_charset].secondloaded)				{					*video = attrib | ((ch-0x60) | CSH);				}				else	/* use normal ibm charset for							control display */				{					*video = attrib | ch;				}			}		}		else				/* display controls C0 */		{			if(vgacs[svsp->vga_charset].secondloaded)			{				*video = attrib | (ch | CSH);			}			else	/* use normal ibm charset for control display*/			{				*video = attrib | ch;			}		}	}}/*---------------------------------------------------------------------------* *	emulator main entry *---------------------------------------------------------------------------*/voidsput (u_char *s, U_char kernel, int len, int page){    register struct video_state *svsp;    u_short	attrib;    u_short	ch;    if(page >= PCVT_NSCREENS)		/* failsafe */	page = 0;    svsp = &vs[page];			/* pointer to current screen state */    if(do_initialization)		/* first time called ? */	vt_coldinit();			/*   yes, we have to init ourselves */    if(svsp == vsp)			/* on current displayed page ?	*/    {	cursor_pos_valid = 0;			/* do not update cursor */#if PCVT_SCREENSAVER	if(scrnsv_active)			/* screen blanked ?	*/		pcvt_scrnsv_reset();		/* unblank NOW !	*/	else		reset_screen_saver = 1;		/* do it asynchronously	*/#endif /* PCVT_SCREENSAVER */    }    attrib = kernel ? kern_attr : svsp->c_attr;    while (len-- > 0)    if (ch = *(s++))    {	if(svsp->sevenbit)		ch &= 0x7f;	if(((ch <= 0x1f) || (ch == 0x7f)) && (svsp->transparent == 0))	{	/* always process control-chars in the range 0x00..0x1f, 0x7f !!! */		if(svsp->dis_fnc)		{			if(svsp->lastchar && svsp->m_awm			   && (svsp->lastrow == svsp->row))			{				svsp->cur_offset++;				svsp->col = 0;				svsp->lastchar = 0;				check_scroll(svsp);			}			if(svsp->irm)				bcopy((svsp->Crtat + svsp->cur_offset),				      (svsp->Crtat + svsp->cur_offset) + 1,				      (((svsp->maxcol)-1) - svsp->col)*CHR);			write_char(svsp, attrib, ch);			vt_selattr(svsp);			if(svsp->col >= ((svsp->maxcol)-1)			   && ch != 0x0a && ch != 0x0b && ch != 0x0c)			{				svsp->lastchar = 1;				svsp->lastrow = svsp->row;			}			else if(ch == 0x0a || ch == 0x0b || ch == 0x0c)			{				svsp->cur_offset -= svsp->col;				svsp->cur_offset += svsp->maxcol;				svsp->col = 0;				svsp->lastchar = 0;				check_scroll(svsp);	/* check scroll up */			}			else			{				svsp->cur_offset++;				svsp->col++;				svsp->lastchar = 0;			}		}		else		{			switch(ch)			{				case 0x00:	/* NUL */				case 0x01:	/* SOH */				case 0x02:	/* STX */				case 0x03:	/* ETX */				case 0x04:	/* EOT */				case 0x05:	/* ENQ */				case 0x06:	/* ACK */					break;				case 0x07:	/* BEL */					if(svsp->bell_on) 					  sysbeep(PCVT_SYSBEEPF/1500, hz/4);					break;				case 0x08:	/* BS */					if(svsp->col > 0)					{						svsp->cur_offset--;						svsp->col--;					}					break;				case 0x09:	/* TAB */					while(svsp->col < ((svsp->maxcol)-1))					{						svsp->cur_offset++;						if(svsp->						   tab_stops[++svsp->col])							break;					}					break;				case 0x0a:	/* LF */				case 0x0b:	/* VT */				case 0x0c:	/* FF */					if(svsp->lnm)					{						svsp->cur_offset -= svsp->col;						svsp->cur_offset +=							svsp->maxcol;						svsp->col = 0;					}					else					{						svsp->cur_offset +=							svsp->maxcol;					}					check_scroll(svsp);					break;				case 0x0d:	/* CR */					svsp->cur_offset -= svsp->col;					svsp->col = 0;					break;				case 0x0e:	/* SO */					svsp->GL = &svsp->G1;					break;				case 0x0f:	/* SI */					svsp->GL = &svsp->G0;					break;				case 0x10:	/* DLE */				case 0x11:	/* DC1/XON */				case 0x12:	/* DC2 */				case 0x13:	/* DC3/XOFF */				case 0x14:	/* DC4 */				case 0x15:	/* NAK */				case 0x16:	/* SYN */				case 0x17:	/* ETB */					break;				case 0x18:	/* CAN */					svsp->state = STATE_INIT;					clr_parms(svsp);					break;				case 0x19:	/* EM */					break;				case 0x1a:	/* SUB */					svsp->state = STATE_INIT;					clr_parms(svsp);					break;				case 0x1b:	/* ESC */					svsp->state = STATE_ESC;					clr_parms(svsp);					break;				case 0x1c:	/* FS */				case 0x1d:	/* GS */				case 0x1e:	/* RS */				case 0x1f:	/* US */				case 0x7f:	/* DEL */				break;			}		}	}	else	{	/* char range 0x20...0x73, 0x80...0xff processing */	/* depends on current state */		switch(svsp->state)		{			case STATE_INIT:				if(svsp->lastchar && svsp->m_awm &&				   (svsp->lastrow == svsp->row))				{					svsp->cur_offset++;					svsp->col = 0;					svsp->lastchar = 0;					check_scroll(svsp);				}				if(svsp->irm)					bcopy  ((svsp->Crtat						 + svsp->cur_offset),						(svsp->Crtat						 + svsp->cur_offset) + 1,						(((svsp->maxcol)-1)						 - svsp->col) * CHR);				write_char(svsp, attrib, ch);				vt_selattr(svsp);				if(svsp->col >= ((svsp->maxcol)-1))				{					svsp->lastchar = 1;					svsp->lastrow = svsp->row;				}				else				{					svsp->lastchar = 0;					svsp->cur_offset++;					svsp->col++;				}				break;			case STATE_ESC:				switch(ch)				{					case ' ':	/* ESC sp family */						svsp->state = STATE_BLANK;						break;					case '#':	/* ESC # family */						svsp->state = STATE_HASH;						break;					case '&':	/* ESC & family (HP) */						if(svsp->vt_pure_mode ==						   M_HPVT)						{							svsp->state =								STATE_AMPSND;							svsp->hp_state =								SHP_INIT;						}						else							svsp->state =								STATE_INIT;						break;					case '(':	/* ESC ( family */						svsp->state = STATE_BROPN;						break;					case ')':	/* ESC ) family */						svsp->state = STATE_BRCLO;						break;					case '*':	/* ESC * family */						svsp->state = STATE_STAR;						break;					case '+':	/* ESC + family */						svsp->state = STATE_PLUS;						break;					case '-':	/* ESC - family */						svsp->state = STATE_MINUS;						break;					case '.':	/* ESC . family */						svsp->state = STATE_DOT;						break;					case '/':	/* ESC / family */						svsp->state = STATE_SLASH;						break;					case '7':	/* SAVE CURSOR */						vt_sc(svsp);						svsp->state = STATE_INIT;						break;					case '8':	/* RESTORE CURSOR */						vt_rc(svsp);						if (!kernel)							attrib = svsp->c_attr;						svsp->state = STATE_INIT;						break;					case '=': /* keypad application mode */#if !PCVT_INHIBIT_NUMLOCK						vt_keyappl(svsp);#endif						svsp->state = STATE_INIT;						break;					case '>': /* keypad numeric mode */#if !PCVT_INHIBIT_NUMLOCK						vt_keynum(svsp);#endif						svsp->state = STATE_INIT;						break;					case 'D':	/* INDEX */						vt_ind(svsp);						svsp->state = STATE_INIT;						break;					case 'E':	/* NEXT LINE */						vt_nel(svsp);						svsp->state = STATE_INIT;						break;					case 'H': /* set TAB at current col */						svsp->tab_stops[svsp->col] = 1;						svsp->state = STATE_INIT;						break;					case 'M':	/* REVERSE INDEX */						vt_ri(svsp);						svsp->state = STATE_INIT;						break;					case 'N':	/* SINGLE SHIFT G2 */						svsp->Gs = &svsp->G2;						svsp->ss = 1;						svsp->state = STATE_INIT;						break;					case 'O':	/* SINGLE SHIFT G3 */						svsp->Gs = &svsp->G3;						svsp->ss = 1;						svsp->state = STATE_INIT;						break;					case 'P':	/* DCS detected */						svsp->dcs_state = DCS_INIT;						svsp->state = STATE_DCS;						break;					case 'Z': /* What are you = ESC [ c */						vt_da(svsp);						svsp->state = STATE_INIT;						break;					case '[':	/* CSI detected */						clr_parms(svsp);						svsp->state = STATE_CSI;						break;					case '\\':	/* String Terminator */						svsp->state = STATE_INIT;						break;					case 'c':	/* hard reset */						vt_ris(svsp);						if (!kernel)							attrib = svsp->c_attr;						svsp->state = STATE_INIT;						break;#if PCVT_SETCOLOR					case 'd':	/* set color sgr */						if(color)						{							/* set shiftwidth=4 */							sgr_tab_color								[svsp->								 vtsgr] =								 svsp->c_attr								 >> 8;							user_attr =								sgr_tab_color								[0] << 8;						}						svsp->state = STATE_INIT;						break;#endif /* PCVT_SETCOLOR */					case 'n': /* Lock Shift G2 -> GL */						svsp->GL = &svsp->G2;						svsp->state = STATE_INIT;						break;					case 'o': /* Lock Shift G3 -> GL */						svsp->GL = &svsp->G3;						svsp->state = STATE_INIT;						break;					case '}': /* Lock Shift G2 -> GR */						svsp->GR = &svsp->G2;						svsp->state = STATE_INIT;						break;					case '|': /* Lock Shift G3 -> GR */						svsp->GR = &svsp->G3;						svsp->state = STATE_INIT;						break;

⌨️ 快捷键说明

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