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
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rbcurse/app'
|
2
|
+
require 'rbcurse/extras/multiform'
|
3
|
+
|
4
|
+
App.new do
|
5
|
+
header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "My Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
6
|
+
message "Press F10 to exit from here, F1 for help, F2 for menu"
|
7
|
+
|
8
|
+
stack :margin_top => 2, :margin => 5, :width => 30 do
|
9
|
+
|
10
|
+
mf = MultiForm.new @form do
|
11
|
+
row 2
|
12
|
+
col 2
|
13
|
+
height 15
|
14
|
+
width 50
|
15
|
+
|
16
|
+
add_form "first" do |f|
|
17
|
+
f1 = Field.new f, :name => "f1", :row => 1, :col => 10, :display_length => 15, :color => :red, :bgcolor => :white
|
18
|
+
f2 = Field.new f, :name => "f2", :row => 2, :col => 10, :display_length => 15, :color => :cyan, :bgcolor => :red
|
19
|
+
f1.set_buffer "ABCD"
|
20
|
+
f2.set_buffer "1234a"
|
21
|
+
#add_to(0, f1)
|
22
|
+
#add_to(0, f2)
|
23
|
+
end
|
24
|
+
add_form "second" do |f|
|
25
|
+
f1 = Field.new f, :name => "f1", :row => 2, :col => 10, :display_length => 15, :color => :white, :bgcolor => :blue
|
26
|
+
f2 = Field.new f, :name => "F2", :row => 4, :col => 10, :display_length => 15, :color => :yellow, :bgcolor => :blue
|
27
|
+
f1.set_buffer "alpha"
|
28
|
+
f2.set_buffer "roger"
|
29
|
+
#add_to(0, f1)
|
30
|
+
#add_to(0, f2)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end # stack
|
35
|
+
end # app
|
@@ -26,7 +26,7 @@ if $0 == __FILE__
|
|
26
26
|
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
27
27
|
$log.level = Logger::DEBUG
|
28
28
|
|
29
|
-
|
29
|
+
#@window = VER::Window.root_window
|
30
30
|
# Initialize few color pairs
|
31
31
|
# Create the window to be associated with the form
|
32
32
|
# Un post form and free the memory
|
@@ -43,7 +43,6 @@ if $0 == __FILE__
|
|
43
43
|
@form.set_pad_dimensions(row, col, h, w)
|
44
44
|
# dimensions of screen area onto which pad will paint
|
45
45
|
@form.should_print_border(true)
|
46
|
-
#@buttonpad = @form.create_pad
|
47
46
|
|
48
47
|
#@window.print_border_only 0, 0, 20+2, 100+2, $datacolor
|
49
48
|
@window.printstring 0, 30, "Demo of ScrollForm ", $normalcolor, 'reverse'
|
@@ -89,25 +88,8 @@ if $0 == __FILE__
|
|
89
88
|
# a special case required since another form (combo popup also modifies)
|
90
89
|
$message.update_command() { message_label.repaint }
|
91
90
|
|
92
|
-
#@form.by_name["line"].display_length = 3
|
93
|
-
#@form.by_name["line"].maxlen = 3
|
94
|
-
#@form.by_name["line"].set_buffer "24"
|
95
91
|
@form.by_name["detail"].set_buffer "This form has more components"
|
96
92
|
@form.by_name["descr"].set_buffer "Use M-l/h and M-n/p for scrolling"
|
97
|
-
#@form.by_name["name"].set_focusable(false)
|
98
|
-
#@form.by_name["line"].chars_allowed = /\d/
|
99
|
-
##@form.by_name["regex"].type(:ALPHA)
|
100
|
-
#@form.by_name["regex"].valid_regex(/^[A-Z][a-z]*/)
|
101
|
-
#@form.by_name["regex"].set_buffer "SYNOP"
|
102
|
-
#@form.by_name["regex"].display_length = 10
|
103
|
-
#@form.by_name["regex"].maxlen = 20
|
104
|
-
##@form.by_name["regex"].bgcolor 'cyan'
|
105
|
-
#@form.by_name["password"].set_buffer ""
|
106
|
-
#@form.by_name["password"].show '*'
|
107
|
-
#@form.by_name["password"].color 'red'
|
108
|
-
##@form.by_name["password"].bgcolor 'blue'
|
109
|
-
#@form.by_name["password"].values(%w[scotty tiger secret pass qwerty])
|
110
|
-
#@form.by_name["password"].null_allowed true
|
111
93
|
|
112
94
|
# a form level event, whenever any widget is focussed
|
113
95
|
@form.bind(:ENTER) { |f| f.label && f.label.bgcolor = 'red' if f.respond_to? :label}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# #!/usr/bin/env ruby -w
|
2
|
+
=begin
|
3
|
+
* Name : teststackflow.rb
|
4
|
+
* Description : to test Container2.rb (to be renamed)
|
5
|
+
* :
|
6
|
+
* Author : rkumar http://github.com/rkumar/rbcurse/
|
7
|
+
* Date : 25.10.11 - 12:57
|
8
|
+
* License :
|
9
|
+
* Last update : Use ,,L to update
|
10
|
+
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
11
|
+
|
12
|
+
=end
|
13
|
+
|
14
|
+
|
15
|
+
if __FILE__ == $PROGRAM_NAME
|
16
|
+
require 'rbcurse/app'
|
17
|
+
require 'rbcurse/rlistbox'
|
18
|
+
require 'rbcurse/experimental/stackflow'
|
19
|
+
App.new do
|
20
|
+
|
21
|
+
lb = Listbox.new nil, :list => ["borodin","berlioz","bernstein","balakirev", "elgar"] , :name => "mylist"
|
22
|
+
lb1 = Listbox.new nil, :list => ["bach","beethoven","mozart","gorecki", "chopin","wagner","grieg","holst"] , :name => "mylist1"
|
23
|
+
|
24
|
+
lb2 = Listbox.new nil, :list => `gem list --local`.split("\n") , :name => "mylist2"
|
25
|
+
|
26
|
+
alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
|
27
|
+
str = "Hello, people of Earth.\nI am HAL, a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-e/C-n/C-p\n"
|
28
|
+
str << alist.join("\n")
|
29
|
+
require 'rbcurse/rtextview'
|
30
|
+
tv = TextView.new nil, :name => "text"
|
31
|
+
tv.set_content str
|
32
|
+
=begin
|
33
|
+
f1 = field "name", :maxlen => 20, :display_length => 20, :bgcolor => :white,
|
34
|
+
:color => :black, :text => "abc", :label => " Name: ", :label_color_pair => @datacolor
|
35
|
+
f2 = field "email", :display_length => 20, :bgcolor => :white,
|
36
|
+
:color => :blue, :text => "me@google.com", :label => "Email: ", :label_color_pair => @datacolor
|
37
|
+
f3 = radio :group => :grp, :text => "red", :value => "RED", :color => :red
|
38
|
+
f4 = radio :group => :grp, :text => "blue", :value => "BLUE", :color => :blue
|
39
|
+
f5 = radio :group => :grp, :text => "green", :value => "GREEN", :color => :green
|
40
|
+
=end
|
41
|
+
|
42
|
+
f1 = Field.new nil, :maxlen => 20, :display_length => 20, :bgcolor => :white,
|
43
|
+
:color => :black, :text => "abc", :label => " Name: ", :label_color_pair => @datacolor,
|
44
|
+
:valid_regex => /[A-Z][a-z]*/
|
45
|
+
f2 = Field.new nil, :display_length => 20, :bgcolor => :white,
|
46
|
+
:color => :blue, :text => "me@google.com", :label => "Email: ", :label_color_pair => @datacolor
|
47
|
+
f3 = Field.new nil, :display_length => 20, :bgcolor => :white,
|
48
|
+
:color => :blue, :text => "24", :label => "Age: ", :label_color_pair => @datacolor,
|
49
|
+
:valid_range => (20..100)
|
50
|
+
r = StackFlow.new @form, :row => 1, :col => 2, :width => 80, :height => 25, :title => "Stack n Flow with margins" do
|
51
|
+
#stack :margin_top => 2, :margin_left => 1 do
|
52
|
+
flow :margin_top => 0, :margin_left => 2, :margin_right => 0, :orientation => :right do #:weight => 49 do
|
53
|
+
add tv, :weight => 40
|
54
|
+
add lb2 , :weight => 50
|
55
|
+
end
|
56
|
+
stack :margin_top => 0, :orientation => :bottom do #stack :height => 12, :width => 78 do
|
57
|
+
add lb, :weight => 40, :margin_left => 1
|
58
|
+
add lb1 , :weight => 40
|
59
|
+
#add f1
|
60
|
+
#stack :weight => 30 do
|
61
|
+
#add f1
|
62
|
+
#add f2
|
63
|
+
#add f3
|
64
|
+
end
|
65
|
+
#end # stack
|
66
|
+
end # r
|
67
|
+
def increase_height
|
68
|
+
@r.height += 1
|
69
|
+
@r.repaint_all(true)
|
70
|
+
end
|
71
|
+
def increase_width
|
72
|
+
@r.width += 1
|
73
|
+
@r.repaint_all(true)
|
74
|
+
end
|
75
|
+
@r = r
|
76
|
+
@r.bind_key(?\M-w) {increase_width}
|
77
|
+
@r.bind_key(?\M-h) {increase_height}
|
78
|
+
@r.bind_key(0) {
|
79
|
+
f = @r.item_for tv
|
80
|
+
f1 = @r.item_for lb2
|
81
|
+
p = @r.parent_of tv
|
82
|
+
p1 = @r.parent_of lb2
|
83
|
+
$log.debug "XXX: ITEM_FOR tv is #{f}, #{f1} #{p} , #{p1} "
|
84
|
+
@ctr ||= 0
|
85
|
+
case @ctr
|
86
|
+
when 0
|
87
|
+
@r.components[0].orientation = :left
|
88
|
+
when 1
|
89
|
+
@r.components[0].orientation = :right
|
90
|
+
when 2
|
91
|
+
@r.components[1].orientation = :top
|
92
|
+
when 3
|
93
|
+
@r.components[1].orientation = :bottom
|
94
|
+
else
|
95
|
+
@ctr = -1
|
96
|
+
end
|
97
|
+
$status_message.value =" Flow: #{@r.components[0].orientation} | Stack #{@r.components[1].orientation}. Use C-Space to change "
|
98
|
+
@r.repaint_all(true)
|
99
|
+
@ctr += 1
|
100
|
+
|
101
|
+
}
|
102
|
+
$status_message.value =" Flow: #{@r.components[0].orientation} | Stack #{@r.components[1].orientation}. Use Ctrl-Space to change "
|
103
|
+
|
104
|
+
#r.add(f1)
|
105
|
+
#r.add(f2)
|
106
|
+
#r.add(f3,f4,f5)
|
107
|
+
#sl = status_line
|
108
|
+
|
109
|
+
st = status_line
|
110
|
+
end # app
|
111
|
+
end # if
|
data/examples/menu1.rb
CHANGED
data/examples/multispl.rb
CHANGED
@@ -2,13 +2,13 @@ require 'rbcurse/app'
|
|
2
2
|
|
3
3
|
App.new do
|
4
4
|
header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "MultiSplit Demo", :text_right =>"ColumnBrowse pattern"
|
5
|
-
message_row(27)
|
5
|
+
#message_row(27)
|
6
6
|
message "<TAB> and <BTAB> "
|
7
7
|
oo = :HORIZONTAL_SPLIT
|
8
8
|
oo = :VERTICAL_SPLIT
|
9
9
|
|
10
|
-
stack :margin_top =>
|
11
|
-
splp = multisplit "outer", :height =>
|
10
|
+
stack :margin_top => 2, :margin => 1, :width => FFI::NCurses.COLS-2 do
|
11
|
+
splp = multisplit "outer", :height => FFI::NCurses.LINES - 3 , :split_count => 2, :orientation => oo do |s|
|
12
12
|
#s.suppress_borders = false
|
13
13
|
lb = list_box "Classes",:list => `ri -f bs`.split("\n")
|
14
14
|
s.add lb
|
@@ -48,7 +48,7 @@ App.new do
|
|
48
48
|
}
|
49
49
|
|
50
50
|
|
51
|
-
blank
|
51
|
+
#blank
|
52
52
|
flow do
|
53
53
|
#toggle :onvalue => "Vertical", :offvalue => "Horizontal", :value => true do |e|
|
54
54
|
#message "pressed #{e.state}"
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# this is a test program, tests out tabbed panes. type F1 to exit
|
2
|
+
#
|
3
|
+
require 'rbcurse'
|
4
|
+
require 'rbcurse/extras/newmessagebox'
|
5
|
+
|
6
|
+
def alertme mess, config={}
|
7
|
+
|
8
|
+
_title = config[:title] || "Alert"
|
9
|
+
tp = NewMessagebox.new config do
|
10
|
+
title _title
|
11
|
+
button_type :ok
|
12
|
+
message mess
|
13
|
+
#text mess
|
14
|
+
end
|
15
|
+
tp.run
|
16
|
+
end
|
17
|
+
def textdialog mess, config={}
|
18
|
+
config[:title] ||= "Alert"
|
19
|
+
tp = NewMessagebox.new config do
|
20
|
+
button_type :ok
|
21
|
+
text mess
|
22
|
+
end
|
23
|
+
tp.run
|
24
|
+
end
|
25
|
+
#
|
26
|
+
def newget_string label, config={}
|
27
|
+
config[:title] ||= "Entry"
|
28
|
+
label_config = config[:label_config] || {}
|
29
|
+
label_config[:row] ||= 2
|
30
|
+
label_config[:col] ||= 2
|
31
|
+
label_config[:text] = label
|
32
|
+
|
33
|
+
field_config = config[:field_config] || {}
|
34
|
+
field_config[:row] ||= 3
|
35
|
+
field_config[:col] ||= 2
|
36
|
+
field_config[:attr] = :reverse
|
37
|
+
field_config[:maxlen] ||= config[:maxlen]
|
38
|
+
field_config[:default] ||= config[:default]
|
39
|
+
#field_config[:display_length] ||= 50 # i want it to extend since i don't know the actual width
|
40
|
+
field_config[:width] ||= 50 # i want it to extend since i don't know the actual width
|
41
|
+
|
42
|
+
tp = NewMessagebox.new config do
|
43
|
+
button_type :ok_cancel
|
44
|
+
item Label.new nil, label_config
|
45
|
+
item Field.new nil, field_config
|
46
|
+
end
|
47
|
+
tp.run
|
48
|
+
end
|
49
|
+
include RubyCurses
|
50
|
+
class SetupMessagebox
|
51
|
+
def run
|
52
|
+
$config_hash ||= Variable.new Hash.new
|
53
|
+
#configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
|
54
|
+
|
55
|
+
#tp = NewMessagebox.new :row => 3, :col => 7, :width => 60, :height => 20 , :color => :white, :bgcolor => :blue do
|
56
|
+
tp = NewMessagebox.new :color => :white, :bgcolor => :blue do
|
57
|
+
title "User Setup"
|
58
|
+
button_type :ok_apply_cancel
|
59
|
+
item Field.new nil, :row => 2, :col => 2, :text => "enter your name", :label => ' Name: '
|
60
|
+
item Field.new nil, :row => 3, :col => 2, :text => "enter your email", :label => 'Email: '
|
61
|
+
r = 4
|
62
|
+
item Label.new nil, :text => "Text", :row => r+1, :col => 2, :attr => :bold
|
63
|
+
item CheckBox.new nil, :row => r+2, :col => 2, :text => "Antialias text"
|
64
|
+
item CheckBox.new nil, :row => r+3, :col => 2, :text => "Use bold fonts"
|
65
|
+
item CheckBox.new nil, :row => r+4, :col => 2, :text => "Allow blinking text"
|
66
|
+
item CheckBox.new nil, :row => r+5, :col => 2, :text => "Display ANSI Colors"
|
67
|
+
=begin
|
68
|
+
item Label.new nil, :text => "Cursor", :row => 7, :col => 2, :attr => 'bold'
|
69
|
+
$config_hash.set_value Variable.new, :cursor
|
70
|
+
item RadioButton.new nil, :row => 8, :col => 2, :text => "Block", :value => "block", :variable => $config_hash[:cursor]
|
71
|
+
item RadioButton.new nil, :row => 9, :col => 2, :text => "Blink", :value => "blink", :variable => $config_hash[:cursor]
|
72
|
+
item RadioButton.new nil, :row => 10, :col => 2, :text => "Underline", :value => "underline", :variable => $config_hash[:cursor]
|
73
|
+
end
|
74
|
+
tab "&Term" do
|
75
|
+
|
76
|
+
item Label.new nil, :text => "Arrow Key in Combos", :row => 2, :col => 2, :attr => 'bold'
|
77
|
+
x = Variable.new
|
78
|
+
$config_hash.set_value x, :term
|
79
|
+
item RadioButton.new nil, :row => 3, :col => 2, :text => "ignore", :value => "ignore", :variable => $config_hash[:term]
|
80
|
+
item RadioButton.new nil, :row => 4, :col => 2, :text => "popup", :value => "popup", :variable => $config_hash[:term]
|
81
|
+
item RadioButton.new nil, :row => 5, :col => 2, :text => "next", :value => "next", :variable => $config_hash[:term]
|
82
|
+
cb = ComboBox.new nil, :row => 7, :col => 2, :display_length => 15,
|
83
|
+
:list => %w[xterm xterm-color xterm-256color screen vt100 vt102],
|
84
|
+
:label => "Declare terminal as: "
|
85
|
+
#radio.update_command() {|rb| ENV['TERM']=rb.value }
|
86
|
+
item cb
|
87
|
+
x.update_command do |rb|
|
88
|
+
cb.arrow_key_policy=rb.value.to_sym
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
tab "Conta&iner" do
|
93
|
+
item r
|
94
|
+
end
|
95
|
+
# tell tabbedpane what to do if a button is pressed (ok/apply/cancel)
|
96
|
+
=end
|
97
|
+
command do |eve|
|
98
|
+
case eve.event
|
99
|
+
when 0,2 # ok cancel
|
100
|
+
newget_string "Enter name: ", :default => "john", :maxlen => 50
|
101
|
+
alertme "user pressed button index:#{eve.event}, #{eve.action_command} "
|
102
|
+
throw :close, eve.event
|
103
|
+
when 1 # apply
|
104
|
+
textdialog "user pressed apply: #{eve.to_s.length} : #{eve} "
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
tp.run
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
if $0 == __FILE__
|
113
|
+
# Initialize curses
|
114
|
+
begin
|
115
|
+
# XXX update with new color and kb
|
116
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
117
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
118
|
+
$log.level = Logger::DEBUG
|
119
|
+
tp = SetupMessagebox.new()
|
120
|
+
buttonindex = tp.run
|
121
|
+
$log.debug "XXX: MESSAGEBOX retirned #{buttonindex} "
|
122
|
+
rescue => ex
|
123
|
+
ensure
|
124
|
+
VER::stop_ncurses
|
125
|
+
p ex if ex
|
126
|
+
p(ex.backtrace.join("\n")) if ex
|
127
|
+
$log.debug( ex) if ex
|
128
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# this is a test program, tests out tabbed panes. type F1 to exit
|
2
|
+
#
|
3
|
+
require 'logger'
|
4
|
+
require 'rbcurse'
|
5
|
+
require 'rbcurse/extras/newtabbedpane'
|
6
|
+
require 'rbcurse/rcontainer'
|
7
|
+
require 'rbcurse/rcombo'
|
8
|
+
require 'rbcurse/extras/newtabbedwindow'
|
9
|
+
|
10
|
+
include RubyCurses
|
11
|
+
class SetupTabbedPane
|
12
|
+
def run
|
13
|
+
$config_hash ||= Variable.new Hash.new
|
14
|
+
#configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
|
15
|
+
|
16
|
+
r = Container.new nil, :suppress_borders => true
|
17
|
+
l1 = Label.new nil, :name => "profile", :attr => 'bold', :text => "Profile"
|
18
|
+
f1 = Field.new nil, :name => "name", :maxlen => 20, :display_length => 20, :bgcolor => :white,
|
19
|
+
:color => :black, :text => "abc", :label => ' Name: '
|
20
|
+
f2 = Field.new nil, :name => "email", :display_length => 20, :bgcolor => :white,
|
21
|
+
:color => :blue, :text => "me@google.com", :label => 'Email: '
|
22
|
+
f3 = RadioButton.new nil, :variable => $config_hash, :text => "red", :value => "RED", :color => :red
|
23
|
+
f4 = RadioButton.new nil, :variable => $config_hash, :text => "blue", :value => "BLUE", :color => :blue
|
24
|
+
f5 = RadioButton.new nil, :variable => $config_hash, :text => "green", :value => "GREEN", :color => :green
|
25
|
+
r.add(l1,f1)
|
26
|
+
r.add(f2)
|
27
|
+
r.add(f3,f4,f5)
|
28
|
+
|
29
|
+
tp = NewTabbedWindow.new :row => 3, :col => 7, :width => 60, :height => 20 do
|
30
|
+
title "User Setup"
|
31
|
+
button_type :ok_apply_cancel
|
32
|
+
tab "&Profile" do
|
33
|
+
item Field.new nil, :row => 2, :col => 2, :text => "enter your name", :label => ' Name: '
|
34
|
+
item Field.new nil, :row => 3, :col => 2, :text => "enter your email", :label => 'Email: '
|
35
|
+
end
|
36
|
+
tab "&Settings" do
|
37
|
+
item Label.new nil, :text => "Text", :row => 1, :col => 2, :attr => 'bold'
|
38
|
+
item CheckBox.new nil, :row => 2, :col => 2, :text => "Antialias text"
|
39
|
+
item CheckBox.new nil, :row => 3, :col => 2, :text => "Use bold fonts"
|
40
|
+
item CheckBox.new nil, :row => 4, :col => 2, :text => "Allow blinking text"
|
41
|
+
item CheckBox.new nil, :row => 5, :col => 2, :text => "Display ANSI Colors"
|
42
|
+
item Label.new nil, :text => "Cursor", :row => 7, :col => 2, :attr => 'bold'
|
43
|
+
$config_hash.set_value Variable.new, :cursor
|
44
|
+
item RadioButton.new nil, :row => 8, :col => 2, :text => "Block", :value => "block", :variable => $config_hash[:cursor]
|
45
|
+
item RadioButton.new nil, :row => 9, :col => 2, :text => "Blink", :value => "blink", :variable => $config_hash[:cursor]
|
46
|
+
item RadioButton.new nil, :row => 10, :col => 2, :text => "Underline", :value => "underline", :variable => $config_hash[:cursor]
|
47
|
+
end
|
48
|
+
tab "&Term" do
|
49
|
+
|
50
|
+
item Label.new nil, :text => "Arrow Key in Combos", :row => 2, :col => 2, :attr => 'bold'
|
51
|
+
x = Variable.new
|
52
|
+
$config_hash.set_value x, :term
|
53
|
+
item RadioButton.new nil, :row => 3, :col => 2, :text => "ignore", :value => "ignore", :variable => $config_hash[:term]
|
54
|
+
item RadioButton.new nil, :row => 4, :col => 2, :text => "popup", :value => "popup", :variable => $config_hash[:term]
|
55
|
+
item RadioButton.new nil, :row => 5, :col => 2, :text => "next", :value => "next", :variable => $config_hash[:term]
|
56
|
+
cb = ComboBox.new nil, :row => 7, :col => 2, :display_length => 15,
|
57
|
+
:list => %w[xterm xterm-color xterm-256color screen vt100 vt102],
|
58
|
+
:label => "Declare terminal as: "
|
59
|
+
#radio.update_command() {|rb| ENV['TERM']=rb.value }
|
60
|
+
item cb
|
61
|
+
x.update_command do |rb|
|
62
|
+
cb.arrow_key_policy=rb.value.to_sym
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
tab "Conta&iner" do
|
67
|
+
item r
|
68
|
+
end
|
69
|
+
# tell tabbedpane what to do if a button is pressed (ok/apply/cancel)
|
70
|
+
command do |eve|
|
71
|
+
alert "user pressed button index:#{eve.event} , Name: #{eve.action_command}, Tab: #{eve.source.current_tab} "
|
72
|
+
case eve.event
|
73
|
+
when 0,2 # ok cancel
|
74
|
+
throw :close, eve.event
|
75
|
+
when 1 # apply
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
tp.run
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
if $0 == __FILE__
|
84
|
+
# Initialize curses
|
85
|
+
begin
|
86
|
+
# XXX update with new color and kb
|
87
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
88
|
+
$log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
|
89
|
+
$log.level = Logger::DEBUG
|
90
|
+
tp = SetupTabbedPane.new()
|
91
|
+
buttonindex = tp.run
|
92
|
+
rescue => ex
|
93
|
+
ensure
|
94
|
+
VER::stop_ncurses
|
95
|
+
p ex if ex
|
96
|
+
p(ex.backtrace.join("\n")) if ex
|
97
|
+
$log.debug( ex) if ex
|
98
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
99
|
+
end
|
100
|
+
end
|