rbhex-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/CHANGELOG +2000 -0
  4. data/LICENSE +56 -0
  5. data/README.md +44 -0
  6. data/examples/abasiclist.rb +179 -0
  7. data/examples/alpmenu.rb +50 -0
  8. data/examples/app.sample +19 -0
  9. data/examples/atree.rb +100 -0
  10. data/examples/bline.rb +136 -0
  11. data/examples/common/file.rb +45 -0
  12. data/examples/data/README.markdown +9 -0
  13. data/examples/data/brew.txt +38 -0
  14. data/examples/data/color.2 +37 -0
  15. data/examples/data/gemlist.txt +60 -0
  16. data/examples/data/lotr.txt +12 -0
  17. data/examples/data/ports.txt +136 -0
  18. data/examples/data/table.txt +37 -0
  19. data/examples/data/tasks.csv +88 -0
  20. data/examples/data/tasks.txt +27 -0
  21. data/examples/data/todo.txt +10 -0
  22. data/examples/data/todo.txt.bak +10 -0
  23. data/examples/data/todocsv.csv +28 -0
  24. data/examples/data/unix1.txt +21 -0
  25. data/examples/data/unix2.txt +11 -0
  26. data/examples/dbdemo.rb +502 -0
  27. data/examples/dirtree.rb +94 -0
  28. data/examples/newtabbedwindow.rb +100 -0
  29. data/examples/newtesttabp.rb +92 -0
  30. data/examples/tabular.rb +146 -0
  31. data/examples/tasks.rb +178 -0
  32. data/examples/term2.rb +84 -0
  33. data/examples/testbuttons.rb +296 -0
  34. data/examples/testcombo.rb +102 -0
  35. data/examples/testfields.rb +195 -0
  36. data/examples/testkeypress.rb +72 -0
  37. data/examples/testlistbox.rb +170 -0
  38. data/examples/testmessagebox.rb +140 -0
  39. data/examples/testprogress.rb +116 -0
  40. data/examples/testree.rb +106 -0
  41. data/examples/testwsshortcuts.rb +66 -0
  42. data/examples/testwsshortcuts2.rb +128 -0
  43. data/lib/rbhex.rb +6 -0
  44. data/lib/rbhex/core/docs/index.txt +73 -0
  45. data/lib/rbhex/core/include/action.rb +80 -0
  46. data/lib/rbhex/core/include/actionmanager.rb +49 -0
  47. data/lib/rbhex/core/include/appmethods.rb +214 -0
  48. data/lib/rbhex/core/include/bordertitle.rb +48 -0
  49. data/lib/rbhex/core/include/chunk.rb +203 -0
  50. data/lib/rbhex/core/include/io.rb +553 -0
  51. data/lib/rbhex/core/include/listbindings.rb +74 -0
  52. data/lib/rbhex/core/include/listcellrenderer.rb +140 -0
  53. data/lib/rbhex/core/include/listeditable.rb +317 -0
  54. data/lib/rbhex/core/include/listscrollable.rb +663 -0
  55. data/lib/rbhex/core/include/listselectable.rb +271 -0
  56. data/lib/rbhex/core/include/multibuffer.rb +83 -0
  57. data/lib/rbhex/core/include/orderedhash.rb +77 -0
  58. data/lib/rbhex/core/include/ractionevent.rb +73 -0
  59. data/lib/rbhex/core/include/rchangeevent.rb +27 -0
  60. data/lib/rbhex/core/include/rhistory.rb +95 -0
  61. data/lib/rbhex/core/include/rinputdataevent.rb +47 -0
  62. data/lib/rbhex/core/include/vieditable.rb +172 -0
  63. data/lib/rbhex/core/include/widgetmenu.rb +66 -0
  64. data/lib/rbhex/core/system/colormap.rb +165 -0
  65. data/lib/rbhex/core/system/keyboard.rb +150 -0
  66. data/lib/rbhex/core/system/keydefs.rb +30 -0
  67. data/lib/rbhex/core/system/ncurses.rb +236 -0
  68. data/lib/rbhex/core/system/panel.rb +162 -0
  69. data/lib/rbhex/core/system/window.rb +913 -0
  70. data/lib/rbhex/core/util/ansiparser.rb +119 -0
  71. data/lib/rbhex/core/util/app.rb +1228 -0
  72. data/lib/rbhex/core/util/basestack.rb +410 -0
  73. data/lib/rbhex/core/util/bottomline.rb +1859 -0
  74. data/lib/rbhex/core/util/colorparser.rb +77 -0
  75. data/lib/rbhex/core/util/focusmanager.rb +31 -0
  76. data/lib/rbhex/core/util/padreader.rb +192 -0
  77. data/lib/rbhex/core/util/rcommandwindow.rb +604 -0
  78. data/lib/rbhex/core/util/rdialogs.rb +574 -0
  79. data/lib/rbhex/core/util/viewer.rb +149 -0
  80. data/lib/rbhex/core/util/widgetshortcuts.rb +506 -0
  81. data/lib/rbhex/core/version.rb +5 -0
  82. data/lib/rbhex/core/widgets/applicationheader.rb +103 -0
  83. data/lib/rbhex/core/widgets/box.rb +58 -0
  84. data/lib/rbhex/core/widgets/divider.rb +310 -0
  85. data/lib/rbhex/core/widgets/keylabelprinter.rb +194 -0
  86. data/lib/rbhex/core/widgets/rcombo.rb +253 -0
  87. data/lib/rbhex/core/widgets/rcontainer.rb +415 -0
  88. data/lib/rbhex/core/widgets/rlink.rb +30 -0
  89. data/lib/rbhex/core/widgets/rlist.rb +696 -0
  90. data/lib/rbhex/core/widgets/rmenu.rb +958 -0
  91. data/lib/rbhex/core/widgets/rmenulink.rb +22 -0
  92. data/lib/rbhex/core/widgets/rmessagebox.rb +387 -0
  93. data/lib/rbhex/core/widgets/rprogress.rb +118 -0
  94. data/lib/rbhex/core/widgets/rtabbedpane.rb +634 -0
  95. data/lib/rbhex/core/widgets/rtabbedwindow.rb +70 -0
  96. data/lib/rbhex/core/widgets/rtextarea.rb +960 -0
  97. data/lib/rbhex/core/widgets/rtextview.rb +739 -0
  98. data/lib/rbhex/core/widgets/rtree.rb +768 -0
  99. data/lib/rbhex/core/widgets/rwidget.rb +3277 -0
  100. data/lib/rbhex/core/widgets/scrollbar.rb +143 -0
  101. data/lib/rbhex/core/widgets/statusline.rb +113 -0
  102. data/lib/rbhex/core/widgets/tabular.rb +264 -0
  103. data/lib/rbhex/core/widgets/tabularwidget.rb +1142 -0
  104. data/lib/rbhex/core/widgets/textpad.rb +995 -0
  105. data/lib/rbhex/core/widgets/tree/treecellrenderer.rb +150 -0
  106. data/lib/rbhex/core/widgets/tree/treemodel.rb +428 -0
  107. data/rbhex-core.gemspec +32 -0
  108. metadata +172 -0
@@ -0,0 +1,5 @@
1
+ module Rbhex
2
+ module Core
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,103 @@
1
+ # ----------------------------------------------------------------------------- #
2
+ # File: applicationheader.rb
3
+ # Description: Prints a header on first row, with right, left and centered text
4
+ # NOTE: on some terminal such as xterm-256color spaces do not print
5
+ # so you will see black or empty spaces between text.
6
+ # This does not happen on screen and xterm-color.
7
+ # I've done some roundabout stuff to circumvent that.
8
+ # Author: rkumar http://github.com/rkumar/rbcurse-core/
9
+ # Date:
10
+ # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
11
+ # Last update: 2011-11-16 - 00:07
12
+ #
13
+ # CHANGES:
14
+ # For some terminals, like xterm-256color which were not printing spaces
15
+ # I've changed to code so only text is printed where it has to with no
16
+ # padding. These terminals remove the padding color.
17
+ # ----------------------------------------------------------------------------- #
18
+ #
19
+ require 'rbhex/core/widgets/rwidget'
20
+ include RubyCurses
21
+ module RubyCurses
22
+ class ApplicationHeader < Widget
23
+ dsl_property :text1
24
+ dsl_property :text2
25
+ dsl_property :text_center
26
+ dsl_property :text_right
27
+
28
+
29
+ def initialize form, text1, config={}, &block
30
+
31
+ @name = "header"
32
+ @text1 = text1
33
+ # setting default first or else Widget will place its BW default
34
+ @color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor
35
+ super form, config, &block
36
+ @color_pair = get_color $bottomcolor, @color, @bgcolor
37
+ @window = form.window
38
+ @editable = false
39
+ @focusable = false
40
+ @cols ||= Ncurses.COLS-1
41
+ @row ||= 0
42
+ @col ||= 0
43
+ @repaint_required = true
44
+ #@color_pair ||= $bottomcolor # XXX this was forcing the color
45
+ #pair
46
+ @text2 ||= ""
47
+ @text_center ||= ""
48
+ @text_right ||= ""
49
+ end
50
+ def getvalue
51
+ @text1
52
+ end
53
+
54
+ ##
55
+ # XXX need to move wrapping etc up and done once.
56
+ def repaint
57
+ return unless @repaint_required
58
+
59
+ #print_header(htext, posy = 0, posx = 0)
60
+ att = get_attrib @attr
61
+ len = @window.width
62
+ len = Ncurses.COLS-0 if len == 0
63
+ # print a bar across the screen
64
+ @window.attron(Ncurses.COLOR_PAIR(@color_pair) | att)
65
+ @window.mvhline(@row, @col, 1, len)
66
+ @window.attroff(Ncurses.COLOR_PAIR(@color_pair) | att)
67
+ #print_header(@text1 + " %15s " % @text2 + " %20s" % @text_center , posy=0, posx=0)
68
+
69
+ # Now print the text in the correct positions with no padding, else some terminal
70
+ # will blacken the text out.
71
+ print_header("#{@text1} #{@text2}") # + " %20s" % @text_center , posy=0, posx=0)
72
+ print_center("#{@text_center}") # + " %20s" % @text_center , posy=0, posx=0)
73
+ print_top_right(@text_right)
74
+ @repaint_required = false
75
+ end
76
+ def print_header(htext, r = 0, c = 0)
77
+ #win = @window
78
+ #len = @window.width
79
+ #len = Ncurses.COLS-0 if len == 0
80
+ #
81
+ #@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
82
+ @form.window.printstring r, c, htext, @color_pair, @attr
83
+ end
84
+ def print_center(htext, r = 0, c = 0)
85
+ win = @window
86
+ len = win.getmaxx
87
+ len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS
88
+ #
89
+ #@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
90
+ win.printstring r, ((len-htext.length)/2).floor, htext, @color_pair, @attr
91
+ end
92
+ def print_top_right(htext)
93
+ hlen = htext.length
94
+ len = @window.getmaxx # width was not changing when resize happens
95
+ len = Ncurses.COLS-0 if len == 0 || len > Ncurses.COLS
96
+ $log.debug " def print_top_right(#{htext}) #{len} #{Ncurses.COLS} "
97
+ @form.window.printstring 0, len-hlen, htext, @color_pair, @attr
98
+ end
99
+ ##
100
+ ##
101
+ # ADD HERE
102
+ end
103
+ end
@@ -0,0 +1,58 @@
1
+ # ------------------------------------------------------------ #
2
+ # File: box.rb
3
+ # Description: draws a box around some group of items
4
+ # Author: rkumar http://github.com/rkumar/rbcurse/
5
+ # Date: 06.11.11 - 18:22
6
+ # Last update: 06.11.11 - 19:53
7
+ # ------------------------------------------------------------ #
8
+ #
9
+ require 'rbhex'
10
+ require 'rbhex/core/include/bordertitle'
11
+ include RubyCurses
12
+ #include RubyCurses::BorderTitle
13
+
14
+ # @example
15
+ #
16
+ # At a later stage, we will integrate this with lists and tables, so it will happen automatically.
17
+ #
18
+ # @since 1.4.1 UNTESTED
19
+ module RubyCurses
20
+ class Box < Widget
21
+
22
+ include BorderTitle
23
+
24
+ # margin for placing widgets inside
25
+ # This is not used inside here, but is used by stacks.
26
+ # @see widgetshortcuts.rb
27
+ dsl_accessor :margin_left, :margin_top
28
+
29
+ def initialize form, config={}, &block
30
+
31
+ bordertitle_init
32
+ super
33
+ @window = form.window if @form
34
+ @editable = false
35
+ @focusable = false
36
+ #@height += 1 # for that silly -1 that happens
37
+ @repaint_required = true
38
+ end
39
+
40
+ ##
41
+ # repaint the scrollbar
42
+ def repaint
43
+ return unless @repaint_required
44
+ bc = $datacolor
45
+ bordercolor = @border_color || bc
46
+ borderatt = @border_attrib || Ncurses::A_NORMAL
47
+ @window.print_border row, col, height, width, bordercolor, borderatt
48
+ #print_borders
49
+ print_title
50
+ @repaint_required = false
51
+ end
52
+ ##
53
+ ##
54
+ # ADD HERE
55
+ end
56
+ end
57
+ if __FILE__ == $PROGRAM_NAME
58
+ end
@@ -0,0 +1,310 @@
1
+ require 'rbhex/core/util/app'
2
+ #include Ncurses # FFI 2011-09-8
3
+ include RubyCurses
4
+
5
+ # TODO : We can consider making it independent of objects, or allow for a margin so it does not write
6
+ # over the object. Then it will be always visible.
7
+ # TODO: if lists and tables, can without borders actually adjust then putting this independent
8
+ # would make even more sense, since it won't eat an extra line.
9
+ #
10
+ # @example
11
+ # lb = list_box ....
12
+ # rb = Divider.new @form, :parent => lb, :side => :right
13
+ #
14
+ # At a later stage, we will integrate this with lists and tables, so it will happen automatically.
15
+ #
16
+ # @since 1.2.0
17
+ module RubyCurses
18
+ class DragEvent < Struct.new(:source, :type); end
19
+
20
+ # This is a horizontal or vertical bar (like a scrollbar), at present attached to a
21
+ # widget that is focusable, and allows user to press arrow keys.
22
+ # It highlights on focus, the caller can expand and contract components in a container
23
+ # or even screen, based on arrow movements. This allows for a visual resizing of components.
24
+ # @example
25
+ # lb = list_box ....
26
+ # rb = Divider.new @form, :parent => lb, :side => :right
27
+ #
28
+ # NOTE: since this can be deactivated, containers need to check focusable before passing
29
+ # focus in
30
+ # 2010-10-07 23:56 made focusable false by default. Add divider to
31
+ # FocusManager when creating, so F3 can be used to set focusable
32
+ # See rvimsplit.rb for example
33
+
34
+ class Divider < Widget
35
+ # row to start, same as listbox, required.
36
+ dsl_property :row
37
+ # column to start, same as listbox, required.
38
+ dsl_property :col
39
+ # how many rows is this (should be same as listboxes height, required.
40
+ dsl_property :length
41
+ # vertical or horizontal currently only VERTICAL
42
+ dsl_property :side
43
+ # initialize based on parent's values
44
+ dsl_property :parent
45
+ # which row is focussed, current_index of listbox, required.
46
+ # how many total rows of data does the list have, same as @list.length, required.
47
+ dsl_accessor :next_component # 'next' bombing in dsl_accessor 2011-10-2 PLS CHANGE ELSEWHERE
48
+
49
+ # TODO: if parent passed, we shold bind to ON_ENTER and get current_index, so no extra work is required.
50
+
51
+ def initialize form, config={}, &block
52
+
53
+ # setting default first or else Widget will place its BW default
54
+ #@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor
55
+ super
56
+ @height = 1
57
+ @color_pair = get_color $datacolor, @color, @bgcolor
58
+ @scroll_pair = get_color $bottomcolor, :green, :white
59
+ #@window = form.window
60
+ @editable = false
61
+ # you can set to true upon creation, or use F3 on vimsplit to
62
+ # toggle focusable
63
+ @focusable = false
64
+ @repaint_required = true
65
+ @_events.push(:DRAG_EVENT)
66
+ map_keys
67
+ unless @parent
68
+ raise ArgumentError, "row col and length should be provided" if !@row || !@col || !@length
69
+ end
70
+ #if @parent
71
+ #@parent.bind :ENTER_ROW do |p|
72
+ ## parent must implement row_count, and have a @current_index
73
+ #raise StandardError, "Parent must implement row_count" unless p.respond_to? :row_count
74
+ #self.current_index = p.current_index
75
+ #@repaint_required = true #requred otherwise at end when same value sent, prop handler
76
+ ## will not be fired (due to optimization).
77
+ #end
78
+ #end
79
+ end
80
+ def map_keys
81
+ if !defined? $deactivate_dividers
82
+ $deactivate_dividers = false
83
+ end
84
+ # deactivate only this bar
85
+ bind_key(?f) {@focusable=false; }
86
+ # deactivate all bars, i've had nuff!
87
+ bind_key(?F) {deactivate_all(true)}
88
+ end
89
+
90
+ ##
91
+ # repaint the scrollbar
92
+ # Taking the data from parent as late as possible in case parent resized, or
93
+ # moved around by a container.
94
+ # NOTE: sometimes if this is inside another object, the divider repaints but then
95
+ # is wiped out when that objects print_border is called. So such an obkect (e.g.
96
+ # vimsplit) should call repaint after its has done its own repaint. that does mean
97
+ # the repaint happens twice during movement
98
+ def repaint
99
+ woffset = 2
100
+ coffset = 1
101
+ if @parent
102
+ woffset = 0 if @parent.suppress_borders
103
+ @border_attrib ||= @parent.border_attrib
104
+ case @side
105
+ when :right
106
+ @row = @parent.row+1
107
+ @col = @parent.col + @parent.width - 0
108
+ @length = @parent.height - woffset
109
+ when :left
110
+ @row = @parent.row+1
111
+ @col = @parent.col+0 #+ @parent.width - 1
112
+ @length = @parent.height - woffset
113
+ when :top
114
+ @row = @parent.row+0
115
+ @col = @parent.col + @parent.col_offset #+ @parent.width - 1
116
+ @length = @parent.width - woffset
117
+ when :bottom
118
+ @row = @parent.row+@parent.height-0 #1
119
+ @col = @parent.col+@parent.col_offset #+ @parent.width - 1
120
+ @length = @parent.width - woffset
121
+ end
122
+ else
123
+ # row, col and length should be passed
124
+ end
125
+ my_win = @form ? @form.window : @target_window
126
+ @graphic = my_win unless @graphic
127
+ raise "graphic is nil in divider, perhaps form was nil when creating" unless @graphic
128
+ return unless @repaint_required
129
+
130
+ # first print a right side vertical line
131
+ #bc = $bottomcolor # dark blue
132
+ bc = get_color($datacolor, :cyan, :black)
133
+ bordercolor = @border_color || bc
134
+ borderatt = @border_attrib || Ncurses::A_REVERSE
135
+ if @focussed
136
+ bordercolor = $promptcolor || bordercolor
137
+ end
138
+
139
+ borderatt = convert_attrib_to_sym(borderatt) if borderatt.is_a? Symbol
140
+
141
+ @graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
142
+ $log.debug " XXX DIVIDER #{@row} #{@col} #{@length} "
143
+ case @side
144
+ when :right, :left
145
+ @graphic.mvvline(@row, @col, 1, @length)
146
+ when :top, :bottom
147
+ @graphic.mvhline(@row, @col, 1, @length)
148
+ end
149
+ @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
150
+ _paint_marker
151
+ #alert "divider repaint at #{row} #{col} "
152
+
153
+ @repaint_required = false
154
+ end
155
+ def convert_attrib_to_sym attr
156
+ case attr
157
+ when 'reverse'
158
+ Ncurses::A_REVERSE
159
+ when 'bold'
160
+ Ncurses::A_BOLD
161
+ when 'normal'
162
+ Ncurses::A_NORMAL
163
+ when 'blink'
164
+ Ncurses::A_BLINK
165
+ when 'underline'
166
+ Ncurses::A_UNDERLINE
167
+ else
168
+ Ncurses::A_REVERSE
169
+ end
170
+ end
171
+ # deactivate all dividers
172
+ # The application has to provide a key or button to activate all
173
+ # or just this one.
174
+ def deactivate_all tf=true
175
+ $deactivate_dividers = tf
176
+ @focusable = !tf
177
+ end
178
+ def handle_key ch
179
+ # all dividers have been deactivated
180
+ if $deactivate_dividers || !@focusable
181
+ @focusable = false
182
+ return :UNHANDLED
183
+ end
184
+ case @side
185
+ when :right, :left
186
+ case ch
187
+ when KEY_RIGHT
188
+ fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
189
+ when KEY_LEFT
190
+ fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
191
+ else
192
+ ret = process_key ch, self
193
+ return ret if ret == :UNHANDLED
194
+ end
195
+ set_form_col
196
+ when :top, :bottom
197
+ case ch
198
+ when KEY_UP
199
+ fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
200
+ when KEY_DOWN
201
+ fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
202
+ else
203
+ ret = process_key ch, self
204
+ return ret if ret == :UNHANDLED
205
+ end
206
+ set_form_col
207
+ else
208
+ end
209
+ @repaint_required = true
210
+ return 0
211
+ end
212
+ def on_enter
213
+ if $deactivate_dividers || !@focusable
214
+ @focusable = false
215
+ return :UNHANDLED
216
+ end
217
+ # since it is over border of component, we need to repaint
218
+ @focussed = true
219
+ @repaint_required = true
220
+ repaint
221
+ end
222
+ def on_leave
223
+ @focussed = false
224
+ @repaint_required = true
225
+ repaint
226
+ # TODO: we should review this since its not over the parent any longer
227
+ if @parent
228
+ # since it is over border of component, we need to clear
229
+ @parent.repaint_required
230
+ # if we don't paint now, parent paints over other possible dividers
231
+ @parent.repaint
232
+ end
233
+ end
234
+ def set_form_row
235
+ return unless @focusable
236
+ r,c = rowcol
237
+ setrowcol r, c
238
+ end
239
+ # set the cursor on first point of bar
240
+ def set_form_col
241
+ return unless @focusable
242
+ # need to set it to first point, otherwise it could be off the widget
243
+ r,c = rowcol
244
+ setrowcol r, c
245
+ end
246
+ # is this a vertical divider
247
+ def v?
248
+ @side == :top || @side == :bottom
249
+ end
250
+ # is this a horizontal divider
251
+ def h?
252
+ @side == :right || @side == :left
253
+ end
254
+ private
255
+ def _paint_marker #:nodoc:
256
+ r,c = rowcol
257
+ if @focussed
258
+ @graphic.mvwaddch r,c, Ncurses::ACS_DIAMOND
259
+ if v?
260
+ @graphic.mvwaddch r,c+1, Ncurses::ACS_UARROW
261
+ @graphic.mvwaddch r,c+2, Ncurses::ACS_DARROW
262
+ else
263
+ @graphic.mvwaddch r+1,c, Ncurses::ACS_LARROW
264
+ @graphic.mvwaddch r+2,c, Ncurses::ACS_RARROW
265
+ end
266
+ else
267
+ #@graphic.mvwaddch r,c, Ncurses::ACS_CKBOARD
268
+ end
269
+ end
270
+ ##
271
+ ##
272
+ # ADD HERE
273
+ end # class
274
+ end # module
275
+ if __FILE__ == $PROGRAM_NAME
276
+ App.new do
277
+ r = 5
278
+ len = 20
279
+ list = []
280
+ 0.upto(100) { |v| list << "#{v} scrollable data" }
281
+ lb = list_box "A list", :list => list, :row => 2, :col => 2
282
+ #sb = Scrollbar.new @form, :row => r, :col => 20, :length => len, :list_length => 50, :current_index => 0
283
+ rb = Divider.new @form, :parent => lb, :side => :right
284
+ rb.bind :DRAG_EVENT do |e|
285
+ message "got an event #{e.type} "
286
+ case e.type
287
+ when KEY_RIGHT
288
+ lb.width += 1
289
+ when KEY_LEFT
290
+ lb.width -= 1
291
+ end
292
+ lb.repaint_required
293
+ end
294
+ rb1 = Divider.new @form, :parent => lb, :side => :bottom
295
+ rb.focusable(true)
296
+ rb1.focusable(true)
297
+ rb1.bind :DRAG_EVENT do |e|
298
+ message " 2 got an event #{e.type} "
299
+ end
300
+ #hline :width => 20, :row => len+r
301
+ #keypress do |ch|
302
+ #case ch
303
+ #when :down
304
+ #sb.current_index += 1
305
+ #when :up
306
+ #sb.current_index -= 1
307
+ #end
308
+ #end
309
+ end
310
+ end