News for hackers. Stuff that matters.
Re:Safe Terminal Escape Codes by arp242 on Wednesday May 22, 2024 @06:48PM (#40447712)
Hence "or read key input". And:

> Key input handling is kind of a mess, and this is where I really recommend using a terminfo library if at all possible. This also avoids the whole backspace/delete key confusion (less of an issue today than it used to be, but still exists).

Of course lots of applications don't use backspace or delete; sometimes you just want the ability to select between 3 items with j/k and arrow keys, or something like that. And if this is something just for yourself or a limited audience then it's fine to just read that from stdin and not worry too much.

Re:Safe Terminal Escape Codes by kragen on Wednesday May 22, 2024 @07:13PM (#40448001)
you are replying to a comment which specifically explains why it disagrees with the text you quoted from your essay
Re:Safe Terminal Escape Codes by rockorager on Thursday May 23, 2024 @07:32AM (#40453386)
I guess my point is that even for key input, you don't need terminfo. Modern terminals, and I would agree with your definition of that, all use the same keyboard encodings. There is the notable case of backspace/delete you mentioned but as I said - you can treat both as a backspace press.

All of that said, I am a huge proponent of the kitty keyboard protocol. I would love to live in a world where the "default" encoding of keys is done with the that protocol (with the disambiguate flag on)

Re:Safe Terminal Escape Codes by arp242 on Thursday May 23, 2024 @11:09AM (#40455667)
> I guess my point is that even for key input, you don't need terminfo.

Right, I read that the other way round ("no, you do need terminfo for key input")!

For basic input it's fairly straight-forward, and even for various "special" keys like arrows and function keys it's not too bad: just check from a list.

But with modifier keys it gets more tricky; lots of that isn't even in terminfo and requires "special" handling.

If you know how this works and you know what you're doing it can be fine, but for most people it's far easier to just use a terminfo library that does this for you.

And yeah, Kitty keyboard protocol being the default would be brilliant. Right now support is (far) too flaky though, so maybe in 5 to 10 years.