Module: Conio

Defined in:
lib/conio.rb

Overview

Module Conio

Constant Summary collapse

COLOR_BLACK =

Costant Color Value

0
COLOR_BLUE =

Costant Color Value

1
COLOR_GREEN =

Costant Color Value

2
COLOR_CYAN =

Costant Color Value

3
COLOR_RED =

Costant Color Value

4
COLOR_MAGENTA =

Costant Color Value

5
COLOR_BROWN =

Costant Color Value

6
COLOR_LIGHTGRAY =

Costant Color Value

7
COLOR_DARKGRAY =

Costant Color Value

8
COLOR_LIGHTBLUE =

Costant Color Value

9
COLOR_LIGHTGREEN =

Costant Color Value

10
COLOR_LIGHTCYAN =

Costant Color Value

11
COLOR_LIGHTRED =

Costant Color Value

12
COLOR_LIGHTMAGENTA =

Costant Color Value

13
COLOR_YELLOW =

Costant Color Value

14
COLOR_WHITE =

Costant Color Value

15
INFO_ATTR =

Costant Info Value

0
INFO_CX =

Costant Info Value

1
INFO_CY =

Costant Info Value

2
INFO_TOP =

Costant Info Value

3
INFO_LEFT =

Costant Info Value

4
INFO_RIGHT =

Costant Info Value

5
INFO_BOTTOM =

Costant Info Value

6
INFO_WIDTH =

Costant Info Value

7
INFO_HEIGHT =

Costant Info Value

8
INFO_MAXWIDTH =

Costant Info Value

9
INFO_MAXHEIGHT =

Costant Info Value

10
INFO_TOTALWIDTH =

Costant Info Value

11
INFO_TOTALHEIGHT =

Costant Info Value

12
TEXTINFO_ATTRIBUTE =

Costant Text Info Value

0
TEXTINFO_NORMATTR =

Costant Text Info Value

1
TEXTINFO_CURRMODE =

Costant Text Info Value

2
TEXTINFO_CURX =

Costant Text Info Value

3
TEXTINFO_CURY =

Costant Text Info Value

4
TEXTINFO_SCREENWIDTH =

Costant Text Info Value

5
TEXTINFO_SCREENHEIGHT =

Costant Text Info Value

6
TEXTINFO_WINLEFT =

Costant Text Info Value

7
TEXTINFO_WINTOP =

Costant Text Info Value

8
TEXTINFO_WINRIGHT =

Costant Text Info Value

9
TEXTINFO_WINBOTTOM =

Costant Text Info Value

10
CURSOR_HIDE =

Costant Cursor Value

0
CURSOR_NORMAL =

Costant Cursor Value

25
CURSOR_SOLID =

Costant Cursor Value

100
KEY_F1 =

Costant Key Value

59
KEY_F2 =

Costant Key Value

60
KEY_F3 =

Costant Key Value

61
KEY_F4 =

Costant Key Value

62
KEY_F5 =

Costant Key Value

63
KEY_F6 =

Costant Key Value

64
KEY_F7 =

Costant Key Value

65
KEY_F8 =

Costant Key Value

66
KEY_F9 =

Costant Key Value

67
KEY_F10 =

Costant Key Value

68
KEY_F11 =

Costant Key Value

133
KEY_F12 =

Costant Key Value

134
KEY_SHIFT_F1 =

Costant Key Value

84
KEY_SHIFT_F2 =

Costant Key Value

85
KEY_SHIFT_F3 =

Costant Key Value

86
KEY_SHIFT_F4 =

Costant Key Value

87
KEY_SHIFT_F5 =

Costant Key Value

88
KEY_SHIFT_F6 =

Costant Key Value

89
KEY_SHIFT_F7 =

Costant Key Value

90
KEY_SHIFT_F8 =

Costant Key Value

91
KEY_SHIFT_F9 =

Costant Key Value

92
KEY_SHIFT_F10 =

Costant Key Value

93
KEY_SHIFT_F11 =

Costant Key Value

135
KEY_SHIFT_F12 =

Costant Key Value

136
KEY_CTRL_F1 =

Costant Key Value

94
KEY_CTRL_F2 =

Costant Key Value

95
KEY_CTRL_F3 =

Costant Key Value

96
KEY_CTRL_F4 =

Costant Key Value

97
KEY_CTRL_F5 =

Costant Key Value

98
KEY_CTRL_F6 =

Costant Key Value

99
KEY_CTRL_F7 =

Costant Key Value

100
KEY_CTRL_F8 =

Costant Key Value

101
KEY_CTRL_F9 =

Costant Key Value

102
KEY_CTRL_F10 =

Costant Key Value

103
KEY_CTRL_F11 =

Costant Key Value

137
KEY_CTRL_F12 =

Costant Key Value

138
KEY_ALT_F1 =

Costant Key Value

104
KEY_ALT_F2 =

Costant Key Value

105
KEY_ALT_F3 =

Costant Key Value

106
KEY_ALT_F4 =

Costant Key Value

107
KEY_ALT_F5 =

Costant Key Value

108
KEY_ALT_F6 =

Costant Key Value

109
KEY_ALT_F7 =

Costant Key Value

110
KEY_ALT_F8 =

Costant Key Value

111
KEY_ALT_F9 =

Costant Key Value

112
KEY_ALT_F10 =

Costant Key Value

113
KEY_ALT_F11 =

Costant Key Value

139
KEY_ALT_F12 =

Costant Key Value

140
KEY_INS =

Costant Key Value

82
KEY_DEL =

Costant Key Value

83
KEY_STAMP =

Costant Key Value

71
KEY_END =

Costant Key Value

79
KEY_UP =

Costant Key Value

72
KEY_DOWN =

Costant Key Value

80
KEY_LEFT =

Costant Key Value

75
KEY_RIGHT =

Costant Key Value

77
KEY_PAGEUP =

Costant Key Value

73
KEY_PAGDOWN =

Costant Key Value

81
KEY_CTRL_INS =

Costant Key Value

146
KEY_CTRL_DEL =

Costant Key Value

147
KEY_CTRL_STAMP =

Costant Key Value

119
KEY_CTRL_END =

Costant Key Value

117
KEY_CTRL_UP =

Costant Key Value

141
KEY_CTRL_DOWN =

Costant Key Value

145
KEY_CTRL_LEFT =

Costant Key Value

115
KEY_CTRL_RIGHT =

Costant Key Value

116
KEY_CTRL_PAGEUP =

Costant Key Value

134
KEY_CTRL_PAGDOWN =

Costant Key Value

118
KEY_ALT_INS =

Costant Key Value

162
KEY_ALT_DEL =

Costant Key Value

163
KEY_ALT_STAMP =

Costant Key Value

151
KEY_ALT_END =

Costant Key Value

159
KEY_ALT_UP =

Costant Key Value

152
KEY_ALT_DOWN =

Costant Key Value

160
KEY_ALT_LEFT =

Costant Key Value

155
KEY_ALT_RIGHT =

Costant Key Value

157
KEY_ALT_PAGEUP =

Costant Key Value

153
KEY_ALT_PAGDOWN =

Costant Key Value

161

Class Method Summary collapse

Class Method Details

.beep(number, milliseconds) ⇒ Object

:call-seq:

beep()  -> nil

Execute bells sound in time interval.



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/conio.rb', line 399

def self.beep(number, milliseconds)
  # Variable service
  index = 0
  
  # Verify equal value of index and number
  while index != number do
    # Put character sound
    putch(7)
      
    # Put time interval
    delay(milliseconds)
    
    # Increment index value by one
    index = index + 1
  end
  
  # Return nil value
  return nil
end

.cgets(length) ⇒ Object

:call-seq:

cgets(length)  -> string

Reads a string of characters from the console and stores the string, and the string length, in the location string.



424
425
426
427
428
429
430
431
432
433
# File 'lib/conio.rb', line 424

def self.cgets(length)
  # Declare variable text
  text = gets()

  # Set text value
  text = text[0, length]

  # Return text value
  return text
end

.getkeyObject

:call-seq:

getkey()  -> number

Reads a double character directly from the keyboard for special key.



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/conio.rb', line 439

def self.getkey()
  # Conio function getch()
  character = getch()

  # Verify key pressed
  while character != 0 and character != 224
    # Conio function getch()
    character = getch()
  end

  # Conio function getch()
  character = getch()

  # Return value character
  return character
end

.getlimit(length) ⇒ Object

:call-seq:

getlimit(length)  -> string

Puts a string of characters and limit the string length in the location string.



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/conio.rb', line 460

def self.getlimit(length)
  # Declare and initalize variable text
  text = ""
  
  # Conio function getch()
  character = getch()

  # Verify character code
  while character != 13 do
    # Verify character code
    while character == 0 or character == 224
      # Conio function getch()
      character = getch()
      character = getch()
    end
      
    # Declare and initalize variable dimension
    dimension = text.length
      
    # Verify character code value and variable dimension
    if character == 8 and dimension > 0 then
      # Conio function putch()
      putch(8)
      putch(32)
      putch(8)
          
      # Set text value
      text = text[0, dimension - 1]
    elsif character == 13 then
      # Exit from cicle while
      break 
    # Verify character code value and variable dimension
    elsif character != 8 and character != 9 and character != 27 and dimension < length then
      # Enable only characters alphanumeric
      if character > 47 and character < 58 or character > 64 and character < 91 or character > 96 and character < 123 or character == 32 then
        # Conio function putch()
        putch(character)
        
        # Set format for character code
        character = character.chr
          
        # Set variable texe
        text = text + character
      end  
    else
      # Nil 
    end
      
    # Conio function getch()
    character = getch()
  end
  
  # Return text value
  return text
end

.versionObject

:call-seq:

version()  -> nil

Puts the current version of Ruby Conio in text window.



520
521
522
523
524
525
526
# File 'lib/conio.rb', line 520

def self.version()
  # Put Ruby Conio version
  cputs("Ruby Conio 1.1.0")
  
  # Return nil value
  return nil
end

.wherexy(x, y) ⇒ Object

:call-seq:

wherexy(x, y)  -> boolean

Verify if x and y are equals to current cursor position.



532
533
534
535
536
537
538
539
540
541
542
543
544
545
# File 'lib/conio.rb', line 532

def self.wherexy(x, y)
  # Declare and initialize variables cursorx and cursory
  cursorx = wherex()
  cursory = wherey()
  
  # Verify cursor position
  if x == cursorx and y == cursory then
    # Return value true
    return true
  else
    # Return value false
    return false  
  end
end

.write(text, x, y) ⇒ Object

:call-seq:

write(text, x, y)  -> string

Writes the null-terminated string text to the current text window and positioning in the coordinates x and y.



551
552
553
554
555
556
557
558
559
560
# File 'lib/conio.rb', line 551

def self.write(text, x, y)
  # Set cursor position
  gotoxy(x, y)
  
  # Print text
  cputs(text)
  
  # Return text value
  return text
end