rndk 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -4
- data/TODO +21 -1
- data/demos/appointment.rb +279 -299
- data/demos/clock.rb +13 -8
- data/demos/rss-reader.rb +84 -0
- data/examples/01-hello-world.rb +13 -11
- data/examples/02-colors.rb +14 -21
- data/examples/03-markup.rb +7 -7
- data/examples/04-quick-widgets.rb +2 -2
- data/examples/05-position-widget.rb +50 -31
- data/examples/06-callbacks.rb +77 -0
- data/examples/07-traverse.rb +90 -0
- data/examples/10-all-widgets.rb +165 -0
- data/examples/calendar.rb +20 -32
- data/examples/entry.rb +15 -20
- data/examples/label.rb +11 -11
- data/examples/scroll.rb +16 -60
- data/examples/slider.rb +18 -19
- data/examples/viewer.rb +65 -0
- data/lib/rndk.rb +28 -7
- data/lib/rndk/alphalist.rb +309 -313
- data/lib/rndk/button.rb +239 -157
- data/lib/rndk/buttonbox.rb +136 -103
- data/lib/rndk/calendar.rb +246 -203
- data/lib/rndk/core/color.rb +63 -13
- data/lib/rndk/core/display.rb +1 -1
- data/lib/rndk/core/draw.rb +11 -11
- data/lib/rndk/core/markup.rb +21 -21
- data/lib/rndk/core/quick_widgets.rb +75 -96
- data/lib/rndk/core/screen.rb +145 -102
- data/lib/rndk/core/traverse.rb +150 -136
- data/lib/rndk/core/utils.rb +5 -6
- data/lib/rndk/core/widget.rb +207 -191
- data/lib/rndk/core/widget_bind.rb +108 -0
- data/lib/rndk/dialog.rb +88 -56
- data/lib/rndk/entry.rb +79 -64
- data/lib/rndk/fscale.rb +38 -20
- data/lib/rndk/fslider.rb +38 -23
- data/lib/rndk/graph.rb +92 -53
- data/lib/rndk/itemlist.rb +80 -62
- data/lib/rndk/label.rb +111 -77
- data/lib/rndk/radio.rb +138 -128
- data/lib/rndk/scale.rb +123 -122
- data/lib/rndk/scroll.rb +444 -391
- data/lib/rndk/scroller.rb +21 -21
- data/lib/rndk/slider.rb +149 -140
- data/lib/rndk/template.rb +74 -61
- data/lib/rndk/version.rb +1 -1
- data/lib/rndk/viewer.rb +499 -298
- metadata +8 -14
- data/demos/fileview.rb +0 -141
- data/lib/rndk/dscale.rb +0 -13
- data/lib/rndk/fselect.rb +0 -938
- data/lib/rndk/histogram.rb +0 -412
- data/lib/rndk/marquee.rb +0 -244
- data/lib/rndk/matrix.rb +0 -1189
- data/lib/rndk/mentry.rb +0 -619
- data/lib/rndk/menu.rb +0 -478
- data/lib/rndk/selection.rb +0 -630
- data/lib/rndk/swindow.rb +0 -766
- data/lib/rndk/uscale.rb +0 -14
- data/lib/rndk/uslider.rb +0 -14
data/lib/rndk/fscale.rb
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
require 'rndk/scale'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
class
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
class Fscale < Scale
|
5
|
+
def initialize(screen, config={})
|
6
|
+
@widget_type = :Fscale
|
7
|
+
|
8
|
+
x = 0
|
9
|
+
y = 0
|
10
|
+
title = "fscale"
|
11
|
+
label = "label"
|
12
|
+
field_attr = RNDK::Color[:normal]
|
13
|
+
field_width = 0
|
14
|
+
start = 0
|
15
|
+
low = 0
|
16
|
+
high = 100
|
17
|
+
inc = 1
|
18
|
+
fast_inc = 5
|
19
|
+
digits = 3
|
20
|
+
box = true
|
21
|
+
shadow = false
|
22
|
+
|
23
|
+
config.each do |key, val|
|
24
|
+
x = val if key == :x
|
25
|
+
y = val if key == :y
|
26
|
+
title = val if key == :title
|
27
|
+
label = val if key == :label
|
28
|
+
field_attr = val if key == :field_attr
|
29
|
+
field_width = val if key == :field_width
|
30
|
+
start = val if key == :start
|
31
|
+
low = val if key == :low
|
32
|
+
high = val if key == :high
|
33
|
+
inc = val if key == :inc
|
34
|
+
fast_inc = val if key == :fast_inc
|
35
|
+
digits = val if key == :digits
|
36
|
+
box = val if key == :box
|
37
|
+
shadow = val if key == :shadow
|
38
|
+
end
|
39
|
+
|
20
40
|
@digits = digits
|
21
|
-
super(
|
41
|
+
super(screen, x, y, title, label, field_attr, field_width, start, low, high, inc, fast_inc, box, shadow)
|
22
42
|
end
|
23
43
|
|
24
44
|
def drawField
|
@@ -54,8 +74,6 @@ module RNDK
|
|
54
74
|
'%g%c'
|
55
75
|
end
|
56
76
|
|
57
|
-
def object_type
|
58
|
-
:FSCALE
|
59
|
-
end
|
60
77
|
end
|
61
78
|
end
|
79
|
+
|
data/lib/rndk/fslider.rb
CHANGED
@@ -1,29 +1,47 @@
|
|
1
1
|
require 'rndk/slider'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
class
|
5
|
-
def initialize(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
class Fslider < Slider
|
5
|
+
def initialize(screen, config={})
|
6
|
+
x = 0
|
7
|
+
y = 0
|
8
|
+
title = "fslider"
|
9
|
+
label = "label"
|
10
|
+
filler = ' '.ord | RNDK::Color[:reverse]
|
11
|
+
field_width = 0
|
12
|
+
start = 0
|
13
|
+
low = 0
|
14
|
+
high = 100
|
15
|
+
inc = 1
|
16
|
+
fast_inc = 5
|
17
|
+
digits = 3
|
18
|
+
box = true
|
19
|
+
shadow = false
|
20
|
+
|
21
|
+
config.each do |key, val|
|
22
|
+
x = val if key == :x
|
23
|
+
y = val if key == :y
|
24
|
+
title = val if key == :title
|
25
|
+
label = val if key == :label
|
26
|
+
filler = val if key == :filler
|
27
|
+
field_width = val if key == :field_width
|
28
|
+
start = val if key == :start
|
29
|
+
low = val if key == :low
|
30
|
+
high = val if key == :high
|
31
|
+
inc = val if key == :inc
|
32
|
+
fast_inc = val if key == :fast_inc
|
33
|
+
digits = val if key == :digits
|
34
|
+
box = val if key == :box
|
35
|
+
shadow = val if key == :shadow
|
36
|
+
end
|
20
37
|
|
21
38
|
@digits = digits
|
22
|
-
super(
|
39
|
+
super(screen, x, y, title, label, filler, field_width, start, low, high, inc, fast_inc, box, shadow)
|
40
|
+
@widget_type = :fslider
|
23
41
|
end
|
24
42
|
|
25
43
|
# This draws the widget.
|
26
|
-
def
|
44
|
+
def draw_field
|
27
45
|
step = 1.0 * @field_width / (@high - @low)
|
28
46
|
|
29
47
|
# Determine how many filler characters need to be drawn.
|
@@ -45,7 +63,7 @@ module RNDK
|
|
45
63
|
@field_width,
|
46
64
|
0,
|
47
65
|
temp,
|
48
|
-
|
66
|
+
RNDK::Color[:normal],
|
49
67
|
RNDK::HORIZONTAL,
|
50
68
|
0,
|
51
69
|
temp.size)
|
@@ -54,7 +72,7 @@ module RNDK
|
|
54
72
|
Ncurses.wrefresh(@field_win)
|
55
73
|
end
|
56
74
|
|
57
|
-
def
|
75
|
+
def formatted_size(value)
|
58
76
|
digits = [@digits, 30].min
|
59
77
|
format = '%%.%if' % [digits]
|
60
78
|
temp = format % [value]
|
@@ -73,8 +91,5 @@ module RNDK
|
|
73
91
|
'%g%c'
|
74
92
|
end
|
75
93
|
|
76
|
-
def object_type
|
77
|
-
:FSLIDER
|
78
|
-
end
|
79
94
|
end
|
80
95
|
end
|
data/lib/rndk/graph.rb
CHANGED
@@ -1,38 +1,75 @@
|
|
1
1
|
require 'rndk'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
|
5
|
+
# TODO Fix how this widget is displayed onscreen.
|
6
|
+
#
|
7
|
+
# ## Signals
|
8
|
+
#
|
9
|
+
# For info, see Signals section on Widget class.
|
10
|
+
#
|
11
|
+
# ### :before_set_data
|
12
|
+
#
|
13
|
+
# * when: right before Graph#set_values fix the new values
|
14
|
+
# into the widget.
|
15
|
+
# * argument: The **new data** to be fixed
|
16
|
+
# * effect when return false: Interrupt fixing the data,
|
17
|
+
# old data is kept.
|
18
|
+
#
|
19
|
+
# ### :after_set_data
|
20
|
+
#
|
21
|
+
# * when: right after Graph#set_values does it's job.
|
22
|
+
# * argument: The **new data** as an argument.
|
23
|
+
#
|
24
|
+
class Graph < Widget
|
25
|
+
|
26
|
+
def initialize(screen, config={})
|
13
27
|
super()
|
14
|
-
|
15
|
-
|
28
|
+
@widget_type = :graph
|
29
|
+
@supported_signals += [:before_set_data, :after_set_data]
|
30
|
+
|
31
|
+
x = 0
|
32
|
+
y = 0
|
33
|
+
width = 0
|
34
|
+
height = 0
|
35
|
+
title = " graph" # MUST HAVE TWO SPACES BECAUSE OF FUCK
|
36
|
+
xtitle = "x"
|
37
|
+
ytitle = "y"
|
38
|
+
box = true
|
39
|
+
|
40
|
+
config.each do |key, val|
|
41
|
+
x = val if key == :x
|
42
|
+
y = val if key == :y
|
43
|
+
width = val if key == :width
|
44
|
+
height = val if key == :height
|
45
|
+
title = val if key == :title
|
46
|
+
xtitle = val if key == :xtitle
|
47
|
+
ytitle = val if key == :ytitle
|
48
|
+
box = val if key == :box
|
49
|
+
end
|
50
|
+
|
51
|
+
parent_width = Ncurses.getmaxx screen.window
|
52
|
+
parent_height = Ncurses.getmaxy screen.window
|
16
53
|
|
17
54
|
self.set_box(false)
|
18
55
|
|
19
|
-
box_height = RNDK.
|
20
|
-
box_width = RNDK.
|
56
|
+
box_height = RNDK.set_widget_dimension(parent_height, height, 3)
|
57
|
+
box_width = RNDK.set_widget_dimension(parent_width, width, 0)
|
21
58
|
box_width = self.set_title(title, box_width)
|
22
59
|
box_height += @title_lines
|
23
60
|
box_width = [parent_width, box_width].min
|
24
61
|
box_height = [parent_height, box_height].min
|
25
62
|
|
26
63
|
# Rejustify the x and y positions if we need to
|
27
|
-
xtmp = [
|
28
|
-
ytmp = [
|
29
|
-
RNDK.alignxy(
|
64
|
+
xtmp = [x]
|
65
|
+
ytmp = [y]
|
66
|
+
RNDK.alignxy(screen.window, xtmp, ytmp, box_width, box_height)
|
30
67
|
xpos = xtmp[0]
|
31
68
|
ypos = ytmp[0]
|
32
69
|
|
33
70
|
# Create the widget pointer
|
34
|
-
@screen =
|
35
|
-
@parent =
|
71
|
+
@screen = screen
|
72
|
+
@parent = screen.window
|
36
73
|
@win = Ncurses.newwin(box_height, box_width, ypos, xpos)
|
37
74
|
@box_height = box_height
|
38
75
|
@box_width = box_width
|
@@ -42,6 +79,7 @@ module RNDK
|
|
42
79
|
@yscale = 0
|
43
80
|
@count = 0
|
44
81
|
@display_type = :LINE
|
82
|
+
@box = box
|
45
83
|
|
46
84
|
if @win.nil?
|
47
85
|
self.destroy
|
@@ -84,24 +122,24 @@ module RNDK
|
|
84
122
|
@graph_char = 0
|
85
123
|
@values = []
|
86
124
|
|
87
|
-
|
125
|
+
screen.register(@widget_type, self)
|
88
126
|
end
|
89
127
|
|
90
128
|
# This was added for the builder.
|
91
|
-
def activate(actions)
|
92
|
-
self.draw
|
129
|
+
def activate(actions=[])
|
130
|
+
self.draw
|
93
131
|
end
|
94
132
|
|
95
133
|
# Set multiple attributes of the widget
|
96
|
-
def set(values,
|
97
|
-
ret = self.
|
134
|
+
def set(values, graph_char, start_at_zero, display_type)
|
135
|
+
ret = self.set_values(values, start_at_zero)
|
98
136
|
self.setCharacters(graph_char)
|
99
137
|
self.setDisplayType(display_type)
|
100
138
|
return ret
|
101
139
|
end
|
102
140
|
|
103
141
|
# Set the scale factors for the graph after wee have loaded new values.
|
104
|
-
def
|
142
|
+
def set_scales
|
105
143
|
@xscale = (@maxx - @minx) / [1, @box_height - @title_lines - 5].max
|
106
144
|
if @xscale <= 0
|
107
145
|
@xscale = 1
|
@@ -114,7 +152,9 @@ module RNDK
|
|
114
152
|
end
|
115
153
|
|
116
154
|
# Set the values of the graph.
|
117
|
-
def
|
155
|
+
def set_values(values, start_at_zero)
|
156
|
+
count = values.size
|
157
|
+
|
118
158
|
min = 2**30
|
119
159
|
max = -2**30
|
120
160
|
|
@@ -123,6 +163,9 @@ module RNDK
|
|
123
163
|
return false
|
124
164
|
end
|
125
165
|
|
166
|
+
keep_going = self.run_signal_binding(:before_set_data)
|
167
|
+
return if not keep_going
|
168
|
+
|
126
169
|
if !(@values.nil?) && @values.size > 0
|
127
170
|
@values = []
|
128
171
|
@count = 0
|
@@ -147,18 +190,18 @@ module RNDK
|
|
147
190
|
@minx = 0
|
148
191
|
end
|
149
192
|
|
150
|
-
self.
|
151
|
-
|
152
|
-
|
193
|
+
self.set_scales
|
194
|
+
self.run_signal_binding(:after_set_data)
|
195
|
+
true
|
153
196
|
end
|
154
197
|
|
155
198
|
def getValues(size)
|
156
199
|
size << @count
|
157
|
-
|
200
|
+
@values
|
158
201
|
end
|
159
202
|
|
160
203
|
# Set the value of the graph at the given index.
|
161
|
-
def
|
204
|
+
def set_value(index, value, start_at_zero)
|
162
205
|
# Make sure the index is within range.
|
163
206
|
if index < 0 || index >= @count
|
164
207
|
return false
|
@@ -174,9 +217,8 @@ module RNDK
|
|
174
217
|
@minx = 0
|
175
218
|
end
|
176
219
|
|
177
|
-
self.
|
178
|
-
|
179
|
-
return true
|
220
|
+
self.set_scales
|
221
|
+
true
|
180
222
|
end
|
181
223
|
|
182
224
|
def getValue(index)
|
@@ -236,22 +278,22 @@ module RNDK
|
|
236
278
|
end
|
237
279
|
|
238
280
|
# Set the background attribute of the widget.
|
239
|
-
def
|
281
|
+
def set_bg_color(attrib)
|
240
282
|
Ncurses.wbkgd(@win, attrib)
|
241
283
|
end
|
242
284
|
|
243
285
|
# Move the graph field to the given location.
|
244
|
-
def move(
|
286
|
+
def move(x, y, relative, refresh_flag)
|
245
287
|
current_x = Ncurses.getbegx(@win)
|
246
288
|
current_y = Ncurses.getbegy(@win)
|
247
|
-
xpos =
|
248
|
-
ypos =
|
289
|
+
xpos = x
|
290
|
+
ypos = y
|
249
291
|
|
250
292
|
# If this is a relative move, then we will adjust where we want
|
251
293
|
# to move to
|
252
294
|
if relative
|
253
|
-
xpos = Ncurses.getbegx(@win) +
|
254
|
-
ypos = Ncurses.getbegy(@win) +
|
295
|
+
xpos = Ncurses.getbegx(@win) + x
|
296
|
+
ypos = Ncurses.getbegy(@win) + y
|
255
297
|
end
|
256
298
|
|
257
299
|
# Adjust the window if we need to.
|
@@ -274,15 +316,15 @@ module RNDK
|
|
274
316
|
|
275
317
|
# Reraw the windowk if they asked for it
|
276
318
|
if refresh_flag
|
277
|
-
self.draw
|
319
|
+
self.draw
|
278
320
|
end
|
279
321
|
end
|
280
322
|
|
281
|
-
# Draw the
|
282
|
-
def draw(box)
|
323
|
+
# Draw the graph widget
|
324
|
+
def draw(box=false)
|
283
325
|
adj = 2 + (if @xtitle.nil? || @xtitle.size == 0 then 0 else 1 end)
|
284
326
|
spacing = 0
|
285
|
-
attrib = ' '.ord |
|
327
|
+
attrib = ' '.ord | RNDK::Color[:reverse]
|
286
328
|
|
287
329
|
if box
|
288
330
|
Draw.drawObjBox(@win, self)
|
@@ -304,12 +346,12 @@ module RNDK
|
|
304
346
|
@box_height - 3,
|
305
347
|
Ncurses::ACS_HLINE)
|
306
348
|
|
307
|
-
self.
|
349
|
+
self.draw_title(@win)
|
308
350
|
|
309
351
|
# Draw in the X axis title.
|
310
352
|
if !(@xtitle.nil?) && @xtitle.size > 0
|
311
353
|
Draw.writeChtype(@win, 0, @xtitle_pos, @xtitle, RNDK::VERTICAL, 0, @xtitle_len)
|
312
|
-
attrib = @xtitle[0] &
|
354
|
+
attrib = @xtitle[0] & RNDK::Color[:extract]
|
313
355
|
end
|
314
356
|
|
315
357
|
# Draw in the X axis high value
|
@@ -377,25 +419,22 @@ module RNDK
|
|
377
419
|
end
|
378
420
|
|
379
421
|
def destroy
|
380
|
-
self.
|
381
|
-
self.clean_bindings
|
382
|
-
|
422
|
+
self.clean_title
|
423
|
+
self.clean_bindings
|
424
|
+
@screen.unregister self
|
383
425
|
RNDK.window_delete(@win)
|
384
426
|
end
|
385
427
|
|
386
428
|
def erase
|
387
|
-
if self.
|
429
|
+
if self.valid?
|
388
430
|
RNDK.window_erase(@win)
|
389
431
|
end
|
390
432
|
end
|
391
433
|
|
392
|
-
def object_type
|
393
|
-
:GRAPH
|
394
|
-
end
|
395
|
-
|
396
434
|
def position
|
397
435
|
super(@win)
|
398
436
|
end
|
437
|
+
|
399
438
|
end
|
400
439
|
end
|
401
440
|
|
data/lib/rndk/itemlist.rb
CHANGED
@@ -1,15 +1,40 @@
|
|
1
1
|
require 'rndk'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
class Itemlist < Widget
|
6
|
+
|
7
|
+
def initialize(screen, config={})
|
7
8
|
super()
|
8
|
-
|
9
|
-
|
9
|
+
@widget_type = :itemlist
|
10
|
+
@supported_signals += [:before_input, :after_input]
|
11
|
+
|
12
|
+
x = 0
|
13
|
+
y = 0
|
14
|
+
title = "itemlist"
|
15
|
+
label = "label"
|
16
|
+
items = []
|
17
|
+
default_item = 0
|
18
|
+
box = true
|
19
|
+
shadow = false
|
20
|
+
|
21
|
+
config.each do |key, val|
|
22
|
+
x = val if key == :x
|
23
|
+
y = val if key == :y
|
24
|
+
title = val if key == :title
|
25
|
+
label = val if key == :label
|
26
|
+
items = val if key == :items
|
27
|
+
default_item = val if key == :default_item
|
28
|
+
box = val if key == :box
|
29
|
+
shadow = val if key == :shadow
|
30
|
+
end
|
31
|
+
|
32
|
+
count = items.size
|
33
|
+
parent_width = Ncurses.getmaxx(screen.window)
|
34
|
+
parent_height = Ncurses.getmaxy(screen.window)
|
10
35
|
field_width = 0
|
11
36
|
|
12
|
-
if !self.
|
37
|
+
if !self.create_list items
|
13
38
|
self.destroy
|
14
39
|
return nil
|
15
40
|
end
|
@@ -41,9 +66,9 @@ module RNDK
|
|
41
66
|
self.updateFieldWidth
|
42
67
|
|
43
68
|
# Rejustify the x and y positions if we need to.
|
44
|
-
xtmp = [
|
45
|
-
ytmp = [
|
46
|
-
RNDK.alignxy(
|
69
|
+
xtmp = [x]
|
70
|
+
ytmp = [y]
|
71
|
+
RNDK.alignxy(screen.window, xtmp, ytmp, box_width, box_height)
|
47
72
|
xpos = xtmp[0]
|
48
73
|
ypos = ytmp[0]
|
49
74
|
|
@@ -77,8 +102,8 @@ module RNDK
|
|
77
102
|
end
|
78
103
|
|
79
104
|
# Set up the rest of the structure
|
80
|
-
@screen =
|
81
|
-
@parent =
|
105
|
+
@screen = screen
|
106
|
+
@parent = screen.window
|
82
107
|
@shadow_win = nil
|
83
108
|
@accepts_focus = true
|
84
109
|
@shadow = shadow
|
@@ -103,22 +128,22 @@ module RNDK
|
|
103
128
|
end
|
104
129
|
|
105
130
|
# Register this baby.
|
106
|
-
|
131
|
+
screen.register(@widget_type, self)
|
107
132
|
end
|
108
133
|
|
109
134
|
# This allows the user to play with the widget.
|
110
|
-
def activate(actions)
|
111
|
-
ret =
|
135
|
+
def activate(actions=[])
|
136
|
+
ret = false
|
112
137
|
|
113
138
|
# Draw the widget.
|
114
|
-
self.draw
|
115
|
-
self.
|
139
|
+
self.draw
|
140
|
+
self.draw_field(true)
|
116
141
|
|
117
142
|
if actions.nil? || actions.size == 0
|
118
143
|
input = 0
|
119
144
|
|
120
145
|
while true
|
121
|
-
input = self.getch
|
146
|
+
input = self.getch
|
122
147
|
|
123
148
|
# Inject the character into the widget.
|
124
149
|
ret = self.inject(input)
|
@@ -142,28 +167,26 @@ module RNDK
|
|
142
167
|
end
|
143
168
|
|
144
169
|
# This injects a single character into the widget.
|
145
|
-
def inject
|
146
|
-
pp_return =
|
147
|
-
ret =
|
170
|
+
def inject input
|
171
|
+
pp_return = true
|
172
|
+
ret = false
|
148
173
|
complete = false
|
149
174
|
|
150
175
|
# Set the exit type.
|
151
176
|
self.set_exit_type(0)
|
152
177
|
|
153
178
|
# Draw the widget field
|
154
|
-
self.
|
179
|
+
self.draw_field(true)
|
155
180
|
|
156
181
|
# Check if there is a pre-process function to be called.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
182
|
+
keep_going = self.run_signal_binding(:before_input, input)
|
183
|
+
|
184
|
+
if keep_going
|
161
185
|
|
162
|
-
# Should we continue?
|
163
|
-
if pp_return != 0
|
164
186
|
# Check a predefined binding.
|
165
|
-
if self.
|
166
|
-
|
187
|
+
if self.is_bound? input
|
188
|
+
self.run_key_binding input
|
189
|
+
#complete = true
|
167
190
|
else
|
168
191
|
case input
|
169
192
|
when Ncurses::KEY_UP, Ncurses::KEY_RIGHT, ' '.ord, '+'.ord, 'n'.ord
|
@@ -203,13 +226,11 @@ module RNDK
|
|
203
226
|
end
|
204
227
|
|
205
228
|
# Should we call a post-process?
|
206
|
-
if
|
207
|
-
@post_process_func.call(:ITEMLIST, self, @post_process_data, input)
|
208
|
-
end
|
229
|
+
self.run_signal_binding(:after_input) if not complete
|
209
230
|
end
|
210
231
|
|
211
232
|
if !complete
|
212
|
-
self.
|
233
|
+
self.draw_field(true)
|
213
234
|
self.set_exit_type(0)
|
214
235
|
end
|
215
236
|
|
@@ -218,20 +239,18 @@ module RNDK
|
|
218
239
|
end
|
219
240
|
|
220
241
|
# This moves the itemlist field to the given location.
|
221
|
-
def move(
|
242
|
+
def move(x, y, relative, refresh_flag)
|
222
243
|
windows = [@win, @field_win, @label_win, @shadow_win]
|
223
|
-
|
224
|
-
|
244
|
+
|
245
|
+
self.move_specific(x, y, relative, refresh_flag, windows, [])
|
225
246
|
end
|
226
247
|
|
227
248
|
# This draws the widget on the screen.
|
228
|
-
def draw
|
249
|
+
def draw
|
229
250
|
# Did we ask for a shadow?
|
230
|
-
unless @shadow_win.nil?
|
231
|
-
Draw.drawShadow(@shadow_win)
|
232
|
-
end
|
251
|
+
Draw.drawShadow(@shadow_win) unless @shadow_win.nil?
|
233
252
|
|
234
|
-
self.
|
253
|
+
self.draw_title(@win)
|
235
254
|
|
236
255
|
# Draw in the label to the widget.
|
237
256
|
unless @label_win.nil?
|
@@ -240,25 +259,23 @@ module RNDK
|
|
240
259
|
end
|
241
260
|
|
242
261
|
# Box the widget if asked.
|
243
|
-
if box
|
244
|
-
Draw.drawObjBox(@win, self)
|
245
|
-
end
|
262
|
+
Draw.drawObjBox(@win, self) if @box
|
246
263
|
|
247
264
|
Ncurses.wrefresh @win
|
248
265
|
|
249
266
|
# Draw in the field.
|
250
|
-
self.
|
267
|
+
self.draw_field(false)
|
251
268
|
end
|
252
269
|
|
253
270
|
# This sets the background attribute of the widget
|
254
|
-
def
|
271
|
+
def set_bg_color(attrib)
|
255
272
|
Ncurses.wbkgd(@win, attrib)
|
256
273
|
Ncurses.wbkgd(@field_win, attrib)
|
257
274
|
Ncurses.wbkgd(@label_win, attrib) unless @label_win.nil?
|
258
275
|
end
|
259
276
|
|
260
277
|
# This function draws the contents of the field.
|
261
|
-
def
|
278
|
+
def draw_field(highlight)
|
262
279
|
# Declare local vars.
|
263
280
|
current_item = @current_item
|
264
281
|
|
@@ -273,7 +290,7 @@ module RNDK
|
|
273
290
|
c = @item[current_item][x]
|
274
291
|
|
275
292
|
if highlight
|
276
|
-
c = c.ord |
|
293
|
+
c = c.ord | RNDK::Color[:reverse]
|
277
294
|
end
|
278
295
|
|
279
296
|
Ncurses.mvwaddch(@field_win, 0, x + @item_pos[current_item], c)
|
@@ -285,7 +302,7 @@ module RNDK
|
|
285
302
|
|
286
303
|
# This function removes the widget from the screen.
|
287
304
|
def erase
|
288
|
-
if self.
|
305
|
+
if self.valid?
|
289
306
|
RNDK.window_erase(@field_win)
|
290
307
|
RNDK.window_erase(@label_win)
|
291
308
|
RNDK.window_erase(@win)
|
@@ -300,7 +317,7 @@ module RNDK
|
|
300
317
|
|
301
318
|
# This function destroys the widget and all the memory it used.
|
302
319
|
def destroy
|
303
|
-
self.
|
320
|
+
self.clean_title
|
304
321
|
self.destroyInfo
|
305
322
|
|
306
323
|
# Delete the windows
|
@@ -310,20 +327,20 @@ module RNDK
|
|
310
327
|
RNDK.window_delete(@win)
|
311
328
|
|
312
329
|
# Clean the key bindings.
|
313
|
-
self.clean_bindings
|
330
|
+
self.clean_bindings
|
314
331
|
|
315
|
-
|
332
|
+
@screen.unregister self
|
316
333
|
end
|
317
334
|
|
318
335
|
# This sets multiple attributes of the widget.
|
319
336
|
def set(list, count, current, box)
|
320
|
-
self.
|
337
|
+
self.set_values(list, count, current)
|
321
338
|
self.set_box(box)
|
322
339
|
end
|
323
340
|
|
324
341
|
# This function sets the contents of the list
|
325
|
-
def
|
326
|
-
if self.
|
342
|
+
def set_values(item, default_item)
|
343
|
+
if self.create_list item
|
327
344
|
old_width = @field_width
|
328
345
|
|
329
346
|
# Set the default item.
|
@@ -341,7 +358,7 @@ module RNDK
|
|
341
358
|
|
342
359
|
# Draw the field.
|
343
360
|
self.erase
|
344
|
-
self.draw
|
361
|
+
self.draw
|
345
362
|
end
|
346
363
|
end
|
347
364
|
|
@@ -379,14 +396,16 @@ module RNDK
|
|
379
396
|
end
|
380
397
|
|
381
398
|
def focus
|
382
|
-
self.
|
399
|
+
self.draw_field(true)
|
383
400
|
end
|
384
401
|
|
385
402
|
def unfocus
|
386
|
-
self.
|
403
|
+
self.draw_field(false)
|
387
404
|
end
|
388
405
|
|
389
|
-
def
|
406
|
+
def create_list item
|
407
|
+
count = item.size
|
408
|
+
|
390
409
|
status = false
|
391
410
|
new_items = []
|
392
411
|
new_pos = []
|
@@ -467,8 +486,7 @@ module RNDK
|
|
467
486
|
super(@win)
|
468
487
|
end
|
469
488
|
|
470
|
-
|
471
|
-
|
472
|
-
end
|
489
|
+
|
490
|
+
|
473
491
|
end
|
474
492
|
end
|