win32console 1.2.0-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY.txt ADDED
@@ -0,0 +1,7 @@
1
+ v1.0 - Added .dup to _printString function to avoid mangling outside
2
+ string references. Removed the other (later) .dup call.
3
+ Turned of some exceptions that were conflicting with using
4
+ the module with pipes or redirections.
5
+ v0.8 - Fixed bugs in reading routines, added ruby docs, and
6
+ sample test suite.
7
+ v0.5 - First public release.
data/HISTORY_GEM.txt ADDED
@@ -0,0 +1,38 @@
1
+ 1.2.0 - Code corrections integrated from GitHub
2
+ * Removed license conflicting ANSI Term code and functionality.
3
+ * Better code organization and clenaup
4
+
5
+ 1.1.0 - Bug fixes provided by Gordon Thiesfeld (gthiesfeld at gmail dot com).
6
+ * added #putc to Win32::Console::ANSI::IO
7
+ This putc buffers escape sequences so that they will be handled properly
8
+ *added Kernel#putc
9
+ Redefined Kernel#putc to wrap Win32::Console::ANSI::IO#putc
10
+ *added #redirected? to Win32::Console::ANSI::IO
11
+ Checks the mode of the console to see if IO is being redirected or not
12
+ * fixed "Invalid Handle" error in compiled version of GetConsoleMode
13
+ I'm actually not sure of the source of this error. It may be expected behavior when output is being redirected. I worked around it by rescuing the exception in Win32::Console#Mode and returning 9999. I picked that arbitrary value, because it is higher than 31, which is what I think is the highest value Mode would return if output isn't being redirected.
14
+ * modified Win32::Console::ANSI::IO#write
15
+ to check for redirection. If output is redirected, it uses WriteFile instead of WriteConosle. It also skips the parsing step, and passes the escape sequences through.
16
+ * added Win32::Console::API#WriteFile
17
+ to both the Ruby and compiled versions
18
+ * added Win32::Console*WriteFile
19
+ This is a wrapper around Win32::Console::API#WriteFile
20
+ * modified Win32::Console::ANSI::IO#_PrintString
21
+ Didn't change behavior, just tried to make it more idiomatic ruby. I didn't make all of the changes I wanted to, because I wasn't sure how to test them all.
22
+ * split Win32::Console::Constants and Win32::Console::API out into seperate files.
23
+ These two classes were in 'Win32/Console.rb' I moved them into 'Win32/Console/constants.rb' and 'Win32/Console/api.rb' respectively.
24
+ * cleaned up indentation
25
+ indentations was a mixture of tabs and spaces. I made everything indented with 2 spaces.
26
+ * modified all Win32::Console::API methods
27
+ It was assigning Win32API functions to class variables. I switched them to instance variables. I also changed the idiom it was using to instantiate the objects.
28
+ For instance, instead of:
29
+
30
+ if @@m_AllocConsole == nil
31
+ @@m_AllocConsole = Win32API.new( "kernel32", "AllocConsole",
32
+ [], 'l' )
33
+
34
+ It is now:
35
+
36
+ @AllocConsole ||= Win32API.new( "kernel32", "AllocConsole", [], 'l' )
37
+ * Non-string arguments passed to Win32::Console::ANSI#write caused error - fix by Ivan Evtuhovich (evtuhovich at gmail dot com).
38
+ 1.0.8 - First public release of win32console gem by Justin Bailey (jgbailey at gmail dot com).
data/INSTALL.txt ADDED
@@ -0,0 +1,18 @@
1
+
2
+ To compile and install:
3
+
4
+
5
+ Open a windows console.
6
+ > vcvars32.bat # to set up microsoft's compiling environment
7
+ # this is located in the bin/ directory of the MSVC compiler
8
+ > ruby extconf.rb # to create a Makefile
9
+ > nmake # to compile
10
+ > nmake install # to install
11
+
12
+
13
+ To test:
14
+
15
+ > cd test
16
+ > dir # to see available samples
17
+ > ruby [anysample]
18
+
data/README.txt ADDED
@@ -0,0 +1,25 @@
1
+
2
+ This file implements a port of Perl's Win32::Console
3
+ and Win32::Console::ANSI modules.
4
+
5
+ Win32::Console allows controling the windows command line terminal
6
+ thru an OO-interface. This allows you to query the terminal (find
7
+ its size, characters, attributes, etc). The interface and functionality
8
+ should be identical to Perl's.
9
+
10
+ Win32::Console consists of a Ruby .rb interface.
11
+ For best performance, this library has been also ported to C.
12
+ If you lack a C compiler, you can still use the class thru the ruby
13
+ interface. If you can compile it, then the ruby interface is not
14
+ used and the C functions are called instead.
15
+
16
+ Win32::Console::ANSI is a class derived from IO that seamlessly
17
+ translates ANSI Esc control character codes into Windows' command.exe
18
+ or cmd.exe equivalents.
19
+
20
+ These modules allow you to develop command-line tools that can take
21
+ advantage of the unix terminal functions while still being portable.
22
+ One of the most common uses for this is to allow to color your
23
+ output.
24
+ The modules are disted with Term/ansicolor.rb, too, as it is a nice
25
+ thing to verify it is working properly.
data/README_GEM.txt ADDED
@@ -0,0 +1,64 @@
1
+ = Introduction
2
+
3
+ This gem packages Gonzalo Garramuno's Win32::Console project, and includes a compiled binary for speed. The Win32::Console project's home can be found at:
4
+
5
+ http://rubyforge.org/projects/win32console
6
+
7
+ To use the gem, just put
8
+
9
+ require 'win32console'
10
+
11
+ At the top of your file.
12
+
13
+ = Example
14
+
15
+ To output a simple bolded string, try this script:
16
+
17
+ require 'rubygems'
18
+ require 'win32console'
19
+ include Win32::Console::ANSI
20
+ include Term::ANSIColor
21
+
22
+ puts bold << "bolded text" << clear << " and no longer bold."
23
+
24
+ = Formatting Methods Available
25
+
26
+ The full list of methods available is found in lib/Term/ansicolor.rb (generated from the @@attributes array):
27
+
28
+ clear
29
+ reset # synonym for clear
30
+ bold
31
+ dark
32
+ italic # not widely implemented
33
+ underline
34
+ underscore # synonym for underline
35
+ blink
36
+ rapid_blink # not widely implemented
37
+ negative # no reverse because of String#reverse
38
+ concealed
39
+ strikethrough # not widely implemented
40
+
41
+ # The following will set the foreground color
42
+
43
+ black
44
+ red
45
+ green
46
+ yellow
47
+ blue
48
+ magenta
49
+ cyan
50
+ white
51
+
52
+ # The following will set the background color
53
+
54
+ on_black
55
+ on_red
56
+ on_green
57
+ on_yellow
58
+ on_blue
59
+ on_magenta
60
+ on_cyan
61
+ on_white
62
+
63
+ The methods are fairly sophisticated. If you don't pass an argument, the appropriate escape sequence is returned. If a string is given, it will be outputted with an escape sequence wrapping it to apply the formatting to just that portion. If a block is given, the escape sequence will wrap the output of the block. Finally, if the Term::ANSIColor module is mixed into an object, and that instance supports to_str, tnen the result of to_str will be wrapped in the escape sequence.
64
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require 'rubygems'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require './tasks/ext_helper'
5
+
6
+ # House-keeping
7
+ CLEAN.include '**/*.o', '**/*.so', '**/*.bundle', '**/*.a',
8
+ '**/*.log', '{ext,lib}/*.{bundle,so,obj,pdb,lib,def,exp}',
9
+ 'ext/Makefile', '**/*.db'
10
+
11
+ spec = Gem::Specification.new do |s|
12
+ s.name = 'win32console'
13
+ s.version = '1.2.0'
14
+ s.platform = Gem::Platform::RUBY
15
+ s.has_rdoc = true
16
+ s.extra_rdoc_files = %w[ README.txt README_GEM.txt INSTALL.txt HISTORY.txt HISTORY_GEM.txt ]
17
+ s.summary = 'A library giving the Win32 console ANSI escape sequence support.'
18
+ s.description = s.summary
19
+ s.author = 'Original Library by Gonzalo Garramuno, Gem by Justin Bailey'
20
+ s.email = 'ggarra @nospam@ advancedsl.com.ar, jgbailey @nospan@ gmail.com'
21
+ s.homepage = 'http://rubyforge.org/projects/winconsole'
22
+ s.rubyforge_project = 'http://rubyforge.org/projects/winconsole'
23
+ s.description = <<EOS
24
+ This gem packages Gonzalo Garramuno's Win32::Console project, and includes a compiled binary for speed. The Win32::Console project's home can be found at:
25
+
26
+ http://rubyforge.org/projects/win32console
27
+
28
+ The gem project can be found at
29
+
30
+ http://rubyforge.org/projects/winconsole
31
+ EOS
32
+
33
+ s.require_path = 'lib'
34
+ s.extensions = %w[ ext/extconf.rb ]
35
+ s.files = FileList[ '{doc,ext,lib,test}/**/*.{rdoc,c,cpp,rb}', 'Rakefile', *s.extra_rdoc_files ]
36
+
37
+ s.rdoc_options << '--title' << 'Win32Console Gem -- Gem for Win32::Console Project' <<
38
+ '--main' << 'README_GEM.txt' <<
39
+ '--line-numbers'
40
+ end
41
+
42
+ Rake::GemPackageTask.new(spec) do |pkg|
43
+ pkg.need_tar = true
44
+ pkg.gem_spec = spec
45
+ end
46
+
47
+ # Use of ext_helper to properly setup compile tasks and native gem generation
48
+ # add 'native', 'compile' and some tweaks to gem specifications.
49
+ setup_extension 'Console', spec
data/doc/Console.rdoc ADDED
@@ -0,0 +1,690 @@
1
+ #
2
+ # = NAME
3
+ #
4
+ # Win32::Console - Win32 Console and Character Mode Functions
5
+ #
6
+ #
7
+ # = DESCRIPTION
8
+ #
9
+ # This module implements the Win32 console and character mode
10
+ # functions. They give you full control on the console input and output,
11
+ # including: support of off-screen console buffers (eg. multiple screen
12
+ # pages)
13
+ #
14
+ # - reading and writing of characters, attributes and whole portions of
15
+ # the screen
16
+ #
17
+ # - complete processing of keyboard and mouse events
18
+ #
19
+ # - some very funny additional features :)
20
+ #
21
+ #
22
+ # Those functions should also make possible a port of the Unix's curses
23
+ # library; if there is anyone interested (and/or willing to contribute)
24
+ # to this project, e-mail me. Thank you.
25
+ #
26
+ #
27
+ # = REFERENCE
28
+ #
29
+ #
30
+ # == Methods
31
+ #
32
+ # - Alloc
33
+ #
34
+ # Allocates a new console for the process. Returns C<nil> on errors, a
35
+ # nonzero value on success. A process cannot be associated with more
36
+ # than one console, so this method will fail if there is already an
37
+ # allocated console. Use Free to detach the process from the console,
38
+ # and then call Alloc to create a new console. See also: C<Free>
39
+ #
40
+ # Example:
41
+ #
42
+ # Win32::Console::Alloc()
43
+ #
44
+ # - Attr [attr]
45
+ #
46
+ # Gets or sets the current console attribute. This attribute is used by
47
+ # the Write method.
48
+ #
49
+ # Example:
50
+ #
51
+ # attr = console.Attr()
52
+ # console.Attr(FG_YELLOW | BG_BLUE)
53
+ #
54
+ # - Close
55
+ #
56
+ # Closes a shortcut object. Note that it is not "strictly" required to
57
+ # close the objects you created, since the Win32::Shortcut objects are
58
+ # automatically closed when the program ends (or when you elsehow
59
+ # destroy such an object).
60
+ #
61
+ # Example:
62
+ #
63
+ # link.Close()
64
+ #
65
+ # - Cls [attr]
66
+ #
67
+ # Clear the console, with the specified I<attr> if given, or using
68
+ # ATTR_NORMAL otherwise.
69
+ #
70
+ # Example:
71
+ #
72
+ # console.Cls()
73
+ # console.Cls(FG_WHITE | BG_GREEN)
74
+ #
75
+ # - Cursor [x, y, size, visible]
76
+ #
77
+ # Gets or sets cursor position and appearance. Returns C<nil> on
78
+ # errors, or a 4-element list containing: I<x>, I<y>, I<size>,
79
+ # I<visible>. I<x> and I<y> are the current cursor position; ...
80
+ #
81
+ # Example:
82
+ #
83
+ # x, y, size, visible = console.Cursor()
84
+ #
85
+ # # Get position only
86
+ # x, y = console.Cursor()
87
+ #
88
+ # console.Cursor(40, 13, 50, 1)
89
+ #
90
+ # # Set position only
91
+ # console.Cursor(40, 13)
92
+ #
93
+ # # Set size and visibility without affecting position
94
+ # console.Cursor(-1, -1, 50, 1)
95
+ #
96
+ # - Display
97
+ #
98
+ # Displays the specified console on the screen. Returns C<nil> on errors,
99
+ # a nonzero value on success.
100
+ #
101
+ # Example:
102
+ #
103
+ # console.Display()
104
+ #
105
+ # - FillAttr [attribute, number, col, row]
106
+ #
107
+ # Fills the specified number of consecutive attributes, beginning at
108
+ # I<col>, I<row>, with the value specified in I<attribute>. Returns the
109
+ # number of attributes filled, or C<nil> on errors. See also:
110
+ # C<FillChar>.
111
+ #
112
+ # Example:
113
+ #
114
+ # console.FillAttr(FG_BLACK | BG_BLACK, 80*25, 0, 0)
115
+ #
116
+ # - FillChar char, number, col, row
117
+ #
118
+ # Fills the specified number of consecutive characters, beginning at
119
+ # I<col>, I<row>, with the character specified in I<char>. Returns the
120
+ # number of characters filled, or C<nil> on errors. See also:
121
+ # C<FillAttr>.
122
+ #
123
+ # Example:
124
+ #
125
+ # console.FillChar("X", 80*25, 0, 0)
126
+ #
127
+ # - Flush
128
+ #
129
+ # Flushes the console input buffer. All the events in the buffer are
130
+ # discarded. Returns C<nil> on errors, a nonzero value on success.
131
+ #
132
+ # Example:
133
+ #
134
+ # console.Flush()
135
+ #
136
+ # - Free
137
+ #
138
+ # Detaches the process from the console. Returns C<nil> on errors, a
139
+ # nonzero value on success. See also: C<Alloc>.
140
+ #
141
+ # Example:
142
+ #
143
+ # Win32::Console::Free()
144
+ #
145
+ # - GenerateCtrlEvent [type, processgroup]
146
+ #
147
+ # Sends a break signal of the specified I<type> to the specified
148
+ # I<processgroup>. I<type> can be one of the following constants:
149
+ #
150
+ # CTRL_BREAK_EVENT
151
+ # CTRL_C_EVENT
152
+ #
153
+ # they signal, respectively, the pressing of Control + Break and of
154
+ # Control + C; if not specified, it defaults to CTRL_C_EVENT.
155
+ # I<processgroup> is the pid of a process sharing the same console. If
156
+ # omitted, it defaults to 0 (the current process), which is also the
157
+ # only meaningful value that you can pass to this function. Returns
158
+ # C<nil> on errors, a nonzero value on success.
159
+ #
160
+ # Example:
161
+ #
162
+ # # break this script now
163
+ # Win32::Console::GenerateCtrlEvent()
164
+ #
165
+ # - GetEvents
166
+ #
167
+ # Returns the number of unread input events in the console's input
168
+ # buffer, or C<nil> on errors. See also: C<Input>, C<InputChar>,
169
+ # C<PeekInput>, C<WriteInput>.
170
+ #
171
+ # Example:
172
+ #
173
+ # events = console.GetEvents()
174
+ #
175
+ # - Info
176
+ #
177
+ # Returns an array of informations about the console (or C<nil> on
178
+ # errors), which contains:
179
+ #
180
+ # * columns (X size) of the console buffer.
181
+ #
182
+ # * rows (Y size) of the console buffer.
183
+ #
184
+ # * current column (X position) of the cursor.
185
+ #
186
+ # * current row (Y position) of the cursor.
187
+ #
188
+ # * current attribute used for C<Write>.
189
+ #
190
+ # * left column (X of the starting point) of the current console window.
191
+ #
192
+ # * top row (Y of the starting point) of the current console window.
193
+ #
194
+ # * right column (X of the final point) of the current console window.
195
+ #
196
+ # * bottom row (Y of the final point) of the current console window.
197
+ #
198
+ # * maximum number of columns for the console window, given the current
199
+ # buffer size, font and the screen size.
200
+ #
201
+ # * maximum number of rows for the console window, given the current
202
+ # buffer size, font and the screen size.
203
+ #
204
+ #
205
+ # See also: <b>Attr</b>, <b>Cursor</b>, <b>Size</b>, <b>Window</b>, <b>MaxWindow</b>.
206
+ #
207
+ # Example:
208
+ #
209
+ # info = console.Info()
210
+ # puts "Cursor at #{info[3]}, #{info[4]}."
211
+ #
212
+ # - Input
213
+ #
214
+ # Reads an event from the input buffer. Returns an array of values, which
215
+ # depending on the event's nature are:
216
+ #
217
+ # - keyboard event
218
+ #
219
+ # The array will contain:
220
+ #
221
+ # * event type: 1 for keyboard
222
+ #
223
+ # * key down: TRUE if the key is being pressed, FALSE if the key is being released
224
+ #
225
+ # * repeat count: the number of times the key is being held down
226
+ #
227
+ # * virtual keycode: the virtual key code of the key
228
+ #
229
+ # * virtual scancode: the virtual scan code of the key
230
+ #
231
+ # * char: the ASCII code of the character (if the key is a character key, 0 otherwise)
232
+ #
233
+ # * control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
234
+ #
235
+ #
236
+ # - mouse event
237
+ #
238
+ # The array will contain:
239
+ #
240
+ # * event type: 2 for mouse
241
+ #
242
+ # * mouse pos. X: X coordinate (column) of the mouse location
243
+ #
244
+ # * mouse pos. Y: Y coordinate (row) of the mouse location
245
+ #
246
+ # * button state: the mouse button(s) which are pressed
247
+ #
248
+ # * control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
249
+ #
250
+ # * event flags: the type of the mouse event
251
+ #
252
+ #
253
+ # This method will return <b>nil</b> on errors. Note that the events
254
+ # returned are depending on the input <b>Mode</b> of the console; for example,
255
+ # mouse events are not intercepted unless ENABLE_MOUSE_INPUT is
256
+ # specified. See also: <b>GetEvents</b>, <b>InputChar</b>, <b>Mode</b>,
257
+ # <b>PeekInput</b>, <b>WriteInput</b>.
258
+ #
259
+ # Example:
260
+ #
261
+ # event = console.Input()
262
+ #
263
+ # - InputChar number
264
+ #
265
+ # Reads and returns I<number> characters from the console input buffer,
266
+ # or <b>nil</b> on errors. See also: <b>Input</b>, <b>Mode</b>.
267
+ #
268
+ # Example:
269
+ #
270
+ # key = console.InputChar(1)
271
+ #
272
+ # - InputCP [codepage]
273
+ #
274
+ # Gets or sets the input code page used by the console. Note that this
275
+ # doesn't apply to a console object, but to the standard input
276
+ # console. This attribute is used by the Write method. See also:
277
+ # <b>OutputCP</b>.
278
+ #
279
+ # Example:
280
+ #
281
+ # codepage = Win32::Console::InputCP()
282
+ # Win32::Console::InputCP(437)
283
+ #
284
+ # - MaxWindow
285
+ #
286
+ # Returns the size of the largest possible console window, based on the
287
+ # current font and the size of the display. The result is <b>nil</b> on
288
+ # errors, otherwise a 2-element list containing col, row.
289
+ #
290
+ # Example:
291
+ #
292
+ # maxCol, maxRow = console.MaxWindow()
293
+ #
294
+ # - Mode [flags]
295
+ #
296
+ # Gets or sets the input or output mode of a console. I<flags> can be a
297
+ # combination of the following constants:
298
+ #
299
+ # ENABLE_LINE_INPUT
300
+ # ENABLE_ECHO_INPUT
301
+ # ENABLE_PROCESSED_INPUT
302
+ # ENABLE_WINDOW_INPUT
303
+ # ENABLE_MOUSE_INPUT
304
+ # ENABLE_PROCESSED_OUTPUT
305
+ # ENABLE_WRAP_AT_EOL_OUTPUT
306
+ #
307
+ # For more informations on the meaning of those flags, please refer to
308
+ # the L<"Microsoft's Documentation">.
309
+ #
310
+ # Example:
311
+ #
312
+ # mode = console.Mode()
313
+ # console.Mode(ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT)
314
+ #
315
+ # - MouseButtons
316
+ #
317
+ # Returns the number of the buttons on your mouse, or <b>nil</b> on errors.
318
+ #
319
+ # Example:
320
+ #
321
+ # puts "Your mouse has #{Win32::Console::MouseButtons()} buttons."
322
+ #
323
+ # - Win32::Console.new standard_handle
324
+ #
325
+ # - Win32::Console.new [accessmode, sharemode]
326
+ #
327
+ # Creates a new console object. The first form creates a handle to a
328
+ # standard channel, I<standard_handle> can be one of the following:
329
+ #
330
+ # STD_OUTPUT_HANDLE
331
+ # STD_ERROR_HANDLE
332
+ # STD_INPUT_HANDLE
333
+ #
334
+ # The second form, instead, creates a console screen buffer in memory,
335
+ # which you can access for reading and writing as a normal console, and
336
+ # then redirect on the standard output (the screen) with <b>Display</b>. In
337
+ # this case, you can specify one or both of the following values for
338
+ # I<accessmode>:
339
+ #
340
+ # GENERIC_READ
341
+ # GENERIC_WRITE
342
+ #
343
+ # which are the permissions you will have on the created buffer, and one
344
+ # or both of the following values for I<sharemode>:
345
+ #
346
+ # FILE_SHARE_READ
347
+ # FILE_SHARE_WRITE
348
+ #
349
+ # which affect the way the console can be shared. If you don't specify
350
+ # any of those parameters, all 4 flags will be used.
351
+ #
352
+ # Example:
353
+ #
354
+ # stdout = Win32::Console.new(STD_OUTPUT_HANDLE)
355
+ # stderr = Win32::Console.new(STD_ERROR_HANDLE)
356
+ # stdin = Win32::Console.new(STD_INPUT_HANDLE)
357
+ #
358
+ # buffer = Win32::Console.new()
359
+ # buffer = Win32::Console.new(GENERIC_READ | GENERIC_WRITE)
360
+ #
361
+ # - OutputCP [codepage]
362
+ #
363
+ # Gets or sets the output code page used by the console. Note that this
364
+ # doesn't apply to a console object, but to the standard output console.
365
+ # See also: <b>InputCP</b>.
366
+ #
367
+ # Example:
368
+ #
369
+ # codepage = Win32::Console::OutputCP()
370
+ # Win32::Console::OutputCP(437)
371
+ #
372
+ # - PeekInput
373
+ #
374
+ # Does exactly the same as <b>Input</b>, except that the event read is not
375
+ # removed from the input buffer. See also: <b>GetEvents</b>, <b>Input</b>,
376
+ # <b>InputChar</b>, <b>Mode</b>, <b>WriteInput</b>.
377
+ #
378
+ # Example:
379
+ #
380
+ # event = console.PeekInput()
381
+ #
382
+ # - ReadAttr [number, col, row]
383
+ #
384
+ # Reads the specified I<number> of consecutive attributes, beginning at
385
+ # I<col>, I<row>, from the console. Returns the attributes read (a
386
+ # variable containing one character for each attribute), or <b>nil</b> on
387
+ # errors. You can then pass the returned variable to <b>WriteAttr</b> to
388
+ # restore the saved attributes on screen. See also: <b>ReadChar</b>,
389
+ # <b>ReadRect</b>.
390
+ #
391
+ # Example:
392
+ #
393
+ # colors = console.ReadAttr(80*25, 0, 0)
394
+ #
395
+ # - ReadChar [number, col, row]
396
+ #
397
+ # Reads the specified I<number> of consecutive characters, beginning at
398
+ # I<col>, I<row>, from the console. Returns a string containing the
399
+ # characters read, or <b>nil</b> on errors. You can then pass the
400
+ # returned variable to <b>WriteChar</b> to restore the saved characters on
401
+ # screen. See also: <b>ReadAttr</b>, <b>ReadRect</b>.
402
+ #
403
+ # Example:
404
+ #
405
+ # chars = console.ReadChar(80*25, 0, 0)
406
+ #
407
+ # - ReadRect left, top, right, bottom
408
+ #
409
+ # Reads the content (characters and attributes) of the rectangle
410
+ # specified by I<left>, I<top>, I<right>, I<bottom> from the console.
411
+ # Returns a string containing the rectangle read, or <b>nil</b> on errors.
412
+ # You can then pass the returned variable to <b>WriteRect</b> to restore the
413
+ # saved rectangle on screen (or on another console). See also:
414
+ # <b>ReadAttr</b>, <b>ReadChar</b>.
415
+ #
416
+ # Example:
417
+ #
418
+ # rect = console.ReadRect(0, 0, 80, 25)
419
+ #
420
+ # - Scroll left, top, right, bottom, col, row, char, attr,
421
+ # [cleft, ctop, cright, cbottom]
422
+ #
423
+ # Moves a block of data in a console buffer the block is identified by
424
+ # I<left>, I<top>, I<right>, I<bottom>, while I<row>, I<col> identify
425
+ # the new location of the block. The cells left empty as a result of
426
+ # the move are filled with the character I<char> and attribute I<attr>.
427
+ # Optionally you can specify a clipping region with I<cleft>, I<ctop>,
428
+ # I<cright>, I<cbottom>, so that the content of the console outside this
429
+ # rectangle are unchanged. Returns <b>nil</b> on errors, a nonzero value
430
+ # on success.
431
+ #
432
+ # Example:
433
+ #
434
+ # # scrolls the screen 10 lines down, filling with black spaces
435
+ # console.Scroll(0, 0, 80, 25, 0, 10, " ", FG_BLACK | BG_BLACK)
436
+ #
437
+ # - Select standard_handle
438
+ #
439
+ # Redirects a standard handle to the specified console.
440
+ # I<standard_handle> can have one of the following values:
441
+ #
442
+ # STD_INPUT_HANDLE
443
+ # STD_OUTPUT_HANDLE
444
+ # STD_ERROR_HANDLE
445
+ #
446
+ # Returns <b>nil</b> on errors, a nonzero value on success.
447
+ #
448
+ # Example:
449
+ #
450
+ # console.Select(STD_OUTPUT_HANDLE)
451
+ #
452
+ # - Size [col, row]
453
+ #
454
+ # Gets or sets the console buffer size.
455
+ #
456
+ # Example:
457
+ #
458
+ # x, y = console.Size()
459
+ # console.Size(80, 25)
460
+ #
461
+ # - Title [title]
462
+ #
463
+ # Gets or sets the title bar the string of the current console window.
464
+ #
465
+ # Example:
466
+ #
467
+ # title = console.Title()
468
+ # console.Title("This is a title")
469
+ #
470
+ # - Window [flag, left, top, right, bottom]
471
+ #
472
+ # Gets or sets the current console window size. If called without
473
+ # arguments, returns a 4-element list containing the current window
474
+ # coordinates in the form of I<left>, I<top>, I<right>, I<bottom>. To
475
+ # set the window size, you have to specify an additional I<flag>
476
+ # parameter: if it is 0 (zero), coordinates are considered relative to
477
+ # the current coordinates; if it is non-zero, coordinates are absolute.
478
+ #
479
+ # Example:
480
+ #
481
+ # left, top, right, bottom = console.Window()
482
+ # console.Window(1, 0, 0, 80, 50)
483
+ #
484
+ # - Write string
485
+ #
486
+ # Writes I<string> on the console, using the current attribute, that you
487
+ # can set with <b>Attr</b>, and advancing the cursor as needed. This isn't
488
+ # so different from Perl's "print" statement. Returns the number of
489
+ # characters written or <b>nil</b> on errors. See also: <b>WriteAttr</b>,
490
+ # <b>WriteChar</b>, <b>WriteRect</b>.
491
+ #
492
+ # Example:
493
+ #
494
+ # console.Write("Hello, world!")
495
+ #
496
+ # - WriteAttr attrs, col, row
497
+ #
498
+ # Writes the attributes in the string I<attrs>, beginning at I<col>,
499
+ # I<row>, without affecting the characters that are on screen. The
500
+ # string attrs can be the result of a <b>ReadAttr</b> function, or you can
501
+ # build your own attribute string; in this case, keep in mind that every
502
+ # attribute is treated as a character, not a number (see example).
503
+ # Returns the number of attributes written or <b>nil</b> on errors. See
504
+ # also: <b>Write</b>, <b>WriteChar</b>, <b>WriteRect</b>.
505
+ #
506
+ # Example:
507
+ #
508
+ # console.WriteAttr($attrs, 0, 0)
509
+ #
510
+ # # note the use of chr()...
511
+ # attrs = (FG_BLACK | BG_WHITE).chr() * 80
512
+ # console.WriteAttr(attrs, 0, 0)
513
+ #
514
+ # - WriteChar chars, col, row
515
+ #
516
+ # Writes the characters in the string <i>attr</i>, beginning at <i>col</i>, <i>row</i>,
517
+ # without affecting the attributes that are on screen. The string <i>chars</i>
518
+ # can be the result of a <b>ReadChar</b> function, or a normal string. Returns
519
+ # the number of characters written or <b>nil</b> on errors. See also:
520
+ # <b>Write</b>, <b>WriteAttr</b>, <b>WriteRect</b>.
521
+ #
522
+ # Example:
523
+ #
524
+ # console.WriteChar("Hello, worlds!", 0, 0)
525
+ #
526
+ # - WriteInput (event)
527
+ #
528
+ # Pushes data in the console input buffer. I<(event)> is a list of values,
529
+ # for more information see <b>Input</b>. The string chars can be the result of
530
+ # a <b>ReadChar</b> function, or a normal string. Returns the number of
531
+ # characters written or <b>nil</b> on errors. See also: <b>Write</b>,
532
+ # <b>WriteAttr</b>, <b>WriteRect</b>.
533
+ #
534
+ # Example:
535
+ #
536
+ # console.WriteInput(event)
537
+ #
538
+ # - WriteRect rect, left, top, right, bottom
539
+ #
540
+ # Writes a rectangle of characters and attributes (contained in <i>rect</i>)
541
+ # on the console at the coordinates specified by <i>left</i>, <i>top</i>,
542
+ # <i>right</i>, <i>bottom</i>. <i>rect</i> can be the result of a <b>ReadRect</b>
543
+ # function. Returns <b>nil</b> on errors, otherwise a 4-element list
544
+ # containing the coordinates of the affected rectangle, in the format
545
+ # <i>left</i>, <i>top</i>, <i>right</i>, <i>bottom</i>. See also: <b>Write</b>,
546
+ # <b>WriteAttr</b>, <b>WriteChar</b>.
547
+ #
548
+ # Example:
549
+ #
550
+ # console.WriteRect(rect, 0, 0, 80, 25)
551
+ #
552
+ #
553
+ # == Constants
554
+ #
555
+ # The following constants are defined in the namespace of
556
+ # Win32::Console::Constants and are brought into the current
557
+ # namespace when the module is required:
558
+ #
559
+ # BACKGROUND_BLUE
560
+ # BACKGROUND_GREEN
561
+ # BACKGROUND_INTENSITY
562
+ # BACKGROUND_RED
563
+ # CAPSLOCK_ON
564
+ # CONSOLE_TEXTMODE_BUFFER
565
+ # ENABLE_ECHO_INPUT
566
+ # ENABLE_LINE_INPUT
567
+ # ENABLE_MOUSE_INPUT
568
+ # ENABLE_PROCESSED_INPUT
569
+ # ENABLE_PROCESSED_OUTPUT
570
+ # ENABLE_WINDOW_INPUT
571
+ # ENABLE_WRAP_AT_EOL_OUTPUT
572
+ # ENHANCED_KEY
573
+ # FILE_SHARE_READ
574
+ # FILE_SHARE_WRITE
575
+ # FOREGROUND_BLUE
576
+ # FOREGROUND_GREEN
577
+ # FOREGROUND_INTENSITY
578
+ # FOREGROUND_RED
579
+ # LEFT_ALT_PRESSED
580
+ # LEFT_CTRL_PRESSED
581
+ # NUMLOCK_ON
582
+ # GENERIC_READ
583
+ # GENERIC_WRITE
584
+ # RIGHT_ALT_PRESSED
585
+ # RIGHT_CTRL_PRESSED
586
+ # SCROLLLOCK_ON
587
+ # SHIFT_PRESSED
588
+ # STD_INPUT_HANDLE
589
+ # STD_OUTPUT_HANDLE
590
+ # STD_ERROR_HANDLE
591
+ #
592
+ # Additionally, these other constants are also added to your current
593
+ # namespace when requiring the module:
594
+ #
595
+ # FG_BLACK
596
+ # FG_BLUE
597
+ # FG_LIGHTBLUE
598
+ # FG_RED
599
+ # FG_LIGHTRED
600
+ # FG_GREEN
601
+ # FG_LIGHTGREEN
602
+ # FG_MAGENTA
603
+ # FG_LIGHTMAGENTA
604
+ # FG_CYAN
605
+ # FG_LIGHTCYAN
606
+ # FG_BROWN
607
+ # FG_YELLOW
608
+ # FG_GRAY
609
+ # FG_WHITE
610
+ #
611
+ # BG_BLACK
612
+ # BG_BLUE
613
+ # BG_LIGHTBLUE
614
+ # BG_RED
615
+ # BG_LIGHTRED
616
+ # BG_GREEN
617
+ # BG_LIGHTGREEN
618
+ # BG_MAGENTA
619
+ # BG_LIGHTMAGENTA
620
+ # BG_CYAN
621
+ # BG_LIGHTCYAN
622
+ # BG_BROWN
623
+ # BG_YELLOW
624
+ # BG_GRAY
625
+ # BG_WHITE
626
+ #
627
+ # ATTR_NORMAL
628
+ # ATTR_INVERSE
629
+ #
630
+ # ATTR_NORMAL is set to gray foreground on black background (DOS's
631
+ # standard colors).
632
+ #
633
+ #
634
+ # == Microsoft's Documentation
635
+ #
636
+ # Documentation for the Win32 Console and Character mode Functions can
637
+ # be found on Microsoft's site at this URL:
638
+ #
639
+ # http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar.htm
640
+ #
641
+ # A reference of the available functions is at:
642
+ #
643
+ # http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar_34.htm
644
+ #
645
+ #
646
+ # = VERSION HISTORY
647
+ #
648
+ # * 0.031 (24 Sep 1999)
649
+ #
650
+ # * Fixed typo in GenerateCtrlEvent().
651
+ #
652
+ # * Converted and added pod documentation (from Jan Dubois <jand@activestate.com>).
653
+ #
654
+ # * 0.03 (07 Apr 1997)
655
+ #
656
+ # * Added "GenerateCtrlEvent" method.
657
+ #
658
+ # * The PLL file now comes in 2 versions, one for Perl version 5.001
659
+ # (build 110) and one for Perl version 5.003 (build 300 and higher,
660
+ # EXCEPT 304).
661
+ #
662
+ # * added an installation program that will automatically copy the right
663
+ # version in the right place.
664
+ #
665
+ # * 0.01 (09 Feb 1997)
666
+ #
667
+ # * First public release.
668
+ #
669
+ # = AUTHORS
670
+ #
671
+ # Aldo Calpini <a.calpini@romagiubileo.it> Perl module
672
+ #
673
+ # Gonzalo Garramu�o <GGarramuno@aol.com> Ruby Port
674
+ #
675
+ # = CREDITS
676
+ #
677
+ # Thanks to: Jesse Dougherty, Dave Roth, ActiveWare, and the
678
+ # Perl-Win32-Users community.
679
+ #
680
+ #
681
+ # = DISCLAIMER
682
+ #
683
+ # This program is FREE; you can redistribute, modify, disassemble, or
684
+ # even reverse engineer this software at your will. Keep in mind,
685
+ # however, that NOTHING IS GUARANTEED to work and everything you do is
686
+ # AT YOUR OWN RISK - I will not take responsibility for any damage, loss
687
+ # of money and/or health that may arise from the use of this program!
688
+ #
689
+ # This is distributed under the terms of Larry Wall's Artistic License.
690
+ #