Re: How does one find the terminal's width within the JVM?



Daniel Gee wrote:
Other than assuming it to be a standard 80x24 terminal, is there a
library call for it? The System class doesn't seem to have anything
for it, and the PrintStream class doesn't have anything on it either.
Am I just looking the wrong place?

If you are using an ANSI terminal emulator: The standard technique is to send the escape sequence to move to an absurdly large row and column position (<ESC>[999;999f) then query the cursor position (<ESC>[6n, which is responded to by <ESC>[{ROW};{COLUMN}R).

Telnet has command (NAWS) that reports changes in terminal sizes, but telnet commands are not available at the telnet stream level.

For Microsoft Windows console, I think in general you'd need native code.

Tom Hawtin
.