davison@drivax.DRI (Wayne Davison) (02/22/89)
I've been doing a lot of twiddling with screen lately. In the process, I've fixed some bugs, added some features, and made some minor optimizations to the code. I was about to send my diffs (about 60k worth) to Oliver for him to mull over, but it appears that he doesn't have any time right now to devote to working on screen. So I thot I'd mention what I've been doing, and see if anyone else out there might like to swap changes. If there's enough general interest in what I've done, I could post the diffs to comp.sources.unix, or comp.sources.bugs, or whatever. Bugfixes: --------- o If MakeWindow() fails, there are cases where the opened PTY is not closed, nor is partially allocated memory freed. In fact, I found that the "tabs" array is never freed at any point, even when you delete a window. I've reordered allocation in MakeWindow and call a modified FreeWindow from more places in MakeWindow to fix this. o Whenever a background window turns the keypad or insert mode on/off, screen incorrectly toggles the internal state of keypad or insert even though the physical mode of these items has not changed. o When detaching or suspending screen, the keypad and insert mode need to be turned off and stdout flushed. As it works now, screen might leave these on and will expect them to still be on when restarted. o ClearScreen() is called twice in ansi.c and followed by a Goto() that has two different assumptions for the "from" field of the current cursor position. The code should assume that the cursor was homed by the clear-screen string. o There's a few spots where curr->bot should be referrenced for the last line in the scrolling region, not rows-1 for the last screen line. o I fixed auto-margin support by advertising `am' in the termcap if your terminal is such a terminal and then correctly emulating it. This allows screen to display that last character of the last line in normal circumstances. The only time it doesn't display it is when you switch screen into nowrap mode on an `am' terminal. o As Paul Lew already noted, changing the default escape key with the escape command in .screenrc does not set the default escape-escape action. However, the correct solution is NOT to re-order the call to InitKeytab(), since it could possibly override "bind" commands made in the .screenrc. The correct solution is to add the line: ktab[Esc].type = KEY_OTHER; into the processing of the escape command. o Goto() erroneously forced an x,y cursor move when going to the first or last line of the scrolling region or when moving around outside the scrolling region. It should only do this when going from inside to outside the scrolling region. o RewriteCost() erroneously thinks that rewriting UP TO rows-1 is "EXPENSIVE". o The DeleteChar() & InsertChar() code simply return if the emulator is in the "pseudo-last column" of the line (the spot after writing a character to the last column of a line). It should remove the last character of the line. Added features: --------------- o Made flow control selectable on a per-console basis. This lets you run shells with flow control, and editors (such as emacs) without and switch back and forth. o Added flow-toggle mode that turns flow control on/off for the current console when the application keypad turns off/on (respectivly). o Added the -f/ command line option to select the flow-toggle mode from the command line. o Added keystroke commands and default bindings to: toggle flow control on/off (C-A f, C-A C-F) toggle flow-toggle on/off (C-A /) toggle wrap on/off (C-A r, C-A C-R) clear the screen (C-A C) reset the virtual terminal (C-A Z) o Added .screenrc commands to: set default flow mode (flow on|off|toggle) set default wrap mode (wrap on|off) o I put all the windows in a most-recently-used linked list so that the "other" window we switch to (with C-A C-A) is always the most recently accessed window (besides the current window), no matter how many windows have been deleted. o Added left margin ^H line-wrap when in wrap mode. This kinda rounds out the "wrap when a second character is written into the right margin" feature of screen, and lets simple-minded applications (like csh) edit a wrapped command line. o Added interrupt option (-i) which will immediately terminate the output when ^C is pressed. Currently, screen might scroll another 8 lines or more before stopping. The only trade-off, is that the virtual screen memory contains the extra "8" lines of output, not the abbreviated version. You won't notice that fact too often, however. Optimizations: -------------- o Removed the GotArg array in ansi.c. It was completely redundant with a parameter value of 0. o Made clear-to-eol work on non-LP terminals w/o CE but with DC. o Correctly set last_x & last_y on exit of DisplayLine so that the Goto() kludge that forced an x,y cursor move isn't needed. o Bind now requires the \ in front of an octal number. This lets you bind the numeric keys without resorting to octal, and also lets the bind command use the same translate code as the -e option. o I redid the insert code to selectivly choose between IC and IM if both are specified for a terminal. o Made large arrays malloc'ed. o Optimized scrolling of interal character maps and ClearScreen. -- Wayne Davison ...amdahl!drivax!davison =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Qn qyrzx zkhn ly ubbren tyr loul lon crkxnx skbbkznb jreenplzt jypwneckpc qklo tyre bokf uen fuel ya u bfnjkuz bnewkjn qn ndlnpx ly uzz ya yre sybl nplorbkublkj jzknplb, upx lon arzzt uesnx prjznue queonuxb uen, ya jyrebn snenzt u jyrelnbt xnlukz. Qn zyyh ayequex ly tyre jrblys kp arlren zkwnb. -- Lon Okljookhne'b Crkxn ly lon Cuzudt
pwolfe@kailand.KAI.COM (02/27/89)
The two different cursor movement commands after the two ClearScreen calls in ansi.c are correct. Screen is emulating an ANSI terminal (even if the terminal you run it on *isn't* an ANSI terminal), and in all the manuals for ANSI style terminals we have, <esc>c resets the terminal and homes the cursor, and <esc>[2J clears the screen but *doesn't* home the cursor. Patrick Wolfe System Manager, Kuck & Assoc., Inc. pat@kai.com {uunet,uiucuxc,sequent}!kailand!pat pat%kai.com@uxc.cso.uiuc.edu pat%kai.com@uiucuxc.arpa pat@kai.com@uiucvmd.bitnet (<= does this one work?)
davison@drivax.DRI (Wayne Davison) (03/01/89)
In article <2800013@kailand> pwolfe@kailand.KAI.COM writes: >The two different cursor movement commands after the two ClearScreen calls in >ansi.c are correct. The problem with the two Goto() lines is not where they are sending the cursor TO but where they think they are coming FROM. In both cases they have just called ClearScreen() which outputs the termcap variable `cl'. This variable by definition both homes the cursor and clears the screen. Thus, in the <esc>c code, the Goto() is erroneous and should be removed. The call in the <esc>[2J code is correct. I guess I wasn't clear enough in my brevity -- I mentioned both of the Goto() calls because they were contradictory in the FROM fields, not because they (correctly) differed in the TO fields. I've received quite a few requests for my diffs, and I'm having a brief discussion with Oliver Laumann about what he'd like to see done with my screen patches (which I sent to him awhile back). My current plans are to post my changes to comp.sources.unix unless Oliver has objections or plans to do something official with them. -- Wayne Davison ...amdahl!drivax!davison
pwolfe@kailand.KAI.COM (03/06/89)
/* Written by davison@drivax.DRI in kailand:comp.sources.bugs */ > > In article <2800013@kailand> pwolfe@kailand.KAI.COM writes: > >The two different cursor movement commands after the two ClearScreen calls > >in ansi.c are correct. > > The problem with the two Goto() lines is not where they are sending the > cursor TO but where they think they are coming FROM. In both cases they > have just called ClearScreen() which outputs the termcap variable `cl'. > This variable by definition both homes the cursor and clears the screen. > Thus, in the <esc>c code, the Goto() is erroneous and should be removed. On the BSD TERMCAP(5) manpage, "cl" is defined as "clear the screen". It does not mention "and homes the cursor" anywhere. Maybe on the terminal you use, clearing the screen homes the cursor, but this is *NOT* true for every terminal. If you remove that Goto(), then you will break screen for some terminals. While this might not affect you, but if you post patches to the net, you might break it for someone else. Then again, since you are going to send your patches through comp.sources.unix, at least it probably won't get broken until sometime in the 1990's. :-) Patrick Wolfe (pat@kai.com, kailand!pat)
gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/08/89)
In article <2800015@kailand> pwolfe@kailand.KAI.COM writes: >On the BSD TERMCAP(5) manpage, "cl" is defined as "clear the screen". It >does not mention "and homes the cursor" anywhere. "cl" means "clear the screen and home the cursor", as described in the 4.3BSD TERMCAP(5) manual entry. - Douglas A. Gwyn 4.3BSD TERMCAP(5) manual entry editor
davison@drivax.DRI (Wayne Davison) (03/08/89)
In article <2800015@kailand> pwolfe@kailand.KAI.COM writes: >On the BSD TERMCAP(5) manpage, "cl" is defined as "clear the screen". It >does not mention "and homes the cursor" anywhere. Maybe on the terminal you >use, clearing the screen homes the cursor, but this is *NOT* true for every >terminal. If you remove that Goto(), then you will break screen for some >terminals. While this might not affect you, but if you post patches to the >net, you might break it for someone else. An interesting thing about documentation -- it is often misleading. The programmers of many popular packages (including vi & rn) assume that the variable "cl" homes the cursor. If you change your termcap to only clear the screen on a VT100 (from the default of cl=\E[2J\E[H), you will find that many applications cease to function correctly. It may not be documented that way, but that is the way it is defined in actual termcaps. If you still wish to leave the Goto() call in anyway, it should at least be changed to be: Goto (-1, -1, 0, 0); since you do not want an optimized cursor move after the ClearScreen() call if you don't think you know where the cursor really is. At least it would only be superfluous, instead of erroneous. -- Wayne Davison ...amdahl!drivax!davison
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (03/09/89)
In article <4370@drivax.DRI> davison@drivax.UUCP (Wayne Davison) writes:
: An interesting thing about documentation -- it is often misleading. The
: programmers of many popular packages (including vi & rn) assume that
: the variable "cl" homes the cursor.
"Assume" nothin'! Every system I've used documents "cl" as
Clear screen and home cursor
But it would be a reasonable thing to assume anyway, because many terminals
can't clear the screen without homing. You can go ahead and add your extra
Goto(), but at low baud rate it can be quite noticable. I prefer to think
that "cl" entries that don't home are busted.
Larry Wall
lwall@jpl-devvax.jpl.nasa.gov
root@cca.ucsf.edu (Systems Staff) (03/09/89)
In article <4533@jpl-devvax.JPL.NASA.GOV>, lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: : In article <4370@drivax.DRI> davison@drivax.UUCP (Wayne Davison) writes: : : programmers of many popular packages (including vi & rn) assume that : : the variable "cl" homes the cursor. : : "Assume" nothin'! Every system I've used documents "cl" as : : Clear screen and home cursor : I just looked in the 4.2BSD termcap(5) manual entry and it just says "Clear screen" for cl. Then I looked in the 4.3 Manual entry and it says "Clear screen and home cursor" so this matter has come up before and been dealt with. Please stop beating this dead horse. Thos Sumner (thos@cca.ucsf.edu) BITNET: thos@ucsfcca (The I.G.) (...ucbvax!ucsfcgl!cca.ucsf!thos) OS|2 -- an Operating System for puppets. #include <disclaimer.std>
allbery@ncoast.ORG (Brandon S. Allbery) (03/14/89)
As quoted from <2800015@kailand> by pwolfe@kailand.KAI.COM: +--------------- | /* Written by davison@drivax.DRI in kailand:comp.sources.bugs */ | > In article <2800013@kailand> pwolfe@kailand.KAI.COM writes: | > >The two different cursor movement commands after the two ClearScreen calls | > >in ansi.c are correct. | > | > have just called ClearScreen() which outputs the termcap variable `cl'. | > This variable by definition both homes the cursor and clears the screen. | | On the BSD TERMCAP(5) manpage, "cl" is defined as "clear the screen". It | does not mention "and homes the cursor" anywhere. Maybe on the terminal you +--------------- Beg your pardon, but... (1) Xenix termcap and Xenix and System V terminfo man pages all say that "cl" homes the cursor. (2) If it doesn't, then why do even BSD termcaps (so you can't argue that SV != BSD, which is irrelevant anyway because all SV termcap stuff comes from BSD; AT&T endorses terminfo, PERIOD) output BOTH sequences for common terminals where it takes separate sequences to clear the screen and home the cursor (ex: all DEC terminals)? I think this argument leaks somewhat. ++Brandon -- Brandon S. Allbery, moderator of comp.sources.misc allbery@ncoast.org uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu Send comp.sources.misc submissions to comp-sources-misc@<backbone> NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser
net@tub.UUCP (Oliver Laumann) (03/14/89)
In article <4533@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: > "Assume" nothin'! Every system I've used documents "cl" as > > Clear screen and home cursor Then you obviously haven't used an Integrated Solutions UNIX box running 4.2 BSD, where "cl" is documented as "clear screen" (i.e. no "and home cursor"). I have developed "screen" under Integrated Solutions 4.2 BSD and didn't want to introduce an additional symbol indicating whether or not "cl" homes the cursor. -- Oliver Laumann net@TUB.BITNET net@tub.UUCP