use
5.014;
sub
main {
my
$key
;
my
$moved
= 0;
Console->BufferWidth(Console->BufferWidth + 4);
Console->Clear();
ShowConsoleStatistics();
do
{
$key
= Console->ReadKey(1);
if
(
$key
->Key == ConsoleKey->LeftArrow ) {
my
$pos
= Console->WindowLeft - 1;
if
(
$pos
>= 0 &&
$pos
+ Console->WindowWidth <= Console->BufferWidth) {
Console->WindowLeft(
$pos
);
$moved
= 1;
}
}
elsif
(
$key
->Key == ConsoleKey->RightArrow ) {
my
$pos
= Console->WindowLeft + 1;
if
(
$pos
+ Console->WindowWidth <= Console->BufferWidth ) {
Console->WindowLeft(
$pos
);
$moved
= 1;
}
}
if
(
$moved
) {
ShowConsoleStatistics();
$moved
= 0;
}
Console->WriteLine();
}
while
(1);
return
0;
}
sub
ShowConsoleStatistics {
Console->WriteLine(
"Console statistics:"
);
Console->WriteLine(
" Buffer: %d x %d"
, Console->BufferHeight,
Console->BufferWidth);
Console->WriteLine(
" Window: %d x %d"
, Console->WindowHeight,
Console->WindowWidth);
Console->WriteLine(
" Window starts at %d."
, Console->WindowLeft);
Console->WriteLine(
"Press <- or -> to move window, Ctrl+C to exit."
);
}
exit
main();