Hacker News new | past | comments | ask | show | jobs | submit login
Everything you ever wanted to know about terminals (xn--rpa.cc)
3 points by tosh on Oct 2, 2018 | hide | past | favorite | 4 comments



Sorry, unfortunately hardcoding escape sequences still won't work.

The smcup this uses is the one for st and kitty, and it's not valid for xterm, iterm, konsole, vte (e.g. gnome-terminal),....

That means it's not just "obscure dumb terminals from 1983". It's the majority of your userbase!

Which means you _need_ some kind of authoritative database of escape sequences, and you need to query that instead of building the strings yourself. Whether that database is terminfo or something new to replace it is up for debate - there's room for improvement over both it and ncurses - but that makes most of this irrelevant.


Most of these escape sequences have been standardized for ages in ECMA 48 (1976), ANSI X3.64 (1979), and ISO/IEC 6429 (early 1980s?) [1].

According to [1], the code for smcup given in the article, ESC[?1049h, or 'Enable alternative screen buffer', is a 'popular private sequence' so I suppose it is not guaranteed to work everywhere. But most of the content in the original article is still valid.

[1] https://en.wikipedia.org/wiki/ANSI_escape_code


> But most of the content in the original article is still valid.

Well.. I mean sure, you can program the things this article says that way.

But my point is that once you move even slightly beyond basic color, like the alternative buffer, or e.g. input, hard-coding escapes is going to bite you.

That means that if you recommend that, you are doing a disservice to people who don't know better.

And that means that "most of the content", line-by-line wise, is valid. But the sentiment behind that, the idea that "terminfo is a fucking joke" is invalid.

I'm also disputing that all this juggling of weird strings is in any way less work than using ncurses, so why not just use curses and have it "all" work? (Except for the stuff that curses doesn't handle or is slow to incorporate - 24-bit color has "just" gotten in)


Well OK, but that Wikipedia article warns, "Many programs, including text editors such as vi and GNU Emacs, still use termcap or terminfo, or use libraries such as curses that use termcap or terminfo, and thus in theory support non-ANSI terminals, but this is so rarely tested nowadays that they are unlikely to work with those terminals."




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: