bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ken Arnold's curses paper (was: cbreak+echo+nl: carriage return but no n


From: G. Branden Robinson
Subject: Ken Arnold's curses paper (was: cbreak+echo+nl: carriage return but no newline)
Date: Wed, 13 Mar 2024 06:07:00 -0500

Hi Gabriel,

At 2024-03-13T01:23:57+0000, Gabriel Ravier wrote:
> Looking at the original documentation for curses from way back in
> 1980, i.e.  Kenneth C. R. C. Arnold's /Screen Updating and Cursor
> Movement Optimization: A Library Package/ paper (I'm pretty sure this
> is long before committee meetings were involved)

Thanks for this!  I was vaguely aware that this document existed but had
never bothered to look it up.  I found an online, rendered copy updated
by Elan Amir dated on the threshold of 1993 (the one from 4.4BSD, I
think), and consumed it at once.  (It's only 19 pages, and not dense.)
But, curious to observe the document's origin and development, I headed
over to TUHS and did some exploring on minnie.

I've noticed that NetBSD curses man pages trace the package's history
back to "4.0BSD".  curses indeed appears to arrive in 4BSD,[1] released
in October 1980.[2]

> (I'm pretty sure this is long before committee meetings were involved)

True, but those meetings might have discussed why certain points of
behavior explicitly called out in Arnold's paper were abandoned in the
process of standardization.

>states that:
> 
> - _nl_() and _nonl_() control what the documentation calls "newline
> mapping"

Yes.

> - when newline mapping is on and _waddch_() is passed a newline ('\n')
> as an input character, the line is cleared to the end and the y/x
> coordinates are changed to the beginning of the next line

Per my experiment, ncurses (given a _newline_, ^J) indeed behaves this
way.  Exhibit attached.

>- whereas if newline mapping is
> off the y/x coordinates are changed to the next line but at the same x
> coordinate.

ncurses does _not_ behave this way when I call nonl() instead of nl().
The screen updates the same way in both scenarios.  This is consistent
with characterizations earlier in the thread that I made of ncurses's
internals, and Thomas's...I won't say agreed, but that he didn't
contradict me.  ;-)

> - _raw_() and _noraw_() also respectively turn off and on newline
> mapping but "only on Version 7 UNIX" (though 4BSD appears to also have
> this behavior - likely the paper predatesk 4BSD and that's why this is
> not mentioned)

As noted above, I don't think the paper does predate 4BSD.  I think they
were contemporaneous.[1]

As a side note, one of the things I want to take out of ncurses man
pages are the repeated references to "Version 7 [Unix] curses"
(alongside BSD and System V).  As far as I can tell there was no such
thing.  I don't doubt that people carried the sources of sundry variants
of curses over to their PDP-11s running Seventh Edition, nor, given the
evidence you adduced above, that this was anticipated by BSD curses's
developers and some thought to Seventh Edition's terminal driver was
given.  Also, I'm aware of no account that Research Unix spent
measurable time on support for "glass teletypes".

But that doesn't mean there was Seventh Edition line of curses
development in the same way that there was for BSD and System V.  Once
they moved on from paper terminals, the Bell Labs CSRC's focus was on
graphical terminals and a considerable rethink of the Unix...UX, if you
will.[3]

Nevertheless, the foregoing points might be worth noting in the
"HISTORY" sections of curs_addch.3x and curs_inopts.3x, respectively.
I'll work up some language.

> - If newline mapping is not done, _refresh_() can "do more
> optimization" and thus "it is recommanded" to turn it off (this is
> also restated in an example program which has a comment on a call to
> _nonl_() stating "for optimization")

This, I don't think the ncurses documentation needs to say anything
about.  There seem to be several concessions to crude optimization
methods in Arnold's document that survived all the way to 4.4BSD, such
as the advice to move the cursor to the top-right corner of the screen
to "force absolute addressing" to be used when moving it to the
bottom-left corner upon exiting the application.  I reckon (1) ncurses's
optimization is smarter and (2) there's no point in doing this when the
terminal offers an "alternate screen", as xterm does.

> So it seems to be largely for optimization - the documentation doesn't
> mention any other reasons why someone would want to use it (I guess
> "some people might just want newline mapping in general" is implied).

I agree.  It seems like a...layering violation (take a drink).

> I will also add that in 4BSD those functions do in fact change the
> terminal mode, as mentioned before, using _stty_ to unset CRMOD -
> w.r.t. how this optimizes anything I'm not exactly clear on, and BSD
> developers that came after the original creation of curses seem to
> agree with that sentiment as well since BSD SCCS checkins on libcurses
> contain such quotes as "We still aren't sure what pfast is for, but we
> haven't given up yet" (in BSD's libcurses pfast is FALSE when newline
> mapping is on and TRUE when it is off)

/* You are not expected to understand this. */

We write such comments to our later regret...[4] ;-)

Regards,
Branden

[1] See, e.g.,

https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/include/curses.h
https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/man/man3/curses.3
https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/src/lib/libcurses/Makefile
https://minnie.tuhs.org/cgi-bin/utree.pl?file=4BSD/usr/doc/curses/Makefile

[2] https://www.oreilly.com/openbook/opensources/book/kirkmck.html

[3] https://www.tuhs.org/cgi-bin/utree.pl?file=V8
    http://doc.cat-v.org/bell_labs/blit/

[4] https://www.bell-labs.com/usr/dmr/www/odd.html

Attachment: nl2.c
Description: nl2.c

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]