console_cmdr 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +1 -4
- data.tar.gz.sig +0 -0
- data/lib/console_cmdr.rb +71 -42
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 601ff0285d317389e4a6ef22cf4060d9b99806c7
|
4
|
+
data.tar.gz: 81935978bdadac036b615e3843c716a581955771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee069686795d2674297fa3da000bf446db8ac62aca177ccee92003965abfd7433dd44f2db6db5a050a2d8e2dc52d09dd22119a8e7eeb27e4bea24a45590b834c
|
7
|
+
data.tar.gz: b634103b3ae5507c27609e4e17b382e710d67ce105ea84d2647ef4036e7ec5ae64fd71845742ef0158a3204b0a1ced684b2f5976872a091c4c99b0641df763ee
|
checksums.yaml.gz.sig
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/console_cmdr.rb
CHANGED
@@ -9,7 +9,6 @@ require 'terminfo'
|
|
9
9
|
require 'io/console'
|
10
10
|
|
11
11
|
|
12
|
-
|
13
12
|
class ConsoleCmdr < Cmdr
|
14
13
|
|
15
14
|
def initialize(pxindex: nil)
|
@@ -177,45 +176,11 @@ class ConsoleCmdr < Cmdr
|
|
177
176
|
@keys = []
|
178
177
|
|
179
178
|
if key.to_i.to_s == key and @input_selection and @input_selection.any?
|
180
|
-
|
181
|
-
key = ''
|
182
|
-
return r
|
183
|
-
end
|
184
|
-
|
185
|
-
parent = @pxi.parent.title if @pxi.parent
|
186
|
-
|
187
|
-
a = @pxi.q?(@linebuffer+key)
|
188
|
-
|
189
|
-
if a then
|
190
|
-
unless @input_selection == a.map(&:title) then
|
191
|
-
@input_selection = a.map(&:title)
|
192
|
-
@selection = a.map.with_index do |x,i|
|
193
|
-
|
194
|
-
branch = x.records.any? ? :branch : nil
|
195
|
-
|
196
|
-
title = x.title
|
197
|
-
# is the target a web page?
|
198
|
-
title = title.green if x.target[0] == 'w'
|
199
|
-
title << '>' if branch
|
200
|
-
|
201
|
-
["%d.%s" % [i+1, title], branch, x.desc.yellow]
|
202
|
-
|
203
|
-
end
|
204
|
-
print ("\b" * @linebuffer.length) + @selection.map \
|
205
|
-
{|x| x.values_at(0,2).join ' '}.join(" | ") + "\n"
|
206
|
-
|
207
|
-
end
|
208
|
-
print ("\b" * @linebuffer.length)
|
179
|
+
key = select_item(key.to_i-1)
|
209
180
|
|
210
|
-
if (@linebuffer[/\s/] or a.length == 1) and key == ' ' then
|
211
|
-
|
212
|
-
@linebuffer.sub!(/\w+$/, @item_selected)
|
213
|
-
|
214
|
-
end
|
215
|
-
print @linebuffer + key
|
216
|
-
else
|
217
|
-
@input_selection = nil
|
218
181
|
end
|
182
|
+
|
183
|
+
query key if key
|
219
184
|
|
220
185
|
elsif key == :arrow_down or key == :arrow_right
|
221
186
|
|
@@ -293,8 +258,10 @@ class ConsoleCmdr < Cmdr
|
|
293
258
|
oldlinebuffer = @linebuffer
|
294
259
|
print ("\b" * oldlinebuffer.length)
|
295
260
|
|
261
|
+
type = @selection[-1][-1]
|
262
|
+
branch = @selection[i][1] == :branch
|
296
263
|
|
297
|
-
if
|
264
|
+
if branch or append_command or type == :message then
|
298
265
|
|
299
266
|
if @linebuffer[-1] != ' ' then
|
300
267
|
a = @linebuffer.split(/ /)
|
@@ -304,9 +271,12 @@ class ConsoleCmdr < Cmdr
|
|
304
271
|
|
305
272
|
linebuffer.prepend @linebuffer
|
306
273
|
execute_command = false
|
307
|
-
else
|
308
|
-
|
274
|
+
else
|
275
|
+
|
276
|
+
execute_command = true unless type == :interactive
|
309
277
|
end
|
278
|
+
|
279
|
+
execute_command = true if type == :message
|
310
280
|
|
311
281
|
if @selection[i][1] == :branch then
|
312
282
|
words = @linebuffer.split(/ /)
|
@@ -322,8 +292,67 @@ class ConsoleCmdr < Cmdr
|
|
322
292
|
print rblankpadding
|
323
293
|
print ("\b" * rblankpadding.length)
|
324
294
|
|
325
|
-
|
295
|
+
|
296
|
+
return execute_command ? "\r" : (branch and type != :webpage) ? ' ' : nil
|
297
|
+
|
298
|
+
end
|
299
|
+
|
300
|
+
def query(key)
|
301
|
+
|
302
|
+
a = @pxi.q?(@linebuffer+key)
|
303
|
+
|
304
|
+
if a then
|
305
|
+
|
306
|
+
unless @input_selection == a.map(&:title) then
|
307
|
+
@input_selection = a.map(&:title)
|
308
|
+
@selection = a.map.with_index do |x,i|
|
309
|
+
|
310
|
+
branch = x.records.any? ? :branch : nil
|
311
|
+
|
312
|
+
title = x.title
|
313
|
+
# is the target a web page?
|
314
|
+
title = title.green if x.target[0] == 'w'
|
315
|
+
title << '>' if branch
|
316
|
+
|
317
|
+
["%d.%s" % [i+1, title], branch, x.desc.yellow, target(x.target.to_s)]
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
print ("\b" * @linebuffer.length) + @selection.map \
|
322
|
+
{|x| x.values_at(0,2).join ' '}.join(" | ") + "\n"
|
326
323
|
|
324
|
+
end
|
325
|
+
|
326
|
+
print ("\b" * @linebuffer.length)
|
327
|
+
|
328
|
+
if (@linebuffer[/\s/] or a.length == 1) and key == ' ' then
|
329
|
+
|
330
|
+
@linebuffer.sub!(/\w+$/, @item_selected)
|
331
|
+
|
332
|
+
end
|
333
|
+
|
334
|
+
print @linebuffer + key
|
335
|
+
|
336
|
+
else
|
337
|
+
|
338
|
+
@input_selection = nil
|
339
|
+
|
340
|
+
end
|
341
|
+
|
327
342
|
end
|
328
343
|
|
344
|
+
def target(c)
|
345
|
+
|
346
|
+
case c.to_sym
|
347
|
+
when :i
|
348
|
+
:interactive
|
349
|
+
when :w
|
350
|
+
:webpage
|
351
|
+
when :m
|
352
|
+
:message
|
353
|
+
else
|
354
|
+
:command
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
329
358
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|