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
@@ -0,0 +1,123 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'ncurses'
|
4
|
+
require 'logger'
|
5
|
+
require 'rbcurse'
|
6
|
+
require 'rbcurse/rsplitpane'
|
7
|
+
#require 'rbcurse/rtestwidget'
|
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("v#{$0}.log")
|
16
|
+
$log.level = Logger::DEBUG
|
17
|
+
|
18
|
+
@window = VER::Window.root_window
|
19
|
+
|
20
|
+
catch(:close) do
|
21
|
+
colors = Ncurses.COLORS
|
22
|
+
@form = Form.new @window
|
23
|
+
r = 3; c = 5; ht = 18; w = 70
|
24
|
+
# filler just to see that we are covering correct space and not wasting lines or cols
|
25
|
+
filler = "*" * 88
|
26
|
+
# (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
|
27
|
+
|
28
|
+
|
29
|
+
@help = "q to quit. v for vertical split, h - horizontal. -/+/= to resize split. : #{$0}"
|
30
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
|
31
|
+
splitp = SplitPane.new @form do
|
32
|
+
name "mainpane"
|
33
|
+
row r
|
34
|
+
col c
|
35
|
+
width w
|
36
|
+
height ht
|
37
|
+
#focusable false
|
38
|
+
#orientation :VERTICAL_SPLIT
|
39
|
+
orientation :HORIZONTAL_SPLIT
|
40
|
+
#set_resize_weight 0.60
|
41
|
+
end
|
42
|
+
# note that splitc has no form. so focus has to be managed XXX
|
43
|
+
splitc = SplitPane.new nil do
|
44
|
+
name "FC"
|
45
|
+
#row r
|
46
|
+
#col c
|
47
|
+
|
48
|
+
## earlier commented now bombing
|
49
|
+
#width w-4 # 30
|
50
|
+
#height ht/2-1
|
51
|
+
|
52
|
+
#focusable false
|
53
|
+
#orientation :HORIZONTAL_SPLIT
|
54
|
+
orientation :VERTICAL_SPLIT
|
55
|
+
border_color $promptcolor
|
56
|
+
border_attrib Ncurses::A_NORMAL
|
57
|
+
end
|
58
|
+
splitc2 = SplitPane.new nil do
|
59
|
+
name "2C"
|
60
|
+
#
|
61
|
+
## not present earlier now bombing
|
62
|
+
#width w-4
|
63
|
+
#height ht/2-1
|
64
|
+
|
65
|
+
orientation :VERTICAL_SPLIT
|
66
|
+
border_color $promptcolor
|
67
|
+
border_attrib Ncurses::A_REVERSE
|
68
|
+
end
|
69
|
+
splitp.first_component(splitc)
|
70
|
+
splitp.second_component(splitc2)
|
71
|
+
splitc.preferred_width w/2
|
72
|
+
splitc.preferred_height ht/2-2
|
73
|
+
splitc.set_resize_weight 0.50
|
74
|
+
splitc2.min_width 15
|
75
|
+
splitc2.min_height 5
|
76
|
+
splitc.min_width 12
|
77
|
+
splitc.min_height 6
|
78
|
+
ret = splitp.reset_to_preferred_sizes
|
79
|
+
splitp.set_resize_weight(0.50) if ret == :ERROR
|
80
|
+
|
81
|
+
@form.repaint
|
82
|
+
@window.wrefresh
|
83
|
+
Ncurses::Panel.update_panels
|
84
|
+
while((ch = @window.getchar()) != ?q.getbyte(0) )
|
85
|
+
str = keycode_tos ch
|
86
|
+
case ch
|
87
|
+
when ?v.getbyte(0)
|
88
|
+
$log.debug " ORIENTATION VERTICAL"
|
89
|
+
splitp.orientation(:VERTICAL_SPLIT)
|
90
|
+
splitp.reset_to_preferred_sizes
|
91
|
+
when ?h.getbyte(0)
|
92
|
+
$log.debug " ORIENTATION HORIZ"
|
93
|
+
splitp.orientation(:HORIZONTAL_SPLIT)
|
94
|
+
splitp.reset_to_preferred_sizes
|
95
|
+
when ?-.getbyte(0)
|
96
|
+
$log.debug " KEY PRESS -"
|
97
|
+
splitp.set_divider_location(splitp.divider_location-1)
|
98
|
+
when ?+.getbyte(0)
|
99
|
+
$log.debug " KEY PRESS +"
|
100
|
+
splitp.set_divider_location(splitp.divider_location+1)
|
101
|
+
when ?=.getbyte(0)
|
102
|
+
$log.debug " KEY PRESS ="
|
103
|
+
splitp.set_resize_weight(0.50)
|
104
|
+
end
|
105
|
+
#splitp.get_buffer().wclear
|
106
|
+
#splitp << "#{ch} got (#{str})"
|
107
|
+
# splitp.repaint
|
108
|
+
# splitp.buffer_to_screen
|
109
|
+
@form.repaint
|
110
|
+
@form.handle_key(ch)
|
111
|
+
@window.wrefresh
|
112
|
+
end
|
113
|
+
end
|
114
|
+
rescue => ex
|
115
|
+
ensure
|
116
|
+
@window.destroy if !@window.nil?
|
117
|
+
VER::stop_ncurses
|
118
|
+
p ex if ex
|
119
|
+
p(ex.backtrace.join("\n")) if ex
|
120
|
+
$log.debug( ex) if ex
|
121
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
#*******************************************************#
|
3
|
+
# testsplit3.rb #
|
4
|
+
# written by Rahul Kumar #
|
5
|
+
# January 14, 2010 #
|
6
|
+
# #
|
7
|
+
# test textview, split and textarea inside splitpane #
|
8
|
+
# #
|
9
|
+
#
|
10
|
+
# /----+---------------\
|
11
|
+
# | | |
|
12
|
+
# | 1 | |
|
13
|
+
# +----+ 3 |
|
14
|
+
# | 2 | |
|
15
|
+
# | | |
|
16
|
+
# \----+---------------/
|
17
|
+
#
|
18
|
+
# Please note, this is *not* the ideal way of placing a textview directly inside a
|
19
|
+
# splitpane, unless you size it so that the entire TV is visible inside
|
20
|
+
# the splitpane. If the TV is too large, you won't be able to scroll down to the
|
21
|
+
# bottom-most portion using TV's inbuilt scrolling (C-n C-p). This is *not* a bug.
|
22
|
+
# TV does not know you've put it inside a small SPLP.
|
23
|
+
#
|
24
|
+
# The ideal way is to put a TV inside a scrollpane, and put the scrollpane inside
|
25
|
+
# a SPLP just like all frames on the internet do. That is the subject of the next example.
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# Released under ruby license. See #
|
29
|
+
# http://www.ruby-lang.org/en/LICENSE.txt #
|
30
|
+
# Copyright 2010, Rahul Kumar #
|
31
|
+
#*******************************************************#
|
32
|
+
require 'rubygems'
|
33
|
+
require 'ncurses'
|
34
|
+
require 'logger'
|
35
|
+
require 'rbcurse'
|
36
|
+
require 'rbcurse/rsplitpane'
|
37
|
+
require 'rbcurse/rtextarea'
|
38
|
+
require 'rbcurse/rtextview'
|
39
|
+
require 'rbcurse/rlistbox'
|
40
|
+
if $0 == __FILE__
|
41
|
+
include RubyCurses
|
42
|
+
include RubyCurses::Utils
|
43
|
+
|
44
|
+
begin
|
45
|
+
# Initialize curses
|
46
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
47
|
+
$log = Logger.new("v#{$0}.log")
|
48
|
+
$log.level = Logger::DEBUG
|
49
|
+
|
50
|
+
@window = VER::Window.root_window
|
51
|
+
|
52
|
+
catch(:close) do
|
53
|
+
colors = Ncurses.COLORS
|
54
|
+
@form = Form.new @window
|
55
|
+
@form.name = "Form::MAINFORM"
|
56
|
+
$log.debug " MAIN FORM #{@form} #{$0} "
|
57
|
+
r = 3; c = 5; ht = 18; w = 90
|
58
|
+
# r = 0; c = 0; ht = 20; w = 100
|
59
|
+
|
60
|
+
|
61
|
+
@help = "F1 to quit. -/+/= to resize outer split, M-, M+, M= for inner split: #{$0}"
|
62
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+2, "col" => 2, "color" => "yellow"}
|
63
|
+
|
64
|
+
outer = SplitPane.new @form do
|
65
|
+
name "mainpane"
|
66
|
+
row r
|
67
|
+
col c
|
68
|
+
width w
|
69
|
+
height ht
|
70
|
+
#focusable false
|
71
|
+
orientation :VERTICAL_SPLIT
|
72
|
+
#orientation :HORIZONTAL_SPLIT
|
73
|
+
#set_resize_weight 0.60
|
74
|
+
border_color $promptcolor
|
75
|
+
end
|
76
|
+
# note that splitleft has no form. so focus has to be managed XXX
|
77
|
+
splitleft = SplitPane.new nil do
|
78
|
+
name "C1-leftpane"
|
79
|
+
#row r
|
80
|
+
#col c
|
81
|
+
|
82
|
+
## earlier commented now bombing
|
83
|
+
#width w/2 # 30
|
84
|
+
#height ht-2 #/2-1
|
85
|
+
|
86
|
+
#focusable false
|
87
|
+
orientation :HORIZONTAL_SPLIT
|
88
|
+
#orientation :VERTICAL_SPLIT
|
89
|
+
border_color $promptcolor
|
90
|
+
border_attrib Ncurses::A_NORMAL
|
91
|
+
end
|
92
|
+
ta1 = TextArea.new nil do
|
93
|
+
name "myTextArea-right"
|
94
|
+
#row 0
|
95
|
+
#col 0
|
96
|
+
width w/2-2
|
97
|
+
#height (ht/2)-1
|
98
|
+
height ht
|
99
|
+
title "README.md"
|
100
|
+
title_attrib 'bold'
|
101
|
+
print_footer true
|
102
|
+
footer_attrib 'bold'
|
103
|
+
#should_create_buffer true
|
104
|
+
end
|
105
|
+
|
106
|
+
t1 = TextView.new nil do
|
107
|
+
name "myView-left-first"
|
108
|
+
#row 0
|
109
|
+
#col 0
|
110
|
+
#width w-2
|
111
|
+
#height ht
|
112
|
+
height (ht/2)-1
|
113
|
+
width w/2 #-1
|
114
|
+
title "README.md"
|
115
|
+
title_attrib 'bold'
|
116
|
+
print_footer true
|
117
|
+
footer_attrib 'bold'
|
118
|
+
#should_create_buffer true
|
119
|
+
end
|
120
|
+
content = File.open("../README.markdown","r").readlines
|
121
|
+
t1.set_content content #, :WRAP_WORD
|
122
|
+
|
123
|
+
# to see lower border i need to set height to ht/2 -2 in both cases, but that
|
124
|
+
# crashes ruby when i reduce height by 1.
|
125
|
+
t2 = TextView.new nil do
|
126
|
+
name "myView2-left-second"
|
127
|
+
#row 0
|
128
|
+
#col 0
|
129
|
+
width w/2
|
130
|
+
#height ht
|
131
|
+
height (ht/2)-1
|
132
|
+
title "NOTES"
|
133
|
+
title_attrib 'bold'
|
134
|
+
print_footer true
|
135
|
+
footer_attrib 'bold'
|
136
|
+
#should_create_buffer true
|
137
|
+
end
|
138
|
+
content = File.open("../NOTES","r").readlines
|
139
|
+
t2.set_content content #, :WRAP_WORD
|
140
|
+
|
141
|
+
# the outer compo needs child set first else cursor does not reach up from
|
142
|
+
# lower levels. Is the connection broken ?
|
143
|
+
outer.first_component(splitleft)
|
144
|
+
outer.second_component(ta1)
|
145
|
+
splitleft.first_component(t1)
|
146
|
+
splitleft.second_component(t2)
|
147
|
+
t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
|
148
|
+
t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
|
149
|
+
#t1.set_resize_weight 0.50
|
150
|
+
t2.min_width 15
|
151
|
+
t2.min_height 5
|
152
|
+
t1.min_width 12
|
153
|
+
t1.min_height 5
|
154
|
+
ret = splitleft.reset_to_preferred_sizes
|
155
|
+
splitleft.set_resize_weight(0.50) if ret == :ERROR
|
156
|
+
|
157
|
+
splitleft.preferred_width w/2
|
158
|
+
splitleft.preferred_height ht/2-2
|
159
|
+
#splitleft.set_resize_weight 0.50
|
160
|
+
ta1.min_width 10
|
161
|
+
ta1.min_height 5
|
162
|
+
splitleft.min_width 12
|
163
|
+
splitleft.min_height 6
|
164
|
+
ret = outer.reset_to_preferred_sizes
|
165
|
+
outer.set_resize_weight(0.50) if ret == :ERROR
|
166
|
+
|
167
|
+
File.open("../README.markdown","r") do |file|
|
168
|
+
while (line = file.gets)
|
169
|
+
ta1 << line.chomp
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
@form.repaint
|
174
|
+
@window.wrefresh
|
175
|
+
Ncurses::Panel.update_panels
|
176
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
177
|
+
str = keycode_tos ch
|
178
|
+
case ch
|
179
|
+
#when ?v.getbyte(0)
|
180
|
+
#$log.debug " ORIENTATION VERTICAL"
|
181
|
+
#outer.orientation(:VERTICAL_SPLIT)
|
182
|
+
#outer.reset_to_preferred_sizes
|
183
|
+
#when ?h.getbyte(0)
|
184
|
+
#$log.debug " ORIENTATION HORIZ"
|
185
|
+
#outer.orientation(:HORIZONTAL_SPLIT)
|
186
|
+
#outer.reset_to_preferred_sizes
|
187
|
+
when ?-.getbyte(0)
|
188
|
+
$log.debug " KEY PRESS -"
|
189
|
+
outer.set_divider_location(outer.divider_location-1)
|
190
|
+
when ?+.getbyte(0)
|
191
|
+
$log.debug " KEY PRESS +"
|
192
|
+
outer.set_divider_location(outer.divider_location+1)
|
193
|
+
when ?=.getbyte(0)
|
194
|
+
$log.debug " KEY PRESS ="
|
195
|
+
outer.set_resize_weight(0.50)
|
196
|
+
end
|
197
|
+
#outer.get_buffer().wclear
|
198
|
+
#outer << "#{ch} got (#{str})"
|
199
|
+
# outer.repaint
|
200
|
+
# outer.buffer_to_screen
|
201
|
+
@form.repaint
|
202
|
+
@form.handle_key(ch)
|
203
|
+
@window.wrefresh
|
204
|
+
end
|
205
|
+
end
|
206
|
+
rescue => ex
|
207
|
+
ensure
|
208
|
+
@window.destroy if !@window.nil?
|
209
|
+
VER::stop_ncurses
|
210
|
+
p ex if ex
|
211
|
+
p(ex.backtrace.join("\n")) if ex
|
212
|
+
$log.debug( ex) if ex
|
213
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
#$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
|
2
|
+
#*******************************************************#
|
3
|
+
# testsplit3.rb #
|
4
|
+
# written by Rahul Kumar #
|
5
|
+
# January 14, 2010 #
|
6
|
+
# #
|
7
|
+
# test textview, split and textarea inside splitpane #
|
8
|
+
# #
|
9
|
+
#
|
10
|
+
# /---------|----------\
|
11
|
+
# | | |
|
12
|
+
# | 1 | 3 |
|
13
|
+
# +---------|----------|
|
14
|
+
# | 2 | 4 |
|
15
|
+
# | | |
|
16
|
+
# \---------|----------/
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# Released under ruby license. See #
|
20
|
+
# http://www.ruby-lang.org/en/LICENSE.txt #
|
21
|
+
# Copyright 2010, Rahul Kumar #
|
22
|
+
#*******************************************************#
|
23
|
+
require 'rubygems'
|
24
|
+
require 'ncurses'
|
25
|
+
require 'logger'
|
26
|
+
require 'rbcurse'
|
27
|
+
require 'rbcurse/rsplitpane'
|
28
|
+
require 'rbcurse/rtextarea'
|
29
|
+
require 'rbcurse/rtextview'
|
30
|
+
require 'rbcurse/rlistbox'
|
31
|
+
if $0 == __FILE__
|
32
|
+
include RubyCurses
|
33
|
+
include RubyCurses::Utils
|
34
|
+
|
35
|
+
begin
|
36
|
+
# Initialize curses
|
37
|
+
VER::start_ncurses # this is initializing colors via ColorMap.setup
|
38
|
+
$log = Logger.new("vv#{$0}.log")
|
39
|
+
$log.level = Logger::DEBUG
|
40
|
+
show_caret_flag = true
|
41
|
+
|
42
|
+
@window = VER::Window.root_window
|
43
|
+
|
44
|
+
catch(:close) do
|
45
|
+
colors = Ncurses.COLORS
|
46
|
+
@form = Form.new @window
|
47
|
+
@form.name = "Form::MAINFORM"
|
48
|
+
r = 1; c = 3; ht = 18; w = 70
|
49
|
+
r = 3; c = 7; ht = 24; w = 100
|
50
|
+
|
51
|
+
|
52
|
+
@help = "F1 to quit. -/+/= to resize outer split, M-, M+, M= for inner split: #{$0}"
|
53
|
+
RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
|
54
|
+
|
55
|
+
outer = SplitPane.new @form do
|
56
|
+
name "mainpane"
|
57
|
+
row r
|
58
|
+
col c
|
59
|
+
width w
|
60
|
+
height ht
|
61
|
+
#focusable false
|
62
|
+
orientation :VERTICAL_SPLIT
|
63
|
+
#orientation :HORIZONTAL_SPLIT
|
64
|
+
#set_resize_weight 0.60
|
65
|
+
end
|
66
|
+
# note that splitleft has no form. so focus has to be managed XXX
|
67
|
+
splitleft = SplitPane.new nil do
|
68
|
+
name "C1-left"
|
69
|
+
#row r
|
70
|
+
#col c
|
71
|
+
|
72
|
+
## earlier commented now bombing
|
73
|
+
width w/2 # 30
|
74
|
+
height ht #/2-1
|
75
|
+
|
76
|
+
#focusable false
|
77
|
+
orientation :HORIZONTAL_SPLIT
|
78
|
+
#orientation :VERTICAL_SPLIT
|
79
|
+
border_color $promptcolor
|
80
|
+
border_attrib Ncurses::A_NORMAL
|
81
|
+
end
|
82
|
+
splitrt = SplitPane.new nil do
|
83
|
+
name "C1-rt"
|
84
|
+
#row r
|
85
|
+
#col c
|
86
|
+
|
87
|
+
## earlier commented now bombing
|
88
|
+
width w/2 # 30
|
89
|
+
height ht #/2-1
|
90
|
+
|
91
|
+
#focusable false
|
92
|
+
orientation :HORIZONTAL_SPLIT
|
93
|
+
#orientation :VERTICAL_SPLIT
|
94
|
+
border_color $promptcolor
|
95
|
+
border_attrib Ncurses::A_NORMAL
|
96
|
+
end
|
97
|
+
ta1 = TextArea.new nil do
|
98
|
+
name "myTextArea1-left-bot"
|
99
|
+
#row 0
|
100
|
+
#col 0
|
101
|
+
width w/2-2
|
102
|
+
height (ht/2)-1
|
103
|
+
#height ht
|
104
|
+
title "README.mark"
|
105
|
+
title_attrib 'bold'
|
106
|
+
print_footer true
|
107
|
+
footer_attrib 'bold'
|
108
|
+
end
|
109
|
+
#ta1.show_caret=show_caret_flag
|
110
|
+
ta2 = TextArea.new nil do
|
111
|
+
name "myTextArea2-right-bot"
|
112
|
+
#row 0
|
113
|
+
#col 0
|
114
|
+
width w/2-2
|
115
|
+
height (ht/2)-1
|
116
|
+
#height ht
|
117
|
+
title "Scratch Pad"
|
118
|
+
title_attrib 'reverse'
|
119
|
+
print_footer true
|
120
|
+
footer_attrib 'bold'
|
121
|
+
end
|
122
|
+
#ta2.show_caret=show_caret_flag
|
123
|
+
|
124
|
+
t1 = TextView.new nil do
|
125
|
+
name "myView-right-top"
|
126
|
+
#row 0
|
127
|
+
#col 0
|
128
|
+
#width w-2
|
129
|
+
height ht
|
130
|
+
#height (ht/2)-1
|
131
|
+
width w/2-1
|
132
|
+
title "README.md"
|
133
|
+
title_attrib 'bold'
|
134
|
+
print_footer true
|
135
|
+
footer_attrib 'bold'
|
136
|
+
end
|
137
|
+
#t1.show_caret=show_caret_flag
|
138
|
+
content = File.open("../README.markdown","r").readlines
|
139
|
+
t1.set_content content #, :WRAP_WORD
|
140
|
+
|
141
|
+
# to see lower border i need to set height to ht/2 -2 in both cases, but that
|
142
|
+
# crashes ruby when i reduce height by 1.
|
143
|
+
t2 = TextView.new nil do
|
144
|
+
name "myView2-left-top"
|
145
|
+
#row 0
|
146
|
+
#col 0
|
147
|
+
width w/2-1
|
148
|
+
height ht
|
149
|
+
#height (ht/2)-1
|
150
|
+
title "NOTES"
|
151
|
+
title_attrib 'bold'
|
152
|
+
print_footer true
|
153
|
+
footer_attrib 'bold'
|
154
|
+
end
|
155
|
+
#t2.show_caret=show_caret_flag
|
156
|
+
content = File.open("../NOTES","r").readlines
|
157
|
+
t2.set_content content #, :WRAP_WORD
|
158
|
+
|
159
|
+
# the outer compo needs child set first else cursor does not reach up from
|
160
|
+
# lower levels. Is the connection broken ?
|
161
|
+
outer.first_component(splitleft)
|
162
|
+
outer.second_component(splitrt)
|
163
|
+
splitleft.first_component(t2)
|
164
|
+
splitleft.second_component(ta1)
|
165
|
+
splitrt.first_component(t1)
|
166
|
+
splitrt.second_component(ta2)
|
167
|
+
t2.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
|
168
|
+
t2.preferred_height (ht/2)-1 ## this messes things up when we change orientation
|
169
|
+
t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
|
170
|
+
t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
|
171
|
+
#t1.set_resize_weight 0.50
|
172
|
+
t2.min_width 15
|
173
|
+
t2.min_height 5
|
174
|
+
t1.min_width 12
|
175
|
+
t1.min_height 5
|
176
|
+
ta1.min_width 10
|
177
|
+
ta1.min_height 5
|
178
|
+
ta2.min_width 10
|
179
|
+
ta2.min_height 5
|
180
|
+
ret = splitleft.reset_to_preferred_sizes
|
181
|
+
splitleft.set_resize_weight(0.50) if ret == :ERROR
|
182
|
+
ret = splitrt.reset_to_preferred_sizes
|
183
|
+
splitrt.set_resize_weight(0.50) if ret == :ERROR
|
184
|
+
|
185
|
+
splitleft.preferred_width w/2
|
186
|
+
splitleft.preferred_height ht/2-2
|
187
|
+
splitleft.min_width 12
|
188
|
+
splitleft.min_height 6
|
189
|
+
splitrt.preferred_width w/2
|
190
|
+
splitrt.preferred_height ht/2-2
|
191
|
+
splitrt.min_width 12
|
192
|
+
splitrt.min_height 6
|
193
|
+
ret = outer.reset_to_preferred_sizes
|
194
|
+
outer.set_resize_weight(0.50) if ret == :ERROR
|
195
|
+
|
196
|
+
File.open("../README.markdown","r") do |file|
|
197
|
+
while (line = file.gets)
|
198
|
+
ta1 << line.chomp
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
@form.repaint
|
203
|
+
@window.wrefresh
|
204
|
+
Ncurses::Panel.update_panels
|
205
|
+
while((ch = @window.getchar()) != KEY_F1 )
|
206
|
+
str = keycode_tos ch
|
207
|
+
#case ch
|
208
|
+
#when ?v.getbyte(0)
|
209
|
+
#$log.debug " ORIENTATION VERTICAL"
|
210
|
+
#outer.orientation(:VERTICAL_SPLIT)
|
211
|
+
#outer.reset_to_preferred_sizes
|
212
|
+
#when ?h.getbyte(0)
|
213
|
+
#$log.debug " ORIENTATION HORIZ"
|
214
|
+
#outer.orientation(:HORIZONTAL_SPLIT)
|
215
|
+
#outer.reset_to_preferred_sizes
|
216
|
+
#when ?-.getbyte(0)
|
217
|
+
#$log.debug " KEY PRESS -"
|
218
|
+
#outer.set_divider_location(outer.divider_location-1)
|
219
|
+
#when ?+.getbyte(0)
|
220
|
+
#$log.debug " KEY PRESS +"
|
221
|
+
#outer.set_divider_location(outer.divider_location+1)
|
222
|
+
#when ?=.getbyte(0)
|
223
|
+
#$log.debug " KEY PRESS ="
|
224
|
+
#outer.set_resize_weight(0.50)
|
225
|
+
#end
|
226
|
+
#outer.get_buffer().wclear
|
227
|
+
#outer << "#{ch} got (#{str})"
|
228
|
+
# outer.repaint
|
229
|
+
# outer.buffer_to_screen
|
230
|
+
@form.repaint
|
231
|
+
@form.handle_key(ch)
|
232
|
+
@window.wrefresh
|
233
|
+
end
|
234
|
+
end
|
235
|
+
rescue => ex
|
236
|
+
ensure
|
237
|
+
@window.destroy if !@window.nil?
|
238
|
+
VER::stop_ncurses
|
239
|
+
p ex if ex
|
240
|
+
p(ex.backtrace.join("\n")) if ex
|
241
|
+
$log.debug( ex) if ex
|
242
|
+
$log.debug(ex.backtrace.join("\n")) if ex
|
243
|
+
end
|
244
|
+
end
|