Standard input and output are connected to a terminal that implements ANSI escape sequences, but is of unknown dimensions.
I need to know how big the terminal so to facilitate drawing a full-screen text UI on it. How can I get the size?
The correct size is not loaded into environment variables. I cannot use TIOCGETS; the the call would return success but the values are not correct -- the kernel doesn't know the size either.
There are lots and lots of answers searching stackoverflow, but they all depend on the OS providing the answer one way or anther; but this time that is not true.
The best clue I can find is the DSR command which returns the current cursor position; but there's no move to bottom/right command.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…