ncumbra 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.md +712 -6
- data/examples/ex1.rb +2 -3
- data/examples/ex3.rb +2 -3
- data/examples/ex4.rb +1 -2
- data/examples/ex5.rb +4 -3
- data/examples/exbox.rb +1 -1
- data/examples/extab3.rb +1 -2
- data/lib/umbra.rb +2 -0
- data/lib/umbra/box.rb +23 -9
- data/lib/umbra/button.rb +13 -14
- data/lib/umbra/checkbox.rb +3 -3
- data/lib/umbra/eventhandler.rb +2 -3
- data/lib/umbra/field.rb +23 -12
- data/lib/umbra/form.rb +19 -109
- data/lib/umbra/listbox.rb +26 -20
- data/lib/umbra/menu.rb +2 -2
- data/lib/umbra/messagebox.rb +2 -2
- data/lib/umbra/multiline.rb +95 -32
- data/lib/umbra/pad.rb +5 -3
- data/lib/umbra/radiobutton.rb +2 -2
- data/lib/umbra/tabular.rb +5 -2
- data/lib/umbra/textbox.rb +14 -153
- data/lib/umbra/togglebutton.rb +75 -112
- data/lib/umbra/version.rb +1 -1
- data/lib/umbra/widget.rb +9 -14
- data/lib/umbra/window.rb +8 -2
- data/tut/field.rb +72 -0
- data/tut/hello.rb +17 -0
- data/tut/label_hello.rb +28 -0
- data/tut/labfield.rb +63 -0
- metadata +6 -2
data/lib/umbra/tabular.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
* :
|
11
11
|
* Author : jkepler
|
12
12
|
* Date :
|
13
|
-
* Last Update : 2018-05-
|
13
|
+
* Last Update : 2018-05-31 16:16
|
14
14
|
* License : MIT
|
15
15
|
=end
|
16
16
|
|
@@ -241,7 +241,7 @@ module Umbra
|
|
241
241
|
buffer << str
|
242
242
|
#puts "-" * str.length
|
243
243
|
buffer << separator if @use_separator
|
244
|
-
if @list ## XXX why wasn't
|
244
|
+
if @list ## XXX why wasn't numbering done in _prepare_format ???? FIXME
|
245
245
|
if @numbering
|
246
246
|
fmstr = "%#{rows}d "+ @y + fmstr
|
247
247
|
end
|
@@ -268,6 +268,9 @@ module Umbra
|
|
268
268
|
end
|
269
269
|
|
270
270
|
## render_row
|
271
|
+
## @param [Array] row as Array
|
272
|
+
## @param [String] format string
|
273
|
+
## @param [Integer] row offset in data
|
271
274
|
def convert_value_to_text r, fmstr, index
|
272
275
|
return fmstr % r;
|
273
276
|
end
|
data/lib/umbra/textbox.rb
CHANGED
@@ -4,38 +4,34 @@
|
|
4
4
|
# Author: j kepler http://github.com/mare-imbrium/canis/
|
5
5
|
# Date: 2018-03-24 - 12:39
|
6
6
|
# License: MIT
|
7
|
-
# Last update: 2018-05-
|
7
|
+
# Last update: 2018-05-30 12:47
|
8
8
|
# ----------------------------------------------------------------------------- #
|
9
9
|
# textbox.rb Copyright (C) 2012-2018 j kepler
|
10
|
-
##
|
11
|
-
|
12
|
-
## 2018-05-08 - extend Multiline
|
10
|
+
## Todo -----------------------------------
|
11
|
+
## TODO w and b for next and previous word movement
|
13
12
|
#
|
14
13
|
# ----------------------------------------
|
15
14
|
## CHANGELOG
|
16
|
-
#
|
15
|
+
# 2018-05-30 - giving self during cursor movement
|
17
16
|
# ----------------------------------------
|
18
17
|
require 'umbra/multiline'
|
19
18
|
module Umbra
|
20
19
|
class Textbox < Multiline
|
21
20
|
attr_accessor :file_name # filename passed in for reading
|
22
21
|
#attr_accessor :cursor # position of cursor in line ??
|
23
|
-
=begin
|
24
|
-
attr_accessor :selected_mark # row selected character
|
25
|
-
attr_accessor :unselected_mark # row unselected character (usually blank)
|
26
|
-
attr_accessor :current_mark # row current character (default is >)
|
27
|
-
=end
|
28
22
|
|
29
23
|
def initialize config={}, &block
|
30
24
|
@highlight_attr = FFI::NCurses::A_BOLD
|
31
25
|
@row_offset = 0
|
32
26
|
@col_offset = 0
|
33
27
|
@curpos = 0 # current cursor position in buffer (NOT screen/window/field)
|
34
|
-
|
35
|
-
register_events([:CURSOR_MOVE]) #
|
28
|
+
|
29
|
+
register_events([:CURSOR_MOVE]) # movement of cursor left or right, up down or panning.
|
36
30
|
super
|
37
31
|
|
38
32
|
end
|
33
|
+
|
34
|
+
|
39
35
|
# set list of data to be displayed from filename. {{{
|
40
36
|
# NOTE this can be called again and again, so we need to take care of change in size of data
|
41
37
|
# as well as things like current_index and selected_index or indices.
|
@@ -81,150 +77,15 @@ class Textbox < Multiline
|
|
81
77
|
return ret
|
82
78
|
ensure
|
83
79
|
if @repaint_required
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
def OLDhandle_key ch # {{{
|
89
|
-
return :UNHANDLED unless @list
|
90
|
-
# save old positions so we know movement has happened
|
91
|
-
old_current_index = @current_index
|
92
|
-
old_pcol = @pcol
|
93
|
-
old_col_offset = @col_offset
|
94
|
-
|
95
|
-
begin
|
96
|
-
ret = super
|
97
|
-
return ret
|
98
|
-
ensure
|
99
|
-
@current_index = 0 if @current_index < 0
|
100
|
-
@current_index = @list.size-1 if @current_index >= @list.size
|
101
|
-
@repaint_required = true if @current_index != old_current_index
|
102
|
-
if @current_index != old_current_index or @pcol != old_pcol or @col_offset != old_col_offset
|
103
|
-
if @current_index != old_current_index
|
104
|
-
on_leave_row old_current_index
|
105
|
-
on_enter_row @current_index
|
106
|
-
end
|
107
|
-
@repaint_required = true
|
108
|
-
fire_handler(:CURSOR_MOVE, [@col_offset, @current_index, @curpos, @pcol, ch ]) # 2018-03-25 - improve this
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end # }}}
|
112
|
-
# advance col_offset (where cursor will be displayed on screen) {{{
|
113
|
-
# @param [Integer] advance by n (can be negative or positive)
|
114
|
-
# @return -1 if cannot advance
|
115
|
-
private def OLDadd_col_offset num
|
116
|
-
x = @col_offset + num
|
117
|
-
return -1 if x < 0
|
118
|
-
return -1 if x > @int_width
|
119
|
-
# is it a problem that i am directly changing col_offset ??? XXX
|
120
|
-
@col_offset += num
|
121
|
-
end
|
122
|
-
|
123
|
-
# move cursor forward one character, called with KEY_RIGHT action.
|
124
|
-
def OLDcursor_forward
|
125
|
-
blen = current_row().size-1
|
126
|
-
if @curpos < blen
|
127
|
-
if add_col_offset(1)==-1 # go forward if you can, else scroll
|
128
|
-
#@pcol += 1 if @pcol < @width
|
129
|
-
@pcol += 1 if @pcol < blen
|
130
|
-
end
|
131
|
-
@curpos += 1
|
132
|
-
end
|
133
|
-
end
|
134
|
-
def OLDcursor_backward
|
135
|
-
|
136
|
-
if @col_offset > 0
|
137
|
-
@curpos -= 1
|
138
|
-
add_col_offset -1
|
139
|
-
else
|
140
|
-
# cur is on the first col, then scroll left
|
141
|
-
if @pcol > 0
|
142
|
-
@pcol -= 1
|
143
|
-
@curpos -= 1
|
144
|
-
else
|
145
|
-
# do nothing
|
80
|
+
## this could get fired even if color changed or something not related to cursor moving. FIXME
|
81
|
+
## Should this fire if users scrolls but does not change cursor position
|
82
|
+
#fire_handler(:CURSOR_MOVE, [@col_offset, @current_index, @curpos, @panned_cols, ch ]) # 2018-03-25 - improve this
|
83
|
+
fire_handler(:CURSOR_MOVE, self) ## 2018-05-30 - made this like most others yielding self
|
146
84
|
end
|
147
85
|
end
|
148
86
|
end
|
149
|
-
# position cursor at start of field
|
150
|
-
def OLDcursor_home
|
151
|
-
@curpos = 0
|
152
|
-
@pcol = 0
|
153
|
-
set_col_offset 0
|
154
|
-
end
|
155
|
-
# goto end of line.
|
156
|
-
# This should be consistent with moving the cursor to the end of the row with right arrow
|
157
|
-
def OLDcursor_end
|
158
|
-
blen = current_row().length
|
159
|
-
if blen < @int_width
|
160
|
-
set_col_offset blen # just after the last character
|
161
|
-
@pcol = 0
|
162
|
-
else
|
163
|
-
@pcol = blen-@int_width
|
164
|
-
set_col_offset blen
|
165
|
-
end
|
166
|
-
@curpos = blen # this is position in array where editing or motion is to happen regardless of what you see
|
167
|
-
# regardless of pcol (panning)
|
168
|
-
end
|
169
|
-
# go to start of file (first line)
|
170
|
-
def OLDgoto_start
|
171
|
-
@current_index = 0
|
172
|
-
@pcol = @curpos = 0
|
173
|
-
set_col_offset 0
|
174
|
-
end
|
175
|
-
# go to end of file (last line)
|
176
|
-
def OLDgoto_end
|
177
|
-
@current_index = @list.size-1
|
178
|
-
end
|
179
|
-
# sets the visual cursor on the window at correct place
|
180
|
-
# NOTE be careful of curpos - pcol being less than 0
|
181
|
-
# @param [Integer] position in data on the line
|
182
|
-
private def OLD_set_col_offset x=@curpos
|
183
|
-
@curpos = x || 0 # NOTE we set the index of cursor here - WHY TWO THINGS ??? XXX
|
184
|
-
#return -1 if x < 0
|
185
|
-
#return -1 if x > @width
|
186
|
-
if x >= @int_width
|
187
|
-
x = @int_width
|
188
|
-
@col_offset = @int_width
|
189
|
-
return
|
190
|
-
end
|
191
|
-
@col_offset = x
|
192
|
-
@col_offset = @int_width if @col_offset > @int_width
|
193
|
-
return
|
194
|
-
end
|
195
|
-
# called whenever a row entered.
|
196
|
-
# Call when object entered, also.
|
197
|
-
def OLD_on_enter_row index
|
198
|
-
#fire_handler(:ENTER_ROW, [old_current_index, @current_index, ch ]) # 2018-03-26 - improve this
|
199
|
-
fire_handler(:ENTER_ROW, [@current_index]) # 2018-03-26 - improve this
|
200
|
-
# if cursor ahead of blen then fix it
|
201
|
-
blen = current_row().size-1
|
202
|
-
if @curpos > blen
|
203
|
-
@col_offset = blen - @pcol
|
204
|
-
@curpos = blen
|
205
|
-
if @pcol > blen
|
206
|
-
@pcol = blen - @int_width
|
207
|
-
@pcol = 0 if @pcol < 0
|
208
|
-
@col_offset = blen - @pcol
|
209
|
-
end
|
210
|
-
end
|
211
|
-
@col_offset = 0 if @col_offset < 0
|
212
|
-
end # }}}
|
213
|
-
## border {{{
|
214
|
-
private def print_border row, col, height, width, color, att=FFI::NCurses::A_NORMAL
|
215
|
-
raise
|
216
|
-
pointer = @graphic.pointer
|
217
|
-
FFI::NCurses.wattron(pointer, FFI::NCurses.COLOR_PAIR(color) | att)
|
218
|
-
FFI::NCurses.mvwaddch pointer, row, col, FFI::NCurses::ACS_ULCORNER
|
219
|
-
FFI::NCurses.mvwhline( pointer, row, col+1, FFI::NCurses::ACS_HLINE, width-2)
|
220
|
-
FFI::NCurses.mvwaddch pointer, row, col+width-1, FFI::NCurses::ACS_URCORNER
|
221
|
-
FFI::NCurses.mvwvline( pointer, row+1, col, FFI::NCurses::ACS_VLINE, height-2)
|
222
87
|
|
223
|
-
FFI::NCurses.mvwaddch pointer, row+height-1, col, FFI::NCurses::ACS_LLCORNER
|
224
|
-
FFI::NCurses.mvwhline(pointer, row+height-1, col+1, FFI::NCurses::ACS_HLINE, width-2)
|
225
|
-
FFI::NCurses.mvwaddch pointer, row+height-1, col+width-1, FFI::NCurses::ACS_LRCORNER
|
226
|
-
FFI::NCurses.mvwvline( pointer, row+1, col+width-1, FFI::NCurses::ACS_VLINE, height-2)
|
227
|
-
FFI::NCurses.wattroff(pointer, FFI::NCurses.COLOR_PAIR(color) | att)
|
228
|
-
end # }}}
|
229
88
|
end
|
230
89
|
end # module
|
90
|
+
|
91
|
+
# vim: comments=sr\:##,mb\:##,el\:#/,\:## :
|
data/lib/umbra/togglebutton.rb
CHANGED
@@ -6,133 +6,96 @@ require 'umbra/button'
|
|
6
6
|
# Author: j kepler http://github.com/mare-imbrium/umbra/
|
7
7
|
# Date: 2018-03-17 - 22:50
|
8
8
|
# License: MIT
|
9
|
-
# Last update: 2018-05-
|
9
|
+
# Last update: 2018-05-27 14:21
|
10
10
|
# ----------------------------------------------------------------------------- #
|
11
|
-
# togglebutton.rb Copyright (C)
|
11
|
+
# togglebutton.rb Copyright (C) 2018 j kepler
|
12
12
|
#
|
13
13
|
#
|
14
14
|
module Umbra
|
15
|
-
##
|
16
|
-
# an event fired when an item that can be selected is toggled/selected
|
17
|
-
class ItemEvent # {{{
|
18
|
-
# http://java.sun.com/javase/6/docs/api/java/awt/event/ItemEvent.html
|
19
|
-
attr_reader :state # :SELECTED :DESELECTED
|
20
|
-
attr_reader :item # the item pressed such as toggle button
|
21
|
-
attr_reader :item_selectable # item originating event such as list or collection
|
22
|
-
attr_reader :item_first # if from a list
|
23
|
-
attr_reader :item_last #
|
24
|
-
attr_reader :param_string # for debugging etc
|
25
|
-
=begin
|
26
|
-
def initialize item, item_selectable, state, item_first=-1, item_last=-1, paramstring=nil
|
27
|
-
@item, @item_selectable, @state, @item_first, @item_last =
|
28
|
-
item, item_selectable, state, item_first, item_last
|
29
|
-
@param_string = "Item event fired: #{item}, #{state}"
|
30
|
-
end
|
31
|
-
=end
|
32
|
-
# i think only one is needed per object, so create once only
|
33
|
-
def initialize item, item_selectable
|
34
|
-
@item, @item_selectable =
|
35
|
-
item, item_selectable
|
36
|
-
end
|
37
|
-
def set state, item_first=-1, item_last=-1, param_string=nil
|
38
|
-
@state, @item_first, @item_last, @param_string =
|
39
|
-
state, item_first, item_last, param_string
|
40
|
-
@param_string = "Item event fired: #{item}, #{state}" if param_string.nil?
|
41
|
-
end
|
42
|
-
end # }}}
|
43
|
-
# A button that may be switched off an on.
|
44
|
-
# Extended by RadioButton and checkbox.
|
45
|
-
# WARNING, pls do not override +text+ otherwise checkboxes etc will stop functioning.
|
46
|
-
# TODO: add editable here nd prevent toggling if not so.
|
47
|
-
class ToggleButton < Button
|
48
|
-
# text for on value and off value
|
49
|
-
attr_accessor :onvalue, :offvalue
|
50
|
-
# boolean, which value to use currently, onvalue or offvalue
|
51
|
-
attr_accessor :value
|
52
|
-
# characters to use for surround, array, default square brackets
|
53
|
-
attr_property :surround_chars
|
54
|
-
# 2018-04-02 - removing variable
|
55
|
-
#attr_accessor :variable # value linked to this variable which is a boolean
|
56
|
-
# background to use when selected, if not set then default
|
57
|
-
# 2018-04-02 - unused so commenting off. color_pair is not used here or in checkbox
|
58
|
-
attr_property :selected_color_pair
|
59
15
|
|
60
|
-
|
61
|
-
|
16
|
+
# A button that may be switched off an on.
|
17
|
+
# Extended by RadioButton and checkbox.
|
18
|
+
# WARNING, pls do not override +text+ otherwise checkboxes etc will stop functioning.
|
19
|
+
# TODO: add editable here and prevent toggling if not so.
|
20
|
+
class ToggleButton < Button
|
21
|
+
# text to display for on value and off value
|
22
|
+
attr_accessor :onvalue, :offvalue
|
23
|
+
# boolean, which value to use currently, onvalue or offvalue
|
24
|
+
attr_property :value
|
25
|
+
# characters to use for surround, array, default square brackets
|
26
|
+
#attr_property :surround_chars already in button
|
27
|
+
# 2018-04-02 - removing variable
|
28
|
+
# background to use when selected, if not set then default
|
29
|
+
# 2018-04-02 - unused so commenting off. color_pair is not used here or in checkbox
|
30
|
+
#attr_property :selected_color_pair
|
62
31
|
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
def getvalue
|
67
|
-
@value ? @onvalue : @offvalue
|
68
|
-
end
|
32
|
+
def initialize config={}, &block
|
33
|
+
super
|
69
34
|
|
70
|
-
|
35
|
+
end
|
36
|
+
def getvalue
|
37
|
+
@value ? @onvalue : @offvalue
|
38
|
+
end
|
39
|
+
|
40
|
+
# WARNING, pls do not override +text+ otherwise checkboxes etc will stop functioning.
|
71
41
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
42
|
+
# added for some standardization 2010-09-07 20:28
|
43
|
+
# alias :text :getvalue # NEXT VERSION
|
44
|
+
# change existing text to label
|
45
|
+
##
|
46
|
+
# is the button on or off
|
47
|
+
# added 2008-12-09 19:05
|
48
|
+
def checked?
|
49
|
+
@value
|
50
|
+
end
|
51
|
+
alias :selected? :checked?
|
82
52
|
|
83
|
-
|
84
|
-
|
85
|
-
|
53
|
+
def getvalue_for_paint
|
54
|
+
# when the width is set externally then the surround chars sit outside the width
|
55
|
+
#unless @width
|
86
56
|
if @onvalue && @offvalue
|
87
57
|
@width = [ @onvalue.length, @offvalue.length ].max
|
88
58
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
# toggle button handle key
|
96
|
-
# @param [int] key received
|
97
|
-
#
|
98
|
-
def handle_key ch
|
99
|
-
if ch == 32
|
100
|
-
toggle
|
101
|
-
@repaint_required = true # need to change the label
|
102
|
-
else
|
103
|
-
super
|
59
|
+
#end
|
60
|
+
buttontext = getvalue().center(@width)
|
61
|
+
@text_offset = @surround_chars[0].length
|
62
|
+
@surround_chars[0] + buttontext + @surround_chars[1]
|
104
63
|
end
|
105
|
-
end
|
106
64
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
# caller should check state of itemevent passed to block
|
115
|
-
# NOTE i have not brought ItemEvent in here.
|
116
|
-
def fire
|
117
|
-
checked(!@value)
|
118
|
-
@item_event = ItemEvent.new self, self if @item_event.nil?
|
119
|
-
@item_event.set(@value ? :SELECTED : :DESELECTED)
|
120
|
-
fire_handler :PRESS, @item_event # should the event itself be ITEM_EVENT
|
121
|
-
end
|
122
|
-
##
|
123
|
-
# set the value to true or false
|
124
|
-
# user may programmatically want to check or uncheck
|
125
|
-
def checked tf
|
126
|
-
@value = tf
|
127
|
-
=begin
|
128
|
-
if @variable
|
129
|
-
if @value
|
130
|
-
@variable.set_value((@onvalue || 1), @name)
|
65
|
+
# toggle button handle key
|
66
|
+
# @param [int] key received
|
67
|
+
#
|
68
|
+
def handle_key ch
|
69
|
+
if ch == 32
|
70
|
+
toggle
|
71
|
+
@repaint_required = true # need to change the label
|
131
72
|
else
|
132
|
-
|
73
|
+
super
|
133
74
|
end
|
134
75
|
end
|
135
|
-
|
136
|
-
|
137
|
-
|
76
|
+
|
77
|
+
##
|
78
|
+
# toggle the button value
|
79
|
+
def toggle
|
80
|
+
fire
|
81
|
+
end
|
82
|
+
|
83
|
+
# called on :PRESS event
|
84
|
+
def fire
|
85
|
+
checked(!@value)
|
86
|
+
#@item_event = ItemEvent.new self, self if @item_event.nil?
|
87
|
+
#@item_event.set(@value ? :SELECTED : :DESELECTED)
|
88
|
+
#fire_handler :PRESS, @item_event # should the event itself be ITEM_EVENT
|
89
|
+
## 2018-05-27 - trying to use self in most cases. Above was not needed.
|
90
|
+
fire_handler :PRESS, self
|
91
|
+
end
|
92
|
+
##
|
93
|
+
# set the value to true or false
|
94
|
+
# user may programmatically want to check or uncheck
|
95
|
+
# ## duplicate of value ??? 2018-05-26 -
|
96
|
+
def checked tf
|
97
|
+
@value = tf
|
98
|
+
@repaint_required = true
|
99
|
+
end
|
100
|
+
end # class
|
138
101
|
end # module
|
data/lib/umbra/version.rb
CHANGED
data/lib/umbra/widget.rb
CHANGED
@@ -44,7 +44,7 @@ class Widget
|
|
44
44
|
include KeyMappingHandler
|
45
45
|
# common interface for text related to a field, label, textview, button etc
|
46
46
|
attr_property :text
|
47
|
-
attr_property :width, :height ##
|
47
|
+
attr_property :width, :height ## width and height of widget
|
48
48
|
|
49
49
|
# foreground and background colors when focussed. Currently used with buttons and field
|
50
50
|
# Form checks and repaints on entry if these are set.
|
@@ -54,13 +54,12 @@ class Widget
|
|
54
54
|
# NOTE: 2018-03-04 - user will have to call repaint_required if he changes color or coordinates.
|
55
55
|
attr_accessor :col # location of object
|
56
56
|
attr_writer :row # location of object
|
57
|
-
#attr_writer :color, :bgcolor # normal foreground and background 2018-03-08 - now color_pair
|
58
57
|
# moved to a method which calculates color 2011-11-12
|
59
58
|
attr_property :color_pair # instead of colors give just color_pair
|
60
59
|
attr_property :attr # attribute bold, normal, reverse
|
61
60
|
attr_accessor :name # name to refr to or recall object by_name
|
62
61
|
attr_accessor :curpos # cursor position inside object - column, not row.
|
63
|
-
attr_reader :config # can be used for popping user objects too. NOTE unused
|
62
|
+
#attr_reader :config # can be used for popping user objects too. NOTE unused
|
64
63
|
#attr_accessor :form # made accessor 2008-11-27 22:32 so menu can set
|
65
64
|
attr_accessor :graphic # window which should be set by form when adding 2018-03-19
|
66
65
|
attr_accessor :state # normal, selected, highlighted
|
@@ -76,8 +75,8 @@ class Widget
|
|
76
75
|
|
77
76
|
#attr_accessor :parent_component # added 2010-01-12 23:28 BUFFERED - to bubble up
|
78
77
|
|
79
|
-
# NOTE state takes care of this and is set by form. boolean
|
80
|
-
attr_reader :focussed # is this widget in focus, so they may paint differently
|
78
|
+
# NOTE state takes care of this and is set by form. boolean 2018-05-26 - commented since unused
|
79
|
+
#attr_reader :focussed # is this widget in focus, so they may paint differently
|
81
80
|
|
82
81
|
# height percent and width percent used in stacks and flows.
|
83
82
|
#attr_accessor :height_pc, :width_pc # may bring this back
|
@@ -99,9 +98,8 @@ class Widget
|
|
99
98
|
# These are standard events for most widgets which will be fired by
|
100
99
|
# Form. In the case of CHANGED, form fires if it's editable property is set, so
|
101
100
|
# it does not apply to all widgets.
|
102
|
-
# 2018-03-18 - proporty change is deprecated since we don't use dsl_property any longer
|
103
101
|
register_events( [:ENTER, :LEAVE, :CHANGED, :PROPERTY_CHANGE])
|
104
|
-
@repaint_required = true
|
102
|
+
@repaint_required = true
|
105
103
|
|
106
104
|
aconfig.each_pair { |k,v| variable_set(k,v) }
|
107
105
|
#instance_eval &block if block_given?
|
@@ -129,25 +127,21 @@ class Widget
|
|
129
127
|
def modified?
|
130
128
|
@modified
|
131
129
|
end
|
132
|
-
#def set_modified tf=true
|
133
|
-
#@modified = tf
|
134
|
-
#end
|
135
|
-
#alias :modified :set_modified
|
136
130
|
|
137
131
|
# triggered whenever a widget is entered.
|
138
132
|
# NOTE should we not fix cursor at this point (on_enter) ?
|
139
133
|
def on_enter
|
134
|
+
## Form has already set this, and set modified to false
|
140
135
|
@state = :HIGHLIGHTED # duplicating since often these are inside containers
|
141
|
-
|
136
|
+
#@focussed = true
|
142
137
|
if @handler && @handler.has_key?(:ENTER)
|
143
138
|
fire_handler :ENTER, self
|
144
139
|
end
|
145
140
|
end
|
146
141
|
## Called when user exits a widget
|
147
|
-
# 2018-03-04 - Are we keeping this at all, can we avoid NOT_SURE
|
148
142
|
def on_leave
|
149
143
|
@state = :NORMAL # duplicating since often these are inside containers
|
150
|
-
|
144
|
+
#@focussed = false
|
151
145
|
if @handler && @handler.has_key?(:LEAVE)
|
152
146
|
fire_handler :LEAVE, self
|
153
147
|
end
|
@@ -268,6 +262,7 @@ class Widget
|
|
268
262
|
@height
|
269
263
|
end
|
270
264
|
def row
|
265
|
+
return nil unless @row
|
271
266
|
if @row < 0
|
272
267
|
return FFI::NCurses.LINES + @row
|
273
268
|
end
|