[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cbreak+echo+nl: carriage return but no newline
From: |
G. Branden Robinson |
Subject: |
cbreak+echo+nl: carriage return but no newline |
Date: |
Tue, 12 Mar 2024 03:31:44 -0500 |
Hi folks,
I'm working on a revision of the getch(3X) man page and a simple
experiment has left me stumped. The attached sample program, as I
understand the man page, _should_ move the cursor down one row when the
user types a carriage return. But, for me, it doesn't.
Here's the existing man page language:
If echo is enabled, and the window is not a pad, then the character
will also be echoed into the designated window according to the
following rules:
• If the character is the current erase character, left arrow, or
backspace, the cursor is moved one space to the left and that
screen position is erased as if delch had been called.
• If the character value is any other KEY_ define, the user is
alerted with a beep call.
• If the character is a carriage‐return, and if nl is enabled, it
is translated to a line‐feed after echoing.
• Otherwise the character is simply output to the screen.
1. Echo is enabled.
2. The window is not a pad.
3. The carriage return "echoes" (the cursor moves to column 0).
4. The character is not erase, KEY_LEFT, or KEY_BACKSPACE.
5. The character is not some other KEY_* code.
6. The character is a carriage return.
7. "nl" is enabled.
8. No "translation" (or supplementary) line feed occurs.
What gives?
Regards,
Branden
P.S. Here's a draft of my revised language, but of course I'm not
confident about it until I resolve this issue.
If echo(3X) has been called, and the window is not a pad, curses
writes the returned character ch to the window (at the cursor
position) per the following rules.
• If ch matches the terminal’s erase character, the cursor moves
leftward one position and the new position is erased as if
wmove(3NCURSES) and then wdelch(3X) were called. When the
window’s keypad mode is enabled (see below), KEY_LEFT and
KEY_BACKSPACE are handled the same way.
• curses writes any other ch to the window, as with
wechochar(3X).
• If ch is a carriage return, and if cbreak(3X) and nl(3X) have
both been called, curses also performs a line feed.
As my (draft) commit message says:
* This function doesn't directly cause any beeping. I could not
reproduce the documented behavior nor does its implementation in
ncurses/base/lib_getch.c ever call "beep".
nl.c
Description: nl.c
signature.asc
Description: PGP signature
- cbreak+echo+nl: carriage return but no newline,
G. Branden Robinson <=
- Re: cbreak+echo+nl: carriage return but no newline, Thomas Dickey, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, Thomas Dickey, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, Thomas Dickey, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, G. Branden Robinson, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, Thomas Dickey, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, G. Branden Robinson, 2024/03/12
- Re: cbreak+echo+nl: carriage return but no newline, Gabriel Ravier, 2024/03/12
- Ken Arnold's curses paper (was: cbreak+echo+nl: carriage return but no newline), G. Branden Robinson, 2024/03/13
Re: cbreak+echo+nl: carriage return but no newline, G. Branden Robinson, 2024/03/25