rndk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/README.md +61 -42
- data/demos/appointment.rb +2 -2
- data/demos/clock.rb +1 -1
- data/demos/fileview.rb +0 -0
- data/examples/01-hello-world.rb +1 -1
- data/examples/02-colors.rb +1 -1
- data/examples/03-markup.rb +6 -4
- data/examples/04-quick-widgets.rb +1 -0
- data/examples/05-position-widget.rb +1 -1
- data/examples/entry.rb +76 -0
- data/examples/label.rb +51 -0
- data/examples/scroll.rb +68 -42
- data/examples/slider.rb +70 -0
- data/lib/rndk/alphalist.rb +224 -116
- data/lib/rndk/button.rb +4 -2
- data/lib/rndk/buttonbox.rb +1 -1
- data/lib/rndk/calendar.rb +18 -23
- data/lib/rndk/core/draw.rb +0 -30
- data/lib/rndk/core/quick_widgets.rb +9 -10
- data/lib/rndk/core/utils.rb +6 -6
- data/lib/rndk/core/widget.rb +9 -1
- data/lib/rndk/dialog.rb +1 -6
- data/lib/rndk/dscale.rb +1 -1
- data/lib/rndk/entry.rb +266 -116
- data/lib/rndk/fscale.rb +1 -1
- data/lib/rndk/fselect.rb +13 -15
- data/lib/rndk/fslider.rb +1 -1
- data/lib/rndk/graph.rb +1 -1
- data/lib/rndk/histogram.rb +1 -1
- data/lib/rndk/itemlist.rb +1 -1
- data/lib/rndk/label.rb +7 -6
- data/lib/rndk/marquee.rb +1 -1
- data/lib/rndk/matrix.rb +1 -1
- data/lib/rndk/mentry.rb +8 -8
- data/lib/rndk/menu.rb +1 -1
- data/lib/rndk/radio.rb +1 -1
- data/lib/rndk/scale.rb +1 -1
- data/lib/rndk/scroll.rb +138 -55
- data/lib/rndk/scroller.rb +9 -1
- data/lib/rndk/selection.rb +1 -1
- data/lib/rndk/slider.rb +123 -42
- data/lib/rndk/swindow.rb +10 -10
- data/lib/rndk/template.rb +1 -1
- data/lib/rndk/uscale.rb +1 -1
- data/lib/rndk/uslider.rb +1 -1
- data/lib/rndk/version.rb +1 -1
- data/lib/rndk/viewer.rb +3 -3
- data/rndk.gemspec +1 -1
- metadata +7 -3
data/lib/rndk/calendar.rb
CHANGED
@@ -24,19 +24,19 @@ module RNDK
|
|
24
24
|
# Enter:: Exits the widget and returns a value of
|
25
25
|
# time_t which represents the day
|
26
26
|
# selected at 1 second after midnight.
|
27
|
-
# This also sets the widget data
|
28
|
-
# to
|
27
|
+
# This also sets the widget data `exit_type`
|
28
|
+
# to `:NORMAL`.
|
29
29
|
# Tab:: Exits the widget and returns a value of
|
30
30
|
# time_t which represents the day
|
31
31
|
# selected at 1 second after midnight.
|
32
|
-
# This also sets the widget data
|
33
|
-
# to
|
34
|
-
# Escape:: Exits the widget and returns
|
35
|
-
# This also sets the widget data
|
36
|
-
# to
|
32
|
+
# This also sets the widget data `exit_type`
|
33
|
+
# to `:NORMAL`.
|
34
|
+
# Escape:: Exits the widget and returns selected date
|
35
|
+
# This also sets the widget data `exit_type`
|
36
|
+
# to `:ESCAPE_HIT`.
|
37
37
|
# Ctrl-L:: Refreshes the screen.
|
38
38
|
#
|
39
|
-
class Calendar <
|
39
|
+
class Calendar < Widget
|
40
40
|
|
41
41
|
attr_reader :day, :month, :year
|
42
42
|
|
@@ -117,6 +117,10 @@ module RNDK
|
|
117
117
|
|
118
118
|
# Creates a Calendar Widget.
|
119
119
|
#
|
120
|
+
# * `xplace` is the x position - can be an integer or
|
121
|
+
# `RNDK::LEFT`, `RNDK::RIGHT`, `RNDK::CENTER`.
|
122
|
+
# * `yplace` is the y position - can be an integer or
|
123
|
+
# `RNDK::TOP`, `RNDK::BOTTOM`, `RNDK::CENTER`.
|
120
124
|
# * `day`, `month` and `year` are integers. I suggest
|
121
125
|
# you to use Ruby's `Time.now.gmtime`.
|
122
126
|
# * `title` can be more than one line - just split them
|
@@ -274,7 +278,7 @@ module RNDK
|
|
274
278
|
@marker[Calendar.calendar_index(d, m, y)]
|
275
279
|
end
|
276
280
|
|
277
|
-
# Activates the
|
281
|
+
# Activates the Widget, letting the user interact with it.
|
278
282
|
#
|
279
283
|
# `actions` is an Array of characters. If it's non-null,
|
280
284
|
# will #inject each char on it into the Widget.
|
@@ -306,14 +310,7 @@ module RNDK
|
|
306
310
|
ret
|
307
311
|
end
|
308
312
|
|
309
|
-
#
|
310
|
-
# had pressed it.
|
311
|
-
#
|
312
|
-
# Nice to simulate batch actions on a Widget.
|
313
|
-
#
|
314
|
-
# Besides normal keybindings (arrow keys and such), see
|
315
|
-
# Widget#set_exit_type to see how the Widget exits.
|
316
|
-
#
|
313
|
+
# @see Widget#inject
|
317
314
|
def inject char
|
318
315
|
pp_return = 1
|
319
316
|
ret = nil
|
@@ -386,14 +383,14 @@ module RNDK
|
|
386
383
|
return ret
|
387
384
|
end
|
388
385
|
|
389
|
-
#
|
386
|
+
# @see Widget#move
|
390
387
|
def move(xplace, yplace, relative, refresh_flag)
|
391
388
|
windows = [@win, @field_win, @label_win, @shadow_win]
|
392
389
|
|
393
390
|
self.move_specific(xplace, yplace, relative, refresh_flag, windows, [])
|
394
391
|
end
|
395
392
|
|
396
|
-
# Draws the
|
393
|
+
# Draws the Widget on the Screen.
|
397
394
|
#
|
398
395
|
# If `box` is true, it is drawn with a box.
|
399
396
|
def draw(box=false)
|
@@ -568,8 +565,7 @@ module RNDK
|
|
568
565
|
Ncurses.wbkgd(@label_win, attrib) unless @label_win.nil?
|
569
566
|
end
|
570
567
|
|
571
|
-
#
|
572
|
-
# @note It does not destroy the widget.
|
568
|
+
# @see Widget#erase
|
573
569
|
def erase
|
574
570
|
return unless self.valid_widget?
|
575
571
|
|
@@ -579,8 +575,7 @@ module RNDK
|
|
579
575
|
RNDK.window_erase @shadow_win
|
580
576
|
end
|
581
577
|
|
582
|
-
#
|
583
|
-
# removes it from the Screen.
|
578
|
+
# @see Widget#destroy
|
584
579
|
def destroy
|
585
580
|
self.cleanTitle
|
586
581
|
|
data/lib/rndk/core/draw.rb
CHANGED
@@ -2,36 +2,6 @@
|
|
2
2
|
module RNDK
|
3
3
|
|
4
4
|
module Draw
|
5
|
-
# # This sets up a basic set of color pairs.
|
6
|
-
# # These can be redefined if wanted
|
7
|
-
# def Draw.initRNDKColor
|
8
|
-
# color = [Ncurses::COLOR_WHITE,
|
9
|
-
# Ncurses::COLOR_RED,
|
10
|
-
# Ncurses::COLOR_GREEN,
|
11
|
-
# Ncurses::COLOR_YELLOW,
|
12
|
-
# Ncurses::COLOR_BLUE,
|
13
|
-
# Ncurses::COLOR_MAGENTA,
|
14
|
-
# Ncurses::COLOR_CYAN,
|
15
|
-
# Ncurses::COLOR_BLACK]
|
16
|
-
# pair = 1
|
17
|
-
|
18
|
-
# if Ncurses.has_colors
|
19
|
-
# # XXX: Only checks if terminal has colours not if colours are started
|
20
|
-
# Ncurses.start_color
|
21
|
-
# limit = if Ncurses.COLORS < 8
|
22
|
-
# then Ncurses.COLORS
|
23
|
-
# else 8
|
24
|
-
# end
|
25
|
-
|
26
|
-
# # Create the color pairs
|
27
|
-
# (0...limit).each do |fg|
|
28
|
-
# (0...limit).each do |bg|
|
29
|
-
# Ncurses.init_pair(pair, color[fg], color[bg])
|
30
|
-
# pair += 1
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
# end
|
35
5
|
|
36
6
|
# This prints out a box around a window with attributes
|
37
7
|
def Draw.boxWindow(window, attr)
|
@@ -49,7 +49,7 @@ module RNDK
|
|
49
49
|
return if message.class != Array or message.empty?
|
50
50
|
|
51
51
|
self.cleanly do
|
52
|
-
popup = RNDK::
|
52
|
+
popup = RNDK::Label.new(self, CENTER, CENTER, message, true, false)
|
53
53
|
popup.draw(true)
|
54
54
|
|
55
55
|
# Wait for some input.
|
@@ -67,7 +67,7 @@ module RNDK
|
|
67
67
|
return if message.class != Array or message.empty?
|
68
68
|
|
69
69
|
self.cleanly do
|
70
|
-
popup = RNDK::
|
70
|
+
popup = RNDK::Label.new(self, CENTER, CENTER, message, true, false)
|
71
71
|
popup.setBackgroundAttrib attrib
|
72
72
|
popup.draw(true)
|
73
73
|
|
@@ -254,15 +254,14 @@ module RNDK
|
|
254
254
|
width = [width, title.size].max
|
255
255
|
width += 5
|
256
256
|
|
257
|
-
scrollp = RNDK::
|
257
|
+
scrollp = RNDK::Scroll.new(self,
|
258
258
|
RNDK::CENTER,
|
259
259
|
RNDK::CENTER,
|
260
260
|
RNDK::RIGHT,
|
261
|
-
height,
|
262
261
|
width,
|
262
|
+
height,
|
263
263
|
title,
|
264
264
|
list,
|
265
|
-
list.size,
|
266
265
|
numbers,
|
267
266
|
Ncurses::A_REVERSE,
|
268
267
|
true,
|
@@ -288,10 +287,10 @@ module RNDK
|
|
288
287
|
# Pops up an Entry Widget and returns the value supplied
|
289
288
|
# by the user.
|
290
289
|
#
|
291
|
-
# `title`, `label` and `
|
292
|
-
def get_string(title, label,
|
290
|
+
# `title`, `label` and `initial_text` are passed to the Widget.
|
291
|
+
def get_string(title, label, initial_text="")
|
293
292
|
|
294
|
-
widget = RNDK::
|
293
|
+
widget = RNDK::Entry.new(self,
|
295
294
|
RNDK::CENTER,
|
296
295
|
RNDK::CENTER,
|
297
296
|
title,
|
@@ -305,7 +304,7 @@ module RNDK
|
|
305
304
|
true,
|
306
305
|
false)
|
307
306
|
|
308
|
-
widget.
|
307
|
+
widget.set_text(initial_text)
|
309
308
|
|
310
309
|
value = widget.activate([])
|
311
310
|
|
@@ -316,7 +315,7 @@ module RNDK
|
|
316
315
|
end
|
317
316
|
|
318
317
|
# Return a copy of the string typed in.
|
319
|
-
value = widget.
|
318
|
+
value = widget.get_text.clone
|
320
319
|
widget.destroy
|
321
320
|
|
322
321
|
value
|
data/lib/rndk/core/utils.rb
CHANGED
@@ -7,17 +7,17 @@ module RNDK
|
|
7
7
|
value.to_str.size
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
10
|
+
# Returns all files from `directory` as
|
11
|
+
# an Array of Strings.
|
12
|
+
def RNDK.get_directory_contents directory
|
13
|
+
list = []
|
13
14
|
|
14
15
|
Dir.foreach(directory) do |filename|
|
15
|
-
next if filename == '.'
|
16
|
+
next if filename == '.' or filename == '..'
|
16
17
|
list << filename
|
17
18
|
end
|
18
19
|
|
19
|
-
list.sort
|
20
|
-
return list.size
|
20
|
+
list.sort
|
21
21
|
end
|
22
22
|
|
23
23
|
# This looks for a subset of a word in the given list
|
data/lib/rndk/core/widget.rb
CHANGED
@@ -57,6 +57,8 @@ module RNDK
|
|
57
57
|
def draw(a)
|
58
58
|
end
|
59
59
|
|
60
|
+
# Erases the Widget from the Screen.
|
61
|
+
# @note It does not destroy the Widget.
|
60
62
|
def erase
|
61
63
|
end
|
62
64
|
|
@@ -136,6 +138,10 @@ module RNDK
|
|
136
138
|
# had pressed it.
|
137
139
|
#
|
138
140
|
# Nice to simulate batch actions on a Widget.
|
141
|
+
#
|
142
|
+
# Besides normal keybindings (arrow keys and such), see
|
143
|
+
# Widget#set_exit_type to see how the Widget exits.
|
144
|
+
#
|
139
145
|
def inject char
|
140
146
|
end
|
141
147
|
|
@@ -160,6 +166,8 @@ module RNDK
|
|
160
166
|
def refreshData
|
161
167
|
end
|
162
168
|
|
169
|
+
# Destroys all windows inside the Widget and
|
170
|
+
# removes it from the Screen.
|
163
171
|
def destroy
|
164
172
|
end
|
165
173
|
|
@@ -315,7 +323,7 @@ module RNDK
|
|
315
323
|
def bindableObject(rndktype)
|
316
324
|
if rndktype != self.object_type
|
317
325
|
return nil
|
318
|
-
elsif [:FSELECT, :
|
326
|
+
elsif [:FSELECT, :alphalist].include?(self.object_type)
|
319
327
|
return @entry_field
|
320
328
|
else
|
321
329
|
return self
|
data/lib/rndk/dialog.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rndk'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
class DIALOG <
|
4
|
+
class DIALOG < Widget
|
5
5
|
attr_reader :current_button
|
6
6
|
MIN_DIALOG_WIDTH = 10
|
7
7
|
|
@@ -220,11 +220,6 @@ module RNDK
|
|
220
220
|
return ret
|
221
221
|
end
|
222
222
|
|
223
|
-
# This moves the dialog field to the given location.
|
224
|
-
# Inherited
|
225
|
-
# def move(xplace, yplace, relative, refresh_flag)
|
226
|
-
# end
|
227
|
-
|
228
223
|
# This function draws the dialog widget.
|
229
224
|
def draw(box)
|
230
225
|
# Is there a shadow?
|
data/lib/rndk/dscale.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rndk/fscale'
|
2
2
|
|
3
3
|
module RNDK
|
4
|
-
class DSCALE <
|
4
|
+
class DSCALE < FSCALE
|
5
5
|
# The original DScale handled unsigned values.
|
6
6
|
# Since Ruby's typing is different this is really just FSCALE
|
7
7
|
# but is nice it's nice to have this for compatibility/completeness
|