I'm in the process of building a new terminal emulator. Yes, I know they're already a dime a dozen but I have plans to take this into a different direction.
Anyhow, the big problem I have is that there are literally hundreds of escape codes that you need to support even just to reach parity with xterm. And while I've been trawling through xterm's docs (eg https://www.xfree86.org/current/ctlseqs.html ) they don't really go into much detail regarding how the actual implementation should look like.
for example: CSI n S (Scroll Up), should that insert empty lines at the bottom (ie scrolling the content up) or scroll back through the buffer?
Admittedly a lot of the codes are pretty self-explanatory and I can fill in a lot of missing gaps via testing those escape codes in other terminal emulators. But having a detailed reference doc would certainly save a lot of time (and reduce the risk of error too).
To be clear, what I'm looking for is a more exhaustive list of escape codes rather than the common ones everyone already knows like SGR.
Thanks in advance :)
That being said:
> for example: CSI n S (Scroll Up), should that insert empty lines at the bottom (ie scrolling the content up) or scroll back through the buffer?
As a general rule, nothing interacts with scrollback. CSI S inserts empty lines at the bottom of the screen and deletes lines from the top; conversely, CSI T inserts empty lines at the top and deletes from the bottom.
Which operations should touch the scrollback is debatable. My inclination is to only append to scrollback when scrolling occurs "naturally" as the result of a newline or wrap, and neither DECSTBM nor the alternate screen are active at the time. (DECSTBM and alt-screen tend to indicate that a full-screen application is running, so saving rows to scrollback is unlikely to be meaningful.)
All of them are open source, why don't you check how they end up emitting escape sequences? My guess would be through abstraction via something like terminfo/termcap. Ncurses might be another place to look at.
Don't forget about dynamic resizing from day one. That won't be mentioned in old documents from the VT100 times. Don't remember which VT was the first one that could be switch to 132(?) characters a line.
A classic terminal only has a screen full of memory: it does have extra memory that would allow it to scroll backwards.
The ESC [ S command (CSI itself can only be used if you are sure the line to the terminal is 8-bit clean, and as a third-party developer, I could not guarantee that) scrolls the scrolling region. The scrolling region is either the entire screen, or it's just a couple of line at the bottom. A scrolling region is used so the use can have a scrolling place to type commands and Aldo have a non-scrolling area to display data.
it might help but not sure how comprehensive it is! would it be a bad idea for you to check out the source code of other popular emulators (maybe iTerm 2^0) ?
0: https://github.com/search?q=repo%3Agnachman%2FiTerm2%20ansi&...
https://news.ycombinator.com/item?id=26011198
Also, search Hacker News for the links above.
Though, I kinda suspect “xterm” is the defacto modern standard.
VK100 ESCape sequences start on Page 59 https://vt100.net/dec/vk100in2.pdf
GIGI BASIC at http://bitsavers.org/pdf/dec/terminal/gigi/AA-K335A-TK_GIGI_... (read bottom of page 1-1 carefully --think of the possibilities...you may want to add a security feature to limit that here in the post-dystopian wasteland)
VT102/400 ESCape sequences at https://manx-docs.org/collections/mds-199909/cd3/term/vt420r...
The state of the art in this area is a commercial product by a small team in Arizona at https://vandyke.com/products/securecrt/index.html
Applause for not being afraid to take on a concept that's been done (wrong) many times.