"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/tlperl/site/lib/Win32/Console.pm" (5 Apr 2016, 37763 Bytes) of package /windows/misc/install-tl.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #######################################################################
    2 #
    3 # Win32::Console - Win32 Console and Character Mode Functions
    4 #
    5 #######################################################################
    6 
    7 package Win32::Console;
    8 
    9 require Exporter;
   10 require DynaLoader;
   11 
   12 $VERSION = "0.10";
   13 
   14 @ISA= qw( Exporter DynaLoader );
   15 @EXPORT = qw(
   16     BACKGROUND_BLUE
   17     BACKGROUND_GREEN
   18     BACKGROUND_INTENSITY
   19     BACKGROUND_RED
   20     CAPSLOCK_ON
   21     CONSOLE_TEXTMODE_BUFFER
   22     CTRL_BREAK_EVENT
   23     CTRL_C_EVENT
   24     ENABLE_ECHO_INPUT
   25     ENABLE_LINE_INPUT
   26     ENABLE_MOUSE_INPUT
   27     ENABLE_PROCESSED_INPUT
   28     ENABLE_PROCESSED_OUTPUT
   29     ENABLE_WINDOW_INPUT
   30     ENABLE_WRAP_AT_EOL_OUTPUT
   31     ENHANCED_KEY
   32     FILE_SHARE_READ
   33     FILE_SHARE_WRITE
   34     FOREGROUND_BLUE
   35     FOREGROUND_GREEN
   36     FOREGROUND_INTENSITY
   37     FOREGROUND_RED
   38     LEFT_ALT_PRESSED
   39     LEFT_CTRL_PRESSED
   40     NUMLOCK_ON
   41     GENERIC_READ
   42     GENERIC_WRITE
   43     RIGHT_ALT_PRESSED
   44     RIGHT_CTRL_PRESSED
   45     SCROLLLOCK_ON
   46     SHIFT_PRESSED
   47     STD_INPUT_HANDLE
   48     STD_OUTPUT_HANDLE
   49     STD_ERROR_HANDLE
   50     $FG_BLACK
   51     $FG_GRAY
   52     $FG_BLUE
   53     $FG_LIGHTBLUE
   54     $FG_RED
   55     $FG_LIGHTRED
   56     $FG_GREEN
   57     $FG_LIGHTGREEN
   58     $FG_MAGENTA
   59     $FG_LIGHTMAGENTA
   60     $FG_CYAN
   61     $FG_LIGHTCYAN
   62     $FG_BROWN
   63     $FG_YELLOW
   64     $FG_LIGHTGRAY
   65     $FG_WHITE
   66     $BG_BLACK
   67     $BG_GRAY
   68     $BG_BLUE
   69     $BG_LIGHTBLUE
   70     $BG_RED
   71     $BG_LIGHTRED
   72     $BG_GREEN
   73     $BG_LIGHTGREEN
   74     $BG_MAGENTA
   75     $BG_LIGHTMAGENTA
   76     $BG_CYAN
   77     $BG_LIGHTCYAN
   78     $BG_BROWN
   79     $BG_YELLOW
   80     $BG_LIGHTGRAY
   81     $BG_WHITE
   82     $ATTR_NORMAL
   83     $ATTR_INVERSE
   84     @CONSOLE_COLORS
   85 );
   86 
   87 
   88 #######################################################################
   89 # This AUTOLOAD is used to 'autoload' constants from the constant()
   90 # XS function.  If a constant is not found then control is passed
   91 # to the AUTOLOAD in AutoLoader.
   92 #
   93 
   94 sub AUTOLOAD {
   95     my($constname);
   96     ($constname = $AUTOLOAD) =~ s/.*:://;
   97     #reset $! to zero to reset any current errors.
   98     local $! = 0;
   99     my $val = constant($constname, @_ ? $_[0] : 0);
  100     if ($! != 0) {
  101 #    if ($! =~ /Invalid/) {
  102 #        $AutoLoader::AUTOLOAD = $AUTOLOAD;
  103 #        goto &AutoLoader::AUTOLOAD;
  104 #    } else {
  105         ($pack, $file, $line) = caller; undef $pack;
  106         die "Symbol Win32::Console::$constname not defined, used at $file line $line.";
  107 #    }
  108     }
  109     eval "sub $AUTOLOAD { $val }";
  110     goto &$AUTOLOAD;
  111 }
  112 
  113 
  114 #######################################################################
  115 # STATIC OBJECT PROPERTIES
  116 #
  117 
  118 # %HandlerRoutineStack = ();
  119 # $HandlerRoutineRegistered = 0;
  120 
  121 #######################################################################
  122 # PUBLIC METHODS
  123 #
  124 
  125 #========
  126 sub new {
  127 #========
  128     my($class, $param1, $param2) = @_;
  129 
  130     my $self = {};
  131 
  132     if (defined($param1)
  133     and ($param1 == constant("STD_INPUT_HANDLE",  0)
  134     or   $param1 == constant("STD_OUTPUT_HANDLE", 0)
  135     or   $param1 == constant("STD_ERROR_HANDLE",  0)))
  136     {
  137         $self->{'handle'} = _GetStdHandle($param1);
  138     }
  139     else {
  140         $param1 = constant("GENERIC_READ", 0)    | constant("GENERIC_WRITE", 0) unless $param1;
  141         $param2 = constant("FILE_SHARE_READ", 0) | constant("FILE_SHARE_WRITE", 0) unless $param2;
  142         $self->{'handle'} = _CreateConsoleScreenBuffer($param1, $param2,
  143                                                        constant("CONSOLE_TEXTMODE_BUFFER", 0));
  144     }
  145     bless $self, $class;
  146     return $self;
  147 }
  148 
  149 #============
  150 sub Display {
  151 #============
  152     my($self) = @_;
  153     return undef unless ref($self);
  154     return _SetConsoleActiveScreenBuffer($self->{'handle'});
  155 }
  156 
  157 #===========
  158 sub Select {
  159 #===========
  160     my($self, $type) = @_;
  161     return undef unless ref($self);
  162     return _SetStdHandle($type, $self->{'handle'});
  163 }
  164 
  165 #===========
  166 sub SetIcon {
  167 #===========
  168     my($self, $icon) = @_;
  169     $icon = $self unless ref($self);
  170     return _SetConsoleIcon($icon);
  171 }
  172 
  173 #==========
  174 sub Title {
  175 #==========
  176     my($self, $title) = @_;
  177     $title = $self unless ref($self);
  178 
  179     if (defined($title)) {
  180     return _SetConsoleTitle($title);
  181     }
  182     else {
  183     return _GetConsoleTitle();
  184     }
  185 }
  186 
  187 #==============
  188 sub WriteChar {
  189 #==============
  190     my($self, $text, $col, $row) = @_;
  191     return undef unless ref($self);
  192     return _WriteConsoleOutputCharacter($self->{'handle'},$text,$col,$row);
  193 }
  194 
  195 #=============
  196 sub ReadChar {
  197 #=============
  198     my($self, $size, $col, $row) = @_;
  199     return undef unless ref($self);
  200 
  201     my $buffer = (" " x $size);
  202     if (_ReadConsoleOutputCharacter($self->{'handle'}, $buffer, $size, $col, $row)) {
  203         return $buffer;
  204     }
  205     else {
  206         return undef;
  207     }
  208 }
  209 
  210 #==============
  211 sub WriteAttr {
  212 #==============
  213     my($self, $attr, $col, $row) = @_;
  214     return undef unless ref($self);
  215     return _WriteConsoleOutputAttribute($self->{'handle'}, $attr, $col, $row);
  216 }
  217 
  218 #=============
  219 sub ReadAttr {
  220 #=============
  221     my($self, $size, $col, $row) = @_;
  222     return undef unless ref($self);
  223     return _ReadConsoleOutputAttribute($self->{'handle'}, $size, $col, $row);
  224 }
  225 
  226 #==========
  227 sub Write {
  228 #==========
  229     my($self,$string) = @_;
  230     return undef unless ref($self);
  231     return _WriteConsole($self->{'handle'}, $string);
  232 }
  233 
  234 #=============
  235 sub ReadRect {
  236 #=============
  237     my($self, $left, $top, $right, $bottom) = @_;
  238     return undef unless ref($self);
  239 
  240     my $col = $right  - $left + 1;
  241     my $row = $bottom - $top  + 1;
  242 
  243     my $buffer = (" " x ($col*$row*4));
  244     if (_ReadConsoleOutput($self->{'handle'},   $buffer,
  245                           $col,  $row, 0,      0,
  246                           $left, $top, $right, $bottom))
  247     {
  248         return $buffer;
  249     }
  250     else {
  251         return undef;
  252     }
  253 }
  254 
  255 #==============
  256 sub WriteRect {
  257 #==============
  258     my($self, $buffer, $left, $top, $right, $bottom) = @_;
  259     return undef unless ref($self);
  260 
  261     my $col = $right  - $left + 1;
  262     my $row = $bottom - $top  + 1;
  263 
  264     return _WriteConsoleOutput($self->{'handle'},   $buffer,
  265                                $col,  $row, 0,  0,
  266                                $left, $top, $right, $bottom);
  267 }
  268 
  269 #===========
  270 sub Scroll {
  271 #===========
  272     my($self, $left1, $top1, $right1, $bottom1,
  273               $col,   $row,  $char,   $attr,
  274               $left2, $top2, $right2, $bottom2) = @_;
  275     return undef unless ref($self);
  276 
  277     return _ScrollConsoleScreenBuffer($self->{'handle'},
  278                                       $left1, $top1, $right1, $bottom1,
  279                                       $col,   $row,  $char,   $attr,
  280                                       $left2, $top2, $right2, $bottom2);
  281 }
  282 
  283 #==============
  284 sub MaxWindow {
  285 #==============
  286     my($self, $flag) = @_;
  287     return undef unless ref($self);
  288 
  289     if (not defined($flag)) {
  290         my @info = _GetConsoleScreenBufferInfo($self->{'handle'});
  291         return $info[9], $info[10];
  292     }
  293     else {
  294         return _GetLargestConsoleWindowSize($self->{'handle'});
  295     }
  296 }
  297 
  298 #=========
  299 sub Info {
  300 #=========
  301     my($self) = @_;
  302     return undef unless ref($self);
  303     return _GetConsoleScreenBufferInfo($self->{'handle'});
  304 }
  305 
  306 #===========
  307 sub Window {
  308 #===========
  309     my($self, $flag, $left, $top, $right, $bottom) = @_;
  310     return undef unless ref($self);
  311 
  312     if (not defined($flag)) {
  313         my @info = _GetConsoleScreenBufferInfo($self->{'handle'});
  314         return $info[5], $info[6], $info[7], $info[8];
  315     }
  316     else {
  317         return _SetConsoleWindowInfo($self->{'handle'}, $flag, $left, $top, $right, $bottom);
  318     }
  319 }
  320 
  321 #==============
  322 sub GetEvents {
  323 #==============
  324     my($self) = @_;
  325     return undef unless ref($self);
  326     return _GetNumberOfConsoleInputEvents($self->{'handle'});
  327 }
  328 
  329 #==========
  330 sub Flush {
  331 #==========
  332     my($self) = @_;
  333     return undef unless ref($self);
  334     return _FlushConsoleInputBuffer($self->{'handle'});
  335 }
  336 
  337 #==============
  338 sub InputChar {
  339 #==============
  340     my($self, $number) = @_;
  341     return undef unless ref($self);
  342 
  343     $number = 1 unless defined($number);
  344 
  345     my $buffer = (" " x $number);
  346     if (_ReadConsole($self->{'handle'}, $buffer, $number) == $number) {
  347         return $buffer;
  348     }
  349     else {
  350         return undef;
  351     }
  352 }
  353 
  354 #==========
  355 sub Input {
  356 #==========
  357     my($self) = @_;
  358     return undef unless ref($self);
  359     return _ReadConsoleInput($self->{'handle'});
  360 }
  361 
  362 #==============
  363 sub PeekInput {
  364 #==============
  365     my($self) = @_;
  366     return undef unless ref($self);
  367     return _PeekConsoleInput($self->{'handle'});
  368 }
  369 
  370 #===============
  371 sub WriteInput {
  372 #===============
  373     my($self) = shift;
  374     return undef unless ref($self);
  375     return _WriteConsoleInput($self->{'handle'}, @_);
  376 }
  377 
  378 #=========
  379 sub Mode {
  380 #=========
  381     my($self, $mode) = @_;
  382     return undef unless ref($self);
  383     if (defined($mode)) {
  384         return _SetConsoleMode($self->{'handle'}, $mode);
  385     }
  386     else {
  387         return _GetConsoleMode($self->{'handle'});
  388     }
  389 }
  390 
  391 #========
  392 sub Cls {
  393 #========
  394     my($self, $attr) = @_;
  395     return undef unless ref($self);
  396 
  397     $attr = $ATTR_NORMAL unless defined($attr);
  398 
  399     my ($x, $y) = $self->Size();
  400     my($left, $top, $right ,$bottom) = $self->Window();
  401     my $vx = $right  - $left;
  402     my $vy = $bottom - $top;
  403     $self->FillChar(" ", $x*$y, 0, 0);
  404     $self->FillAttr($attr, $x*$y, 0, 0);
  405     $self->Cursor(0, 0);
  406     $self->Window(1, 0, 0, $vx, $vy);
  407 }
  408 
  409 #=========
  410 sub Attr {
  411 #=========
  412     my($self, $attr) = @_;
  413     return undef unless ref($self);
  414 
  415     if (not defined($attr)) {
  416         return (_GetConsoleScreenBufferInfo($self->{'handle'}))[4];
  417     }
  418     else {
  419         return _SetConsoleTextAttribute($self->{'handle'}, $attr);
  420     }
  421 }
  422 
  423 #===========
  424 sub Cursor {
  425 #===========
  426     my($self, $col, $row, $size, $visi) = @_;
  427     return undef unless ref($self);
  428 
  429     my $curr_row  = 0;
  430     my $curr_col  = 0;
  431     my $curr_size = 0;
  432     my $curr_visi = 0;
  433     my $return    = 0;
  434     my $discard   = 0;
  435 
  436 
  437     if (defined($col)) {
  438         $row = -1 if not defined($row);
  439         if ($col == -1 or $row == -1) {
  440             ($discard, $discard, $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  441             $col=$curr_col if $col==-1;
  442             $row=$curr_row if $row==-1;
  443         }
  444         $return += _SetConsoleCursorPosition($self->{'handle'}, $col, $row);
  445         if (defined($size) and defined($visi)) {
  446             if ($size == -1 or $visi == -1) {
  447                 ($curr_size, $curr_visi) = _GetConsoleCursorInfo($self->{'handle'});
  448                 $size = $curr_size if $size == -1;
  449                 $visi = $curr_visi if $visi == -1;
  450             }
  451             $size = 1 if $size < 1;
  452             $size = 99 if $size > 99;
  453             $return += _SetConsoleCursorInfo($self->{'handle'}, $size, $visi);
  454         }
  455         return $return;
  456     }
  457     else {
  458         ($discard, $discard, $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  459         ($curr_size, $curr_visi) = _GetConsoleCursorInfo($self->{'handle'});
  460         return ($curr_col, $curr_row, $curr_size, $curr_visi);
  461     }
  462 }
  463 
  464 #=========
  465 sub Size {
  466 #=========
  467     my($self, $col, $row) = @_;
  468     return undef unless ref($self);
  469 
  470     if (not defined($col)) {
  471         ($col, $row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  472         return ($col, $row);
  473     }
  474     else {
  475         $row = -1 if not defined($row);
  476         if ($col == -1 or $row == -1) {
  477             ($curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  478             $col=$curr_col if $col==-1;
  479             $row=$curr_row if $row==-1;
  480         }
  481         return _SetConsoleScreenBufferSize($self->{'handle'}, $col, $row);
  482     }
  483 }
  484 
  485 #=============
  486 sub FillAttr {
  487 #=============
  488     my($self, $attr, $number, $col, $row) = @_;
  489     return undef unless ref($self);
  490 
  491     $number = 1 unless $number;
  492 
  493     if (!defined($col) or !defined($row) or $col == -1 or $row == -1) {
  494         ($discard,  $discard,
  495          $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  496         $col = $curr_col if !defined($col) or $col == -1;
  497         $row = $curr_row if !defined($row) or $row == -1;
  498     }
  499     return _FillConsoleOutputAttribute($self->{'handle'}, $attr, $number, $col, $row);
  500 }
  501 
  502 #=============
  503 sub FillChar {
  504 #=============
  505     my($self, $char, $number, $col, $row) = @_;
  506     return undef unless ref($self);
  507 
  508     if (!defined($col) or !defined($row) or $col == -1 or $row == -1) {
  509         ($discard,  $discard,
  510          $curr_col, $curr_row) = _GetConsoleScreenBufferInfo($self->{'handle'});
  511         $col = $curr_col if !defined($col) or $col == -1;
  512         $row = $curr_row if !defined($row) or $row == -1;
  513     }
  514     return _FillConsoleOutputCharacter($self->{'handle'}, $char, $number, $col, $row);
  515 }
  516 
  517 #============
  518 sub InputCP {
  519 #============
  520     my($self, $codepage) = @_;
  521     $codepage = $self if (defined($self) and ref($self) ne "Win32::Console");
  522     if (defined($codepage)) {
  523         return _SetConsoleCP($codepage);
  524     }
  525     else {
  526         return _GetConsoleCP();
  527     }
  528 }
  529 
  530 #=============
  531 sub OutputCP {
  532 #=============
  533     my($self, $codepage) = @_;
  534     $codepage = $self if (defined($self) and ref($self) ne "Win32::Console");
  535     if (defined($codepage)) {
  536         return _SetConsoleOutputCP($codepage);
  537     }
  538     else {
  539         return _GetConsoleOutputCP();
  540     }
  541 }
  542 
  543 #======================
  544 sub GenerateCtrlEvent {
  545 #======================
  546     my($self, $type, $pid) = @_;
  547     $type = constant("CTRL_C_EVENT", 0) unless defined($type);
  548     $pid = 0 unless defined($pid);
  549     return _GenerateConsoleCtrlEvent($type, $pid);
  550 }
  551 
  552 #===================
  553 #sub SetCtrlHandler {
  554 #===================
  555 #    my($name, $add) = @_;
  556 #    $add = 1 unless defined($add);
  557 #    my @nor = keys(%HandlerRoutineStack);
  558 #    if ($add == 0) {
  559 #        foreach $key (@nor) {
  560 #            delete $HandlerRoutineStack{$key}, last if $HandlerRoutineStack{$key}==$name;
  561 #        }
  562 #        $HandlerRoutineRegistered--;
  563 #    } else {
  564 #        if ($#nor == -1) {
  565 #            my $r = _SetConsoleCtrlHandler();
  566 #            if (!$r) {
  567 #                print "WARNING: SetConsoleCtrlHandler failed...\n";
  568 #            }
  569 #        }
  570 #        $HandlerRoutineRegistered++;
  571 #        $HandlerRoutineStack{$HandlerRoutineRegistered} = $name;
  572 #    }
  573 #}
  574 
  575 #===================
  576 sub get_Win32_IPC_HANDLE { # So Win32::IPC can wait on a console handle
  577 #===================
  578     $_[0]->{'handle'};
  579 }
  580 
  581 ########################################################################
  582 # PRIVATE METHODS
  583 #
  584 
  585 #================
  586 #sub CtrlHandler {
  587 #================
  588 #    my($ctrltype) = @_;
  589 #    my $routine;
  590 #    my $result = 0;
  591 #    CALLEM: foreach $routine (sort { $b <=> $a } keys %HandlerRoutineStack) {
  592 #        #print "CtrlHandler: calling $HandlerRoutineStack{$routine}($ctrltype)\n";
  593 #        $result = &{"main::".$HandlerRoutineStack{$routine}}($ctrltype);
  594 #        last CALLEM if $result;
  595 #    }
  596 #    return $result;
  597 #}
  598 
  599 #============
  600 sub DESTROY {
  601 #============
  602     my($self) = @_;
  603     _CloseHandle($self->{'handle'});
  604 }
  605 
  606 #######################################################################
  607 # dynamically load in the Console.pll module.
  608 #
  609 
  610 bootstrap Win32::Console;
  611 
  612 #######################################################################
  613 # ADDITIONAL CONSTANTS EXPORTED IN THE MAIN NAMESPACE
  614 #
  615 
  616 $FG_BLACK        = 0;
  617 $FG_GRAY         = constant("FOREGROUND_INTENSITY",0);
  618 $FG_BLUE         = constant("FOREGROUND_BLUE",0);
  619 $FG_LIGHTBLUE    = constant("FOREGROUND_BLUE",0)|
  620                    constant("FOREGROUND_INTENSITY",0);
  621 $FG_RED          = constant("FOREGROUND_RED",0);
  622 $FG_LIGHTRED     = constant("FOREGROUND_RED",0)|
  623                    constant("FOREGROUND_INTENSITY",0);
  624 $FG_GREEN        = constant("FOREGROUND_GREEN",0);
  625 $FG_LIGHTGREEN   = constant("FOREGROUND_GREEN",0)|
  626                    constant("FOREGROUND_INTENSITY",0);
  627 $FG_MAGENTA      = constant("FOREGROUND_RED",0)|
  628                    constant("FOREGROUND_BLUE",0);
  629 $FG_LIGHTMAGENTA = constant("FOREGROUND_RED",0)|
  630                    constant("FOREGROUND_BLUE",0)|
  631                    constant("FOREGROUND_INTENSITY",0);
  632 $FG_CYAN         = constant("FOREGROUND_GREEN",0)|
  633                    constant("FOREGROUND_BLUE",0);
  634 $FG_LIGHTCYAN    = constant("FOREGROUND_GREEN",0)|
  635                    constant("FOREGROUND_BLUE",0)|
  636                    constant("FOREGROUND_INTENSITY",0);
  637 $FG_BROWN        = constant("FOREGROUND_RED",0)|
  638                    constant("FOREGROUND_GREEN",0);
  639 $FG_YELLOW       = constant("FOREGROUND_RED",0)|
  640                    constant("FOREGROUND_GREEN",0)|
  641                    constant("FOREGROUND_INTENSITY",0);
  642 $FG_LIGHTGRAY    = constant("FOREGROUND_RED",0)|
  643                    constant("FOREGROUND_GREEN",0)|
  644                    constant("FOREGROUND_BLUE",0);
  645 $FG_WHITE        = constant("FOREGROUND_RED",0)|
  646                    constant("FOREGROUND_GREEN",0)|
  647                    constant("FOREGROUND_BLUE",0)|
  648                    constant("FOREGROUND_INTENSITY",0);
  649 
  650 $BG_BLACK        = 0;
  651 $BG_GRAY         = constant("BACKGROUND_INTENSITY",0);
  652 $BG_BLUE         = constant("BACKGROUND_BLUE",0);
  653 $BG_LIGHTBLUE    = constant("BACKGROUND_BLUE",0)|
  654                    constant("BACKGROUND_INTENSITY",0);
  655 $BG_RED          = constant("BACKGROUND_RED",0);
  656 $BG_LIGHTRED     = constant("BACKGROUND_RED",0)|
  657                    constant("BACKGROUND_INTENSITY",0);
  658 $BG_GREEN        = constant("BACKGROUND_GREEN",0);
  659 $BG_LIGHTGREEN   = constant("BACKGROUND_GREEN",0)|
  660                    constant("BACKGROUND_INTENSITY",0);
  661 $BG_MAGENTA      = constant("BACKGROUND_RED",0)|
  662                    constant("BACKGROUND_BLUE",0);
  663 $BG_LIGHTMAGENTA = constant("BACKGROUND_RED",0)|
  664                    constant("BACKGROUND_BLUE",0)|
  665                    constant("BACKGROUND_INTENSITY",0);
  666 $BG_CYAN         = constant("BACKGROUND_GREEN",0)|
  667                    constant("BACKGROUND_BLUE",0);
  668 $BG_LIGHTCYAN    = constant("BACKGROUND_GREEN",0)|
  669                    constant("BACKGROUND_BLUE",0)|
  670                    constant("BACKGROUND_INTENSITY",0);
  671 $BG_BROWN        = constant("BACKGROUND_RED",0)|
  672                    constant("BACKGROUND_GREEN",0);
  673 $BG_YELLOW       = constant("BACKGROUND_RED",0)|
  674                    constant("BACKGROUND_GREEN",0)|
  675                    constant("BACKGROUND_INTENSITY",0);
  676 $BG_LIGHTGRAY    = constant("BACKGROUND_RED",0)|
  677                    constant("BACKGROUND_GREEN",0)|
  678                    constant("BACKGROUND_BLUE",0);
  679 $BG_WHITE        = constant("BACKGROUND_RED",0)|
  680                    constant("BACKGROUND_GREEN",0)|
  681                    constant("BACKGROUND_BLUE",0)|
  682                    constant("BACKGROUND_INTENSITY",0);
  683 
  684 $ATTR_NORMAL  = $FG_LIGHTGRAY|$BG_BLACK;
  685 $ATTR_INVERSE = $FG_BLACK|$BG_LIGHTGRAY;
  686 
  687 for my $fg ($FG_BLACK, $FG_GRAY, $FG_BLUE, $FG_GREEN,
  688         $FG_CYAN, $FG_RED, $FG_MAGENTA, $FG_BROWN,
  689         $FG_LIGHTBLUE, $FG_LIGHTGREEN, $FG_LIGHTCYAN,
  690         $FG_LIGHTRED, $FG_LIGHTMAGENTA, $FG_YELLOW,
  691         $FG_LIGHTGRAY, $FG_WHITE)
  692 {
  693     for my $bg ($BG_BLACK, $BG_GRAY, $BG_BLUE, $BG_GREEN,
  694         $BG_CYAN, $BG_RED, $BG_MAGENTA, $BG_BROWN,
  695         $BG_LIGHTBLUE, $BG_LIGHTGREEN, $BG_LIGHTCYAN,
  696         $BG_LIGHTRED, $BG_LIGHTMAGENTA, $BG_YELLOW,
  697         $BG_LIGHTGRAY, $BG_WHITE)
  698     {
  699         push(@CONSOLE_COLORS, $fg|$bg);
  700     }
  701 }
  702 
  703 # Preloaded methods go here.
  704 
  705 #Currently Autoloading is not implemented in Perl for win32
  706 # Autoload methods go after __END__, and are processed by the autosplit program.
  707 
  708 1;
  709 
  710 __END__
  711 
  712 =head1 NAME
  713 
  714 Win32::Console - Win32 Console and Character Mode Functions
  715 
  716 
  717 =head1 DESCRIPTION
  718 
  719 This module implements the Win32 console and character mode
  720 functions.  They give you full control on the console input and output,
  721 including: support of off-screen console buffers (eg. multiple screen
  722 pages)
  723 
  724 =over
  725 
  726 =item *
  727 
  728 reading and writing of characters, attributes and whole portions of
  729 the screen
  730 
  731 =item *
  732 
  733 complete processing of keyboard and mouse events
  734 
  735 =item *
  736 
  737 some very funny additional features :)
  738 
  739 =back
  740 
  741 Those functions should also make possible a port of the Unix's curses
  742 library; if there is anyone interested (and/or willing to contribute)
  743 to this project, e-mail me.  Thank you.
  744 
  745 
  746 =head1 REFERENCE
  747 
  748 
  749 =head2 Methods
  750 
  751 =over
  752 
  753 =item Alloc
  754 
  755 Allocates a new console for the process.  Returns C<undef> on errors, a
  756 nonzero value on success.  A process cannot be associated with more
  757 than one console, so this method will fail if there is already an
  758 allocated console.  Use Free to detach the process from the console,
  759 and then call Alloc to create a new console.  See also: C<Free>
  760 
  761 Example:
  762 
  763     $CONSOLE->Alloc();
  764 
  765 =item Attr [attr]
  766 
  767 Gets or sets the current console attribute.  This attribute is used by
  768 the Write method.
  769 
  770 Example:
  771 
  772     $attr = $CONSOLE->Attr();
  773     $CONSOLE->Attr($FG_YELLOW | $BG_BLUE);
  774 
  775 =item Close
  776 
  777 Closes a shortcut object.  Note that it is not "strictly" required to
  778 close the objects you created, since the Win32::Shortcut objects are
  779 automatically closed when the program ends (or when you somehow
  780 destroy such an object).
  781 
  782 Example:
  783 
  784     $LINK->Close();
  785 
  786 =item Cls [attr]
  787 
  788 Clear the console, with the specified I<attr> if given, or using
  789 ATTR_NORMAL otherwise.
  790 
  791 Example:
  792 
  793     $CONSOLE->Cls();
  794     $CONSOLE->Cls($FG_WHITE | $BG_GREEN);
  795 
  796 =item Cursor [x, y, size, visible]
  797 
  798 Gets or sets cursor position and appearance.  Returns C<undef> on
  799 errors, or a 4-element list containing: I<x>, I<y>, I<size>,
  800 I<visible>.  I<x> and I<y> are the current cursor position; ...
  801 
  802 Example:
  803 
  804     ($x, $y, $size, $visible) = $CONSOLE->Cursor();
  805 
  806     # Get position only
  807     ($x, $y) = $CONSOLE->Cursor();
  808 
  809     $CONSOLE->Cursor(40, 13, 50, 1);
  810 
  811     # Set position only
  812     $CONSOLE->Cursor(40, 13);
  813 
  814     # Set size and visibility without affecting position
  815     $CONSOLE->Cursor(-1, -1, 50, 1);
  816 
  817 =item Display
  818 
  819 Displays the specified console on the screen.  Returns C<undef> on errors,
  820 a nonzero value on success.
  821 
  822 Example:
  823 
  824     $CONSOLE->Display();
  825 
  826 =item FillAttr [attribute, number, col, row]
  827 
  828 Fills the specified number of consecutive attributes, beginning at
  829 I<col>, I<row>, with the value specified in I<attribute>.  Returns the
  830 number of attributes filled, or C<undef> on errors.  See also:
  831 C<FillChar>.
  832 
  833 Example:
  834 
  835     $CONSOLE->FillAttr($FG_BLACK | $BG_BLACK, 80*25, 0, 0);
  836 
  837 =item FillChar char, number, col, row
  838 
  839 Fills the specified number of consecutive characters, beginning at
  840 I<col>, I<row>, with the character specified in I<char>.  Returns the
  841 number of characters filled, or C<undef> on errors.  See also:
  842 C<FillAttr>.
  843 
  844 Example:
  845 
  846     $CONSOLE->FillChar("X", 80*25, 0, 0);
  847 
  848 =item Flush
  849 
  850 Flushes the console input buffer.  All the events in the buffer are
  851 discarded.  Returns C<undef> on errors, a nonzero value on success.
  852 
  853 Example:
  854 
  855     $CONSOLE->Flush();
  856 
  857 =item Free
  858 
  859 Detaches the process from the console.  Returns C<undef> on errors, a
  860 nonzero value on success.  See also: C<Alloc>.
  861 
  862 Example:
  863 
  864     $CONSOLE->Free();
  865 
  866 =item GenerateCtrlEvent [type, processgroup]
  867 
  868 Sends a break signal of the specified I<type> to the specified
  869 I<processgroup>.  I<type> can be one of the following constants:
  870 
  871     CTRL_BREAK_EVENT
  872     CTRL_C_EVENT
  873 
  874 they signal, respectively, the pressing of Control + Break and of
  875 Control + C; if not specified, it defaults to CTRL_C_EVENT.
  876 I<processgroup> is the pid of a process sharing the same console.  If
  877 omitted, it defaults to 0 (the current process), which is also the
  878 only meaningful value that you can pass to this function.  Returns
  879 C<undef> on errors, a nonzero value on success.
  880 
  881 Example:
  882 
  883     # break this script now
  884     $CONSOLE->GenerateCtrlEvent();
  885 
  886 =item GetEvents
  887 
  888 Returns the number of unread input events in the console's input
  889 buffer, or C<undef> on errors.  See also: C<Input>, C<InputChar>,
  890 C<PeekInput>, C<WriteInput>.
  891 
  892 Example:
  893 
  894     $events = $CONSOLE->GetEvents();
  895 
  896 =item Info
  897 
  898 Returns an array of informations about the console (or C<undef> on
  899 errors), which contains:
  900 
  901 =over
  902 
  903 =item *
  904 
  905 columns (X size) of the console buffer.
  906 
  907 =item *
  908 
  909 rows (Y size) of the console buffer.
  910 
  911 =item *
  912 
  913 current column (X position) of the cursor.
  914 
  915 =item *
  916 
  917 current row (Y position) of the cursor.
  918 
  919 =item *
  920 
  921 current attribute used for C<Write>.
  922 
  923 =item *
  924 
  925 left column (X of the starting point) of the current console window.
  926 
  927 =item *
  928 
  929 top row (Y of the starting point) of the current console window.
  930 
  931 =item *
  932 
  933 right column (X of the final point) of the current console window.
  934 
  935 =item *
  936 
  937 bottom row (Y of the final point) of the current console window.
  938 
  939 =item *
  940 
  941 maximum number of columns for the console window, given the current
  942 buffer size, font and the screen size.
  943 
  944 =item *
  945 
  946 maximum number of rows for the console window, given the current
  947 buffer size, font and the screen size.
  948 
  949 =back
  950 
  951 See also: C<Attr>, C<Cursor>, C<Size>, C<Window>, C<MaxWindow>.
  952 
  953 Example:
  954 
  955     @info = $CONSOLE->Info();
  956     print "Cursor at $info[3], $info[4].\n";
  957 
  958 =item Input
  959 
  960 Reads an event from the input buffer.  Returns a list of values, which
  961 depending on the event's nature are:
  962 
  963 =over
  964 
  965 =item keyboard event
  966 
  967 The list will contain:
  968 
  969 =over
  970 
  971 =item *
  972 
  973 event type: 1 for keyboard
  974 
  975 =item *
  976 
  977 key down: TRUE if the key is being pressed, FALSE if the key is being released
  978 
  979 =item *
  980 
  981 repeat count: the number of times the key is being held down
  982 
  983 =item *
  984 
  985 virtual keycode: the virtual key code of the key
  986 
  987 =item *
  988 
  989 virtual scancode: the virtual scan code of the key
  990 
  991 =item *
  992 
  993 char: the ASCII code of the character (if the key is a character key, 0 otherwise)
  994 
  995 =item *
  996 
  997 control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
  998 
  999 =back
 1000 
 1001 =item mouse event
 1002 
 1003 The list will contain:
 1004 
 1005 =over
 1006 
 1007 =item *
 1008 
 1009 event type: 2 for mouse
 1010 
 1011 =item *
 1012 
 1013 mouse pos. X: X coordinate (column) of the mouse location
 1014 
 1015 =item *
 1016 
 1017 mouse pos. Y: Y coordinate (row) of the mouse location
 1018 
 1019 =item *
 1020 
 1021 button state: the mouse button(s) which are pressed
 1022 
 1023 =item *
 1024 
 1025 control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
 1026 
 1027 =item *
 1028 
 1029 event flags: the type of the mouse event
 1030 
 1031 =back
 1032 
 1033 =back
 1034 
 1035 This method will return C<undef> on errors.  Note that the events
 1036 returned are depending on the input C<Mode> of the console; for example,
 1037 mouse events are not intercepted unless ENABLE_MOUSE_INPUT is
 1038 specified.  See also: C<GetEvents>, C<InputChar>, C<Mode>,
 1039 C<PeekInput>, C<WriteInput>.
 1040 
 1041 Example:
 1042 
 1043     @event = $CONSOLE->Input();
 1044 
 1045 =item InputChar number
 1046 
 1047 Reads and returns I<number> characters from the console input buffer,
 1048 or C<undef> on errors.  See also: C<Input>, C<Mode>.
 1049 
 1050 Example:
 1051 
 1052     $key = $CONSOLE->InputChar(1);
 1053 
 1054 =item InputCP [codepage]
 1055 
 1056 Gets or sets the input code page used by the console.  Note that this
 1057 doesn't apply to a console object, but to the standard input
 1058 console.  This attribute is used by the Write method.  See also:
 1059 C<OutputCP>.
 1060 
 1061 Example:
 1062 
 1063     $codepage = $CONSOLE->InputCP();
 1064     $CONSOLE->InputCP(437);
 1065 
 1066     # you may want to use the non-instanciated form to avoid confuzion :)
 1067     $codepage = Win32::Console::InputCP();
 1068     Win32::Console::InputCP(437);
 1069 
 1070 =item MaxWindow
 1071 
 1072 Returns the size of the largest possible console window, based on the
 1073 current font and the size of the display.  The result is C<undef> on
 1074 errors, otherwise a 2-element list containing col, row.
 1075 
 1076 Example:
 1077 
 1078     ($maxCol, $maxRow) = $CONSOLE->MaxWindow();
 1079 
 1080 =item Mode [flags]
 1081 
 1082 Gets or sets the input or output mode of a console.  I<flags> can be a
 1083 combination of the following constants:
 1084 
 1085     ENABLE_LINE_INPUT
 1086     ENABLE_ECHO_INPUT
 1087     ENABLE_PROCESSED_INPUT
 1088     ENABLE_WINDOW_INPUT
 1089     ENABLE_MOUSE_INPUT
 1090     ENABLE_PROCESSED_OUTPUT
 1091     ENABLE_WRAP_AT_EOL_OUTPUT
 1092 
 1093 For more informations on the meaning of those flags, please refer to
 1094 the L<"Microsoft's Documentation">.
 1095 
 1096 Example:
 1097 
 1098     $mode = $CONSOLE->Mode();
 1099     $CONSOLE->Mode(ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT);
 1100 
 1101 =item MouseButtons
 1102 
 1103 Returns the number of the buttons on your mouse, or C<undef> on errors.
 1104 
 1105 Example:
 1106 
 1107     print "Your mouse has ", $CONSOLE->MouseButtons(), " buttons.\n";
 1108 
 1109 =item new Win32::Console standard_handle
 1110 
 1111 =item new Win32::Console [accessmode, sharemode]
 1112 
 1113 Creates a new console object.  The first form creates a handle to a
 1114 standard channel, I<standard_handle> can be one of the following:
 1115 
 1116     STD_OUTPUT_HANDLE
 1117     STD_ERROR_HANDLE
 1118     STD_INPUT_HANDLE
 1119 
 1120 The second form, instead, creates a console screen buffer in memory,
 1121 which you can access for reading and writing as a normal console, and
 1122 then redirect on the standard output (the screen) with C<Display>.  In
 1123 this case, you can specify one or both of the following values for
 1124 I<accessmode>:
 1125 
 1126     GENERIC_READ
 1127     GENERIC_WRITE
 1128 
 1129 which are the permissions you will have on the created buffer, and one
 1130 or both of the following values for I<sharemode>:
 1131 
 1132     FILE_SHARE_READ
 1133     FILE_SHARE_WRITE
 1134 
 1135 which affect the way the console can be shared.  If you don't specify
 1136 any of those parameters, all 4 flags will be used.
 1137 
 1138 Example:
 1139 
 1140     $STDOUT = new Win32::Console(STD_OUTPUT_HANDLE);
 1141     $STDERR = new Win32::Console(STD_ERROR_HANDLE);
 1142     $STDIN  = new Win32::Console(STD_INPUT_HANDLE);
 1143 
 1144     $BUFFER = new Win32::Console();
 1145     $BUFFER = new Win32::Console(GENERIC_READ | GENERIC_WRITE);
 1146 
 1147 =item OutputCP [codepage]
 1148 
 1149 Gets or sets the output code page used by the console.  Note that this
 1150 doesn't apply to a console object, but to the standard output console.
 1151 See also: C<InputCP>.
 1152 
 1153 Example:
 1154 
 1155     $codepage = $CONSOLE->OutputCP();
 1156     $CONSOLE->OutputCP(437);
 1157 
 1158     # you may want to use the non-instanciated form to avoid confuzion :)
 1159     $codepage = Win32::Console::OutputCP();
 1160     Win32::Console::OutputCP(437);
 1161 
 1162 =item PeekInput
 1163 
 1164 Does exactly the same as C<Input>, except that the event read is not
 1165 removed from the input buffer.  See also: C<GetEvents>, C<Input>,
 1166 C<InputChar>, C<Mode>, C<WriteInput>.
 1167 
 1168 Example:
 1169 
 1170     @event = $CONSOLE->PeekInput();
 1171 
 1172 =item ReadAttr [number, col, row]
 1173 
 1174 Reads the specified I<number> of consecutive attributes, beginning at
 1175 I<col>, I<row>, from the console.  Returns the attributes read (a
 1176 variable containing one character for each attribute), or C<undef> on
 1177 errors.  You can then pass the returned variable to C<WriteAttr> to
 1178 restore the saved attributes on screen.  See also: C<ReadChar>,
 1179 C<ReadRect>.
 1180 
 1181 Example:
 1182 
 1183     $colors = $CONSOLE->ReadAttr(80*25, 0, 0);
 1184 
 1185 =item ReadChar [number, col, row]
 1186 
 1187 Reads the specified I<number> of consecutive characters, beginning at
 1188 I<col>, I<row>, from the console.  Returns a string containing the
 1189 characters read, or C<undef> on errors.  You can then pass the
 1190 returned variable to C<WriteChar> to restore the saved characters on
 1191 screen.  See also: C<ReadAttr>, C<ReadRect>.
 1192 
 1193 Example:
 1194 
 1195     $chars = $CONSOLE->ReadChar(80*25, 0, 0);
 1196 
 1197 =item ReadRect left, top, right, bottom
 1198 
 1199 Reads the content (characters and attributes) of the rectangle
 1200 specified by I<left>, I<top>, I<right>, I<bottom> from the console.
 1201 Returns a string containing the rectangle read, or C<undef> on errors.
 1202 You can then pass the returned variable to C<WriteRect> to restore the
 1203 saved rectangle on screen (or on another console).  See also:
 1204 C<ReadAttr>, C<ReadChar>.
 1205 
 1206 Example:
 1207 
 1208      $rect = $CONSOLE->ReadRect(0, 0, 80, 25);
 1209 
 1210 =item Scroll left, top, right, bottom, col, row, char, attr,
 1211              [cleft, ctop, cright, cbottom]
 1212 
 1213 Moves a block of data in a console buffer; the block is identified by
 1214 I<left>, I<top>, I<right>, I<bottom>, while I<row>, I<col> identify
 1215 the new location of the block.  The cells left empty as a result of
 1216 the move are filled with the character I<char> and attribute I<attr>.
 1217 Optionally you can specify a clipping region with I<cleft>, I<ctop>,
 1218 I<cright>, I<cbottom>, so that the content of the console outside this
 1219 rectangle are unchanged.  Returns C<undef> on errors, a nonzero value
 1220 on success.
 1221 
 1222 Example:
 1223 
 1224     # scrolls the screen 10 lines down, filling with black spaces
 1225     $CONSOLE->Scroll(0, 0, 80, 25, 0, 10, " ", $FG_BLACK | $BG_BLACK);
 1226 
 1227 =item Select standard_handle
 1228 
 1229 Redirects a standard handle to the specified console.
 1230 I<standard_handle> can have one of the following values:
 1231 
 1232     STD_INPUT_HANDLE
 1233     STD_OUTPUT_HANDLE
 1234     STD_ERROR_HANDLE
 1235 
 1236 Returns C<undef> on errors, a nonzero value on success.
 1237 
 1238 Example:
 1239 
 1240     $CONSOLE->Select(STD_OUTPUT_HANDLE);
 1241 
 1242 =item SetIcon icon_file
 1243 
 1244 Sets the icon in the title bar of the current console window.
 1245 
 1246 Example:
 1247 
 1248     $CONSOLE->SetIcon("C:/My/Path/To/Custom.ico");
 1249 
 1250 =item Size [col, row]
 1251 
 1252 Gets or sets the console buffer size.
 1253 
 1254 Example:
 1255 
 1256     ($x, $y) = $CONSOLE->Size();
 1257     $CONSOLE->Size(80, 25);
 1258 
 1259 =item Title [title]
 1260 
 1261 Gets or sets the title of the current console window.
 1262 
 1263 Example:
 1264 
 1265     $title = $CONSOLE->Title();
 1266     $CONSOLE->Title("This is a title");
 1267 
 1268 =item Window [flag, left, top, right, bottom]
 1269 
 1270 Gets or sets the current console window size.  If called without
 1271 arguments, returns a 4-element list containing the current window
 1272 coordinates in the form of I<left>, I<top>, I<right>, I<bottom>.  To
 1273 set the window size, you have to specify an additional I<flag>
 1274 parameter: if it is 0 (zero), coordinates are considered relative to
 1275 the current coordinates; if it is non-zero, coordinates are absolute.
 1276 
 1277 Example:
 1278 
 1279     ($left, $top, $right, $bottom) = $CONSOLE->Window();
 1280     $CONSOLE->Window(1, 0, 0, 80, 50);
 1281 
 1282 =item Write string
 1283 
 1284 Writes I<string> on the console, using the current attribute, that you
 1285 can set with C<Attr>, and advancing the cursor as needed.  This isn't
 1286 so different from Perl's "print" statement.  Returns the number of
 1287 characters written or C<undef> on errors.  See also: C<WriteAttr>,
 1288 C<WriteChar>, C<WriteRect>.
 1289 
 1290 Example:
 1291 
 1292     $CONSOLE->Write("Hello, world!");
 1293 
 1294 =item WriteAttr attrs, col, row
 1295 
 1296 Writes the attributes in the string I<attrs>, beginning at I<col>,
 1297 I<row>, without affecting the characters that are on screen.  The
 1298 string attrs can be the result of a C<ReadAttr> function, or you can
 1299 build your own attribute string; in this case, keep in mind that every
 1300 attribute is treated as a character, not a number (see example).
 1301 Returns the number of attributes written or C<undef> on errors.  See
 1302 also: C<Write>, C<WriteChar>, C<WriteRect>.
 1303 
 1304 Example:
 1305 
 1306     $CONSOLE->WriteAttr($attrs, 0, 0);
 1307 
 1308     # note the use of chr()...
 1309     $attrs = chr($FG_BLACK | $BG_WHITE) x 80;
 1310     $CONSOLE->WriteAttr($attrs, 0, 0);
 1311 
 1312 =item WriteChar chars, col, row
 1313 
 1314 Writes the characters in the string I<attr>, beginning at I<col>, I<row>,
 1315 without affecting the attributes that are on screen.  The string I<chars>
 1316 can be the result of a C<ReadChar> function, or a normal string.  Returns
 1317 the number of characters written or C<undef> on errors.  See also:
 1318 C<Write>, C<WriteAttr>, C<WriteRect>.
 1319 
 1320 Example:
 1321 
 1322     $CONSOLE->WriteChar("Hello, worlds!", 0, 0);
 1323 
 1324 =item WriteInput (event)
 1325 
 1326 Pushes data in the console input buffer.  I<(event)> is a list of values,
 1327 for more information see C<Input>.  The string chars can be the result of
 1328 a C<ReadChar> function, or a normal string.  Returns the number of
 1329 characters written or C<undef> on errors.  See also: C<Write>,
 1330 C<WriteAttr>, C<WriteRect>.
 1331 
 1332 Example:
 1333 
 1334     $CONSOLE->WriteInput(@event);
 1335 
 1336 =item WriteRect rect, left, top, right, bottom
 1337 
 1338 Writes a rectangle of characters and attributes (contained in I<rect>)
 1339 on the console at the coordinates specified by I<left>, I<top>,
 1340 I<right>, I<bottom>.  I<rect> can be the result of a C<ReadRect>
 1341 function.  Returns C<undef> on errors, otherwise a 4-element list
 1342 containing the coordinates of the affected rectangle, in the format
 1343 I<left>, I<top>, I<right>, I<bottom>.  See also: C<Write>,
 1344 C<WriteAttr>, C<WriteChar>.
 1345 
 1346 Example:
 1347 
 1348     $CONSOLE->WriteRect($rect, 0, 0, 80, 25);
 1349 
 1350 =back
 1351 
 1352 
 1353 =head2 Constants
 1354 
 1355 The following constants are exported in the main namespace of your
 1356 script using Win32::Console:
 1357 
 1358     BACKGROUND_BLUE
 1359     BACKGROUND_GREEN
 1360     BACKGROUND_INTENSITY
 1361     BACKGROUND_RED
 1362     CAPSLOCK_ON
 1363     CONSOLE_TEXTMODE_BUFFER
 1364     ENABLE_ECHO_INPUT
 1365     ENABLE_LINE_INPUT
 1366     ENABLE_MOUSE_INPUT
 1367     ENABLE_PROCESSED_INPUT
 1368     ENABLE_PROCESSED_OUTPUT
 1369     ENABLE_WINDOW_INPUT
 1370     ENABLE_WRAP_AT_EOL_OUTPUT
 1371     ENHANCED_KEY
 1372     FILE_SHARE_READ
 1373     FILE_SHARE_WRITE
 1374     FOREGROUND_BLUE
 1375     FOREGROUND_GREEN
 1376     FOREGROUND_INTENSITY
 1377     FOREGROUND_RED
 1378     LEFT_ALT_PRESSED
 1379     LEFT_CTRL_PRESSED
 1380     NUMLOCK_ON
 1381     GENERIC_READ
 1382     GENERIC_WRITE
 1383     RIGHT_ALT_PRESSED
 1384     RIGHT_CTRL_PRESSED
 1385     SCROLLLOCK_ON
 1386     SHIFT_PRESSED
 1387     STD_INPUT_HANDLE
 1388     STD_OUTPUT_HANDLE
 1389     STD_ERROR_HANDLE
 1390 
 1391 Additionally, the following variables can be used:
 1392 
 1393     $FG_BLACK
 1394     $FG_GRAY
 1395     $FG_BLUE
 1396     $FG_LIGHTBLUE
 1397     $FG_RED
 1398     $FG_LIGHTRED
 1399     $FG_GREEN
 1400     $FG_LIGHTGREEN
 1401     $FG_MAGENTA
 1402     $FG_LIGHTMAGENTA
 1403     $FG_CYAN
 1404     $FG_LIGHTCYAN
 1405     $FG_BROWN
 1406     $FG_YELLOW
 1407     $FG_LIGHTGRAY
 1408     $FG_WHITE
 1409 
 1410     $BG_BLACK
 1411     $BG_GRAY
 1412     $BG_BLUE
 1413     $BG_LIGHTBLUE
 1414     $BG_RED
 1415     $BG_LIGHTRED
 1416     $BG_GREEN
 1417     $BG_LIGHTGREEN
 1418     $BG_MAGENTA
 1419     $BG_LIGHTMAGENTA
 1420     $BG_CYAN
 1421     $BG_LIGHTCYAN
 1422     $BG_BROWN
 1423     $BG_YELLOW
 1424     $BG_LIGHTGRAY
 1425     $BG_WHITE
 1426 
 1427     $ATTR_NORMAL
 1428     $ATTR_INVERSE
 1429 
 1430 ATTR_NORMAL is set to gray foreground on black background (DOS's
 1431 standard colors).
 1432 
 1433 
 1434 =head2 Microsoft's Documentation
 1435 
 1436 Documentation for the Win32 Console and Character mode Functions can
 1437 be found on Microsoft's site at this URL:
 1438 
 1439 http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar.htm
 1440 
 1441 A reference of the available functions is at:
 1442 
 1443 http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar_34.htm
 1444 
 1445 
 1446 =head1 AUTHOR
 1447 
 1448 Aldo Calpini <a.calpini@romagiubileo.it>
 1449 
 1450 =head1 CREDITS
 1451 
 1452 Thanks to: Jesse Dougherty, Dave Roth, ActiveWare, and the
 1453 Perl-Win32-Users community.
 1454 
 1455 =head1 DISCLAIMER
 1456 
 1457 This program is FREE; you can redistribute, modify, disassemble, or
 1458 even reverse engineer this software at your will.  Keep in mind,
 1459 however, that NOTHING IS GUARANTEED to work and everything you do is
 1460 AT YOUR OWN RISK - I will not take responsibility for any damage, loss
 1461 of money and/or health that may arise from the use of this program!
 1462 
 1463 This is distributed under the terms of Larry Wall's Artistic License.