conio 1.0 → 1.1.0

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.
Files changed (8) hide show
  1. data/LICENSE +1 -1
  2. data/README +51 -33
  3. data/Rakefile +40 -40
  4. data/ext/libconio.c +1009 -0
  5. data/lib/conio.rb +392 -407
  6. data/lib/libconio.so +0 -0
  7. data/test/test.rb +31 -283
  8. metadata +10 -5
@@ -1,14 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Library Console I/O for Ruby
4
-
5
3
  # *******************************************************
6
4
  # * Conio *
7
5
  # *******************************************************
8
6
  # * Library Console I/O for Ruby *
9
7
  # *******************************************************
10
8
  # * Title: Conio *
11
- # * Version: 1.0 *
9
+ # * Version: 1.1.0 *
12
10
  # * Language: Ruby *
13
11
  # * Source: conio.rb *
14
12
  # *******************************************************
@@ -20,560 +18,547 @@
20
18
  # * Copyright (C) 2010 RAGNETTO Software *
21
19
  # *******************************************************
22
20
 
21
+ # Library Console I/O for Ruby 1.9
22
+
23
23
  # Require Dynamic Library [libconio.so]
24
24
  require "libconio"
25
25
 
26
- # Include Object Libconio
26
+ # Initialize object Libconio
27
27
  include Libconio
28
28
 
29
- # ****************
30
- # * Conio Module *
31
- # ****************
32
-
29
+ # Module Conio
33
30
  module Conio
34
-
35
- # ******************
36
- # * Conio Costants *
37
- # ******************
38
-
31
+
39
32
  # Costant Color Value
40
- BLACK = 0
33
+ COLOR_BLACK = 0
41
34
 
42
35
  # Costant Color Value
43
- BLUE = 1
36
+ COLOR_BLUE = 1
44
37
 
45
38
  # Costant Color Value
46
- GREEN = 2
39
+ COLOR_GREEN = 2
47
40
 
48
41
  # Costant Color Value
49
- CYAN = 3
42
+ COLOR_CYAN = 3
50
43
 
51
44
  # Costant Color Value
52
- RED = 4
45
+ COLOR_RED = 4
53
46
 
54
47
  # Costant Color Value
55
- MAGENTA = 5
48
+ COLOR_MAGENTA = 5
56
49
 
57
50
  # Costant Color Value
58
- BROWN = 6
51
+ COLOR_BROWN = 6
59
52
 
60
53
  # Costant Color Value
61
- LIGHTGRAY = 7
54
+ COLOR_LIGHTGRAY = 7
62
55
 
63
56
  # Costant Color Value
64
- DARKGRAY = 8
57
+ COLOR_DARKGRAY = 8
65
58
 
66
59
  # Costant Color Value
67
- LIGHTBLUE = 9
60
+ COLOR_LIGHTBLUE = 9
68
61
 
69
62
  # Costant Color Value
70
- LIGHTGREEN = 10
63
+ COLOR_LIGHTGREEN = 10
71
64
 
72
65
  # Costant Color Value
73
- LIGHTCYAN = 11
66
+ COLOR_LIGHTCYAN = 11
74
67
 
75
68
  # Costant Color Value
76
- LIGHTRED = 12
69
+ COLOR_LIGHTRED = 12
77
70
 
78
71
  # Costant Color Value
79
- LIGHTMAGENTA = 13
72
+ COLOR_LIGHTMAGENTA = 13
80
73
 
81
74
  # Costant Color Value
82
- YELLOW = 14
75
+ COLOR_YELLOW = 14
83
76
 
84
77
  # Costant Color Value
85
- WHITE = 15
78
+ COLOR_WHITE = 15
86
79
 
87
80
  # Costant Info Value
88
- ATTR = 0
81
+ INFO_ATTR = 0
89
82
 
90
83
  # Costant Info Value
91
- CX = 1
84
+ INFO_CX = 1
92
85
 
93
86
  # Costant Info Value
94
- CY = 2
87
+ INFO_CY = 2
95
88
 
96
89
  # Costant Info Value
97
- TOP = 3
90
+ INFO_TOP = 3
98
91
 
99
92
  # Costant Info Value
100
- LEFT = 4
93
+ INFO_LEFT = 4
101
94
 
102
95
  # Costant Info Value
103
- RIGHT = 5
96
+ INFO_RIGHT = 5
104
97
 
105
98
  # Costant Info Value
106
- BOTTOM = 6
99
+ INFO_BOTTOM = 6
107
100
 
108
101
  # Costant Info Value
109
- WIDTH = 7
102
+ INFO_WIDTH = 7
110
103
 
111
104
  # Costant Info Value
112
- HEIGHT = 8
105
+ INFO_HEIGHT = 8
113
106
 
114
107
  # Costant Info Value
115
- MAXWIDTH = 9
108
+ INFO_MAXWIDTH = 9
116
109
 
117
110
  # Costant Info Value
118
- MAXHEIGHT = 10
111
+ INFO_MAXHEIGHT = 10
119
112
 
120
113
  # Costant Info Value
121
- TOTALWIDTH = 11
114
+ INFO_TOTALWIDTH = 11
122
115
 
123
116
  # Costant Info Value
124
- TOTALHEIGHT = 12
117
+ INFO_TOTALHEIGHT = 12
125
118
 
126
119
  # Costant Text Info Value
127
- ATTRIBUTE = 0
120
+ TEXTINFO_ATTRIBUTE = 0
128
121
 
129
122
  # Costant Text Info Value
130
- NORMATTR = 1
123
+ TEXTINFO_NORMATTR = 1
131
124
 
132
125
  # Costant Text Info Value
133
- CURRMODE = 2
126
+ TEXTINFO_CURRMODE = 2
134
127
 
135
128
  # Costant Text Info Value
136
- CURX = 3
129
+ TEXTINFO_CURX = 3
137
130
 
138
131
  # Costant Text Info Value
139
- CURY = 4
132
+ TEXTINFO_CURY = 4
140
133
 
141
134
  # Costant Text Info Value
142
- SCREENWIDTH = 5
135
+ TEXTINFO_SCREENWIDTH = 5
143
136
 
144
137
  # Costant Text Info Value
145
- SCREENHEIGHT = 6
138
+ TEXTINFO_SCREENHEIGHT = 6
146
139
 
147
140
  # Costant Text Info Value
148
- WINLEFT = 7
141
+ TEXTINFO_WINLEFT = 7
149
142
 
150
143
  # Costant Text Info Value
151
- WINTOP = 8
144
+ TEXTINFO_WINTOP = 8
152
145
 
153
146
  # Costant Text Info Value
154
- WINRIGHT = 9
147
+ TEXTINFO_WINRIGHT = 9
155
148
 
156
149
  # Costant Text Info Value
157
- WINBOTTOM = 10
150
+ TEXTINFO_WINBOTTOM = 10
158
151
 
159
152
  # Costant Cursor Value
160
- HIDE = 0
153
+ CURSOR_HIDE = 0
161
154
 
162
155
  # Costant Cursor Value
163
- NORMAL = 25
156
+ CURSOR_NORMAL = 25
164
157
 
165
158
  # Costant Cursor Value
166
- SOLID = 100
159
+ CURSOR_SOLID = 100
167
160
 
168
- # ***************************
169
- # * Conio Library Functions *
170
- # ***************************
161
+ # Costant Key Value
162
+ KEY_F1 = 59
171
163
 
172
- # Reads a string of characters from the console and stores the string, and the string length, in the location string.
173
- def cgets(lenght)
174
- # Ruby Function cgets()
175
- value = Libconio.ruby_cgets(lenght)
176
-
177
- # Return value
178
- return value
179
- end
164
+ # Costant Key Value
165
+ KEY_F2 = 60
180
166
 
181
- # Clears all characters from the cursor position to the end of the line within the string length, in the location string.
182
- def clreol()
183
- # Ruby Function clreol()
184
- Libconio.ruby_clreol()
185
-
186
- # Return nil
187
- return nil
188
- end
167
+ # Costant Key Value
168
+ KEY_F3 = 61
189
169
 
190
- # Clears the current text window and places the cursor in the upper left hand corner.
191
- def clrscr()
192
- # Ruby Function clrscr()
193
- Libconio.ruby_clrscr()
194
-
195
- # Return nil
196
- return nil
197
- end
170
+ # Costant Key Value
171
+ KEY_F4 = 62
198
172
 
199
- # Writes the null-terminated string text to the current text window. It does not append a newline character.
200
- def cputs(text)
201
- # Ruby Function cputs()
202
- value = Libconio.ruby_cputs(text)
203
-
204
- # Return text value
205
- return value
206
- end
173
+ # Costant Key Value
174
+ KEY_F5 = 63
207
175
 
208
- # Crop the window console buffer size.
209
- def crop()
210
- # Ruby Function crop()
211
- Libconio.ruby_crop()
212
-
213
- # Return nil
214
- return nil
215
- end
176
+ # Costant Key Value
177
+ KEY_F6 = 64
216
178
 
217
- # The time interval for which execution is to be suspended, in milliseconds.
218
- def delay(milliseconds)
219
- # Ruby Function delay()
220
- Libconio.ruby_delay(milliseconds)
221
-
222
- # Return nil
223
- return nil
224
- end
179
+ # Costant Key Value
180
+ KEY_F7 = 65
225
181
 
226
- # Deletes the line containing the cursor and moves all lines below it a line up.
227
- def delline()
228
- # Ruby Function delline()
229
- Libconio.ruby_delline()
230
-
231
- # Return nil
232
- return nil
233
- end
182
+ # Costant Key Value
183
+ KEY_F8 = 66
234
184
 
235
- # Write the specified number of consecutive characters, beginning at X and Y coordinates, with the value specified attribute.
236
- def fill(character,forecolor, backcolor, number, x, y)
237
- # Ruby Function fill()
238
- Libconio.ruby_fill(character, forecolor, backcolor, number, x, y)
239
-
240
- # Return nil
241
- return nil
242
- end
185
+ # Costant Key Value
186
+ KEY_F9 = 67
243
187
 
244
- # Fills the specified number of consecutive attributes, beginning at X and Y coordinates, with the value specified attribute.
245
- def fillattr(forecolor, backcolor, number, x, y)
246
- # Ruby Function fillattr()
247
- Libconio.ruby_fillattr(forecolor, backcolor, number, x, y)
248
-
249
- # Return nil
250
- return nil
251
- end
188
+ # Costant Key Value
189
+ KEY_F10 = 68
252
190
 
253
- # Write the specified number of consecutive characters, beginning at X and Y coordinates.
254
- def fillchar(character, number, x, y)
255
- # Ruby Function fillchar()
256
- Libconio.ruby_fillchar(character, number, x, y)
257
-
258
- # Return nil
259
- return nil
260
- end
191
+ # Costant Key Value
192
+ KEY_F11 = 133
261
193
 
262
- # Write the specified number of consecutive characters, beginning at X and Y coordinates.
263
- def fillcr(character, number, x, y)
264
- # Ruby Function fillcr()
265
- Libconio.ruby_fillcr(character, number, x, y)
266
-
267
- # Return nil
268
- return nil
269
- end
194
+ # Costant Key Value
195
+ KEY_F12 = 134
270
196
 
271
- # Get the contents with attributes of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
272
- def get(left, top, right, bottom, buffer)
273
- # Ruby Function get()
274
- Libconio.ruby_get(left, top, right, bottom, buffer)
275
-
276
- # Return nil
277
- return nil
278
- end
197
+ # Costant Key Value
198
+ KEY_SHIFT_F1 = 84
279
199
 
280
- # Get the attributes of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
281
- def getattrs(left, top, right, bottom, buffer)
282
- # Ruby Function getattrs()
283
- Libconio.ruby_getattrs(left, top, right, bottom, buffer)
284
-
285
- # Return nil
286
- return nil
287
- end
200
+ # Costant Key Value
201
+ KEY_SHIFT_F2 = 85
288
202
 
289
- # Reads a single character directly from the keyboard, without echoing to the screen.
290
- def getch()
291
- # Ruby Function getch()
292
- value = Libconio.ruby_getch()
293
-
294
- # Return character value
295
- return value
296
- end
203
+ # Costant Key Value
204
+ KEY_SHIFT_F3 = 86
297
205
 
298
- # Get the contents of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
299
- def getchars(left, top, right, bottom, buffer)
300
- # Ruby Function getchars()
301
- Libconio.ruby_getchars(left, top, right, bottom, buffer)
302
-
303
- # Return nil
304
- return nil
305
- end
206
+ # Costant Key Value
207
+ KEY_SHIFT_F4 = 87
306
208
 
307
- # Reads a single character from the keyboard and echoes it to the current text windows.
308
- def getche()
309
- # Ruby Function getche()
310
- value = Libconio.ruby_getche()
311
-
312
- # Return value
313
- return value
314
- end
209
+ # Costant Key Value
210
+ KEY_SHIFT_F5 = 88
315
211
 
316
- # Gets video information.
317
- def getinfo()
318
- # Ruby Function getinfo()
319
- value = Libconio.ruby_getinfo()
320
-
321
- # Return value
322
- return value
323
- end
212
+ # Costant Key Value
213
+ KEY_SHIFT_F6 = 89
324
214
 
325
- # Get the text of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
326
- def gettext(left, top, right, bottom, buffer)
327
- # Ruby Function gettext()
328
- Libconio.ruby_gettext(left, top, right, bottom, buffer)
329
-
330
- # Return nil
331
- return nil
332
- end
215
+ # Costant Key Value
216
+ KEY_SHIFT_F7 = 90
333
217
 
334
- # Gets text mode video information.
335
- def gettextinfo()
336
- # Ruby Function gettextinfo()
337
- value = Libconio.ruby_gettextinfo()
218
+ # Costant Key Value
219
+ KEY_SHIFT_F8 = 91
338
220
 
339
- # Return value
340
- return value
341
- end
221
+ # Costant Key Value
222
+ KEY_SHIFT_F9 = 92
342
223
 
343
- # Moves the cursor to the given position in the current text window.
344
- def gotoxy(x, y)
345
- # Ruby Function gotoxy()
346
- Libconio.ruby_gotoxy(x, y)
347
-
348
- # Return nil
349
- return nil
350
- end
224
+ # Costant Key Value
225
+ KEY_SHIFT_F10 = 93
351
226
 
352
- # Inserts an empty line in the text window at the cursor position using the current text background color.
353
- def insline()
354
- # Ruby Function insline()
355
- Libconio.ruby_insline()
356
-
357
- # Return nil
358
- return nil
359
- end
227
+ # Costant Key Value
228
+ KEY_SHIFT_F11 = 135
360
229
 
361
- # Checks to see if a keystroke is currently available.
362
- def kbhit()
363
- # Ruby Function kbhit()
364
- value = Libconio.ruby_kbhit()
365
-
366
- # Return value
367
- return value
368
- end
230
+ # Costant Key Value
231
+ KEY_SHIFT_F12 = 136
369
232
 
370
- # Copies the contents of the onscreen rectangle defined by left, top, right, and bottom to a new rectangle of the same dimensions.
371
- def movetext(left, top, right, bottom, newleft, newtop)
372
- # Ruby Function movetext()
373
- Libconio.ruby_movetext(left, top, right, bottom, newleft, newtop)
374
-
375
- # Return nil
376
- return nil
377
- end
233
+ # Costant Key Value
234
+ KEY_CTRL_F1 = 94
378
235
 
379
- # Put the contents with attributes of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
380
- def put(left, top, right, bottom, buffer)
381
- # Ruby Function put()
382
- Libconio.ruby_put(left, top, right, bottom, buffer)
383
-
384
- # Return nil
385
- return nil
386
- end
236
+ # Costant Key Value
237
+ KEY_CTRL_F2 = 95
387
238
 
388
- # Put the attributes of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
389
- def putattrs(left, top, right, bottom, buffer)
390
- # Ruby Function putattrs()
391
- Libconio.ruby_putattrs(left, top, right, bottom, buffer)
392
-
393
- # Return nil
394
- return nil
395
- end
239
+ # Costant Key Value
240
+ KEY_CTRL_F3 = 96
396
241
 
397
- # Outputs the character to the current text window. It is a text-mode function that performs direct video output to the console.
398
- def putch(character)
399
- # Ruby Function putch()
400
- value = Libconio.ruby_putch(character)
401
-
402
- # Return value
403
- return value
404
- end
242
+ # Costant Key Value
243
+ KEY_CTRL_F4 = 97
405
244
 
406
- # Put the contents of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
407
- def putchars(left, top, right, bottom, buffer)
408
- # Ruby Function putchars()
409
- Libconio.ruby_putchars(left, top, right, bottom, buffer)
410
-
411
- # Return nil
412
- return nil
413
- end
245
+ # Costant Key Value
246
+ KEY_CTRL_F5 = 98
414
247
 
415
- # Put the text of the memory area source out to the onscreen rectangle defined by left, top, right and bottom.
416
- def puttext(left, top, right, bottom, buffer)
417
- # Ruby Function puttext()
418
- Libconio.ruby_puttext(left, top, right, bottom, buffer)
419
-
420
- # Return nil
421
- return nil
422
- end
248
+ # Costant Key Value
249
+ KEY_CTRL_F6 = 99
423
250
 
424
- # Resize buffer and window size.
425
- def resize(width, height)
426
- # Ruby Function resize()
427
- Libconio.ruby_resize(width, height)
428
-
429
- # Return nil
430
- return nil
431
- end
251
+ # Costant Key Value
252
+ KEY_CTRL_F7 = 100
432
253
 
433
- # The console window displays a portion of the active screen buffer.
434
- def scroll(left, top, right, bottom, newleft, newtop)
435
- # Ruby Function scroll()
436
- Libconio.ruby_scroll(left, top, right, bottom, newleft, newtop)
437
-
438
- # Return nil
439
- return nil
440
- end
254
+ # Costant Key Value
255
+ KEY_CTRL_F8 = 101
441
256
 
442
- # Scroll up the text in current window text.
443
- def scrollup(left, top, right, bottom)
444
- # Ruby Function scrollup()
445
- Libconio.ruby_scrollup(left, top, right, bottom)
446
-
447
- # Return nil
448
- return nil
449
- end
257
+ # Costant Key Value
258
+ KEY_CTRL_F9 = 102
450
259
 
451
- # Scroll down the text in current window text.
452
- def scrolldown(left, top, right, bottom)
453
- # Ruby Function scrolldown()
454
- Libconio.ruby_scrolldown(left, top, right, bottom)
455
-
456
- # Return nil
457
- return nil
458
- end
260
+ # Costant Key Value
261
+ KEY_CTRL_F10 = 103
459
262
 
460
- # Scroll left the text in current window text.
461
- def scrollleft(left, top, right, bottom)
462
- # Ruby Function scrollleft()
463
- Libconio.ruby_scrollleft(left, top, right, bottom)
464
-
465
- # Return nil
466
- return nil
467
- end
263
+ # Costant Key Value
264
+ KEY_CTRL_F11 = 137
468
265
 
469
- # Scroll right the text in current window text.
470
- def scrollright(left, top, right, bottom)
471
- # Ruby Function scrollright()
472
- Libconio.ruby_scrollright(left, top, right, bottom)
473
-
474
- # Return nil
475
- return nil
476
- end
266
+ # Costant Key Value
267
+ KEY_CTRL_F12 = 138
268
+
269
+ # Costant Key Value
270
+ KEY_ALT_F1 = 104
477
271
 
478
- # Define a window buffer size.
479
- def setbuffer(width, height)
480
- # Ruby Function setbuffer()
481
- Libconio.ruby_setbuffer(width, height)
482
-
483
- # Return nil
484
- return nil
485
- end
272
+ # Costant Key Value
273
+ KEY_ALT_F2 = 105
486
274
 
487
- # Sets the cursor type in range 0 (hide cursor) to 100 (solid block cursor).
488
- def setcursortype(cursor)
489
- # Ruby Function setcursortype()
490
- Libconio.ruby_setcursortype(cursor)
491
-
492
- # Return nil
493
- return nil
494
- end
275
+ # Costant Key Value
276
+ KEY_ALT_F3 = 106
495
277
 
496
- # Change the console window title.
497
- def settitle(title)
498
- # Ruby Function settitle()
499
- Libconio.ruby_settitle(title)
500
-
501
- # Return nil
502
- return nil
503
- end
278
+ # Costant Key Value
279
+ KEY_ALT_F4 = 107
504
280
 
505
- # Defines a text window onscreen. If the coordinates are in any way invalid, the call to window is ignored.
506
- def setwindow(left, top, right, bottom)
507
- # Ruby Function setwindow()
508
- Libconio.ruby_setwindow(left, top, right, bottom)
509
-
510
- # Return nil
511
- return nil
512
- end
281
+ # Costant Key Value
282
+ KEY_ALT_F5 = 108
513
283
 
514
- # The time interval for which execution is to be suspended, in seconds.
515
- def sleep(seconds)
516
- # Ruby Function sleep()
517
- Libconio.ruby_sleep(seconds)
518
-
519
- # Return nil
520
- return nil
521
- end
284
+ # Costant Key Value
285
+ KEY_ALT_F6 = 109
286
+
287
+ # Costant Key Value
288
+ KEY_ALT_F7 = 110
289
+
290
+ # Costant Key Value
291
+ KEY_ALT_F8 = 111
292
+
293
+ # Costant Key Value
294
+ KEY_ALT_F9 = 112
295
+
296
+ # Costant Key Value
297
+ KEY_ALT_F10 = 113
298
+
299
+ # Costant Key Value
300
+ KEY_ALT_F11 = 139
301
+
302
+ # Costant Key Value
303
+ KEY_ALT_F12 = 140
304
+
305
+ # Costant Key Value
306
+ KEY_INS = 82
307
+
308
+ # Costant Key Value
309
+ KEY_DEL = 83
310
+
311
+ # Costant Key Value
312
+ KEY_STAMP = 71
313
+
314
+ # Costant Key Value
315
+ KEY_END = 79
316
+
317
+ # Costant Key Value
318
+ KEY_UP = 72
319
+
320
+ # Costant Key Value
321
+ KEY_DOWN = 80
322
+
323
+ # Costant Key Value
324
+ KEY_LEFT = 75
522
325
 
523
- # Selects the background character color.
524
- def textbackground(color)
525
- # Ruby Function textbackground()
526
- Libconio.ruby_textbackground(color)
326
+ # Costant Key Value
327
+ KEY_RIGHT = 77
328
+
329
+ # Costant Key Value
330
+ KEY_PAGEUP = 73
331
+
332
+ # Costant Key Value
333
+ KEY_PAGDOWN = 81
334
+
335
+ # Costant Key Value
336
+ KEY_CTRL_INS = 146
337
+
338
+ # Costant Key Value
339
+ KEY_CTRL_DEL = 147
340
+
341
+ # Costant Key Value
342
+ KEY_CTRL_STAMP = 119
343
+
344
+ # Costant Key Value
345
+ KEY_CTRL_END = 117
346
+
347
+ # Costant Key Value
348
+ KEY_CTRL_UP = 141
349
+
350
+ # Costant Key Value
351
+ KEY_CTRL_DOWN = 145
352
+
353
+ # Costant Key Value
354
+ KEY_CTRL_LEFT = 115
355
+
356
+ # Costant Key Value
357
+ KEY_CTRL_RIGHT = 116
358
+
359
+ # Costant Key Value
360
+ KEY_CTRL_PAGEUP = 134
361
+
362
+ # Costant Key Value
363
+ KEY_CTRL_PAGDOWN = 118
364
+
365
+ # Costant Key Value
366
+ KEY_ALT_INS = 162
367
+
368
+ # Costant Key Value
369
+ KEY_ALT_DEL = 163
370
+
371
+ # Costant Key Value
372
+ KEY_ALT_STAMP = 151
373
+
374
+ # Costant Key Value
375
+ KEY_ALT_END = 159
376
+
377
+ # Costant Key Value
378
+ KEY_ALT_UP = 152
379
+
380
+ # Costant Key Value
381
+ KEY_ALT_DOWN = 160
382
+
383
+ # Costant Key Value
384
+ KEY_ALT_LEFT = 155
385
+
386
+ # Costant Key Value
387
+ KEY_ALT_RIGHT = 157
388
+
389
+ # Costant Key Value
390
+ KEY_ALT_PAGEUP = 153
391
+
392
+ # Costant Key Value
393
+ KEY_ALT_PAGDOWN = 161
394
+
395
+ # :call-seq:
396
+ # beep() -> nil
397
+ #
398
+ # Execute bells sound in time interval.
399
+ def self.beep(number, milliseconds)
400
+ # Variable service
401
+ index = 0
402
+
403
+ # Verify equal value of index and number
404
+ while index != number do
405
+ # Put character sound
406
+ putch(7)
407
+
408
+ # Put time interval
409
+ delay(milliseconds)
410
+
411
+ # Increment index value by one
412
+ index = index + 1
413
+ end
527
414
 
528
- # Return nil
415
+ # Return nil value
529
416
  return nil
530
417
  end
418
+
419
+ # :call-seq:
420
+ # cgets(length) -> string
421
+ #
422
+ # Reads a string of characters from the console and stores the
423
+ # string, and the string length, in the location string.
424
+ def self.cgets(length)
425
+ # Declare variable text
426
+ text = gets()
427
+
428
+ # Set text value
429
+ text = text[0, length]
430
+
431
+ # Return text value
432
+ return text
433
+ end
531
434
 
532
- # Selects the foreground character color.
533
- def textcolor(color)
534
- # Ruby Function textcolor()
535
- Libconio.ruby_textcolor(color)
536
-
537
- # Return nil
538
- return nil
435
+ # :call-seq:
436
+ # getkey() -> number
437
+ #
438
+ # Reads a double character directly from the keyboard for special key.
439
+ def self.getkey()
440
+ # Conio function getch()
441
+ character = getch()
442
+
443
+ # Verify key pressed
444
+ while character != 0 and character != 224
445
+ # Conio function getch()
446
+ character = getch()
447
+ end
448
+
449
+ # Conio function getch()
450
+ character = getch()
451
+
452
+ # Return value character
453
+ return character
539
454
  end
540
455
 
541
- # Pushes the character ch back to the console, causing ch to be the next character read.
542
- def ungetch(character)
543
- # Ruby Function ungetch()
544
- value = Libconio.ruby_ungetch(character)
456
+ # :call-seq:
457
+ # getlimit(length) -> string
458
+ #
459
+ # Puts a string of characters and limit the string length in the location string.
460
+ def self.getlimit(length)
461
+ # Declare and initalize variable text
462
+ text = ""
463
+
464
+ # Conio function getch()
465
+ character = getch()
466
+
467
+ # Verify character code
468
+ while character != 13 do
469
+ # Verify character code
470
+ while character == 0 or character == 224
471
+ # Conio function getch()
472
+ character = getch()
473
+ character = getch()
474
+ end
475
+
476
+ # Declare and initalize variable dimension
477
+ dimension = text.length
478
+
479
+ # Verify character code value and variable dimension
480
+ if character == 8 and dimension > 0 then
481
+ # Conio function putch()
482
+ putch(8)
483
+ putch(32)
484
+ putch(8)
485
+
486
+ # Set text value
487
+ text = text[0, dimension - 1]
488
+ elsif character == 13 then
489
+ # Exit from cicle while
490
+ break
491
+ # Verify character code value and variable dimension
492
+ elsif character != 8 and character != 9 and character != 27 and dimension < length then
493
+ # Enable only characters alphanumeric
494
+ if character > 47 and character < 58 or character > 64 and character < 91 or character > 96 and character < 123 or character == 32 then
495
+ # Conio function putch()
496
+ putch(character)
497
+
498
+ # Set format for character code
499
+ character = character.chr
500
+
501
+ # Set variable texe
502
+ text = text + character
503
+ end
504
+ else
505
+ # Nil
506
+ end
507
+
508
+ # Conio function getch()
509
+ character = getch()
510
+ end
545
511
 
546
- # Return value
547
- return value
512
+ # Return text value
513
+ return text
548
514
  end
549
515
 
550
- # Returns the X coordinate of the current cursor position (within the current text window).
551
- def wherex()
552
- # Ruby Function wherex()
553
- value = Libconio.ruby_wherex()
516
+ # :call-seq:
517
+ # version() -> nil
518
+ #
519
+ # Puts the current version of Ruby Conio in text window.
520
+ def self.version()
521
+ # Put Ruby Conio version
522
+ cputs("Ruby Conio 1.1.0")
554
523
 
555
- # Return value
556
- return value
524
+ # Return nil value
525
+ return nil
557
526
  end
558
527
 
559
- # Copies the value of x coordinate and y coordinate of the cursor location to the variables whose address is specified in the arguments column and row.
560
- def wherexy(x, y)
561
- # Ruby Function wherex()
562
- Libconio.ruby_wherexy(x, y)
528
+ # :call-seq:
529
+ # wherexy(x, y) -> boolean
530
+ #
531
+ # Verify if x and y are equals to current cursor position.
532
+ def self.wherexy(x, y)
533
+ # Declare and initialize variables cursorx and cursory
534
+ cursorx = wherex()
535
+ cursory = wherey()
563
536
 
564
- # Return nil
565
- return nil
537
+ # Verify cursor position
538
+ if x == cursorx and y == cursory then
539
+ # Return value true
540
+ return true
541
+ else
542
+ # Return value false
543
+ return false
544
+ end
566
545
  end
567
546
 
568
- # Returns the Y coordinate of the current cursor position (within the current text window).
569
- def wherey()
570
- # Ruby Function wherey()
571
- value = Libconio.ruby_wherey()
547
+ # :call-seq:
548
+ # write(text, x, y) -> string
549
+ #
550
+ # Writes the null-terminated string text to the current text window and positioning in the coordinates x and y.
551
+ def self.write(text, x, y)
552
+ # Set cursor position
553
+ gotoxy(x, y)
554
+
555
+ # Print text
556
+ cputs(text)
572
557
 
573
- # Return value
574
- return value
558
+ # Return text value
559
+ return text
575
560
  end
576
-
577
561
  end
578
562
 
563
+
579
564
  # End of file