Special cursor for special modes (e.g. password entry)
@egmontkob
Submitted by Egmont Koblinger Link to original bug (#755371)
Description
Mac Terminal switches the cursor to a rectangle with a circle hole inside when it's reading a password. (Screenshot: https://www.maketecheasier.com/assets/uploads/2014/11/Yosemite-Bootable-Disk-Password.jpg)
The reason I like it is because many people coming from the usual standard graphical environments get surprised and stuck why there are no dots printed after every keypress. This gives them a clue that something special's going on and it's not that the terminal became totally deaf.
With similar analogy, I think the scroll locked state or the read-only mode of the terminal could also be shown in the cursor. It has happened to me many times (even recently, after many years in the Unix world I still get tricked) that I accidentally press ^S and think that the application froze.
I don't think there's a way to get notified when the termios settings change. Since it's a UI thing, we could just poll the termios with a certain FPS to always display the cursor perfectly, but that's a waste of resources.
Password: Mac Terminal.app looks for the cooked + no local echo combo. It seems to check the state after processing incoming characters, or before a UI update - not sure which. With a manual "sleep 1; stty -echo" it can be tricked into not changing the cursor when it should. But in glibc the getpass() call happens to first switch the tty settings and then print the prompt, so with a nonempty prompt it would change the cursor shape reliably.
^S/^Q: I think we should watch the input: Whenever the user presses a control character that we'd send to the tty, we can check the termios and manually figure out whether that'll block or release the output. I think this again would work quite reliably in practice.
Read-only mode: Piece of cake since we explicitly know that.
Version: git master