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: Soumendra Ganguly
Subject: Re: Unset ICRNL in CBREAK mode in stty(1) following X/Open Curses
Date: Tue, 23 Jan 2024 05:18:19 +0100

On Tue, Jan 23, 2024 at 3:24 AM Kaz Kylheku <kaz@kylheku.com> wrote:

> 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.
>
> Haha. That might be correct :D


> 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!
>
>
Yes, this one I know.


> 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.
>
> Agreed.

> Forget about "cbreak"; it doesn't have enough content.
> When asserted, all it does is clear "-icanon": one single
> mode.
>
> Agreed. I was just volunteering in case someone really wanted a
cursescbreak.


> 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.
>
>
> Yes, I know this one. I have a very useful script (which I call sane.sh; I
will share on GitHub ONLY if you want since I do not wish to avoid writing
docs  :)) which goes to great lengths to fix a terminal if something goes
wrong using a combination of stty, reset, tput, setterm, etc: it fixes
termios, winsize, character set, rendering options, cursor, etc. I also
have a separate shell alias that fixes the standard fds.

Thank you; I learned a lot...

...and this goes without saying: I love coreutils. I just learned about
nl(1) yesterday; I will be using it (as an alternative to
rectangle-number-lines) to number lines in regions in emacs! I am also
using it in combination with awk(1) to index git commits as a part of a
dependency-free way of quickly selecting a commit based on a numerical
index from the command line.

Sincerely,
Soumendra


reply via email to

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