bug-ncurses
[Top][All Lists]
Advanced

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

Re: cbreak+echo+nl: carriage return but no newline


From: Thomas Dickey
Subject: Re: cbreak+echo+nl: carriage return but no newline
Date: Tue, 12 Mar 2024 18:47:57 -0400

On Tue, Mar 12, 2024 at 05:38:03PM -0500, G. Branden Robinson wrote:
> Hi Thomas,
> 
> At 2024-03-12T18:11:40-0400, Thomas Dickey wrote:
> > ...that "echoed" should remind the reader that text gets to the screen
> > by "addch" or something equivalent.
> 
> That's why part of my pending revision said this...
> 
> getch(3x):
>      •   curses writes any other ch to the window, as with
>          wechochar(3X).
> 
> It seemed useful to call out wechochar() specifically since it's getting
> called and doing a refresh() without my involvement.
> 
>         while (TRUE) {
>                 ch = getch();
>                 (void) napms(50);
>         }
> 
> With a preceding cbreak() and echo(), this loop is a perfectly useful,
> if dumb, typewriter.
> 
> > There probably are similar cases in other manpages...
> 
> Well, that's what ya have me around for.

hmm - sometimes I read the manpages, too.
 
> > either way, the test program returns ^J from getch for me for either
> > key...
> 
> Same here; my example was cut down from a slightly more elaborate one
> that reported the keycode.  I get back code 10 reliably no matter
> whether I press Return, ^M, or ^J.  But only ^J echoes as a line feed.
> 
> I guess the thing I missed that is that the semantics of the carriage
> return keystroke were honored before the translation of its keycode
> value.  I think I may have assumed that nl() and nonl() were
> manipulating the terminal state in the same way that "stty -ocrnl" does.
> (Or do I mean "stty -icrnl"?)
> 
> So all nl() and nonl() do is convert the keycode reported by wgetch()?
> 
> ...huh, wow, yes, it seems so.

the reasoning is lost in the mists of committee meetings thirty-some years ago
 
> Reading through the layers of preprocessor macros and OS/2 support,
> that's what I'm seeing in ncurses/base/lib_nl.c:54-88 and
> ncurses/base/lib_getch.c:650-651.
> 
> What is this feature _for_?  Disparate terminal behavior in the '80s,
> similar to the "backspace/delete is ^H!  no, it's ^?" we endured much
> more recently?
> 
> BTW some of my pending changes are not small.
> 
> $ COLUMNS=72 git diff --stat
>  man/curs_add_wch.3x   |  26 +-
>  man/curs_addch.3x     | 431 +++++++++++++++---------
>  man/curs_get_wch.3x   |  35 +-
>  man/curs_getch.3x     | 768 +++++++++++++++++++++++++++---------------
>  man/man_db.renames.in |   7 +
>  5 files changed, 820 insertions(+), 447 deletions(-)
> 
> The _wch ones will probably get bigger (synchronization).

okay... bear in mind that I'm working the kinks out of portability stuff,
to push out a release sometime (presumably before getting nagged by bugs)

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

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