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.
- data/LICENSE +1 -1
- data/README +51 -33
- data/Rakefile +40 -40
- data/ext/libconio.c +1009 -0
- data/lib/conio.rb +392 -407
- data/lib/libconio.so +0 -0
- data/test/test.rb +31 -283
- metadata +10 -5
data/lib/libconio.so
CHANGED
Binary file
|
data/test/test.rb
CHANGED
@@ -1,298 +1,46 @@
|
|
1
|
-
|
2
|
-
require "conio"
|
3
|
-
|
4
|
-
include Conio
|
5
|
-
|
6
|
-
# Globals variables
|
7
|
-
$index = nil
|
8
|
-
$table = nil
|
1
|
+
#!/usr/bin/env ruby
|
9
2
|
|
10
|
-
|
11
|
-
# * main function *
|
12
|
-
# *****************
|
13
|
-
|
14
|
-
def main()
|
15
|
-
# Set console title
|
16
|
-
Conio.settitle("Ruby Conio 1.0")
|
17
|
-
|
18
|
-
# Set console size
|
19
|
-
Conio.resize(80, 30)
|
20
|
-
|
21
|
-
# Set cursor
|
22
|
-
Conio.setcursortype(HIDE)
|
23
|
-
|
24
|
-
# Call def display()
|
25
|
-
display()
|
26
|
-
end
|
27
|
-
|
28
|
-
# *********************
|
29
|
-
# * Program functions *
|
30
|
-
# *********************
|
31
|
-
|
32
|
-
def display()
|
33
|
-
# Print text console
|
34
|
-
write("Ruby Conio 1.0", 1, 0)
|
35
|
-
write("Author: Gabriele Secci", 57, 0)
|
36
|
-
write("COPYRIGHT \xb8 2010 RAGNETTO \xa9 Software - All Rights Reserved", 11, 29)
|
37
|
-
|
38
|
-
# Fill attribute of text console
|
39
|
-
Conio.fillattr(WHITE, RED, 80, 0, 0)
|
40
|
-
Conio.fillattr(WHITE, RED, 80, 0, 29)
|
41
|
-
|
42
|
-
# Set text and background color
|
43
|
-
Conio.textbackground(BLACK)
|
44
|
-
Conio.textcolor(RED)
|
45
|
-
|
46
|
-
# Print text console
|
47
|
-
write("\xda", 1, 1)
|
48
|
-
write("\xbf", 46, 1)
|
49
|
-
write("\xb3", 1, 2)
|
50
|
-
write("\xb3", 46, 2)
|
51
|
-
write("\xc0", 1, 3)
|
52
|
-
write("\xd9", 46, 3)
|
53
|
-
|
54
|
-
# Fill attribute of text console
|
55
|
-
Conio.fill(196, RED, BLACK, 44, 2, 1)
|
56
|
-
Conio.fill(196, RED, BLACK, 44, 2, 3)
|
57
|
-
|
58
|
-
# Print text console
|
59
|
-
write("\xda", 1, 4)
|
60
|
-
write("\xbf", 46, 4)
|
61
|
-
|
62
|
-
for i in 5 .. 24 do
|
63
|
-
write("\xb3", 1, i)
|
64
|
-
write("\xb3", 46, i)
|
65
|
-
end
|
66
|
-
|
67
|
-
write("\xc0", 1, 25)
|
68
|
-
write("\xd9", 46, 25)
|
69
|
-
|
70
|
-
# Fill attribute of text console
|
71
|
-
Conio.fill(196, RED, BLACK, 44, 2, 4)
|
72
|
-
Conio.fill(196, RED, BLACK, 44, 2, 25)
|
73
|
-
|
74
|
-
# Print text console
|
75
|
-
write("\xda", 48, 1)
|
76
|
-
write("\xbf", 78, 1)
|
77
|
-
write("\xb3", 48, 2)
|
78
|
-
write("\xb3", 78, 2)
|
79
|
-
write("\xc0", 48, 3)
|
80
|
-
write("\xd9", 78, 3)
|
81
|
-
write("\xda", 48, 4)
|
82
|
-
write("\xbf", 78, 4)
|
83
|
-
|
84
|
-
for i in 5 .. 27 do
|
85
|
-
write("\xb3", 48, i)
|
86
|
-
write("\xb3", 76, i)
|
87
|
-
write("\xb3", 78, i)
|
88
|
-
end
|
89
|
-
|
90
|
-
write("\xc0", 48, 28)
|
91
|
-
write("\xd9", 78, 28)
|
92
|
-
|
93
|
-
# Fill attribute of text console
|
94
|
-
Conio.fill(196, RED, BLACK, 29, 49, 1)
|
95
|
-
Conio.fill(196, RED, BLACK, 29, 49, 3)
|
96
|
-
Conio.fill(196, RED, BLACK, 29, 49, 4)
|
97
|
-
Conio.fill(196, RED, BLACK, 29, 49, 28)
|
98
|
-
|
99
|
-
# Print text console
|
100
|
-
write("\xc2", 76, 4)
|
101
|
-
write("\xc1", 76, 28)
|
102
|
-
write("\xda", 1, 26)
|
103
|
-
write("\xbf", 46, 26)
|
104
|
-
write("\xb3", 1, 27)
|
105
|
-
write("\xb3", 46, 27)
|
106
|
-
write("\xc0", 1, 28)
|
107
|
-
write("\xd9", 46, 28)
|
108
|
-
|
109
|
-
# Fill attribute of text console
|
110
|
-
Conio.fill(196, RED, BLACK, 44, 2, 26)
|
111
|
-
Conio.fill(196, RED, BLACK, 44, 2, 28)
|
3
|
+
require "conio"
|
112
4
|
|
113
|
-
|
114
|
-
|
115
|
-
Conio.textcolor(WHITE)
|
116
|
-
|
117
|
-
# Print text console
|
118
|
-
write("Conio 1.0 is wrapper for Turbo C conio", 5, 2)
|
119
|
-
write("FUNCTION", 60, 2)
|
120
|
-
write("Project: Ruby Conio", 3, 5)
|
121
|
-
write("Version: 1.0", 3, 6)
|
122
|
-
write("Language: Ruby 1.9", 3, 7)
|
123
|
-
write("License: GNU GPL", 3, 8)
|
124
|
-
write("", 3, 9)
|
125
|
-
write("Module: conio.rb", 3, 10)
|
126
|
-
write("Extension: libconio.so", 3, 11)
|
127
|
-
write("", 3, 12)
|
128
|
-
write("Author: Gabriele Secci", 3, 13)
|
129
|
-
write("Company: RAGNETTO Software", 3, 14)
|
130
|
-
write("E-Mail: ragnettosoftware@gmail.com", 3, 15)
|
131
|
-
write("Web: www.ragnetto.altervista.org", 3, 16)
|
132
|
-
write("", 3, 16)
|
133
|
-
write("ESC: Close \x18: Scroll Up \x19: Scroll Down", 3, 27)
|
134
|
-
|
135
|
-
# Call function functions()
|
136
|
-
functions()
|
137
|
-
end
|
5
|
+
# Set the console title
|
6
|
+
Conio.settitle("Ruby Conio 1.1.0 [test.rb]")
|
138
7
|
|
139
|
-
|
140
|
-
|
141
|
-
$table = Array.new()
|
142
|
-
|
143
|
-
# Populate new table with functions of library Conio
|
144
|
-
$table[0] = "cgets(len) "
|
145
|
-
$table[1] = "clreol() "
|
146
|
-
$table[2] = "clrscr() "
|
147
|
-
$table[3] = "cputs(txt) "
|
148
|
-
$table[4] = "crop() "
|
149
|
-
$table[5] = "delay(ms) "
|
150
|
-
$table[6] = "delline() "
|
151
|
-
$table[7] = "fill(ch, fc, bc, n, x, y) "
|
152
|
-
$table[8] = "fillattr(fc, bc, n, x, y) "
|
153
|
-
$table[9] = "fillchar(ch, n, x, y) "
|
154
|
-
$table[10] = "fillcr(ch, n, x, y) "
|
155
|
-
$table[11] = "get(l, t, r, b, buf) "
|
156
|
-
$table[12] = "getattrs(l, t, r, b, buf) "
|
157
|
-
$table[13] = "getch() "
|
158
|
-
$table[14] = "getchars(l, t, r, b, buf) "
|
159
|
-
$table[15] = "getche() "
|
160
|
-
$table[16] = "getinfo() "
|
161
|
-
$table[17] = "gettext(l, t, r, b, buf) "
|
162
|
-
$table[18] = "gettextinfo() "
|
163
|
-
$table[19] = "gotoxy(x, y) "
|
164
|
-
$table[20] = "insline() "
|
165
|
-
$table[21] = "kbhit() "
|
166
|
-
$table[22] = "movetext(l, t, r, b, l, t)"
|
167
|
-
$table[23] = "put(l, t, r, b, buf) "
|
168
|
-
$table[24] = "putattrs(l, t, r, b, buf) "
|
169
|
-
$table[25] = "putch(ch) "
|
170
|
-
$table[26] = "putchars(l, t, r, b, buf) "
|
171
|
-
$table[27] = "puttext(l, t, r, b, buf) "
|
172
|
-
$table[28] = "resize() "
|
173
|
-
$table[29] = "scroll(l, t, r, b, l, t) "
|
174
|
-
$table[30] = "scrollup(l, t, r, b) "
|
175
|
-
$table[31] = "scrolldown(l, t, r, b) "
|
176
|
-
$table[32] = "scrollleft(l, t, r, b) "
|
177
|
-
$table[33] = "scrollright(l, t, r, b) "
|
178
|
-
$table[34] = "setbuffer(w, h) "
|
179
|
-
$table[35] = "setcursortype(cur) "
|
180
|
-
$table[36] = "settitle(tl) "
|
181
|
-
$table[37] = "setwindow(l, t, r, b) "
|
182
|
-
$table[38] = "sleep(s) "
|
183
|
-
$table[39] = "textbackground(bc) "
|
184
|
-
$table[40] = "textcolor(fc "
|
185
|
-
$table[41] = "ungetch(ch) "
|
186
|
-
$table[42] = "wherex() "
|
187
|
-
$table[43] = "wherexy(x, y) "
|
188
|
-
$table[44] = "wherey() "
|
8
|
+
# Set the console window and buffer size
|
9
|
+
Conio.resize(80, 30)
|
189
10
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
# Call function putter()
|
194
|
-
putter()
|
11
|
+
# Hide cursor
|
12
|
+
Conio.setcursortype(Conio::CURSOR_HIDE)
|
195
13
|
|
196
|
-
|
14
|
+
# Put name module
|
15
|
+
Conio.write("Ruby Conio 1.1.0", 1, 0)
|
197
16
|
|
198
|
-
|
17
|
+
# Put name script
|
18
|
+
Conio.write("test.rb", 72, 0)
|
199
19
|
|
200
|
-
|
201
|
-
|
202
|
-
# Set global variable index equal to 0
|
203
|
-
$index = 0
|
204
|
-
elsif $index > 22 then
|
205
|
-
# Set global variable index equal to 22
|
206
|
-
$index = 22
|
207
|
-
else
|
208
|
-
# Get index
|
209
|
-
end
|
20
|
+
# Select cursor position
|
21
|
+
Conio.gotoxy(20, 29)
|
210
22
|
|
211
|
-
|
212
|
-
|
213
|
-
stop = 22
|
23
|
+
# Put copyright
|
24
|
+
print("Copyright \xa9 2010 RAGNETTO \xb8 Software")
|
214
25
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
write($table[i], 50, limit)
|
219
|
-
|
220
|
-
# Verify the position of the cursor
|
221
|
-
if wherey() - 5 == $index then
|
222
|
-
# Print text console
|
223
|
-
write("\xdb", 77, limit)
|
224
|
-
else
|
225
|
-
# Print text console
|
226
|
-
write("\xb0", 77, limit)
|
227
|
-
end
|
228
|
-
|
229
|
-
# Increment local varible limit
|
230
|
-
limit += 1
|
231
|
-
end
|
232
|
-
|
233
|
-
# Call function press()
|
234
|
-
press()
|
235
|
-
end
|
26
|
+
# Put text attribute
|
27
|
+
Conio.fillattr(Conio::COLOR_WHITE, Conio::COLOR_RED, 80, 0, 0)
|
28
|
+
Conio.fillattr(Conio::COLOR_WHITE, Conio::COLOR_RED, 80, 0, 29)
|
236
29
|
|
237
|
-
|
238
|
-
|
239
|
-
key = Conio.getch()
|
30
|
+
# Print message
|
31
|
+
Conio.write("Press F1 to exit...", 1, 3)
|
240
32
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
elsif key == 72 then
|
246
|
-
# Set local variable index decrement of 1
|
247
|
-
$index -=1
|
248
|
-
end
|
249
|
-
|
250
|
-
# Call function putter()
|
251
|
-
putter()
|
252
|
-
end
|
253
|
-
|
254
|
-
def exit(key)
|
255
|
-
# Verify parameter key value
|
256
|
-
if key == 27 then
|
257
|
-
# Quit program
|
258
|
-
Kernel.exit()
|
259
|
-
else
|
260
|
-
# Call function press()
|
261
|
-
press()
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
# *********************
|
266
|
-
# * Service functions *
|
267
|
-
# *********************
|
268
|
-
|
269
|
-
def write(text, x, y)
|
270
|
-
# Set cursor position
|
271
|
-
Conio.gotoxy(x, y)
|
272
|
-
|
273
|
-
# Write string text
|
274
|
-
print(text)
|
33
|
+
# Stop program while users press F1...
|
34
|
+
while Conio.getkey() != Conio::KEY_F1
|
35
|
+
# nil
|
36
|
+
Conio.getkey()
|
275
37
|
end
|
276
38
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
# Verify local variable key value equal to 224
|
282
|
-
while key != 224
|
283
|
-
# Call function exit()
|
284
|
-
exit(key)
|
285
|
-
|
286
|
-
# Exit cicle while
|
287
|
-
break
|
288
|
-
end
|
39
|
+
# Count exit time
|
40
|
+
for index in (1..4) do
|
41
|
+
# Print message
|
42
|
+
Conio.write("Program exit in 4 seconds: #{index}", 1, 27)
|
289
43
|
|
290
|
-
#
|
291
|
-
|
44
|
+
# Exit before 4 seconds
|
45
|
+
Conio.sleep(1)
|
292
46
|
end
|
293
|
-
|
294
|
-
# **********************
|
295
|
-
# * Call main function *
|
296
|
-
# **********************
|
297
|
-
|
298
|
-
main()
|
metadata
CHANGED
@@ -4,8 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
version:
|
9
|
+
version: 1.1.0
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Gabriele Secci
|
@@ -13,11 +14,11 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-
|
17
|
+
date: 2010-11-23 00:00:00 +01:00
|
17
18
|
default_executable:
|
18
19
|
dependencies: []
|
19
20
|
|
20
|
-
description:
|
21
|
+
description: Ruby Conio is a wrapper for Turbo C conio.
|
21
22
|
email: ragnettosoftware@gmail.com
|
22
23
|
executables: []
|
23
24
|
|
@@ -26,10 +27,12 @@ extensions: []
|
|
26
27
|
extra_rdoc_files:
|
27
28
|
- README
|
28
29
|
- LICENSE
|
30
|
+
- ext/libconio.c
|
29
31
|
files:
|
30
32
|
- LICENSE
|
31
33
|
- README
|
32
34
|
- Rakefile
|
35
|
+
- ext/libconio.c
|
33
36
|
- lib/conio.rb
|
34
37
|
- lib/libconio.so
|
35
38
|
- test/test.rb
|
@@ -43,6 +46,7 @@ rdoc_options: []
|
|
43
46
|
require_paths:
|
44
47
|
- lib
|
45
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
46
50
|
requirements:
|
47
51
|
- - ">="
|
48
52
|
- !ruby/object:Gem::Version
|
@@ -50,6 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
54
|
- 0
|
51
55
|
version: "0"
|
52
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
53
58
|
requirements:
|
54
59
|
- - ">="
|
55
60
|
- !ruby/object:Gem::Version
|
@@ -59,9 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
64
|
requirements: []
|
60
65
|
|
61
66
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.3.
|
67
|
+
rubygems_version: 1.3.7
|
63
68
|
signing_key:
|
64
69
|
specification_version: 3
|
65
|
-
summary: Ruby Conio
|
70
|
+
summary: Ruby Conio is a wrapper for Turbo C conio.
|
66
71
|
test_files: []
|
67
72
|
|