Closed frossm closed 3 years ago
Yes, right now, you can define the method using
public static int getWindowsTerminalWidth() {
long outputHandle = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO info = new CONSOLE_SCREEN_BUFFER_INFO();
GetConsoleScreenBufferInfo (outputHandle, info);
return info.windowWidth();
}
Is that specific to windows ? I could re-introduce a helper function, but I don't really why it would be specific on windows. Maybe something like:
public static int getTerminalWidth() {
if ("Windows".equals(OSInfo.getOSName())) {
long outputHandle = Kernel32.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE);
Kernel32.CONSOLE_SCREEN_BUFFER_INFO info = new Kernel32.CONSOLE_SCREEN_BUFFER_INFO();
Kernel32.GetConsoleScreenBufferInfo(outputHandle, info);
return info.windowWidth();
} else {
CLibrary.WinSize sz = new CLibrary.WinSize();
CLibrary.ioctl(CLibrary.STDOUT_FILENO, CLibrary.TIOCGWINSZ, sz);
return sz.ws_col;
}
}
I'd have to check that it works on Cygwin and other enhanced Windows environments...
Hello,
Is that specific to windows ? I could re-introduce a helper function, but I don't really why it would be specific on windows. Maybe something like:
Such a function would be great for me too! Some of my code plays orund with the terminal in terms of ASCII-Art, and I just uncommented the detection of the console width for Windows using JANSI as I upgraded to the latest JANSI version. As soon as the helper methods will be avaialable, I will re-introduce JANSI's width detection as it was the most reliable one I encountered till now :-)
Hello,
With the update to jansi 2.0.1, I can't seem to find getWindowsTerminalWidth() anymore. Is there another function I should be using to get the the columns in the terminal window instead?
Here is the call I was using
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
terminalWidth = org.fusesource.jansi.internal.WindowsSupport.getWindowsTerminalWidth() - 1;
}
BTW, I love the library and use it on all of my projects. Thanks for all of the work on this.
Michael