git @ Cat's Eye Technologies noit-o-mnain-worb / bcfdac5
Update included Console::Virtual to 2.0. --HG-- rename : lib/console-virtual/readme.txt => lib/console-virtual/README.markdown catseye 12 years ago
6 changed file(s) with 288 addition(s) and 290 deletion(s). Raw diff Collapse all Expand all
4747
4848 cbreak; # optimistic
4949 noecho; # optimistic
50
51 $::SIG{__DIE__} = sub($) {
52 my $msg = shift;
53 nocbreak;
54 echo;
55 endwin;
56 die $msg;
57 }
5058 }
5159
5260 sub getkey
00 # Console::Virtual.pm - unbuffered-input/addressed-display layer
1 # v2007.1122 Chris Pressey, Cat's Eye Technologies
1 # version 2.0 (February 2013)
22
3 # Copyright (c)2003-2007, Chris Pressey, Cat's Eye Technologies.
3 # Copyright (c)2003-2013, Chris Pressey, Cat's Eye Technologies.
44 # All rights reserved.
55 #
66 # Redistribution and use in source and binary forms, with or without
3636 use 5;
3737 use strict qw(subs);
3838 use Exporter;
39 $VERSION = 2007.1122;
39 $VERSION = 2.0;
4040 @ISA = qw(Exporter);
4141 @EXPORT_OK = qw(&display &clrscr &clreol &gotoxy
4242 &bold &inverse &normal
43 &update_display &getkey &color);
43 &update_display &getkey &color
44 &vsleep);
4445 }
4546
4647 %setup = ();
4748
4849 BEGIN
4950 {
50 my $c;
51 my $fc = 0; # found Curses.pm?
52 my $fs = 0; # found Term::Screen?
53 my $fp = 0; # found POSIX.pm?
54 my $ft = 0; # found $TERM and /etc/termcap?
55 foreach $c (@INC)
51 my $found_curses = 0; # found Curses.pm?
52 my $found_term_screen = 0; # found Term::Screen?
53 my $found_posix = 0; # found POSIX.pm?
54 my $found_termcap = 0; # found $TERM and /etc/termcap?
55 foreach my $path (@INC)
5656 {
57 $fc = 1 if -r "$c/Curses.pm";
58 $fs = 1 if -r "$c/Term/Screen.pm";
59 $fp = 1 if -r "$c/POSIX.pm";
57 $found_curses = 1 if -r "$path/Curses.pm";
58 $found_term_screen = 1 if -r "$path/Term/Screen.pm";
59 $found_posix = 1 if -r "$path/POSIX.pm";
6060 }
61 $ft = $ENV{TERM} && -r "/etc/termcap";
61 $found_termcap = $ENV{TERM} && -r "/etc/termcap";
6262 $| = 1;
6363
6464 # Determine raw input module to use.
6565 # This can be pre-set by the calling code
6666 # by modifying %Console::Virtual::setup.
6767
68 if (defined $setup{input})
68 if (not defined $setup{input})
6969 {
70 require "Console/Input/$setup{input}.pm";
70 if ($found_curses)
71 {
72 $setup{input} = 'Curses';
73 }
74 elsif ($^O eq 'MSWin32')
75 {
76 $setup{input} = 'Win32';
77 }
78 elsif ($found_term_screen)
79 {
80 $setup{input} = 'Screen';
81 }
82 elsif ($found_posix)
83 {
84 $setup{input} = 'POSIX';
85 } else
86 {
87 warn "Warning! Raw input probably not available on this '$^O' system.\n";
88 $setup{input} = 'Teletype';
89 }
7190 }
72 elsif ($fc)
73 {
74 require Console::Input::Curses;
75 $setup{input} = 'Curses';
76 }
77 elsif ($^O eq 'MSWin32')
78 {
79 require Console::Input::Win32;
80 $setup{input} = 'Win32';
81 }
82 elsif ($fs)
83 {
84 require Console::Input::Screen;
85 $setup{input} = 'Screen';
86 }
87 elsif ($fp)
88 {
89 require Console::Input::POSIX;
90 $setup{input} = 'POSIX';
91 } else
92 {
93 warn "Warning! Raw input probably not available on this '$^O' system.\n";
94 require Console::Input::Teletype;
95 $setup{input} = 'Teletype';
96 }
91 require "Console/Input/$setup{input}.pm";
9792
9893 # Determine screen-addressed output method to use.
9994 # This can be pre-set by the calling code
10095 # by modifying %Console::Virtual::setup.
10196
102 if (defined $setup{display})
97 if (not defined $setup{display})
10398 {
104 require "Console/Display/$setup{display}.pm";
99 if ($found_curses)
100 {
101 $setup{display} = 'Curses';
102 }
103 elsif ($^O eq 'MSWin32')
104 {
105 $setup{display} = 'Win32';
106 }
107 elsif ($found_term_screen)
108 {
109 $setup{display} = 'Screen';
110 }
111 elsif ($found_termcap)
112 {
113 $setup{display} = 'Tput';
114 } else
115 {
116 warn "Addressable screen must be emulated on this '$^O' system";
117 $setup{display} = 'Teletype';
118 }
105119 }
106 elsif ($fc)
107 {
108 require Console::Display::Curses;
109 $setup{display} = 'Curses';
110 }
111 elsif ($^O eq 'MSWin32')
112 {
113 require Console::Display::Win32;
114 $setup{display} = 'Win32';
115 }
116 elsif ($fs)
117 {
118 require Console::Display::Screen;
119 $setup{display} = 'Screen';
120 }
121 elsif ($ft)
122 {
123 require Console::Display::Tput;
124 $setup{display} = 'Tput';
125 } else
126 {
127 warn "Addressable screen must be emulated on this '$^O' system";
128 require Console::Display::Teletype;
129 $setup{display} = 'Teletype';
130 }
120 require "Console/Display/$setup{display}.pm";
131121
132122 # 2001.01.27 CAP
133123 # Determine color module to use.
134124 # This can be pre-set by the calling code
135125 # by modifying %Console::Virtual::setup.
136126
137 if (defined $setup{color})
127 if (not defined $setup{color})
138128 {
139 require "Console/Color/$setup{color}.pm";
129 if ($found_curses)
130 {
131 $setup{color} = 'Curses';
132 }
133 elsif ($^O eq 'MSWin32')
134 {
135 $setup{color} = 'Win32';
136 }
137 elsif ($found_term_screen)
138 {
139 # $setup{color} = 'Screen'; # TODO! needs to be written
140 $setup{color} = 'ANSI16'; # not a very general solution
141 }
142 else
143 {
144 $setup{color} = 'Mono';
145 }
140146 }
141 elsif ($fc)
142 {
143 require Console::Color::Curses;
144 $setup{color} = 'Curses';
145 }
146 elsif ($^O eq 'MSWin32')
147 {
148 require Console::Color::Win32;
149 $setup{color} = 'Win32';
150 }
151 elsif ($fs)
152 {
153 # require Console::Color::Screen; # TODO! needs to be written
154 require Console::Color::ANSI16; # not a very general solution
155 $setup{color} = 'ANSI16';
156 }
157 else
158 {
159 require Console::Color::Mono;
160 $setup{color} = 'Mono';
161 }
147 require "Console/Color/$setup{color}.pm";
148 }
149
150 # This lets us do sub-second sleeps, if Time::HiRes is available.
151 my $sleep = sub($) { sleep(shift); };
152 my $found_time_hires = 0;
153 foreach my $c (@INC)
154 {
155 $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
156 }
157 if ($found_time_hires) {
158 require Time::HiRes;
159 $sleep = sub($) { Time::HiRes::sleep(shift); };
160 }
161 sub vsleep($) {
162 &$sleep($_[0]);
162163 }
163164
164165 1;
0 Console::Virtual
1 ================
2
3 Version 2.0
4 (c)2003-2013 Chris Pressey, Cat's Eye Technologies. All rights reserved.
5 (BSD-style license. See file `Console/Virtual.pm` for full license info.)
6
7 What is Console::Virtual?
8 -------------------------
9
10 Console::Virtual is a lightweight, abstract, function-based (as opposed to
11 object-oriented) Perl interface for accessing unbuffered keyboard input
12 and an addressable screen display. Together, these facilities are thought
13 of as a 'virtual console,' regardless of what underlying technologies
14 implement it.
15
16 Console::Virtual is intended to be only a simple redirection layer that
17 insulates the programmer from whatever screen-oriented mechanisms are
18 actually installed at the site.
19
20 On most modern systems, Perl's Curses module is usually installed, or easy
21 to install via the package system, and for that reason, Console::Virtual
22 defaults to using it as its backend.
23
24 On some systems, though (and please understand this was more true when this
25 interface was first written), Curses is impractical to install, or installed
26 incorrectly. Perl has other ways of working with an addressable screen,
27 such as Term::Cap and Term::Screen (part of the Perl 5.8.8 core libraries),
28 but they too on occasion are not installed correctly. Further, they are
29 lacking in abstraction -- they are based on the starting assumption of a
30 Unix-like terminal interface. Not all systems look at the world this way,
31 Windows being one example.
32
33 Because I was writing a console-based application which was to be highly
34 portable, I needed a layer which would automatically decide which unbuffered-
35 input and screen-addressing methods were appropriate for the site, and
36 provide a small, simple, abstract, portable interface to delegate to those
37 methods.
38
39 Synopsis
40 --------
41
42 To use Console::Virtual, you will either have to install it somewhere in
43 Perl's include path (you can do this by copying the Console directory and
44 all of its contents to e.g. `/usr/local/lib/perl5/site_perl/5.005`), or
45 alternately, give Perl a new include path which contains the Console
46 directory. As usual, there is more than one way to do this: you can
47 pass the `-I` flag to the perl executable, or you can add a line like
48 `BEGIN { push @INC, $dir }` to your script. If you want to just keep the
49 Console directory in the same directory as your script, you can add
50 `BEGIN { use File::Basename; push @INC, dirname($0) }` instead.
51
52 Then you can insert the following into your Perl script to use it:
53
54 use Console::Virtual 2.0
55 qw(getkey display gotoxy clrscr clreol
56 normal inverse bold color update_display
57 vsleep);
58
59 Console::Virtual first tries to use Curses, if it's installed. If not, and
60 it detects that it's running on a Win32 system, it tries to use
61 Win32::Console. If not, it tries using Term::Screen if that's installed.
62 If not, it then checks to see if POSIX is available, that TERM is set in the
63 environment, and that /etc/termcap exists; if so, it uses POSIX raw input
64 and it shells the external command `tput`, buffering the result, for output.
65
66 Failing all of that, if Console::Virtual can't find anything that suits your
67 platform, it will produce a warning, carry on regardless, and assume that it
68 is running on a teletype. It will emulate an addressable screen on the
69 standard output stream the best way it knows how: the entire screen will be
70 re-printed whenever an update is requested. Also, the user will have to
71 tolerate line-buffered input, where a carriage return must be issued before
72 keystrokes will be responded to. If this saddens you, be thankful that
73 teletypes are rare these days. (There are some of us who are frankly more
74 saddened *by* the fact that teletypes are rare these days.)
75
76 A specific input or display methodology can be specified by setting
77 values in the `%Console::Virtual::setup` hash before using Console::Virtual.
78 You probably shouldn't do this if you want to retain portability; the intent
79 of it is to allow the end user to tailor their local copy of a script,
80 forcing it to pick some specific implementation, presumably in preference to
81 some other which would normally be preferred, but is (for whatever reason)
82 not desired. Note that when doing this, you can mix different regimens
83 for input, display, and color; however, unless you know what you're doing,
84 you probably shouldn't, as you're likely to get really weird results.
85 See the code for more details.
86
87 Any functions that you don't need to access can be left out of the qw()
88 list. In fact, the entire list can be omitted, in which case none of these
89 names will be imported into your namespace. In that case, you'll have to
90 fully qualify them (like Console::Virtual::gotoxy()) to use them.
91
92 Input Functions:
93
94 getkey() wait for keystroke; don't wait for ENTER or echo
95
96 Output Functions:
97
98 clrscr() clear the screen
99 clreol() clear to end of line
100 display(@list) display all strings in @list at screen cursor
101 gotoxy($x,$y) move the cursor to the 1-based (x,y) coordinate
102 bold() set display style to bold
103 inverse() set display style to inverted
104 normal() set display style back to normal
105 update_display() explicitly refresh the screen (Curses & Teletype need this)
106 color($f,$b) sets the colors of text about to be displayed
107 vsleep($s) sleep for $s seconds (may be a fraction)
108
109 Acceptable arguments for $f and $b in color() are 'black', 'red', 'blue',
110 'purple', 'green', 'brown', 'aqua', 'grey', 'pink', 'sky' (blue), 'magenta',
111 'lime' (green), 'yellow', 'cyan', and 'white'. Of course, not all terminals
112 can display this many colors (or any color at all,) in which case color will
113 be crudely approximated.
114
115 Since the library is intended to be simple and abstract, that's all there is;
116 nothing fancy enough to be severely broken, no capability predicates to check,
117 no overkill object-oriented interface to follow.
118
119 Differences with Term::Screen
120 -----------------------------
121
122 Console::Virtual is designed to be a (portable) abstraction layer, whereas
123 Term::Screen is not. There are several 'holes' in the interfaces provided
124 by Term::Screen; that is, actions which are not prohibited as they probably
125 ought to be. In fact, last I checked, they are encouraged.
126
127 These actions are prohibited in Console::Virtual. Specifically, you should
128 not simply use `print` to place text on the display device; you must instead
129 use `display()`. If you do not do this, the output of your program will look
130 funny (to say the least) when the end user is using Curses, or a teletype,
131 or some future output technology that Console::Virtual one day delegates to.
132 By the same token, you must occasionally use `update_display()` for the
133 benefit of Curses and other output regimens which require explicit refresh.
134 Calling `update_display()` must be done when the cursor is to be seen, by
135 the user, to move. It is also a good idea to do it in anticipation of a
136 long upcoming delay in the program (e.g. intense computation.)
137
138 A Note on Version Numbers
139 -------------------------
140
141 There was a point in time when I thought `YYYY.MMDD` was the Only Version
142 Number You'd Ever Need. My opinion on that has changed. Therefore, I am
143 changing the version numbering for Console::Virtual; this is version 2.0.
144
145 Alas, this plays havoc with logic that tries to decide which version of a
146 package is more recent than another, as `2007.1122` > `2.0`. However, there
147 are two things that soften the blow:
148
149 * A local copy of this module ships with all Cat's Eye Technologies
150 projects that rely on it.
151 * I don't think anyone else actually uses this module. Hooray!
152 * The `vsleep` function was introduced in 2.0. To ensure that you
153 are really getting version 2.x or later, import `vsleep` in your
154 `use Console::Virtual 2.0`.
155
156 But if you are saying `use Console::Virtual 2007.1122` in your script and
157 you want to use the new 2.0 version, you will have to change the version
158 number in that line.
159
160 History
161 -------
162
163 - v2001.0123: Renamed this module to _Console::Virtual.
164 - v2001.0124: fixed some namespace issues w.r.t. Win32.
165 - v2001.0127: added Color subfunctionality.
166 - v2003.0325: fixed up test.pl and readme.txt (no changes to code)
167 - v2007.1122: renamed to Console::Virtual, prettied readme.txt.
168 Also updated language in BSD license (no "REGENTS".)
169 - v2007.1122-YPSILAXDEV: made `die` turn off Curses before dying.
170 Converted README to Markdown.
171 - v2.0: added `vsleep`. Did horrific thing to version number.
172
173 More Information
174 ----------------
175
176 The latest version of Console::Virtual can be found at:
177
178 https://github.com/catseye/Console-Virtual
+0
-149
lib/console-virtual/readme.txt less more
0 Console::Virtual
1 ----------------
2
3 v2007.1122 Chris Pressey, Cat's Eye Technologies.
4 (c)2003-2007 Cat's Eye Technologies. All rights reserved.
5 (BSD-style license. See file Console/Virtual.pm for full license info.)
6
7 What is Console::Virtual?
8 -------------------------
9
10 Console::Virtual is a lightweight, abstract, function-based (as opposed to
11 object-oriented) Perl interface for accessing unbuffered keyboard input
12 and an addressable screen display. Together, these facilities are thought
13 of as a 'virtual console,' regardless of what underlying technologies
14 implement it.
15
16 Console::Virtual is intended to be only a simple redirection layer that
17 insulates the programmer from whatever screen-oriented mechanisms are
18 actually installed at the site. My experience has been that Curses is often
19 not installed, or installed incorrectly. It can be impractical to install,
20 for any number of reasons. While Term::Cap and Term::Screen are part of the
21 Perl 5.8.8 core libraries, they too on occasion are not installed correctly.
22 Further, they are insufficiently abstract, assuming that the user interacts
23 with what is essentially a terminal. Not all systems look at the world this
24 way -- Windows machines being an obvious example.
25
26 Because I was writing a console-based application which was to be highly
27 portable, I needed a layer which would automatically decide which unbuffered-
28 input and screen-addressing methods were appropriate for the site, and
29 provide a small, simple, abstract, portable interface to delegate to those
30 methods.
31
32 Synopsis
33 --------
34
35 To use Console::Virtual, you will either have to install it somewhere in
36 Perl's include path (you can do this by copying the Console directory and
37 all of its contents to e.g. /usr/local/lib/perl5/site_perl/5.005), or
38 alternately, give Perl a new include path which contains the Console
39 directory. As usual, there is more than one way to do this: you can
40 pass the -I flag to the perl executable, or you can add a line like
41 BEGIN { push @INC, $dir } to your script. If you want to just keep the
42 Console directory in the same directory as your script, you can add
43 BEGIN { use File::Basename; push @INC, dirname($0) } instead.
44
45 Then you can insert the following into your Perl script to use it:
46
47 use Console::Virtual 2007.1122
48 qw(getkey display gotoxy clrscr clreol
49 normal inverse bold color update_display);
50
51 Console::Virtual first tries to use Curses, if it's installed. If not, and
52 it detects that it's running on a Win32 system, it tries to use
53 Win32::Console. If not, it tries using Term::Screen if that's installed.
54 If not, it then checks to see if POSIX is available, that TERM is set in the
55 environment, and that /etc/termcap exists; if so, it uses POSIX raw input
56 and it shells the external command `tput`, buffering the result, for output.
57
58 Failing all of that, if Console::Virtual can't find anything that suits your
59 platform, it will produce a warning, carry on regardless, and assume that it
60 is running on a teletype. It will emulate an addressible screen on the
61 standard output stream the best way it knows how: the entire screen will be
62 re-printed whenever an update is requested. Also, the user will have to
63 tolerate line-buffered input, where a carriage return must be issued before
64 keystrokes will be responded to. If this saddens you, be thankful that
65 teletypes are rare these days. (There are some of us who are frankly more
66 saddened *by* the fact that teletypes are rare these days.)
67
68 A specific input or display methodology can be specified by setting
69 values in the %Console::Virtual::setup hash before using Console::Virtual.
70 You probably shouldn't do this if you want to retain portability; the intent
71 of it is to allow the end user to tailor their local copy of a script,
72 forcing it to pick some specific implementation, presumably in preference to
73 some other which would normally be preferred, but is (for whatever reason)
74 not desired. Note that when doing this, you can mix different regimens
75 for input, display, and color; however, unless you know what you're doing,
76 you probably shouldn't, as you're likely to get really weird results.
77 See the code for more details.
78
79 Any functions that you don't need to access can be left out of the qw()
80 list. In fact, the entire list can be omitted, in which case none of these
81 names will be imported into your namespace. In that case, you'll have to
82 fully qualify them (like Console::Virtual::gotoxy()) to use them.
83
84 Input Functions:
85
86 getkey() wait for keystroke; don't wait for ENTER or echo
87
88 Output Functions:
89
90 clrscr() clear the screen
91 clreol() clear to end of line
92 display(@list) display all strings in @list at screen cursor
93 gotoxy($x,$y) move the cursor to the 1-based (x,y) coordinate
94 bold() set display style to bold
95 inverse() set display style to inverted
96 normal() set display style back to normal
97 update_display() explicitly refresh the screen (Curses & Teletype need this)
98 color($f,$b) sets the colors of text about to be displayed
99
100 Acceptable arguments for $f and $b in color() are 'black', 'red', 'blue',
101 'purple', 'green', 'brown', 'aqua', 'grey', 'pink', 'sky' (blue), 'magenta',
102 'lime' (green), 'yellow', 'cyan', and 'white'. Of course, not all terminals
103 can display this many colors (or any color at all,) in which case color will
104 be crudely approximated.
105
106 Since the library is intended to be simple and abstract, that's all there is;
107 nothing fancy enough to be severely broken, no capability predicates to check,
108 no overkill object-oriented interface to follow.
109
110 Differences with Term::Screen
111 -----------------------------
112
113 Console::Virtual is designed to be a (portable) abstraction layer, whereas
114 Term::Screen is not. There are several 'holes' in the interfaces provided
115 by Term::Screen; that is, actions which are not prohibited as they probably
116 ought to be. In fact, last I checked, they are encouraged.
117
118 These actions are prohibited in Console::Virtual. Specifically, you should
119 not simply use 'print' to place text on the display device; you must instead
120 use display(). If you do not do this, the output of your program will look
121 funny (to say the least) when the end user is using Curses, or a teletype,
122 or some future output technology that Console::Virtual one day delegates to.
123 By the same token, you must occasionally use update_display() for the
124 benefit of Curses and other output regimens which require explicit refresh.
125 Calling update_display() must be done when the cursor is to be seen, by
126 the user, to move. It is also a good idea to do it in anticipation of a
127 long upcoming delay in the program (e.g. intense computation.)
128
129 History
130 -------
131
132 v2001.0123: Renamed this module to _Console::Virtual.
133 v2001.0124: fixed some namespace issues w.r.t. Win32.
134 v2001.0127: added Color subfunctionality.
135 v2003.0325: fixed up test.pl and readme.txt (no changes to code)
136 v2007.1122: renamed to Console::Virtual, prettied readme.txt.
137 Also updated language in BSD license (no "REGENTS".)
138
139 More Information
140 ----------------
141
142 The latest version of Console::Virtual can be found at:
143
144 http://catseye.webhop.net/projects/cons_virt/
145
146 Chris Pressey
147 November 22, 2007
148 Chicago, Illinois, USA
00 #!/usr/bin/perl -w
1 # test.pl - test program for Console::Virtual
2 # v2007.1122 Chris Pressey, Cat's Eye Technologies
3
4 # Copyright (c)2000-2007, Chris Pressey, Cat's Eye Technologies.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # 1. Redistributions of source code must retain the above copyright
12 # notices, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notices, this list of conditions, and the following disclaimer in
15 # the documentation and/or other materials provided with the
16 # distribution.
17 # 3. Neither the names of the copyright holders nor the names of their
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
1 # test.pl - test program for Console::Virtual v2.0
2 # By Chris Pressey, Cat's Eye Technologies.
3 # This work is in the public domain.
334
345 # This line allows us to have the Console directory in the same
356 # directory as the test script.
4112 # BEGIN { $Console::Virtual::setup{input} = 'POSIX'; $Console::Virtual::setup{display} = 'Tput'; }
4213 # BEGIN { $Console::Virtual::setup{input} = 'Teletype'; $Console::Virtual::setup{display} = 'Teletype'; }
4314
44 use Console::Virtual 2001.0127 qw(getkey display gotoxy clrscr clreol
45 normal inverse bold update_display);
15 use Console::Virtual 2.0 qw(getkey display gotoxy clrscr clreol
16 normal inverse bold update_display);
4617
4718 clrscr;
4819 gotoxy(10,20);
7849 update_display;
7950
8051 ### END of test.pl ###
81
6262 # BEGIN { $Console::Virtual::setup{input} = 'Teletype'; }
6363 # BEGIN { $Console::Virtual::setup{color} = 'ANSI16'; }
6464
65 use Console::Virtual 2007.1122
65 use Console::Virtual 2.0
6666 qw(getkey display gotoxy clrscr clreol
67 normal inverse bold update_display color);
68
69 # This lets us do sub-second sleeps, if Time::HiRes is available.
70 my $sleep = sub($) { sleep(shift); };
71 my $found_time_hires = 0;
72 foreach my $c (@INC)
73 {
74 $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
75 }
76 if ($found_time_hires) {
77 require Time::HiRes;
78 $sleep = sub($) { Time::HiRes::sleep(shift); };
79 }
67 normal inverse bold update_display color
68 vsleep);
8069
8170 ### GLOBALS ###
8271
253242 }
254243 }
255244 update_display();
256 &$sleep($delay / 1000);
245 vsleep($delay / 1000);
257246 }
258247
259248 ### END ###