*BSD News Article 5524


Return to BSD News archive

Path: sserve!manuel!munnari.oz.au!spool.mu.edu!sdd.hp.com!swrinde!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!apple!motcsd!xhost92.csd.mot.com!ajv
From: ajv@xhost92.csd.mot.com
Newsgroups: comp.unix.bsd
Subject: New pccons escape sequences
Message-ID: <7138@motcsd.csd.mot.com>
Date: 23 Sep 92 23:10:27 GMT
Sender: usenet@motcsd.csd.mot.com
Lines: 168

This is a patch to add a couple more escape sequences to the 
console driver.  I needed them so I could log onto my V.4 box
and have vi be reasonably happy with just an "ansi" terminal
type.

Properly, the patch to termcap should be in terms of the source,
not the file in /usr/share.  However, I'm hoping that this new
pccons functionality can be folded into the base release before
people need to build /usr/share from source again.

Once you've patched pccons.c and rebuilt/rebooted, merely set your
terminal type to "pc3x", and you should be up and running.  If you
have your TERMCAP variable filled in with the termcap entry, you
will of course need to re-source your .login/.profile.

					Regards,
					Andy Valencia
					ajv@csd.mot.com (for now)
					jtk@netcom.com (when it bounces)

*** pcc.old	Wed Sep 23 16:46:45 1992
--- pcc.new	Wed Sep 23 16:46:53 1992
***************
*** 500,514 ****
   *   if ka, use kernel attributes.
   */
  sput(c,  ka)
  u_char c;
  u_char ka;
  {
- 
  	int sc = 1;	/* do scroll check */
  	char fg_at, bg_at, at;
  
  	if (crtat == 0)
  	{
  		u_short *cp = Crtat + (CGA_BUF-MONO_BUF)/CHR, was;
  		unsigned cursorat;
  
--- 500,514 ----
   *   if ka, use kernel attributes.
   */
  sput(c,  ka)
  u_char c;
  u_char ka;
  {
  	int sc = 1;	/* do scroll check */
  	char fg_at, bg_at, at;
+ 	u_short *crtend, *pp;
  
  	if (crtat == 0)
  	{
  		u_short *cp = Crtat + (CGA_BUF-MONO_BUF)/CHR, was;
  		unsigned cursorat;
  
***************
*** 678,689 ****
--- 678,766 ----
  						/* ... entire line */
  						fillw((at << 8) + ' ',
  							crtat - (crtat - Crtat) % vs.ncol,
  							vs.ncol);
  					vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
  					break;
+ 				case 'M': /* Delete line */
+ 					if (vs.cx < 1)
+ 						vs.cx = 1;
+ 
+ 					/* Work from beginning of line */
+ 					crtat -=  (crtat - Crtat) % vs.ncol; vs.col = 0;
+ 					crtend = Crtat + vs.ncol*vs.nrow;
+ 
+ 					/* Cap affected area at bottom of screen */
+ 					if ((pp = (crtat + vs.cx*vs.ncol)) > crtend) {
+ 						vs.cx = (crtend-crtat) / vs.ncol;
+ 						pp = crtend;
+ 					}
+ 
+ 					/* If there's visible lines left, move them up */
+ 					if (pp < crtend) {
+ 						bcopy(pp, crtat, (crtend-pp)*CHR);
+ 					}
+ 					fillw((at << 8) + ' ', crtend - vs.cx*vs.ncol,
+ 						vs.cx*vs.ncol);
+ 					vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ 					break;
+ 				case 'L': /* Insert line */
+ 					if (vs.cx < 1)
+ 						vs.cx = 1;
+ 
+ 					/* Work from beginning of line */
+ 					crtat -=  (crtat - Crtat) % vs.ncol; vs.col = 0;
+ 					crtend = Crtat + vs.ncol*vs.nrow;
+ 
+ 					/* Cap affected area at bottom of screen */
+ 					if ((pp = (crtat + vs.cx*vs.ncol)) > crtend) {
+ 						vs.cx = (crtend-crtat) / vs.ncol;
+ 						pp = crtend;
+ 					}
+ 
+ 					/* If there's visible lines left, move them down */
+ 					if (pp < crtend) {
+ 						bcopy(crtat, pp, (crtend-pp)*CHR);
+ 					}
+ 					fillw((at << 8) + ' ', crtat, vs.cx*vs.ncol);
+ 					vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ 					break;
+ 				case 'P':	/* Delete characters */
+ 					/* At least 1 */
+ 					if (vs.cx < 1)
+ 						vs.cx = 1;
+ 					/* Point to end of current line */
+ 					pp = crtat + (vs.ncol - (crtat-Crtat)%vs.ncol);
+ 					/* Cap delete to end of current line */
+ 					if ((crtat+vs.cx) > pp)
+ 						vs.cx = pp-crtat;
+ 					/* If visible characters, move in */
+ 					if ((crtat+vs.cx) < pp)
+ 						bcopy(crtat+vs.cx, crtat, ((pp-crtat)-vs.cx)*CHR);
+ 					/* Blank out space at end of line */
+ 					fillw((at << 8) + ' ', pp-vs.cx, vs.cx);
+ 					vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ 					break;
+ 
+ 				case '@':	/* Insert characters */
+ 					/* At least 1 */
+ 					if (vs.cx < 1)
+ 						vs.cx = 1;
+ 					/* Point to end of current line */
+ 					pp = crtat + (vs.ncol - (crtat-Crtat)%vs.ncol);
+ 					/* Cap insert to end of current line */
+ 					if ((crtat+vs.cx) > pp)
+ 						vs.cx = pp-crtat;
+ 					/* If visible characters, move out */
+ 					if ((crtat+vs.cx) < pp)
+ 						bcopy(crtat, crtat+vs.cx, ((pp-crtat)-vs.cx)*CHR);
+ 					/* Blank out space at new positions */
+ 					fillw((at << 8) + ' ', crtat, vs.cx);
+ 					vs.esc = 0; vs.ebrac = 0; vs.eparm = 0;
+ 					break;
+ 
  				case 'f': /* in system V consoles */
  				case 'H': /* Cursor move */
  					if ((!vs.cx)||(!vs.cy)) {
  						crtat = Crtat;
  						vs.col = 0;
  					} else {
*** termcap.orig	Fri Sep  4 19:39:51 1992
--- /usr/share/misc/termcap	Mon Aug 24 20:36:36 1992
***************
*** 76,87 ****
--- 76,91 ----
  	:kb=^h:kh=\E[Y:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:\
          :li#25:sr=\E[T:sf=\E[S:tc=pc:
  # Almost, but not yet...
  #	:AF=\E[2;%dx:AB=\E[1;%dx:Co#8:OP=\E[0x:
  #
  
+ pc3x|Extended 386 functions:\
+ 	:DC=\E[%dP:IC=\E[%d@:dc=\E[P:ic=\E[@:\
+ 	:AL=\E[%dL:DL=\E[%dM:dl=\E[M:al=\E[L:tc=pc3:
+ 
  zk|ibmx|ibmpcx|IBM PC xenix console display:\
  	:al=\E[L:am:bs:cd=\E[J:ce=\E[K:cl=^L:cm=\E[%d;%dH:co#80:\
  	:dc=\E[P:dl=\E[M:do=\E[B:ei=:ho=\E[H:ic=\E[@:im=:li#25:\
  	:nd=\E[C:ms:se=\E[0m:so=\E[7m:us=\E[4m:\
  	:ue=\E[m:up=\E[A:MR=\E[0m:\
  	:kb=^h:kh=\E[Y:ku=\E[A:kd=\E[B:kl=\E[D:kr=\E[C:eo:\