Live data from Hacker News

Everything you ever wanted to know about terminals

xn--rpa.cc

41–50 of 191 posts

Re: Everything you ever wanted to know about terminals

#41
post #40

A while ago I was trying to find a way to make my terminal scroll back up after a command executed, so that if the output was long I could read it from the top without having to scroll up manually. There are ways to get yours shell to print something after the command executes, so I just needed to find an ansi escape sequence that would scroll up. Unfortunately I didn't see any sequences that do this. Anyone have any…

Maybe pipe output of every command into a script that invokes $PAGER when the output is long enough?

Re: Everything you ever wanted to know about terminals

#42

Earlier quoted context omitted.

I can’t agree more. An author who can’t be bothered to follow well established forms of style, grammar, and punctuation in a technical article somehow deflates whatever else they have to say even if accurate. It’s not as if they are trying to emulate the works of E. E. Cummings, James Joyce, or Arno Schmidt.

y'all are the most boring people on the planet istg. in the entire legion of internet writers making in depth technical content there is what, one who deviates from the conventions and you can't handle it. This author is a much much better writer than average for free technical content! They have an interesting, unique style! The typography and punctuation are part of that style! It would be tangibly worse if they ad…

> y'all are the most boring people on the planet

Citation needed. Please cite your source and make sure you strictly follow MLA format

Re: Everything you ever wanted to know about terminals

#43

You can't have "everything you wanted to know about terminals" with absolutely no mention of terminfo and (previously) termcap. You don't necessarily need ncurses to have a portable smart terminal experience, but you do need terminfo. ncurses magic relies on the lore stored in terminfo, which contains all of the obscure escape sequences and other information about the disparate world of terminals. They're maintained…

I've found that tcell works pretty well across many different OS terminals.

https://github.com/gdamore/tcell

Re: Everything you ever wanted to know about terminals

#44

off topic but I would love a version of this with a more "plain" colors/ punctuation/formatting. finding it very hard to read / navigate anyway the content looks good so will try to find time to sit down and read this "essay" soon

The colors are very distracting on my monitor.

Re: Everything you ever wanted to know about terminals

#45
This will be obvious to any C programmer, but the macro[1] used throughout the article only "works" on string literals and arrays, not pointers.

Also, it will include the null terminator. Probably won't do any harm but quite silly if you're redirecting to a file for example. I'd subtract one, or use strlen which would cover the pointer case above and I'd hope a modern compiler would elide the call on a string literal anyway.

[1] #define szstr(str) str,sizeof(str)

Re: Everything you ever wanted to know about terminals

#46
The author seems not to be aware of the recent TUI rennaisance[1]. There are libraries like termbox and blessings (python) that are a middle-ground between full ncurses and adding your own ansi codes. There are a lot of modern TUI frameworks like tui-go or tui-rs that bring common GUI conventions back to the TUI (heck there are TUI programming libraries that are designed to be similar to react) - these too tend to be a lot nicer than working with ncurses.

Definitely worth checking out the full landscape these days if you're going to dive into making your console programs prettier.

[1] My words, I just coined that name (although I wouldn't be surprised if others had said it too). I mean that in the last ~decade there has been a lot of TUI work in the background, with lots of new programs and some pretty stunning results. I blame unicode - once the web folks realized they could use something like font-awesome instead of sprite-sheets (or maybe as a pre-build sprite sheet?), and the "icons in a font" movement took hold, terminal programs got a lot prettier too. It makes sense, its the same font/font renderer provided by the system no matter if the app is a browser or terminal emulator.

Re: Everything you ever wanted to know about terminals

#47
post #24

Earlier quoted context omitted.

You couldn't find an authoritative spec because there isn't a universal standard. Lots of terminal emulators differ in different ways.

https://www.ecma-international.org/publications-and-standard...

Not all terminal emulators follow that completely. Most only include a subset and some include their own proprietary escape codes too (like iTerm and Terminology have codes for rendering images. tmux has an escape code for changing the session title).

Then there's other specs not included in that doc even outside of the aforementioned proprietary codes. Like Sixel, conventions on non-POSIX terminals, etc. Also lets not forget the popular-but-not-standardised conventions like the hyperlink escape codes (which I personally think shouldn't exist in the first place....but that's another topic entirely).

Even standard ASCII characters can differ from one platform to another. Backspace being a classic example: ISO 646 describe it as ^H whereas ASCII 1963 has it as ^?

This mess of differing compatibilities is exactly why termcap is a thing.

Being an author of a readline library, this is a topic quite close to my heart :)

Re: Everything you ever wanted to know about terminals

#48

You can't have "everything you wanted to know about terminals" with absolutely no mention of terminfo and (previously) termcap. You don't necessarily need ncurses to have a portable smart terminal experience, but you do need terminfo. ncurses magic relies on the lore stored in terminfo, which contains all of the obscure escape sequences and other information about the disparate world of terminals. They're maintained…

There is no need for the complexity of terminfo or termcap, because we have an ECMA/ANSI/ISO standard for terminal control. We have had it since before terminfo. ECMA-48 dates back to 1976. People have had 46 years to upgrade to standard-conforming terminals.

Terminfo is not a de jure standard, only de facto. It is not in POSIX.

POSIX specifies a tput command with exactly three operations: clear, init and reset.

Right here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...

There is a Rationale section giving reasons for why terminfo wasn't standardized.

Bottom line: ECMA/ANSI is the real standard that can be used to drive a conforming terminal from any OS, without any special library other than basic I/O.

Re: Everything you ever wanted to know about terminals

#49

Earlier quoted context omitted.

I can’t agree more. An author who can’t be bothered to follow well established forms of style, grammar, and punctuation in a technical article somehow deflates whatever else they have to say even if accurate. It’s not as if they are trying to emulate the works of E. E. Cummings, James Joyce, or Arno Schmidt.

y'all are the most boring people on the planet istg. in the entire legion of internet writers making in depth technical content there is what, one who deviates from the conventions and you can't handle it. This author is a much much better writer than average for free technical content! They have an interesting, unique style! The typography and punctuation are part of that style! It would be tangibly worse if they ad…

Best part is, every programmer has their own unique style as well. It doesn't stop us from running clang-format though

Re: Everything you ever wanted to know about terminals

#50

You can't have "everything you wanted to know about terminals" with absolutely no mention of terminfo and (previously) termcap. You don't necessarily need ncurses to have a portable smart terminal experience, but you do need terminfo. ncurses magic relies on the lore stored in terminfo, which contains all of the obscure escape sequences and other information about the disparate world of terminals. They're maintained…

As the article states: > being compatible only with ANSI-capable terminals is a feature, not a bug Driving old hardware terminals (as opposed to terminal emulators) is a fun stunt, not something of actual modern value. Every modern terminal emulator supports ANSI escape sequences. Some features are supported by a subset of terminals, but you can either 1) probe for those features by asking the terminal, which some te…

[deleted]
Post reply on HN