Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!mordor!sri-spam!sri-unix!hplabs!gatech!gtss!chas From: chas@gtss.UUCP (Charles Cleveland) Newsgroups: comp.sys.amiga Subject: vt100 (2.3) patches for cursor mode Message-ID: <161@gtss.UUCP> Date: Tue, 9-Dec-86 11:08:28 EST Article-I.D.: gtss.161 Posted: Tue Dec 9 11:08:28 1986 Date-Received: Wed, 10-Dec-86 10:41:06 EST Reply-To: chas@gtss.UUCP (Charles Cleveland) Distribution: world Organization: Georgia Tech Surface Studies Lines: 194 Here are the (context) diffs for adding normal/application cursor capability to Wecker's vt100 (v2.3). I have had several requests for them, but have also seen more incorrect solutions to this problem posted, so I thought I'd better put in my contribution. In general, the host needs to be able to toggle normal/application mode for the cursor keys independently of the keypad mode. All I have to say about the questions of timing and queueing of input which several writers have said makes UNIX vi misbehave as per vt100's cursor keys because the escape sequences in termcap [or terminfo?] aren't actually the vt100 escape sequences (or some such, my eyes were glazing over), is that that means termcap (or vi) ought to be fixed, not vt100 emulators. A good emulation of a turd does not smell like a rose. There are times one needs a turd :-). I'm on a vt100 on a Sun 2/170 in vi right now, and here, where the escape sequences given in termcap for the up, down, right, and left cursor keys, with no modification on my part, are OA, OB, OC, OD (the 'application' values, which the cursor keys are set to on entering vi), I find it impossible to produce, at 9600 baud, any misbehavior on the part of my cursor keys. I may just be lucky though. Of course if I try to move the cursor while in insert mode I spew A's, B's, C's, and D's all over the place, but the vt100 is not, according to termcap, one of those terminal for which it is safe to try this. One gets used to hitting before cursor motions. On the other hand, if I *force* the cursor keys into 'normal' mode, I always get the A's, B's, C's, & D's, and have to revert to k's, j's, l's, and h's to move around. Different hosts and different programs on those hosts may want different settings. Just as the host can set the the keypad to either application or normal mode, it is supposed to be able to set the cursor keys to either application or normal mode. These patches do this. I suspect that some of the problems that people are having with cursor keys will go away if these patches are installed, especially on non-UNIX systems, and I suspect that others will go away if termcap is altered (You can make your own termcap entry in your own directory if you can't muck around in /etc/termcap. You can even make a vtamiga entry.). I strongly suspect that other cursor key problems will still remain for some folks. ---------------------------------------- here the crap ends and the patches begin ---------------------------------------- diff -c remote.c remote.c.fixed *** remote.c Mon Nov 24 19:00:56 1986 --- remote.c.fixed Mon Dec 8 21:15:59 1986 *************** *** 88,94 case 'c': /* Reset */ top = MINY; bot = MAXY; savx = MINX; savy = MINY; ! curmode = FS_NORMAL; keyapp = FALSE; inesc = -1; a[0] = 0; a[1] = 0; sa[0] = 0; sa[1] = 0; emit(12); --- 88,94 ----- case 'c': /* Reset */ top = MINY; bot = MAXY; savx = MINX; savy = MINY; ! curmode = FS_NORMAL; keyapp = FALSE; curapp = FALSE; inesc = -1; a[0] = 0; a[1] = 0; sa[0] = 0; sa[1] = 0; emit(12); *************** *** 267,273 case 'h': /* Set parameter */ if (private == 0 && p[0] == 20) nlmode = 1; ! else if (private == '?' && p[0] == 7) p_wrap = 1; return; case 'l': /* Reset parameter */ --- 267,276 ----- case 'h': /* Set parameter */ if (private == 0 && p[0] == 20) nlmode = 1; ! else if (private == '?'){ ! if( p[0] == 7) p_wrap = 1; ! else if( p[0] == 1) curapp = 1; ! } return; case 'l': /* Reset parameter */ *************** *** 272,278 case 'l': /* Reset parameter */ if (private == 0 && p[0] == 20) nlmode = 0; ! else if (private == '?' && p[0] == 7) p_wrap = 0; return; case 'x': --- 275,284 ----- case 'l': /* Reset parameter */ if (private == 0 && p[0] == 20) nlmode = 0; ! else if (private == '?'){ ! if(p[0] == 7) p_wrap = 0; ! else if( p[0] == 1) curapp = 0; ! } return; case 'x': diff -c vt100.c vt100.c.fixed *** vt100.c Mon Nov 24 19:00:24 1986 --- vt100.c.fixed Mon Dec 8 21:12:01 1986 *************** *** 61,66 y = MINY; curmode = FS_NORMAL; keyapp = 0; script_on = FALSE; script_wait= TRUE; SetAPen(mywindow->RPort,1L); --- 61,67 ----- y = MINY; curmode = FS_NORMAL; keyapp = 0; + curapp = 0; script_on = FALSE; script_wait= TRUE; SetAPen(mywindow->RPort,1L); diff -c vt100.h vt100.h.fixed *** vt100.h Mon Nov 24 19:00:19 1986 --- vt100.h.fixed Mon Dec 8 21:23:37 1986 *************** *** 159,165 UBYTE *BeepWave; UBYTE Audio_AllocMap[4] = { 1, 8, 2, 4 }; int want_message; ! int x,y,curmode,keyapp; int MINX = 0; int MAXX = 632; int MINY = 14; --- 159,165 ----- UBYTE *BeepWave; UBYTE Audio_AllocMap[4] = { 1, 8, 2, 4 }; int want_message; ! int x,y,curmode,keyapp,curapp; int MINX = 0; int MAXX = 632; int MINY = 14; *************** *** 254,260 extern char *rs_in; extern struct IOExtSer *Write_Request; extern char rs_out[2]; ! extern int x,y,curmode,keyapp; extern int MINX,MAXX,MINY,MAXY,top,bot,savx,savy; extern int savmode,nlmode,alt,savalt,a[2],sa[2]; extern int inesc,inctrl,private,badseq,maxcol; --- 254,260 ----- extern char *rs_in; extern struct IOExtSer *Write_Request; extern char rs_out[2]; ! extern int x,y,curmode,keyapp,curapp; extern int MINX,MAXX,MINY,MAXY,top,bot,savx,savy; extern int savmode,nlmode,alt,savalt,a[2],sa[2]; extern int inesc,inctrl,private,badseq,maxcol; diff -c window.c window.c.fixed *** window.c Mon Nov 24 19:01:00 1986 --- window.c.fixed Mon Dec 8 21:07:41 1986 *************** *** 310,316 case 0x4d: case 0x4e: case 0x4f: sendchar(27); /* cursor keys */ ! if (keyapp) sendchar('O'); else sendchar('['); sendchar(code - 11); break; --- 310,316 ----- case 0x4d: case 0x4e: case 0x4f: sendchar(27); /* cursor keys */ ! if (curapp) sendchar('O'); else sendchar('['); sendchar(code - 11); break; ---------------------------------------- end of patches ---------------------------------------- -- Charles Cleveland chas@ss.physics.gatech.edu Georgia Tech School of Physics Atlanta, GA 30332 Georgia Tech Surface Studies ...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp,rlgvax,sb1, uf-cgrl,unmvax,ut-sally}!gatech!gtss!chas