Indeed, the screen size is dynamically variable - but if I remove/mark the sleep command than I can't see the screen resize.
And that is a problem because?
Perhaps you what to see it resize in steps, but with the sleep in there it takes too long, and without the sleep it happens so fast you don't see the intermediate positions?
If so, replace the sleep 1; with Win32::Sleep 100;; Adjust the number to suit.
I Would love to know what I was doing wrong, how can I make my current screen resize to 80*100 and stay on this size?
If you want to unconditionally change the screen size to 80x100, the try:
perl -MWin32::Console -e"Win32::Console->new(STD_OUTPUT_HANDLE)->Windo
+w(1, 0, 0, 50,50);"
But realise that the call will fail if you try to size the window so that some part of it will be outside of the screen: C:\test>perl -Mstrict -MWin32::Console -we"Win32::Console->new(STD_OUT
+PUT_HANDLE)->Window(1, 0, 0, 50,500) or die $^E;"
The parameter is incorrect at -e line 1.
In the above, the 'right' dimension specified (500) is bigger than my screen can handle with the currently selected font/size, so the call fails with "The parameter is incorrect".
See SetConsoleWindowInfo() for more info on this.
The thing to note here is that:
- ->Size( x, y ) specified the size of the Screen buffer, which can be huge 1000x1000 at least.
- ->Window( flag, top, left, bottom, right ); decides how big the window is.
This might get you started: #! perl -slw
use strict;
use List::Util qw[ max min ];
use Win32::Console;
my $OUT = Win32::Console->new(STD_OUTPUT_HANDLE);
my $origAttr = $OUT->Attr;
$OUT->Cls;
$OUT->Size(1000, 1000);
my ($maxx, $maxy) = $OUT->MaxWindow;
$OUT->Window( 1, 0, 0, $maxx-1, $maxy - 1 );
my $striped = chr( $FG_BLUE | $BG_WHITE ) . chr( $FG_LIGHTBLUE | $BG_L
+IGHTGRAY );
for my $row ( 1 .. 1000 ) {
$OUT->WriteAttr( $striped x 500, 0, $row );
$OUT->WriteChar( '1234567890' x 100, 0, $row );
}
for ( 1 .. 3 ) {
for my $n ( 0 .. $maxx - 2 ) {
$OUT->Window( 1, min( $maxx-2, $n ), min( $maxy-2, $n ), $maxx
+-1, $maxy-1 ) or die $^E;
Win32::Sleep 3 - $_;
}
for my $n ( 0 .. $maxx ) {
$OUT->Window( 1, 0, 0, min( $maxx-1, $n ), min( $maxy-1, $n )
+) or die $^E;
Win32::Sleep 3 - $_;
}
}
$OUT->Attr( $origAttr );
$OUT->Cls;
Mode command I used is good indeed, the only problem is that it disappear the buffer size and the user can't scroll the screen up and down
The mode command sets the size of the buffer.
It then also sets the size of the screen to (whichever is smaller of) that buffer size, or the maximum the screen can hold.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|