Anonymous avatar Anonymous committed 46b7fc0

Initial import of Console::Virtual sources.

Comments (0)

Files changed (18)

Console/Color/ANSI16.pm

+# ANSI16.pm - 16-colour-ANSI colour abstraction
+
+# Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+%::colormap =
+(
+  'black'    =>  0,
+  'red'      =>  1,
+  'green'    =>  2,
+  'brown'    =>  3,
+  'blue'     =>  4,
+  'purple'   =>  5,
+  'aqua'     =>  6,
+  'grey'     =>  7,
+  'pink'     =>  1,
+  'lime'     =>  2,
+  'yellow'   =>  3,
+  'sky'      =>  4,
+  'magenta'  =>  5,
+  'cyan'     =>  6,
+  'white'    =>  7,
+);
+
+%::intensitymap =
+(
+  'black'    =>  0,
+  'red'      =>  0,
+  'blue'     =>  0,
+  'purple'   =>  0,
+  'green'    =>  0,
+  'brown'    =>  0,
+  'aqua'     =>  0,
+  'grey'     =>  0,
+  'pink'     =>  1,
+  'sky'      =>  1,
+  'magenta'  =>  1,
+  'lime'     =>  1,
+  'yellow'   =>  1,
+  'cyan'     =>  1,
+  'white'    =>  1,
+);
+
+sub color
+{
+  my $fg = shift;
+  my $bg = shift;
+  die "Bad color" if not exists $::colormap{$fg} or not exists $::colormap{$bg};
+  print "\e[$::intensitymap{$fg};3$::colormap{$fg};4$::colormap{$bg}m";
+}
+
+1;

Console/Color/Curses.pm

+# Curses.pm - color abstraction for Curses
+
+# Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use Curses;
+
+%::colormap =
+(
+  'black'    => 1,
+  'red'      => 2,
+  'blue'     => 3,
+  'purple'   => 4,
+  'green'    => 5,
+  'brown'    => 6,
+  'aqua'     => 7,
+  'grey'     => 0,
+  'pink'     => 18,
+  'sky'      => 19,
+  'magenta'  => 20,
+  'lime'     => 21,
+  'yellow'   => 22,
+  'cyan'     => 23,
+  'white'    => 24,
+);
+
+init_pair(1, COLOR_BLACK,   COLOR_WHITE);
+init_pair(2, COLOR_RED,     COLOR_BLACK);
+init_pair(3, COLOR_BLUE,    COLOR_BLACK);
+init_pair(4, COLOR_MAGENTA, COLOR_BLACK);
+init_pair(5, COLOR_GREEN,   COLOR_BLACK);
+init_pair(6, COLOR_YELLOW,  COLOR_BLACK);
+init_pair(7, COLOR_CYAN,    COLOR_BLACK);
+init_pair(8, COLOR_WHITE,   COLOR_BLACK);
+
+$::old_color = 'grey';
+
+sub color
+{
+  my $fg = shift;
+  my $bg = shift;
+  attroff(A_BOLD) if $::colormap{$::old_color} > 10;
+  attroff(COLOR_PAIR($::colormap{$::old_color} % 16));
+  attron(A_BOLD) if $::colormap{$fg} > 10;
+  attron(COLOR_PAIR($::colormap{$fg} % 16));
+  $::old_color = $fg;
+}
+
+1;

Console/Color/Mono.pm

+# Mono.pm - monochrome (w/intensity bit) display abstraction
+
+# Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+%::colormap =
+(
+  'black'    => 0,
+  'red'      => 1,
+  'blue'     => 1,
+  'purple'   => 1,
+  'green'    => 1,
+  'brown'    => 1,
+  'aqua'     => 1,
+  'grey'     => 1,
+  'pink'     => 2,
+  'sky'      => 2,
+  'magenta'  => 2,
+  'lime'     => 2,
+  'yellow'   => 2,
+  'cyan'     => 2,
+  'white'    => 2,
+);
+
+sub color
+{
+  my $fg = shift;
+  my $bg = shift;
+  if ($::colormap{$bg} > 0)
+  {
+    ::inverse;
+  } elsif ($::colormap{$fg} > 1)
+  {
+    ::bold;
+  } else
+  {
+    ::normal;
+  }
+}
+
+1;

Console/Color/Win32.pm

+# Win32.pm - 16-colour Windows 32-bit Console colour abstraction
+
+# Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use Win32::Console;
+
+%::bgcolormap =
+(
+  'black'    => $BG_BLACK,
+  'red'      => $BG_RED,
+  'blue'     => $BG_BLUE,
+  'purple'   => $BG_MAGENTA,
+  'green'    => $BG_GREEN,
+  'brown'    => $BG_BROWN,
+  'aqua'     => $BG_CYAN,
+  'grey'     => $BG_GRAY,
+  'pink'     => $BG_LIGHTRED,
+  'sky'      => $BG_LIGHTBLUE,
+  'magenta'  => $BG_LIGHTMAGENTA,
+  'lime'     => $BG_LIGHTGREEN,
+  'yellow'   => $BG_YELLOW,
+  'cyan'     => $BG_LIGHTCYAN,
+  'white'    => $BG_WHITE,
+);
+
+%::fgcolormap =
+(
+  'black'    => $FG_BLACK,
+  'red'      => $FG_RED,
+  'blue'     => $FG_BLUE,
+  'purple'   => $FG_MAGENTA,
+  'green'    => $FG_GREEN,
+  'brown'    => $FG_BROWN,
+  'aqua'     => $FG_CYAN,
+  'grey'     => $FG_GRAY,
+  'pink'     => $FG_LIGHTRED,
+  'sky'      => $FG_LIGHTBLUE,
+  'magenta'  => $FG_LIGHTMAGENTA,
+  'lime'     => $FG_LIGHTGREEN,
+  'yellow'   => $FG_YELLOW,
+  'cyan'     => $FG_LIGHTCYAN,
+  'white'    => $FG_WHITE,
+);
+
+sub color
+{
+  my $fg = shift;
+  my $bg = shift;
+  die "Bad color $fg" if not exists $::fgcolormap{$fg};
+  die "Bad color $bg" if not exists $::bgcolormap{$bg};
+  $::STDOUT->Attr($::fgcolormap{$fg} | $::bgcolormap{$bg});
+}
+
+1;

Console/Display/ANSI.pm

+# Console::Display::ANSI.pm - ANSI terminal display layer
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Superceded by _Console::Display::Tput, but included for
+# backwards compatibility.  Implements a subset of ANSI/vt100.
+
+### SUBS ###
+
+sub display { my ($m) = join('',@_);
+              $m =~ s/\n/\r\cJ/g;
+              print $m; }
+sub clrscr  { print "\e[2J\e[1;1H"; }
+sub clreol  { print "\e[K"; }
+sub gotoxy  { my ($x, $y) = @_; print "\e[${y};${x}H"; }
+sub bold    { print "\e[1m"; }
+sub inverse { print "\e[0;7m"; }
+sub normal  { print "\e[0m"; }
+sub update_display { }
+
+1;
+
+### END of ANSI.pm ###

Console/Display/Curses.pm

+# Console::Display::Curses.pm - display layer for Curses
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use Curses;
+
+### SUBS ###
+
+$curses_x = 1;
+$curses_y = 1;
+
+sub display { my ($m) = join('',@_);
+              addstr($curses_y-1, $curses_x-1, $m);
+              $curses_x += length($m); }
+sub clrscr  { $curses_x = 1; $curses_y = 1; move(0, 0); clear; refresh; }
+sub clreol  { move($curses_y-1, $curses_x-1); clrtoeol; }
+sub gotoxy  { ($curses_x, $curses_y) = @_; }
+sub bold    { attrset(A_BOLD); } 
+sub inverse { attrset(A_REVERSE); }
+sub normal  { attrset(A_NORMAL); }
+sub update_display { move($curses_y-1,$curses_x-1); refresh; }
+
+1;
+
+### END of Curses.pm ###

Console/Display/Screen.pm

+# Console::Display::Screen.pm - Term::Screen under Console::Virtual
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+### SUBS ###
+
+sub display { $screen->puts(join('', @_)); }
+sub clrscr  { $screen->clrscr(); }
+sub clreol  { $screen->clreol(); }
+sub gotoxy  { my ($x, $y) = @_; $screen->at($x, $y); }
+sub bold    { $screen->bold(); }
+sub inverse { $screen->reverse(); }
+sub normal  { $screen->normal(); }
+sub update_display { }
+
+1;
+
+### END of Screen.pm ###

Console/Display/Teletype.pm

+# Console::Display::Teletype.pm - emulate screen under true teletype
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+$buffer = [];
+$cursor_x = 1;
+$cursor_y = 1;
+
+### SUBS ###
+
+sub display
+{
+  my ($m) = join('',@_);
+  my $i = 0;
+  for($i=0;$i<$cursor_x-1;$i++)
+  {
+    $buffer->[$cursor_y-1][$i] = ' ' if
+      not defined $buffer->[$cursor_y-1][$i];
+  }
+  for($i=0;$i<length($m);$i++)
+  {
+    $buffer->[$cursor_y-1][$cursor_x-1+$i] = substr($m, $i, 1);
+  }
+  $cursor_x += length($m);
+}
+sub clrscr
+{
+  my $i = 0;
+  for($i=0;$i<25;$i++) { $buffer->[$i] = [ ' ' ]; }
+  $cursor_x = 1;
+  $cursor_y = 1;
+}
+sub clreol
+{
+  while($buffer->[$cursor_y-1][$cursor_x])
+  {
+    pop @{$buffer->[$cursor_y]};
+  }
+}
+sub gotoxy  { ($cursor_x, $cursor_y) = @_; }
+sub bold    { } 
+sub inverse { }
+sub normal  { }
+sub update_display
+{
+  my $i; my $j;
+  print chr(12);
+  for($i = 0; $i < 25 and defined $buffer->[$i]; $i++)
+  {
+    for($j = 0; $j < 80 and defined $buffer->[$i][$j]; $j++)
+    {
+      print $buffer->[$i][$j];
+    }
+    print "\n";
+  }
+}
+
+1;
+
+### END of Teletype.pm ###

Console/Display/Tput.pm

+# Console::Display:Tput.pm - display layer for cached 'tput'
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN
+{
+  $clrscr = `tput cl`;
+  $clreol = `tput ce`;
+  $gotoxy = [];
+  $bold = `tput md`;
+  $inverse = `tput so`;
+  $normal = `tput me se`;
+}
+
+### SUBS ###
+
+sub display { my ($m) = join('',@_); print $m; }
+sub clrscr  { print $clrscr; }
+sub clreol  { print $clreol; }
+sub gotoxy  { my ($x, $y) = @_;
+              $gotoxy->[$x][$y] = `tput cm $x $y`
+                if not defined $gotoxy->[$x][$y];
+              print $gotoxy->[$x][$y];
+            }
+sub bold    { print $bold; }
+sub inverse { print $inverse; }
+sub normal  { print $normal; }
+sub update_display { }
+
+1;
+
+### END of Tput.pm ###

Console/Display/Win32.pm

+# Console::Display::Win32.pm - layer for Win32 Console
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN
+{
+  use Win32::Console;
+  if (defined $setup{screen_height} or defined $setup{screen_width})
+  {
+    $STDOUT->Size($setup{screen_width}, $setup{screen_height});
+  }
+}
+
+### SUBS ###
+
+sub display { $STDOUT->Write(join('',@_)); }
+sub clrscr  { $STDOUT->Cls; }
+sub clreol  { my ($x, $y) = $STDOUT->Cursor;
+              my ($sx, $sy) = $STDOUT->Info;
+              $STDOUT->FillAttr($::FG_GRAY | $::BG_BLACK, $sx-$x, $x, $y);
+              $STDOUT->FillChar(" ", $sx-$x, $x, $y); }
+sub gotoxy  { my ($x, $y) = @_; $STDOUT->Cursor($x-1,$y-1); }
+sub bold    { $STDOUT->Attr($::FG_WHITE | $::BG_BLACK); }
+sub inverse { $STDOUT->Attr($::FG_BLACK | $::BG_GRAY); }
+sub normal  { $STDOUT->Attr($::FG_GRAY  | $::BG_BLACK); }
+sub update_display { } # $STDOUT->Cursor(-1, -1, -1, 1); }
+
+1;
+
+### END of Win32.pm ###

Console/Input/Curses.pm

+# Console::Input::Curses.pm - raw input layer for Curses
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN
+{
+  use Curses;
+
+  initscr;
+  if (has_colors)
+  {
+    start_color;
+  }
+  nonl;
+  intrflush(0);
+  keypad(1);
+  nodelay(1);
+  refresh;
+
+  cbreak; # optimistic
+  noecho; # optimistic
+}
+
+sub getkey
+{
+  my $key = '';
+  refresh;
+  # cbreak; # pessimistic
+  # noecho; # pessimistic
+  sysread(STDIN, $key, 1);
+  # nocbreak; # pessimistic
+  # echo;     # pessimistic
+  return $key;
+}
+
+END
+{
+  nocbreak; # optimistic
+  echo;     # optimistic
+  endwin;
+}
+
+1;
+
+### END of Curses.pm ###

Console/Input/POSIX.pm

+# Console::Input::POSIX.pm - raw input layer for POSIX
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Snarfed rather shamelessly from the Perl FAQ on the subject:
+
+BEGIN
+{
+  use POSIX qw(:termios_h);
+
+  $fd_stdin = fileno(STDIN);
+
+  $term     = POSIX::Termios->new();
+  $term->getattr($fd_stdin);
+  $oterm     = $term->getlflag();
+
+  $echo     = ECHO | ECHOK | ICANON;
+  $noecho   = $oterm & ~$echo;
+
+  sub cbreak
+  {
+    $term->setlflag($noecho);
+    $term->setcc(VTIME, 1);
+    $term->setattr($fd_stdin, TCSANOW);
+  }
+
+  cbreak; # optimistic
+}
+
+sub cooked
+{
+  $term->setlflag($oterm);
+  $term->setcc(VTIME, 0);
+  $term->setattr($fd_stdin, TCSANOW);
+}
+
+sub getkey
+{
+  my $key = '';
+  # cbreak(); # pessimistic
+  sysread(STDIN, $key, 1);
+  # cooked(); # pessimistic
+  return $key;
+}
+
+END
+{
+  cooked(); # optimistic
+}
+
+1;
+
+### END of POSIX.pm ###

Console/Input/Screen.pm

+# Console::Input::Screen.pm - raw input using Term::Screen
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN
+{
+  require Term::Screen;
+  $screen = Term::Screen->new();
+}
+
+sub getkey { $screen->getch(); }
+
+1;
+
+### END of Screen.pm ###

Console/Input/Teletype.pm

+# Console::Input::Teletype.pm - emulate screen on true teletype
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# This is, of course, not really raw input.  Using this,
+# you'll have to manually press Return or Enter after each
+# character is pressed.
+
+sub getkey
+{
+  my $key = '';
+  update_display();
+  sysread(STDIN, $key, 1);
+  return $key;
+}
+
+1;
+
+### END of Teletype.pm ###

Console/Input/Win32.pm

+# Console::Input::Win32.pm - input layer for Windows 95/98/NT console
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2001-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+BEGIN
+{
+  use Win32::Console;
+
+  $STDOUT = new Win32::Console(STD_OUTPUT_HANDLE);
+  $STDERR = new Win32::Console(STD_ERROR_HANDLE);
+  $STDIN  = new Win32::Console(STD_INPUT_HANDLE);
+}
+
+sub getkey
+{
+  my $key = '';
+  my @event = ();
+  $STDOUT->Cursor(-1, -1, -1, 1);
+  for(;;)
+  {
+    @event = $STDIN->Input();
+    if ($event[0] == 1 and $event[1] and $event[5] != 0)
+    {
+      $key = chr($event[5]);
+      last;
+    }
+  }
+  $STDOUT->Cursor(-1, -1, -1, 0);
+  return $key;
+}
+
+END
+{
+  $STDOUT->Cursor(-1, -1, -1, 1);
+}
+
+1;
+
+### END of Win32.pm ###

Console/Virtual.pm

+# Console::Virtual.pm - unbuffered-input/addressed-display layer
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2003-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+package Console::Virtual;
+BEGIN
+{
+  use 5;
+  use strict qw(subs);
+  use Exporter;
+  $VERSION = 2007.1122;
+  @ISA = qw(Exporter);
+  @EXPORT_OK = qw(&display &clrscr &clreol &gotoxy
+                  &bold &inverse &normal
+                  &update_display &getkey &color);
+}
+
+%setup = ();
+
+BEGIN
+{
+  my $c;
+  my $fc = 0;  # found Curses.pm?
+  my $fs = 0;  # found Term::Screen?
+  my $fp = 0;  # found POSIX.pm?
+  my $ft = 0;  # found $TERM and /etc/termcap?
+  foreach $c (@INC)
+  {
+    $fc = 1 if -r "$c/Curses.pm";
+    $fs = 1 if -r "$c/Term/Screen.pm";
+    $fp = 1 if -r "$c/POSIX.pm";
+  }
+  $ft = $ENV{TERM} && -r "/etc/termcap";
+  $| = 1;
+
+  # Determine raw input module to use.
+  # This can be pre-set by the calling code
+  # by modifying %Console::Virtual::setup.
+
+  if (defined $setup{input})
+  {
+    require "Console/Input/$setup{input}.pm";
+  }
+  elsif ($fc)
+  {
+    require Console::Input::Curses;
+    $setup{input} = 'Curses';
+  }
+  elsif ($^O eq 'MSWin32')
+  {
+    require Console::Input::Win32;
+    $setup{input} = 'Win32';
+  }
+  elsif ($fs)
+  {
+    require Console::Input::Screen;
+    $setup{input} = 'Screen';
+  }
+  elsif ($fp)
+  {
+    require Console::Input::POSIX;
+    $setup{input} = 'POSIX';
+  } else
+  {
+    warn "Warning! Raw input probably not available on this '$^O' system.\n";
+    require Console::Input::Teletype;
+    $setup{input} = 'Teletype';
+  }
+
+  # Determine screen-addressed output method to use.
+  # This can be pre-set by the calling code
+  # by modifying %Console::Virtual::setup.
+
+  if (defined $setup{display})
+  {
+    require "Console/Display/$setup{display}.pm";
+  }
+  elsif ($fc)
+  {
+    require Console::Display::Curses;
+    $setup{display} = 'Curses';
+  }
+  elsif ($^O eq 'MSWin32')
+  {
+    require Console::Display::Win32;
+    $setup{display} = 'Win32';
+  }
+  elsif ($fs)
+  {
+    require Console::Display::Screen;
+    $setup{display} = 'Screen';
+  }
+  elsif ($ft)
+  {
+    require Console::Display::Tput;
+    $setup{display} = 'Tput';
+  } else
+  {
+    warn "Addressable screen must be emulated on this '$^O' system";
+    require Console::Display::Teletype;
+    $setup{display} = 'Teletype';
+  }
+
+  # 2001.01.27 CAP
+  # Determine color module to use.
+  # This can be pre-set by the calling code
+  # by modifying %Console::Virtual::setup.
+
+  if (defined $setup{color})
+  {
+    require "Console/Color/$setup{color}.pm";
+  }
+  elsif ($fc)
+  {
+    require Console::Color::Curses;
+    $setup{color} = 'Curses';
+  }
+  elsif ($^O eq 'MSWin32')
+  {
+    require Console::Color::Win32;
+    $setup{color} = 'Win32';
+  }
+  elsif ($fs)
+  {
+    # require Console::Color::Screen;  # TODO! needs to be written
+    require Console::Color::ANSI16;    # not a very general solution
+    $setup{color} = 'ANSI16';
+  }
+  else
+  {
+    require Console::Color::Mono;
+    $setup{color} = 'Mono';
+  }
+}
+
+1;
+
+### END of Virtual.pm ###
+Console::Virtual
+----------------
+
+v2007.1122 Chris Pressey, Cat's Eye Technologies.
+(c)2003-2007 Cat's Eye Technologies.  All rights reserved.
+(BSD-style license.  See file Console/Virtual.pm for full license info.)
+
+What is Console::Virtual?
+-------------------------
+
+Console::Virtual is a lightweight, abstract, function-based (as opposed to
+object-oriented) Perl interface for accessing unbuffered keyboard input
+and an addressable screen display.  Together, these facilities are thought
+of as a 'virtual console,' regardless of what underlying technologies
+implement it.
+
+Console::Virtual is intended to be only a simple redirection layer that
+insulates the programmer from whatever screen-oriented mechanisms are
+actually installed at the site.  My experience has been that Curses is often
+not installed, or installed incorrectly.  It can be impractical to install,
+for any number of reasons.  While Term::Cap and Term::Screen are part of the
+Perl 5.8.8 core libraries, they too on occasion are not installed correctly.
+Further, they are insufficiently abstract, assuming that the user interacts
+with what is essentially a terminal.  Not all systems look at the world this
+way -- Windows machines being an obvious example.
+
+Because I was writing a console-based application which was to be highly
+portable, I needed a layer which would automatically decide which unbuffered-
+input and screen-addressing methods were appropriate for the site, and
+provide a small, simple, abstract, portable interface to delegate to those
+methods.
+
+Synopsis
+--------
+
+To use Console::Virtual, you will either have to install it somewhere in
+Perl's include path (you can do this by copying the Console directory and
+all of its contents to e.g. /usr/local/lib/perl5/site_perl/5.005), or
+alternately, give Perl a new include path which contains the Console
+directory.  As usual, there is more than one way to do this: you can
+pass the -I flag to the perl executable, or you can add a line like
+BEGIN { push @INC, $dir } to your script.  If you want to just keep the
+Console directory in the same directory as your script, you can add
+BEGIN { use File::Basename; push @INC, dirname($0) } instead.
+
+Then you can insert the following into your Perl script to use it:
+
+  use Console::Virtual 2007.1122
+       qw(getkey display gotoxy clrscr clreol
+          normal inverse bold color update_display);
+
+Console::Virtual first tries to use Curses, if it's installed.  If not, and
+it detects that it's running on a Win32 system, it tries to use
+Win32::Console.  If not, it tries using Term::Screen if that's installed.
+If not, it then checks to see if POSIX is available, that TERM is set in the
+environment, and that /etc/termcap exists; if so, it uses POSIX raw input
+and it shells the external command `tput`, buffering the result, for output.
+
+Failing all of that, if Console::Virtual can't find anything that suits your
+platform, it will produce a warning, carry on regardless, and assume that it
+is running on a teletype.  It will emulate an addressible screen on the
+standard output stream the best way it knows how: the entire screen will be
+re-printed whenever an update is requested.  Also, the user will have to
+tolerate line-buffered input, where a carriage return must be issued before
+keystrokes will be responded to.  If this saddens you, be thankful that
+teletypes are rare these days.  (There are some of us who are frankly more
+saddened *by* the fact that teletypes are rare these days.)
+
+A specific input or display methodology can be specified by setting
+values in the %Console::Virtual::setup hash before using Console::Virtual.
+You probably shouldn't do this if you want to retain portability; the intent
+of it is to allow the end user to tailor their local copy of a script,
+forcing it to pick some specific implementation, presumably in preference to
+some other which would normally be preferred, but is (for whatever reason)
+not desired.  Note that when doing this, you can mix different regimens
+for input, display, and color; however, unless you know what you're doing,
+you probably shouldn't, as you're likely to get really weird results.
+See the code for more details.
+
+Any functions that you don't need to access can be left out of the qw()
+list.  In fact, the entire list can be omitted, in which case none of these
+names will be imported into your namespace.  In that case, you'll have to
+fully qualify them (like Console::Virtual::gotoxy()) to use them.
+
+Input Functions:
+
+  getkey()          wait for keystroke; don't wait for ENTER or echo
+
+Output Functions:
+
+  clrscr()          clear the screen
+  clreol()          clear to end of line
+  display(@list)    display all strings in @list at screen cursor
+  gotoxy($x,$y)     move the cursor to the 1-based (x,y) coordinate
+  bold()            set display style to bold
+  inverse()         set display style to inverted
+  normal()          set display style back to normal
+  update_display()  explicitly refresh the screen (Curses & Teletype need this)
+  color($f,$b)      sets the colors of text about to be displayed
+
+Acceptable arguments for $f and $b in color() are 'black', 'red', 'blue',
+'purple', 'green', 'brown', 'aqua', 'grey', 'pink', 'sky' (blue), 'magenta',
+'lime' (green), 'yellow', 'cyan', and 'white'.  Of course, not all terminals
+can display this many colors (or any color at all,) in which case color will
+be crudely approximated.
+
+Since the library is intended to be simple and abstract, that's all there is;
+nothing fancy enough to be severely broken, no capability predicates to check,
+no overkill object-oriented interface to follow.
+
+Differences with Term::Screen
+-----------------------------
+
+Console::Virtual is designed to be a (portable) abstraction layer, whereas
+Term::Screen is not.  There are several 'holes' in the interfaces provided
+by Term::Screen; that is, actions which are not prohibited as they probably
+ought to be.  In fact, last I checked, they are encouraged.
+
+These actions are prohibited in Console::Virtual.  Specifically, you should
+not simply use 'print' to place text on the display device; you must instead
+use display().  If you do not do this, the output of your program will look
+funny (to say the least) when the end user is using Curses, or a teletype,
+or some future output technology that Console::Virtual one day delegates to.
+By the same token, you must occasionally use update_display() for the
+benefit of Curses and other output regimens which require explicit refresh.
+Calling update_display() must be done when the cursor is to be seen, by
+the user, to move.  It is also a good idea to do it in anticipation of a
+long upcoming delay in the program (e.g. intense computation.)
+
+History
+-------
+
+v2001.0123: Renamed this module to _Console::Virtual.
+v2001.0124: fixed some namespace issues w.r.t. Win32.
+v2001.0127: added Color subfunctionality.
+v2003.0325: fixed up test.pl and readme.txt (no changes to code)
+v2007.1122: renamed to Console::Virtual, prettied readme.txt.
+            Also updated language in BSD license (no "REGENTS".)
+
+More Information
+----------------
+
+The latest version of Console::Virtual can be found at:
+
+  http://catseye.webhop.net/projects/cons_virt/
+
+Chris Pressey
+November 22, 2007
+Chicago, Illinois, USA
+#!/usr/bin/perl -w
+# test.pl - test program for Console::Virtual
+# v2007.1122 Chris Pressey, Cat's Eye Technologies
+
+# Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+#  1. Redistributions of source code must retain the above copyright
+#     notices, this list of conditions and the following disclaimer.
+#  2. Redistributions in binary form must reproduce the above copyright
+#     notices, this list of conditions, and the following disclaimer in
+#     the documentation and/or other materials provided with the
+#     distribution.
+#  3. Neither the names of the copyright holders nor the names of their
+#     contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# This line allows us to have the Console directory in the same
+# directory as the test script.
+
+BEGIN { use File::Basename; push @INC, dirname($0); }
+
+# uncomment any of these lines to test with other setups
+# BEGIN { $Console::Virtual::setup{input} = 'Screen'; $Console::Virtual::setup{display} = 'Screen'; }
+# BEGIN { $Console::Virtual::setup{input} = 'POSIX'; $Console::Virtual::setup{display} = 'Tput'; }
+# BEGIN { $Console::Virtual::setup{input} = 'Teletype'; $Console::Virtual::setup{display} = 'Teletype'; }
+
+use Console::Virtual 2001.0127 qw(getkey display gotoxy clrscr clreol
+                                  normal inverse bold update_display);
+
+clrscr;
+gotoxy(10,20);
+display("Hello, world!");
+
+gotoxy(20,10);
+inverse();
+display("Outta sight!");
+normal();
+
+# In this example, Console::Virtual's functions have been imported into
+# package main.
+# Because of this, code which relied on the old package 'vC' still works.
+
+::gotoxy(1,1);
+::bold();
+::display("Rock on!");
+::normal();
+
+# So does explicitly referencing the 'Console::Virtual' package.
+# In fact, if you leave out the qw() list on 'use Console::Virtual',
+# you'll have to do it this way.
+
+Console::Virtual::gotoxy(3,3);
+Console::Virtual::update_display();
+
+# getkey should automatically invoke update_display when appropriate.
+
+display("Press a key: ");
+$foo = getkey();
+clrscr();
+display("You pressed ", $foo, "!");
+update_display;
+
+### END of test.pl ###
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.