rndk 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.yardopts +1 -0
  4. data/README.md +61 -42
  5. data/demos/appointment.rb +2 -2
  6. data/demos/clock.rb +1 -1
  7. data/demos/fileview.rb +0 -0
  8. data/examples/01-hello-world.rb +1 -1
  9. data/examples/02-colors.rb +1 -1
  10. data/examples/03-markup.rb +6 -4
  11. data/examples/04-quick-widgets.rb +1 -0
  12. data/examples/05-position-widget.rb +1 -1
  13. data/examples/entry.rb +76 -0
  14. data/examples/label.rb +51 -0
  15. data/examples/scroll.rb +68 -42
  16. data/examples/slider.rb +70 -0
  17. data/lib/rndk/alphalist.rb +224 -116
  18. data/lib/rndk/button.rb +4 -2
  19. data/lib/rndk/buttonbox.rb +1 -1
  20. data/lib/rndk/calendar.rb +18 -23
  21. data/lib/rndk/core/draw.rb +0 -30
  22. data/lib/rndk/core/quick_widgets.rb +9 -10
  23. data/lib/rndk/core/utils.rb +6 -6
  24. data/lib/rndk/core/widget.rb +9 -1
  25. data/lib/rndk/dialog.rb +1 -6
  26. data/lib/rndk/dscale.rb +1 -1
  27. data/lib/rndk/entry.rb +266 -116
  28. data/lib/rndk/fscale.rb +1 -1
  29. data/lib/rndk/fselect.rb +13 -15
  30. data/lib/rndk/fslider.rb +1 -1
  31. data/lib/rndk/graph.rb +1 -1
  32. data/lib/rndk/histogram.rb +1 -1
  33. data/lib/rndk/itemlist.rb +1 -1
  34. data/lib/rndk/label.rb +7 -6
  35. data/lib/rndk/marquee.rb +1 -1
  36. data/lib/rndk/matrix.rb +1 -1
  37. data/lib/rndk/mentry.rb +8 -8
  38. data/lib/rndk/menu.rb +1 -1
  39. data/lib/rndk/radio.rb +1 -1
  40. data/lib/rndk/scale.rb +1 -1
  41. data/lib/rndk/scroll.rb +138 -55
  42. data/lib/rndk/scroller.rb +9 -1
  43. data/lib/rndk/selection.rb +1 -1
  44. data/lib/rndk/slider.rb +123 -42
  45. data/lib/rndk/swindow.rb +10 -10
  46. data/lib/rndk/template.rb +1 -1
  47. data/lib/rndk/uscale.rb +1 -1
  48. data/lib/rndk/uslider.rb +1 -1
  49. data/lib/rndk/version.rb +1 -1
  50. data/lib/rndk/viewer.rb +3 -3
  51. data/rndk.gemspec +1 -1
  52. metadata +7 -3
@@ -1,28 +1,100 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class ALPHALIST < RNDK::Widget
4
+
5
+ # Allows user to select from a list of alphabetically sorted words.
6
+ #
7
+ # Use the arrow keys to navigate on the list or type in the
8
+ # beginning of the word and it'll automagically adjust
9
+ # itself in the correct place.
10
+ #
11
+ # ## Keybindings
12
+ #
13
+ # Since Alphalist is built from both the Scroll and Entry Widgets,
14
+ # the key bindings are the same for the respective fields.
15
+ #
16
+ # Extra key bindings are listed below:
17
+ #
18
+ # Up Arrow:: Scrolls the scrolling list up one line.
19
+ # Down Arrow:: Scrolls the scrolling list down one line.
20
+ # Page Up:: Scrolls the scrolling list up one page.
21
+ # CTRL-B:: Scrolls the scrolling list up one page.
22
+ # Page Down:: Scrolls the scrolling list down one page.
23
+ # CTRL-F:: Scrolls the scrolling list down one page.
24
+ # Tab:: Tries to complete the word in the entry field.
25
+ # If the word segment is not unique then the widget
26
+ # will beep and present a list of close matches.
27
+ # Return:: Returns the word in the entry field.
28
+ # It also sets the widget data exitType to `:NORMAL`.
29
+ # Escape:: Exits the widget and returns `nil`.
30
+ # It also sets the widget data exitType to `:ESCAPE_HIT`.
31
+ #
32
+ # ## Developer notes
33
+ #
34
+ # This widget, like the file selector widget, is a compound widget
35
+ # of both the entry field widget and the scrolling list widget - sorted.
36
+ #
37
+ class Alphalist < Widget
5
38
  attr_reader :scroll_field, :entry_field, :list
6
39
 
7
- def initialize(rndkscreen, xplace, yplace, height, width, title, label,
8
- list, list_size, filler_char, highlight, box, shadow)
40
+ # Creates an Alphalist Widget.
41
+ #
42
+ # * `xplace` is the x position - can be an integer or `RNDK::LEFT`,
43
+ # `RNDK::RIGHT`, `RNDK::CENTER`.
44
+ # * `yplace` is the y position - can be an integer or `RNDK::TOP`,
45
+ # `RNDK::BOTTOM`, `RNDK::CENTER`.
46
+ # * `width`/`height` are integers - if either are 0, Widget
47
+ # will be created with full width/height of the screen.
48
+ # If it's a negative value, will create with full width/height
49
+ # minus the value.
50
+ # * `message` is an Array of Strings with all the lines you'd want
51
+ # to show. RNDK markup applies (see RNDK#Markup).
52
+ # * `title` can be more than one line - just split them
53
+ # with `\n`s.
54
+ # * `label` is the String that will appear on the label
55
+ # of the Entry field.
56
+ # * `list` is an Array of Strings with the content to
57
+ # display.
58
+ # * `filler_char` is the character to display on the
59
+ # empty spaces in the Entry field.
60
+ # * `highlight` is the attribute/color of the current
61
+ # item.
62
+ # * `box` if the Widget is drawn with a box outside it.
63
+ # * `shadow` turns on/off the shadow around the Widget.
64
+ #
65
+ def initialize(rndkscreen,
66
+ xplace,
67
+ yplace,
68
+ width,
69
+ height,
70
+ title,
71
+ label,
72
+ list,
73
+ filler_char,
74
+ highlight,
75
+ box,
76
+ shadow)
9
77
  super()
10
- parent_width = Ncurses.getmaxx(rndkscreen.window)
11
- parent_height = Ncurses.getmaxy(rndkscreen.window)
12
- box_width = width
78
+
79
+ parent_width = Ncurses.getmaxx rndkscreen.window
80
+ parent_height = Ncurses.getmaxy rndkscreen.window
81
+
82
+ box_width = width
13
83
  box_height = height
84
+
14
85
  label_len = 0
86
+
15
87
  bindings = {
16
88
  RNDK::BACKCHAR => Ncurses::KEY_PPAGE,
17
89
  RNDK::FORCHAR => Ncurses::KEY_NPAGE,
18
90
  }
19
91
 
20
- if !self.createList(list, list_size)
92
+ if not self.createList list
21
93
  self.destroy
22
94
  return nil
23
95
  end
24
96
 
25
- self.set_box(box)
97
+ self.set_box box
26
98
 
27
99
  # If the height is a negative value, the height will be ROWS-height,
28
100
  # otherwise the height will be the given height.
@@ -55,54 +127,66 @@ module RNDK
55
127
  end
56
128
  Ncurses.keypad(@win, true)
57
129
 
58
- # Set some variables.
59
130
  @screen = rndkscreen
60
131
  @parent = rndkscreen.window
61
- @highlight = highlight
132
+ @highlight = highlight
62
133
  @filler_char = filler_char
134
+
135
+ @box_width = box_width
63
136
  @box_height = box_height
64
- @box_width = box_width
137
+
65
138
  @shadow = shadow
66
139
  @shadow_win = nil
67
140
 
68
141
  # Do we want a shadow?
69
142
  if shadow
70
- @shadow_win = Ncurses.newwin(box_height, box_width,
71
- ypos + 1, xpos + 1)
143
+ @shadow_win = Ncurses.newwin(box_height, box_width, ypos+1, xpos+1)
72
144
  end
73
145
 
74
146
  # Create the entry field.
75
- temp_width = if RNDK::ALPHALIST.isFullWidth(width)
147
+ temp_width = if Alphalist.isFullWidth(width)
76
148
  then RNDK::FULL
77
149
  else box_width - 2 - label_len
78
150
  end
79
- @entry_field = RNDK::ENTRY.new(rndkscreen, Ncurses.getbegx(@win), Ncurses.getbegy(@win),
80
- title, label, Ncurses::A_NORMAL, filler_char, :MIXED, temp_width,
81
- 0, 512, box, false)
151
+
152
+ @entry_field = RNDK::Entry.new(rndkscreen,
153
+ Ncurses.getbegx(@win),
154
+ Ncurses.getbegy(@win),
155
+ title,
156
+ label,
157
+ Ncurses::A_NORMAL,
158
+ filler_char,
159
+ :MIXED,
160
+ temp_width,
161
+ 0,
162
+ 512,
163
+ box,
164
+ false)
82
165
  if @entry_field.nil?
83
166
  self.destroy
84
167
  return nil
85
168
  end
86
- @entry_field.setLLchar(Ncurses::ACS_LTEE)
87
- @entry_field.setLRchar(Ncurses::ACS_RTEE)
169
+ @entry_field.setLLchar Ncurses::ACS_LTEE
170
+ @entry_field.setLRchar Ncurses::ACS_RTEE
88
171
 
89
172
  # Callback functions
90
173
  adjust_alphalist_cb = lambda do |object_type, object, alphalist, key|
91
174
  scrollp = alphalist.scroll_field
92
- entry = alphalist.entry_field
175
+ entry = alphalist.entry_field
93
176
 
94
177
  if scrollp.list_size > 0
95
178
  # Adjust the scrolling list.
96
179
  alphalist.injectMyScroller(key)
97
180
 
98
181
  # Set the value in the entry field.
99
- current = RNDK.chtype2Char(scrollp.item[scrollp.current_item])
100
- entry.setValue(current)
101
- entry.draw(entry.box)
182
+ current = RNDK.chtype2Char scrollp.item[scrollp.current_item]
183
+ entry.setValue current
184
+ entry.draw entry.box
102
185
  return true
103
186
  end
187
+
104
188
  RNDK.beep
105
- return false
189
+ false
106
190
  end
107
191
 
108
192
  complete_word_cb = lambda do |object_type, object, alphalist, key|
@@ -128,12 +212,11 @@ module RNDK
128
212
 
129
213
  # Did we find the last word in the list?
130
214
  if index == alphalist.list.size - 1
131
- entry.setValue(alphalist.list[index])
132
- entry.draw(entry.box)
215
+ entry.setValue alphalist.list[index]
216
+ entry.draw entry.box
133
217
  return true
134
218
  end
135
219
 
136
-
137
220
  # Ok, we found a match, is the next item similar?
138
221
  len = [entry.info.size, alphalist.list[index + 1].size].min
139
222
  ret = alphalist.list[index + 1][0...len] <=> entry.info
@@ -144,8 +227,8 @@ module RNDK
144
227
 
145
228
  # Start looking for alternate words
146
229
  # FIXME(original): bsearch would be more suitable.
147
- while current_index < alphalist.list.size &&
148
- (alphalist.list[current_index][0...len] <=> entry.info) == 0
230
+ while (current_index < alphalist.list.size) and
231
+ ((alphalist.list[current_index][0...len] <=> entry.info) == 0)
149
232
  alt_words << alphalist.list[current_index]
150
233
  current_index += 1
151
234
  end
@@ -154,13 +237,21 @@ module RNDK
154
237
  height = if alt_words.size < 8 then alt_words.size + 3 else 11 end
155
238
 
156
239
  # Create a scrolling list of close matches.
157
- scrollp = RNDK::SCROLL.new(entry.screen,
158
- RNDK::CENTER, RNDK::CENTER, RNDK::RIGHT, height, -30,
159
- "<C></B/5>Possible Matches.", alt_words, alt_words.size,
160
- true, Ncurses::A_REVERSE, true, false)
240
+ scrollp = RNDK::Scroll.new(entry.screen,
241
+ RNDK::CENTER,
242
+ RNDK::CENTER,
243
+ RNDK::RIGHT,
244
+ height,
245
+ -30,
246
+ "<C></B/5>Possible Matches.",
247
+ alt_words,
248
+ true,
249
+ Ncurses::A_REVERSE,
250
+ true,
251
+ false)
161
252
 
162
253
  # Allow them to select a close match.
163
- match = scrollp.activate([])
254
+ match = scrollp.activate
164
255
  selected = scrollp.current_item
165
256
 
166
257
  # Check how they exited the list.
@@ -168,7 +259,6 @@ module RNDK
168
259
  # Destroy the scrolling list.
169
260
  scrollp.destroy
170
261
 
171
- # beep at the user.
172
262
  RNDK.beep
173
263
 
174
264
  # Redraw the alphalist and return.
@@ -188,13 +278,14 @@ module RNDK
188
278
  end
189
279
 
190
280
  # Redraw the alphalist.
191
- alphalist.draw(alphalist.box)
281
+ alphalist.draw alphalist.box
282
+
192
283
  else
193
284
  # Set the entry field with the found item.
194
285
  entry.set(alphalist.list[index], entry.min, entry.max, entry.box)
195
- entry.draw(entry.box)
286
+ entry.draw entry.box
196
287
  end
197
- return true
288
+ true
198
289
  end
199
290
 
200
291
  pre_process_entry_field = lambda do |rndktype, object, alphalist, input|
@@ -204,34 +295,40 @@ module RNDK
204
295
  result = 1
205
296
  empty = false
206
297
 
207
- if alphalist.isBind(:ALPHALIST, input)
298
+ if alphalist.isBind(:alphalist, input)
208
299
  result = 1 # Don't try to use this key in editing
300
+
209
301
  elsif (RNDK.is_char?(input) &&
210
302
  input.chr.match(/^[[:alnum:][:punct:]]$/)) ||
211
303
  [Ncurses::KEY_BACKSPACE, Ncurses::KEY_DC].include?(input)
304
+
212
305
  index = 0
213
306
  curr_pos = entry.screen_col + entry.left_char
214
307
  pattern = entry.info.clone
215
- if [Ncurses::KEY_BACKSPACE, Ncurses::KEY_DC].include?(input)
216
- if input == Ncurses::KEY_BACKSPACE
217
- curr_pos -= 1
218
- end
219
- if curr_pos >= 0
220
- pattern.slice!(curr_pos)
221
- end
308
+
309
+ if [Ncurses::KEY_BACKSPACE, Ncurses::KEY_DC].include? input
310
+
311
+ curr_pos -= 1 if input == Ncurses::KEY_BACKSPACE
312
+
313
+ pattern.slice!(curr_pos) if curr_pos >= 0
314
+
222
315
  else
223
- front = (pattern[0...curr_pos] or '')
224
- back = (pattern[curr_pos..-1] or '')
316
+ front = (pattern[0...curr_pos] or '')
317
+ back = (pattern[curr_pos..-1] or '')
225
318
  pattern = front + input.chr + back
226
319
  end
227
320
 
228
321
  if pattern.size == 0
229
322
  empty = true
323
+
230
324
  elsif (index = RNDK.searchList(alphalist.list,
231
- alphalist.list.size, pattern)) >= 0
325
+ alphalist.list.size,
326
+ pattern)) >= 0
327
+
232
328
  # XXX: original uses n scroll downs/ups for <10 positions change
233
329
  scrollp.setPosition(index)
234
330
  alphalist.drawMyScroller
331
+
235
332
  else
236
333
  RNDK.beep
237
334
  result = 0
@@ -243,15 +340,15 @@ module RNDK
243
340
  alphalist.drawMyScroller
244
341
  end
245
342
 
246
- return result
343
+ result
247
344
  end
248
345
 
249
346
  # Set the key bindings for the entry field.
250
- @entry_field.bind(:ENTRY, Ncurses::KEY_UP, adjust_alphalist_cb, self)
251
- @entry_field.bind(:ENTRY, Ncurses::KEY_DOWN, adjust_alphalist_cb, self)
252
- @entry_field.bind(:ENTRY, Ncurses::KEY_NPAGE, adjust_alphalist_cb, self)
253
- @entry_field.bind(:ENTRY, Ncurses::KEY_PPAGE, adjust_alphalist_cb, self)
254
- @entry_field.bind(:ENTRY, RNDK::KEY_TAB, complete_word_cb, self)
347
+ @entry_field.bind(:entry, Ncurses::KEY_UP, adjust_alphalist_cb, self)
348
+ @entry_field.bind(:entry, Ncurses::KEY_DOWN, adjust_alphalist_cb, self)
349
+ @entry_field.bind(:entry, Ncurses::KEY_NPAGE, adjust_alphalist_cb, self)
350
+ @entry_field.bind(:entry, Ncurses::KEY_PPAGE, adjust_alphalist_cb, self)
351
+ @entry_field.bind(:entry, RNDK::KEY_TAB, complete_word_cb, self)
255
352
 
256
353
  # Set up the post-process function for the entry field.
257
354
  @entry_field.setPreProcess(pre_process_entry_field, self)
@@ -259,12 +356,12 @@ module RNDK
259
356
  # Create the scrolling list. It overlaps the entry field by one line if
260
357
  # we are using box-borders.
261
358
  temp_height = Ncurses.getmaxy(@entry_field.win) - @border_size
262
- temp_width = if RNDK::ALPHALIST.isFullWidth(width)
359
+ temp_width = if Alphalist.isFullWidth(width)
263
360
  then RNDK::FULL
264
361
  else box_width - 1
265
362
  end
266
363
 
267
- @scroll_field = RNDK::SCROLL.new(rndkscreen,
364
+ @scroll_field = RNDK::Scroll.new(rndkscreen,
268
365
  Ncurses.getbegx(@win),
269
366
  Ncurses.getbegy(@entry_field.win) + temp_height,
270
367
  RNDK::RIGHT,
@@ -272,23 +369,23 @@ module RNDK
272
369
  temp_width,
273
370
  '',
274
371
  list,
275
- list_size,
276
372
  false,
277
- Ncurses::A_REVERSE,
373
+ Ncurses::A_REVERSE,
278
374
  box,
279
375
  false)
280
- @scroll_field.setULchar(Ncurses::ACS_LTEE)
281
- @scroll_field.setURchar(Ncurses::ACS_RTEE)
376
+
377
+ @scroll_field.setULchar Ncurses::ACS_LTEE
378
+ @scroll_field.setURchar Ncurses::ACS_RTEE
282
379
 
283
380
  # Setup the key bindings.
284
381
  bindings.each do |from, to|
285
- self.bind(:ALPHALIST, from, :getc, to)
382
+ self.bind(:alphalist, from, :getc, to)
286
383
  end
287
384
 
288
- rndkscreen.register(:ALPHALIST, self)
385
+ rndkscreen.register(:alphalist, self)
289
386
  end
290
387
 
291
- # This erases the alphalist from the screen.
388
+ # @see Widget#erase
292
389
  def erase
293
390
  if self.valid_widget?
294
391
  @scroll_field.erase
@@ -299,12 +396,11 @@ module RNDK
299
396
  end
300
397
  end
301
398
 
302
- # This moves the alphalist field to the given location.
399
+ # @see Widget#move
303
400
  def move(xplace, yplace, relative, refresh_flag)
304
401
  windows = [@win, @shadow_win]
305
402
  subwidgets = [@entry_field, @scroll_field]
306
- self.move_specific(xplace, yplace, relative, refresh_flag,
307
- windows, subwidgets)
403
+ self.move_specific(xplace, yplace, relative, refresh_flag, windows, subwidgets)
308
404
  end
309
405
 
310
406
  # The alphalist's focus resides in the entry widget. But the scroll widget
@@ -332,29 +428,37 @@ module RNDK
332
428
  self.restoreFocus
333
429
  end
334
430
 
335
- # This draws the alphalist widget.
336
- def draw(box)
337
- # Does this widget have a shadow?
338
- unless @shadow_win.nil?
339
- Draw.drawShadow(@shadow_win)
340
- end
431
+ # Draws the Widget on the Screen.
432
+ #
433
+ # If `box` is true, it is drawn with a box.
434
+ def draw box
435
+ Draw.drawShadow @shadow_win unless @shadow_win.nil?
341
436
 
342
437
  # Draw in the entry field.
343
- @entry_field.draw(@entry_field.box)
438
+ @entry_field.draw @entry_field.box
344
439
 
345
440
  # Draw in the scroll field.
346
441
  self.drawMyScroller
347
442
  end
348
443
 
349
- # This activates the alphalist
350
- def activate(actions)
444
+ # Activates the Alphalist Widget, letting the user interact with it.
445
+ #
446
+ # `actions` is an Array of characters. If it's non-null,
447
+ # will #inject each char on it into the Widget.
448
+ #
449
+ # See Alphalist for keybindings.
450
+ #
451
+ # @return The text currently inside the entry field (and
452
+ # `exit_type` will be `:NORMAL`) or `nil` (and
453
+ # `exit_type` will be `:ESCAPE_HIT`).
454
+ def activate(actions=[])
351
455
  ret = 0
352
456
 
353
457
  # Draw the widget.
354
458
  self.draw(@box)
355
459
 
356
460
  # Activate the widget.
357
- ret = @entry_field.activate(actions)
461
+ ret = @entry_field.activate actions
358
462
 
359
463
  # Copy the exit type from the entry field.
360
464
  @exit_type = @entry_field.exit_type
@@ -366,80 +470,84 @@ module RNDK
366
470
  return 0
367
471
  end
368
472
 
369
- # This injects a single character into the alphalist.
370
- def inject(input)
473
+ # Makes the Alphalist react to `char` just as if the user
474
+ # had pressed it.
475
+ #
476
+ # Nice to simulate batch actions on a Widget.
477
+ #
478
+ # Besides normal keybindings (arrow keys and such), see
479
+ # Widget#set_exit_type to see how the Widget exits.
480
+ #
481
+ def inject char
371
482
  ret = -1
372
483
 
373
- # Draw the widget.
374
- self.draw(@box)
484
+ self.draw @box
375
485
 
376
486
  # Inject a character into the widget.
377
- ret = @entry_field.inject(input)
487
+ ret = @entry_field.inject char
378
488
 
379
489
  # Copy the eixt type from the entry field.
380
490
  @exit_type = @entry_field.exit_type
381
491
 
382
492
  # Determine the exit status.
383
- if @exit_type == :EARLY_EXIT
384
- ret = -1
385
- end
493
+ ret = -1 if @exit_type == :EARLY_EXIT
386
494
 
387
495
  @result_data = ret
388
- return ret
496
+ ret
389
497
  end
390
498
 
391
- # This sets multiple attributes of the widget.
392
- def set(list, list_size, filler_char, highlight, box)
393
- self.setContents(list, list_size)
394
- self.setFillerChar(filler_char)
395
- self.set_highlight(highlight)
396
- self.set_box(box)
499
+ # Sets multiple attributes of the Widget.
500
+ #
501
+ # See Alphalist#initialize.
502
+ def set(list, filler_char, highlight, box)
503
+ self.set_contents list
504
+ self.set_filler_char filler_char
505
+ self.set_highlight highlight
506
+ self.set_box box
397
507
  end
398
508
 
399
509
  # This function sets the information inside the alphalist.
400
- def setContents(list, list_size)
401
- if !self.createList(list, list_size)
402
- return
403
- end
510
+ def set_contents list
511
+ return if not self.createList list
404
512
 
405
513
  # Set the information in the scrolling list.
406
514
  @scroll_field.set(@list, @list_size, false,
407
515
  @scroll_field.highlight, @scroll_field.box)
408
516
 
409
517
  # Clean out the entry field.
410
- self.setCurrentItem(0)
518
+ self.set_current_item(0)
411
519
  @entry_field.clean
412
520
 
413
521
  # Redraw the widget.
414
522
  self.erase
415
- self.draw(@box)
523
+ self.draw @box
416
524
  end
417
525
 
418
526
  # This returns the contents of the widget.
419
- def getContents(size)
527
+ def getContents size
420
528
  size << @list_size
421
529
  return @list
422
530
  end
423
531
 
424
532
  # Get/set the current position in the scroll widget.
425
- def getCurrentItem
426
- return @scroll_field.getCurrentItem
533
+ def get_current_item
534
+ return @scroll_field.get_current_item
427
535
  end
428
536
 
429
- def setCurrentItem(item)
537
+ def set_current_item item
430
538
  if @list_size != 0
431
- @scroll_field.setCurrentItem(item)
432
- @entry_field.setValue(@list[@scroll_field.getCurrentItem])
539
+ @scroll_field.set_current_item item
540
+ @entry_field.setValue @list[@scroll_field.get_current_item]
433
541
  end
434
542
  end
435
543
 
436
544
  # This sets the filler character of the entry field of the alphalist.
437
- def setFillerChar(filler_character)
438
- @filler_char = filler_character
439
- @entry_field.setFillerChar(filler_character)
545
+ def set_filler_char char
546
+ @filler_char = char
547
+ @entry_field.set_filler_char char
440
548
  end
441
549
 
442
- def getFillerChar
550
+ def get_filler_char
443
551
  return @filler_char
444
552
  end
445
553
 
@@ -500,7 +608,7 @@ module RNDK
500
608
  self.destroyInfo
501
609
 
502
610
  # Clean the key bindings.
503
- self.clean_bindings(:ALPHALIST)
611
+ self.clean_bindings(:alphalist)
504
612
 
505
613
  @entry_field.destroy
506
614
  @scroll_field.destroy
@@ -510,7 +618,7 @@ module RNDK
510
618
  RNDK.window_delete(@win)
511
619
 
512
620
  # Unregister the object.
513
- RNDK::Screen.unregister(:ALPHALIST, self)
621
+ RNDK::Screen.unregister(:alphalist, self)
514
622
  end
515
623
 
516
624
  # This function sets the pre-process function.
@@ -523,13 +631,13 @@ module RNDK
523
631
  @entry_field.setPostProcess(callback, data)
524
632
  end
525
633
 
526
- def createList(list, list_size)
527
- if list_size >= 0
634
+ def createList list
635
+ if list.size >= 0
528
636
  newlist = []
529
637
 
530
638
  # Copy in the new information.
531
639
  status = true
532
- (0...list_size).each do |x|
640
+ (0...list.size).each do |x|
533
641
  newlist << list[x]
534
642
  if newlist[x] == 0
535
643
  status = false
@@ -538,7 +646,7 @@ module RNDK
538
646
  end
539
647
  if status
540
648
  self.destroyInfo
541
- @list_size = list_size
649
+ @list_size = list.size
542
650
  @list = newlist
543
651
  @list.sort!
544
652
  end
@@ -546,7 +654,7 @@ module RNDK
546
654
  self.destroyInfo
547
655
  status = true
548
656
  end
549
- return status
657
+ status
550
658
  end
551
659
 
552
660
  def focus
@@ -566,7 +674,7 @@ module RNDK
566
674
  end
567
675
 
568
676
  def object_type
569
- :ALPHALIST
677
+ :alphalist
570
678
  end
571
679
  end
572
680
  end
data/lib/rndk/button.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class BUTTON < RNDK::Widget
4
+ class BUTTON < Widget
5
5
  def initialize(rndkscreen, xplace, yplace, text, callback, box, shadow)
6
6
  super()
7
7
  parent_width = Ncurses.getmaxx(rndkscreen.window)
@@ -177,7 +177,7 @@ module RNDK
177
177
  end
178
178
  end
179
179
 
180
- # This moves the button field to the given location.
180
+ # @see Widget#move
181
181
  def move(xplace, yplace, relative, refresh_flag)
182
182
  current_x = Ncurses.getbegx(@win)
183
183
  current_y = Ncurses.getbegy(@win)
@@ -366,5 +366,7 @@ module RNDK
366
366
  def object_type
367
367
  :BUTTON
368
368
  end
369
+
369
370
  end
370
371
  end
372
+
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class BUTTONBOX < RNDK::Widget
4
+ class BUTTONBOX < Widget
5
5
  attr_reader :current_button
6
6
 
7
7
  def initialize(rndkscreen, x_pos, y_pos, height, width, title, rows, cols,