clio 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/CHANGES +66 -0
  2. data/MANIFEST +48 -169
  3. data/README +13 -17
  4. data/RELEASE +8 -0
  5. data/VERSION +1 -0
  6. data/lib/clio/buffer.rb +93 -0
  7. data/lib/clio/commandable.rb +71 -69
  8. data/lib/clio/commandline.rb +429 -230
  9. data/lib/clio/consoleutils.rb +0 -16
  10. data/lib/clio/facets/kernel.rb +13 -0
  11. data/lib/clio/facets/string.rb +25 -0
  12. data/lib/clio/layout.rb +14 -0
  13. data/lib/clio/layout/flow.rb +1 -0
  14. data/lib/clio/layout/line.rb +23 -0
  15. data/lib/clio/layout/list.rb +33 -0
  16. data/lib/clio/layout/split.rb +122 -0
  17. data/lib/clio/layout/stack.rb +17 -0
  18. data/lib/clio/layout/table.rb +46 -0
  19. data/lib/clio/progressbar.rb +189 -210
  20. data/lib/clio/string.rb +116 -109
  21. data/lib/clio/usage.rb +184 -0
  22. data/lib/clio/usage/argument.rb +84 -0
  23. data/lib/clio/usage/command.rb +440 -0
  24. data/lib/clio/usage/interface.rb +122 -0
  25. data/lib/clio/usage/main.rb +165 -0
  26. data/lib/clio/usage/option.rb +251 -0
  27. data/lib/clio/usage/parser.rb +191 -0
  28. data/lib/clio/usage/signature.rb +55 -0
  29. data/meta/abstract +3 -0
  30. data/meta/authors +1 -0
  31. data/meta/created +1 -0
  32. data/meta/homepage +1 -0
  33. data/meta/license +1 -0
  34. data/meta/repository +1 -0
  35. data/meta/summary +1 -0
  36. data/spec/commandline/autousage.rd +56 -0
  37. data/spec/commandline/bracket.rd +64 -0
  38. data/spec/commandline/completion.rd +38 -0
  39. data/spec/commandline/define.rd +44 -0
  40. data/spec/commandline/method.rd +60 -0
  41. data/spec/commandline/parse.rd +72 -0
  42. data/spec/commandline/scenario.rd +81 -0
  43. data/spec/commandline/subclass.rd +54 -0
  44. data/spec/string/unit.rd +58 -0
  45. data/spec/usage/define.rd +44 -0
  46. data/spec/usage/parse.rd +47 -0
  47. metadata +65 -196
  48. data/HISTORY +0 -11
  49. data/METADATA +0 -18
  50. data/NEWS +0 -10
  51. data/admin/config/reap.yaml +0 -30
  52. data/admin/depot/commandline.rb +0 -219
  53. data/admin/depot/multicommand.rb +0 -403
  54. data/admin/depot/test_multicommand.rb +0 -40
  55. data/admin/log/notes.xml +0 -28
  56. data/admin/log/stats.html +0 -25
  57. data/admin/log/syntax.log +0 -0
  58. data/admin/log/testunit.log +0 -16
  59. data/admin/pack/clio-0.0.1.gem +0 -0
  60. data/admin/share/reap/example.rb +0 -7
  61. data/admin/temps/lib/clio/about.rb.erb +0 -4
  62. data/lib/clio/command.rb +0 -296
  63. data/lib/clio/option.rb +0 -36
  64. data/lib/clio/runmode.rb +0 -126
  65. data/test/test_command.rb +0 -42
  66. data/test/test_commandline.rb +0 -83
  67. data/vendor/Console/Console.cpp +0 -1203
  68. data/vendor/Console/Console.rdoc +0 -690
  69. data/vendor/Console/Console_ANSI.rdoc +0 -302
  70. data/vendor/Console/HISTORY.txt +0 -7
  71. data/vendor/Console/INSTALL.txt +0 -18
  72. data/vendor/Console/Makefile +0 -162
  73. data/vendor/Console/README.txt +0 -26
  74. data/vendor/Console/doc/classes/Win32.html +0 -115
  75. data/vendor/Console/doc/classes/Win32/Console.html +0 -650
  76. data/vendor/Console/doc/classes/Win32/Console.src/M000001.html +0 -31
  77. data/vendor/Console/doc/classes/Win32/Console.src/M000002.html +0 -23
  78. data/vendor/Console/doc/classes/Win32/Console.src/M000003.html +0 -23
  79. data/vendor/Console/doc/classes/Win32/Console.src/M000004.html +0 -27
  80. data/vendor/Console/doc/classes/Win32/Console.src/M000005.html +0 -23
  81. data/vendor/Console/doc/classes/Win32/Console.src/M000006.html +0 -28
  82. data/vendor/Console/doc/classes/Win32/Console.src/M000007.html +0 -23
  83. data/vendor/Console/doc/classes/Win32/Console.src/M000008.html +0 -24
  84. data/vendor/Console/doc/classes/Win32/Console.src/M000009.html +0 -44
  85. data/vendor/Console/doc/classes/Win32/Console.src/M000010.html +0 -23
  86. data/vendor/Console/doc/classes/Win32/Console.src/M000011.html +0 -33
  87. data/vendor/Console/doc/classes/Win32/Console.src/M000012.html +0 -26
  88. data/vendor/Console/doc/classes/Win32/Console.src/M000013.html +0 -27
  89. data/vendor/Console/doc/classes/Win32/Console.src/M000014.html +0 -28
  90. data/vendor/Console/doc/classes/Win32/Console.src/M000015.html +0 -23
  91. data/vendor/Console/doc/classes/Win32/Console.src/M000016.html +0 -23
  92. data/vendor/Console/doc/classes/Win32/Console.src/M000017.html +0 -23
  93. data/vendor/Console/doc/classes/Win32/Console.src/M000018.html +0 -29
  94. data/vendor/Console/doc/classes/Win32/Console.src/M000019.html +0 -23
  95. data/vendor/Console/doc/classes/Win32/Console.src/M000020.html +0 -23
  96. data/vendor/Console/doc/classes/Win32/Console.src/M000021.html +0 -28
  97. data/vendor/Console/doc/classes/Win32/Console.src/M000022.html +0 -23
  98. data/vendor/Console/doc/classes/Win32/Console.src/M000023.html +0 -28
  99. data/vendor/Console/doc/classes/Win32/Console.src/M000024.html +0 -35
  100. data/vendor/Console/doc/classes/Win32/Console.src/M000025.html +0 -28
  101. data/vendor/Console/doc/classes/Win32/Console.src/M000026.html +0 -28
  102. data/vendor/Console/doc/classes/Win32/Console.src/M000027.html +0 -28
  103. data/vendor/Console/doc/classes/Win32/Console.src/M000028.html +0 -31
  104. data/vendor/Console/doc/classes/Win32/Console.src/M000029.html +0 -23
  105. data/vendor/Console/doc/classes/Win32/Console.src/M000030.html +0 -23
  106. data/vendor/Console/doc/classes/Win32/Console.src/M000031.html +0 -23
  107. data/vendor/Console/doc/classes/Win32/Console.src/M000032.html +0 -27
  108. data/vendor/Console/doc/classes/Win32/Console.src/M000033.html +0 -27
  109. data/vendor/Console/doc/classes/Win32/Console.src/M000034.html +0 -25
  110. data/vendor/Console/doc/classes/Win32/Console/ANSI.html +0 -103
  111. data/vendor/Console/doc/classes/Win32/Console/ANSI/IO.html +0 -220
  112. data/vendor/Console/doc/classes/Win32/Console/ANSI/IO.src/M000035.html +0 -32
  113. data/vendor/Console/doc/classes/Win32/Console/ANSI/IO.src/M000036.html +0 -205
  114. data/vendor/Console/doc/classes/Win32/Console/ANSI/IO.src/M000037.html +0 -40
  115. data/vendor/Console/doc/classes/Win32/Console/ANSI/IO.src/M000038.html +0 -25
  116. data/vendor/Console/doc/classes/Win32/Console/API.html +0 -758
  117. data/vendor/Console/doc/classes/Win32/Console/API.src/M000039.html +0 -27
  118. data/vendor/Console/doc/classes/Win32/Console/API.src/M000040.html +0 -27
  119. data/vendor/Console/doc/classes/Win32/Console/API.src/M000041.html +0 -27
  120. data/vendor/Console/doc/classes/Win32/Console/API.src/M000042.html +0 -32
  121. data/vendor/Console/doc/classes/Win32/Console/API.src/M000043.html +0 -32
  122. data/vendor/Console/doc/classes/Win32/Console/API.src/M000044.html +0 -28
  123. data/vendor/Console/doc/classes/Win32/Console/API.src/M000045.html +0 -26
  124. data/vendor/Console/doc/classes/Win32/Console/API.src/M000046.html +0 -26
  125. data/vendor/Console/doc/classes/Win32/Console/API.src/M000047.html +0 -27
  126. data/vendor/Console/doc/classes/Win32/Console/API.src/M000048.html +0 -30
  127. data/vendor/Console/doc/classes/Win32/Console/API.src/M000049.html +0 -29
  128. data/vendor/Console/doc/classes/Win32/Console/API.src/M000050.html +0 -27
  129. data/vendor/Console/doc/classes/Win32/Console/API.src/M000051.html +0 -28
  130. data/vendor/Console/doc/classes/Win32/Console/API.src/M000052.html +0 -30
  131. data/vendor/Console/doc/classes/Win32/Console/API.src/M000053.html +0 -27
  132. data/vendor/Console/doc/classes/Win32/Console/API.src/M000054.html +0 -29
  133. data/vendor/Console/doc/classes/Win32/Console/API.src/M000055.html +0 -29
  134. data/vendor/Console/doc/classes/Win32/Console/API.src/M000056.html +0 -28
  135. data/vendor/Console/doc/classes/Win32/Console/API.src/M000057.html +0 -27
  136. data/vendor/Console/doc/classes/Win32/Console/API.src/M000058.html +0 -47
  137. data/vendor/Console/doc/classes/Win32/Console/API.src/M000059.html +0 -32
  138. data/vendor/Console/doc/classes/Win32/Console/API.src/M000060.html +0 -47
  139. data/vendor/Console/doc/classes/Win32/Console/API.src/M000061.html +0 -34
  140. data/vendor/Console/doc/classes/Win32/Console/API.src/M000062.html +0 -32
  141. data/vendor/Console/doc/classes/Win32/Console/API.src/M000063.html +0 -32
  142. data/vendor/Console/doc/classes/Win32/Console/API.src/M000064.html +0 -35
  143. data/vendor/Console/doc/classes/Win32/Console/API.src/M000065.html +0 -26
  144. data/vendor/Console/doc/classes/Win32/Console/API.src/M000066.html +0 -27
  145. data/vendor/Console/doc/classes/Win32/Console/API.src/M000067.html +0 -29
  146. data/vendor/Console/doc/classes/Win32/Console/API.src/M000068.html +0 -27
  147. data/vendor/Console/doc/classes/Win32/Console/API.src/M000069.html +0 -27
  148. data/vendor/Console/doc/classes/Win32/Console/API.src/M000070.html +0 -28
  149. data/vendor/Console/doc/classes/Win32/Console/API.src/M000071.html +0 -27
  150. data/vendor/Console/doc/classes/Win32/Console/API.src/M000072.html +0 -26
  151. data/vendor/Console/doc/classes/Win32/Console/API.src/M000073.html +0 -27
  152. data/vendor/Console/doc/classes/Win32/Console/API.src/M000074.html +0 -31
  153. data/vendor/Console/doc/classes/Win32/Console/API.src/M000075.html +0 -27
  154. data/vendor/Console/doc/classes/Win32/Console/API.src/M000076.html +0 -32
  155. data/vendor/Console/doc/classes/Win32/Console/API.src/M000077.html +0 -27
  156. data/vendor/Console/doc/classes/Win32/Console/API.src/M000078.html +0 -32
  157. data/vendor/Console/doc/classes/Win32/Console/API.src/M000079.html +0 -32
  158. data/vendor/Console/doc/classes/Win32/Console/API.src/M000080.html +0 -32
  159. data/vendor/Console/doc/classes/Win32/Console/Constants.html +0 -360
  160. data/vendor/Console/doc/created.rid +0 -1
  161. data/vendor/Console/doc/files/Console_ANSI_rdoc.html +0 -407
  162. data/vendor/Console/doc/files/Console_cpp.html +0 -104
  163. data/vendor/Console/doc/files/Console_rdoc.html +0 -964
  164. data/vendor/Console/doc/files/lib/Win32/Console/ANSI_rb.html +0 -123
  165. data/vendor/Console/doc/files/lib/Win32/Console_rb.html +0 -297
  166. data/vendor/Console/doc/fr_class_index.html +0 -32
  167. data/vendor/Console/doc/fr_file_index.html +0 -31
  168. data/vendor/Console/doc/fr_method_index.html +0 -106
  169. data/vendor/Console/doc/index.html +0 -24
  170. data/vendor/Console/doc/rdoc-style.css +0 -172
  171. data/vendor/Console/extconf.rb +0 -18
  172. data/vendor/Console/lib/Term/ansicolor.rb +0 -76
  173. data/vendor/Console/lib/Win32/Console.rb +0 -970
  174. data/vendor/Console/lib/Win32/Console/ANSI.rb +0 -305
  175. data/vendor/Console/test/test_cursor.rb +0 -9
  176. data/vendor/Console/test/test_mouse.rb +0 -6
  177. data/vendor/Console/test/test_readinput.rb +0 -62
  178. data/vendor/Console/test/test_readoutput.rb +0 -52
  179. data/vendor/Console/test/test_sendevent.rb +0 -17
  180. data/vendor/Console/test/test_title.rb +0 -14
  181. data/vendor/Console/test/test_write.rb +0 -36
@@ -1,964 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
- "DTD/xhtml1-transitional.dtd">
5
-
6
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
- <head>
8
- <title>File: Console.rdoc</title>
9
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
- <script type="text/javascript">
13
- // <![CDATA[
14
-
15
- function popupCode( url ) {
16
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
- }
18
-
19
- function toggleCode( id ) {
20
- if ( document.getElementById )
21
- elem = document.getElementById( id );
22
- else if ( document.all )
23
- elem = eval( "document.all." + id );
24
- else
25
- return false;
26
-
27
- elemStyle = elem.style;
28
-
29
- if ( elemStyle.display != "block" ) {
30
- elemStyle.display = "block"
31
- } else {
32
- elemStyle.display = "none"
33
- }
34
-
35
- return true;
36
- }
37
-
38
- // Make codeblocks hidden by default
39
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
-
41
- // ]]>
42
- </script>
43
-
44
- </head>
45
- <body>
46
-
47
-
48
-
49
- <div id="fileHeader">
50
- <h1>Console.rdoc</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>Console.rdoc
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Sat Jan 17 12:59:28 Hora est. de Sudam�rica E. 2004</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
- <div id="contextContent">
69
-
70
- <div id="description">
71
- <h1>NAME</h1>
72
- <p>
73
- Win32::Console - <a href="../classes/Win32.html">Win32</a> Console and
74
- Character Mode Functions
75
- </p>
76
- <h1>DESCRIPTION</h1>
77
- <p>
78
- This module implements the <a href="../classes/Win32.html">Win32</a>
79
- console and character mode functions. They give you full control on the
80
- console input and output, including: support of off-screen console buffers
81
- (eg. multiple screen pages)
82
- </p>
83
- <pre>
84
- - reading and writing of characters, attributes and whole portions of
85
- the screen
86
-
87
- - complete processing of keyboard and mouse events
88
-
89
- - some very funny additional features :)
90
- </pre>
91
- <p>
92
- Those functions should also make possible a port of the Unix&#8217;s curses
93
- library; if there is anyone interested (and/or willing to contribute) to
94
- this project, e-mail me. Thank you.
95
- </p>
96
- <h1>REFERENCE</h1>
97
- <h2>Methods</h2>
98
- <ul>
99
- <li>Alloc
100
-
101
- <p>
102
- Allocates a new console for the process. Returns C&lt;nil&gt; on errors, a
103
- nonzero value on success. A process cannot be associated with more than one
104
- console, so this method will fail if there is already an allocated console.
105
- Use Free to detach the process from the console, and then call Alloc to
106
- create a new console. See also: C&lt;Free&gt;
107
- </p>
108
- <p>
109
- Example:
110
- </p>
111
- <pre>
112
- Win32::Console::Alloc()
113
- </pre>
114
- </li>
115
- <li>Attr [attr]
116
-
117
- <p>
118
- Gets or sets the current console attribute. This attribute is used by the
119
- Write method.
120
- </p>
121
- <p>
122
- Example:
123
- </p>
124
- <pre>
125
- attr = console.Attr()
126
- console.Attr(FG_YELLOW | BG_BLUE)
127
- </pre>
128
- </li>
129
- <li>Close
130
-
131
- <p>
132
- Closes a shortcut object. Note that it is not &quot;strictly&quot; required
133
- to close the objects you created, since the Win32::Shortcut objects are
134
- automatically closed when the program ends (or when you elsehow destroy
135
- such an object).
136
- </p>
137
- <p>
138
- Example:
139
- </p>
140
- <pre>
141
- link.Close()
142
- </pre>
143
- </li>
144
- <li>Cls [attr]
145
-
146
- <p>
147
- Clear the console, with the specified I&lt;attr&gt; if given, or using
148
- ATTR_NORMAL otherwise.
149
- </p>
150
- <p>
151
- Example:
152
- </p>
153
- <pre>
154
- console.Cls()
155
- console.Cls(FG_WHITE | BG_GREEN)
156
- </pre>
157
- </li>
158
- <li>Cursor [x, y, size, visible]
159
-
160
- <p>
161
- Gets or sets cursor position and appearance. Returns C&lt;nil&gt; on
162
- errors, or a 4-element list containing: I&lt;x&gt;, I&lt;y&gt;,
163
- I&lt;size&gt;, I&lt;visible&gt;. I&lt;x&gt; and I&lt;y&gt; are the current
164
- cursor position; &#8230;
165
- </p>
166
- <p>
167
- Example:
168
- </p>
169
- <pre>
170
- x, y, size, visible = console.Cursor()
171
-
172
- # Get position only
173
- x, y = console.Cursor()
174
-
175
- console.Cursor(40, 13, 50, 1)
176
-
177
- # Set position only
178
- console.Cursor(40, 13)
179
-
180
- # Set size and visibility without affecting position
181
- console.Cursor(-1, -1, 50, 1)
182
- </pre>
183
- </li>
184
- <li>Display
185
-
186
- <p>
187
- Displays the specified console on the screen. Returns C&lt;nil&gt; on
188
- errors, a nonzero value on success.
189
- </p>
190
- <p>
191
- Example:
192
- </p>
193
- <pre>
194
- console.Display()
195
- </pre>
196
- </li>
197
- <li>FillAttr [attribute, number, col, row]
198
-
199
- <p>
200
- Fills the specified number of consecutive attributes, beginning at
201
- I&lt;col&gt;, I&lt;row&gt;, with the value specified in I&lt;attribute&gt;.
202
- Returns the number of attributes filled, or C&lt;nil&gt; on errors. See
203
- also: C&lt;FillChar&gt;.
204
- </p>
205
- <p>
206
- Example:
207
- </p>
208
- <pre>
209
- console.FillAttr(FG_BLACK | BG_BLACK, 80*25, 0, 0)
210
- </pre>
211
- </li>
212
- <li>FillChar char, number, col, row
213
-
214
- <p>
215
- Fills the specified number of consecutive characters, beginning at
216
- I&lt;col&gt;, I&lt;row&gt;, with the character specified in I&lt;char&gt;.
217
- Returns the number of characters filled, or C&lt;nil&gt; on errors. See
218
- also: C&lt;FillAttr&gt;.
219
- </p>
220
- <p>
221
- Example:
222
- </p>
223
- <pre>
224
- console.FillChar(&quot;X&quot;, 80*25, 0, 0)
225
- </pre>
226
- </li>
227
- <li>Flush
228
-
229
- <p>
230
- Flushes the console input buffer. All the events in the buffer are
231
- discarded. Returns C&lt;nil&gt; on errors, a nonzero value on success.
232
- </p>
233
- <p>
234
- Example:
235
- </p>
236
- <pre>
237
- console.Flush()
238
- </pre>
239
- </li>
240
- <li>Free
241
-
242
- <p>
243
- Detaches the process from the console. Returns C&lt;nil&gt; on errors, a
244
- nonzero value on success. See also: C&lt;Alloc&gt;.
245
- </p>
246
- <p>
247
- Example:
248
- </p>
249
- <pre>
250
- Win32::Console::Free()
251
- </pre>
252
- </li>
253
- <li>GenerateCtrlEvent [type, processgroup]
254
-
255
- <p>
256
- Sends a break signal of the specified I&lt;type&gt; to the specified
257
- I&lt;processgroup&gt;. I&lt;type&gt; can be one of the following constants:
258
- </p>
259
- <pre>
260
- CTRL_BREAK_EVENT
261
- CTRL_C_EVENT
262
- </pre>
263
- <p>
264
- they signal, respectively, the pressing of Control + Break and of Control +
265
- C; if not specified, it defaults to CTRL_C_EVENT. I&lt;processgroup&gt; is
266
- the pid of a process sharing the same console. If omitted, it defaults to 0
267
- (the current process), which is also the only meaningful value that you can
268
- pass to this function. Returns C&lt;nil&gt; on errors, a nonzero value on
269
- success.
270
- </p>
271
- <p>
272
- Example:
273
- </p>
274
- <pre>
275
- # break this script now
276
- Win32::Console::GenerateCtrlEvent()
277
- </pre>
278
- </li>
279
- <li>GetEvents
280
-
281
- <p>
282
- Returns the number of unread input events in the console&#8217;s input
283
- buffer, or C&lt;nil&gt; on errors. See also: C&lt;Input&gt;,
284
- C&lt;InputChar&gt;, C&lt;PeekInput&gt;, C&lt;WriteInput&gt;.
285
- </p>
286
- <p>
287
- Example:
288
- </p>
289
- <pre>
290
- events = console.GetEvents()
291
- </pre>
292
- </li>
293
- <li>Info
294
-
295
- <p>
296
- Returns an array of informations about the console (or C&lt;nil&gt; on
297
- errors), which contains:
298
- </p>
299
- <pre>
300
- * columns (X size) of the console buffer.
301
-
302
- * rows (Y size) of the console buffer.
303
-
304
- * current column (X position) of the cursor.
305
-
306
- * current row (Y position) of the cursor.
307
-
308
- * current attribute used for C&lt;Write&gt;.
309
-
310
- * left column (X of the starting point) of the current console window.
311
-
312
- * top row (Y of the starting point) of the current console window.
313
-
314
- * right column (X of the final point) of the current console window.
315
-
316
- * bottom row (Y of the final point) of the current console window.
317
-
318
- * maximum number of columns for the console window, given the current
319
- buffer size, font and the screen size.
320
-
321
- * maximum number of rows for the console window, given the current
322
- buffer size, font and the screen size.
323
- </pre>
324
- <p>
325
- See also: <b>Attr</b>, <b>Cursor</b>, <b>Size</b>, <b>Window</b>,
326
- <b>MaxWindow</b>.
327
- </p>
328
- <p>
329
- Example:
330
- </p>
331
- <pre>
332
- info = console.Info()
333
- puts &quot;Cursor at #{info[3]}, #{info[4]}.&quot;
334
- </pre>
335
- </li>
336
- <li>Input
337
-
338
- <p>
339
- Reads an event from the input buffer. Returns an array of values, which
340
- depending on the event&#8217;s nature are:
341
- </p>
342
- <ul>
343
- <li>keyboard event
344
-
345
- <pre>
346
- The array will contain:
347
-
348
- * event type: 1 for keyboard
349
-
350
- * key down: TRUE if the key is being pressed, FALSE if the key is being released
351
-
352
- * repeat count: the number of times the key is being held down
353
-
354
- * virtual keycode: the virtual key code of the key
355
-
356
- * virtual scancode: the virtual scan code of the key
357
-
358
- * char: the ASCII code of the character (if the key is a character key, 0 otherwise)
359
-
360
- * control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
361
- </pre>
362
- </li>
363
- <li>mouse event
364
-
365
- <p>
366
- The array will contain:
367
- </p>
368
- <pre>
369
- * event type: 2 for mouse
370
-
371
- * mouse pos. X: X coordinate (column) of the mouse location
372
-
373
- * mouse pos. Y: Y coordinate (row) of the mouse location
374
-
375
- * button state: the mouse button(s) which are pressed
376
-
377
- * control key state: the state of the control keys (SHIFTs, CTRLs, ALTs, etc.)
378
-
379
- * event flags: the type of the mouse event
380
- </pre>
381
- </li>
382
- </ul>
383
- <p>
384
- This method will return <b>nil</b> on errors. Note that the events returned
385
- are depending on the input <b>Mode</b> of the console; for example, mouse
386
- events are not intercepted unless ENABLE_MOUSE_INPUT is specified. See
387
- also: <b>GetEvents</b>, <b>InputChar</b>, <b>Mode</b>, <b>PeekInput</b>,
388
- <b>WriteInput</b>.
389
- </p>
390
- <p>
391
- Example:
392
- </p>
393
- <pre>
394
- event = console.Input()
395
- </pre>
396
- </li>
397
- <li>InputChar number
398
-
399
- <p>
400
- Reads and returns I&lt;number&gt; characters from the console input buffer,
401
- or <b>nil</b> on errors. See also: <b>Input</b>, <b>Mode</b>.
402
- </p>
403
- <p>
404
- Example:
405
- </p>
406
- <pre>
407
- key = console.InputChar(1)
408
- </pre>
409
- </li>
410
- <li>InputCP [codepage]
411
-
412
- <p>
413
- Gets or sets the input code page used by the console. Note that this
414
- doesn&#8217;t apply to a console object, but to the standard input console.
415
- This attribute is used by the Write method. See also: <b>OutputCP</b>.
416
- </p>
417
- <p>
418
- Example:
419
- </p>
420
- <pre>
421
- codepage = Win32::Console::InputCP()
422
- Win32::Console::InputCP(437)
423
- </pre>
424
- </li>
425
- <li>MaxWindow
426
-
427
- <p>
428
- Returns the size of the largest possible console window, based on the
429
- current font and the size of the display. The result is <b>nil</b> on
430
- errors, otherwise a 2-element list containing col, row.
431
- </p>
432
- <p>
433
- Example:
434
- </p>
435
- <pre>
436
- maxCol, maxRow = console.MaxWindow()
437
- </pre>
438
- </li>
439
- <li>Mode [flags]
440
-
441
- <p>
442
- Gets or sets the input or output mode of a console. I&lt;flags&gt; can be a
443
- combination of the following constants:
444
- </p>
445
- <pre>
446
- ENABLE_LINE_INPUT
447
- ENABLE_ECHO_INPUT
448
- ENABLE_PROCESSED_INPUT
449
- ENABLE_WINDOW_INPUT
450
- ENABLE_MOUSE_INPUT
451
- ENABLE_PROCESSED_OUTPUT
452
- ENABLE_WRAP_AT_EOL_OUTPUT
453
- </pre>
454
- <p>
455
- For more informations on the meaning of those flags, please refer to the
456
- L&lt;&quot;Microsoft&#8217;s Documentation&quot;&gt;.
457
- </p>
458
- <p>
459
- Example:
460
- </p>
461
- <pre>
462
- mode = console.Mode()
463
- console.Mode(ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT)
464
- </pre>
465
- </li>
466
- <li>MouseButtons
467
-
468
- <p>
469
- Returns the number of the buttons on your mouse, or <b>nil</b> on errors.
470
- </p>
471
- <p>
472
- Example:
473
- </p>
474
- <pre>
475
- puts &quot;Your mouse has #{Win32::Console::MouseButtons()} buttons.&quot;
476
- </pre>
477
- </li>
478
- <li>Win32::Console.new standard_handle
479
-
480
- </li>
481
- <li>Win32::Console.new [accessmode, sharemode]
482
-
483
- <p>
484
- Creates a new console object. The first form creates a handle to a standard
485
- channel, I&lt;standard_handle&gt; can be one of the following:
486
- </p>
487
- <pre>
488
- STD_OUTPUT_HANDLE
489
- STD_ERROR_HANDLE
490
- STD_INPUT_HANDLE
491
- </pre>
492
- <p>
493
- The second form, instead, creates a console screen buffer in memory, which
494
- you can access for reading and writing as a normal console, and then
495
- redirect on the standard output (the screen) with <b>Display</b>. In this
496
- case, you can specify one or both of the following values for
497
- I&lt;accessmode&gt;:
498
- </p>
499
- <pre>
500
- GENERIC_READ
501
- GENERIC_WRITE
502
- </pre>
503
- <p>
504
- which are the permissions you will have on the created buffer, and one or
505
- both of the following values for I&lt;sharemode&gt;:
506
- </p>
507
- <pre>
508
- FILE_SHARE_READ
509
- FILE_SHARE_WRITE
510
- </pre>
511
- <p>
512
- which affect the way the console can be shared. If you don&#8217;t specify
513
- any of those parameters, all 4 flags will be used.
514
- </p>
515
- <p>
516
- Example:
517
- </p>
518
- <pre>
519
- stdout = Win32::Console.new(STD_OUTPUT_HANDLE)
520
- stderr = Win32::Console.new(STD_ERROR_HANDLE)
521
- stdin = Win32::Console.new(STD_INPUT_HANDLE)
522
-
523
- buffer = Win32::Console.new()
524
- buffer = Win32::Console.new(GENERIC_READ | GENERIC_WRITE)
525
- </pre>
526
- </li>
527
- <li>OutputCP [codepage]
528
-
529
- <p>
530
- Gets or sets the output code page used by the console. Note that this
531
- doesn&#8217;t apply to a console object, but to the standard output
532
- console. See also: <b>InputCP</b>.
533
- </p>
534
- <p>
535
- Example:
536
- </p>
537
- <pre>
538
- codepage = Win32::Console::OutputCP()
539
- Win32::Console::OutputCP(437)
540
- </pre>
541
- </li>
542
- <li>PeekInput
543
-
544
- <p>
545
- Does exactly the same as <b>Input</b>, except that the event read is not
546
- removed from the input buffer. See also: <b>GetEvents</b>, <b>Input</b>,
547
- <b>InputChar</b>, <b>Mode</b>, <b>WriteInput</b>.
548
- </p>
549
- <p>
550
- Example:
551
- </p>
552
- <pre>
553
- event = console.PeekInput()
554
- </pre>
555
- </li>
556
- <li>ReadAttr [number, col, row]
557
-
558
- <p>
559
- Reads the specified I&lt;number&gt; of consecutive attributes, beginning at
560
- I&lt;col&gt;, I&lt;row&gt;, from the console. Returns the attributes read
561
- (a variable containing one character for each attribute), or <b>nil</b> on
562
- errors. You can then pass the returned variable to <b>WriteAttr</b> to
563
- restore the saved attributes on screen. See also: <b>ReadChar</b>,
564
- <b>ReadRect</b>.
565
- </p>
566
- <p>
567
- Example:
568
- </p>
569
- <pre>
570
- colors = console.ReadAttr(80*25, 0, 0)
571
- </pre>
572
- </li>
573
- <li>ReadChar [number, col, row]
574
-
575
- <p>
576
- Reads the specified I&lt;number&gt; of consecutive characters, beginning at
577
- I&lt;col&gt;, I&lt;row&gt;, from the console. Returns a string containing
578
- the characters read, or <b>nil</b> on errors. You can then pass the
579
- returned variable to <b>WriteChar</b> to restore the saved characters on
580
- screen. See also: <b>ReadAttr</b>, <b>ReadRect</b>.
581
- </p>
582
- <p>
583
- Example:
584
- </p>
585
- <pre>
586
- chars = console.ReadChar(80*25, 0, 0)
587
- </pre>
588
- </li>
589
- <li>ReadRect left, top, right, bottom
590
-
591
- <p>
592
- Reads the content (characters and attributes) of the rectangle specified by
593
- I&lt;left&gt;, I&lt;top&gt;, I&lt;right&gt;, I&lt;bottom&gt; from the
594
- console. Returns a string containing the rectangle read, or <b>nil</b> on
595
- errors. You can then pass the returned variable to <b>WriteRect</b> to
596
- restore the saved rectangle on screen (or on another console). See also:
597
- <b>ReadAttr</b>, <b>ReadChar</b>.
598
- </p>
599
- <p>
600
- Example:
601
- </p>
602
- <pre>
603
- rect = console.ReadRect(0, 0, 80, 25)
604
- </pre>
605
- </li>
606
- <li>Scroll left, top, right, bottom, col, row, char, attr,
607
-
608
- <pre>
609
- [cleft, ctop, cright, cbottom]
610
- </pre>
611
- <p>
612
- Moves a block of data in a console buffer the block is identified by
613
- I&lt;left&gt;, I&lt;top&gt;, I&lt;right&gt;, I&lt;bottom&gt;, while
614
- I&lt;row&gt;, I&lt;col&gt; identify the new location of the block. The
615
- cells left empty as a result of the move are filled with the character
616
- I&lt;char&gt; and attribute I&lt;attr&gt;. Optionally you can specify a
617
- clipping region with I&lt;cleft&gt;, I&lt;ctop&gt;, I&lt;cright&gt;,
618
- I&lt;cbottom&gt;, so that the content of the console outside this rectangle
619
- are unchanged. Returns <b>nil</b> on errors, a nonzero value on success.
620
- </p>
621
- <p>
622
- Example:
623
- </p>
624
- <pre>
625
- # scrolls the screen 10 lines down, filling with black spaces
626
- console.Scroll(0, 0, 80, 25, 0, 10, &quot; &quot;, FG_BLACK | BG_BLACK)
627
- </pre>
628
- </li>
629
- <li>Select standard_handle
630
-
631
- <p>
632
- Redirects a standard handle to the specified console.
633
- I&lt;standard_handle&gt; can have one of the following values:
634
- </p>
635
- <pre>
636
- STD_INPUT_HANDLE
637
- STD_OUTPUT_HANDLE
638
- STD_ERROR_HANDLE
639
- </pre>
640
- <p>
641
- Returns <b>nil</b> on errors, a nonzero value on success.
642
- </p>
643
- <p>
644
- Example:
645
- </p>
646
- <pre>
647
- console.Select(STD_OUTPUT_HANDLE)
648
- </pre>
649
- </li>
650
- <li>Size [col, row]
651
-
652
- <p>
653
- Gets or sets the console buffer size.
654
- </p>
655
- <p>
656
- Example:
657
- </p>
658
- <pre>
659
- x, y = console.Size()
660
- console.Size(80, 25)
661
- </pre>
662
- </li>
663
- <li>Title [title]
664
-
665
- <p>
666
- Gets or sets the title bar the string of the current console window.
667
- </p>
668
- <p>
669
- Example:
670
- </p>
671
- <pre>
672
- title = console.Title()
673
- console.Title(&quot;This is a title&quot;)
674
- </pre>
675
- </li>
676
- <li>Window [flag, left, top, right, bottom]
677
-
678
- <p>
679
- Gets or sets the current console window size. If called without arguments,
680
- returns a 4-element list containing the current window coordinates in the
681
- form of I&lt;left&gt;, I&lt;top&gt;, I&lt;right&gt;, I&lt;bottom&gt;. To
682
- set the window size, you have to specify an additional I&lt;flag&gt;
683
- parameter: if it is 0 (zero), coordinates are considered relative to the
684
- current coordinates; if it is non-zero, coordinates are absolute.
685
- </p>
686
- <p>
687
- Example:
688
- </p>
689
- <pre>
690
- left, top, right, bottom = console.Window()
691
- console.Window(1, 0, 0, 80, 50)
692
- </pre>
693
- </li>
694
- <li>Write string
695
-
696
- <p>
697
- Writes I&lt;string&gt; on the console, using the current attribute, that
698
- you can set with <b>Attr</b>, and advancing the cursor as needed. This
699
- isn&#8217;t so different from Perl&#8217;s &quot;print&quot; statement.
700
- Returns the number of characters written or <b>nil</b> on errors. See also:
701
- <b>WriteAttr</b>, <b>WriteChar</b>, <b>WriteRect</b>.
702
- </p>
703
- <p>
704
- Example:
705
- </p>
706
- <pre>
707
- console.Write(&quot;Hello, world!&quot;)
708
- </pre>
709
- </li>
710
- <li>WriteAttr attrs, col, row
711
-
712
- <p>
713
- Writes the attributes in the string I&lt;attrs&gt;, beginning at
714
- I&lt;col&gt;, I&lt;row&gt;, without affecting the characters that are on
715
- screen. The string attrs can be the result of a <b>ReadAttr</b> function,
716
- or you can build your own attribute string; in this case, keep in mind that
717
- every attribute is treated as a character, not a number (see example).
718
- Returns the number of attributes written or <b>nil</b> on errors. See also:
719
- <b>Write</b>, <b>WriteChar</b>, <b>WriteRect</b>.
720
- </p>
721
- <p>
722
- Example:
723
- </p>
724
- <pre>
725
- console.WriteAttr($attrs, 0, 0)
726
-
727
- # note the use of chr()...
728
- attrs = (FG_BLACK | BG_WHITE).chr() * 80
729
- console.WriteAttr(attrs, 0, 0)
730
- </pre>
731
- </li>
732
- <li>WriteChar chars, col, row
733
-
734
- <p>
735
- Writes the characters in the string <em>attr</em>, beginning at
736
- <em>col</em>, <em>row</em>, without affecting the attributes that are on
737
- screen. The string <em>chars</em> can be the result of a <b>ReadChar</b>
738
- function, or a normal string. Returns the number of characters written or
739
- <b>nil</b> on errors. See also: <b>Write</b>, <b>WriteAttr</b>,
740
- <b>WriteRect</b>.
741
- </p>
742
- <p>
743
- Example:
744
- </p>
745
- <pre>
746
- console.WriteChar(&quot;Hello, worlds!&quot;, 0, 0)
747
- </pre>
748
- </li>
749
- <li>WriteInput (event)
750
-
751
- <p>
752
- Pushes data in the console input buffer. I&lt;(event)&gt; is a list of
753
- values, for more information see <b>Input</b>. The string chars can be the
754
- result of a <b>ReadChar</b> function, or a normal string. Returns the
755
- number of characters written or <b>nil</b> on errors. See also:
756
- <b>Write</b>, <b>WriteAttr</b>, <b>WriteRect</b>.
757
- </p>
758
- <p>
759
- Example:
760
- </p>
761
- <pre>
762
- console.WriteInput(event)
763
- </pre>
764
- </li>
765
- <li>WriteRect rect, left, top, right, bottom
766
-
767
- <p>
768
- Writes a rectangle of characters and attributes (contained in
769
- <em>rect</em>) on the console at the coordinates specified by
770
- <em>left</em>, <em>top</em>, <em>right</em>, <em>bottom</em>. <em>rect</em>
771
- can be the result of a <b>ReadRect</b> function. Returns <b>nil</b> on
772
- errors, otherwise a 4-element list containing the coordinates of the
773
- affected rectangle, in the format <em>left</em>, <em>top</em>,
774
- <em>right</em>, <em>bottom</em>. See also: <b>Write</b>, <b>WriteAttr</b>,
775
- <b>WriteChar</b>.
776
- </p>
777
- <p>
778
- Example:
779
- </p>
780
- <pre>
781
- console.WriteRect(rect, 0, 0, 80, 25)
782
- </pre>
783
- </li>
784
- </ul>
785
- <h2>Constants</h2>
786
- <p>
787
- The following constants are defined in the namespace of
788
- Win32::Console::Constants and are brought into the current namespace when
789
- the module is required:
790
- </p>
791
- <pre>
792
- BACKGROUND_BLUE
793
- BACKGROUND_GREEN
794
- BACKGROUND_INTENSITY
795
- BACKGROUND_RED
796
- CAPSLOCK_ON
797
- CONSOLE_TEXTMODE_BUFFER
798
- ENABLE_ECHO_INPUT
799
- ENABLE_LINE_INPUT
800
- ENABLE_MOUSE_INPUT
801
- ENABLE_PROCESSED_INPUT
802
- ENABLE_PROCESSED_OUTPUT
803
- ENABLE_WINDOW_INPUT
804
- ENABLE_WRAP_AT_EOL_OUTPUT
805
- ENHANCED_KEY
806
- FILE_SHARE_READ
807
- FILE_SHARE_WRITE
808
- FOREGROUND_BLUE
809
- FOREGROUND_GREEN
810
- FOREGROUND_INTENSITY
811
- FOREGROUND_RED
812
- LEFT_ALT_PRESSED
813
- LEFT_CTRL_PRESSED
814
- NUMLOCK_ON
815
- GENERIC_READ
816
- GENERIC_WRITE
817
- RIGHT_ALT_PRESSED
818
- RIGHT_CTRL_PRESSED
819
- SCROLLLOCK_ON
820
- SHIFT_PRESSED
821
- STD_INPUT_HANDLE
822
- STD_OUTPUT_HANDLE
823
- STD_ERROR_HANDLE
824
- </pre>
825
- <p>
826
- Additionally, these other constants are also added to your current
827
- namespace when requiring the module:
828
- </p>
829
- <pre>
830
- FG_BLACK
831
- FG_BLUE
832
- FG_LIGHTBLUE
833
- FG_RED
834
- FG_LIGHTRED
835
- FG_GREEN
836
- FG_LIGHTGREEN
837
- FG_MAGENTA
838
- FG_LIGHTMAGENTA
839
- FG_CYAN
840
- FG_LIGHTCYAN
841
- FG_BROWN
842
- FG_YELLOW
843
- FG_GRAY
844
- FG_WHITE
845
-
846
- BG_BLACK
847
- BG_BLUE
848
- BG_LIGHTBLUE
849
- BG_RED
850
- BG_LIGHTRED
851
- BG_GREEN
852
- BG_LIGHTGREEN
853
- BG_MAGENTA
854
- BG_LIGHTMAGENTA
855
- BG_CYAN
856
- BG_LIGHTCYAN
857
- BG_BROWN
858
- BG_YELLOW
859
- BG_GRAY
860
- BG_WHITE
861
-
862
- ATTR_NORMAL
863
- ATTR_INVERSE
864
- </pre>
865
- <p>
866
- ATTR_NORMAL is set to gray foreground on black background (DOS&#8217;s
867
- standard colors).
868
- </p>
869
- <h2>Microsoft&#8217;s Documentation</h2>
870
- <p>
871
- Documentation for the <a href="../classes/Win32.html">Win32</a> Console and
872
- Character mode Functions can be found on Microsoft&#8217;s site at this
873
- URL:
874
- </p>
875
- <p>
876
- <a
877
- href="http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar.htm">www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar.htm</a>
878
- </p>
879
- <p>
880
- A reference of the available functions is at:
881
- </p>
882
- <p>
883
- <a
884
- href="http://www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar_34.htm">www.microsoft.com/msdn/sdk/platforms/doc/sdk/win32/sys/src/conchar_34.htm</a>
885
- </p>
886
- <h1>VERSION HISTORY</h1>
887
- <pre>
888
- * 0.031 (24 Sep 1999)
889
-
890
- * Fixed typo in GenerateCtrlEvent().
891
-
892
- * Converted and added pod documentation (from Jan Dubois &lt;jand@activestate.com&gt;).
893
-
894
- * 0.03 (07 Apr 1997)
895
-
896
- * Added &quot;GenerateCtrlEvent&quot; method.
897
-
898
- * The PLL file now comes in 2 versions, one for Perl version 5.001
899
- (build 110) and one for Perl version 5.003 (build 300 and higher,
900
- EXCEPT 304).
901
-
902
- * added an installation program that will automatically copy the right
903
- version in the right place.
904
- </pre>
905
- <ul>
906
- <li>0.01 (09 Feb 1997)
907
-
908
- <pre>
909
- * First public release.
910
- </pre>
911
- </li>
912
- </ul>
913
- <h1>AUTHORS</h1>
914
- <p>
915
- Aldo Calpini &lt;a.calpini@romagiubileo.it&gt; Perl module
916
- </p>
917
- <p>
918
- Gonzalo Garramu�o &lt;GGarramuno@aol.com&gt; Ruby Port
919
- </p>
920
- <h1>CREDITS</h1>
921
- <p>
922
- Thanks to: Jesse Dougherty, Dave Roth, ActiveWare, and the Perl-<a
923
- href="../classes/Win32.html">Win32</a>-Users community.
924
- </p>
925
- <h1>DISCLAIMER</h1>
926
- <p>
927
- This program is FREE; you can redistribute, modify, disassemble, or even
928
- reverse engineer this software at your will. Keep in mind, however, that
929
- NOTHING IS GUARANTEED to work and everything you do is AT YOUR OWN RISK - I
930
- will not take responsibility for any damage, loss of money and/or health
931
- that may arise from the use of this program!
932
- </p>
933
- <p>
934
- This is distributed under the terms of Larry Wall&#8217;s Artistic License.
935
- </p>
936
-
937
- </div>
938
-
939
-
940
-
941
-
942
-
943
-
944
-
945
-
946
- </div>
947
-
948
-
949
-
950
- <!-- if includes -->
951
-
952
-
953
- <!-- if method_list -->
954
-
955
-
956
- </div>
957
-
958
-
959
- <div id="validator-badges">
960
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
961
- </div>
962
-
963
- </body>
964
- </html>