Reputation: 25117
When I call this script on a Linux OS Term::Size::Any (chars
) and Term::ReadKey (GetTerminalSize
) return always the same number of columns.
When I call the script on a Windows machine the returned number of columns differ as soon as I resize the terminal with the mouse to a smaller size. chars
returns the new width while GetTerminalSize
returns the initial terminal width.
Is there a trick to get from GetTerminalSize
the new resized terminal width?
use strict;
use warnings;
use 5.10.0;
use Term::Size::Any qw(chars);
use Term::ReadKey qw(GetTerminalSize);
say( ( chars( \*STDOUT ) )[0] );
say( ( GetTerminalSize( \*STDOUT ) )[0] );
Upvotes: 2
Views: 135
Reputation: 5598
What you are currently doing is not called "resizing", the terminal screen size is still the same, you are just diminishing the terminal visible size.
To change the Window Terminal "size", click on the top left corner, go to Properties change the "Screen Buffer Size", at the moment you are just changing the "Window Size"
Upvotes: 1