rbcurse 0.1.3 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +126 -0
- data/Manifest.txt +53 -20
- data/README.markdown +423 -0
- data/Rakefile +3 -1
- data/examples/keytest.rb +177 -0
- data/examples/mpad2.rb +156 -0
- data/examples/newtesttabp.rb +121 -0
- data/examples/rfe.rb +48 -10
- data/examples/rfe_renderer.rb +4 -4
- data/examples/rvimsplit.rb +376 -0
- data/examples/sqlc.rb +97 -106
- data/examples/sqlm.rb +446 -0
- data/examples/test1.rb +4 -4
- data/examples/test2.rb +12 -12
- data/examples/testchars.rb +140 -0
- data/examples/testkeypress.rb +9 -4
- data/examples/testmulticomp.rb +72 -0
- data/examples/testscroller.rb +136 -0
- data/examples/testscrolllb.rb +86 -0
- data/examples/testscrollp.rb +87 -0
- data/examples/testscrollta.rb +80 -0
- data/examples/testscrolltable.rb +166 -0
- data/examples/testsplit.rb +87 -0
- data/examples/testsplit2.rb +123 -0
- data/examples/testsplit3.rb +215 -0
- data/examples/testsplit3_1.rb +244 -0
- data/examples/testsplit3a.rb +215 -0
- data/examples/testsplit3b.rb +237 -0
- data/examples/testsplitta.rb +148 -0
- data/examples/testsplittv.rb +142 -0
- data/examples/testsplittvv.rb +144 -0
- data/examples/testtable.rb +1 -1
- data/examples/testtabp.rb +3 -2
- data/examples/testtestw.rb +69 -0
- data/examples/testtodo.rb +5 -3
- data/examples/testtpane.rb +203 -0
- data/examples/testtpane2.rb +145 -0
- data/examples/testtpanetable.rb +199 -0
- data/examples/viewtodo.rb +5 -3
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/celleditor.rb +2 -2
- data/lib/rbcurse/colormap.rb +5 -5
- data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
- data/lib/rbcurse/io.rb +663 -0
- data/lib/rbcurse/listeditable.rb +306 -0
- data/lib/rbcurse/listkeys.rb +15 -15
- data/lib/rbcurse/listscrollable.rb +168 -27
- data/lib/rbcurse/mapper.rb +35 -13
- data/lib/rbcurse/rchangeevent.rb +28 -0
- data/lib/rbcurse/rform.rb +845 -0
- data/lib/rbcurse/rlistbox.rb +144 -34
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +325 -0
- data/lib/rbcurse/rmultitextview.rb +306 -0
- data/lib/rbcurse/rscrollform.rb +369 -0
- data/lib/rbcurse/rscrollpane.rb +511 -0
- data/lib/rbcurse/rsplitpane.rb +820 -0
- data/lib/rbcurse/rtabbedpane.rb +737 -109
- data/lib/rbcurse/rtabbedwindow.rb +326 -0
- data/lib/rbcurse/rtable.rb +220 -64
- data/lib/rbcurse/rtextarea.rb +340 -181
- data/lib/rbcurse/rtextview.rb +237 -101
- data/lib/rbcurse/rviewport.rb +203 -0
- data/lib/rbcurse/rwidget.rb +919 -95
- data/lib/rbcurse/scrollable.rb +7 -7
- data/lib/rbcurse/selectable.rb +4 -4
- data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
- data/lib/rbcurse/undomanager.rb +181 -0
- data/lib/rbcurse/vieditable.rb +100 -0
- data/lib/ver/window.rb +471 -21
- metadata +66 -22
- data/README.txt +0 -312
- data/examples/testd.db +0 -0
- data/examples/todocsv.csv +0 -28
data/examples/test1.rb
CHANGED
@@ -30,7 +30,7 @@ if $0 == __FILE__
|
|
30
30
|
$log.debug "START MESSAGE BOX TEST #{ARGV[0]}. choice==#{choice} ---------"
|
31
31
|
# need to pass a form, not window.
|
32
32
|
case choice
|
33
|
-
when 1
|
33
|
+
when 1
|
34
34
|
@mb = RubyCurses::MessageBox.new do
|
35
35
|
title "Enter your name"
|
36
36
|
message "Enter your name"
|
@@ -42,7 +42,7 @@ if $0 == __FILE__
|
|
42
42
|
|
43
43
|
default_button 0
|
44
44
|
end
|
45
|
-
when 2
|
45
|
+
when 2
|
46
46
|
@mb = RubyCurses::MessageBox.new do
|
47
47
|
title "Color selector"
|
48
48
|
message "Select a color"
|
@@ -65,7 +65,7 @@ if $0 == __FILE__
|
|
65
65
|
button_type :ok_cancel
|
66
66
|
default_value "Rahul"
|
67
67
|
end
|
68
|
-
when 4
|
68
|
+
when 4
|
69
69
|
@form = RubyCurses::Form.new nil
|
70
70
|
field_list = []
|
71
71
|
titlelabel = RubyCurses::Label.new @form, {'text' => 'User', 'row'=>3, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white', 'mnemonic'=>'U'}
|
@@ -167,7 +167,7 @@ if $0 == __FILE__
|
|
167
167
|
button_type :ok
|
168
168
|
default_button 0
|
169
169
|
end
|
170
|
-
when 5
|
170
|
+
when 5
|
171
171
|
@form = RubyCurses::Form.new nil
|
172
172
|
label = RubyCurses::Label.new @form, {'text' => 'File', 'row'=>3, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white', 'mnemonic'=>'F'}
|
173
173
|
field = RubyCurses::Field.new @form do
|
data/examples/test2.rb
CHANGED
@@ -5,7 +5,6 @@ require 'ncurses'
|
|
5
5
|
require 'logger'
|
6
6
|
require 'rbcurse'
|
7
7
|
require 'rbcurse/rwidget'
|
8
|
-
#require 'rbcurse/rform'
|
9
8
|
require 'rbcurse/rtextarea'
|
10
9
|
require 'rbcurse/rtextview'
|
11
10
|
require 'rbcurse/rmenu'
|
@@ -23,6 +22,7 @@ if $0 == __FILE__
|
|
23
22
|
begin
|
24
23
|
# Initialize curses
|
25
24
|
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
25
|
+
#$log = Logger.new("v#{$0}.log")
|
26
26
|
$log = Logger.new("view.log")
|
27
27
|
$log.level = Logger::DEBUG
|
28
28
|
|
@@ -33,9 +33,9 @@ if $0 == __FILE__
|
|
33
33
|
|
34
34
|
catch(:close) do
|
35
35
|
colors = Ncurses.COLORS
|
36
|
-
$log.debug "START #{colors} colors
|
36
|
+
$log.debug "START #{colors} colors test2.rb --------- #{@window} "
|
37
37
|
@form = Form.new @window
|
38
|
-
@form.window.printstring 0,
|
38
|
+
@form.window.printstring 0, 30, "Demo of Ruby Curses Widgets - rbcurse", $normalcolor, 'reverse'
|
39
39
|
r = 1; fc = 12;
|
40
40
|
mnemonics = %w[ n l r p]
|
41
41
|
%w[ name line regex password].each_with_index do |w,i|
|
@@ -66,7 +66,7 @@ if $0 == __FILE__
|
|
66
66
|
row r
|
67
67
|
col 1
|
68
68
|
width 40
|
69
|
-
height
|
69
|
+
height 11
|
70
70
|
# list mylist
|
71
71
|
list_variable $listdata
|
72
72
|
#selection_mode :SINGLE
|
@@ -79,7 +79,7 @@ if $0 == __FILE__
|
|
79
79
|
end
|
80
80
|
#listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
81
81
|
#$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
|
82
|
-
listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi
|
82
|
+
listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure"
|
83
83
|
texta = TextArea.new @form do
|
84
84
|
name "mytext"
|
85
85
|
row 1
|
@@ -108,7 +108,7 @@ if $0 == __FILE__
|
|
108
108
|
# list mylist
|
109
109
|
list_variable cblist
|
110
110
|
#selection_mode :SINGLE
|
111
|
-
title "
|
111
|
+
title "CList"
|
112
112
|
title_attrib 'reverse'
|
113
113
|
cell_renderer RubyCurses::CheckBoxCellRenderer.new nil, {"parent" => self, "display_length"=> @width-2}
|
114
114
|
cell_editing_allowed true
|
@@ -140,14 +140,14 @@ if $0 == __FILE__
|
|
140
140
|
col 52
|
141
141
|
width 40
|
142
142
|
height 10
|
143
|
-
title "README.
|
143
|
+
title "README.mark"
|
144
144
|
title_attrib 'bold'
|
145
145
|
print_footer true
|
146
146
|
footer_attrib 'bold'
|
147
147
|
end
|
148
|
-
content = File.open("../README.
|
148
|
+
content = File.open("../README.markdown","r").readlines
|
149
149
|
@textview.set_content content #, :WRAP_WORD
|
150
|
-
|
150
|
+
#@textview.top_row 21
|
151
151
|
|
152
152
|
# just for demo, lets scroll the text view as we scroll this.
|
153
153
|
listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index }
|
@@ -360,13 +360,13 @@ if $0 == __FILE__
|
|
360
360
|
str << " bugs as they crop up."
|
361
361
|
testa.goto_start
|
362
362
|
#testa.cursor_bol
|
363
|
-
testa.handle_key ?\C-a # bol
|
363
|
+
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
364
364
|
str.each_char {|c| testa.putch(c)}
|
365
365
|
testa.repaint
|
366
366
|
testa.handle_key KEY_DOWN # down
|
367
367
|
testa.handle_key KEY_DOWN # down
|
368
368
|
testa.handle_key KEY_DOWN # down
|
369
|
-
testa.handle_key ?\C-a # bol
|
369
|
+
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
370
370
|
#testa.cursor_bol
|
371
371
|
str.each_char {|c| testa.putch(c)}
|
372
372
|
$message.value = "Wrapping textarea"
|
@@ -376,7 +376,7 @@ if $0 == __FILE__
|
|
376
376
|
filemenu.add(item = RubyCurses::MenuItem.new("Wrap",'W'))
|
377
377
|
item.command(@form, texta) do |it, form, testa|
|
378
378
|
#testa.goto_start
|
379
|
-
testa.handle_key ?\C-a # bol
|
379
|
+
testa.handle_key ?\C-a # bol XXX should it be getbytes(0) now
|
380
380
|
testa.wrap_para
|
381
381
|
testa.repaint
|
382
382
|
throw(:menubarclose)
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'ncurses'
|
4
|
+
require 'logger'
|
5
|
+
#require 'lib/ver/keyboard'
|
6
|
+
require 'rbcurse'
|
7
|
+
if $0 == __FILE__
|
8
|
+
include RubyCurses
|
9
|
+
include RubyCurses::Utils
|
10
|
+
|
11
|
+
begin
|
12
|
+
# Initialize curses
|
13
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
14
|
+
$log = Logger.new("view.log")
|
15
|
+
$log.level = Logger::DEBUG
|
16
|
+
|
17
|
+
@window = VER::Window.root_window
|
18
|
+
|
19
|
+
catch(:close) do
|
20
|
+
colors = Ncurses.COLORS
|
21
|
+
@form = Form.new @window
|
22
|
+
r = 1; c = 1;
|
23
|
+
arr=[]; sarr=[]
|
24
|
+
|
25
|
+
sarr << "ACS_BBSS"
|
26
|
+
arr << ACS_BBSS
|
27
|
+
sarr << "ACS_BLOCK"
|
28
|
+
arr << ACS_BLOCK
|
29
|
+
sarr << "ACS_BOARD"
|
30
|
+
arr << ACS_BOARD
|
31
|
+
sarr << "ACS_BSBS"
|
32
|
+
arr << ACS_BSBS
|
33
|
+
sarr << "ACS_BSSB"
|
34
|
+
arr << ACS_BSSB
|
35
|
+
sarr << "ACS_BSSS"
|
36
|
+
arr << ACS_BSSS
|
37
|
+
sarr << "ACS_BTEE"
|
38
|
+
arr << ACS_BTEE
|
39
|
+
sarr << "ACS_BULLET"
|
40
|
+
arr << ACS_BULLET
|
41
|
+
sarr << "ACS_CKBOARD"
|
42
|
+
arr << ACS_CKBOARD
|
43
|
+
sarr << "ACS_DARROW"
|
44
|
+
arr << ACS_DARROW
|
45
|
+
sarr << "ACS_DEGREE"
|
46
|
+
arr << ACS_DEGREE
|
47
|
+
sarr << "ACS_DIAMOND"
|
48
|
+
arr << ACS_DIAMOND
|
49
|
+
sarr << "ACS_GEQUAL"
|
50
|
+
arr << ACS_GEQUAL
|
51
|
+
sarr << "ACS_HLINE"
|
52
|
+
arr << ACS_HLINE
|
53
|
+
sarr << "ACS_LANTERN"
|
54
|
+
arr << ACS_LANTERN
|
55
|
+
sarr << "ACS_LARROW"
|
56
|
+
arr << ACS_LARROW
|
57
|
+
sarr << "ACS_LEQUAL"
|
58
|
+
arr << ACS_LEQUAL
|
59
|
+
sarr << "ACS_LLCORNER"
|
60
|
+
arr << ACS_LLCORNER
|
61
|
+
sarr << "ACS_LRCORNER"
|
62
|
+
arr << ACS_LRCORNER
|
63
|
+
sarr << "ACS_LTEE"
|
64
|
+
arr << ACS_LTEE
|
65
|
+
sarr << "ACS_NEQUAL"
|
66
|
+
arr << ACS_NEQUAL
|
67
|
+
sarr << "ACS_PI"
|
68
|
+
arr << ACS_PI
|
69
|
+
sarr << "ACS_PLMINUS"
|
70
|
+
arr << ACS_PLMINUS
|
71
|
+
sarr << "ACS_PLUS"
|
72
|
+
arr << ACS_PLUS
|
73
|
+
sarr << "ACS_RARROW"
|
74
|
+
arr << ACS_RARROW
|
75
|
+
sarr << "ACS_RTEE"
|
76
|
+
arr << ACS_RTEE
|
77
|
+
sarr << "ACS_S1"
|
78
|
+
arr << ACS_S1
|
79
|
+
sarr << "ACS_S3"
|
80
|
+
arr << ACS_S3
|
81
|
+
sarr << "ACS_S7"
|
82
|
+
arr << ACS_S7
|
83
|
+
sarr << "ACS_S9"
|
84
|
+
arr << ACS_S9
|
85
|
+
sarr << "ACS_SBBS"
|
86
|
+
arr << ACS_SBBS
|
87
|
+
sarr << "ACS_SBSB"
|
88
|
+
arr << ACS_SBSB
|
89
|
+
sarr << "ACS_SBSS"
|
90
|
+
arr << ACS_SBSS
|
91
|
+
sarr << "ACS_SSBB"
|
92
|
+
arr << ACS_SSBB
|
93
|
+
sarr << "ACS_SSBS"
|
94
|
+
arr << ACS_SSBS
|
95
|
+
sarr << "ACS_SSSB"
|
96
|
+
arr << ACS_SSSB
|
97
|
+
sarr << "ACS_SSSS"
|
98
|
+
arr << ACS_SSSS
|
99
|
+
sarr << "ACS_STERLING"
|
100
|
+
arr << ACS_STERLING
|
101
|
+
sarr << "ACS_TTEE"
|
102
|
+
arr << ACS_TTEE
|
103
|
+
sarr << "ACS_UARROW"
|
104
|
+
arr << ACS_UARROW
|
105
|
+
sarr << "ACS_ULCORNER"
|
106
|
+
arr << ACS_ULCORNER
|
107
|
+
sarr << "ACS_URCORNER"
|
108
|
+
arr << ACS_URCORNER
|
109
|
+
sarr << "ACS_VLINE"
|
110
|
+
arr << ACS_VLINE
|
111
|
+
|
112
|
+
sarr.each_index { |i|
|
113
|
+
@window.mvaddch r,c, arr[i]
|
114
|
+
@window.mvprintw r,c+2,"%s", sarr[i]
|
115
|
+
r+=1
|
116
|
+
if r == 25
|
117
|
+
r = 1
|
118
|
+
c+=25
|
119
|
+
end
|
120
|
+
}
|
121
|
+
|
122
|
+
#@form.repaint
|
123
|
+
@window.wrefresh
|
124
|
+
Ncurses::Panel.update_panels
|
125
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
126
|
+
str = keycode_tos ch
|
127
|
+
@form.handle_key(ch)
|
128
|
+
@window.wrefresh
|
129
|
+
end
|
130
|
+
end
|
131
|
+
rescue => ex
|
132
|
+
ensure
|
133
|
+
@window.destroy if !@window.nil?
|
134
|
+
VER::stop_ncurses
|
135
|
+
p ex if ex
|
136
|
+
p(ex.backtrace.join("\n")) if ex
|
137
|
+
$log.debug( ex) if ex
|
138
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
139
|
+
end
|
140
|
+
end
|
data/examples/testkeypress.rb
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'ncurses'
|
4
4
|
require 'logger'
|
5
|
-
#require 'lib/ver/keyboard'
|
6
5
|
require 'rbcurse'
|
7
6
|
require 'rbcurse/rtextarea'
|
7
|
+
#require 'rbcurse/oldrtextarea'
|
8
8
|
if $0 == __FILE__
|
9
9
|
include RubyCurses
|
10
10
|
include RubyCurses::Utils
|
@@ -35,17 +35,22 @@ if $0 == __FILE__
|
|
35
35
|
auto_scroll true
|
36
36
|
title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
37
37
|
end
|
38
|
-
@help = "q to quit. Use any key of key combination to see what's caught
|
38
|
+
@help = "q to quit. Use any key of key combination to see what's caught.: #{$0} Check logger too"
|
39
39
|
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
40
40
|
|
41
41
|
@form.repaint
|
42
42
|
@window.wrefresh
|
43
43
|
Ncurses::Panel.update_panels
|
44
|
-
while((ch = @window.getchar()) != ?q )
|
44
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
45
45
|
str = keycode_tos ch
|
46
|
+
$log.debug "#{ch} got (#{str})"
|
46
47
|
texta << "#{ch} got (#{str})"
|
47
48
|
texta.repaint
|
48
|
-
|
49
|
+
# 2010-01-01 16:00 not much point calling handle_key since textarea is not editable
|
50
|
+
# and will return unhandled and thus NOT do a repaint. so we have to repaint anyway.
|
51
|
+
#ret = @form.handle_key(ch)
|
52
|
+
#$log.debug " form handlekey returned: #{ret} "
|
53
|
+
@form.repaint
|
49
54
|
@window.wrefresh
|
50
55
|
end
|
51
56
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'ncurses'
|
4
|
+
require 'logger'
|
5
|
+
require 'rbcurse'
|
6
|
+
require 'rbcurse/rmulticontainer'
|
7
|
+
require 'rbcurse/rtextarea'
|
8
|
+
if $0 == __FILE__
|
9
|
+
include RubyCurses
|
10
|
+
include RubyCurses::Utils
|
11
|
+
|
12
|
+
begin
|
13
|
+
# Initialize curses
|
14
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
15
|
+
$log = Logger.new("view.log")
|
16
|
+
$log.level = Logger::DEBUG
|
17
|
+
|
18
|
+
@window = VER::Window.root_window
|
19
|
+
|
20
|
+
catch(:close) do
|
21
|
+
colors = Ncurses.COLORS
|
22
|
+
$log.debug "START #{colors} colors --------- testmulticomp"
|
23
|
+
@form = Form.new @window
|
24
|
+
@ctr = 1
|
25
|
+
r = 1; c = 30;
|
26
|
+
|
27
|
+
mc = MultiContainer.new @form do
|
28
|
+
name "multic"
|
29
|
+
row r
|
30
|
+
col c
|
31
|
+
width 60
|
32
|
+
height 15
|
33
|
+
title "Multiconty"
|
34
|
+
end
|
35
|
+
ctr = 1
|
36
|
+
|
37
|
+
@form.bind_key(?\M-a) do
|
38
|
+
$log.debug " Inside M-a MULTI "
|
39
|
+
texta = TextArea.new do
|
40
|
+
name "mytext#{ctr}"
|
41
|
+
title "Enter Something-#{ctr}"
|
42
|
+
title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
|
43
|
+
end
|
44
|
+
mc.add texta, "Enter Something #{ctr}"
|
45
|
+
texta << "Hello World"
|
46
|
+
texta << "Hello World"
|
47
|
+
ctr += 1
|
48
|
+
end
|
49
|
+
@help = "F1 to quit. M-a to open new component. M-: for menu #{$0} "
|
50
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
|
51
|
+
|
52
|
+
@form.repaint
|
53
|
+
@window.wrefresh
|
54
|
+
Ncurses::Panel.update_panels
|
55
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
56
|
+
str = keycode_tos ch
|
57
|
+
$log.debug "#{ch} got (#{str})"
|
58
|
+
@form.handle_key ch
|
59
|
+
@form.repaint
|
60
|
+
@window.wrefresh
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue => ex
|
64
|
+
ensure
|
65
|
+
@window.destroy if !@window.nil?
|
66
|
+
VER::stop_ncurses
|
67
|
+
p ex if ex
|
68
|
+
p(ex.backtrace.join("\n")) if ex
|
69
|
+
$log.debug( ex) if ex
|
70
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
# this program tests out various widgets.
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ncurses'
|
5
|
+
require 'logger'
|
6
|
+
require 'rbcurse'
|
7
|
+
require 'rbcurse/rwidget'
|
8
|
+
require 'rbcurse/rscrollform'
|
9
|
+
#require 'rbcurse/rtextarea'
|
10
|
+
#require 'rbcurse/rtextview'
|
11
|
+
#require 'rbcurse/rmenu'
|
12
|
+
#require 'rbcurse/rcombo'
|
13
|
+
#require 'rbcurse/listcellrenderer'
|
14
|
+
#require 'rbcurse/checkboxcellrenderer'
|
15
|
+
#require 'rbcurse/comboboxcellrenderer'
|
16
|
+
#require 'rbcurse/celleditor'
|
17
|
+
#require 'qdfilechooser'
|
18
|
+
#require 'rbcurse/rlistbox'
|
19
|
+
#require 'rbcurse/rmessagebox'
|
20
|
+
if $0 == __FILE__
|
21
|
+
include RubyCurses
|
22
|
+
|
23
|
+
begin
|
24
|
+
# Initialize curses
|
25
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
26
|
+
#$log = Logger.new("v#{$0}.log")
|
27
|
+
$log = Logger.new("view.log")
|
28
|
+
$log.level = Logger::DEBUG
|
29
|
+
|
30
|
+
@window = VER::Window.root_window
|
31
|
+
# Initialize few color pairs
|
32
|
+
# Create the window to be associated with the form
|
33
|
+
# Un post form and free the memory
|
34
|
+
|
35
|
+
catch(:close) do
|
36
|
+
colors = Ncurses.COLORS
|
37
|
+
$log.debug "START #{colors} colors testscroller.rb --------- #{@window} "
|
38
|
+
@form = ScrollForm.new @window
|
39
|
+
# pad coordinates - the virtual area larger than screen
|
40
|
+
h = 50
|
41
|
+
w = 150
|
42
|
+
row = 1
|
43
|
+
col = 1
|
44
|
+
@form.set_pad_dimensions(row, col, h, w)
|
45
|
+
# dimensions of screen area onto which pad will paint
|
46
|
+
@form.should_print_border(true)
|
47
|
+
#@buttonpad = @form.create_pad
|
48
|
+
|
49
|
+
#@window.print_border_only 0, 0, 20+2, 100+2, $datacolor
|
50
|
+
@window.printstring 0, 30, "Demo of ScrollForm ", $normalcolor, 'reverse'
|
51
|
+
r = row + 0; fc = 12;
|
52
|
+
#mnemonics = %w[ n l r p]
|
53
|
+
%w[ name detail descr password street city country zip hobbies homepage facebook twitter buzz gmail ].each_with_index do |w,i|
|
54
|
+
field = Field.new @form do
|
55
|
+
name w
|
56
|
+
row r
|
57
|
+
col fc
|
58
|
+
display_length 30
|
59
|
+
maxlen 30
|
60
|
+
#set_buffer "abcd "
|
61
|
+
#set_label Label.new @form, {'text' => w, 'color'=>'cyan','mnemonic'=> mnemonics[i]}
|
62
|
+
set_label Label.new @form, {'text' => w, 'color'=>'cyan'}
|
63
|
+
end
|
64
|
+
r += 3
|
65
|
+
end
|
66
|
+
r = row
|
67
|
+
fc = 120
|
68
|
+
# XXX while typing in a field, cursor goes off in this case
|
69
|
+
%w[ operating_system version application build release shell band instrument guitarist drummer ].each_with_index do |w,i|
|
70
|
+
field = Field.new @form do
|
71
|
+
name w
|
72
|
+
row r
|
73
|
+
col fc
|
74
|
+
display_length 30
|
75
|
+
maxlen 30
|
76
|
+
bgcolor 'white'
|
77
|
+
color 'black'
|
78
|
+
#set_buffer "abcd "
|
79
|
+
#set_label Label.new @form, {'text' => w, 'color'=>'cyan','mnemonic'=> mnemonics[i]}
|
80
|
+
set_label Label.new @form, {'text' => w, 'color'=>'cyan'}
|
81
|
+
end
|
82
|
+
field.overwrite_mode = true
|
83
|
+
r += 3
|
84
|
+
end
|
85
|
+
|
86
|
+
$message = Variable.new
|
87
|
+
$message.value = "Message Comes Here"
|
88
|
+
message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => 27, "col" => 1, "display_length" => 60, "height" => 2, 'color' => 'cyan'}
|
89
|
+
|
90
|
+
# a special case required since another form (combo popup also modifies)
|
91
|
+
$message.update_command() { message_label.repaint }
|
92
|
+
|
93
|
+
#@form.by_name["line"].display_length = 3
|
94
|
+
#@form.by_name["line"].maxlen = 3
|
95
|
+
#@form.by_name["line"].set_buffer "24"
|
96
|
+
@form.by_name["detail"].set_buffer "This form has more components"
|
97
|
+
@form.by_name["descr"].set_buffer "Use M-l/h and M-n/p for scrolling"
|
98
|
+
#@form.by_name["name"].set_focusable(false)
|
99
|
+
#@form.by_name["line"].chars_allowed = /\d/
|
100
|
+
##@form.by_name["regex"].type(:ALPHA)
|
101
|
+
#@form.by_name["regex"].valid_regex(/^[A-Z][a-z]*/)
|
102
|
+
#@form.by_name["regex"].set_buffer "SYNOP"
|
103
|
+
#@form.by_name["regex"].display_length = 10
|
104
|
+
#@form.by_name["regex"].maxlen = 20
|
105
|
+
##@form.by_name["regex"].bgcolor 'cyan'
|
106
|
+
#@form.by_name["password"].set_buffer ""
|
107
|
+
#@form.by_name["password"].show '*'
|
108
|
+
#@form.by_name["password"].color 'red'
|
109
|
+
##@form.by_name["password"].bgcolor 'blue'
|
110
|
+
#@form.by_name["password"].values(%w[scotty tiger secret pass qwerty])
|
111
|
+
#@form.by_name["password"].null_allowed true
|
112
|
+
|
113
|
+
# a form level event, whenever any widget is focussed
|
114
|
+
@form.bind(:ENTER) { |f| f.label && f.label.bgcolor = 'red' if f.respond_to? :label}
|
115
|
+
@form.bind(:LEAVE) { |f| f.label && f.label.bgcolor = 'black' if f.respond_to? :label}
|
116
|
+
|
117
|
+
@form.repaint
|
118
|
+
@window.wrefresh
|
119
|
+
Ncurses::Panel.update_panels
|
120
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
121
|
+
@form.handle_key(ch)
|
122
|
+
@form.repaint
|
123
|
+
@window.wrefresh
|
124
|
+
Ncurses::Panel.update_panels
|
125
|
+
end
|
126
|
+
end
|
127
|
+
rescue => ex
|
128
|
+
ensure
|
129
|
+
@window.destroy if !@window.nil?
|
130
|
+
VER::stop_ncurses
|
131
|
+
p ex if ex
|
132
|
+
p(ex.backtrace.join("\n")) if ex
|
133
|
+
$log.debug( ex) if ex
|
134
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
135
|
+
end
|
136
|
+
end
|