Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow some customization of terminal attributes #732

Open
xiaq opened this issue Aug 1, 2018 · 1 comment
Open

Allow some customization of terminal attributes #732

xiaq opened this issue Aug 1, 2018 · 1 comment

Comments

@xiaq
Copy link
Member

xiaq commented Aug 1, 2018

See @krader1961's comment in #706.

@krader1961
Copy link
Contributor

To improve the likelihood a search will find this issue below is the last comment I made in issue #706. The key point is that we want to allow the user to modify some tty attributes (typically via the stty command) but ensure that the tty is in a usable state when Elvish is running. The latter is to guard against programs which do not, or cannot (e.g., due to SIGKILL), restore the tty attributes when they exit.

===

The fish shell issue I linked to has two main schools of thought. I have seen people propose that fish should assume the tty is in a sane state and if it isn't require the user to type things like stty sane [ctrl-j]. Even for a grey beard like myself who was accustomed to typing that at least once a week back in the 1990's that proposal is absurd. The more sensible approaches are:

  1. Use a whitelist of tty attributes the user can change. Things like the magic chars like stty intr (the c_cc[VINTR] termios structure member) would be whitelisted.

  2. Use a blacklist of tty attributes it never makes sense for the user to change. This would include things like the ICANON flag.

Option 2 gives the user maximal control but also makes it more likely that a program that fails to exit cleanly or a stty command with a stupid set of options will leave the tty in a minimally usable but weird state. I prefer option 1. Primarily because in practice the only things these days that users seem to want to change are the canonical mode special chars. I can't recall the last time I needed to, or heard of anyone else needing to, change attributes like the parity, or enable translating uppercase to lowercase, or having the tty driver convert tabs to spaces. The only exception to this is enabling or disabling software flow control.

The problem with a way to signal to elvish that it should "run this command, and retain the terminal settings it makes" is it will be hard to discover. Yes, to the extent the whitelist and blacklist approaches might surprise a user who deliberately attempts to do stty -icanon, for example, I would argue that user deserves to be surprised 😄 The solution might be to display a warning message that the tty was not in a sane state and elvish corrected the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants