tom@ucbcad.UUCP (12/02/84)
In developing a termcap file for my terminal at home (a Heath H19 with Northwest Digital Systems' Graphics-Plus upgrade*), I came across an interesting behavior of vi. If I delete a line on the screen, vi goes through the following gyrations (I've put the termcap names of the escape sequences in parentheses for each step): 1) position cursor on last line (cm) 2) clear to end of display (ce) 3) position cursor on line to be deleted (cm) 4) save cursor position (sc) 5) change scrolling region to [line-to-be-deleted, last-line] (cs) 6) position cursor on last line (cm) 7) linefeed (nl) 8) change scrolling region to the entire screen (cs) 9) restore cursor position (rc) 10) position cursor on next-to-last line (cm) 11) print the line that appears at the bottom of the screen 12) position cursor on the line below the deleted line (cm) Insert line uses a similar set of steps. If I remove the cs (change scrolling region), sc (save cursor position), or rc (restore cursor position) capability from my termcap file, vi replaces steps 4 through 9 with the delete line sequence (dl). This is 2 characters instead of (typically) 23. While I'm glad that vi knows the change-scrolling-region kludge for brain-damaged terminals that don't have insert- and delete-line (I have a VT125 in my office), I don't understand why it uses this in preference to insert- and delete-line when both are available. I also don't see why it sends the save/restore cursor operations (especially since it sends a cursor motion after the restore-cursor). So. Does anyone know why: (1) vi changes the scrolling region in preference to using insert- and delete-line; (2) vi saves and restores the cursor position; (3) how to make vi use insert- and delete-line without removing one of the other capabilities (which some other program might want to use)? (BTW, I've tried setting the "optimize" option -- it makes no difference here). Tom Laidig * Graphics-Plus adds Tektronics 4013-style graphics to the H19, as well as many other features (INCLUDING the kitchen sink). I recommend it, and if anyone wants a more complete review, send me mail. If there's enough interest, I'll post it to some newsgroup.
chris@umcp-cs.UUCP (Chris Torek) (12/04/84)
I haven't looked at the source to VI for ages and ages (how does one express this in terms of sagans? :-) ), but it seems like making vi use al & dl rather than cs should be a relatively simple fix, considering that the change to make it use cs was added between 4.1 and 4.2.... I think the screen updates for insert & delete line are done someplace deep inside ``ex_vadj.c'', or you could always just have the startup code forget about the ``cs'' string if both al and dl exist! -- (This line accidently left nonblank.) In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690 UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland