-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically detect terminal size #634
Comments
API to enable this:
|
FWIW I've done this with https://github.com/yschimke/oksocial-output/blob/master/src/main/kotlin/com/baulsupp/oksocial/output/ConsoleHandler.kt#L179 I'd love to switch to whatever you come up with particularly if it doesn't require launching commands etc. |
Thanks for the link, just saw that. (Wasn't aware of the My current approach is similar to what you did in ConsoleHandler, but still experimenting with various approaches to find something that also works in Cygwin. What the Lantern project is doing with the ANSI escape sequences may work, but also depends on executing (a number of) commands: |
FYI, here are two other ways to get the console width:
|
@charphi picocli 4.0.0-beta-2 should work (be able to detect the terminal width) with Powershell and MINGW. Is this not working correctly? |
I've not tested it yet. |
I see! That’s good. :-) |
What a coincidence that I found this after I was looking for a way to detect the console width. Can I find the console width with Java? mentions some of the same techniques mentioned here. fusesource/jansi#24 says to use jline, although I didn't understand why if jline3 used Jansi then why I couldn't use Jansi myself to find the console width. (I'm using Jansi already.) But it sounds like you've implemented something in this ticket to detect the console width. So how can I access the value picocli detected so that I can use it in my application? |
Oh, I see. 😭 You hid all that useful code deep in some private method. I'll open a ticket. |
The simplest solution is to rely on the
LINES
andCOLUMNS
environment variables. (Update: these are bash variables and may not be available as env variables unless explicitly exported...)shopt -s checkwinsize
is set. Apparently this is enabled by default.Alternatively (more advanced), the Lantern project (#633) shows how this can be done with ANSI escape sequences.
Example implementation to get the terminal size:
The text was updated successfully, but these errors were encountered: