rbcurse 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +21 -0
- data/Manifest.txt +6 -0
- data/README.markdown +6 -4
- data/TODO +372 -0
- data/TODO2.txt +121 -0
- data/VERSION +1 -1
- data/examples/README.txt +67 -0
- data/examples/abasiclist.rb +33 -0
- data/examples/alpmenu.rb +42 -0
- data/examples/app.rb +859 -0
- data/examples/app.sample +17 -0
- data/examples/appdirtree.rb +74 -0
- data/examples/appemail.rb +191 -0
- data/examples/appemaillb.rb +308 -0
- data/examples/appgcompose.rb +315 -0
- data/examples/atree.rb +64 -0
- data/examples/common/file.rb +40 -0
- data/examples/common/rmail.rb +257 -0
- data/examples/data.txt +683 -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/data/todocsv.csv +28 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +495 -0
- data/examples/deprecated/appgmail.rb +952 -0
- data/examples/deprecated/splitp.rb +56 -0
- data/examples/deprecated/testscrolllb.rb +86 -0
- data/examples/deprecated/testscrollp.rb +88 -0
- data/examples/deprecated/testscrollta.rb +80 -0
- data/examples/deprecated/testscrolltable.rb +165 -0
- data/examples/deprecated/testsplit.rb +87 -0
- data/examples/deprecated/testsplit2.rb +123 -0
- data/examples/deprecated/testsplit3.rb +215 -0
- data/examples/deprecated/testsplit3_1.rb +244 -0
- data/examples/deprecated/testsplit3a.rb +215 -0
- data/examples/deprecated/testsplit3b.rb +237 -0
- data/examples/deprecated/testsplitta.rb +148 -0
- data/examples/deprecated/testsplittv.rb +142 -0
- data/examples/deprecated/testsplittvv.rb +144 -0
- data/examples/deprecated/testtpane.rb +215 -0
- data/examples/deprecated/testtpane2.rb +145 -0
- data/examples/deprecated/testtpanetable.rb +203 -0
- data/examples/dirtree.rb +88 -0
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/experimental/testscroller.rb +117 -0
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +112 -0
- data/examples/multispl.rb +86 -0
- data/examples/newmessagebox.rb +131 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/qdfilechooser.rb +68 -0
- data/examples/rfe.rb +1239 -0
- data/examples/rfe_renderer.rb +121 -0
- data/examples/sqlc.rb +454 -0
- data/examples/sqlm.rb +437 -0
- data/examples/sqlt.rb +408 -0
- data/examples/status.txt +68 -0
- data/examples/table1.rb +24 -0
- data/examples/term2.rb +84 -0
- data/examples/test1.rb +239 -0
- data/examples/test2.rb +674 -0
- data/examples/testapp.rb +44 -0
- data/examples/testapp2.rb +58 -0
- data/examples/testchars.rb +137 -0
- data/examples/testcombo.rb +91 -0
- data/examples/testkeypress.rb +66 -0
- data/examples/testlistbox.rb +113 -0
- data/examples/testmenu.rb +101 -0
- data/examples/testmulticomp.rb +70 -0
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testmultispl.rb +199 -0
- data/examples/testree.rb +106 -0
- data/examples/testtable.rb +264 -0
- data/examples/testtabp.rb +107 -0
- data/examples/testtodo.rb +584 -0
- data/examples/testvimsplit.rb +112 -0
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/todo.db +0 -0
- data/examples/todo.yml +191 -0
- data/examples/viewtodo.rb +574 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/deprecated/rpad.rb +375 -0
- data/lib/rbcurse/deprecated/rscrollpane.rb +512 -0
- data/lib/rbcurse/deprecated/rsplitpane.rb +894 -0
- data/lib/rbcurse/deprecated/rsplitpane2.rb +1009 -0
- data/lib/rbcurse/deprecated/rviewport.rb +204 -0
- data/lib/rbcurse/deprecated/widgets/mapper.rb +130 -0
- data/lib/rbcurse/deprecated/widgets/rmessagebox.rb +348 -0
- data/lib/rbcurse/deprecated/widgets/rtabbedpane.rb +1158 -0
- data/lib/rbcurse/deprecated/widgets/rtabbedwindow.rb +167 -0
- data/lib/rbcurse/deprecated/widgets/scrollable.rb +301 -0
- data/lib/rbcurse/deprecated/widgets/stdscrwindow.rb +309 -0
- data/lib/ver/keyboard2.rb +170 -0
- data/test/test_rbcurse.rb +0 -0
- metadata +131 -9
data/examples/testree.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'rbcurse'
|
2
|
+
require 'rbcurse/core/widgets/rtree'
|
3
|
+
|
4
|
+
if $0 == __FILE__
|
5
|
+
$choice = ARGV[0].to_i || 1
|
6
|
+
class Tester
|
7
|
+
def initialize
|
8
|
+
acolor = $reversecolor
|
9
|
+
end
|
10
|
+
def run
|
11
|
+
@window = VER::Window.root_window
|
12
|
+
@form = Form.new @window
|
13
|
+
|
14
|
+
h = 20; w = 75; t = 3; l = 4
|
15
|
+
#$choice = 1
|
16
|
+
case $choice
|
17
|
+
when 1
|
18
|
+
root = TreeNode.new "ROOT"
|
19
|
+
subroot = TreeNode.new "subroot"
|
20
|
+
leaf1 = TreeNode.new "leaf 1"
|
21
|
+
leaf2 = TreeNode.new "leaf 2"
|
22
|
+
|
23
|
+
model = DefaultTreeModel.new root
|
24
|
+
#model.insert_node_into(subroot, root, 0)
|
25
|
+
#model.insert_node_into(leaf1, subroot, 0)
|
26
|
+
#model.insert_node_into(leaf2, subroot, 1)
|
27
|
+
root << subroot
|
28
|
+
subroot << leaf1 << leaf2
|
29
|
+
leaf1 << "leaf11"
|
30
|
+
leaf1 << "leaf12"
|
31
|
+
|
32
|
+
root.add "blocky", true do
|
33
|
+
add "block2"
|
34
|
+
add "block3" do
|
35
|
+
add "block31"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
39
|
+
|
40
|
+
when 2
|
41
|
+
|
42
|
+
# use an array to populate
|
43
|
+
# we need to do root_visible = false so you get just a list
|
44
|
+
model = %W[ ruby cobol jruby smalltalk fortran piethon purrl lithp ]
|
45
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
46
|
+
|
47
|
+
when 3
|
48
|
+
|
49
|
+
# use an Has to populate
|
50
|
+
#model = { :ruby => %W[ "jruby", "mri", "yarv", "rubinius", "macruby" ], :python => %W[ cpython jython laden-swallow ] }
|
51
|
+
model = { :ruby => [ "jruby", {:mri => %W[ 1.8.6 1.8.7]}, {:yarv => %W[1.9.1 1.9.2]}, "rubinius", "macruby" ], :python => %W[ cpython jython laden-swallow ] }
|
52
|
+
|
53
|
+
Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
|
54
|
+
#when 4
|
55
|
+
else
|
56
|
+
Tree.new @form, :row =>2, :col=>2, :height => 20, :width => 30 do
|
57
|
+
root "root" do
|
58
|
+
branch "hello" do
|
59
|
+
leaf "world"
|
60
|
+
end
|
61
|
+
branch "goodbyee" do
|
62
|
+
leaf "java"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
@help = "F1 to quit. Pass command-line argument 1,2,3,4 #{$0} "
|
71
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => 1, "col" => 2, "color" => "yellow"}
|
72
|
+
@form.repaint
|
73
|
+
@window.wrefresh
|
74
|
+
Ncurses::Panel.update_panels
|
75
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
76
|
+
ret = @form.handle_key(ch)
|
77
|
+
@window.wrefresh
|
78
|
+
if ret == :UNHANDLED
|
79
|
+
str = keycode_tos ch
|
80
|
+
$log.debug " UNHANDLED #{str} by Vim #{ret} "
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
@window.destroy
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
include RubyCurses
|
89
|
+
include RubyCurses::Utils
|
90
|
+
# Initialize curses
|
91
|
+
begin
|
92
|
+
# XXX update with new color and kb
|
93
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
94
|
+
$log = Logger.new("rbc13.log")
|
95
|
+
$log.level = Logger::DEBUG
|
96
|
+
n = Tester.new
|
97
|
+
n.run
|
98
|
+
rescue => ex
|
99
|
+
ensure
|
100
|
+
VER::stop_ncurses
|
101
|
+
p ex if ex
|
102
|
+
puts(ex.backtrace.join("\n")) if ex
|
103
|
+
$log.debug( ex) if ex
|
104
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
require 'rbcurse'
|
2
|
+
require 'rbcurse/core/widgets/rcombo'
|
3
|
+
require 'rbcurse/extras/widgets/rtable'
|
4
|
+
require 'rbcurse/extras/include/celleditor'
|
5
|
+
#require 'rbcurse/table/tablecellrenderer'
|
6
|
+
require 'rbcurse/extras/include/comboboxcellrenderer'
|
7
|
+
require 'rbcurse/core/include/action'
|
8
|
+
|
9
|
+
##
|
10
|
+
# a renderer which paints alternate lines with
|
11
|
+
# another color, for people with poor taste.
|
12
|
+
class MyRenderer < TableCellRenderer
|
13
|
+
def initialize text="", config={}, &block
|
14
|
+
super
|
15
|
+
@orig_bgcolor = @bgcolor
|
16
|
+
@orig_color = @color
|
17
|
+
end
|
18
|
+
def repaint graphic, r=@row,c=@col, value=@text, focussed=false, selected=false
|
19
|
+
@bgcolor = @orig_bgcolor
|
20
|
+
@color = @orig_color
|
21
|
+
if !focussed and !selected
|
22
|
+
@bgcolor = r % 2 == 0 ? "green" : @orig_bgcolor
|
23
|
+
@color = r % 2 == 0 ? "black" : @orig_color
|
24
|
+
end
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
if $0 == __FILE__
|
29
|
+
include RubyCurses
|
30
|
+
include RubyCurses::Utils
|
31
|
+
|
32
|
+
begin
|
33
|
+
# Initialize curses
|
34
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
35
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
36
|
+
$log.level = Logger::DEBUG
|
37
|
+
|
38
|
+
@window = VER::Window.root_window
|
39
|
+
|
40
|
+
catch(:close) do
|
41
|
+
colors = Ncurses.COLORS
|
42
|
+
$log.debug "START #{colors} colors ---------"
|
43
|
+
@form = Form.new @window
|
44
|
+
@window.printstring 0,30,"Demo of Ruby Curses Table: Edit, Resize, Insert, Move, Delete Row/Col", $datacolor
|
45
|
+
r = 1; c = 30;
|
46
|
+
data = [["You're beautiful",3,"James Blunt",3.21, true, "WIP"],
|
47
|
+
["Where are you",3,"London Beat",3.47, true, "WIP"],
|
48
|
+
["I'll always love my mama",92,"Intruders",412, true, "Fin"],
|
49
|
+
["I believe in love",4,"Paula Cole",110.0, false, "Cancel"],
|
50
|
+
["Red Sky at night",4,"Dave Gilmour",102.72, false, "Postp"],
|
51
|
+
["Midnight and you",8,"Barry White",12.72, false, "Todo"],
|
52
|
+
["Let the music play",9,"Barry White",12.2, false, "WIP"],
|
53
|
+
["I swear",nil,"Boyz II Men",112.7, true, "Cancel"],
|
54
|
+
["Believe",9,"Elton John",12.2, false, "Todo"],
|
55
|
+
["Private Dancer",9,"Tina Turner",12.2, false, "Todo"],
|
56
|
+
["Liberian Girl",9,"Michael Jackson",12.2, false, "Todo"],
|
57
|
+
["Like a prayer",163,"Charlotte Perrelli",5.4, false, "WIP"]]
|
58
|
+
|
59
|
+
colnames = %w[ Song Cat Artist Ratio Flag Status]
|
60
|
+
statuses = ["Todo", "WIP", "Fin", "Cancel", "Postp"]
|
61
|
+
|
62
|
+
texta = Table.new @form do
|
63
|
+
name "mytext"
|
64
|
+
row r
|
65
|
+
col c
|
66
|
+
width 78
|
67
|
+
height 15
|
68
|
+
#title "A Table"
|
69
|
+
#title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
70
|
+
cell_editing_allowed true
|
71
|
+
editing_policy :EDITING_AUTO
|
72
|
+
set_data data, colnames
|
73
|
+
end
|
74
|
+
sel_col = Variable.new 0
|
75
|
+
sel_col.value = 0
|
76
|
+
tcm = texta.get_table_column_model
|
77
|
+
selcolname = texta.get_column_name sel_col.value
|
78
|
+
#
|
79
|
+
## key bindings fo texta
|
80
|
+
# column widths
|
81
|
+
tcm.column(0).width 24
|
82
|
+
tcm.column(1).width 5
|
83
|
+
tcm.column(2).width 18
|
84
|
+
#tcm.column(2).editable false
|
85
|
+
tcm.column(3).width 7
|
86
|
+
tcm.column(4).width 5
|
87
|
+
tcm.column(5).width 8
|
88
|
+
texta.configure() do
|
89
|
+
bind_key(330) { texta.remove_column(tcm.column(texta.focussed_col)) rescue "" }
|
90
|
+
bind_key(?+) {
|
91
|
+
acolumn = texta.get_column selcolname
|
92
|
+
w = acolumn.width + 1
|
93
|
+
acolumn.width w
|
94
|
+
#texta.table_structure_changed
|
95
|
+
}
|
96
|
+
bind_key(?-) {
|
97
|
+
acolumn = texta.get_column selcolname
|
98
|
+
w = acolumn.width - 1
|
99
|
+
if w > 3
|
100
|
+
acolumn.width w
|
101
|
+
#texta.table_structure_changed
|
102
|
+
end
|
103
|
+
}
|
104
|
+
bind_key(?>) {
|
105
|
+
colcount = tcm.column_count-1
|
106
|
+
#texta.move_column sel_col.value, sel_col.value+1 unless sel_col.value == colcount
|
107
|
+
col = texta.focussed_col
|
108
|
+
texta.move_column col, col+1 unless col == colcount
|
109
|
+
}
|
110
|
+
bind_key(?<) {
|
111
|
+
col = texta.focussed_col
|
112
|
+
texta.move_column col, col-1 unless col == 0
|
113
|
+
#texta.move_column sel_col.value, sel_col.value-1 unless sel_col.value == 0
|
114
|
+
}
|
115
|
+
#bind_key(KEY_RIGHT) { sel_col.value = sel_col.value+1; current_column sel_col.value}
|
116
|
+
#bind_key(KEY_LEFT) { sel_col.value = sel_col.value-1;current_column sel_col.value}
|
117
|
+
end
|
118
|
+
keylabel = RubyCurses::Label.new @form, {'text' => "", "row" => r+16, "col" => c, "color" => "yellow", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
|
119
|
+
eventlabel = RubyCurses::Label.new @form, {'text' => "Events:", "row" => r+19, "col" => c, "color" => "white", "bgcolor"=>"blue", "display_length"=>60, "height"=>2}
|
120
|
+
|
121
|
+
# report some events
|
122
|
+
texta.table_model.bind(:TABLE_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
|
123
|
+
texta.get_table_column_model.bind(:TABLE_COLUMN_MODEL_EVENT){|e| eventlabel.text = "Event: #{e}"}
|
124
|
+
texta.bind(:TABLE_TRAVERSAL_EVENT){|e| eventlabel.text = "Event: #{e}"}
|
125
|
+
|
126
|
+
@help = "C-q to quit. M-Tab (next col) C-n (Pg Dn), C-p (Pg Up), M-0 Top, M-9 End, C-x (select). Columns:- Narrow, + expand, > < switch"
|
127
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => Ncurses.LINES-3, "col" => 2, "color" => "yellow", "height"=>2}
|
128
|
+
|
129
|
+
str_renderer = TableCellRenderer.new ""
|
130
|
+
num_renderer = TableCellRenderer.new "", { "justify" => :right }
|
131
|
+
bool_renderer = CheckBoxCellRenderer.new "", {"parent" => texta, "display_length"=>5}
|
132
|
+
combo_renderer = RubyCurses::ComboBoxCellRenderer.new nil, {"parent" => texta, "display_length"=> 8}
|
133
|
+
combo_editor = RubyCurses::CellEditor.new(RubyCurses::ComboBox.new nil, {"focusable"=>false, "visible"=>false, "list"=>statuses, "display_length"=>8})
|
134
|
+
texta.set_default_cell_renderer_for_class "String", str_renderer
|
135
|
+
texta.set_default_cell_renderer_for_class "Fixnum", num_renderer
|
136
|
+
texta.set_default_cell_renderer_for_class "Float", num_renderer
|
137
|
+
texta.set_default_cell_renderer_for_class "TrueClass", bool_renderer
|
138
|
+
texta.set_default_cell_renderer_for_class "FalseClass", bool_renderer
|
139
|
+
texta.get_table_column_model.column(5).cell_editor = combo_editor
|
140
|
+
=begin
|
141
|
+
field = Field.new @form do
|
142
|
+
name "value"
|
143
|
+
row r+18
|
144
|
+
col c
|
145
|
+
display_length 30
|
146
|
+
bgcolor "cyan"
|
147
|
+
set_label Label.new @form, {'text' => "Value", 'mnemonic'=> 'V'}
|
148
|
+
# bind :ENTER do $editing = true end
|
149
|
+
# bind :LEAVE do $editing = false end
|
150
|
+
end
|
151
|
+
=end
|
152
|
+
buttrow = r+21 #Ncurses.LINES-4
|
153
|
+
b_newrow = Button.new @form do
|
154
|
+
text "&New"
|
155
|
+
row buttrow
|
156
|
+
col c
|
157
|
+
bind(:ENTER) { eventlabel.text "New button adds a new row at the bottom " }
|
158
|
+
end
|
159
|
+
tm = texta.table_model
|
160
|
+
b_newrow.command {
|
161
|
+
cc = texta.get_table_column_model.column_count
|
162
|
+
# need to get datatypes etc, this is just a junk test
|
163
|
+
tmp=[]
|
164
|
+
#0.upto(cc-1) { tmp << "" }
|
165
|
+
0.upto(cc-1) { tmp << nil }
|
166
|
+
tm << tmp
|
167
|
+
#texta.table_data_changed
|
168
|
+
keylabel.text = "Added a row"
|
169
|
+
alert("Added a row at bottom of table")
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
# using ampersand to set mnemonic
|
174
|
+
b_delrow = Button.new @form do
|
175
|
+
text "&Delete"
|
176
|
+
row buttrow
|
177
|
+
col c+10
|
178
|
+
bind(:ENTER) { eventlabel.text "Deletes focussed row" }
|
179
|
+
end
|
180
|
+
b_delrow.command { |form|
|
181
|
+
row = texta.focussed_row
|
182
|
+
if confirm("Do your really want to delete row #{row}?")== :YES
|
183
|
+
tm.delete_at row
|
184
|
+
#texta.table_data_changed
|
185
|
+
else
|
186
|
+
#$message.value = "Quit aborted"
|
187
|
+
end
|
188
|
+
}
|
189
|
+
b_change = Button.new @form do
|
190
|
+
text "&Lock"
|
191
|
+
row buttrow
|
192
|
+
col c+20
|
193
|
+
command {
|
194
|
+
r = texta.focussed_row
|
195
|
+
c = sel_col.value
|
196
|
+
#$log.debug " Update gets #{field.getvalue.class}"
|
197
|
+
#texta.set_value_at(r, c, field.getvalue)
|
198
|
+
toggle = texta.column(texta.focussed_col()).editable
|
199
|
+
if toggle.nil? or toggle==true
|
200
|
+
toggle = false
|
201
|
+
text "Un&lock"
|
202
|
+
else
|
203
|
+
toggle = true
|
204
|
+
text "&Lock "
|
205
|
+
end
|
206
|
+
eventlabel.text "Set column #{texta.focussed_col()} editable to #{toggle}"
|
207
|
+
texta.column(texta.focussed_col()).editable toggle
|
208
|
+
alert("Set column #{texta.focussed_col()} editable to #{toggle}")
|
209
|
+
}
|
210
|
+
bind(:ENTER) { eventlabel.text "Toggles editable state of current column " }
|
211
|
+
end
|
212
|
+
b_insert = Button.new @form do
|
213
|
+
text "&Insert"
|
214
|
+
row buttrow
|
215
|
+
col c+32
|
216
|
+
command {
|
217
|
+
# this does not trigger a data change since we are not updating model. so update
|
218
|
+
# on pressing up or down
|
219
|
+
#0.upto(100) { |i| data << ["test", rand(100), "abc:#{i}", rand(100)/2.0]}
|
220
|
+
#texta.table_data_changed
|
221
|
+
}
|
222
|
+
bind(:ENTER) { eventlabel.text "Does nothing " }
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
@form.repaint
|
227
|
+
@window.wrefresh
|
228
|
+
Ncurses::Panel.update_panels
|
229
|
+
while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
|
230
|
+
begin
|
231
|
+
colcount = tcm.column_count-1
|
232
|
+
s = keycode_tos ch
|
233
|
+
keylabel.text = "Pressed #{ch} , #{s}"
|
234
|
+
@form.handle_key(ch)
|
235
|
+
|
236
|
+
sel_col.value = tcm.column_count-1 if sel_col.value > tcm.column_count-1
|
237
|
+
sel_col.value = 0 if sel_col.value < 0
|
238
|
+
selcolname = texta.get_column_name sel_col.value
|
239
|
+
keylabel.text = "Pressed #{ch} , #{s}. Column selected #{texta.focussed_col}: Width:#{tcm.column(sel_col.value).width} #{selcolname}. Focussed Row: #{texta.focussed_row}, Rows: #{texta.table_model.row_count}, Cols: #{colcount}"
|
240
|
+
s = texta.get_value_at(texta.focussed_row, texta.focussed_col)
|
241
|
+
#s = s.to_s
|
242
|
+
## $log.debug " updating Field #{s}, #{s.class}"
|
243
|
+
## field.set_buffer s unless field.state == :HIGHLIGHTED # $editing
|
244
|
+
|
245
|
+
@form.repaint
|
246
|
+
@window.wrefresh
|
247
|
+
rescue => ex
|
248
|
+
$log.debug( ex) if ex
|
249
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
250
|
+
#alert ex.to_s
|
251
|
+
textdialog ex
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
rescue => ex
|
256
|
+
ensure
|
257
|
+
@window.destroy if !@window.nil?
|
258
|
+
VER::stop_ncurses
|
259
|
+
p ex if ex
|
260
|
+
p(ex.backtrace.join("\n")) if ex
|
261
|
+
$log.debug( ex) if ex
|
262
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'rbcurse'
|
3
|
+
#require 'rbcurse/rtabbedpane'
|
4
|
+
require 'rbcurse/rtabbedwindow'
|
5
|
+
|
6
|
+
class TestTabbedPane
|
7
|
+
def initialize
|
8
|
+
acolor = $reversecolor
|
9
|
+
#$config_hash ||= {}
|
10
|
+
end
|
11
|
+
def run
|
12
|
+
$config_hash ||= Variable.new Hash.new
|
13
|
+
#configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
|
14
|
+
@tw = RubyCurses::TabbedWindow.new nil do
|
15
|
+
height 18
|
16
|
+
width 60
|
17
|
+
row 5
|
18
|
+
col 20
|
19
|
+
button_type :ok
|
20
|
+
end
|
21
|
+
@tp = @tw.tabbed_pane
|
22
|
+
@tab1 = @tw.add_tab "&Language"
|
23
|
+
f1 = @tp.form @tab1
|
24
|
+
#$radio = Variable.new
|
25
|
+
radio1 = RadioButton.new f1 do
|
26
|
+
#variable $radio
|
27
|
+
variable $config_hash
|
28
|
+
name "radio1"
|
29
|
+
text "ruby"
|
30
|
+
value "ruby"
|
31
|
+
color "red"
|
32
|
+
row 4
|
33
|
+
col 2
|
34
|
+
end
|
35
|
+
radio2 = RadioButton.new f1 do
|
36
|
+
#variable $radio
|
37
|
+
variable $config_hash
|
38
|
+
name "radio1"
|
39
|
+
text "jruby"
|
40
|
+
value "jruby"
|
41
|
+
color "green"
|
42
|
+
row 5
|
43
|
+
col 2
|
44
|
+
end
|
45
|
+
radio3 = RadioButton.new f1 do
|
46
|
+
#variable $radio
|
47
|
+
variable $config_hash
|
48
|
+
name "radio1"
|
49
|
+
text "macruby"
|
50
|
+
value "macruby"
|
51
|
+
color "cyan"
|
52
|
+
row 6
|
53
|
+
col 2
|
54
|
+
end
|
55
|
+
@tab2 = @tw.add_tab "&Settings"
|
56
|
+
#f2 = @tab2.form
|
57
|
+
f2 = @tp.form @tab2
|
58
|
+
r = 2
|
59
|
+
butts = [ "Use &HTTP/1.0", "Use &frames", "&Use SSL" ]
|
60
|
+
bcodes = %w[ HTTP, FRAMES, SSL ]
|
61
|
+
butts.each_with_index do |t, i|
|
62
|
+
RubyCurses::CheckBox.new f2 do
|
63
|
+
text butts[i]
|
64
|
+
variable $config_hash
|
65
|
+
name bcodes[i]
|
66
|
+
row r+i
|
67
|
+
col 4
|
68
|
+
end
|
69
|
+
end
|
70
|
+
@tab3 = @tw.add_tab "&Editors"
|
71
|
+
#f3 = @tab3.form
|
72
|
+
f3 = @tp.form @tab3
|
73
|
+
butts = %w[ &Vim E&macs &Jed &Other ]
|
74
|
+
bcodes = %w[ VIM EMACS JED OTHER]
|
75
|
+
row = 3
|
76
|
+
butts.each_with_index do |name, i|
|
77
|
+
RubyCurses::CheckBox.new f3 do
|
78
|
+
text name
|
79
|
+
variable $config_hash
|
80
|
+
name bcodes[i]
|
81
|
+
row row
|
82
|
+
col 4
|
83
|
+
end
|
84
|
+
row +=1
|
85
|
+
end
|
86
|
+
@tw.show
|
87
|
+
@tw.handle_keys
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if $0 == __FILE__
|
91
|
+
# Initialize curses
|
92
|
+
begin
|
93
|
+
# XXX update with new color and kb
|
94
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
95
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
96
|
+
$log.level = Logger::DEBUG
|
97
|
+
n = TestTabbedPane.new
|
98
|
+
n.run
|
99
|
+
rescue => ex
|
100
|
+
ensure
|
101
|
+
VER::stop_ncurses
|
102
|
+
p ex if ex
|
103
|
+
p(ex.backtrace.join("\n")) if ex
|
104
|
+
$log.debug( ex) if ex
|
105
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
106
|
+
end
|
107
|
+
end
|