rbcurse 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +40 -0
- data/Manifest.txt +4 -1
- data/README.txt +13 -12
- data/examples/rfe.rb +150 -34
- data/examples/rfe_renderer.rb +6 -0
- data/examples/sqlc.rb +419 -0
- data/examples/testd.db +0 -0
- data/examples/testtable.rb +0 -4
- data/examples/testtabp.rb +2 -0
- data/examples/testtodo.rb +73 -23
- data/examples/todocsv.csv +28 -0
- data/lib/rbcurse/defaultlistselectionmodel.rb +14 -0
- data/lib/rbcurse/listcellrenderer.rb +7 -0
- data/lib/rbcurse/listkeys.rb +7 -4
- data/lib/rbcurse/listscrollable.rb +144 -7
- data/lib/rbcurse/listselectable.rb +23 -2
- data/lib/rbcurse/rlistbox.rb +69 -15
- data/lib/rbcurse/rmessagebox.rb +14 -5
- data/lib/rbcurse/rtabbedpane.rb +64 -2
- data/lib/rbcurse/rtable.rb +223 -18
- data/lib/rbcurse/rtextarea.rb +34 -2
- data/lib/rbcurse/rtextview.rb +27 -4
- data/lib/rbcurse/rwidget.rb +9 -3
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -0
- data/lib/rbcurse.rb +1 -1
- metadata +5 -3
- data/lib/rbcurse/rform.rb +0 -845
data/CHANGELOG
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
** 2009-02-17 12:10 **
|
2
|
+
## added table markers for data and columns before and after on border ##
|
3
|
+
|
4
|
+
also added putting space in intercell area, but today i am not getting any
|
5
|
+
junk there anywaym while scrolling etc.
|
6
|
+
|
7
|
+
* * *
|
8
|
+
** 2009-02-16 22:10 **
|
9
|
+
## added edit_length to TableColumn ##
|
10
|
+
|
11
|
+
This is max editable length of editor component in tables.
|
12
|
+
|
13
|
+
* * *
|
14
|
+
** 2009-02-13 13:48 **
|
15
|
+
## added button_type to tabbed pane ##
|
16
|
+
|
17
|
+
Now buttons at bottom of tabbed pane. Will return selected_index
|
18
|
+
to caller.
|
19
|
+
Uploaded to github, will be included in 0.1.2.
|
20
|
+
|
21
|
+
* * *
|
22
|
+
** 2009-02-12 22:48 **
|
23
|
+
## Code to stop table from printing a column if exceeding bounds ##
|
24
|
+
|
25
|
+
Uploaded to github, will be included in 0.1.2.
|
26
|
+
|
27
|
+
EXPERIMENTAL CODE: Affects only tables. Now table will not print a column or header
|
28
|
+
if columns width causes it to exceed width of table.
|
29
|
+
|
30
|
+
This means if you have a single column which is wider than table
|
31
|
+
then it wont print. In Listboxes we always truncate data and pass to
|
32
|
+
renderer. We could do that here, but it could get messy.
|
33
|
+
|
34
|
+
* * *
|
35
|
+
**2009-02-12 **
|
36
|
+
## Missed one parameter in Table's repaint, and some Table Cell Renderers
|
37
|
+
|
38
|
+
Fixed and uploaded as 0.1.1
|
39
|
+
|
40
|
+
* * *
|
1
41
|
**2009-02-11 00:57**
|
2
42
|
## Path changes in order to make first gem ##
|
3
43
|
|
data/Manifest.txt
CHANGED
@@ -21,7 +21,6 @@ lib/rbcurse/mapper.rb
|
|
21
21
|
lib/rbcurse/orderedhash.rb
|
22
22
|
lib/rbcurse/rcombo.rb
|
23
23
|
lib/rbcurse/rdialogs.rb
|
24
|
-
lib/rbcurse/rform.rb
|
25
24
|
lib/rbcurse/rinputdataevent.rb
|
26
25
|
lib/rbcurse/rlistbox.rb
|
27
26
|
lib/rbcurse/rmenu.rb
|
@@ -36,6 +35,7 @@ lib/rbcurse/scrollable.rb
|
|
36
35
|
lib/rbcurse/selectable.rb
|
37
36
|
lib/rbcurse/table/tablecellrenderer.rb
|
38
37
|
lib/rbcurse/table/tabledatecellrenderer.rb
|
38
|
+
lib/rbcurse.rb
|
39
39
|
lib/ver/keyboard.rb
|
40
40
|
lib/ver/keyboard2.rb
|
41
41
|
lib/ver/ncurses.rb
|
@@ -43,12 +43,15 @@ lib/ver/window.rb
|
|
43
43
|
examples/qdfilechooser.rb
|
44
44
|
examples/rfe.rb
|
45
45
|
examples/rfe_renderer.rb
|
46
|
+
examples/sqlc.rb
|
46
47
|
examples/test1.rb
|
47
48
|
examples/test2.rb
|
48
49
|
examples/testcombo.rb
|
50
|
+
examples/testd.db
|
49
51
|
examples/testkeypress.rb
|
50
52
|
examples/testmenu.rb
|
51
53
|
examples/testtable.rb
|
52
54
|
examples/testtabp.rb
|
53
55
|
examples/testtodo.rb
|
56
|
+
examples/todocsv.csv
|
54
57
|
examples/viewtodo.rb
|
data/README.txt
CHANGED
@@ -13,13 +13,19 @@
|
|
13
13
|
|
14
14
|
* rfe.rb is a ruby file explorer
|
15
15
|
|
16
|
+
* sqlc.rb is a ruby sql client demo (using testd.db at
|
17
|
+
http://www.benegal.org/files/screen/testd.db)
|
18
|
+
|
16
19
|
* testtodo.rb is a test TODO application
|
17
20
|
|
18
|
-
* Screenshots on
|
19
|
-
|
20
|
-
and http://www.benegal.org/files/screen/?M=D (new)
|
21
|
+
* Screenshots on
|
22
|
+
http://www.benegal.org/files/screen/?M=D (new)
|
21
23
|
and on blog, http://totalrecall.wordpress.com
|
24
|
+
and http://github.com/rkumar/rbcurse/wikis/screenshots (old)
|
25
|
+
|
26
|
+
* Todo (for 0.1.2): http://rubyforge.org/pm/task.php?group_id=7775&group_project_id=13812&func=browse
|
22
27
|
|
28
|
+
* Next Major Release: http://rubyforge.org/pm/task.php?group_project_id=13813&group_id=7775&func=browse
|
23
29
|
|
24
30
|
== DESCRIPTION:
|
25
31
|
|
@@ -127,7 +133,7 @@ code below. See test programs for latest, working code.
|
|
127
133
|
end
|
128
134
|
field.insert 5, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
129
135
|
|
130
|
-
=== create a textarea for entry
|
136
|
+
=== create a textarea for entry
|
131
137
|
|
132
138
|
texta = TextArea.new @form do
|
133
139
|
name "mytext"
|
@@ -287,21 +293,16 @@ code below. See test programs for latest, working code.
|
|
287
293
|
|
288
294
|
(following is provided with source)
|
289
295
|
|
290
|
-
* uses the window class created by "manveru" (michael)
|
291
|
-
removed if not needed. (lib/ver/window)
|
296
|
+
* uses the window class created by "manveru" (michael)
|
292
297
|
It is provided with this package, and has some alterations from the
|
293
298
|
original. I have added a method getchar() which traps and returns
|
294
299
|
ALT/META, META+CTRL, META+SHIFT+CONTROL, ALT+Fn etc.
|
295
300
|
|
296
|
-
So basically do not remove it unless you have very different
|
297
|
-
requirements.
|
298
301
|
|
299
302
|
== INSTALL:
|
300
303
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
(Please advice me how i can improve installation procedure)
|
304
|
+
sudo gem install ncurses-ruby
|
305
|
+
sudo gem install rbcurse
|
305
306
|
|
306
307
|
== LICENSE:
|
307
308
|
|
data/examples/rfe.rb
CHANGED
@@ -13,9 +13,14 @@ require 'fileutils'
|
|
13
13
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
14
14
|
|
15
15
|
# TODO
|
16
|
-
# operations on selected files: move, delete, zip
|
16
|
+
# operations on selected files: move, delete, zip, copy
|
17
|
+
# - delete should move to Trash if exists - DONE
|
18
|
+
# global - don't ask confirm
|
19
|
+
# Select based on pattern.
|
17
20
|
# This class represents the finder pane. There are 2
|
18
21
|
# on this sample app
|
22
|
+
# NOTE: rfe_renderer uses entries so you may need to sync it with list_data_model
|
23
|
+
# actually, renderer should refer back to list data model!
|
19
24
|
class FileExplorer
|
20
25
|
include FileUtils
|
21
26
|
attr_reader :wdir
|
@@ -34,6 +39,8 @@ class FileExplorer
|
|
34
39
|
@wdir = @dir.path
|
35
40
|
@filter_pattern = '*'
|
36
41
|
@prev_dirs=[]
|
42
|
+
@inside_block = false
|
43
|
+
|
37
44
|
end
|
38
45
|
def title str
|
39
46
|
@list.title = str
|
@@ -234,19 +241,41 @@ class FileExplorer
|
|
234
241
|
def current_index
|
235
242
|
@list.current_index
|
236
243
|
end
|
237
|
-
def filename
|
244
|
+
def filename ix=current_index()
|
238
245
|
#@entries[@list.current_index]
|
239
|
-
list_data()[
|
246
|
+
list_data()[ix]
|
240
247
|
end
|
241
|
-
def filepath
|
242
|
-
f = filename()
|
248
|
+
def filepath ix=current_index()
|
249
|
+
f = filename(ix)
|
243
250
|
if f[0,1]=='/'
|
244
251
|
f
|
245
252
|
else
|
246
|
-
cur_dir() + "/" +
|
253
|
+
cur_dir() + "/" + f
|
254
|
+
end
|
255
|
+
end
|
256
|
+
# delete the item at position i
|
257
|
+
def delete_at i=@list.current_index
|
258
|
+
ret = @list.list_data_model.delete_at i
|
259
|
+
ret = @entries.delete_at i
|
260
|
+
end
|
261
|
+
def delete obj
|
262
|
+
ret = @list.list_data_model.delete obj
|
263
|
+
ret = @entries.delete_at obj
|
264
|
+
end
|
265
|
+
def insert_at obj, ix = @list.current_index
|
266
|
+
@list.list_data_model.insert ix, f
|
267
|
+
@entries.insert ix, obj
|
268
|
+
end
|
269
|
+
def remove_selected_rows
|
270
|
+
rows = @list.selected_rows
|
271
|
+
rows=rows.sort! {|x,y| y <=> x }
|
272
|
+
rows.each do |i|
|
273
|
+
ret = @list.list_data_model.delete_at i
|
274
|
+
ret = @entries.delete_at i
|
247
275
|
end
|
248
276
|
end
|
249
277
|
|
278
|
+
# ADD
|
250
279
|
end
|
251
280
|
class RFe
|
252
281
|
attr_reader :status_row
|
@@ -258,6 +287,9 @@ class RFe
|
|
258
287
|
colb = Ncurses.COLS/2
|
259
288
|
ht = Ncurses.LINES - 7
|
260
289
|
wid = Ncurses.COLS/2 - 0
|
290
|
+
@trash_path = File.expand_path("~/.Trash")
|
291
|
+
@trash_exists = File.directory? @trash_path
|
292
|
+
$log.debug " trash_path #{@trash_path}, #{@trash_exists}"
|
261
293
|
@lista = FileExplorer.new @form, self, row=2, col=1, ht, wid
|
262
294
|
@listb = FileExplorer.new @form, self, row=2, col=colb, ht, wid
|
263
295
|
|
@@ -280,33 +312,116 @@ class RFe
|
|
280
312
|
File.open(@config_name, "w") { | f | YAML.dump( @config, f )}
|
281
313
|
end
|
282
314
|
def move
|
283
|
-
fp = @current_list.filepath
|
315
|
+
fp = @current_list.filepath #.gsub(' ',"\ ")
|
284
316
|
fn = @current_list.filename
|
285
317
|
$log.debug " FP #{fp}"
|
286
318
|
other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
|
287
319
|
other_dir = other_list.cur_dir
|
288
320
|
$log.debug " OL #{other_list.cur_dir}"
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
321
|
+
if @current_list.list.selected_row_count == 0
|
322
|
+
str= "#{fn}"
|
323
|
+
else
|
324
|
+
str= "#{@current_list.list.selected_row_count} files "
|
325
|
+
end
|
326
|
+
mb = RubyCurses::MessageBox.new do
|
327
|
+
title "Move"
|
328
|
+
message "Move #{str} to"
|
329
|
+
type :input
|
330
|
+
width 80
|
331
|
+
default_value other_dir
|
332
|
+
button_type :ok_cancel
|
333
|
+
default_button 0
|
334
|
+
end
|
301
335
|
#confirm "selected :#{mb.input_value}, #{mb.selected_index}"
|
302
336
|
if mb.selected_index == 0
|
303
|
-
|
304
|
-
|
305
|
-
|
337
|
+
if @current_list.list.selected_row_count == 0
|
338
|
+
FileUtils.move(fp, mb.input_value)
|
339
|
+
#ret = @current_list.list.list().delete_at @current_list.list.current_index # ???
|
340
|
+
# @current_list.entries.delete_at @current_list.current_index
|
341
|
+
@current_list.delete_at
|
342
|
+
else
|
343
|
+
each_selected_row do |f|
|
344
|
+
FileUtils.move(f, mb.input_value)
|
345
|
+
end
|
346
|
+
@current_list.remove_selected_rows
|
347
|
+
@current_list.list.clear_selection
|
348
|
+
end
|
306
349
|
other_list.rescan
|
307
350
|
end
|
308
351
|
end
|
352
|
+
def each_selected_row #title, message, default_value
|
353
|
+
rows = @current_list.list.selected_rows
|
354
|
+
rows = rows.dup
|
355
|
+
rows.each do |i|
|
356
|
+
fp = @current_list.filepath i
|
357
|
+
#$log.debug " moving #{i}: #{fp}"
|
358
|
+
#FileUtils.move(fp, mb.input_value)
|
359
|
+
yield fp
|
360
|
+
end
|
361
|
+
end
|
309
362
|
def copy
|
363
|
+
fp = @current_list.filepath #.gsub(' ',"\ ")
|
364
|
+
fn = @current_list.filename
|
365
|
+
$log.debug " FP #{fp}"
|
366
|
+
other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
|
367
|
+
other_dir = other_list.cur_dir
|
368
|
+
$log.debug " OL #{other_list.cur_dir}"
|
369
|
+
if @current_list.list.selected_row_count == 0
|
370
|
+
str= "#{fn}"
|
371
|
+
else
|
372
|
+
str= "#{@current_list.list.selected_row_count} files "
|
373
|
+
end
|
374
|
+
mb = RubyCurses::MessageBox.new do
|
375
|
+
title "Copy"
|
376
|
+
message "Copy #{str} to"
|
377
|
+
type :input
|
378
|
+
width 80
|
379
|
+
default_value other_dir
|
380
|
+
button_type :ok_cancel
|
381
|
+
default_button 0
|
382
|
+
end
|
383
|
+
if mb.selected_index == 0
|
384
|
+
if @current_list.list.selected_row_count == 0
|
385
|
+
FileUtils.copy(fp, mb.input_value)
|
386
|
+
else
|
387
|
+
each_selected_row do |f|
|
388
|
+
FileUtils.copy(f, mb.input_value)
|
389
|
+
end
|
390
|
+
@current_list.list.clear_selection
|
391
|
+
end
|
392
|
+
other_list.rescan
|
393
|
+
end
|
394
|
+
end
|
395
|
+
def delete
|
396
|
+
fp = @current_list.filepath #.gsub(' ',"\ ")
|
397
|
+
fn = @current_list.filename
|
398
|
+
if @current_list.list.selected_row_count == 0
|
399
|
+
str= "#{fn}"
|
400
|
+
else
|
401
|
+
str= "#{@current_list.list.selected_row_count} files "
|
402
|
+
end
|
403
|
+
if confirm("delete #{str}")==:YES
|
404
|
+
if @current_list.list.selected_row_count == 0
|
405
|
+
if @trash_exists
|
406
|
+
FileUtils.mv fp, @trash_path
|
407
|
+
else
|
408
|
+
FileUtils.rm fp
|
409
|
+
end
|
410
|
+
ret=@current_list.delete_at
|
411
|
+
else
|
412
|
+
each_selected_row do |f|
|
413
|
+
if @trash_exists
|
414
|
+
FileUtils.mv f, @trash_path
|
415
|
+
else
|
416
|
+
FileUtils.rm f
|
417
|
+
end
|
418
|
+
end
|
419
|
+
@current_list.remove_selected_rows
|
420
|
+
@current_list.list.clear_selection
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
def copy1
|
310
425
|
fp = @current_list.filepath
|
311
426
|
fn = @current_list.filename
|
312
427
|
$log.debug " FP #{fp}"
|
@@ -392,22 +507,11 @@ class RFe
|
|
392
507
|
other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
|
393
508
|
case c
|
394
509
|
when 'c'
|
395
|
-
# str= "copy #{fn} to #{other_list.cur_dir}"
|
396
510
|
copy
|
397
511
|
when 'm'
|
398
|
-
str= "move #{fn} to #{other_list.cur_dir}"
|
399
512
|
move
|
400
|
-
#if confirm("#{str}")==:YES
|
401
|
-
#$log.debug " MOVE #{str}"
|
402
|
-
#end
|
403
513
|
when 'd'
|
404
|
-
|
405
|
-
if confirm("#{str}")==:YES
|
406
|
-
$log.debug " delete #{fp}"
|
407
|
-
FileUtils.rm fp
|
408
|
-
ret=@current_list.list.list_data_model.delete_at @current_list.list.current_index # ???
|
409
|
-
$log.debug " DEL RET #{ret},#{@current_list.list.current_index}"
|
410
|
-
end
|
514
|
+
delete
|
411
515
|
when 'u'
|
412
516
|
str= "move #{fn} to #{other_list.cur_dir}"
|
413
517
|
if confirm("#{str}")==:YES
|
@@ -475,6 +579,14 @@ class RFe
|
|
475
579
|
str= "edit #{fp}"
|
476
580
|
#if confirm("#{str}")==:YES
|
477
581
|
edit fp
|
582
|
+
when 'm'
|
583
|
+
f = get_string("Enter a directory to create", 20 )
|
584
|
+
if f != ""
|
585
|
+
FileUtils.mkdir f
|
586
|
+
@current_list.list.list_data_model.insert @current_list.list.current_index, f # ???
|
587
|
+
@current_list.entries.insert @current_list.list.current_index, f # ???
|
588
|
+
end
|
589
|
+
|
478
590
|
when 'x'
|
479
591
|
str= "exec #{fp}"
|
480
592
|
exec_popup fp
|
@@ -508,6 +620,9 @@ class RFe
|
|
508
620
|
@lista.draw_screen lasta
|
509
621
|
@listb.draw_screen lastb
|
510
622
|
|
623
|
+
# @form.bind_key(?\M-x){
|
624
|
+
# @current_list.mark_block
|
625
|
+
# }
|
511
626
|
@form.bind_key(?@){
|
512
627
|
@current_list.change_dir File.expand_path("~/")
|
513
628
|
}
|
@@ -653,6 +768,7 @@ def get_key_labels categ=nil
|
|
653
768
|
['t', 'tree'], ['p', 'Previous'],
|
654
769
|
['b', 'Bookmark'], ['u', 'Unbookmark'],
|
655
770
|
['l', 'List'], ['s', 'Save'],
|
771
|
+
['m', 'mkdir'], nil,
|
656
772
|
['C-c', 'Cancel']
|
657
773
|
]
|
658
774
|
end
|
data/examples/rfe_renderer.rb
CHANGED
@@ -19,12 +19,14 @@ module RubyCurses
|
|
19
19
|
@bgcolor = @orig_bgcolor
|
20
20
|
@color = @orig_color
|
21
21
|
@row_attr = @orig_attr
|
22
|
+
# XXX ouch, when we delete from list, must delete from here too.
|
22
23
|
value = @parent.entries[row_index]
|
23
24
|
if value[0,1]=="/"
|
24
25
|
path = value.dup
|
25
26
|
else
|
26
27
|
path = @parent.cur_dir()+"/"+value
|
27
28
|
end
|
29
|
+
begin
|
28
30
|
stat = File.stat(path)
|
29
31
|
if File.directory? path
|
30
32
|
@row_attr = Ncurses::A_BOLD
|
@@ -33,6 +35,10 @@ module RubyCurses
|
|
33
35
|
value = format_string(value, path, stat)
|
34
36
|
super
|
35
37
|
|
38
|
+
rescue => err
|
39
|
+
$log.debug " rfe_renderer: #{err}"
|
40
|
+
end
|
41
|
+
|
36
42
|
end
|
37
43
|
GIGA_SIZE = 1073741824.0
|
38
44
|
MEGA_SIZE = 1048576.0
|