How do I use a text terminal as a bitmap?

This is a discussion on How do I use a text terminal as a bitmap? within the C Programming forums, part of the General Programming Boards category; 1 pixel being one chat.
I've googled a bit around but all results mentioned curses like libraries, that, if I ...

How do I use a text terminal as a bitmap?

1 pixel being one chat.

I've googled a bit around but all results mentioned curses like libraries, that, if I understand it correctly, are more like a widget library than a canvas so to speak.
I would like to work at a lower level, but I don't have a good grasp of how a terminal really works.

Say I want to draw a cross of chars 'A' dividing the screen in half. Could anybody show me a simple snipet that would get me started?

If you resize the terminal window -- mine are practically never exactly 80 columns wide, nowadays --, it is seen as a keypress by the above program. Since it is not Q, it will redraw the screen. However, that screen update "keypress" also updates LINES and COLS, which means that the next iteration of the loop will redraw everything correctly, as per the resized terminal window. It's quite nifty, and pretty much exactly what I want from such a "terminal canvas".

As a programmer, all you need to remember is that COLS is not always 80, and LINES is not always 25 or 43 or 50, and both may change at any point if the user resizes the terminal window.

In Windows, you can use pdcurses, but I have no idea about the installation or compilation details since I don't use Windows at all. Maybe someone else can point out those details?

Thank you Nominal Animal. That is exactly the info I was looking for. being aware of such ncurses capabilities, I narrowed down my googling and found that this how-to on ncurses actually covers such uses of a text terminal rather well. I was being deceived by all the references to ncurses widgets. For some reason, all the documentation on ncurses out there focus too much on windows and widgets.

For now I'll stick with ncurses, although some time in the future I would actually like to know how terminals work at a lower level. What bugs me with good abstractions (such as ncurses) is that one doesn't get an accurate idea of how much processing power is required to perform a simple task.

Also check out pdcurses. It is not as feature-rich as ncurses, but the basic terminal access functions are all there. And it compiles/works on Windows as well as Linux.

In the end, these libraries will eventually call the functions of the host-os. In the case of Windows, this means calling the terminal-handling functions provided by the WIN32API. If its DOS, it means writing the appropriate attribute and character codes to address-range reserved for the text-terminal, etc. Abstraction layers like curses serve to makes it cross-platform compatible because the function calls like mvaddch should do the same thing no matter what system you're on.

Just about everything -- except Windows, of course -- uses some subset of ANSI escape codes. Many support POSIX.1-2001 termios interface for the terminal settings. In Linux, you'll probably also use at least one tty ioctl (TIOCGWINSZ, to get the new terminal size when a SIGWINCH signal is caught).

The kernel side support in Linux at least is very lightweight. Almost all the work is really done in your terminal application (or console driver, if you are using e.g. a framebuffer console). If you look at the ANSI escape codes, they're not difficult to support at all. Same for DOS; the libraries just manipulate the display buffer that consists of alternating character and attribute bytes, or rely on ANSI escape codes too, via ANSI.SYS. I suspect even Windows does not do anything overly complicated.

Overall, the curses interface seems a pretty good abstraction for this, in my opinion. It should not really be a surprise, considering it is decades old already, but still actively developed. ncurses, for example, started as pcurses in 1983 or so. First ncurses (version 1.8.1) was released in 1993.