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
data/lib/rndk/fselect.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class FSELECT < RNDK::Widget
4
+ class FSELECT < Widget
5
5
  attr_reader :scroll_field, :entry_field
6
6
  attr_reader :dir_attribute, :file_attribute, :link_attribute, :highlight
7
7
  attr_reader :sock_attribute, :field_attribute, :filler_character
@@ -83,7 +83,7 @@ module RNDK
83
83
  then RNDK::FULL
84
84
  else box_width - 2 - label_len
85
85
  end
86
- @entry_field = RNDK::ENTRY.new(rndkscreen, Ncurses.getbegx(@win), Ncurses.getbegy(@win),
86
+ @entry_field = RNDK::Entry.new(rndkscreen, Ncurses.getbegx(@win), Ncurses.getbegy(@win),
87
87
  title, label, field_attribute, filler_char, :MIXED, temp_width,
88
88
  0, 512, box, false)
89
89
 
@@ -148,7 +148,7 @@ module RNDK
148
148
  ]
149
149
 
150
150
  # Create the pop up label.
151
- info_label = RNDK::LABEL.new(entry.screen, RNDK::CENTER, RNDK::CENTER,
151
+ info_label = RNDK::Label.new(entry.screen, RNDK::CENTER, RNDK::CENTER,
152
152
  mesg, 9, true, false)
153
153
  info_label.draw(true)
154
154
  info_label.getch([])
@@ -351,12 +351,12 @@ module RNDK
351
351
  end
352
352
 
353
353
  # Define the callbacks for the entry field.
354
- @entry_field.bind(:ENTRY, Ncurses::KEY_UP, adjust_scroll_cb, self)
355
- @entry_field.bind(:ENTRY, Ncurses::KEY_PPAGE, adjust_scroll_cb, self)
356
- @entry_field.bind(:ENTRY, Ncurses::KEY_DOWN, adjust_scroll_cb, self)
357
- @entry_field.bind(:ENTRY, Ncurses::KEY_NPAGE, adjust_scroll_cb, self)
358
- @entry_field.bind(:ENTRY, RNDK::KEY_TAB, complete_filename_cb, self)
359
- @entry_field.bind(:ENTRY, RNDK.CTRL('^'), display_file_info_cb, self)
354
+ @entry_field.bind(:entry, Ncurses::KEY_UP, adjust_scroll_cb, self)
355
+ @entry_field.bind(:entry, Ncurses::KEY_PPAGE, adjust_scroll_cb, self)
356
+ @entry_field.bind(:entry, Ncurses::KEY_DOWN, adjust_scroll_cb, self)
357
+ @entry_field.bind(:entry, Ncurses::KEY_NPAGE, adjust_scroll_cb, self)
358
+ @entry_field.bind(:entry, RNDK::KEY_TAB, complete_filename_cb, self)
359
+ @entry_field.bind(:entry, RNDK.CTRL('^'), display_file_info_cb, self)
360
360
 
361
361
  # Put the current working directory in the entry field.
362
362
  @entry_field.setValue(@pwd)
@@ -367,7 +367,7 @@ module RNDK
367
367
  then RNDK::FULL
368
368
  else box_width - 1
369
369
  end
370
- @scroll_field = RNDK::SCROLL.new(rndkscreen,
370
+ @scroll_field = RNDK::Scroll.new(rndkscreen,
371
371
  Ncurses.getbegx(@win), Ncurses.getbegy(@win) + temp_height, RNDK::RIGHT,
372
372
  box_height - temp_height, temp_width, '', @dir_contents,
373
373
  @file_counter, false, @highlight, box, false)
@@ -608,11 +608,9 @@ module RNDK
608
608
  dir_list = []
609
609
 
610
610
  # Get the directory contents
611
- file_count = RNDK.getDirectoryContents(@pwd, dir_list)
612
- if file_count <= 0
613
- # We couldn't read the directory. Return.
614
- return false
615
- end
611
+ dir_list = RNDK.get_directory_contents @pwd
612
+
613
+ return false if dir_list.size <= 0
616
614
 
617
615
  @dir_contents = dir_list
618
616
  @file_counter = file_count
data/lib/rndk/fslider.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk/slider'
2
2
 
3
3
  module RNDK
4
- class FSLIDER < RNDK::SLIDER
4
+ class FSLIDER < Slider
5
5
  def initialize(rndkscreen,
6
6
  xplace,
7
7
  yplace,
data/lib/rndk/graph.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class GRAPH < RNDK::Widget
4
+ class GRAPH < Widget
5
5
  def initialize(rndkscreen,
6
6
  xplace,
7
7
  yplace,
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class HISTOGRAM < RNDK::Widget
4
+ class HISTOGRAM < Widget
5
5
  def initialize(rndkscreen, xplace, yplace, height, width, orient,
6
6
  title, box, shadow)
7
7
  super()
data/lib/rndk/itemlist.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class ITEMLIST < RNDK::Widget
4
+ class ITEMLIST < Widget
5
5
  def initialize(rndkscreen, xplace, yplace, title, label, item, count,
6
6
  default_item, box, shadow)
7
7
  super()
data/lib/rndk/label.rb CHANGED
@@ -2,9 +2,9 @@ require 'rndk'
2
2
 
3
3
  module RNDK
4
4
 
5
- # Pop-up Label window.
5
+ # Customizable text on the screen.
6
6
  #
7
- class LABEL < RNDK::Widget
7
+ class Label < Widget
8
8
 
9
9
  # Raw Ncurses window.
10
10
  attr_accessor :win
@@ -105,7 +105,7 @@ module RNDK
105
105
  end
106
106
 
107
107
  # Register this
108
- rndkscreen.register(:LABEL, self)
108
+ rndkscreen.register(:label, self)
109
109
  end
110
110
 
111
111
  # Obsolete entrypoint which calls Label#draw.
@@ -162,7 +162,7 @@ module RNDK
162
162
  end
163
163
 
164
164
  def object_type
165
- :LABEL
165
+ :label
166
166
  end
167
167
 
168
168
  def position
@@ -211,9 +211,9 @@ module RNDK
211
211
  RNDK.window_delete @shadow_win
212
212
  RNDK.window_delete @win
213
213
 
214
- self.clean_bindings :LABEL
214
+ self.clean_bindings :label
215
215
 
216
- RNDK::Screen.unregister(:LABEL, self)
216
+ RNDK::Screen.unregister(:label, self)
217
217
  end
218
218
 
219
219
  # Waits for the user to press a key.
@@ -237,3 +237,4 @@ module RNDK
237
237
 
238
238
  end
239
239
  end
240
+
data/lib/rndk/marquee.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class MARQUEE < RNDK::Widget
4
+ class MARQUEE < Widget
5
5
  def initialize(rndkscreen, xpos, ypos, width, box, shadow)
6
6
  super()
7
7
 
data/lib/rndk/matrix.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class MATRIX < RNDK::Widget
4
+ class MATRIX < Widget
5
5
  attr_accessor :info
6
6
  attr_reader :colvalues, :row, :col, :colwidths, :filler
7
7
  attr_reader :crow, :ccol
data/lib/rndk/mentry.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class MENTRY < RNDK::Widget
4
+ class MEntry < Widget
5
5
  attr_accessor :info, :current_col, :current_row, :top_row
6
6
  attr_reader :disp_type, :field_width, :rows, :field_win
7
7
 
@@ -158,7 +158,7 @@ module RNDK
158
158
  end
159
159
 
160
160
  # Register
161
- rndkscreen.register(:MENTRY, self)
161
+ rndkscreen.register(:MEntry, self)
162
162
  end
163
163
 
164
164
  # This actually activates the mentry widget...
@@ -249,14 +249,14 @@ module RNDK
249
249
  # Check if there is a pre-process function to be called.
250
250
  unless @pre_process_func.nil?
251
251
  # Call the pre-process function
252
- pp_return = @pre_process_func.call(:MENTRY, self,
252
+ pp_return = @pre_process_func.call(:MEntry, self,
253
253
  @pre_process_data, input)
254
254
  end
255
255
 
256
256
  # Should we continue?
257
257
  if pp_return != 0
258
258
  # Check for a key binding...
259
- if self.checkBind(:MENTRY, input)
259
+ if self.checkBind(:MEntry, input)
260
260
  complete = true
261
261
  else
262
262
  moved = false
@@ -419,7 +419,7 @@ module RNDK
419
419
 
420
420
  # Should we do a post-process?
421
421
  if !complete && !(@post_process_func.nil?)
422
- @post_process_func.call(:MENTRY, self, @post_process_data, input)
422
+ @post_process_func.call(:MEntry, self, @post_process_data, input)
423
423
  end
424
424
  end
425
425
 
@@ -519,10 +519,10 @@ module RNDK
519
519
  RNDK.window_delete(@win)
520
520
 
521
521
  # Clean the key bindings.
522
- self.clean_bindings(:MENTRY)
522
+ self.clean_bindings(:MEntry)
523
523
 
524
524
  # Unregister this object.
525
- RNDK::Screen.unregister(:MENTRY, self)
525
+ RNDK::Screen.unregister(:MEntry, self)
526
526
  end
527
527
 
528
528
  # This sets multiple attributes of the widget.
@@ -613,7 +613,7 @@ module RNDK
613
613
  end
614
614
 
615
615
  def object_type
616
- :MENTRY
616
+ :MEntry
617
617
  end
618
618
  end
619
619
  end
data/lib/rndk/menu.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class MENU < RNDK::Widget
4
+ class MENU < Widget
5
5
  TITLELINES = 1
6
6
  MAX_MENU_ITEMS = 30
7
7
  MAX_SUB_ITEMS = 98
data/lib/rndk/radio.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk/scroller'
2
2
 
3
3
  module RNDK
4
- class RADIO < RNDK::SCROLLER
4
+ class RADIO < SCROLLER
5
5
  def initialize(rndkscreen, xplace, yplace, splace, height, width, title,
6
6
  list, list_size, choice_char, def_item, highlight, box, shadow)
7
7
  super()
data/lib/rndk/scale.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk'
2
2
 
3
3
  module RNDK
4
- class SCALE < RNDK::Widget
4
+ class SCALE < Widget
5
5
  def initialize(rndkscreen, xplace, yplace, title, label, field_attr,
6
6
  field_width, start, low, high, inc, fast_inc, box, shadow)
7
7
  super()
data/lib/rndk/scroll.rb CHANGED
@@ -1,30 +1,100 @@
1
1
  require 'rndk/scroller'
2
2
 
3
3
  module RNDK
4
- class SCROLL < RNDK::SCROLLER
4
+
5
+ # A scrolling list of text.
6
+ #
7
+ # ## Keybindings
8
+ #
9
+ # Left Arrow:: Shift the list left one column.
10
+ # Right Arrow:: Shift the list right one column.
11
+ # Up Arrow:: Select the previous item in the list.
12
+ # Down Arrow:: Select the next item in the list.
13
+ # Prev Page:: Scroll one page backward.
14
+ # Ctrl-B:: Scroll one page backward.
15
+ # Next Page:: Scroll one page forward.
16
+ # Ctrl-F:: Scroll one page forward.
17
+ # 1:: Move to the first element in the list.
18
+ # <:: Move to the first element in the list.
19
+ # g:: Move to the first element in the list.
20
+ # Home:: Move to the first element in the list.
21
+ # >:: Move to the last element in the list.
22
+ # G:: Move to the last element in the list.
23
+ # End:: Move to the last element in the list.
24
+ # $:: Shift the list to the far right.
25
+ # |:: Shift the list to the far left.
26
+ # Return:: Exit the widget and return the index
27
+ # of the selected item. Also set the
28
+ # widget `exit_type` to `:NORMAL`.
29
+ # Tab:: Exit the widget and return the index
30
+ # of the selected item. Also set the
31
+ # widget `exit_type` to `:NORMAL`.
32
+ # Escape:: Exit the widget and return -1. Also
33
+ # set the widget `exit_type` `:ESCAPE_HIT`.
34
+ # Ctrl-L:: Refreshes the screen.
35
+ #
36
+ class Scroll < SCROLLER
5
37
  attr_reader :item, :list_size, :current_item, :highlight
6
38
 
7
- def initialize (rndkscreen, xplace, yplace, splace, height, width, title,
8
- list, list_size, numbers, highlight, box, shadow)
39
+ # Creates a Scroll Widget.
40
+ #
41
+ # * `xplace` is the x position - can be an integer or
42
+ # `RNDK::LEFT`, `RNDK::RIGHT`, `RNDK::CENTER`.
43
+ # * `yplace` is the y position - can be an integer or
44
+ # `RNDK::TOP`, `RNDK::BOTTOM`, `RNDK::CENTER`.
45
+ # * `splace` is where the scrollbar will be placed.
46
+ # It can be only `RNDK::LEFT`, `RNDK::RIGHT` or
47
+ # `RNDK::NONE`, for no scrollbar.
48
+ # * `width`/`height` are integers - if either are 0, Widget
49
+ # will be created with full width/height of the screen.
50
+ # If it's a negative value, will create with full width/height
51
+ # minus the value.
52
+ # * `title` can be more than one line - just split them
53
+ # with `\n`s.
54
+ # * `list` is an Array of Strings to be shown on the Widget.
55
+ # * `numbers` is a flag to turn on/off line numbering at
56
+ # the front of the list items.
57
+ # * `highlight` is the attribute/color of the currently selected
58
+ # item at the list.
59
+ # * `box` if the Widget is drawn with a box outside it.
60
+ # * `shadow` turns on/off the shadow around the Widget.
61
+ #
62
+ def initialize (rndkscreen,
63
+ xplace,
64
+ yplace,
65
+ splace,
66
+ width,
67
+ height,
68
+ title,
69
+ list,
70
+ numbers,
71
+ highlight,
72
+ box,
73
+ shadow)
9
74
  super()
10
- parent_width = Ncurses.getmaxx(rndkscreen.window)
11
- parent_height = Ncurses.getmaxy(rndkscreen.window)
12
- box_width = width
75
+
76
+ parent_width = Ncurses.getmaxx rndkscreen.window
77
+ parent_height = Ncurses.getmaxy rndkscreen.window
78
+
79
+ box_width = width
13
80
  box_height = height
81
+
14
82
  xpos = xplace
15
83
  ypos = yplace
84
+
16
85
  scroll_adjust = 0
86
+
17
87
  bindings = {
18
88
  RNDK::BACKCHAR => Ncurses::KEY_PPAGE,
19
89
  RNDK::FORCHAR => Ncurses::KEY_NPAGE,
20
- 'g' => Ncurses::KEY_HOME,
21
- '1' => Ncurses::KEY_HOME,
22
- 'G' => Ncurses::KEY_END,
23
- '<' => Ncurses::KEY_HOME,
24
- '>' => Ncurses::KEY_END
90
+ 'g' => Ncurses::KEY_HOME,
91
+ '1' => Ncurses::KEY_HOME,
92
+ 'G' => Ncurses::KEY_END,
93
+ '<' => Ncurses::KEY_HOME,
94
+ '>' => Ncurses::KEY_END
25
95
  }
26
96
 
27
- self.set_box(box)
97
+ self.set_box box
28
98
 
29
99
  # If the height is a negative value, the height will be ROWS-height,
30
100
  # otherwise the height will be the given height
@@ -38,7 +108,7 @@ module RNDK
38
108
 
39
109
  # Set the box height.
40
110
  if @title_lines > box_height
41
- box_height = @title_lines + [list_size, 8].min + 2 * @border_size
111
+ box_height = @title_lines + [list.size, 8].min + 2 * @border_size
42
112
  end
43
113
 
44
114
  # Adjust the box width if there is a scroll bar
@@ -59,7 +129,7 @@ module RNDK
59
129
  else box_height
60
130
  end
61
131
 
62
- self.setViewSize(list_size)
132
+ self.setViewSize(list.size)
63
133
 
64
134
  # Rejustify the x and y positions if we need to.
65
135
  xtmp = [xpos]
@@ -81,20 +151,27 @@ module RNDK
81
151
 
82
152
  # Create the scrollbar window.
83
153
  if splace == RNDK::RIGHT
84
- @scrollbar_win = Ncurses.subwin(@win, self.maxViewSize, 1,
85
- self.Screen_YPOS(ypos), xpos + box_width - @border_size - 1)
154
+ @scrollbar_win = Ncurses.subwin(@win,
155
+ self.maxViewSize,
156
+ 1,
157
+ self.Screen_YPOS(ypos),
158
+ xpos + box_width - @border_size - 1)
86
159
  elsif splace == RNDK::LEFT
87
- @scrollbar_win = Ncurses.subwin(@win, self.maxViewSize, 1,
88
- self.Screen_YPOS(ypos), self.Screen_XPOS(xpos))
160
+ @scrollbar_win = Ncurses.subwin(@win,
161
+ self.maxViewSize,
162
+ 1,
163
+ self.Screen_YPOS(ypos),
164
+ self.Screen_XPOS(xpos))
89
165
  else
90
166
  @scrollbar_win = nil
91
167
  end
92
168
 
93
169
  # create the list window
94
- @list_win = Ncurses.subwin(@win, self.maxViewSize,
95
- box_width - (2 * @border_size) - scroll_adjust,
96
- self.Screen_YPOS(ypos),
97
- self.Screen_XPOS(xpos) + (if splace == RNDK::LEFT then 1 else 0 end))
170
+ @list_win = Ncurses.subwin(@win,
171
+ self.maxViewSize,
172
+ box_width - (2 * @border_size) - scroll_adjust,
173
+ self.Screen_YPOS(ypos),
174
+ self.Screen_XPOS(xpos) + (if splace == RNDK::LEFT then 1 else 0 end))
98
175
 
99
176
  # Set the rest of the variables
100
177
  @screen = rndkscreen
@@ -112,33 +189,36 @@ module RNDK
112
189
  self.setPosition(0);
113
190
 
114
191
  # Create the scrolling list item list and needed variables.
115
- if self.createItemList(numbers, list, list_size) <= 0
192
+ if self.createItemList(numbers, list, list.size) <= 0
116
193
  return nil
117
194
  end
118
195
 
119
196
  # Do we need to create a shadow?
120
197
  if shadow
121
- @shadow_win = Ncurses.newwin(@box_height, box_width,
122
- ypos + 1, xpos + 1)
198
+ @shadow_win = Ncurses.newwin(@box_height,
199
+ box_width,
200
+ ypos + 1,
201
+ xpos + 1)
123
202
  end
124
203
 
125
204
  # Set up the key bindings.
126
205
  bindings.each do |from, to|
127
- #self.bind(:SCROLL, from, getc_lambda, to)
128
- self.bind(:SCROLL, from, :getc, to)
206
+ #self.bind(:scroll, from, getc_lambda, to)
207
+ self.bind(:scroll, from, :getc, to)
129
208
  end
130
209
 
131
- rndkscreen.register(:SCROLL, self);
210
+ rndkscreen.register(:scroll, self);
132
211
 
133
212
  return self
134
213
  end
135
214
 
136
215
  def object_type
137
- :SCROLL
216
+ :scroll
138
217
  end
139
218
 
219
+ # @see Widget#position
140
220
  def position
141
- super(@win)
221
+ super @win
142
222
  end
143
223
 
144
224
  # Put the cursor on the currently-selected item's row.
@@ -151,29 +231,31 @@ module RNDK
151
231
  Ncurses.wrefresh(@input_window)
152
232
  end
153
233
 
154
- # This actually does all the 'real' work of managing the scrolling list.
155
- def activate(actions)
234
+ # Activates the Widget, letting the user interact with it.
235
+ #
236
+ # `actions` is an Array of characters. If it's non-null,
237
+ # will #inject each char on it into the Widget.
238
+ #
239
+ def activate(actions=[])
156
240
  # Draw the scrolling list
157
241
  self.draw(@box)
158
242
 
159
243
  if actions.nil? || actions.size == 0
160
- while true
244
+ loop do
161
245
  self.fixCursorPosition
162
246
  input = self.getch([])
163
247
 
164
248
  # Inject the character into the widget.
165
- ret = self.inject(input)
166
- if @exit_type != :EARLY_EXIT
167
- return ret
168
- end
249
+ ret = self.inject input
250
+
251
+ return ret if @exit_type != :EARLY_EXIT
169
252
  end
170
253
  else
171
254
  # Inject each character one at a time.
172
255
  actions.each do |action|
173
- ret = self.inject(action)
174
- if @exit_type != :EARLY_EXIT
175
- return ret
176
- end
256
+ ret = self.inject action
257
+
258
+ return ret if @exit_type != :EARLY_EXIT
177
259
  end
178
260
  end
179
261
 
@@ -182,8 +264,8 @@ module RNDK
182
264
  return -1
183
265
  end
184
266
 
185
- # This injects a single character into the widget.
186
- def inject(input)
267
+ # @see Widget#inject
268
+ def inject input
187
269
  pp_return = 1
188
270
  ret = -1
189
271
  complete = false
@@ -196,14 +278,14 @@ module RNDK
196
278
 
197
279
  #Check if there is a pre-process function to be called.
198
280
  unless @pre_process_func.nil?
199
- pp_return = @pre_process_func.call(:SCROLL, self,
281
+ pp_return = @pre_process_func.call(:scroll, self,
200
282
  @pre_process_data, input)
201
283
  end
202
284
 
203
285
  # Should we continue?
204
286
  if pp_return != 0
205
287
  # Check for a predefined key binding.
206
- if self.checkBind(:SCROLL, input) != false
288
+ if self.checkBind(:scroll, input) != false
207
289
  #self.checkEarlyExit
208
290
  complete = true
209
291
  else
@@ -245,7 +327,7 @@ module RNDK
245
327
  end
246
328
 
247
329
  if !complete && !(@post_process_func.nil?)
248
- @post_process_func.call(:SCROLL, self, @post_process_data, input)
330
+ @post_process_func.call(:scroll, self, @post_process_data, input)
249
331
  end
250
332
  end
251
333
 
@@ -279,8 +361,8 @@ module RNDK
279
361
  # This moves the scroll field to the given location.
280
362
  def move(xplace, yplace, relative, refresh_flag)
281
363
  windows = [@win, @list_win, @shadow_win, @scrollbar_win]
282
- self.move_specific(xplace, yplace, relative, refresh_flag,
283
- windows, [])
364
+
365
+ self.move_specific(xplace, yplace, relative, refresh_flag, windows, [])
284
366
  end
285
367
 
286
368
  # This function draws the scrolling list widget.
@@ -311,7 +393,7 @@ module RNDK
311
393
  @item_len[@current_item])
312
394
  end
313
395
 
314
- def drawList(box)
396
+ def drawList box
315
397
  # If the list is empty, don't draw anything.
316
398
  if @list_size > 0
317
399
  # Redraw the list
@@ -390,10 +472,10 @@ module RNDK
390
472
  RNDK.window_delete(@win)
391
473
 
392
474
  # Clean the key bindings.
393
- self.clean_bindings(:SCROLL)
475
+ self.clean_bindings(:scroll)
394
476
 
395
477
  # Unregister this object
396
- RNDK::Screen.unregister(:SCROLL, self)
478
+ RNDK::Screen.unregister(:scroll, self)
397
479
  end
398
480
 
399
481
  # This function erases the scrolling list from the screen.
@@ -592,12 +674,10 @@ module RNDK
592
674
 
593
675
  self.setViewSize(@list_size - 1)
594
676
 
595
- if @list_size > 0
596
- self.resequence
597
- end
677
+ self.resequence if @list_size > 0
598
678
 
599
679
  if @list_size < self.maxViewSize
600
- @win.werase # force the next redraw to be complete
680
+ Ncurses.werase @win # force the next redraw to be complete
601
681
  end
602
682
 
603
683
  # do this to update the view size, etc
@@ -629,5 +709,8 @@ module RNDK
629
709
  def WidestItem
630
710
  @max_left_char + self.AvailableWidth
631
711
  end
712
+
713
+ private
714
+
632
715
  end
633
716
  end
data/lib/rndk/scroller.rb CHANGED
@@ -2,7 +2,13 @@ require 'rndk'
2
2
 
3
3
  module RNDK
4
4
 
5
- class SCROLLER < RNDK::Widget
5
+ # Common actions and functionality between
6
+ # scrolling Widgets.
7
+ #
8
+ # @note Do **not** instantiate this class!
9
+ # Use it's subclasses.
10
+ class SCROLLER < Widget
11
+
6
12
  def initialize
7
13
  super()
8
14
  end
@@ -181,5 +187,7 @@ module RNDK
181
187
  def setCurrentItem(item)
182
188
  self.setPosition(item);
183
189
  end
190
+
184
191
  end
185
192
  end
193
+
@@ -2,7 +2,7 @@ require 'rndk/scroller'
2
2
 
3
3
  module RNDK
4
4
  # TODO This Widget's very buggy! Somehow improve it later!
5
- class SELECTION < RNDK::SCROLLER
5
+ class SELECTION < SCROLLER
6
6
  attr_reader :selections
7
7
 
8
8
  def initialize(rndkscreen, xplace, yplace, splace, height, width, title,