Casey Muratori's refterm video series is a great example of how to do application design. It focuses on writing a terminal emulator for Windows, but almost all the concepts apply to nixes as well -- even down to the level of OS primitives like memory mappings to create a ring buffer, etc. He builds a nearly complete terminal that appears to better support unicode and escape sequences than windows-terminal, in drastically less code and with literally orders of magnitude better performance.<p>In particular, I like his focus on experimentation to figure out a reasonable upper bound on performance (so you can measure success/failure), "non-pessimisation" (don't do things extrinsic to the actual task), understanding the actual machine and its capabilities (he doesn't use the term, but sometimes called "mechanical sympathy"), and tactics for isolating "bad code" that you probably have to use (at least to get started).<p><a href="https://www.youtube.com/watch?v=pgoetgxecw8" rel="nofollow">https://www.youtube.com/watch?v=pgoetgxecw8</a>
While I was an economics student, I somehow landed a job to build out an elevator monitoring system at my college. Figured out that terminal emulators could connect to the elevator controller and that the output spec was called Wyse-60. My first "professional" program was written in Python using ncurses to parse the serial output [0].<p>The program is very cringe but it was my best attempt at the time as I couldn't find any literature on terminal emulators (what actually happened was that I didn't know what to search for)<p>Anyways, I've successfully pivoted my career away from economics and into software development which was the goal when I took the job in college.<p>[0]: <a href="https://github.com/lee-pham/Pyse-60" rel="nofollow">https://github.com/lee-pham/Pyse-60</a>
I recommend going through st source: <a href="https://git.suckless.org/st/file/st.c.html" rel="nofollow">https://git.suckless.org/st/file/st.c.html</a><p>I may have fallen out of love to suckless.org, but the code is usually simple so one can at least learn from it.
Why do I have to click a link to read the article? I don't understand why it's a thing to add a "fold" to a web article.<p>More on topic, this does seem like a decent overview.
For those interested in learning more about terminal emulators and character graphics, checkout Nick Black's book <i>Hacking the Planet (with Notcurses): A Guide to TUIs and Character Graphics</i>[1].<p>While the overall focus of the book is on programming with Notcurses[2], the author shares a wealth of related info and history throughout its pages.<p>[1] <a href="https://nick-black.com/htp-notcurses.pdf" rel="nofollow">https://nick-black.com/htp-notcurses.pdf</a><p>[2] <a href="https://github.com/dankamongmen/notcurses#readme" rel="nofollow">https://github.com/dankamongmen/notcurses#readme</a>
One thing I've been wondering for a long time (and my Google-fu is apparently too weak to find on my own): how do certain console applications change the output color <i>without</i> inserting ANSI escape sequences into the output stream? The specific case I have in mind is when writing console programs in C#/.NET, and using the System.Console.ForegroundColor property to vary output colors on the fly. The resulting output text does not have ANSI escape characters in it, yet the colors are displayed properly in the terminal.
Great article. Terminal emulators / shells are an area where we haven't seen much improvement for years. I can't help but think there could be a much nicer command-line-esque interface other than a classic psuedoterminal and shell. At the same time, I doubt any improvements could really be large enough to gain adoption.
Very well written article, thank you.<p>Especially when my daughter is taking a course on Unix and the instructor is superficially touching in these fundamental topics (due to their own limited understanding), I am going to use this to teach the underlying concepts.
I realize naming things is hard, but they confuse me. Are these due to historical quirks, or am I missing something?<p>E.g., why is it called a terminal emulator and not a terminal user interface? Why is there a "y" in pty if it stands for pseudo terminal? Why is it call it a "pseudo terminal" if it's acting like a communication pipe?
I absolutely love terminals. But, just about the time I could have learned curses, I switched to GUIs. Now I've switched back and uses curses to make UIs (so I can ssh into remote computers with low bandwidth and CPU). It's so funny how terminals are controlled and all the edge cases of each implementation.