rbcurse 1.4.1 → 1.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/CHANGELOG +31 -0
  2. data/README.markdown +69 -11
  3. data/VERSION +1 -1
  4. data/lib/rbcurse.rb +5 -5
  5. metadata +10 -198
  6. data/Makefile +0 -21
  7. data/Manifest.txt +0 -91
  8. data/TODO +0 -372
  9. data/TODO2.txt +0 -118
  10. data/examples/README.txt +0 -67
  11. data/examples/abasiclist.rb +0 -33
  12. data/examples/alpmenu.rb +0 -42
  13. data/examples/app.rb +0 -859
  14. data/examples/app.sample +0 -10
  15. data/examples/appdirtree.rb +0 -75
  16. data/examples/appemail.rb +0 -191
  17. data/examples/appemaillb.rb +0 -308
  18. data/examples/appgcompose.rb +0 -315
  19. data/examples/atree.rb +0 -64
  20. data/examples/common/file.rb +0 -40
  21. data/examples/common/rmail.rb +0 -257
  22. data/examples/data.txt +0 -683
  23. data/examples/data/README.markdown +0 -9
  24. data/examples/data/brew.txt +0 -38
  25. data/examples/data/color.2 +0 -37
  26. data/examples/data/gemlist.txt +0 -60
  27. data/examples/data/lotr.txt +0 -12
  28. data/examples/data/ports.txt +0 -136
  29. data/examples/data/tasks.txt +0 -27
  30. data/examples/data/todocsv.csv +0 -28
  31. data/examples/data/unix1.txt +0 -21
  32. data/examples/data/unix2.txt +0 -11
  33. data/examples/dbdemo.rb +0 -495
  34. data/examples/deprecated/appgmail.rb +0 -952
  35. data/examples/deprecated/splitp.rb +0 -56
  36. data/examples/deprecated/testscrolllb.rb +0 -86
  37. data/examples/deprecated/testscrollp.rb +0 -88
  38. data/examples/deprecated/testscrollta.rb +0 -80
  39. data/examples/deprecated/testscrolltable.rb +0 -165
  40. data/examples/deprecated/testsplit.rb +0 -87
  41. data/examples/deprecated/testsplit2.rb +0 -123
  42. data/examples/deprecated/testsplit3.rb +0 -215
  43. data/examples/deprecated/testsplit3_1.rb +0 -244
  44. data/examples/deprecated/testsplit3a.rb +0 -215
  45. data/examples/deprecated/testsplit3b.rb +0 -237
  46. data/examples/deprecated/testsplitta.rb +0 -148
  47. data/examples/deprecated/testsplittv.rb +0 -142
  48. data/examples/deprecated/testsplittvv.rb +0 -144
  49. data/examples/deprecated/testtpane.rb +0 -215
  50. data/examples/deprecated/testtpane2.rb +0 -145
  51. data/examples/deprecated/testtpanetable.rb +0 -203
  52. data/examples/dirtree.rb +0 -88
  53. data/examples/experimental/resultsetdemo.rb +0 -280
  54. data/examples/experimental/testmform.rb +0 -35
  55. data/examples/experimental/testscroller.rb +0 -117
  56. data/examples/experimental/teststackflow.rb +0 -111
  57. data/examples/menu1.rb +0 -112
  58. data/examples/multispl.rb +0 -86
  59. data/examples/newmessagebox.rb +0 -130
  60. data/examples/newtabbedwindow.rb +0 -100
  61. data/examples/newtesttabp.rb +0 -121
  62. data/examples/qdfilechooser.rb +0 -68
  63. data/examples/rfe.rb +0 -1195
  64. data/examples/rfe_renderer.rb +0 -121
  65. data/examples/sqlc.rb +0 -454
  66. data/examples/sqlm.rb +0 -437
  67. data/examples/sqlt.rb +0 -408
  68. data/examples/status.txt +0 -68
  69. data/examples/table1.rb +0 -24
  70. data/examples/term2.rb +0 -84
  71. data/examples/test1.rb +0 -239
  72. data/examples/test2.rb +0 -674
  73. data/examples/testapp.rb +0 -44
  74. data/examples/testapp2.rb +0 -58
  75. data/examples/testchars.rb +0 -137
  76. data/examples/testcombo.rb +0 -91
  77. data/examples/testkeypress.rb +0 -66
  78. data/examples/testlistbox.rb +0 -113
  79. data/examples/testmenu.rb +0 -101
  80. data/examples/testmulticomp.rb +0 -70
  81. data/examples/testmulticontainer.rb +0 -94
  82. data/examples/testmultispl.rb +0 -199
  83. data/examples/testree.rb +0 -106
  84. data/examples/testtable.rb +0 -263
  85. data/examples/testtabp.rb +0 -107
  86. data/examples/testtodo.rb +0 -584
  87. data/examples/testvimsplit.rb +0 -112
  88. data/examples/testwsshortcuts.rb +0 -64
  89. data/examples/testwsshortcuts2.rb +0 -126
  90. data/examples/todo.db +0 -0
  91. data/examples/todo.yml +0 -191
  92. data/examples/viewtodo.rb +0 -574
  93. data/lib/rbcurse/action.rb +0 -40
  94. data/lib/rbcurse/app.rb +0 -1374
  95. data/lib/rbcurse/applicationheader.rb +0 -102
  96. data/lib/rbcurse/celleditor.rb +0 -112
  97. data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
  98. data/lib/rbcurse/colormap.rb +0 -159
  99. data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
  100. data/lib/rbcurse/common/ansiparser.rb +0 -117
  101. data/lib/rbcurse/common/appmethods.rb +0 -112
  102. data/lib/rbcurse/common/basestack.rb +0 -407
  103. data/lib/rbcurse/common/bordertitle.rb +0 -41
  104. data/lib/rbcurse/common/chunk.rb +0 -177
  105. data/lib/rbcurse/common/colorparser.rb +0 -71
  106. data/lib/rbcurse/common/keydefs.rb +0 -30
  107. data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
  108. data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
  109. data/lib/rbcurse/deprecated/README.markdown +0 -12
  110. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  111. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  112. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  113. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  114. data/lib/rbcurse/experimental/README.markdown +0 -14
  115. data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
  116. data/lib/rbcurse/experimental/stackflow.rb +0 -478
  117. data/lib/rbcurse/extras/bottomline.rb +0 -1850
  118. data/lib/rbcurse/extras/box.rb +0 -58
  119. data/lib/rbcurse/extras/directorylist.rb +0 -467
  120. data/lib/rbcurse/extras/directorytree.rb +0 -69
  121. data/lib/rbcurse/extras/divider.rb +0 -310
  122. data/lib/rbcurse/extras/focusmanager.rb +0 -31
  123. data/lib/rbcurse/extras/horizlist.rb +0 -203
  124. data/lib/rbcurse/extras/listselectable.rb +0 -264
  125. data/lib/rbcurse/extras/masterdetail.rb +0 -166
  126. data/lib/rbcurse/extras/menutree.rb +0 -63
  127. data/lib/rbcurse/extras/multiform.rb +0 -330
  128. data/lib/rbcurse/extras/multilinelabel.rb +0 -142
  129. data/lib/rbcurse/extras/newmessagebox.rb +0 -328
  130. data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
  131. data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
  132. data/lib/rbcurse/extras/padreader.rb +0 -189
  133. data/lib/rbcurse/extras/rcomboedit.rb +0 -256
  134. data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
  135. data/lib/rbcurse/extras/rlink.rb +0 -27
  136. data/lib/rbcurse/extras/rmenulink.rb +0 -21
  137. data/lib/rbcurse/extras/scrollbar.rb +0 -143
  138. data/lib/rbcurse/extras/statusline.rb +0 -94
  139. data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
  140. data/lib/rbcurse/extras/tableextended.rb +0 -40
  141. data/lib/rbcurse/extras/tabular.rb +0 -264
  142. data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
  143. data/lib/rbcurse/extras/textpad.rb +0 -516
  144. data/lib/rbcurse/extras/viewer.rb +0 -136
  145. data/lib/rbcurse/io.rb +0 -850
  146. data/lib/rbcurse/keylabelprinter.rb +0 -178
  147. data/lib/rbcurse/listcellrenderer.rb +0 -140
  148. data/lib/rbcurse/listeditable.rb +0 -310
  149. data/lib/rbcurse/listkeys.rb +0 -37
  150. data/lib/rbcurse/listscrollable.rb +0 -564
  151. data/lib/rbcurse/listselectable.rb +0 -142
  152. data/lib/rbcurse/mapper.rb +0 -130
  153. data/lib/rbcurse/orderedhash.rb +0 -77
  154. data/lib/rbcurse/ractionevent.rb +0 -67
  155. data/lib/rbcurse/rbasiclistbox.rb +0 -768
  156. data/lib/rbcurse/rchangeevent.rb +0 -27
  157. data/lib/rbcurse/rcombo.rb +0 -238
  158. data/lib/rbcurse/rcommandwindow.rb +0 -587
  159. data/lib/rbcurse/rcontainer.rb +0 -415
  160. data/lib/rbcurse/rdialogs.rb +0 -451
  161. data/lib/rbcurse/rinputdataevent.rb +0 -47
  162. data/lib/rbcurse/rlistbox.rb +0 -1196
  163. data/lib/rbcurse/rmenu.rb +0 -939
  164. data/lib/rbcurse/rmessagebox.rb +0 -348
  165. data/lib/rbcurse/rmulticontainer.rb +0 -304
  166. data/lib/rbcurse/rmultisplit.rb +0 -722
  167. data/lib/rbcurse/rmultitextview.rb +0 -306
  168. data/lib/rbcurse/rpopupmenu.rb +0 -755
  169. data/lib/rbcurse/rprogress.rb +0 -118
  170. data/lib/rbcurse/rscrollform.rb +0 -418
  171. data/lib/rbcurse/rtabbedpane.rb +0 -1158
  172. data/lib/rbcurse/rtabbedwindow.rb +0 -167
  173. data/lib/rbcurse/rtable.rb +0 -1718
  174. data/lib/rbcurse/rtextarea.rb +0 -920
  175. data/lib/rbcurse/rtextview.rb +0 -761
  176. data/lib/rbcurse/rtree.rb +0 -780
  177. data/lib/rbcurse/rvimsplit.rb +0 -763
  178. data/lib/rbcurse/rwidget.rb +0 -2915
  179. data/lib/rbcurse/scrollable.rb +0 -301
  180. data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
  181. data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
  182. data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
  183. data/lib/rbcurse/tree/treemodel.rb +0 -428
  184. data/lib/rbcurse/undomanager.rb +0 -188
  185. data/lib/rbcurse/vieditable.rb +0 -144
  186. data/lib/ver/keyboard.rb +0 -150
  187. data/lib/ver/keyboard2.rb +0 -170
  188. data/lib/ver/ncurses.rb +0 -218
  189. data/lib/ver/panel.rb +0 -162
  190. data/lib/ver/rpad.rb +0 -375
  191. data/lib/ver/window.rb +0 -882
  192. data/test/test_rbcurse.rb +0 -0
@@ -1,79 +0,0 @@
1
- require 'rbcurse/listselectable'
2
- ##
3
- # Added ListSelectionEvents on 2009-02-13 23:33
4
- # Data model for list selections. Uses index or indices, or value/values. Please avoid using "row"
5
- # as this is not clear to user, and will be deprecated.
6
- # 2010-09-21 19:43 source now contains List object, not this class
7
-
8
- module RubyCurses
9
- class DefaultListSelectionModel
10
- include EventHandler
11
- attr_accessor :selection_mode
12
- attr_reader :anchor_selection_index
13
- attr_reader :lead_selection_index
14
- attr_reader :parent
15
- def initialize parent
16
- raise ArgumentError "Parent cannot be nil. Please pass List while creating" if parent.nil?
17
- @parent = parent
18
-
19
- @selected_indices=[]
20
- @anchor_selection_index = -1
21
- @lead_selection_index = -1
22
- @selection_mode = 'multiple'
23
- @_events = [:LIST_SELECTION_EVENT]
24
-
25
- #$log.debug " created DefaultListSelectionModel XXX"
26
- end
27
- #def event_list
28
- #return @@events if defined? @@events
29
- #nil
30
- #end
31
-
32
- def clear_selection
33
- ix0 = @selected_indices.first
34
- ix1 = @selected_indices.last
35
- @selected_indices=[]
36
- return if ix0.nil?
37
- lse = ListSelectionEvent.new(ix0, ix1, @parent, :DELETE)
38
- fire_handler :LIST_SELECTION_EVENT, lse
39
- end
40
- def is_selected_index ix
41
- @selected_indices.include? ix
42
- end
43
- def get_max_selection_index
44
- @selected_indices[-1]
45
- end
46
- def get_min_selection_index
47
- @selected_indices[0]
48
- end
49
- def get_selected_indices
50
- @selected_indices
51
- end
52
- alias :get_selected_rows :get_selected_indices
53
- ## TODO should go in sorted, and no dupes
54
- def add_selection_interval ix0, ix1
55
- $log.debug " def add_selection_interval #{ix0}, #{ix1}, mode: #{@selection_mode} "
56
- if @selection_mode != :multiple
57
- clear_selection
58
- end
59
- @anchor_selection_index = ix0
60
- @lead_selection_index = ix1
61
- ix0.upto(ix1) {|i| @selected_indices << i unless @selected_indices.include? i }
62
- lse = ListSelectionEvent.new(ix0, ix1, @parent, :INSERT)
63
- fire_handler :LIST_SELECTION_EVENT, lse
64
- $log.debug " DLSM firing LIST_SELECTION EVENT #{lse}"
65
- end
66
- def remove_selection_interval ix0, ix1
67
- @anchor_selection_index = ix0
68
- @lead_selection_index = ix1
69
- @selected_indices.delete_if {|x| x >= ix0 and x <= ix1}
70
- lse = ListSelectionEvent.new(ix0, ix1, @parent, :DELETE)
71
- fire_handler :LIST_SELECTION_EVENT, lse
72
- end
73
- def insert_index_interval ix0, len
74
- @anchor_selection_index = ix0
75
- @lead_selection_index = ix0+len
76
- add_selection_interval @anchor_selection_index, @lead_selection_index
77
- end
78
- end # class DefaultListSelectionModel
79
- end
@@ -1,12 +0,0 @@
1
- == Short Story
2
-
3
- If you are new here, don't touch anything in this directory.
4
-
5
- == Long Story
6
-
7
- This directory contains stuff that was once used, but has since been rewritten in a simpler form.
8
- Thus, I've replaced this with the simpler form. This still exists for anyone who was using it.
9
-
10
- Some old stuff was either rather ambitiously rewritten or written awfully like MessageBox. I've got a more sensible version up now. Stuff here will *NOT* be maintained by me anylonger.
11
-
12
- There's also stuff here that will *NOT* work any longer such as SplitPanes and ScrollPanes. Support for them has been removed from the core (Form, widget and window) since it was complicating the core too much.
@@ -1,512 +0,0 @@
1
- =begin
2
- * Name: Scrollpane
3
- * Description: a scrollable widget allowing user to scroll and view
4
- parts of underlying object that typically are larger than screen area.
5
- Mainly, contains a viewport, scrollbars and manages viewport through usage
6
- of scrollbars.
7
- Also contains viewport for row and columns.
8
- * Author: rkumar
9
- Todo section:
10
- - add events, property changed etc at least for scrolling - DONE
11
- SCrollpane normall should listen in to changes in viewport, however Scro calls those very methods
12
- and what's more, other classes would listen to SCR and not to VP.
13
- - scrollbars to be classes - shall we avoid over-engineering, and KISS
14
- - if scrollpane reduced it should also resize, as example inside splitpane.
15
- * file created 2009-10-27 19:20
16
- * Added a call to child's set_form_col from set_form_row
17
- Major changes 2010-02-11 19:51 to simplify version RFED16
18
- * Still need to clean up this and viewport. make as light as possible
19
- * If scrolling, no repainting should happen. Scrollpane could get the buffer
20
- and scroll itself. Or ensure that inner object does not rework...
21
-
22
- Pass handle_key to child, also repaint refer child.
23
- Avoid passing to viewport as this would slow down alot.
24
-
25
- NOTE: if a caller is interested in knowing what scrolling has happened, pls bind to :STATE_CHANGE, you will receive the viewport object. If you find this cumbersome, and wish to know only about scrolling, we can put in a scrolling event and inform of row or col scrolling. Or we can fire a property change with row or col increment.
26
-
27
-
28
- --------
29
- * License:
30
- Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
31
-
32
- =end
33
- #require 'rubygems'
34
- #require 'ncurses'
35
- require 'logger'
36
- require 'rbcurse'
37
- require 'rbcurse/rviewport'
38
-
39
- #include Ncurses # FFI 2011-09-8
40
- include RubyCurses
41
- module RubyCurses
42
- extend self
43
-
44
- ##
45
- # A scrollable box throgh which one can see portions of underlying object
46
- # such as textarea, table or a form, usually the underlying data is larger
47
- # than what can be displayed.
48
-
49
- class ScrollPane < Widget
50
- # viewport
51
- # row_viewport
52
- # column_viewport
53
- # horizontal scrollbar 0-NONE, 1=ALWAYS, 2=AS_NEEDED
54
- # vertical scrollbar 0-NONE, 1=ALWAYS, 2=AS_NEEDED
55
- attr_accessor :cascade_changes # should changes in size go down to child, default false
56
-
57
- def initialize form, config={}, &block
58
- @focusable = true
59
- @editable = false
60
- #@left_margin = 1
61
- @row = 0
62
- @col = 0
63
- super
64
- @row_offset = @col_offset = 1
65
- init_vars
66
- @_events.push :STATE_CHANGE
67
- # $log.debug " SCROLLPANE recvs form #{form.name}, #{form.window.name} " unless form.nil?
68
-
69
-
70
- end
71
- ##
72
- # set child component being used in viewport
73
- # @see set_viewport_view
74
- def child ch
75
- if ch != nil
76
- @child = ch # added 2010-02-11 15:28 we might do away with viewport, setting panned to child
77
- @child.rows_panned = @child.cols_panned = 0
78
-
79
- ch.parent_component = self # added 2010-01-13 12:55 so offsets can go down ?
80
-
81
- @child.should_create_buffer = true
82
- @form.add_rows += 2 # related to scr_top XXX What if form not set. i cannot keep accumulating
83
- update_child
84
- # -3 since we start row +1 to get indented by 1, also we use
85
- # height -1 in scrollpane, so we need -2 to indent, and one more
86
- # for row
87
- set_viewport_view(ch)
88
- end
89
- end
90
- ##
91
- # update of child's coordinates, needs to be called whenever it
92
- # changes, so i need to call it before calling child's update
93
- # FIXME - this is become 2 calls, make it one - becoming expensive
94
- # if called often
95
- def update_child
96
- scr_top = 3 # for Pad, if Pad passed as in SplitPane
97
- scr_left = 1 # for Pad, if Pad passed as in SplitPane
98
- if @form.window.window_type == :WINDOW
99
- scr_top = @row + 1
100
- scr_left = @col + 1
101
- @child.row(@row+@row_offset)
102
- @child.col(@col+@col_offset)
103
- else
104
- # PAD case
105
- @child.row(scr_top)
106
- @child.col(scr_left)
107
- end
108
- @child.set_buffering(:target_window => @target_window || @form.window, :form => @form, :bottom => @height-3, :right => @width-3 )
109
- @child.set_buffering(:screen_top => scr_top, :screen_left => scr_left)
110
- # lets set the childs ext offsets
111
- $log.debug "SCRP #{name} adding (to #{@child.name}) ext_row_off: #{@child.ext_row_offset} += #{@ext_row_offset} +#{@row_offset} "
112
- $log.debug "SCRP adding ext_col_off: #{@child.ext_col_offset} += #{@ext_col_offset} +#{@col_offset} "
113
- ## 2010-02-09 18:58 i think we should not put col_offset since the col
114
- ## of child would take care of that. same for row_offset. XXX
115
- @child.ext_col_offset += @ext_col_offset + @col + @col_offset - @screen_left # 2010-02-09 19:14
116
- # added row and col setting to child RFED16 2010-02-17 00:22 as
117
- # in splitpane. seems we are not using ext_offsets now ? texta
118
- # and TV are not. and i've commented off from widget
119
-
120
- $log.debug " #{@child.ext_row_offset} += #{@ext_row_offset} + #{@row} -#{@screen_top} "
121
- @child.ext_row_offset += @ext_row_offset + @row + @row_offset - @screen_top
122
- # adding this since child's ht should not be less. or we have a
123
- # copywin failure
124
- @child.height ||= @height
125
- @child.width ||= @width
126
- if @child.height < @height
127
- @child.height = @height
128
- end
129
- if @child.width < @width
130
- @child.width = @width
131
- end
132
-
133
- end
134
- def init_vars
135
- #@curpos = @pcol = @toprow = @current_index = 0
136
- @hsb_policy = :AS_NEEDED
137
- @vsb_policy = :AS_NEEDED
138
- @repaint_required = true
139
- @repaint_border = true
140
- @row_outofbounds=0
141
- @col_outofbounds=0
142
- @border_width = 2
143
- @screen_top = 0
144
- @screen_left = 0
145
- end
146
- # set the component to be viewed
147
- def set_viewport_view ch
148
- @viewport = Viewport.new nil
149
- @viewport.set_view ch
150
- ## this -2 should depend on whether we are putting border/scrollbars or not.
151
- # -1 added on 2010-02-16 23:35 since we are red 1, and bw
152
- @viewport.set_view_size(@height-@border_width-0, @width-@border_width-0) # XXX make it one less
153
- @viewport.cascade_changes = @cascade_changes # added 2010-02-04 18:19
154
- @viewport.bind(:STATE_CHANGE) { |e| view_state_changed(e) }
155
- @viewport.bind(:PROPERTY_CHANGE) { |e| view_property_changed(e) }
156
- end
157
- # return underlying viewport
158
- # in order to run some of its methods
159
- def get_viewport
160
- return @viewport
161
- end
162
- # Directly set the viewport.
163
- # Usually it is best to use set_viewport_view instead
164
- def set_viewport vp
165
- old = @viewport
166
- @viewport = vp
167
- fire_property_change "viewport", old, @viewport
168
- end
169
- # sets the component to be used as a rowheader TODO
170
- def set_rowheader_view ch
171
- old = @rowheader
172
- @rowheader = Viewport.new
173
- @rowheader.set_view ch
174
- fire_property_change "row_header", old, @rowheader
175
- end
176
- # sets the component to be used as a column header TODO
177
- def set_columnheader_view ch
178
- old = @columnheader
179
- @columnheader = Viewport.new
180
- @columnheader.set_view ch
181
- fire_property_change "column_header", old, @columnheader
182
- end
183
- def set_view_size h,w
184
- # calling the property shoudl uniformally trigger fire_property_change
185
- @viewport.set_view_size h,w
186
- #height(h)
187
- #width(w)
188
- #fire_handler :PROPERTY_CHANGE, self # XXX should it be an event STATE_CHANGED with details
189
- end
190
- ## seems i wrote this only so i could set repaint_required to true
191
- # However, now that VP calls state changed, that will happen XXX
192
- def set_view_position r,c
193
- ret = @viewport.set_view_position r,c
194
- if ret
195
- @repaint_required = true if ret
196
- # fire_property_change("view_position",
197
- end
198
- return ret
199
- end
200
- # this method is registered with Viewport for changes
201
- def view_state_changed ev
202
- fire_handler :STATE_CHANGE, ev #???
203
- @repaint_required = true
204
- end
205
- # this method is registered with Viewport for changes to properties
206
- def view_property_changed ev
207
- fire_handler :PROPERTY_CHANGE, ev #???
208
- @repaint_required = true
209
- end
210
- # @return [true, false] false if r,c not changed
211
- def increment_view_row num
212
- #x r = @viewport.row() #- @viewport.top_margin
213
- #x c = @viewport.col() #- @viewport.left_margin
214
- r, c = @viewport.get_pad_top_left()
215
- $log.debug " SCR inc viewport currently : r #{r} c #{c} "
216
- r += num
217
- ret = set_view_position r, c
218
- v_scroll_bar if ret
219
- return ret
220
- end
221
- # @return [true, false] false if r,c not changed
222
- def increment_view_col num
223
- r, c = @viewport.get_pad_top_left()
224
- #r = @viewport.row() #- @viewport.top_margin
225
- #c = @viewport.col() #- @viewport.left_margin
226
- c += num
227
- ret = set_view_position r, c
228
- h_scroll_bar if ret
229
- return ret
230
- end
231
- def repaint # scrollpane
232
- # viewports child should repaint onto pad
233
- # viewport then clips
234
- # this calls viewports refresh from its refresh
235
- return unless @repaint_required
236
- if @viewport
237
- update_child
238
- $log.debug "SCRP #{@name} calling viewport repaint"
239
- #@viewport.repaint_all true # 2010-01-16 23:09
240
- @viewport.repaint_required true # changed 2010-01-19 19:34
241
- @viewport.repaint # child's repaint should do it on its pad
242
- $log.debug " #{@name} SCRP scrollpane repaint #{@graphic.name} "
243
- end
244
- # TODO this only if major change
245
- if @repaint_border && @repaint_all # added 2010-01-16 20:15
246
- #@graphic.wclear
247
- $log.debug " #{@name} repaint all scroll: r #{@row} c #{@col} h #{@height}-1 w #{@width} "
248
- bordercolor = @border_color || $datacolor
249
- borderatt = @border_attrib || Ncurses::A_NORMAL
250
- # NOTE - should be width-1 print_b reduces one from width, but
251
- # not height !
252
-
253
- @graphic.print_border_only(@row, @col, @height-1, @width, bordercolor, borderatt)
254
- h_scroll_bar
255
- v_scroll_bar
256
- #x XXX @viewport.repaint_all(true) unless @viewport.nil? # brought here 2010-01-19 19:34
257
- #@repaint_border = false # commented off on 2010-01-16 20:15 so repaint_all can have effect
258
- end
259
- return if @viewport == nil
260
- $log.debug "SCRP #{@name} calling viewport to SCRP b2s #{@graphic.name} "
261
- paint
262
- end
263
- def getvalue
264
- # TODO
265
- end
266
- ## handle keys for scrollpane.
267
- # First hands key to child object
268
- # If unused, checks to see if it has anything mapped.
269
- # If not consumed, returns :UNHANDLED, else 0.
270
- def handle_key ch
271
- # if this gets key it should just hand it to child
272
- return :UNHANDLED if @viewport.nil? # added 2010-02-02 12:44
273
- if @viewport != nil
274
- $log.debug " calling child handle_key #{ch} "
275
- ret = @viewport.handle_key ch
276
- # XXX ret returns 0under normal circumstance, so will next line work ?
277
- # what i mean is if ret == 0
278
-
279
- @repaint_required = true if ret == 0 # added 2009-12-27 22:21 BUFFERED
280
- $log.debug " ... child ret #{ret}"
281
-
282
-
283
- ## Here's the only option scrollpane has of checking whether the child has
284
- ##+ exceeded boundary BUFFERED 2009-12-29 23:12
285
- # TEMPORARILY COMMENTED WHILE TESTING SCROLL UP AND DOWN XXX
286
- #fr = @form.row
287
- #fc = @form.col
288
- #if fr >= @row + @height -2
289
- #@form.setrowcol @row + @height -2, fc
290
- #elsif fr < @row
291
- #@form.setrowcol @row, fc
292
- #end
293
- #if fc >= @col + @width -1
294
- #@form.setrowcol fr, @col + @width -1
295
- #end
296
- ##
297
-
298
- return ret if ret != :UNHANDLED
299
- end
300
- ret = 0 # default return value
301
- ks = keycode_tos(ch)
302
- $log.debug " scrollpane gets KEY #{ch}, ks #{ks} "
303
- case ch
304
- when ?\M-n.getbyte(0)
305
- ## scroll down one row (unless multiplier set)
306
- ret = down
307
- when ?\M-p.getbyte(0)
308
- ## scroll up one row (unless multiplier set)
309
- ret = up
310
- #when ?0.getbyte(0), ?\C-[.getbyte(0)
311
- #goto_start #start of buffer # cursor_start
312
- #when ?\C-].getbyte(0)
313
- #goto_end # end / bottom cursor_end # TODO
314
- when ?\M-\<.getbyte(0)
315
- @height.times { up ; }
316
- when ?\M-\>.getbyte(0)
317
- @height.times { down ; }
318
- when KEY_DOWN
319
- ret = down
320
- #check_curpos
321
- when ?\M-h.getbyte(0)
322
- ## scroll left one position
323
- repeatm {
324
- ret = cursor_backward
325
- @child.cols_panned = @child.cols_panned+1 if ret
326
- @form.setrowcol @form.row, @form.col+1+@col_outofbounds if ret
327
- }
328
- when ?\M-l.getbyte(0)
329
- ## scroll right one position
330
- repeatm {
331
- ret = cursor_forward
332
- @child.cols_panned = @child.cols_panned-1 if ret
333
- @form.setrowcol @form.row, @form.col-1+@col_outofbounds if ret
334
- }
335
- when KEY_BACKSPACE, KEY_BSPACE
336
- ret = cursor_backward
337
- #when ?\C-u.getbyte(0)
338
- ## multiplier. Series is 4 16 64
339
- #@multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
340
- #return 0
341
- when ?\C-c.getbyte(0)
342
- $multiplier = 0
343
- return 0
344
- else
345
- return :UNHANDLED
346
- end
347
- ret = :UNHANDLED if !ret
348
- $multiplier = 0
349
- return ret # 0 2010-02-04 18:47 returning ret else repaint is happening when UNHANDLED
350
- end
351
- # private
352
- def _down
353
- increment_view_row(1)
354
- end
355
- # private
356
- def _up
357
- increment_view_row(-1)
358
- end
359
- def cursor_forward
360
- increment_view_col(1)
361
- end
362
- def cursor_backward
363
- increment_view_col(-1)
364
- end
365
- def down
366
- ## scroll down one row (currently one only)
367
- $log.debug " MULT DOWN #{$multiplier} "
368
- repeatm {
369
- ret = _down
370
- return unless ret # 2010-02-04 18:29
371
- ## we've scrolled down, but we need to keep the cursor where
372
- ##+ editing actually is. Isn't this too specific to textarea ?
373
- $log.debug " SCRP setting row to #{@form.row-1} upon scrolling down "
374
- ## only move up the cursor if its within bounds
375
- # if @form.row > @row
376
- @child.rows_panned = @child.rows_panned-1 if ret
377
- @form.setrowcol @form.row-1+@row_outofbounds, @form.col if ret
378
- }
379
- end
380
- def up
381
- ## scroll up one row (currently one only)
382
- repeatm {
383
- ret = _up
384
- return unless ret # 2010-02-04 18:29
385
- $log.debug " SCRP setting row to #{@form.row+1} upon scrolling up R:#{@row} H:#{@height} "
386
- # if @form.row < @row + @height
387
- @child.rows_panned = @child.rows_panned+1 if ret
388
- @form.setrowcol @form.row+1+@row_outofbounds, @form.col if ret
389
- }
390
- end
391
- def on_enter
392
- #super 2010-01-02 18:53 leading to a stack overflow XXX ???
393
- set_form_row
394
- end
395
- # this is called once externally, on on_enter
396
- #+ after that its called internally only, which in this case is never
397
- def set_form_row
398
- #@form.row = @row + 1 unless @form.nil?
399
- if @viewport != nil
400
- #$log.debug " calling scrollpane set_form_row"
401
- ret = @viewport.child.set_form_row # added 2009-12-27 23:23 BUFFERED
402
- ret = @viewport.child.set_form_col # added 2010-01-16 21:09
403
- end
404
- $log.debug " FORM SCRP #{@form.name} "
405
- $log.debug "SCRP set_form_row #{@form.row} #{@form.col} "
406
- end
407
- ## added 2010-02-09 10:17
408
- # Sometimes some parent objects may just call this.
409
- # Would be better if they only called row and row called both ??? or is that less reliable
410
- # In any case we have to combine this someday!!
411
- def set_form_col
412
- #@form.row = @row + 1 unless @form.nil?
413
- if @viewport != nil
414
- #$log.debug " calling scrollpane set_form_row"
415
- ret = @viewport.child.set_form_col # added 2010-01-16 21:09
416
- end
417
- $log.debug " FORM SCRP #{@form.name} "
418
- $log.debug "SCRP set_form_col #{@form.row} #{@form.col} "
419
- end
420
-
421
- ## this is called once only, on select_field by form.
422
- ##+ after that not at all.
423
- def rowcol
424
- r1 = @row #+@row_offset
425
- c1 = @col #+@col_offset
426
- return r1, c1 if @viewport.nil? # added 2010-02-02 12:41
427
-
428
- r,c = @viewport.child.rowcol # added 2009-12-28 15:23 BUFFERED
429
- $log.debug "SCRP rowcol: #{r1} + #{r} , #{c1} + #{c} "
430
- return r1+r, c1+c
431
- end
432
-
433
- def paint
434
- @repaint_required = false
435
- @repaint_all = false
436
- end
437
- def h_scroll_bar
438
- return if @viewport.nil?
439
- sz = (@viewport.width*1.00/@viewport.child().width)*@viewport.width
440
- #$log.debug " h_scroll_bar sz #{sz}, #{@viewport.width} #{@viewport.child().width}"
441
- sz = sz.ceil
442
- return if sz < 1
443
- start = 1
444
- start = ((@viewport.col*1.00+@viewport.width)/@viewport.child().width)*@viewport.width
445
- start -= sz
446
- start = start.ceil
447
- # # the problem with next 2 lines is that attributes of border could be overwritten
448
- # draw horiz line
449
- r = @row #+ @ext_row_offset # 2010-02-11 11:57 RFED16
450
- c = @col #+ @ext_col_offset # 2010-02-11 11:57 RFED16
451
- $log.debug " h_scroll_bar start #{start}, r #{r} c #{c} h:#{@height} "
452
- @graphic.rb_mvwhline(r+@height-1, c+1, FFI::NCurses::ACS_HLINE, @width-2)
453
- # draw scroll bar
454
- #sz.times{ |i| @graphic.mvaddch(r+@height-1, c+start+1+i, FFI::NCurses::ACS_CKBOARD) }
455
- sz.times{ |i| @graphic.rb_mvaddch(r+@height-1, c+start+1+i, FFI::NCurses::ACS_CKBOARD) }
456
- end
457
- def v_scroll_bar
458
- return if @viewport.nil?
459
- sz = (@viewport.height*1.00/@viewport.child().height)*@viewport.height
460
- #$log.debug " v_scroll_bar sz #{sz}, #{@viewport.width} #{@viewport.child().width}"
461
- sz = sz.ceil
462
- return if sz < 1
463
- start = 1
464
- start = ((@viewport.row*1.00+@viewport.height)/@viewport.child().height)*@viewport.height
465
- start -= sz
466
- r = @row #+ @ext_row_offset # 2010-02-11 11:57 RFED16
467
- c = @col #+ @ext_col_offset # 2010-02-11 11:57 RFED16
468
- $log.debug " v_scroll_bar start #{start}, col:#{@col} w:#{@width}, r #{r}+1 c #{c}+w-1 "
469
- start = start.ceil
470
- # # the problem with next 2 lines is that attributes of border could be overwritten
471
- # draw verti line
472
- # this is needed to erase previous bar when shrinking
473
- #@graphic.mvwvline(r+1,c+@width-1, FFI::NCurses::ACS_VLINE, @height-2)
474
- @graphic.rb_mvwvline(r+1,c+@width-1, FFI::NCurses::ACS_VLINE, @height-2)
475
- # draw scroll bar
476
- #sz.times{ |i| @graphic.mvaddch(r+start+1+i, c+@width-1, FFI::NCurses::ACS_CKBOARD) }
477
- sz.times{ |i| @graphic.rb_mvaddch(r+start+1+i, c+@width-1, FFI::NCurses::ACS_CKBOARD) }
478
- end
479
- # set height
480
- # a container must pass down changes in size to it's children
481
- # 2010-02-04 18:06 - i am not sure about this. When viewport is set then it passes down
482
- # changes to child which user did not intend. Maybe in splitpane it is okay but other cases?
483
- # Perhaps its okay if scrollpane gets larger than child, not otherwise.
484
- # added 2010-01-16 23:55
485
- def height(*val)
486
- return @height if val.empty?
487
- oldvalue = @height || 0
488
- super
489
- @height = val[0]
490
- return if @viewport == nil
491
- delta = @height - oldvalue
492
- return if delta == 0
493
- @repaint_required = true
494
- @viewport.height += delta
495
- end
496
- # set width
497
- # a container must pass down changes in size to it's children
498
- # added 2010-01-16 23:55
499
- def width(*val)
500
- return @width if val.empty?
501
- oldvalue = @width || 0
502
- super
503
- @width = val[0]
504
- return if @viewport == nil
505
- delta = @width - oldvalue
506
- return if delta == 0
507
- @repaint_required = true
508
- @viewport.width += delta
509
- end
510
-
511
- end # class ScrollPane
512
- end # module