TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Anatomy of a Terminal Emulator

304 pointsby imsnifover 3 years ago

13 comments

dundariousover 3 years ago
Casey Muratori&#x27;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&#x2F;failure), &quot;non-pessimisation&quot; (don&#x27;t do things extrinsic to the actual task), understanding the actual machine and its capabilities (he doesn&#x27;t use the term, but sometimes called &quot;mechanical sympathy&quot;), and tactics for isolating &quot;bad code&quot; that you probably have to use (at least to get started).<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=pgoetgxecw8" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=pgoetgxecw8</a>
评论 #29091739 未加载
lephover 3 years ago
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 &quot;professional&quot; 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&#x27;t find any literature on terminal emulators (what actually happened was that I didn&#x27;t know what to search for)<p>Anyways, I&#x27;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:&#x2F;&#x2F;github.com&#x2F;lee-pham&#x2F;Pyse-60" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;lee-pham&#x2F;Pyse-60</a>
评论 #29086759 未加载
hawskiover 3 years ago
I recommend going through st source: <a href="https:&#x2F;&#x2F;git.suckless.org&#x2F;st&#x2F;file&#x2F;st.c.html" rel="nofollow">https:&#x2F;&#x2F;git.suckless.org&#x2F;st&#x2F;file&#x2F;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.
评论 #29085663 未加载
评论 #29085589 未加载
timw4mailover 3 years ago
Why do I have to click a link to read the article? I don&#x27;t understand why it&#x27;s a thing to add a &quot;fold&quot; to a web article.<p>More on topic, this does seem like a decent overview.
评论 #29081074 未加载
评论 #29081105 未加载
评论 #29090480 未加载
michaelsbradleyover 3 years ago
For those interested in learning more about terminal emulators and character graphics, checkout Nick Black&#x27;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:&#x2F;&#x2F;nick-black.com&#x2F;htp-notcurses.pdf" rel="nofollow">https:&#x2F;&#x2F;nick-black.com&#x2F;htp-notcurses.pdf</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;dankamongmen&#x2F;notcurses#readme" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dankamongmen&#x2F;notcurses#readme</a>
doodpantsover 3 years ago
One thing I&#x27;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#&#x2F;.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.
评论 #29084033 未加载
评论 #29082866 未加载
评论 #29082569 未加载
davempover 3 years ago
Great article. Terminal emulators &#x2F; shells are an area where we haven&#x27;t seen much improvement for years. I can&#x27;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.
评论 #29083706 未加载
评论 #29085734 未加载
评论 #29081941 未加载
评论 #29081835 未加载
评论 #29083793 未加载
0xdkyover 3 years ago
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.
eatonphilover 3 years ago
Well done guide! Was visually enjoyable to read&#x2F;watch as well as being well-written.
chestervonwinchover 3 years ago
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 &quot;y&quot; in pty if it stands for pseudo terminal? Why is it call it a &quot;pseudo terminal&quot; if it&#x27;s acting like a communication pipe?
评论 #29114124 未加载
评论 #29091003 未加载
评论 #29091029 未加载
dekhnover 3 years ago
I absolutely love terminals. But, just about the time I could have learned curses, I switched to GUIs. Now I&#x27;ve switched back and uses curses to make UIs (so I can ssh into remote computers with low bandwidth and CPU). It&#x27;s so funny how terminals are controlled and all the edge cases of each implementation.
GekkePrutserover 3 years ago
Interesting article. It&#x27;s too late now for me to focus on it but I&#x27;ll check it out in the morning! :D Thanks for posting.
nothrowawaysover 3 years ago
The domain name is hilarious