-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tty: tty.WriteStream event 'resize' on Windows #13197
Comments
Quick answer currently no. It depends on |
Perhaps it's supported in WSL? |
FWIW, I've tried on Git Bash for Windows with the same result. |
Do you know if WSL has signals? |
libuv emulates
|
@richardlau This variant with a possibility to move cursor also does not work: process.stdout.on('resize', () => {
console.log('screen size has changed!');
console.log(`${process.stdout.columns}x${process.stdout.rows}`);
});
process.stdin.pipe(process.stdout); And the event handler by itself does not launch event loop, so it is hardly processed. Could we document this? I am not sure about wording and details. |
@vsemozhetbyt sounds like the correct course of action |
@richardlau do we need to move the cursor in a special way? Because the following does not fire. And console.log('hello')
console.log(`process.stdout.isTTY? ${process.stdout.isTTY}`)
process.stdout.on('resize', (e) => {
console.log(e);
console.log('screen size has changed!');
console.log(`${process.stdout.columns}x${process.stdout.rows}`);
});
setInterval(() => {
console.log(`${process.stdout.columns} X ${process.stdout.rows}`);
}, 1000); |
I have no idea; I just remembered that |
The console needs to be in raw mode for this to work (mind, this will not exit after ctrl-c): process.stdin.setRawMode(true);
process.stdin.on('data', () => {}); // to keep node from exiting
process.stdout.on('resize', (e) => {
console.log(`${process.stdout.columns}x${process.stdout.rows}`);
}); I guess an doc update should be made. |
@bzoz With this code, the event is processed when I change the size via terminal options but is ignored when I change the size manually. This is true for cmd.exe. For the git bash for Windows, manual width change fires the event, height change is ignored. |
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197
PR-URL: #13576 Fixes: #13197 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
PR-URL: #13576 Fixes: #13197 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
PR-URL: #13576 Fixes: #13197 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197
PR-URL: #13576 Fixes: #13197 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
PR-URL: #13576 Fixes: #13197 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197 PR-URL: libuv#1408 Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
Add SetWinEventHook for EVENT_CONSOLE_LAYOUT for better detection of console resize events. Ref: nodejs/node#13197 PR-URL: #1408 Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
Is this event supported on Windows?
The script with this code from the doc exits immediately without launching the event loop. I've tried to modify it like this:
and then to resize the console window manually or via the console window properties, but the event handler never fired.
The text was updated successfully, but these errors were encountered: