-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: Stabilize Deno.consoleSize() API #15933
feat: Stabilize Deno.consoleSize() API #15933
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just a note: this op can be a fast call, if the ConsoleSize
result is put into a Uint32Array
buffer.
I am not in favor of stabilizing as is, because it takes in a rid parameter. Should be |
@littledivy good point, I'll update the PR. @lucacasonato also a good point. I'll rework it. |
@lucacasonato one question though: should we make it |
Yeah sorry, that makes a lot more sense indeed. |
What if both stdout and stderr are piped, but you still want to get the console size? I think this should just be on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should think more about how this would work with a pty before stabilizing (also, not done yet, but we shouldn't move this method to stdout and stderr). Additionally, this function should probably just work without providing an rid, then you provide the rid of a pty to get its size.
In that case, does it even need a rid parameter? Can it just be |
Yes, I think that would be best. Also, related to the other |
If they are both piped, is there even a console? I might have the concept wrong! The use case I came looking for consoleSize was for finding the word-wrap width for displaying help text from a command-line utility. The help is being displayed to either stdout or stderr, and I was expecting to find the width of the one being used, which might be a pipe (and hence width not known). |
@shadowspawn huh, I thought there was some low level api to still get it based on the parent process (or console group or whatever it's called) because I had seen api's like That said, I still think we should consider just making this
Perhaps in a future api (with const size = Deno.stdout.isatty() ? Deno.consoleSize() : undefined; |
I changed the API to not accept any arguments. It will use stdin handle to get the size of the console. @dsherret @lucacasonato please take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but there is an std submodule update that I think should be reverted?
Not really, after merging this PR I will update |
Oh, I see. |
Closes #15929