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.
- data/CHANGELOG +31 -0
- data/README.markdown +69 -11
- data/VERSION +1 -1
- data/lib/rbcurse.rb +5 -5
- metadata +10 -198
- data/Makefile +0 -21
- data/Manifest.txt +0 -91
- data/TODO +0 -372
- data/TODO2.txt +0 -118
- data/examples/README.txt +0 -67
- data/examples/abasiclist.rb +0 -33
- data/examples/alpmenu.rb +0 -42
- data/examples/app.rb +0 -859
- data/examples/app.sample +0 -10
- data/examples/appdirtree.rb +0 -75
- data/examples/appemail.rb +0 -191
- data/examples/appemaillb.rb +0 -308
- data/examples/appgcompose.rb +0 -315
- data/examples/atree.rb +0 -64
- data/examples/common/file.rb +0 -40
- data/examples/common/rmail.rb +0 -257
- data/examples/data.txt +0 -683
- data/examples/data/README.markdown +0 -9
- data/examples/data/brew.txt +0 -38
- data/examples/data/color.2 +0 -37
- data/examples/data/gemlist.txt +0 -60
- data/examples/data/lotr.txt +0 -12
- data/examples/data/ports.txt +0 -136
- data/examples/data/tasks.txt +0 -27
- data/examples/data/todocsv.csv +0 -28
- data/examples/data/unix1.txt +0 -21
- data/examples/data/unix2.txt +0 -11
- data/examples/dbdemo.rb +0 -495
- data/examples/deprecated/appgmail.rb +0 -952
- data/examples/deprecated/splitp.rb +0 -56
- data/examples/deprecated/testscrolllb.rb +0 -86
- data/examples/deprecated/testscrollp.rb +0 -88
- data/examples/deprecated/testscrollta.rb +0 -80
- data/examples/deprecated/testscrolltable.rb +0 -165
- data/examples/deprecated/testsplit.rb +0 -87
- data/examples/deprecated/testsplit2.rb +0 -123
- data/examples/deprecated/testsplit3.rb +0 -215
- data/examples/deprecated/testsplit3_1.rb +0 -244
- data/examples/deprecated/testsplit3a.rb +0 -215
- data/examples/deprecated/testsplit3b.rb +0 -237
- data/examples/deprecated/testsplitta.rb +0 -148
- data/examples/deprecated/testsplittv.rb +0 -142
- data/examples/deprecated/testsplittvv.rb +0 -144
- data/examples/deprecated/testtpane.rb +0 -215
- data/examples/deprecated/testtpane2.rb +0 -145
- data/examples/deprecated/testtpanetable.rb +0 -203
- data/examples/dirtree.rb +0 -88
- data/examples/experimental/resultsetdemo.rb +0 -280
- data/examples/experimental/testmform.rb +0 -35
- data/examples/experimental/testscroller.rb +0 -117
- data/examples/experimental/teststackflow.rb +0 -111
- data/examples/menu1.rb +0 -112
- data/examples/multispl.rb +0 -86
- data/examples/newmessagebox.rb +0 -130
- data/examples/newtabbedwindow.rb +0 -100
- data/examples/newtesttabp.rb +0 -121
- data/examples/qdfilechooser.rb +0 -68
- data/examples/rfe.rb +0 -1195
- data/examples/rfe_renderer.rb +0 -121
- data/examples/sqlc.rb +0 -454
- data/examples/sqlm.rb +0 -437
- data/examples/sqlt.rb +0 -408
- data/examples/status.txt +0 -68
- data/examples/table1.rb +0 -24
- data/examples/term2.rb +0 -84
- data/examples/test1.rb +0 -239
- data/examples/test2.rb +0 -674
- data/examples/testapp.rb +0 -44
- data/examples/testapp2.rb +0 -58
- data/examples/testchars.rb +0 -137
- data/examples/testcombo.rb +0 -91
- data/examples/testkeypress.rb +0 -66
- data/examples/testlistbox.rb +0 -113
- data/examples/testmenu.rb +0 -101
- data/examples/testmulticomp.rb +0 -70
- data/examples/testmulticontainer.rb +0 -94
- data/examples/testmultispl.rb +0 -199
- data/examples/testree.rb +0 -106
- data/examples/testtable.rb +0 -263
- data/examples/testtabp.rb +0 -107
- data/examples/testtodo.rb +0 -584
- data/examples/testvimsplit.rb +0 -112
- data/examples/testwsshortcuts.rb +0 -64
- data/examples/testwsshortcuts2.rb +0 -126
- data/examples/todo.db +0 -0
- data/examples/todo.yml +0 -191
- data/examples/viewtodo.rb +0 -574
- data/lib/rbcurse/action.rb +0 -40
- data/lib/rbcurse/app.rb +0 -1374
- data/lib/rbcurse/applicationheader.rb +0 -102
- data/lib/rbcurse/celleditor.rb +0 -112
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
- data/lib/rbcurse/colormap.rb +0 -159
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
- data/lib/rbcurse/common/ansiparser.rb +0 -117
- data/lib/rbcurse/common/appmethods.rb +0 -112
- data/lib/rbcurse/common/basestack.rb +0 -407
- data/lib/rbcurse/common/bordertitle.rb +0 -41
- data/lib/rbcurse/common/chunk.rb +0 -177
- data/lib/rbcurse/common/colorparser.rb +0 -71
- data/lib/rbcurse/common/keydefs.rb +0 -30
- data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
- data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
- data/lib/rbcurse/deprecated/README.markdown +0 -12
- data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
- data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
- data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
- data/lib/rbcurse/deprecated/rviewport.rb +0 -204
- data/lib/rbcurse/experimental/README.markdown +0 -14
- data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
- data/lib/rbcurse/experimental/stackflow.rb +0 -478
- data/lib/rbcurse/extras/bottomline.rb +0 -1850
- data/lib/rbcurse/extras/box.rb +0 -58
- data/lib/rbcurse/extras/directorylist.rb +0 -467
- data/lib/rbcurse/extras/directorytree.rb +0 -69
- data/lib/rbcurse/extras/divider.rb +0 -310
- data/lib/rbcurse/extras/focusmanager.rb +0 -31
- data/lib/rbcurse/extras/horizlist.rb +0 -203
- data/lib/rbcurse/extras/listselectable.rb +0 -264
- data/lib/rbcurse/extras/masterdetail.rb +0 -166
- data/lib/rbcurse/extras/menutree.rb +0 -63
- data/lib/rbcurse/extras/multiform.rb +0 -330
- data/lib/rbcurse/extras/multilinelabel.rb +0 -142
- data/lib/rbcurse/extras/newmessagebox.rb +0 -328
- data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
- data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
- data/lib/rbcurse/extras/padreader.rb +0 -189
- data/lib/rbcurse/extras/rcomboedit.rb +0 -256
- data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
- data/lib/rbcurse/extras/rlink.rb +0 -27
- data/lib/rbcurse/extras/rmenulink.rb +0 -21
- data/lib/rbcurse/extras/scrollbar.rb +0 -143
- data/lib/rbcurse/extras/statusline.rb +0 -94
- data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
- data/lib/rbcurse/extras/tableextended.rb +0 -40
- data/lib/rbcurse/extras/tabular.rb +0 -264
- data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
- data/lib/rbcurse/extras/textpad.rb +0 -516
- data/lib/rbcurse/extras/viewer.rb +0 -136
- data/lib/rbcurse/io.rb +0 -850
- data/lib/rbcurse/keylabelprinter.rb +0 -178
- data/lib/rbcurse/listcellrenderer.rb +0 -140
- data/lib/rbcurse/listeditable.rb +0 -310
- data/lib/rbcurse/listkeys.rb +0 -37
- data/lib/rbcurse/listscrollable.rb +0 -564
- data/lib/rbcurse/listselectable.rb +0 -142
- data/lib/rbcurse/mapper.rb +0 -130
- data/lib/rbcurse/orderedhash.rb +0 -77
- data/lib/rbcurse/ractionevent.rb +0 -67
- data/lib/rbcurse/rbasiclistbox.rb +0 -768
- data/lib/rbcurse/rchangeevent.rb +0 -27
- data/lib/rbcurse/rcombo.rb +0 -238
- data/lib/rbcurse/rcommandwindow.rb +0 -587
- data/lib/rbcurse/rcontainer.rb +0 -415
- data/lib/rbcurse/rdialogs.rb +0 -451
- data/lib/rbcurse/rinputdataevent.rb +0 -47
- data/lib/rbcurse/rlistbox.rb +0 -1196
- data/lib/rbcurse/rmenu.rb +0 -939
- data/lib/rbcurse/rmessagebox.rb +0 -348
- data/lib/rbcurse/rmulticontainer.rb +0 -304
- data/lib/rbcurse/rmultisplit.rb +0 -722
- data/lib/rbcurse/rmultitextview.rb +0 -306
- data/lib/rbcurse/rpopupmenu.rb +0 -755
- data/lib/rbcurse/rprogress.rb +0 -118
- data/lib/rbcurse/rscrollform.rb +0 -418
- data/lib/rbcurse/rtabbedpane.rb +0 -1158
- data/lib/rbcurse/rtabbedwindow.rb +0 -167
- data/lib/rbcurse/rtable.rb +0 -1718
- data/lib/rbcurse/rtextarea.rb +0 -920
- data/lib/rbcurse/rtextview.rb +0 -761
- data/lib/rbcurse/rtree.rb +0 -780
- data/lib/rbcurse/rvimsplit.rb +0 -763
- data/lib/rbcurse/rwidget.rb +0 -2915
- data/lib/rbcurse/scrollable.rb +0 -301
- data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
- data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
- data/lib/rbcurse/tree/treemodel.rb +0 -428
- data/lib/rbcurse/undomanager.rb +0 -188
- data/lib/rbcurse/vieditable.rb +0 -144
- data/lib/ver/keyboard.rb +0 -150
- data/lib/ver/keyboard2.rb +0 -170
- data/lib/ver/ncurses.rb +0 -218
- data/lib/ver/panel.rb +0 -162
- data/lib/ver/rpad.rb +0 -375
- data/lib/ver/window.rb +0 -882
- data/test/test_rbcurse.rb +0 -0
data/lib/rbcurse/rvimsplit.rb
DELETED
@@ -1,763 +0,0 @@
|
|
1
|
-
# This is a new kind of splitpane, inspired by the vim editor.
|
2
|
-
# I was deeply frustrated with the Java kind of splitpane,
|
3
|
-
# which requires splitpanes within splitpanes to get several split.
|
4
|
-
# This is an attempt at getting many splits, keeping them at one level
|
5
|
-
# and keeping the interface as simple as possible, with minimal input
|
6
|
-
# from user.
|
7
|
-
# It usually takes a listbox or textview or textarea.
|
8
|
-
# It can also take an array, or string or hash.
|
9
|
-
# It supports moving the split, and increasing or decreasing the current box to some extent.
|
10
|
-
# Typically if the split is vertical, add stacks the components, one below the other.
|
11
|
-
# If horizontal, if will flow the components, to the right of previous. This can be overriden by passing
|
12
|
-
# type as :STACK or :FLOW.
|
13
|
-
# See examples/testvimsplit.rb
|
14
|
-
#
|
15
|
-
# This does not support changing the orientation at run time, that's nice for demos, but a pain
|
16
|
-
# to get right, and results in a lot of extra code, meaning more bugs.
|
17
|
-
# TODO: create a class that contains component array and a pointer so it can give next/prev
|
18
|
-
# i am tired of maintaining this everywhere.
|
19
|
-
require 'rbcurse'
|
20
|
-
require 'rbcurse/rlistbox'
|
21
|
-
require 'rbcurse/extras/divider'
|
22
|
-
require 'rbcurse/extras/focusmanager'
|
23
|
-
|
24
|
-
include RubyCurses
|
25
|
-
module RubyCurses
|
26
|
-
extend self
|
27
|
-
class Coord < Struct.new(:row, :col, :h, :w); end
|
28
|
-
# Split contains info for a component added. weight is preferred weight
|
29
|
-
# and can contain value :AUTO. act_weight has the weight calculated.
|
30
|
-
# Often, last component can be nil, remainder will be assigned to it.
|
31
|
-
class Split < Struct.new(:which, :type, :weight, :act_weight); end
|
32
|
-
class ResizeEvent < Struct.new(:source, :type); end
|
33
|
-
|
34
|
-
# A simpler replacement for the java-esque SplitPane. This can take multiple splits
|
35
|
-
# and does not require splits within splits as SplitPane does.
|
36
|
-
# This is less functional, but should be easier to use, setup and hack.
|
37
|
-
class VimSplit < Widget
|
38
|
-
|
39
|
-
# split orientation :V or :H
|
40
|
-
dsl_accessor :orientation
|
41
|
-
# min and max weight of main split. do not allow user to exceed these
|
42
|
-
dsl_accessor :min_weight, :max_weight
|
43
|
-
dsl_accessor :suppress_borders #to_print_borders
|
44
|
-
dsl_accessor :border_attrib, :border_color
|
45
|
-
attr_reader :current_component
|
46
|
-
def initialize form, config={}, &block
|
47
|
-
if config[:width] == :EXPAND
|
48
|
-
config[:width] = Ncurses.COLS - config[:col]
|
49
|
-
end
|
50
|
-
if config[:orientation] == nil
|
51
|
-
config[:orientation] = :HORIZONTAL_SPLIT
|
52
|
-
else
|
53
|
-
# if first char is V or H then fill it in.
|
54
|
-
char = config[:orientation].to_s[0,1].upcase
|
55
|
-
if char == "V"
|
56
|
-
config[:orientation] = :VERTICAL_SPLIT
|
57
|
-
else
|
58
|
-
config[:orientation] = :HORIZONTAL_SPLIT
|
59
|
-
end
|
60
|
-
end
|
61
|
-
@max_weight ||= 0.8
|
62
|
-
@min_weight ||= 0.1 # earlier 0.2 but i wanted 0.15, someone may want 0.05 ??
|
63
|
-
@suppress_borders = false
|
64
|
-
@_use_preferred_sizes = true
|
65
|
-
@row_offset = @col_offset = 1
|
66
|
-
# type can be :INCREASE, :DECREASE, :EXPAND, :UNEXPAND :EQUAL
|
67
|
-
@_events ||= []
|
68
|
-
@_events.push :COMPONENT_RESIZE_EVENT
|
69
|
-
@_events.push :DRAG_EVENT
|
70
|
-
super
|
71
|
-
@focusable = true
|
72
|
-
@editable = false
|
73
|
-
@components = [] # all components
|
74
|
-
@c1 =[] # first split's comps
|
75
|
-
@c2 =[] # second split's comps
|
76
|
-
# coordinates of a split, i calculate and increment row col as i go.
|
77
|
-
@c1rc = nil # TODO create once only
|
78
|
-
@c2rc = nil
|
79
|
-
|
80
|
-
# hash, keyed on component, contains Split (which side, flow or stack, weight)
|
81
|
-
@ch = {}
|
82
|
-
@weight ||= 0.50
|
83
|
-
|
84
|
-
init_vars
|
85
|
-
bind_key([?\C-w,?o], :expand)
|
86
|
-
bind_key([?\C-w,?1], :expand)
|
87
|
-
bind_key([?\C-w,?2], :unexpand)
|
88
|
-
bind_key([?\C-w,?\C-w], :goto_other_split)
|
89
|
-
bind_key([?\C-w,?-], :decrease_height)
|
90
|
-
bind_key([?\C-w,?+], :increase_height)
|
91
|
-
bind_key([?\C-w,?<], :decrease_width)
|
92
|
-
bind_key([?\C-w,?>], :increase_width)
|
93
|
-
bind_key([?\C-w,?i], :increase_weight)
|
94
|
-
bind_key([?\C-w,?d], :decrease_weight)
|
95
|
-
bind_key([?\C-w,?6], :increase_current_component)
|
96
|
-
bind_key([?\C-w,?5], :decrease_current_component)
|
97
|
-
# this needs to be set at application level
|
98
|
-
bind_key(FFI::NCurses::KEY_F3) {RubyCurses::FocusManager.toggle_focusable}
|
99
|
-
end
|
100
|
-
def init_vars
|
101
|
-
@repaint_required = true
|
102
|
-
@recalculate_splits = true # convert weight to size
|
103
|
-
@row_offset = @col_offset = 0 if @suppress_borders # FIXME supposed to use this !!
|
104
|
-
|
105
|
-
@internal_width = 2
|
106
|
-
@internal_width = 1 if @suppress_borders
|
107
|
-
|
108
|
-
end
|
109
|
-
# uses intelligent default a vertical split would prefer stacks and
|
110
|
-
# a horizontal split would go with flows
|
111
|
-
# @param [Widget, Array, String, Hash, Variable] to add
|
112
|
-
# @param [:FIRST, :SECOND]
|
113
|
-
def add c, which, weight=:AUTO, type=:AUTO
|
114
|
-
if type == :AUTO
|
115
|
-
if v?
|
116
|
-
type = :STACK
|
117
|
-
else
|
118
|
-
type = :FLOW
|
119
|
-
end
|
120
|
-
end
|
121
|
-
_add type, c, which, weight
|
122
|
-
#return self # lets return component created for christ's sake and keep it simple
|
123
|
-
end
|
124
|
-
# set the weight of outer split
|
125
|
-
def weight(*val)
|
126
|
-
if val.empty?
|
127
|
-
return @weight
|
128
|
-
else
|
129
|
-
# raise ArgumentError
|
130
|
-
newval = val[0]
|
131
|
-
# this is since, using numeric multipliers he can go beyond, so lets give him the best
|
132
|
-
if val[0] < @min_weight
|
133
|
-
newval = @min_weight
|
134
|
-
elsif val[0] > @max_weight
|
135
|
-
newval = @max_weight
|
136
|
-
end
|
137
|
-
oldvalue = @weight
|
138
|
-
@weight = newval
|
139
|
-
# orientation can be nil, so we cannot calculate rc here
|
140
|
-
#if v?
|
141
|
-
#@rc = (@width * @weight).to_i
|
142
|
-
#else
|
143
|
-
#@rc = (@height * @weight).to_i
|
144
|
-
#end
|
145
|
-
@rc = nil # so recalculated in repaint
|
146
|
-
fire_property_change(:weight, oldvalue, @weight)
|
147
|
-
end
|
148
|
-
self
|
149
|
-
end
|
150
|
-
# stack components, one over another, useful in a vertical split
|
151
|
-
# @param [Widget] component
|
152
|
-
# @param [:FIRST :SECOND] first or second split
|
153
|
-
# @param [Float, nil, :AUTO] weight of object, nil for last will expand it to full
|
154
|
-
# :AUTO will give equal weight to all
|
155
|
-
def stack c, which, weight
|
156
|
-
_add :STACK, c, which, weight
|
157
|
-
#return self # lets return component created for christ's sake and keep it simple
|
158
|
-
end
|
159
|
-
# place components on right of previous. Useful in horizontal split
|
160
|
-
def flow c, which, weight
|
161
|
-
_add :FLOW, c, which, weight
|
162
|
-
#return self # lets return component created for christ's sake and keep it simple
|
163
|
-
end
|
164
|
-
private
|
165
|
-
def _add type, c, which, weight
|
166
|
-
raise ArgumentError, "Nil component passed to add" unless c
|
167
|
-
raise ArgumentError, "which must be :FIRST or :SECOND" if which != :FIRST && which != :SECOND
|
168
|
-
# trying out wt of 0 means it will see height of object and use that.
|
169
|
-
if weight.nil? || weight == :AUTO || (weight >= 0 && weight <= 1.0)
|
170
|
-
else
|
171
|
-
raise ArgumentError, "weight must be >0 and <=1.0 or nil or :AUTO"
|
172
|
-
end
|
173
|
-
if c.is_a? Widget
|
174
|
-
if c.form && c.form != @form
|
175
|
-
$log.debug " removing widget VIMSPLIT #{c.class} "
|
176
|
-
c.form.remove_widget c
|
177
|
-
c.form = nil
|
178
|
-
end
|
179
|
-
#$log.debug " XXXX VIM is a widget"
|
180
|
-
else
|
181
|
-
case c
|
182
|
-
when Array
|
183
|
-
lb = Listbox.new nil, :list => c , :name => "list#{@components.size}"
|
184
|
-
c = lb
|
185
|
-
when String
|
186
|
-
require 'rbcurse/rtextview'
|
187
|
-
lb = TextView.new nil, :name => "text#{@components.size}"
|
188
|
-
lb.set_content c
|
189
|
-
c = lb
|
190
|
-
when Hash
|
191
|
-
lb = Listbox.new nil, :list => c.keys , :name => "list#{@components.size}"
|
192
|
-
c = lb
|
193
|
-
when Variable
|
194
|
-
# TODO
|
195
|
-
else
|
196
|
-
if c == :grabbar || c == :divider
|
197
|
-
side = :bottom
|
198
|
-
case type
|
199
|
-
when :STACK
|
200
|
-
side = :bottom
|
201
|
-
when :FLOW
|
202
|
-
side = :left
|
203
|
-
end
|
204
|
-
c = Divider.new nil, :parent => @components.last, :side => side
|
205
|
-
c.focusable(false)
|
206
|
-
RubyCurses::FocusManager.add c
|
207
|
-
c.bind :DRAG_EVENT do |ev|
|
208
|
-
source = ev.source
|
209
|
-
case ev.type
|
210
|
-
when KEY_UP
|
211
|
-
# CHECK BOUNDS TODO
|
212
|
-
# TODO what about KEY_LEFT and RIGHT ?
|
213
|
-
if source.next_component && source.next_component.row > 1 && source.parent.height > 1
|
214
|
-
source.parent.height -= 1
|
215
|
-
source.next_component.height +=1
|
216
|
-
source.next_component.row -= 1
|
217
|
-
source.parent.repaint_required
|
218
|
-
source.next_component.repaint_required
|
219
|
-
source.parent.repaint
|
220
|
-
source.next_component.repaint
|
221
|
-
end
|
222
|
-
when KEY_DOWN
|
223
|
-
# CHECK BOUNDS TODO check with appemail.rb
|
224
|
-
if source.next_component && source.next_component.height > 1
|
225
|
-
source.parent.height += 1
|
226
|
-
source.next_component.height -=1
|
227
|
-
source.next_component.row += 1
|
228
|
-
source.parent.repaint_required
|
229
|
-
source.next_component.repaint_required
|
230
|
-
source.parent.repaint
|
231
|
-
source.next_component.repaint
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
c.parent_component = self
|
239
|
-
|
240
|
-
@components << c
|
241
|
-
if which == :FIRST
|
242
|
-
@c1 << c
|
243
|
-
else
|
244
|
-
@c2 << c
|
245
|
-
end
|
246
|
-
#@ch[c] = [which, type, weight]
|
247
|
-
@ch[c] = Split.new(which, type, weight)
|
248
|
-
@repaint_required = true
|
249
|
-
return c
|
250
|
-
end
|
251
|
-
public
|
252
|
-
def split_info_for(c = @current_component)
|
253
|
-
@ch[c]
|
254
|
-
end
|
255
|
-
# get the current split focus is on
|
256
|
-
# @return [:FIRST, :SECOND] which split are we on
|
257
|
-
def current_split
|
258
|
-
split_info_for(@current_component).which
|
259
|
-
end
|
260
|
-
# returns the other split.
|
261
|
-
def other_split
|
262
|
-
which = current_split
|
263
|
-
return which == :FIRST ? :SECOND : :FIRST
|
264
|
-
end
|
265
|
-
# returns list of components for FIRST or SECOND split
|
266
|
-
def components_for which
|
267
|
-
return which == :FIRST ? @c1 : @c2
|
268
|
-
end
|
269
|
-
|
270
|
-
public
|
271
|
-
# repaint object
|
272
|
-
# called by Form, and sometimes parent component (if not form).
|
273
|
-
def repaint
|
274
|
-
my_win = @form ? @form.window : @target_window
|
275
|
-
@graphic = my_win unless @graphic
|
276
|
-
raise " #{@name} NO GRAPHIC set as yet VIMSPLIT paint " unless @graphic
|
277
|
-
|
278
|
-
#return unless @repaint_required
|
279
|
-
@recalculate_splits = true if @rc.nil?
|
280
|
-
|
281
|
-
# if some major change has happened then repaint everything
|
282
|
-
if @repaint_required
|
283
|
-
$log.debug " VIM repaint graphic #{@graphic} "
|
284
|
-
print_borders unless @suppress_borders # do this once only, unless everything changes
|
285
|
-
r,c = rowcol
|
286
|
-
|
287
|
-
bordercolor = @border_color || $datacolor
|
288
|
-
borderatt = @border_attrib || Ncurses::A_NORMAL
|
289
|
-
|
290
|
-
|
291
|
-
@graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
292
|
-
|
293
|
-
## The following calculations are only calcing the 2 split areas
|
294
|
-
## and divider locations based on V or H and weight.
|
295
|
-
|
296
|
-
@gbwid ||= 0 # grabbar width
|
297
|
-
roffset = 1
|
298
|
-
loffset = 2
|
299
|
-
if @suppress_borders
|
300
|
-
loffset = roffset = 0
|
301
|
-
end
|
302
|
-
# vertical split
|
303
|
-
if v?
|
304
|
-
@rc ||= (@width * @weight).to_i
|
305
|
-
rc = @rc # divider location
|
306
|
-
$log.debug "SPLP #{@name} prtingign split vline divider 1, rc: #{rc}, h:#{@height} - 2 "
|
307
|
-
unless @vb # if grabbar not created
|
308
|
-
@gbwid = 1
|
309
|
-
_create_divider
|
310
|
-
else # created, so set it
|
311
|
-
@vb.row @row+roffset
|
312
|
-
@vb.col rc+@col
|
313
|
-
#@vb.repaint
|
314
|
-
end
|
315
|
-
#@graphic.mvvline(@row+1, rc+@col, 0, @height-2)
|
316
|
-
# TODO don;t keep recreating, if present, reset values
|
317
|
-
## calculate cordinated of both split areas/boxes
|
318
|
-
@c1rc = Coord.new(@row,@col, @height -0, rc-@gbwid)
|
319
|
-
@c2rc = Coord.new(@row,rc+@col+@gbwid,@height-0, @width - rc-@gbwid)
|
320
|
-
else # horizontal split
|
321
|
-
@rc ||= (@height * @weight).to_i
|
322
|
-
rc = @rc # dividers row col location
|
323
|
-
$log.debug "SPLP #{@name} prtingign split hline divider rc: #{rc} , 1 , w:#{@width} - 2"
|
324
|
-
unless @vb
|
325
|
-
@gbwid = 1
|
326
|
-
_create_divider
|
327
|
-
else
|
328
|
-
#@vb = Divider.new nil, :row => @row+rc-1, :col => @col+1, :length => @width-loffset, :side => :bottom
|
329
|
-
@vb.row @row+@rc-1
|
330
|
-
@vb.col @col+roffset
|
331
|
-
#@vb.repaint # getting wiped out by vimsplit ?
|
332
|
-
end
|
333
|
-
#@graphic.mvhline(rc+@row, @col+1, 0, @width-@internal_width)
|
334
|
-
#@neat = true
|
335
|
-
if @neat
|
336
|
-
a = 1
|
337
|
-
@c1rc = Coord.new(@row+a,@col+a, rc-a, @width-@internal_width)
|
338
|
-
@c2rc = Coord.new(@row+rc+a,@col+a, @height-rc-2, @width - @internal_width)
|
339
|
-
else
|
340
|
-
# flush against border
|
341
|
-
#@c1rc = Coord.new(@row,@col, @height -0, rc-@gbwid)
|
342
|
-
#@c2rc = Coord.new(@row,rc+@col+@gbwid,@height-0, @width - rc-@gbwid)
|
343
|
-
a = 0
|
344
|
-
@c1rc = Coord.new(@row,@col, rc-@gbwid, @width)
|
345
|
-
@c2rc = Coord.new(@row+rc, @col, @height-rc-@gbwid, @width)
|
346
|
-
end
|
347
|
-
end
|
348
|
-
@graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
349
|
-
@components.each { |e| e.repaint_all(true) }
|
350
|
-
$log.debug " XXX VIM REPAINT ALL "
|
351
|
-
# FIXME do this only once, or when major change happends, otherwise
|
352
|
-
# i cannot increase decrease size on user request.
|
353
|
-
recalculate_splits @_use_preferred_sizes if @recalculate_splits
|
354
|
-
# vimsplit often overwrites this while divider is being moved so we must
|
355
|
-
# again call it.
|
356
|
-
@vb.repaint if @vb
|
357
|
-
else
|
358
|
-
# only repaint those that are needing repaint
|
359
|
-
# 2010-09-22 18:09 its possible somenoe has updated an internal
|
360
|
-
# component, but this container does not know. So we've got to call
|
361
|
-
# repaint on all components, only those which are changed will
|
362
|
-
# actually be repainted
|
363
|
-
@components.each { |e| e.repaint }
|
364
|
-
end # if repaint_required
|
365
|
-
# NOTE: at present one cannot change from flow to stack inside a pane
|
366
|
-
|
367
|
-
@repaint_required = false
|
368
|
-
end
|
369
|
-
def v?
|
370
|
-
@orientation == :VERTICAL_SPLIT
|
371
|
-
end
|
372
|
-
def h?
|
373
|
-
!@orientation == :VERTICAL_SPLIT
|
374
|
-
end
|
375
|
-
# convert weight to height and length
|
376
|
-
# we should only do this once, or if major change
|
377
|
-
# otherwise changes that user may have effected in size will be lost
|
378
|
-
# NOTE: this resets all components to preferred weights (given when component was added.
|
379
|
-
# If user has resized components
|
380
|
-
# then those changes in size will be lost.
|
381
|
-
def reset_to_preferred_size
|
382
|
-
recalculate_splits use_preferred_sizes=true
|
383
|
-
end
|
384
|
-
def recalculate_splits use_preferred_sizes=false
|
385
|
-
@recalculate_splits = false
|
386
|
-
[@c1,@c2].each_with_index do |c,i|
|
387
|
-
rca = @c1rc
|
388
|
-
if i == 1
|
389
|
-
#$log.debug " XXX VIM moving to second"
|
390
|
-
rca = @c2rc
|
391
|
-
end
|
392
|
-
totalw = 0 # accumulative weight
|
393
|
-
totalwd = 0 # accumulative weight for width (in case someone switches)
|
394
|
-
totalht = 0 # accumulative weight for height (in case someone switches)
|
395
|
-
sz = c.size
|
396
|
-
auto = 1.0/sz
|
397
|
-
c.each do |e|
|
398
|
-
r = rca.row
|
399
|
-
c = rca.col
|
400
|
-
info = @ch[e]
|
401
|
-
type = info.type
|
402
|
-
wt = info.weight
|
403
|
-
wt = auto if wt == :AUTO
|
404
|
-
e.row = r
|
405
|
-
e.col = c
|
406
|
-
if type == :STACK
|
407
|
-
# store actual weight that was calculated, so if user reduces or increases
|
408
|
-
# we can use this, although ... we have no method that uses actual weights
|
409
|
-
# NOTE: If calling program increases one comp's weight, will have to reduce other.
|
410
|
-
info.act_weight = wt
|
411
|
-
|
412
|
-
e.width = (rca.w * (1 - totalwd)).to_i
|
413
|
-
# recaclulate height only in this case, otherwise we will overwrite changes
|
414
|
-
# made by user
|
415
|
-
if use_preferred_sizes
|
416
|
-
if wt != 0
|
417
|
-
if wt
|
418
|
-
e.height = ((rca.h * wt).to_i)
|
419
|
-
else
|
420
|
-
a = 0
|
421
|
-
a = 1 if @suppress_borders
|
422
|
-
e.height = rca.h - rca.row + a # take exactly rows left
|
423
|
-
end
|
424
|
-
# else use its own height
|
425
|
-
end
|
426
|
-
end
|
427
|
-
rca.row += e.height
|
428
|
-
totalht += wt if wt
|
429
|
-
else
|
430
|
-
# TODO THIS PART AS PER ABOVE CASE , TO TEST
|
431
|
-
# this is a horizontal split or flow
|
432
|
-
info.act_weight = wt
|
433
|
-
#e.height = rca.h
|
434
|
-
e.height = (rca.h * (1- totalht)).to_i
|
435
|
-
if use_preferred_sizes
|
436
|
-
if wt != 0
|
437
|
-
if wt
|
438
|
-
e.width = ((rca.w * wt).to_i)
|
439
|
-
else
|
440
|
-
a = 0
|
441
|
-
a = 1 if @suppress_borders
|
442
|
-
e.width = rca.w - rca.col + a # take exactly rows left
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
rca.col += e.width
|
447
|
-
totalwd += wt if wt
|
448
|
-
end
|
449
|
-
e.set_buffering(:target_window => @target_window || @form.window, :bottom => e.height-1, :right => e.width-1, :form => @form ) # removed on 2011-09-29
|
450
|
-
$log.debug " XXXXX VIMS R #{e.row} C #{e.col} H #{e.height} W #{e.width} "
|
451
|
-
e.repaint
|
452
|
-
e._object_created = true # added 2010-09-16 13:02 now prop handlers can be fired
|
453
|
-
end
|
454
|
-
end
|
455
|
-
@_use_preferred_sizes = false
|
456
|
-
end
|
457
|
-
|
458
|
-
private
|
459
|
-
def print_borders
|
460
|
-
width = @width
|
461
|
-
height = @height-1 # 2010-01-04 15:30 BUFFERED HEIGHT
|
462
|
-
window = @graphic # 2010-01-04 12:37 BUFFERED
|
463
|
-
startcol = @col
|
464
|
-
startrow = @row
|
465
|
-
@color_pair = get_color($datacolor)
|
466
|
-
#$log.debug "rlistb #{name}: window.print_border #{startrow}, #{startcol} , h:#{height}, w:#{width} , @color_pair, @attr "
|
467
|
-
window.print_border startrow, startcol, height, width, @color_pair, @attr
|
468
|
-
print_title
|
469
|
-
end
|
470
|
-
def print_title
|
471
|
-
@graphic.printstring( @row, @col+(@width-@title.length)/2, @title, @color_pair, @title_attrib) unless @title.nil?
|
472
|
-
end
|
473
|
-
|
474
|
-
public
|
475
|
-
# called by parent or form, otherwise its private
|
476
|
-
def handle_key ch
|
477
|
-
$log.debug " VIMSPLIT handle_key #{ch} "
|
478
|
-
_multiplier = ($multiplier == 0 ? 1 : $multiplier )
|
479
|
-
if ch == KEY_TAB
|
480
|
-
$log.debug " GOTO NEXT"
|
481
|
-
return goto_next_component
|
482
|
-
elsif ch == KEY_BTAB
|
483
|
-
return goto_prev_component
|
484
|
-
end
|
485
|
-
comp = @current_component
|
486
|
-
$log.debug " VIMSPL handle_k #{ch}: #{comp}"
|
487
|
-
if comp
|
488
|
-
ret = comp.handle_key(ch)
|
489
|
-
if ret != :UNHANDLED
|
490
|
-
comp.repaint # NOTE: if we don;t do this, then it won't get repainted. I will have to repaint ALL
|
491
|
-
# in repaint of this.
|
492
|
-
return ret
|
493
|
-
end
|
494
|
-
end
|
495
|
-
$log.debug "XXX VIM key unhandled by comp #{comp.name} "
|
496
|
-
case ch
|
497
|
-
when ?\C-c.getbyte(0)
|
498
|
-
$multiplier = 0
|
499
|
-
return 0
|
500
|
-
when ?0.getbyte(0)..?9.getbyte(0)
|
501
|
-
$log.debug " VIM coming here to set multiplier #{$multiplier} "
|
502
|
-
$multiplier *= 10 ; $multiplier += (ch-48)
|
503
|
-
return 0
|
504
|
-
end
|
505
|
-
ret = process_key ch, self
|
506
|
-
# allow user to map left and right if he wants
|
507
|
-
if ret == :UNHANDLED
|
508
|
-
case ch
|
509
|
-
when KEY_UP
|
510
|
-
# form will pick this up and do needful
|
511
|
-
return goto_prev_component #unless on_first_component?
|
512
|
-
when KEY_LEFT
|
513
|
-
# if i don't check for first component, key will go back to form,
|
514
|
-
# but not be processes. so focussed remain here, but be false.
|
515
|
-
# In case of returnign an unhandled TAB, on_leave will happen and cursor will move to
|
516
|
-
# previous component outside of this.
|
517
|
-
return goto_prev_component unless on_first_component?
|
518
|
-
when KEY_RIGHT
|
519
|
-
return goto_next_component #unless on_last_component?
|
520
|
-
when KEY_DOWN
|
521
|
-
return goto_next_component #unless on_last_component?
|
522
|
-
else
|
523
|
-
return :UNHANDLED
|
524
|
-
end
|
525
|
-
end
|
526
|
-
|
527
|
-
$multiplier = 0
|
528
|
-
return 0
|
529
|
-
end
|
530
|
-
# private
|
531
|
-
def on_enter
|
532
|
-
# TODO if BTAB the last comp
|
533
|
-
if $current_key == KEY_BTAB
|
534
|
-
# FIXME last is not focusable, then ??
|
535
|
-
@current_component = @components.last
|
536
|
-
else
|
537
|
-
@current_component = @components.first
|
538
|
-
end
|
539
|
-
$log.debug " VIM came to on_enter #{@current_component} "
|
540
|
-
set_form_row
|
541
|
-
end
|
542
|
-
def on_leave
|
543
|
-
super
|
544
|
-
end
|
545
|
-
def goto_next_component
|
546
|
-
if @current_component != nil
|
547
|
-
leave_current_component
|
548
|
-
if on_last_component?
|
549
|
-
return :UNHANDLED
|
550
|
-
end
|
551
|
-
@current_index = @components.index(@current_component)
|
552
|
-
index = @current_index + 1
|
553
|
-
index.upto(@components.length-1) do |i|
|
554
|
-
f = @components[i]
|
555
|
-
if f.focusable
|
556
|
-
@current_index = i
|
557
|
-
@current_component = f
|
558
|
-
return set_form_row
|
559
|
-
end
|
560
|
-
end
|
561
|
-
end
|
562
|
-
return :UNHANDLED
|
563
|
-
end
|
564
|
-
def goto_prev_component
|
565
|
-
if @current_component != nil
|
566
|
-
leave_current_component
|
567
|
-
if on_first_component?
|
568
|
-
return :UNHANDLED
|
569
|
-
end
|
570
|
-
@current_index = @components.index(@current_component)
|
571
|
-
index = @current_index -= 1
|
572
|
-
index.downto(0) do |i|
|
573
|
-
f = @components[i]
|
574
|
-
if f.focusable
|
575
|
-
@current_index = i
|
576
|
-
@current_component = f
|
577
|
-
return set_form_row
|
578
|
-
end
|
579
|
-
end
|
580
|
-
end
|
581
|
-
return :UNHANDLED
|
582
|
-
end
|
583
|
-
# private
|
584
|
-
def set_form_row
|
585
|
-
#return :UNHANDLED if @current_component.nil?
|
586
|
-
$log.debug " VIM on enter sfr #{@current_component} "
|
587
|
-
@current_component.on_enter
|
588
|
-
@current_component.set_form_col # XXX
|
589
|
-
@current_component.repaint
|
590
|
-
# XXX compo should do set_form_row and col if it has that
|
591
|
-
end
|
592
|
-
# private
|
593
|
-
def set_form_col
|
594
|
-
return if @current_component.nil?
|
595
|
-
$log.debug " #{@name} set_form_col calling sfc for #{@current_component.name} "
|
596
|
-
@current_component.set_form_col
|
597
|
-
end
|
598
|
-
# leave the component we are on.
|
599
|
-
# This should be followed by all containers, so that the on_leave action
|
600
|
-
# of earlier comp can be displayed, such as dimming components selections
|
601
|
-
def leave_current_component
|
602
|
-
@current_component.on_leave
|
603
|
-
# NOTE this is required, since repaint will just not happen otherwise
|
604
|
-
# Some components are erroneously repainting all, after setting this to true so it is
|
605
|
-
# working there.
|
606
|
-
@current_component.repaint_required true
|
607
|
-
$log.debug " after on_leave VIMS XXX #{@current_component.focussed} #{@current_component.name}"
|
608
|
-
@current_component.repaint
|
609
|
-
end
|
610
|
-
|
611
|
-
# is focus on first component
|
612
|
-
def on_first_component?
|
613
|
-
@current_component == @components.first
|
614
|
-
end
|
615
|
-
# is focus on last component
|
616
|
-
def on_last_component?
|
617
|
-
@current_component == @components.last
|
618
|
-
end
|
619
|
-
def goto_other_split
|
620
|
-
c = components_for(other_split)
|
621
|
-
leave_current_component
|
622
|
-
@current_component = c.first
|
623
|
-
set_form_row
|
624
|
-
end
|
625
|
-
# set focus on given component
|
626
|
-
# Sometimes you have the handle to component, and you want to move focus to it
|
627
|
-
def goto_component comp
|
628
|
-
return if comp == @current_component
|
629
|
-
leave_current_component
|
630
|
-
@current_component = comp
|
631
|
-
set_form_row
|
632
|
-
end
|
633
|
-
# decrease the weight of the split
|
634
|
-
def decrease_weight
|
635
|
-
_multiplier = ($multiplier == 0 ? 1 : $multiplier )
|
636
|
-
weight(weight - 0.05*_multiplier)
|
637
|
-
end
|
638
|
-
# increase the weight of the split
|
639
|
-
def increase_weight
|
640
|
-
_multiplier = ($multiplier == 0 ? 1 : $multiplier )
|
641
|
-
weight(weight + 0.05*_multiplier)
|
642
|
-
end
|
643
|
-
# FIXME - i can only reduce if i've increased
|
644
|
-
def decrease_current_component
|
645
|
-
info = split_info_for
|
646
|
-
#info.add_weight = 0 if info.add_weight.nil?
|
647
|
-
#if info.add_weight > 0.0
|
648
|
-
#info.add_weight = info.add_weight - 0.05
|
649
|
-
#end
|
650
|
-
e = ResizeEvent.new @current_component, :DECREASE
|
651
|
-
fire_handler :COMPONENT_RESIZE_EVENT, e
|
652
|
-
#@repaint_required = true
|
653
|
-
end
|
654
|
-
# fires handler to request app to resize component
|
655
|
-
# @param [:INCREASE, :DECREASE]
|
656
|
-
# @param [:HEIGHT, :WIDTH]
|
657
|
-
def resize_component incdec, hw #:nodoc:
|
658
|
-
type = incdec.to_s + '_' + hw.to_s
|
659
|
-
#info = split_info_for
|
660
|
-
#info.add_weight = 0 if info.add_weight.nil?
|
661
|
-
e = ResizeEvent.new @current_component, type.to_sym
|
662
|
-
fire_handler :COMPONENT_RESIZE_EVENT, e
|
663
|
-
#@repaint_required = true
|
664
|
-
end
|
665
|
-
# fires handler to request app to resize current component
|
666
|
-
#
|
667
|
-
def decrease_height
|
668
|
-
resize_component :DECREASE, :HEIGHT
|
669
|
-
end
|
670
|
-
# fires handler to request app to resize current component
|
671
|
-
def decrease_width
|
672
|
-
resize_component :DECREASE, :WIDTH
|
673
|
-
end
|
674
|
-
# fires handler to request app to resize current component
|
675
|
-
def increase_width
|
676
|
-
resize_component :INCREASE, :WIDTH
|
677
|
-
end
|
678
|
-
# fires handler to request app to resize current component
|
679
|
-
def increase_height
|
680
|
-
resize_component :INCREASE, :HEIGHT
|
681
|
-
end
|
682
|
-
def increase_current_component
|
683
|
-
info = split_info_for
|
684
|
-
#info.add_weight = 0 if info.add_weight.nil?
|
685
|
-
#if info.add_weight < 0.3
|
686
|
-
#info.add_weight = info.add_weight + 0.05
|
687
|
-
#end
|
688
|
-
e = ResizeEvent.new @current_component, :INCREASE
|
689
|
-
fire_handler :COMPONENT_RESIZE_EVENT, e
|
690
|
-
#@repaint_required = true
|
691
|
-
end
|
692
|
-
# calling application need to handle this, since it knows
|
693
|
-
# how many windows its has and what the user would mean
|
694
|
-
def expand # maximize
|
695
|
-
e = ResizeEvent.new @current_component, :EXPAND
|
696
|
-
fire_handler :COMPONENT_RESIZE_EVENT, e
|
697
|
-
end
|
698
|
-
# calling application need to handle this, since it knows
|
699
|
-
# how many windows its has and what the user would mean
|
700
|
-
def unexpand
|
701
|
-
e = ResizeEvent.new @current_component, :UNEXPAND
|
702
|
-
fire_handler :COMPONENT_RESIZE_EVENT, e
|
703
|
-
end
|
704
|
-
|
705
|
-
private
|
706
|
-
def _create_divider
|
707
|
-
return if @vb
|
708
|
-
roffset = 1
|
709
|
-
loffset = 2
|
710
|
-
if @suppress_borders
|
711
|
-
loffset = roffset = 0
|
712
|
-
end
|
713
|
-
rc = @rc
|
714
|
-
if v?
|
715
|
-
@vb = Divider.new nil, :row => @row+roffset, :col => rc+@col-1, :length => @height-loffset, :side => :right
|
716
|
-
else
|
717
|
-
@vb = Divider.new nil, :row => @row+rc-1, :col => @col+1, :length => @width-loffset, :side => :bottom
|
718
|
-
end
|
719
|
-
@vb.focusable(false)
|
720
|
-
RubyCurses::FocusManager.add @vb
|
721
|
-
@vb.parent_component = self
|
722
|
-
@components << @vb
|
723
|
-
@vb.set_buffering(:target_window => @target_window || @form.window, :form => @form ) # removed on 2011-09-29
|
724
|
-
@vb.bind :DRAG_EVENT do |ev|
|
725
|
-
if v?
|
726
|
-
case ev.type
|
727
|
-
when KEY_RIGHT
|
728
|
-
$log.debug "VIMSPLIT RIGHT "
|
729
|
-
if @rc < @width - 3
|
730
|
-
@recalculate_splits = true
|
731
|
-
@rc += 1
|
732
|
-
@repaint_required = true # WHY ! Did prop handler not fire ?
|
733
|
-
end
|
734
|
-
when KEY_LEFT
|
735
|
-
if @rc > 3
|
736
|
-
@recalculate_splits = true
|
737
|
-
@repaint_required = true
|
738
|
-
@rc -= 1
|
739
|
-
end
|
740
|
-
end
|
741
|
-
else
|
742
|
-
# horizontal
|
743
|
-
case ev.type
|
744
|
-
when KEY_DOWN
|
745
|
-
if @rc < @height - 3
|
746
|
-
@recalculate_splits = true
|
747
|
-
@rc += 1
|
748
|
-
@repaint_required = true # WHY ! Did prop handler not fire ?
|
749
|
-
end
|
750
|
-
when KEY_UP
|
751
|
-
if @rc > 3
|
752
|
-
@recalculate_splits = true
|
753
|
-
@repaint_required = true
|
754
|
-
@rc -= 1
|
755
|
-
end
|
756
|
-
end
|
757
|
-
end # v?
|
758
|
-
end
|
759
|
-
end
|
760
|
-
|
761
|
-
# ADD HERE ABOVe
|
762
|
-
end # class
|
763
|
-
end # module
|