I have a few general questions about writing C++ programs and running them from Unix shells. Is there a way to ask the shell for it's size? Either in pixels, characters, whatever? What about relocating the cursor within the window? How would you do this if you needed to?
Asked
Active
Viewed 404 times
2 Answers
2
With the ncurses
library, getting the terminal width (in characters) is as easy as calling the function getmaxx
. Similarly, getmaxy
returns the height, and getmaxyx
gets them both at once.
The cursor can be moved by calling move
with the x and y coordinates.

Emil Laine
- 41,598
- 9
- 101
- 157
-
Actually, `LINES` and `COLS` are the usual place to get the screen-size, subject to `use_env`. The getmax* functions are for a given window, which could be smaller than `stdscr`. – Thomas Dickey Mar 27 '15 at 08:40