livecursor 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/livecursor +213 -0
- data/lib/livecurses.rb +399 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8bff88c0b729f1d8eca9a9fed53a4f62d539fe3dc731e7657c08b559083e8cf8
|
4
|
+
data.tar.gz: 4090e9ef100fd48b20b0e91a7a14acde99cd4f7f0101a80ce2f335168427bdf0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f57a2435bf6ea587570d4b63377ce56f2b3b6dd97633edcfd62358d5b48ff9853e4d85cf0b3f4a4edf42a34702602609f701d4505d7a8e2c9a9d0f31f3d34bc8
|
7
|
+
data.tar.gz: bfb887dd122ec2f7fe50bb12a0ad2ce938d01da00c503a5c96c982461fd8a53f3dd5322e6e08d44c16e1358e975e0b15de0849d0dcad3c951e715c7827ddebb9
|
data/bin/livecursor
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'curses'
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
require 'livecurses'
|
7
|
+
include Curses
|
8
|
+
|
9
|
+
a = ARGV
|
10
|
+
sketch = 'nil'
|
11
|
+
biblioteca = 'nil'
|
12
|
+
|
13
|
+
def validar_f arg
|
14
|
+
if !arg.include?("/") and arg[-3..-1] == ".rb"
|
15
|
+
p_actual = Dir.pwd
|
16
|
+
if File.exist?(File.join(p_actual, arg))
|
17
|
+
r_sketch = File.join(p_actual, arg)
|
18
|
+
else
|
19
|
+
r_sketch = 'nil'
|
20
|
+
end
|
21
|
+
elsif arg.include?("/") and arg[-3..-1] == ".rb"
|
22
|
+
if File.exist?(arg)
|
23
|
+
r_sketch = arg
|
24
|
+
elsif arg[0] == "~"
|
25
|
+
r = arg.sub("~",Dir.home)
|
26
|
+
if File.exist?(r)
|
27
|
+
r_sketch = r
|
28
|
+
else
|
29
|
+
r_sketch = 'El archivo del sketch no existe'
|
30
|
+
abort(r_sketch)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
r_sketch = 'nil'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
return r_sketch
|
37
|
+
end
|
38
|
+
|
39
|
+
def validar_d arg
|
40
|
+
if !arg.include?("/")
|
41
|
+
p_actual = Dir.pwd
|
42
|
+
if Dir.exist?(File.join(p_actual, arg))
|
43
|
+
r_biblioteca = File.join(p_actual, arg)
|
44
|
+
else
|
45
|
+
r_biblioteca = 'nil'
|
46
|
+
end
|
47
|
+
elsif arg.include?("/")
|
48
|
+
if Dir.exist?(arg)
|
49
|
+
r_biblioteca = arg
|
50
|
+
elsif arg[0] == "~"
|
51
|
+
r = arg.sub("~",Dir.home)
|
52
|
+
if Dir.exist?(r)
|
53
|
+
r_biblioteca = r
|
54
|
+
else
|
55
|
+
r_biblioteca = 'La carpeta biblioteca no existe'
|
56
|
+
abort(r_biblioteca)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
r_biblioteca = 'nil'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
return r_biblioteca
|
63
|
+
end
|
64
|
+
|
65
|
+
case a.length
|
66
|
+
when 2
|
67
|
+
sketch = validar_f(a[0])
|
68
|
+
biblioteca = validar_d(a[1])
|
69
|
+
when 1
|
70
|
+
c = File.join(Dir.home, 'livecursor/config.yml')
|
71
|
+
if File.exist?(c)
|
72
|
+
c = YAML.load_file(c)
|
73
|
+
puts c['library_path']
|
74
|
+
sketch = validar_f(a[0])
|
75
|
+
biblioteca = validar_d(c['library_path'])
|
76
|
+
else
|
77
|
+
puts 'no tienes el archivo config.yml'
|
78
|
+
end
|
79
|
+
else
|
80
|
+
c = File.join(Dir.home, 'livecursor/config.yml')
|
81
|
+
if File.exist?(c)
|
82
|
+
c = YAML.load_file(c)
|
83
|
+
sketch = validar_f(c['sketch_path'])
|
84
|
+
biblioteca = validar_d(c['library_path'])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
puts "sketch:#{sketch} y biblioteca:#{biblioteca}"
|
88
|
+
|
89
|
+
if sketch == 'nil'
|
90
|
+
abort("El archivo para el sketch no se puede encontrar")
|
91
|
+
end
|
92
|
+
if biblioteca == 'nil'
|
93
|
+
abort("La carpeta biblioteca no se puede encontrar")
|
94
|
+
end
|
95
|
+
|
96
|
+
# variables a usar
|
97
|
+
$t = 0
|
98
|
+
|
99
|
+
$contenido = {}
|
100
|
+
|
101
|
+
Dir.glob(biblioteca + "/*").each do |n|
|
102
|
+
if n.end_with?('.yml')
|
103
|
+
d = n.sub(biblioteca + "/", '').sub '.yml',''
|
104
|
+
$contenido[d] = YAML.load_file(n)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
init_screen
|
110
|
+
start_color
|
111
|
+
curs_set(0)
|
112
|
+
|
113
|
+
Curses.init_pair(0, Curses::COLOR_BLACK, Curses::COLOR_BLACK)
|
114
|
+
Curses.init_pair(1, Curses::COLOR_BLACK, Curses::COLOR_RED)
|
115
|
+
Curses.init_pair(2, Curses::COLOR_BLACK, Curses::COLOR_GREEN)
|
116
|
+
Curses.init_pair(3, Curses::COLOR_BLACK, Curses::COLOR_YELLOW)
|
117
|
+
Curses.init_pair(4, Curses::COLOR_BLACK, Curses::COLOR_BLUE)
|
118
|
+
Curses.init_pair(5, Curses::COLOR_BLACK, Curses::COLOR_MAGENTA)
|
119
|
+
Curses.init_pair(6, Curses::COLOR_BLACK, Curses::COLOR_CYAN)
|
120
|
+
Curses.init_pair(7, Curses::COLOR_BLACK, Curses::COLOR_WHITE)
|
121
|
+
|
122
|
+
Curses.init_pair(8, Curses::COLOR_RED, Curses::COLOR_BLACK)
|
123
|
+
Curses.init_pair(9, Curses::COLOR_RED, Curses::COLOR_RED)
|
124
|
+
Curses.init_pair(10, Curses::COLOR_RED, Curses::COLOR_GREEN)
|
125
|
+
Curses.init_pair(11, Curses::COLOR_RED, Curses::COLOR_YELLOW)
|
126
|
+
Curses.init_pair(12, Curses::COLOR_RED, Curses::COLOR_BLUE)
|
127
|
+
Curses.init_pair(13, Curses::COLOR_RED, Curses::COLOR_MAGENTA)
|
128
|
+
Curses.init_pair(14, Curses::COLOR_RED, Curses::COLOR_CYAN)
|
129
|
+
Curses.init_pair(15, Curses::COLOR_RED, Curses::COLOR_WHITE)
|
130
|
+
|
131
|
+
Curses.init_pair(16, Curses::COLOR_GREEN, Curses::COLOR_BLACK)
|
132
|
+
Curses.init_pair(17, Curses::COLOR_GREEN, Curses::COLOR_RED)
|
133
|
+
Curses.init_pair(18, Curses::COLOR_GREEN, Curses::COLOR_GREEN)
|
134
|
+
Curses.init_pair(19, Curses::COLOR_GREEN, Curses::COLOR_YELLOW)
|
135
|
+
Curses.init_pair(20, Curses::COLOR_GREEN, Curses::COLOR_BLUE)
|
136
|
+
Curses.init_pair(21, Curses::COLOR_GREEN, Curses::COLOR_MAGENTA)
|
137
|
+
Curses.init_pair(22, Curses::COLOR_GREEN, Curses::COLOR_CYAN)
|
138
|
+
Curses.init_pair(23, Curses::COLOR_GREEN, Curses::COLOR_WHITE)
|
139
|
+
|
140
|
+
Curses.init_pair(24, Curses::COLOR_YELLOW, Curses::COLOR_BLACK)
|
141
|
+
Curses.init_pair(25, Curses::COLOR_YELLOW, Curses::COLOR_RED)
|
142
|
+
Curses.init_pair(26, Curses::COLOR_YELLOW, Curses::COLOR_GREEN)
|
143
|
+
Curses.init_pair(27, Curses::COLOR_YELLOW, Curses::COLOR_YELLOW)
|
144
|
+
Curses.init_pair(28, Curses::COLOR_YELLOW, Curses::COLOR_BLUE)
|
145
|
+
Curses.init_pair(29, Curses::COLOR_YELLOW, Curses::COLOR_MAGENTA)
|
146
|
+
Curses.init_pair(30, Curses::COLOR_YELLOW, Curses::COLOR_CYAN)
|
147
|
+
Curses.init_pair(31, Curses::COLOR_YELLOW, Curses::COLOR_WHITE)
|
148
|
+
|
149
|
+
Curses.init_pair(32, Curses::COLOR_BLUE, Curses::COLOR_BLACK)
|
150
|
+
Curses.init_pair(33, Curses::COLOR_BLUE, Curses::COLOR_RED)
|
151
|
+
Curses.init_pair(34, Curses::COLOR_BLUE, Curses::COLOR_GREEN)
|
152
|
+
Curses.init_pair(35, Curses::COLOR_BLUE, Curses::COLOR_YELLOW)
|
153
|
+
Curses.init_pair(36, Curses::COLOR_BLUE, Curses::COLOR_BLUE)
|
154
|
+
Curses.init_pair(37, Curses::COLOR_BLUE, Curses::COLOR_MAGENTA)
|
155
|
+
Curses.init_pair(38, Curses::COLOR_BLUE, Curses::COLOR_CYAN)
|
156
|
+
Curses.init_pair(39, Curses::COLOR_BLUE, Curses::COLOR_WHITE)
|
157
|
+
|
158
|
+
Curses.init_pair(40, Curses::COLOR_MAGENTA, Curses::COLOR_BLACK)
|
159
|
+
Curses.init_pair(41, Curses::COLOR_MAGENTA, Curses::COLOR_RED)
|
160
|
+
Curses.init_pair(42, Curses::COLOR_MAGENTA, Curses::COLOR_GREEN)
|
161
|
+
Curses.init_pair(43, Curses::COLOR_MAGENTA, Curses::COLOR_YELLOW)
|
162
|
+
Curses.init_pair(44, Curses::COLOR_MAGENTA, Curses::COLOR_BLUE)
|
163
|
+
Curses.init_pair(45, Curses::COLOR_MAGENTA, Curses::COLOR_MAGENTA)
|
164
|
+
Curses.init_pair(46, Curses::COLOR_MAGENTA, Curses::COLOR_CYAN)
|
165
|
+
Curses.init_pair(47, Curses::COLOR_MAGENTA, Curses::COLOR_WHITE)
|
166
|
+
|
167
|
+
Curses.init_pair(48, Curses::COLOR_CYAN, Curses::COLOR_BLACK)
|
168
|
+
Curses.init_pair(49, Curses::COLOR_CYAN, Curses::COLOR_RED)
|
169
|
+
Curses.init_pair(50, Curses::COLOR_CYAN, Curses::COLOR_GREEN)
|
170
|
+
Curses.init_pair(51, Curses::COLOR_CYAN, Curses::COLOR_YELLOW)
|
171
|
+
Curses.init_pair(52, Curses::COLOR_CYAN, Curses::COLOR_BLUE)
|
172
|
+
Curses.init_pair(53, Curses::COLOR_CYAN, Curses::COLOR_MAGENTA)
|
173
|
+
Curses.init_pair(54, Curses::COLOR_CYAN, Curses::COLOR_CYAN)
|
174
|
+
Curses.init_pair(55, Curses::COLOR_CYAN, Curses::COLOR_WHITE)
|
175
|
+
|
176
|
+
Curses.init_pair(56, Curses::COLOR_WHITE, Curses::COLOR_BLACK)
|
177
|
+
Curses.init_pair(57, Curses::COLOR_WHITE, Curses::COLOR_RED)
|
178
|
+
Curses.init_pair(58, Curses::COLOR_WHITE, Curses::COLOR_GREEN)
|
179
|
+
Curses.init_pair(59, Curses::COLOR_WHITE, Curses::COLOR_YELLOW)
|
180
|
+
Curses.init_pair(60, Curses::COLOR_WHITE, Curses::COLOR_BLUE)
|
181
|
+
Curses.init_pair(61, Curses::COLOR_WHITE, Curses::COLOR_MAGENTA)
|
182
|
+
Curses.init_pair(62, Curses::COLOR_WHITE, Curses::COLOR_CYAN)
|
183
|
+
Curses.init_pair(63, Curses::COLOR_WHITE, Curses::COLOR_WHITE)
|
184
|
+
Curses.crmode
|
185
|
+
|
186
|
+
begin
|
187
|
+
cont = 'nil'
|
188
|
+
contbk = 'nil'
|
189
|
+
loop do
|
190
|
+
v1 = Ventana.new(1,1, 0,0)
|
191
|
+
v2 = Ventana.new(1,1,0,0)
|
192
|
+
v3 = Ventana.new(1,1,0,0)
|
193
|
+
v4 = Ventana.new(1,1,0,0)
|
194
|
+
[v1,v2,v3,v4].each do |v|
|
195
|
+
v.refresh
|
196
|
+
end
|
197
|
+
|
198
|
+
cont = File.read(sketch)
|
199
|
+
begin
|
200
|
+
eval(cont)
|
201
|
+
contbk = cont
|
202
|
+
rescue
|
203
|
+
eval(contbk)
|
204
|
+
end
|
205
|
+
$t += 1
|
206
|
+
end
|
207
|
+
rescue
|
208
|
+
[v1,v2,v3,v4].each do |v|
|
209
|
+
v.close
|
210
|
+
end
|
211
|
+
close_screen
|
212
|
+
end
|
213
|
+
|
data/lib/livecurses.rb
ADDED
@@ -0,0 +1,399 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'curses'
|
3
|
+
include Curses
|
4
|
+
|
5
|
+
class Ventana < Window
|
6
|
+
|
7
|
+
# Define la forma de usar los colores
|
8
|
+
def pintar arg = 'nil'
|
9
|
+
abreviacion = {
|
10
|
+
'nn' => 0, 'rn' => 1, 'vn' => 2, 'an' => 3, 'zn' => 4, 'mn' => 5, 'cn' => 6, 'bn' => 7,
|
11
|
+
'nr' => 8, 'rr' => 9, 'vr' => 10, 'ar' => 11, 'zr' => 12, 'mr' => 13, 'cr' => 14, 'br' => 15,
|
12
|
+
'nv' => 16, 'rv' => 17, 'vv' => 18, 'av' => 19, 'zv' => 20, 'mv' => 21, 'cv' => 22, 'bv' => 23,
|
13
|
+
'na' => 24, 'ra' => 25, 'va' => 26, 'aa' => 27, 'za' => 28, 'ma' => 29, 'ca' => 30, 'ba' => 31,
|
14
|
+
'nz' => 32, 'rz' => 33, 'vz' => 34, 'az' => 35, 'zz' => 36, 'mz' => 37, 'cz' => 38, 'bz' => 39,
|
15
|
+
'nm' => 40, 'rm' => 41, 'vm' => 42, 'am' => 43, 'zm' => 44, 'mm' => 45, 'cm' => 46, 'bm' => 47,
|
16
|
+
'nc' => 48, 'rc' => 49, 'vc' => 50, 'ac' => 51, 'zc' => 52, 'mc' => 53, 'cc' => 54, 'bc' => 55,
|
17
|
+
'nb' => 56, 'rb' => 57, 'vb' => 58, 'ab' => 59, 'zb' => 60, 'mb' => 61, 'cb' => 62, 'bb' => 63
|
18
|
+
}
|
19
|
+
cordenadas = {
|
20
|
+
0.0 => 0, 1.0 => 1, 2.0 => 2, 3.0 => 3, 4.0 => 4, 5.0 => 5, 6.0 => 6, 7.0 => 7,
|
21
|
+
0.1 => 8, 1.1 => 9, 2.1 => 10, 3.1 => 11, 4.1 => 12, 5.1 => 13, 6.1 => 14, 7.1 => 15,
|
22
|
+
0.2 => 16, 1.2 => 17, 2.2 => 18, 3.2 => 19, 4.2 => 20, 5.2 => 21, 6.2 => 22, 7.2 => 23,
|
23
|
+
0.3 => 24, 1.3 => 25, 2.3 => 26, 3.3 => 27, 4.3 => 28, 5.3 => 29, 6.3 => 30, 7.3 => 31,
|
24
|
+
0.4 => 32, 1.4 => 33, 2.4 => 34, 3.4 => 35, 4.4 => 36, 5.4 => 37, 6.4 => 38, 7.4 => 39,
|
25
|
+
0.5 => 40, 1.5 => 41, 2.5 => 42, 3.5 => 43, 4.5 => 44, 5.5 => 45, 6.5 => 46, 7.5 => 47,
|
26
|
+
0.6 => 48, 1.6 => 49, 2.6 => 50, 3.6 => 51, 4.6 => 52, 5.6 => 53, 6.6 => 54, 7.6 => 55,
|
27
|
+
0.7 => 56, 1.7 => 57, 2.7 => 58, 3.7 => 59, 4.7 => 60, 5.7 => 61, 6.7 => 62, 7.7 => 63
|
28
|
+
}
|
29
|
+
|
30
|
+
if arg.kind_of? String and abreviacion.key?(arg)
|
31
|
+
arg = abreviacion[arg]
|
32
|
+
elsif arg.kind_of? Float and cordenadas.key?(arg)
|
33
|
+
fr = arg.round(1)
|
34
|
+
arg = cordenadas[fr]
|
35
|
+
elsif arg.kind_of? Integer and arg >= 0 and arg <= 63
|
36
|
+
arg = arg
|
37
|
+
else
|
38
|
+
arg = 0
|
39
|
+
end
|
40
|
+
self.attrset(color_pair(arg))
|
41
|
+
end
|
42
|
+
alias :ptr :pintar
|
43
|
+
|
44
|
+
# Define la posición de la ventana
|
45
|
+
def mover sy = 'nil', sx = 'nil', y: self.begy, x:self.begx
|
46
|
+
if sy != 'nil' and sx != 'nil' and sy.kind_of? Integer and sx.kind_of? Integer
|
47
|
+
self.move(sy,sx)
|
48
|
+
elsif y.kind_of? Integer and x.kind_of? Integer
|
49
|
+
self.move(y,x)
|
50
|
+
else
|
51
|
+
self.move(self.begy,self.begx)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
alias :mvr :mover
|
55
|
+
|
56
|
+
# Define el tamaño de la ventana
|
57
|
+
def redimensionar sy='nil', sx='nil', y:'nil', x:'nil'
|
58
|
+
if sy != 'nil' and sx != 'nil' and sy.kind_of? Integer and sx.kind_of? Integer
|
59
|
+
self.resize(sy,sx)
|
60
|
+
elsif y !='nil' or x !='nil'
|
61
|
+
if y.kind_of? Integer and x.kind_of? Integer
|
62
|
+
self.resize(y,x)
|
63
|
+
end
|
64
|
+
else
|
65
|
+
self.resize(Curses.lines,Curses.cols)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
alias :rdr :redimensionar
|
69
|
+
|
70
|
+
# Define la posición y el tamaño de la ventana
|
71
|
+
def colocar *a, c:'nil', v:'nil', h:'nil', m:'nil'
|
72
|
+
|
73
|
+
if a.length() >= 1
|
74
|
+
case a.length
|
75
|
+
when 0
|
76
|
+
self.mvr y:a[0],x:a[0]
|
77
|
+
self.rdr y:a[0], x:a[0]
|
78
|
+
when 1
|
79
|
+
self.mvr y:a[0],x:a[0]
|
80
|
+
self.rdr y:a[1], x:a[1]
|
81
|
+
when 2
|
82
|
+
self.mvr y:a[0],x:a[1]
|
83
|
+
self.rdr y:a[2], x:a[2]
|
84
|
+
when 3
|
85
|
+
self.mvr y:a[0],x:a[1]
|
86
|
+
self.rdr y:a[2], x:a[3]
|
87
|
+
end
|
88
|
+
elsif (0..3).include?(c)
|
89
|
+
case c
|
90
|
+
when 0
|
91
|
+
self.mvr y:0,x:0
|
92
|
+
self.rdr y:lines / 2, x:cols / 2
|
93
|
+
when 1
|
94
|
+
self.mvr y:0, x:cols / 2
|
95
|
+
self.rdr y:lines / 2, x:cols / 2
|
96
|
+
when 2
|
97
|
+
self.mvr y:lines / 2, x:cols / 2
|
98
|
+
self.rdr y:lines / 2, x:cols / 2
|
99
|
+
when 3
|
100
|
+
self.mvr y:lines / 2, x:0
|
101
|
+
self.rdr y:lines / 2, x:cols / 2
|
102
|
+
end
|
103
|
+
elsif (0..3).include?(v)
|
104
|
+
case v
|
105
|
+
when 0
|
106
|
+
self.mvr y:0,x:0
|
107
|
+
self.rdr y:lines, x:cols / 4
|
108
|
+
when 1
|
109
|
+
self.mvr y:0, x:cols / 4
|
110
|
+
self.rdr y:lines, x:cols / 4
|
111
|
+
when 2
|
112
|
+
self.mvr y:0, x:cols / 2
|
113
|
+
self.rdr y:lines, x:cols / 4
|
114
|
+
when 3
|
115
|
+
self.mvr y:0, x:3*cols / 4
|
116
|
+
self.rdr y:lines, x:cols / 4
|
117
|
+
end
|
118
|
+
elsif (0..3).include?(h)
|
119
|
+
case h
|
120
|
+
when 0
|
121
|
+
self.mvr y:0,x:0
|
122
|
+
self.rdr y:lines / 4, x:cols
|
123
|
+
when 1
|
124
|
+
self.mvr y:lines / 4, x:0
|
125
|
+
self.rdr y:lines / 4, x:cols
|
126
|
+
when 2
|
127
|
+
self.mvr y:lines / 2, x:0
|
128
|
+
self.rdr y:lines / 4, x:cols
|
129
|
+
when 3
|
130
|
+
self.mvr y:3*lines / 4, x:0
|
131
|
+
self.rdr y:lines / 4, x:cols
|
132
|
+
end
|
133
|
+
elsif (0..3).include?(m)
|
134
|
+
case m
|
135
|
+
when 0
|
136
|
+
self.mvr y:0,x:0
|
137
|
+
self.rdr y:lines / 2, x:cols
|
138
|
+
when 1
|
139
|
+
self.mvr y:0, x:0
|
140
|
+
self.rdr y:lines, x:cols / 2
|
141
|
+
when 2
|
142
|
+
self.mvr y:lines / 2, x:0
|
143
|
+
self.rdr y:lines / 2, x:cols
|
144
|
+
when 3
|
145
|
+
self.mvr y:0, x: cols / 2
|
146
|
+
self.rdr y:lines, x:cols / 2
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
alias :clr :colocar
|
152
|
+
|
153
|
+
# Define los bordes de la ventana
|
154
|
+
def bordes *a, y:"nil", x:"nil"
|
155
|
+
if y != "nil" and x != "nil"
|
156
|
+
y = y.to_s
|
157
|
+
x = x.to_s
|
158
|
+
elsif a.length() >= 1
|
159
|
+
if a.length() == 1
|
160
|
+
y = a[0].to_s
|
161
|
+
x = a[0].to_s
|
162
|
+
elsif a.length() == 2
|
163
|
+
y = a[0].to_s
|
164
|
+
x = a[1].to_s
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
self.box(x, y)
|
169
|
+
end
|
170
|
+
alias :bds :bordes
|
171
|
+
|
172
|
+
# Define la posición del cursor
|
173
|
+
def cursor_posicion *a, y:'nil', x:'nil'
|
174
|
+
if y != "nil" or x != "nil"
|
175
|
+
y = y.to_i
|
176
|
+
x = x.to_i
|
177
|
+
elsif a.length() >= 1
|
178
|
+
if a.length() == 1
|
179
|
+
y = a[0].to_i
|
180
|
+
x = a[0].to_i
|
181
|
+
elsif a.length() == 2
|
182
|
+
y = a[0].to_i
|
183
|
+
x = a[1].to_i
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
self.setpos(y, x)
|
188
|
+
end
|
189
|
+
alias :cps :cursor_posicion
|
190
|
+
|
191
|
+
# Asigna un caracter
|
192
|
+
def texto arg="·"
|
193
|
+
self.addstr(arg.to_s)
|
194
|
+
end
|
195
|
+
alias :txt :texto
|
196
|
+
|
197
|
+
|
198
|
+
def punto *a, y:'nil', x:'nil', cps:[], ptr:'nil', txt:'nil'
|
199
|
+
if a.length() >= 1
|
200
|
+
if a.length() == 1
|
201
|
+
self.cps(a[0])
|
202
|
+
self.ptr()
|
203
|
+
self.txt(' ')
|
204
|
+
elsif a.length() == 2
|
205
|
+
self.cps(a[0],a[1])
|
206
|
+
self.ptr()
|
207
|
+
self.txt(' ')
|
208
|
+
elsif a.length() == 3
|
209
|
+
self.cps(a[0],a[1])
|
210
|
+
self.ptr(a[2])
|
211
|
+
self.txt(' ')
|
212
|
+
elsif a.length() == 4
|
213
|
+
self.cps(a[0],a[1])
|
214
|
+
self.ptr(a[2])
|
215
|
+
self.txt(a[3])
|
216
|
+
end
|
217
|
+
else
|
218
|
+
if y != 'nil' and x == 'nil'
|
219
|
+
self.cps(y)
|
220
|
+
elsif y != 'nil' and x != 'nil'
|
221
|
+
self.cps(y,x)
|
222
|
+
elsif cps.length() == 1
|
223
|
+
self.cps(cps[0])
|
224
|
+
elsif cps.length() == 2
|
225
|
+
self.cps(cps[0], cps[1])
|
226
|
+
else
|
227
|
+
self.cps()
|
228
|
+
end
|
229
|
+
if ptr != 'nil'
|
230
|
+
self.ptr(ptr)
|
231
|
+
else
|
232
|
+
self.ptr()
|
233
|
+
end
|
234
|
+
if txt != 'nil'
|
235
|
+
self.txt(txt)
|
236
|
+
else
|
237
|
+
self.txt(' ')
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
alias :pt :punto
|
243
|
+
|
244
|
+
# Define fondo de la ventana
|
245
|
+
def fondo *a, ptr:'nil', txt:'nil'
|
246
|
+
if a.length() >= 1
|
247
|
+
case a.length()
|
248
|
+
when 1
|
249
|
+
color = a[0]
|
250
|
+
caracter = ' '
|
251
|
+
when 2
|
252
|
+
color = a[0]
|
253
|
+
caracter = a[1]
|
254
|
+
end
|
255
|
+
elsif ptr != 'nil' or txt != 'nil'
|
256
|
+
if ptr != 'nil' or txt != 'nil'
|
257
|
+
color = ptr
|
258
|
+
caracter = txt
|
259
|
+
elsif ptr != 'nil' or txt == 'nil'
|
260
|
+
color = ptr
|
261
|
+
caracter = ' '
|
262
|
+
elsif ptr == 'nil' or txt != 'nil'
|
263
|
+
color ='nil'
|
264
|
+
caracter = txt
|
265
|
+
end
|
266
|
+
else
|
267
|
+
end
|
268
|
+
(0..self.maxy).each do |y|
|
269
|
+
(0..self.maxx).each do |x|
|
270
|
+
self.pt y, x, color, caracter
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
alias :fn :fondo
|
275
|
+
|
276
|
+
# bytebeat para generar cosas abstractas
|
277
|
+
def bytebeat *a, d:'nil', r:64, i:1, txt:'nil', ec:'nil'
|
278
|
+
d1 = self.maxx
|
279
|
+
d2 = self.maxy
|
280
|
+
|
281
|
+
if d != 'nil'
|
282
|
+
case d
|
283
|
+
when 'horizontal', 'h'
|
284
|
+
d1 = self.maxy
|
285
|
+
d2 = self.maxx
|
286
|
+
when 'vertical', 'v'
|
287
|
+
d1 = self.maxx
|
288
|
+
d2 = self.maxy
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
if a.length() >= 1
|
293
|
+
if a.length() == 1
|
294
|
+
ec = a[0]
|
295
|
+
elsif a.length() == 2
|
296
|
+
ec = a[0]
|
297
|
+
txt = a[1]
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
c = 0
|
302
|
+
|
303
|
+
(0...d1).each do |x|
|
304
|
+
(0...d2).each do |y|
|
305
|
+
if ec != 'nil'
|
306
|
+
cc = eval(ec)
|
307
|
+
else
|
308
|
+
cc = c
|
309
|
+
end
|
310
|
+
|
311
|
+
if txt == 'nil'
|
312
|
+
etxt = ' '
|
313
|
+
elsif txt.length == 1
|
314
|
+
etxt = txt
|
315
|
+
else
|
316
|
+
etxt = (1 + (eval(txt)).abs).chr(Encoding::UTF_8)
|
317
|
+
end
|
318
|
+
|
319
|
+
if d == 'horizontal' or d == 'h'
|
320
|
+
self.pt x, y, cc, etxt
|
321
|
+
else
|
322
|
+
self.pt y, x, cc, etxt
|
323
|
+
end
|
324
|
+
|
325
|
+
if c < r
|
326
|
+
c += i
|
327
|
+
else
|
328
|
+
c = 0
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
alias :bb :bytebeat
|
334
|
+
|
335
|
+
# asciiart para generar cosas no abstractas
|
336
|
+
def asciiart *a, cps:[], n:'nil', t:'nil', c:'nil', txt:'nil'
|
337
|
+
if a.length() >= 3
|
338
|
+
if a.length() == 3
|
339
|
+
y = a[0].to_i
|
340
|
+
x = a[0].to_i
|
341
|
+
n = a[1]
|
342
|
+
t = $contenido[n]['t']
|
343
|
+
c = $contenido[n]['c']
|
344
|
+
txt = a[2]
|
345
|
+
elsif a.length() == 4
|
346
|
+
y = a[0].to_i
|
347
|
+
x = a[1].to_i
|
348
|
+
n = a[2]
|
349
|
+
t = $contenido[n]['t']
|
350
|
+
c = $contenido[n]['c']
|
351
|
+
txt = a[3]
|
352
|
+
end
|
353
|
+
else
|
354
|
+
case cps.length
|
355
|
+
when 1
|
356
|
+
y = cps[0]
|
357
|
+
x = cps[0]
|
358
|
+
when 2
|
359
|
+
y = cps[0]
|
360
|
+
x = cps[1]
|
361
|
+
end
|
362
|
+
if t == 'nil'
|
363
|
+
t = $contenido[n]['t']
|
364
|
+
end
|
365
|
+
if c == 'nil'
|
366
|
+
c = $contenido[n]['c']
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
case t
|
371
|
+
when 'fuente', 'f'
|
372
|
+
maxd = 0
|
373
|
+
txt.split('').each do |w|
|
374
|
+
l = $contenido[n]['e'][w].length
|
375
|
+
l.times do |i|
|
376
|
+
d = $contenido[n]['e'][w][i]
|
377
|
+
self.pt y + i, x, c, d
|
378
|
+
maxd = maxd.to_i < d.length ? d.length : maxd
|
379
|
+
end
|
380
|
+
x = x + maxd
|
381
|
+
maxd = 0
|
382
|
+
end
|
383
|
+
when 'dibujo', 'd'
|
384
|
+
case txt
|
385
|
+
when String
|
386
|
+
l = $contenido[n]['e'][txt].length
|
387
|
+
l.times do |i|
|
388
|
+
self.pt y + i, x, c, $contenido[n]['e'][txt][i]
|
389
|
+
end
|
390
|
+
when Array
|
391
|
+
l = $contenido[n]['e'][txt[$t%txt.length]].length
|
392
|
+
l.times do |i|
|
393
|
+
self.pt y + i, x, c, $contenido[n]['e'][txt[$t%txt.length]][i]
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
398
|
+
alias :aa :asciiart
|
399
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: livecursor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: curses
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
description: Gema para hacer livecoding en la terminal
|
28
|
+
email: carsrouhs@gmail.com
|
29
|
+
executables:
|
30
|
+
- livecursor
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/livecursor
|
35
|
+
- lib/livecurses.rb
|
36
|
+
homepage: https://gitlab.com/livecursor
|
37
|
+
licenses:
|
38
|
+
- GPL-3.0
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.6.0
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubygems_version: 3.2.3
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: lv-h
|
59
|
+
test_files: []
|