Is there a way to manipulate terminal zoom and size with code using the standard library and essential POSIX libraries?

I am searching for a way to change the:

  • terminal zoom (primary)
  • terminal dimensions (secondary)

using only the standard C library and established essential libraries such as <unistd.h> and <termios.h>, etc. Using ncurses is not allowed.


Solution 1:

The Standard C library (as in ISO 9899:2018 or similar) doesn't know what a terminal is, much less how to change one. The answer to that is "NO" — the Standard C library has no such functions.

Originally (once upon a long time ago), terminals were hardware screens attached to a computer via an RS232 cable — Wyse 60 and DEC VT100 are two examples. Such terminals could not be resized — though you could sometimes change the display so that instead of 24x80 you got some larger number of columns to use.

If you're referring to a graphical terminal window on a modern Unix-based system, there probably are ways to change the size, but they involve using the insides of X11 — definitely not particularly easy, and definitely not provided by POSIX via <unistd.h> or <termios.h>; I don't think standard <curses.h> or <ncurses.h> would help either. And the mention of X11 immediately implies that it won't be portable to Windows, and what might work on Windows won't work on Unix — the API for Windows will be different.