coreutils
[Top][All Lists]
Advanced

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

Re: Unset ICRNL in CBREAK mode in stty(1) following X/Open Curses


From: Kaz Kylheku
Subject: Re: Unset ICRNL in CBREAK mode in stty(1) following X/Open Curses
Date: Mon, 22 Jan 2024 18:24:30 -0800
User-agent: Roundcube Webmail/1.4.15

On 2024-01-21 22:41, Soumendra Ganguly wrote:
> Doing this might be useful for users who expect curses like behavior
> without having to worry about *what
> exactly* needs to be done to get curses like behavior (such as clearing
> ICRNL).

I suspect that is only you, and when you've moved on from this issue,
that will leave zero users for the feature.

Note that with the GNU stty, you can can use "stty raw" to put the
TTY into a useful mode for character-oriented interaction:

This is documented as:

   -ignbrk  -brkint  -ignpar -parmrk -inpck -istrip -inlcr
   -igncr -icrnl -ixon -ixoff -icanon
   -opost -isig -iuclc -ixany -imaxbel -xcase min 1 time 0

Note that it doesn't touch the return/linefeed related output modes.
If previously \n characters are being converted to \r\n, then this is
not disabled by "stty raw", and you often don't want that.
Because then your \n terminated prints will
look
     like
         this!

The -ixon and -ixoff is important in "stty raw"; without
that your program will not be able to have Ctrl-S or
Ctrl-Q commands (if those are the configured xon/xoff
characters.)

I'm reasonably sure that if you're cobbing together some
character-oriented editing or menu system or whatever in
the shell, then "stty raw" will stand you in good stead.

Forget about "cbreak"; it doesn't have enough content.
When asserted, all it does is clear "-icanon": one single
mode.

Remember to save the settings using "saved_tty=$(stty -g)". 
POSIX requires the state string not to require quoting, so
the settings can be restored with "stty $saved_tty".

You can put that into interrupt and exit handlers in a script
to make sure that the terminal is restored in most common
termination circumstances.






reply via email to

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