rbcurse 1.4.0 → 1.4.1.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTES +68 -0
- data/README.markdown +73 -330
- data/TODO2.txt +2 -2
- data/VERSION +1 -1
- data/examples/abasiclist.rb +8 -2
- data/examples/alpmenu.rb +1 -1
- data/examples/app.rb +1 -24
- data/examples/appdirtree.rb +1 -1
- data/examples/appemail.rb +8 -14
- data/examples/appemaillb.rb +2 -2
- data/examples/appgcompose.rb +7 -5
- data/examples/common/file.rb +40 -0
- data/examples/{rmail.rb → common/rmail.rb} +0 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +60 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/{todocsv.csv → data/todocsv.csv} +0 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +49 -14
- data/examples/{appgmail.rb → deprecated/appgmail.rb} +1 -1
- data/examples/{splitp.rb → deprecated/splitp.rb} +0 -0
- data/examples/{testscrolllb.rb → deprecated/testscrolllb.rb} +0 -0
- data/examples/{testscrollp.rb → deprecated/testscrollp.rb} +0 -0
- data/examples/{testscrollta.rb → deprecated/testscrollta.rb} +0 -0
- data/examples/{testscrolltable.rb → deprecated/testscrolltable.rb} +0 -0
- data/examples/{testsplit.rb → deprecated/testsplit.rb} +0 -0
- data/examples/{testsplit2.rb → deprecated/testsplit2.rb} +0 -0
- data/examples/{testsplit3.rb → deprecated/testsplit3.rb} +0 -0
- data/examples/{testsplit3_1.rb → deprecated/testsplit3_1.rb} +0 -0
- data/examples/{testsplit3a.rb → deprecated/testsplit3a.rb} +0 -0
- data/examples/{testsplit3b.rb → deprecated/testsplit3b.rb} +0 -0
- data/examples/{testsplitta.rb → deprecated/testsplitta.rb} +0 -0
- data/examples/{testsplittv.rb → deprecated/testsplittv.rb} +0 -0
- data/examples/{testsplittvv.rb → deprecated/testsplittvv.rb} +0 -0
- data/examples/{testtpane.rb → deprecated/testtpane.rb} +0 -0
- data/examples/{testtpane2.rb → deprecated/testtpane2.rb} +0 -0
- data/examples/{testtpanetable.rb → deprecated/testtpanetable.rb} +0 -0
- data/examples/dirtree.rb +17 -7
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/{testscroller.rb → experimental/testscroller.rb} +1 -19
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +1 -0
- data/examples/multispl.rb +4 -4
- data/examples/newmessagebox.rb +130 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +0 -3
- data/examples/qdfilechooser.rb +0 -3
- data/examples/rfe.rb +134 -18
- data/examples/rfe_renderer.rb +48 -2
- data/examples/sqlc.rb +2 -1
- data/examples/sqlm.rb +0 -2
- data/examples/table1.rb +1 -7
- data/examples/term2.rb +4 -1
- data/examples/test1.rb +0 -5
- data/examples/test2.rb +42 -31
- data/examples/testapp2.rb +8 -1
- data/examples/testchars.rb +0 -4
- data/examples/testcombo.rb +5 -9
- data/examples/testkeypress.rb +0 -3
- data/examples/testmenu.rb +0 -4
- data/examples/testmulticomp.rb +3 -5
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testtable.rb +0 -5
- data/examples/testtabp.rb +16 -18
- data/examples/testtodo.rb +1 -5
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/viewtodo.rb +1 -4
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/app.rb +92 -69
- data/lib/rbcurse/applicationheader.rb +46 -6
- data/lib/rbcurse/celleditor.rb +1 -9
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -4
- data/lib/rbcurse/common/ansiparser.rb +117 -0
- data/{examples → lib/rbcurse/common}/appmethods.rb +25 -0
- data/lib/rbcurse/common/basestack.rb +407 -0
- data/lib/rbcurse/common/bordertitle.rb +41 -0
- data/lib/rbcurse/common/chunk.rb +177 -0
- data/lib/rbcurse/common/colorparser.rb +71 -0
- data/lib/rbcurse/common/keydefs.rb +30 -0
- data/lib/rbcurse/common/widgetshortcuts.rb +302 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/{rscrollpane.rb → deprecated/rscrollpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane.rb → deprecated/rsplitpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane2.rb → deprecated/rsplitpane2.rb} +0 -0
- data/lib/rbcurse/{rviewport.rb → deprecated/rviewport.rb} +0 -0
- data/lib/rbcurse/experimental/README.markdown +14 -0
- data/lib/rbcurse/experimental/resultsettextview.rb +585 -0
- data/lib/rbcurse/experimental/stackflow.rb +478 -0
- data/lib/rbcurse/extras/bottomline.rb +85 -16
- data/lib/rbcurse/extras/box.rb +58 -0
- data/lib/rbcurse/extras/directorylist.rb +1 -1
- data/lib/rbcurse/extras/horizlist.rb +203 -0
- data/lib/rbcurse/extras/listselectable.rb +8 -0
- data/lib/rbcurse/extras/multiform.rb +330 -0
- data/lib/rbcurse/extras/multilinelabel.rb +142 -0
- data/lib/rbcurse/extras/newmessagebox.rb +328 -0
- data/lib/rbcurse/extras/newtabbedpane.rb +612 -0
- data/lib/rbcurse/extras/newtabbedwindow.rb +68 -0
- data/lib/rbcurse/extras/padreader.rb +189 -0
- data/lib/rbcurse/extras/rcomboedit.rb +256 -0
- data/lib/rbcurse/extras/resultsetbrowser.rb +281 -0
- data/lib/rbcurse/extras/statusline.rb +44 -6
- data/lib/rbcurse/extras/tabularwidget.rb +141 -104
- data/lib/rbcurse/extras/textpad.rb +516 -0
- data/lib/rbcurse/extras/viewer.rb +2 -0
- data/lib/rbcurse/io.rb +120 -3
- data/lib/rbcurse/listcellrenderer.rb +2 -1
- data/lib/rbcurse/listkeys.rb +1 -1
- data/lib/rbcurse/listscrollable.rb +72 -7
- data/lib/rbcurse/rbasiclistbox.rb +64 -12
- data/lib/rbcurse/rchangeevent.rb +0 -1
- data/lib/rbcurse/rcombo.rb +54 -59
- data/lib/rbcurse/rcommandwindow.rb +46 -10
- data/lib/rbcurse/rcontainer.rb +415 -0
- data/lib/rbcurse/rdialogs.rb +242 -165
- data/lib/rbcurse/rinputdataevent.rb +0 -1
- data/lib/rbcurse/rlistbox.rb +19 -9
- data/lib/rbcurse/rmessagebox.rb +1 -5
- data/lib/rbcurse/rmulticontainer.rb +64 -61
- data/lib/rbcurse/rmultitextview.rb +0 -2
- data/lib/rbcurse/rpopupmenu.rb +0 -2
- data/lib/rbcurse/rscrollform.rb +61 -12
- data/lib/rbcurse/rtabbedpane.rb +89 -73
- data/lib/rbcurse/rtabbedwindow.rb +53 -211
- data/lib/rbcurse/rtable.rb +0 -2
- data/lib/rbcurse/rtextarea.rb +14 -14
- data/lib/rbcurse/rtextview.rb +165 -50
- data/lib/rbcurse/rvimsplit.rb +15 -12
- data/lib/rbcurse/rwidget.rb +404 -150
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -4
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -3
- data/lib/ver/ncurses.rb +1 -9
- data/lib/ver/rpad.rb +375 -0
- data/lib/ver/window.rb +262 -440
- metadata +73 -31
data/examples/newtesttabp.rb
CHANGED
data/examples/qdfilechooser.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# this is a test program, tests out messageboxes. type F1 to exit
|
2
2
|
# a quick dirty file chooser in 2 lines of code.
|
3
|
-
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
4
|
-
require 'rubygems'
|
5
|
-
#require 'ncurses' # FFI
|
6
3
|
require 'logger'
|
7
4
|
require 'ver/ncurses'
|
8
5
|
require 'ver/window'
|
data/examples/rfe.rb
CHANGED
@@ -49,6 +49,7 @@ class FileExplorer
|
|
49
49
|
@filter_pattern = '*'
|
50
50
|
@prev_dirs=[]
|
51
51
|
@inside_block = false
|
52
|
+
$entry_count = 0 # just for show... may not be accurate after deletes etc
|
52
53
|
|
53
54
|
end
|
54
55
|
def title str
|
@@ -80,6 +81,7 @@ class FileExplorer
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
def goto_previous_dir
|
84
|
+
#alert "Previous dirs contain #{@prev_dirs} "
|
83
85
|
d = @prev_dirs.pop
|
84
86
|
if !d.nil? and d == @wdir
|
85
87
|
d = @prev_dirs.pop
|
@@ -94,6 +96,7 @@ class FileExplorer
|
|
94
96
|
end
|
95
97
|
def rescan
|
96
98
|
flist = @dir.entries
|
99
|
+
$entry_count = flist.size # just for show... may not be accurate after deletes etc
|
97
100
|
flist.shift
|
98
101
|
#populate @entries
|
99
102
|
populate flist
|
@@ -110,6 +113,7 @@ class FileExplorer
|
|
110
113
|
#list.list_data_model.insert 0, *fl
|
111
114
|
list.list_data_model.insert 0, *flist
|
112
115
|
list.set_form_row
|
116
|
+
#$entry_count = list.size # just for show... may not be accurate after deletes etc
|
113
117
|
end
|
114
118
|
def sort key, reverse=false
|
115
119
|
# remove parent before sorting, keep at top
|
@@ -227,6 +231,7 @@ class FileExplorer
|
|
227
231
|
# flist << format_string(f, stat)
|
228
232
|
#}
|
229
233
|
@entries = fl
|
234
|
+
$entry_count = @entries.size
|
230
235
|
title = pwd()
|
231
236
|
@wdir = title
|
232
237
|
rfe = self
|
@@ -242,6 +247,7 @@ class FileExplorer
|
|
242
247
|
title wdir
|
243
248
|
#title_attrib 'reverse'
|
244
249
|
cell_renderer RfeRenderer.new "", {"color"=>@color, "bgcolor"=>@bgcolor, "parent" => rfe, "display_length"=> wid-2}
|
250
|
+
KEY_ROW_SELECTOR 0 # C-space since space used for preview
|
245
251
|
end
|
246
252
|
@list = lista
|
247
253
|
lista.bind(:ENTER) {|l| @rfe.current_list(self); l.title_attrib 'reverse'; }
|
@@ -266,6 +272,7 @@ class FileExplorer
|
|
266
272
|
end
|
267
273
|
def filepath ix=current_index()
|
268
274
|
f = filename(ix)
|
275
|
+
return unless f
|
269
276
|
if f[0,1]=='/'
|
270
277
|
f
|
271
278
|
else
|
@@ -479,6 +486,8 @@ class RFe
|
|
479
486
|
fp = @current_list.filepath
|
480
487
|
content = get_contents(fp)
|
481
488
|
rescue => err
|
489
|
+
$log.debug err.to_s
|
490
|
+
$log.debug(err.backtrace.join("\n"))
|
482
491
|
alert err.to_s
|
483
492
|
return
|
484
493
|
end
|
@@ -565,6 +574,10 @@ class RFe
|
|
565
574
|
when 'x'
|
566
575
|
str= "exec #{fp}"
|
567
576
|
exec_popup fp
|
577
|
+
when 'p'
|
578
|
+
page fp
|
579
|
+
when 'q'
|
580
|
+
qlmanage fp
|
568
581
|
end
|
569
582
|
end
|
570
583
|
def opt_dir c
|
@@ -639,7 +652,53 @@ class RFe
|
|
639
652
|
end
|
640
653
|
def edit fp=@current_list.filepath
|
641
654
|
$log.debug " edit #{fp}"
|
642
|
-
|
655
|
+
editor = ENV['EDITOR'] || 'vi'
|
656
|
+
vimp = %x[which #{editor}].chomp
|
657
|
+
shell_out "#{vimp} #{fp}"
|
658
|
+
end
|
659
|
+
|
660
|
+
# TODO we need to move these to some common file so differnt programs and demos
|
661
|
+
# can use them on pressing space or enter.
|
662
|
+
def page fp=@current_list.filepath
|
663
|
+
ft=%x[file #{fp}]
|
664
|
+
if ft.index("text")
|
665
|
+
pager = ENV['PAGER'] || 'less'
|
666
|
+
vimp = %x[which #{pager}].chomp
|
667
|
+
shell_out "#{vimp} #{fp}"
|
668
|
+
elsif ft.index(/zip/i)
|
669
|
+
shell_out "tar tvf #{fp} | less"
|
670
|
+
elsif ft.index(/directory/i)
|
671
|
+
shell_out "ls -lh #{fp} | less"
|
672
|
+
else
|
673
|
+
alert "#{fp} is not text, not paging "
|
674
|
+
#use_on_file "als", fp # only zip or archive
|
675
|
+
end
|
676
|
+
end
|
677
|
+
def qlmanage fp=@current_list.filepath
|
678
|
+
begin
|
679
|
+
a=%x[which qlmanage]
|
680
|
+
if a != ""
|
681
|
+
cmd="qlmanage -p #{@current_list.filepath} 2>/dev/null"
|
682
|
+
%x[#{cmd}]
|
683
|
+
else
|
684
|
+
alert "qlmanage not present on your system. Trying pager"
|
685
|
+
page fp
|
686
|
+
end
|
687
|
+
rescue Interrupt
|
688
|
+
rescue => err
|
689
|
+
alert err.to_s
|
690
|
+
end
|
691
|
+
end
|
692
|
+
# also if calling program gives output but does not stop
|
693
|
+
# or take control, then nothing will show up
|
694
|
+
def use_on_file prog, args, fp=@current_list.filepath
|
695
|
+
vimp = %x[which #{prog}].chomp
|
696
|
+
if vimp != ""
|
697
|
+
alert "using #{prog} "
|
698
|
+
shell_out "#{vimp} #{args } #{fp}"
|
699
|
+
else
|
700
|
+
alert "could not locate #{prog} "
|
701
|
+
end
|
643
702
|
end
|
644
703
|
def stopping?
|
645
704
|
@stopping
|
@@ -688,7 +747,7 @@ class RFe
|
|
688
747
|
while((ch = @window.getchar()) != ?\C-c.getbyte(0) )
|
689
748
|
if ch < 33 || ch > 126
|
690
749
|
Ncurses.beep
|
691
|
-
elsif "
|
750
|
+
elsif "cmdsuvrexpq".index(ch.chr) == nil
|
692
751
|
Ncurses.beep
|
693
752
|
else
|
694
753
|
opt_file ch.chr
|
@@ -717,12 +776,11 @@ class RFe
|
|
717
776
|
@form.bind_key(127){
|
718
777
|
@current_list.goto_previous_dir
|
719
778
|
}
|
779
|
+
# form gives this to list which consumes it for selection.
|
780
|
+
# need to bind to list's LIST_SELECTION_EVENT
|
720
781
|
@form.bind_key(32){
|
721
|
-
|
722
|
-
|
723
|
-
%x[#{cmd}]
|
724
|
-
rescue Interrupt
|
725
|
-
end
|
782
|
+
fp = @current_list.filepath
|
783
|
+
page fp
|
726
784
|
}
|
727
785
|
@form.bind_key(FFI::NCurses::KEY_F3){
|
728
786
|
begin
|
@@ -733,17 +791,30 @@ class RFe
|
|
733
791
|
}
|
734
792
|
@form.bind_key(FFI::NCurses::KEY_F1){
|
735
793
|
#Io.view(["this is some help text","hello there"])
|
794
|
+
color0 = get_color($promptcolor, 'black','green')
|
795
|
+
color1 = get_color($reversecolor, 'green','black')
|
796
|
+
color2 = get_color($reversecolor, 'magenta','black')
|
736
797
|
arr = []
|
737
|
-
arr << " FILE BROWSER HELP "
|
798
|
+
#arr << " FILE BROWSER HELP "
|
799
|
+
arr << [color0," FILE BROWSER HELP ", FFI::NCurses::A_NORMAL]
|
738
800
|
arr << " "
|
739
|
-
arr << " <tab> - switch between windows"
|
740
|
-
arr << " <enter> - open dir"
|
741
|
-
arr << " F3 - view file/dir/zip contents (toggle) "
|
742
|
-
arr << " F4 - edit file content"
|
743
|
-
arr << " <char>
|
801
|
+
arr << [[color1," <tab> ",nil],[color2, "- switch between windows", nil]]
|
802
|
+
arr << [[color1," <enter> ",nil],[color2, "- open dir", nil]]
|
803
|
+
arr << [[color1," F3 ",nil],[color2, "- view file/dir/zip contents (toggle) ", nil]]
|
804
|
+
arr << [[color1," F4 ",nil],[color2, "- edit file content", nil]]
|
805
|
+
arr << [[color1," <char> ", nil],[color2, "first file starting with <char>",nil]]
|
806
|
+
#arr << " VIM MODE "
|
807
|
+
arr << [color0," VIM MODE ", FFI::NCurses::A_NORMAL]
|
808
|
+
arr << [[color1," M",nil],[color2, "-v - Vim like bindings for navigation (toggle)", nil]]
|
809
|
+
arr << " jk gg G up down motion, C-n C-p, Alt-0, Alt-9 "
|
810
|
+
arr << [[color1," p or Space ",nil],[color2, "- use pager on current file", nil]]
|
811
|
+
arr << [[color1," q ",nil],[color2, "- use qlmanage on file ",nil],[$promptcolor, " (OSX)", nil]]
|
812
|
+
arr << [[color1," f<char> ",nil],[color2, "- first file starting with <char>", nil]]
|
813
|
+
|
744
814
|
arr << " "
|
745
815
|
arr << " < > ^ V - move help window "
|
746
816
|
arr << " "
|
817
|
+
# next line does not work due to chunks
|
747
818
|
w = arr.max_by(&:length).length
|
748
819
|
#arr = ["this is some help text","hello there"]
|
749
820
|
|
@@ -754,7 +825,8 @@ class RFe
|
|
754
825
|
#t.color = :black
|
755
826
|
#t.bgcolor = :white
|
756
827
|
# or
|
757
|
-
t.attr = :reverse
|
828
|
+
#t.attr = :reverse
|
829
|
+
t.attr = :normal
|
758
830
|
#t.bind_key(KEY_F1){ alert "closing up!"; throw :close }
|
759
831
|
# just for kicks move window around
|
760
832
|
t.bind_key('<'){ f = t.form.window; c = f.left - 1; f.hide; f.mvwin(f.top, c); f.show;
|
@@ -789,6 +861,13 @@ class RFe
|
|
789
861
|
@form.bind_key(FFI::NCurses::KEY_F8){
|
790
862
|
system_popup()
|
791
863
|
}
|
864
|
+
# will work if you are in vim mode
|
865
|
+
@form.bind_key(?p){
|
866
|
+
page
|
867
|
+
}
|
868
|
+
@form.bind_key(?q){
|
869
|
+
qlmanage
|
870
|
+
}
|
792
871
|
# will no longer come here. list event has to be used
|
793
872
|
#@form.bind_key(?\C-m){ # listbox has eaten it up
|
794
873
|
@lista.list.bind(:PRESS){
|
@@ -803,7 +882,11 @@ class RFe
|
|
803
882
|
@current_list.change_dir dir
|
804
883
|
end
|
805
884
|
}
|
885
|
+
gw = get_color($reversecolor, 'green', 'black')
|
886
|
+
bw = get_color($datacolor, 'blue', 'black')
|
806
887
|
@klp = RubyCurses::KeyLabelPrinter.new @form, get_key_labels
|
888
|
+
@klp.footer_color_pair = bw
|
889
|
+
@klp.footer_mnemonic_color_pair = gw
|
807
890
|
@klp.set_key_labels get_key_labels(:file), :file
|
808
891
|
@klp.set_key_labels get_key_labels(:view), :view
|
809
892
|
@klp.set_key_labels get_key_labels(:dir), :dir
|
@@ -811,13 +894,32 @@ class RFe
|
|
811
894
|
@window.wrefresh
|
812
895
|
Ncurses::Panel.update_panels
|
813
896
|
begin
|
897
|
+
chunks=["File","Key"]
|
898
|
+
color0 = get_color($promptcolor, 'black','cyan')
|
899
|
+
color1 = get_color($datacolor, 'white','cyan')
|
900
|
+
|
814
901
|
## qq stops program, but only if M-v (vim mode)
|
815
902
|
while(!stopping? && (ch = @window.getchar()) != ?\C-q.getbyte(0) )
|
816
903
|
s = keycode_tos ch
|
817
|
-
status_row.text = "Pressed #{ch} , #{s}"
|
904
|
+
#status_row.text = "| Pressed #{ch} , #{s}"
|
818
905
|
@form.handle_key(ch)
|
819
906
|
|
820
|
-
|
907
|
+
# the following is just a test of show_colored_chunks
|
908
|
+
#count = @current_list.list.size
|
909
|
+
count1 = @lista.list.size
|
910
|
+
count2 = @listb.list.size
|
911
|
+
x, y = FFI::NCurses::getyx @window.get_window
|
912
|
+
chunks[0]=[color0, "%-30s" % status_row.text, FFI::NCurses::A_BOLD]
|
913
|
+
chunks[1]=[color1, "%-18s" % " | #{ch}, #{s} |", FFI::NCurses::A_NORMAL]
|
914
|
+
chunks[2]=[color0, " Total: #{count1}, #{count2}"]
|
915
|
+
@window.wmove(Ncurses.LINES-3,0)
|
916
|
+
@window.color_set(color0, nil)
|
917
|
+
@window.print_empty_line
|
918
|
+
@window.wmove(Ncurses.LINES-3,0)
|
919
|
+
@window.show_colored_chunks chunks
|
920
|
+
@window.wmove(x,y)
|
921
|
+
|
922
|
+
#@form.repaint
|
821
923
|
@window.wrefresh
|
822
924
|
end
|
823
925
|
ensure
|
@@ -847,12 +949,13 @@ def get_key_labels categ=nil
|
|
847
949
|
key_labels = [
|
848
950
|
['C-q', 'Exit'], ['C-v', 'View'],
|
849
951
|
['C-f', 'File'], ['C-d', 'Dir'],
|
850
|
-
['C-
|
952
|
+
['C-Sp','Select'], ['Spc', "Preview"],
|
851
953
|
['F3', 'View'], ['F4', 'Edit'],
|
852
954
|
['F5', 'Filter'], ['F6', 'Sort'],
|
853
955
|
['F7', 'Grep'], ['F8', 'System'],
|
854
956
|
['M-0', 'Top'], ['M-9', 'End'],
|
855
|
-
['C-p', 'PgUp'], ['C-n', 'PgDn']
|
957
|
+
['C-p', 'PgUp'], ['C-n', 'PgDn'],
|
958
|
+
['M-v', 'Vim Mode'], ['BSpc', 'PrevDir']
|
856
959
|
]
|
857
960
|
elsif categ == :file
|
858
961
|
key_labels = [
|
@@ -944,6 +1047,10 @@ def filter
|
|
944
1047
|
@current_list.filter_pattern = f
|
945
1048
|
@current_list.rescan
|
946
1049
|
end
|
1050
|
+
|
1051
|
+
# ask user for pattern to grep through files
|
1052
|
+
# and display file names in same list
|
1053
|
+
|
947
1054
|
def grep_popup
|
948
1055
|
last_regex = @last_regex || ""
|
949
1056
|
last_pattern = @last_pattern || "*"
|
@@ -990,16 +1097,25 @@ def grep_popup
|
|
990
1097
|
flags=""
|
991
1098
|
flags << " -i " if mform.by_name["case insensitive"].value==true
|
992
1099
|
flags << " -R " if mform.by_name["Recurse"].value==true
|
1100
|
+
# sometimes grep pukes "No such file or directory if you specify some
|
1101
|
+
# filespec that is not present. I don't want it to come in filestr
|
1102
|
+
# so i am not piping stderr to stdout
|
993
1103
|
cmd = "cd #{@current_list.cur_dir()};grep -l #{flags} #{inp} #{fp}"
|
994
1104
|
filestr = %x[ #{cmd} ]
|
995
1105
|
files = nil
|
996
1106
|
files = filestr.split(/\n/) unless filestr.nil?
|
997
1107
|
#view filestr
|
1108
|
+
if !files || files.empty?
|
1109
|
+
alert "Sorry! No files for regex #{inp}"
|
1110
|
+
return
|
1111
|
+
end
|
998
1112
|
@current_list.title "grep #{inp}"
|
999
1113
|
@current_list.populate files
|
1114
|
+
# Use backspace to go back
|
1000
1115
|
end
|
1001
1116
|
return mb.selected_index, mform.by_name["regex"].getvalue, mform.by_name["filepattern"].getvalue, mform.by_name["Recurse"].value, mform.by_name["case insensitive"].value
|
1002
1117
|
end
|
1118
|
+
|
1003
1119
|
def system_popup
|
1004
1120
|
deflt = @last_system || ""
|
1005
1121
|
options=["run in shell","view output","file explorer"]
|
data/examples/rfe_renderer.rb
CHANGED
@@ -10,9 +10,54 @@ module RubyCurses
|
|
10
10
|
@orig_bgcolor = @bgcolor
|
11
11
|
@orig_color = @color
|
12
12
|
@orig_attr = @attr
|
13
|
+
# we need to refer to file types, executable, dir, link, otherwise we'll go crazy
|
14
|
+
@color_hash = {
|
15
|
+
'.rb' => [get_color($datacolor, 'red', 'black'), 0],
|
16
|
+
'.txt' => [get_color($datacolor, 'white', 'black'), 0],
|
17
|
+
'.gemspec' => [get_color($datacolor, 'yellow', 'black'), 0],
|
18
|
+
'.gem' => [get_color($datacolor, 'yellow', 'black'), 0],
|
19
|
+
'.c' => [get_color($datacolor, 'green', 'black'), 0],
|
20
|
+
'.py' => [get_color($datacolor, 'green', 'black'), 0],
|
21
|
+
'.tgz' => [get_color($datacolor, 'red', 'black'), get_attrib('bold')],
|
22
|
+
'.gz' => [get_color($datacolor, 'red', 'black'), 0],
|
23
|
+
'.zip' => [get_color($datacolor, 'red', 'black'), 0],
|
24
|
+
'.jar' => [get_color($datacolor, 'red', 'black'), 0],
|
25
|
+
'.html' => [get_color($datacolor, 'green', 'black'), get_attrib('reverse')],
|
26
|
+
"" => [get_color($datacolor, 'yellow', 'black'), get_attrib('bold')],
|
27
|
+
'.jpg' => [get_color($datacolor, 'magenta', 'black'), 0],
|
28
|
+
'.png' => [get_color($datacolor, 'magenta', 'black'), 0],
|
29
|
+
'.sh' => [get_color($datacolor, 'red', 'black'), 0],
|
30
|
+
'.mp3' => [get_color($datacolor, 'cyan', 'blue'), 0],
|
31
|
+
'.bak' => [get_color($datacolor, 'magenta', 'black'), 0],
|
32
|
+
'.tmp' => [get_color($datacolor, 'black', 'blue'), 0],
|
33
|
+
'.pl' => [get_color($datacolor, 'green', 'black'), 0],
|
34
|
+
'.java' => [get_color($datacolor, 'cyan', 'blue'), 0],
|
35
|
+
'.class' => [get_color($datacolor, 'magenta', 'black'), 0],
|
36
|
+
'.pyc' => [get_color($datacolor, 'magenta', 'black'), 0],
|
37
|
+
'.o' => [get_color($datacolor, 'magenta', 'black'), 0],
|
38
|
+
'.a' => [get_color($datacolor, 'magenta', 'black'), 0],
|
39
|
+
'.lib' => [get_color($datacolor, 'magenta', 'black'), 0]
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# override parent method to set color_pair and attr for different kind of files
|
44
|
+
def select_colors focussed, selected
|
45
|
+
ext = File.extname(@path)
|
46
|
+
c = @color_hash[ext]
|
47
|
+
c = [$datacolor, FFI::NCurses::A_NORMAL] unless c
|
48
|
+
if File.directory? @path
|
49
|
+
c = [get_color($datacolor, 'blue', 'black'), FFI::NCurses::A_BOLD]
|
50
|
+
end
|
51
|
+
@color_pair, @attr = *c
|
52
|
+
if selected
|
53
|
+
#@attr = FFI::NCurses::A_UNDERLINE | FFI::NCurses::A_BOLD # UL not avaible on screen
|
54
|
+
@attr = FFI::NCurses::A_REVERSE | FFI::NCurses::A_BOLD
|
55
|
+
@color_pair = $datacolor
|
56
|
+
end
|
57
|
+
if focussed
|
58
|
+
@attr = FFI::NCurses::A_REVERSE # | FFI::NCurses::A_BOLD
|
59
|
+
end
|
13
60
|
end
|
14
|
-
##
|
15
|
-
##
|
16
61
|
#
|
17
62
|
def repaint graphic, r=@row,c=@col, row_index=-1, value=@text, focussed=false, selected=false
|
18
63
|
|
@@ -26,6 +71,7 @@ module RubyCurses
|
|
26
71
|
else
|
27
72
|
path = @parent.cur_dir()+"/"+value
|
28
73
|
end
|
74
|
+
@path = path # i need it in select_color
|
29
75
|
begin
|
30
76
|
stat = File.stat(path)
|
31
77
|
if File.directory? path
|
data/examples/sqlc.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
## rkumar, 2009
|
2
|
+
#
|
2
3
|
#DEPRECATED. See sqlm.rb or sqlt.rb in which i use a TabularWidget instead of Table.
|
3
4
|
#AVOID USING TabbedPane till its rewritten 1.3.2 or so.
|
4
5
|
|
@@ -167,7 +168,7 @@ class Sqlc
|
|
167
168
|
end
|
168
169
|
def run
|
169
170
|
title = "rbcurse"
|
170
|
-
@header = ApplicationHeader.new @form, title, {:text2=>"Demo", :text_center=>"SQL Client using TabbedPane and Table (see sqlm.rb instead) "}
|
171
|
+
@header = ApplicationHeader.new @form, title, {:text2=>"Demo", :text_center=>"SQL Client using deprecated TabbedPane and Table (see sqlm.rb instead) "}
|
171
172
|
status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>70}
|
172
173
|
@status_row = status_row
|
173
174
|
# setting ENTER across all objects on a form
|
data/examples/sqlm.rb
CHANGED
data/examples/table1.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
require 'rbcurse/app'
|
2
2
|
|
3
3
|
if $0 == __FILE__
|
4
|
-
#
|
5
|
-
#window = app.window
|
6
|
-
#window.printstring 2, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
|
7
|
-
#app.logger.info "beforegetch"
|
8
|
-
#window.getch
|
9
|
-
#app.close
|
10
|
-
# this was the yield example, but now we've moved to instance eval
|
4
|
+
# NOTE try using the readonly tabular or tabular widget instead, see term2.rb
|
11
5
|
App.new do
|
12
6
|
@window.printstring 1, 30, "Demo of Table - rbcurse", $normalcolor, 'reverse'
|
13
7
|
@window.printstring 2, 30, "Hit F1 to quit", $datacolor, 'normal'
|
data/examples/term2.rb
CHANGED
@@ -16,7 +16,10 @@ App.new do
|
|
16
16
|
#list_box :list => t.to_s.split("\n")
|
17
17
|
list_box :list => t.render
|
18
18
|
end # stack
|
19
|
-
r =
|
19
|
+
r = `/bin/df -gh` # stock BSD df
|
20
|
+
#r = `df -gh` # I've installed brew, the df (maybe coreutils gives an error due to g option"
|
21
|
+
|
22
|
+
raise "df -gh not returning anything. correct command here. Try removing g option" if r == ""
|
20
23
|
# on my system there are extra spaces so i need to remove them, or else
|
21
24
|
# there'll be a mismatch between headers and columns
|
22
25
|
r.gsub!("Mounted on", "Mounted_on")
|
data/examples/test1.rb
CHANGED
@@ -5,12 +5,7 @@
|
|
5
5
|
# TERM=xterm-color does but does not trap F1, f2 etc
|
6
6
|
# TERM=xterm does not but other things are fine.
|
7
7
|
#
|
8
|
-
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
9
|
-
require 'rubygems'
|
10
|
-
#require 'ncurses' # FFI
|
11
8
|
require 'logger'
|
12
|
-
#require 'lib/rbcurse/mapper'
|
13
|
-
#require 'lib/rbcurse/keylabelprinter'
|
14
9
|
require 'rbcurse'
|
15
10
|
require 'rbcurse/rmessagebox'
|
16
11
|
|