views:

173

answers:

2

I have a Perl script running in windows, that displays to screen very long lines.

I don't want to fix my console size permanently. I just want it to be big in case this script is running.

Is there a way to define the console's size from within the Perl script that runs inside this window?

+3  A: 

See Win32::Console. The sample program has a resize demonstration that works on my Windows XP SP3. I haven't tried it anywhere else.

Also, using a simple GUI consisting simply of a text-box might be easier.

Here is an adaptation of testWindow from the sample script:

use strict; use warnings;

use Win32::Console;

my $OUT = Win32::Console->new(STD_OUTPUT_HANDLE);
my $IN  = Win32::Console->new(STD_INPUT_HANDLE);
$IN->Mode(ENABLE_MOUSE_INPUT|ENABLE_WINDOW_INPUT);

$OUT->Size(180, 200);
my ($maxx, $maxy) = $OUT->MaxWindow;

$OUT->Cls;
$OUT->Cursor(-1, -1, -1, 0);

$OUT->FillAttr($BG_YELLOW|$FG_BLUE, $maxy * $maxx, 0, 0);
$OUT->FillChar('X', $maxy*$maxx, 0, 0);

$OUT->Window(1, 0, 0, $maxx, $maxy);

while ($maxx>1 and $maxy>1) {
    $maxx -= 5;
    $maxy -= 5;
    $OUT->Window(1, 0, 0, $maxx, $maxy);
    sleep 1;
}

$OUT->Window(1, 0, 80, 50);
$OUT->Cls;
Sinan Ünür
+3  A: 

You can set the console size of a running console with the mode command:

mode con lines=50 cols=200

The change will only persist until the console window is closed.

Eric Strom
EXCELLENT!Thank you Eric (-:
Roni
BUT... This affects also on the BUFFER size! making my scroll-up bar to disappear. How can I set the Buffer size seperately? After all, "right-click --> properties --> Layout" has FOUR parameters and not only two.Please advice...Thanks,Roni
Roni
@Roni => you can increase the scroll up bar by increasing the lines number, try several thousand.
Eric Strom
you can also type `mode` or `mode con` to get more information on the settings available
Eric Strom