[spoiler]I've had a bit of an issue with ncurses as of recent. To my taste it's horribly clunky taking the concept of a simple abstraction library for controlling a terminal to horrible proportions. This is potentially due to the (SVU) age of curses, but regardless I'm trying to create a new library from scratch to improve curses/ncurses and make it easier to program for.
That brings up a rather critical issue, though. How do you control a terminal?
On Linux/Unix machines, terminals, like everything else, are files. If you write to a terminal, it gets input to the terminal as if you were to (in theory) type into it. If you /read/ from a terminal, you will get whatever was typed in on the terminal, in theory.
This is the purpose of this forum post, to document all the stuff I've found out about how to control a common terminal arbitrarily in Linux and Unix platforms (or any platform that uses the same tty interface).[/spoiler]
NOTE: What I say might be wrong, don't take this as a primary source, information is subject to be corrected and changed. This is my current understanding.
To start off with, the tty is a serial interface. In particular this means that you can only write and read data sequentially. You cannot get big blocks of data (as far as I know, there might be escapes for this).
There is a big list of escape characters available on the old XFree86 website here: https://www.xfree86.org/current/ctlseqs.html
This contains a large bulk of things needed to tell the terminal to do various things. This is for /common/ terminals, not all terminals. In theory anything could be at the other end of a tty interface because it literally is just a serial interface identifying as a terminal with a baud rate and everything. Since most people are targeting VT compatible terminals like xterm (and derivatives), this list is pretty comprehensive.
There will be more.