4 ms·
On this note, I need to build my own Terminal multiplexer - does anyone have a favorite primer of theirs for all the escape codes? Not only do I need to use the
by notheguyouthink 9y ago
On this note, I need to build my own Terminal multiplexer - does anyone have a favorite primer of theirs for all the escape codes? Not only do I need to use them myself, but I need to handle them of child processes to restrict term sizes etc.
I can Google like ya'll - I'm just asking if there are any favorite resources :)
Thanks
- teddyh 9y agoThere are no such things as “the” escape codes. Any terminal could have any codes. You would have to look at the TERM environment variable and use codes appropriate for that terminal. There are, of course, libraries to do this for you, such as terminfo and ncurses. But never output raw escape codes yourself - all the world is not a VT100 or Linux terminal.
- reacweb 9y agoI think the original poster does not want to output escape codes, he wants to build a terminal that will accept escape codes like a xterm. This way, he won't need to create a new terminal type with all the terminfo or ncurses configuration.
- teddyh 9y agoThe two other terminal multiplexers I know of are GNU screen and tmux. GNU screen defines its own “screen” terminal type in terminfo, and tmux shamelessly re-uses it and claims to be “screen-256color” (screen with 256 colors). So I don’t think there is any good way to avoid it.
- mjevans 9y agoI just assumed it's what someone who'd actually thought about the problem did for performance.
- bogomipz 9y ago>"shamelessly re-uses it and claims to be “screen-256color” Could you elaborate on this? Tmux uses the screen terminfo entry? Is it not actually 256?
- teddyh 9y agoIf I set my terminal type to something basic like vt102, and then start "tmux" and run "echo $TERM", I get "screen-256color". Also, the tmux(1) manual states: The TERM environment variable must be set to “screen” for all programs running inside tmux. New windows will automatically have “TERM=screen” added to their environment, but care must be taken not to reset this in shell start-up files. So, yes, Tmux uses the GNU screen terminfo entry.
- masukomi 9y agoI did some research a while back and what i recall is that Xterm is the Gold Standard, supporting more escape sequences than anything else. So, if you can come even close to what Xterm supports you're good. PDF of xterm control sequences https://www.x.org/docs/xterm/ctlseqs.pdf https://www.x.org/docs/xterm/ctlseqs.pdf This site is good to for explaining xterm's behavior: http://invisible-island.net/xterm/ http://invisible-island.net/xterm/ and how it came to be what it is and support what it does. I've seen claims that current command line tools are standardizing around the ECMA-48/ISO 6429/ANSI X3.64 escape code protocol
- JoshTriplett 9y agoThe xterm document pointed to elsewhere in the thread ( http://invisible-island.net/xterm/ctlseqs/ctlseqs.html http://invisible-island.net/xterm/ctlseqs/ctlseqs.html ) is the canonical reference, but I'd suggest using something like libvterm rather than writing that part yourself.
- tragomaskhalos 9y agoNot strictly answering your question, but years ago I worked on a job which comprised a group of us sitting in a room, each with a VT100 connected to a Unix box in the corner, cranking out C. We weren't massively overworked, so one clever bugger wrote his own terminal multiplexer on the side, enabling him to flip between sessions using function keys. Another guy wrote a shell - in Bourne shell. It had, errm, a few issues, but, crucially, gave us command line editing and history (that was otherwise lacking in the vanilla sh we had, and none of us fancied csh much).
- noir_lord 9y agoMy 2nd year college project (UK college not US very different things) was a VT100 emulator written in Delphi. In hindsight I should have done what the rest of the class did and took the Blackjack option but there was the option to do our own project instead, I demonstrated it worked by connecting it to my Linux laptop (this was '98, I was a strange 18yo). I was into LambdaMoo and mtrek at the time and I wanted to understand how they worked better :).
- woodrowbarlow 9y agowhy do you want to build your own multiplexer? is it just to learn the tech, or do you find screen/tmux aren't what you're looking for? (if the latter, what's lacking?) i'm not trying to say it's not worth building your own, i'm just curious.
- notheguyouthink 9y agoSorry, missed your comment. Yes, to learn the tech - but also to toy with ideas. I've been using Kakoune recently after years of Vim and while I enjoy it, it makes me wonder many things. After much speculation to myself, I decided to try implementing my ideas. I mainly expect them to fail, in the UX department at least, but I have to use it to really flesh it out. This may sound more editor oriented, and you'd be right, but for a simplest explanation a self made multiplexer like tmux/etc will be involved.
- woodrowbarlow 9y agocool! good luck.