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/test2.rb
CHANGED
@@ -14,14 +14,16 @@ require 'rbcurse/rtextarea'
|
|
14
14
|
require 'rbcurse/rtextview'
|
15
15
|
require 'rbcurse/rmenu'
|
16
16
|
require 'rbcurse/rcombo'
|
17
|
+
require 'rbcurse/extras/rcomboedit'
|
17
18
|
require 'rbcurse/listcellrenderer'
|
18
19
|
require 'rbcurse/checkboxcellrenderer'
|
19
20
|
require 'rbcurse/comboboxcellrenderer'
|
20
21
|
require 'rbcurse/celleditor'
|
21
22
|
require 'rbcurse/rlistbox'
|
22
|
-
require 'rbcurse/
|
23
|
+
require 'rbcurse/rbasiclistbox'
|
24
|
+
#require 'rbcurse/rmessagebox'
|
23
25
|
require 'rbcurse/rtree'
|
24
|
-
require '
|
26
|
+
require 'rbcurse/common/appmethods.rb'
|
25
27
|
require 'rbcurse/extras/scrollbar'
|
26
28
|
def help_text
|
27
29
|
<<-eos
|
@@ -71,7 +73,7 @@ if $0 == __FILE__
|
|
71
73
|
$log.debug "START #{colors} colors test2.rb --------- #{@window} "
|
72
74
|
@form = Form.new @window
|
73
75
|
title = (" "*30) + "Demo of some Ruby Curses Widgets - rbcurse " + Rbcurse::VERSION
|
74
|
-
Label.new @form, {'text' => title,
|
76
|
+
Label.new @form, {'text' => title, :row => 0, :col => 0, :color => 'green', :bgcolor => 'black'}
|
75
77
|
r = 1; fc = 12;
|
76
78
|
mnemonics = %w[ n l r p]
|
77
79
|
%w[ name line regex password].each_with_index do |w,i|
|
@@ -96,29 +98,25 @@ if $0 == __FILE__
|
|
96
98
|
$results.value = "A variable"
|
97
99
|
var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r, "col" => fc}
|
98
100
|
r += 1
|
99
|
-
mylist =
|
100
|
-
0.upto(100) { |v| mylist << "#{v} scrollable data" }
|
101
|
-
|
102
|
-
listb = Listbox.new @form do
|
101
|
+
mylist = File.open("data/tasks.txt",'r').readlines
|
102
|
+
#0.upto(100) { |v| mylist << "#{v} scrollable data" }
|
103
|
+
listb = BasicListbox.new @form do
|
103
104
|
name "mylist"
|
104
105
|
row r
|
105
106
|
col 1
|
106
107
|
width 40
|
107
108
|
height 11
|
108
|
-
|
109
|
-
list_variable $listdata
|
109
|
+
list mylist
|
110
110
|
#selection_mode :SINGLE
|
111
111
|
show_selector true
|
112
|
-
row_selected_symbol "
|
113
|
-
row_unselected_symbol "
|
114
|
-
|
115
|
-
|
116
|
-
|
112
|
+
#row_selected_symbol "*"
|
113
|
+
#row_unselected_symbol " "
|
114
|
+
selected_bgcolor :white
|
115
|
+
selected_color :blue
|
116
|
+
title "Todo List"
|
117
117
|
end
|
118
118
|
Scrollbar.new @form, :parent => listb # 2011-10-1 added
|
119
|
-
#listb.insert
|
120
|
-
#$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
121
|
-
listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure"
|
119
|
+
#listb.list_data_model.insert -1, "rake build", "rake release", "bump version", "fix bugs"
|
122
120
|
col2 = 42
|
123
121
|
texta = TextArea.new @form do
|
124
122
|
name "mytext"
|
@@ -131,11 +129,13 @@ if $0 == __FILE__
|
|
131
129
|
print_footer true
|
132
130
|
bind(:CHANGE){|e| $message.value = e.to_s+" CP:"+e.source.curpos.to_s }
|
133
131
|
end
|
134
|
-
|
135
|
-
|
136
|
-
texta << " "
|
137
|
-
texta << "
|
138
|
-
texta << "
|
132
|
+
lines = File.open("data/unix1.txt",'r').readlines
|
133
|
+
lines.each { |e| texta << e }
|
134
|
+
#texta << "I expect to pass through this world but once." << "Any good therefore that I can do, or any kindness or abilities that I can show to any fellow creature, let me do it now."
|
135
|
+
#texta << "Let me not defer it or neglect it, for I shall not pass this way again."
|
136
|
+
#texta << " "
|
137
|
+
#texta << " F10 to exit. or click cancel button"
|
138
|
+
#texta << " Or alt-c"
|
139
139
|
|
140
140
|
col3 = 92
|
141
141
|
treemodel = nil
|
@@ -212,7 +212,7 @@ if $0 == __FILE__
|
|
212
212
|
editable false
|
213
213
|
list %w[left right center]
|
214
214
|
set_label Label.new @form, {'text' => "Align", 'color'=>'cyan','col'=>1, "mnemonic"=>"I"}
|
215
|
-
list_config
|
215
|
+
list_config :color => :yellow, :bgcolor=>:blue
|
216
216
|
end
|
217
217
|
|
218
218
|
list = ListDataModel.new( %w[white yellow cyan magenta red blue black])
|
@@ -220,7 +220,7 @@ if $0 == __FILE__
|
|
220
220
|
list.bind(:ENTER_ROW) { |obj| $message.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$message.value} , #{obj}"; @form.widgets.each { |e| next unless e.is_a? Widget; e.color = obj.selected_item }; @mb.color = obj.selected_item }
|
221
221
|
|
222
222
|
row += 1
|
223
|
-
combo1 =
|
223
|
+
combo1 = ComboBoxEdit.new @form do
|
224
224
|
name "combo1"
|
225
225
|
row row
|
226
226
|
col fc
|
@@ -433,9 +433,10 @@ if $0 == __FILE__
|
|
433
433
|
filemenu.add(item = RubyCurses::MenuItem.new("Test",'T'))
|
434
434
|
item.command(@form, texta) do |it, form, testa|
|
435
435
|
$message.value = "Testing textarea"
|
436
|
-
str = "
|
437
|
-
str
|
438
|
-
str << "
|
436
|
+
str = File.open("data/lotr.txt",'r').readlines.join
|
437
|
+
#str = "Hello there good friends and fellow rubyists. Here is a textarea that I am testing out with"
|
438
|
+
#str << " some long data, to see how it acts, how the wrapping takes place. Sit back and enjoy the "
|
439
|
+
#str << " bugs as they crop up."
|
439
440
|
testa.goto_start
|
440
441
|
#testa.cursor_bol
|
441
442
|
testa.handle_key ?\C-a.getbyte(0)
|
@@ -471,7 +472,7 @@ if $0 == __FILE__
|
|
471
472
|
item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : 'normal'; label.attr(att); label.repaint}
|
472
473
|
@status_line = status_line :row => Ncurses.LINES-2
|
473
474
|
@status_line.command {
|
474
|
-
"
|
475
|
+
"F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [$message.value]
|
475
476
|
}
|
476
477
|
row += 1 #2
|
477
478
|
ok_button = Button.new @form do
|
@@ -485,7 +486,7 @@ if $0 == __FILE__
|
|
485
486
|
mnemonic 'O'
|
486
487
|
end
|
487
488
|
ok_button.command() { |eve|
|
488
|
-
|
489
|
+
alert("Hope you enjoyed this demo ", {'title' => "Hello", :bgcolor => :blue, :color => :white})
|
489
490
|
sw = case @lookfeel
|
490
491
|
when :dialog
|
491
492
|
progress_dialog :color_pair => $reversecolor, :row_offset => 4, :col_offset => 5
|
@@ -563,6 +564,15 @@ if $0 == __FILE__
|
|
563
564
|
$log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
|
564
565
|
end
|
565
566
|
menu.add(item)
|
567
|
+
item = RubyCurses::MenuItem.new "Options2 ..."
|
568
|
+
item.command() do |it|
|
569
|
+
require './newtabbedwindow'
|
570
|
+
tp = SetupTabbedPane.new
|
571
|
+
tp.run
|
572
|
+
$message.value=$config_hash.inspect
|
573
|
+
$log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
|
574
|
+
end
|
575
|
+
menu.add(item)
|
566
576
|
item = RubyCurses::MenuItem.new "Shell Command..."
|
567
577
|
item.command { shell_output }
|
568
578
|
menu.add(item)
|
@@ -616,6 +626,7 @@ if $0 == __FILE__
|
|
616
626
|
# the main loop
|
617
627
|
|
618
628
|
while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
|
629
|
+
break if ch == ?\C-q.getbyte(0)
|
619
630
|
begin
|
620
631
|
@form.handle_key(ch)
|
621
632
|
|
@@ -630,8 +641,8 @@ if $0 == __FILE__
|
|
630
641
|
end
|
631
642
|
$error_message.value = ""
|
632
643
|
rescue => err
|
633
|
-
$log.
|
634
|
-
$log.
|
644
|
+
$log.error( err) if err
|
645
|
+
$log.error(err.backtrace.join("\n")) if err
|
635
646
|
alert "Got an exception in test2: #{err} "
|
636
647
|
$error_message.value = ""
|
637
648
|
end
|
data/examples/testapp2.rb
CHANGED
@@ -42,7 +42,14 @@ class Testy
|
|
42
42
|
}
|
43
43
|
|
44
44
|
end # stack
|
45
|
-
|
45
|
+
app.status_line :row => last_line()
|
46
|
+
|
47
|
+
# earlier style without end, everything had to be explicit but quite simple. Hard to edit since you
|
48
|
+
# could mess up by inserting inside
|
49
|
+
s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[reverse] reverseme#[normal]normal#[bg = black]just yellow#[fg=blue],blue now #[underline] underlined text"
|
50
|
+
# revised, i know allow [end] so you can pop back to whatever was there before.
|
51
|
+
s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[/end] back to green#[reverse]reverse#[end]#[bg=blue]blue bg #[end],back to green #[/end]plain#[underline] underlined text"
|
52
|
+
app.window.printstring_formatted 15,1, s, $datacolor, 'normal'
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
data/examples/testchars.rb
CHANGED
data/examples/testcombo.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
-
require 'rubygems'
|
3
|
-
#require 'ncurses' # FFI
|
4
2
|
require 'logger'
|
5
3
|
#require 'lib/rbcurse/mapper'
|
6
4
|
#require 'lib/rbcurse/keylabelprinter'
|
7
5
|
#require 'lib/rbcurse/commonio'
|
8
6
|
#require 'lib/rbcurse/rwidget'
|
9
7
|
#require 'lib/rbcurse/rform'
|
10
|
-
require 'rbcurse/
|
8
|
+
require 'rbcurse/extras/rcomboedit'
|
11
9
|
if $0 == __FILE__
|
12
10
|
include RubyCurses
|
13
11
|
|
@@ -23,13 +21,11 @@ if $0 == __FILE__
|
|
23
21
|
# Un post form and free the memory
|
24
22
|
|
25
23
|
catch(:close) do
|
26
|
-
colors = Ncurses.COLORS
|
27
|
-
$log.debug "START #{colors} colors ---------"
|
28
24
|
@form = Form.new @window
|
29
25
|
r = 1; c = 30;
|
30
26
|
mylist = []
|
31
27
|
0.upto(100) { |i| mylist << i.to_s }
|
32
|
-
combo =
|
28
|
+
combo = ComboBoxEdit.new @form do
|
33
29
|
name "combo"
|
34
30
|
row r
|
35
31
|
col c
|
@@ -56,7 +52,7 @@ if $0 == __FILE__
|
|
56
52
|
list = ListDataModel.new( %w[spotty tiger secret pass torvalds qwerty quail toiletry])
|
57
53
|
list.bind(:LIST_DATA_EVENT, name) { |lde,n| $results.value = lde.to_s[0,70]; $log.debug " STA: #{$results} #{lde}" }
|
58
54
|
list.bind(:ENTER_ROW, name) { |obj,n| $results.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$results.value} , #{obj}" }
|
59
|
-
|
55
|
+
ComboBoxEdit.new @form do
|
60
56
|
name name
|
61
57
|
row r
|
62
58
|
col 30
|
@@ -72,13 +68,13 @@ if $0 == __FILE__
|
|
72
68
|
r+=2
|
73
69
|
end
|
74
70
|
|
75
|
-
@help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields.
|
71
|
+
@help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields. F10-quit"
|
76
72
|
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
77
73
|
|
78
74
|
@form.repaint
|
79
75
|
@window.wrefresh
|
80
76
|
Ncurses::Panel.update_panels
|
81
|
-
while((ch = @window.getchar()) !=
|
77
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
82
78
|
@form.handle_key(ch)
|
83
79
|
@window.wrefresh
|
84
80
|
end
|
data/examples/testkeypress.rb
CHANGED
data/examples/testmenu.rb
CHANGED
data/examples/testmulticomp.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
-
require 'rubygems'
|
3
|
-
#require 'ncurses' # FFI
|
4
1
|
require 'logger'
|
5
2
|
require 'rbcurse'
|
6
3
|
require 'rbcurse/rmulticontainer'
|
@@ -46,13 +43,14 @@ if $0 == __FILE__
|
|
46
43
|
texta << "Hello World"
|
47
44
|
ctr += 1
|
48
45
|
end
|
49
|
-
@help = "
|
46
|
+
@help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
|
50
47
|
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
51
48
|
|
52
49
|
@form.repaint
|
53
50
|
@window.wrefresh
|
54
51
|
Ncurses::Panel.update_panels
|
55
|
-
while((ch = @window.getchar()) !=
|
52
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
53
|
+
break if ch == ?\C-q.getbyte(0)
|
56
54
|
str = keycode_tos ch
|
57
55
|
$log.debug "#{ch} got (#{str})"
|
58
56
|
@form.handle_key ch
|
@@ -0,0 +1,94 @@
|
|
1
|
+
##
|
2
|
+
# This tests both multicontainer and container
|
3
|
+
#
|
4
|
+
require 'logger'
|
5
|
+
require 'rbcurse'
|
6
|
+
require 'rbcurse/rmulticontainer'
|
7
|
+
require 'rbcurse/rcontainer'
|
8
|
+
require 'rbcurse/rtextarea'
|
9
|
+
if $0 == __FILE__
|
10
|
+
include RubyCurses
|
11
|
+
include RubyCurses::Utils
|
12
|
+
|
13
|
+
begin
|
14
|
+
# Initialize curses
|
15
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
16
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
17
|
+
$log.level = Logger::DEBUG
|
18
|
+
|
19
|
+
@window = VER::Window.root_window
|
20
|
+
|
21
|
+
catch(:close) do
|
22
|
+
colors = Ncurses.COLORS
|
23
|
+
$log.debug "START #{colors} colors --------- testmulticomp"
|
24
|
+
@form = Form.new @window
|
25
|
+
@ctr = 1
|
26
|
+
r = 1; c = 30;
|
27
|
+
|
28
|
+
mc = MultiContainer.new @form do
|
29
|
+
name "multic"
|
30
|
+
row r
|
31
|
+
col c
|
32
|
+
width 60
|
33
|
+
height 15
|
34
|
+
title "Multicontainer"
|
35
|
+
end
|
36
|
+
ctr = 1
|
37
|
+
|
38
|
+
c1 = Container.new
|
39
|
+
mc.add c1, "A form"
|
40
|
+
f1 = Field.new nil do
|
41
|
+
name "name"
|
42
|
+
text "rahul"
|
43
|
+
row 1
|
44
|
+
col 10
|
45
|
+
label " Name: "
|
46
|
+
end
|
47
|
+
f2 = Field.new nil, :name => "email", :text => "me@somebody.com", :label => "Email: "
|
48
|
+
c1.add( f1, f2)
|
49
|
+
|
50
|
+
c3 = TextArea.new
|
51
|
+
mc.add c3, "Edit Me"
|
52
|
+
c2 = Container.new
|
53
|
+
mc.add c2, "Another form"
|
54
|
+
attrib = 'underline'
|
55
|
+
f3 = Field.new do
|
56
|
+
name "language"
|
57
|
+
text "ruby"
|
58
|
+
row 1
|
59
|
+
col 10
|
60
|
+
label "Language: "
|
61
|
+
attr attrib
|
62
|
+
end
|
63
|
+
f4 = Field.new nil, :name => "version", :text => "1.9.2", :row => 2, :col => 10,
|
64
|
+
:label => " Version: ", :attr => attrib
|
65
|
+
c2.add( f3, f4)
|
66
|
+
|
67
|
+
@help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
|
68
|
+
RubyCurses::Label.new @form, {:text => @help, :row => last_line(), :col => 2,
|
69
|
+
:color => 'yellow', :bgcolor => 'red'}
|
70
|
+
f5 = Field.new @form, :name => "version2", :text => "1.9.2", :row => 20, :col => c, :bgcolor => 'blue',
|
71
|
+
:label => "Version: ", :label_color_pair => get_color($datacolor, 'green', 'black')
|
72
|
+
|
73
|
+
@form.repaint
|
74
|
+
@window.wrefresh
|
75
|
+
Ncurses::Panel.update_panels
|
76
|
+
while((ch = @window.getchar()) != KEY_F10 )
|
77
|
+
break if ch == ?\C-q.getbyte(0)
|
78
|
+
str = keycode_tos ch
|
79
|
+
$log.debug "#{ch} got (#{str})"
|
80
|
+
@form.handle_key ch
|
81
|
+
@form.repaint
|
82
|
+
@window.wrefresh
|
83
|
+
end
|
84
|
+
end
|
85
|
+
rescue => ex
|
86
|
+
ensure
|
87
|
+
@window.destroy if !@window.nil?
|
88
|
+
VER::stop_ncurses
|
89
|
+
p ex if ex
|
90
|
+
p(ex.backtrace.join("\n")) if ex
|
91
|
+
$log.debug( ex) if ex
|
92
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
93
|
+
end
|
94
|
+
end
|
data/examples/testtable.rb
CHANGED
data/examples/testtabp.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
# this is a test program, tests out tabbed panes. type F1 to exit
|
2
|
-
#
|
3
|
-
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
4
|
-
require 'rubygems'
|
5
|
-
#require 'ncurses' # FFI
|
6
1
|
require 'logger'
|
7
2
|
require 'rbcurse'
|
8
3
|
#require 'rbcurse/rtabbedpane'
|
@@ -16,15 +11,16 @@ class TestTabbedPane
|
|
16
11
|
def run
|
17
12
|
$config_hash ||= Variable.new Hash.new
|
18
13
|
#configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
|
19
|
-
@
|
20
|
-
height
|
21
|
-
width
|
14
|
+
@tw = RubyCurses::TabbedWindow.new nil do
|
15
|
+
height 18
|
16
|
+
width 60
|
22
17
|
row 5
|
23
|
-
col
|
18
|
+
col 20
|
24
19
|
button_type :ok
|
25
20
|
end
|
26
|
-
@
|
27
|
-
|
21
|
+
@tp = @tw.tabbed_pane
|
22
|
+
@tab1 = @tw.add_tab "&Language"
|
23
|
+
f1 = @tp.form @tab1
|
28
24
|
#$radio = Variable.new
|
29
25
|
radio1 = RadioButton.new f1 do
|
30
26
|
#variable $radio
|
@@ -56,9 +52,10 @@ class TestTabbedPane
|
|
56
52
|
row 6
|
57
53
|
col 2
|
58
54
|
end
|
59
|
-
@tab2 = @
|
60
|
-
f2 = @tab2.form
|
61
|
-
|
55
|
+
@tab2 = @tw.add_tab "&Settings"
|
56
|
+
#f2 = @tab2.form
|
57
|
+
f2 = @tp.form @tab2
|
58
|
+
r = 2
|
62
59
|
butts = [ "Use &HTTP/1.0", "Use &frames", "&Use SSL" ]
|
63
60
|
bcodes = %w[ HTTP, FRAMES, SSL ]
|
64
61
|
butts.each_with_index do |t, i|
|
@@ -70,8 +67,9 @@ class TestTabbedPane
|
|
70
67
|
col 4
|
71
68
|
end
|
72
69
|
end
|
73
|
-
@tab3 = @
|
74
|
-
f3 = @tab3.form
|
70
|
+
@tab3 = @tw.add_tab "&Editors"
|
71
|
+
#f3 = @tab3.form
|
72
|
+
f3 = @tp.form @tab3
|
75
73
|
butts = %w[ &Vim E&macs &Jed &Other ]
|
76
74
|
bcodes = %w[ VIM EMACS JED OTHER]
|
77
75
|
row = 3
|
@@ -85,8 +83,8 @@ class TestTabbedPane
|
|
85
83
|
end
|
86
84
|
row +=1
|
87
85
|
end
|
88
|
-
@
|
89
|
-
@
|
86
|
+
@tw.show
|
87
|
+
@tw.handle_keys
|
90
88
|
end
|
91
89
|
end
|
92
90
|
if $0 == __FILE__
|