cdk 0.9.0 → 0.10.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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cdk.rb +7 -866
  3. data/lib/cdk/cdk_objs.rb +46 -423
  4. data/lib/cdk/components.rb +28 -0
  5. data/lib/cdk/{alphalist.rb → components/alphalist.rb} +9 -6
  6. data/lib/cdk/components/button.rb +405 -0
  7. data/lib/cdk/{buttonbox.rb → components/buttonbox.rb} +11 -11
  8. data/lib/cdk/{calendar.rb → components/calendar.rb} +13 -13
  9. data/lib/cdk/components/dialog.rb +343 -0
  10. data/lib/cdk/{dscale.rb → components/dscale.rb} +0 -0
  11. data/lib/cdk/{entry.rb → components/entry.rb} +18 -18
  12. data/lib/cdk/{fscale.rb → components/fscale.rb} +1 -1
  13. data/lib/cdk/{fselect.rb → components/fselect.rb} +16 -13
  14. data/lib/cdk/{fslider.rb → components/fslider.rb} +1 -1
  15. data/lib/cdk/components/graph.rb +386 -0
  16. data/lib/cdk/{histogram.rb → components/histogram.rb} +3 -3
  17. data/lib/cdk/{itemlist.rb → components/itemlist.rb} +14 -14
  18. data/lib/cdk/{label.rb → components/label.rb} +7 -7
  19. data/lib/cdk/{marquee.rb → components/marquee.rb} +7 -7
  20. data/lib/cdk/{matrix.rb → components/matrix.rb} +27 -27
  21. data/lib/cdk/{mentry.rb → components/mentry.rb} +18 -18
  22. data/lib/cdk/{menu.rb → components/menu.rb} +18 -18
  23. data/lib/cdk/{radio.rb → components/radio.rb} +12 -12
  24. data/lib/cdk/{scale.rb → components/scale.rb} +13 -13
  25. data/lib/cdk/{scroll.rb → components/scroll.rb} +23 -386
  26. data/lib/cdk/{scroller.rb → components/scroller.rb} +1 -1
  27. data/lib/cdk/{selection.rb → components/selection.rb} +14 -14
  28. data/lib/cdk/{slider.rb → components/slider.rb} +15 -15
  29. data/lib/cdk/{swindow.rb → components/swindow.rb} +14 -14
  30. data/lib/cdk/{template.rb → components/template.rb} +18 -18
  31. data/lib/cdk/{uscale.rb → components/uscale.rb} +0 -0
  32. data/lib/cdk/{uslider.rb → components/uslider.rb} +0 -0
  33. data/lib/cdk/{viewer.rb → components/viewer.rb} +88 -18
  34. data/lib/cdk/constants.rb +54 -0
  35. data/lib/cdk/display.rb +30 -35
  36. data/lib/cdk/draw.rb +4 -6
  37. data/lib/cdk/helpers/file.rb +43 -0
  38. data/lib/cdk/helpers/types.rb +13 -0
  39. data/lib/cdk/helpers/window.rb +64 -0
  40. data/lib/cdk/mixins/alignments.rb +55 -0
  41. data/lib/cdk/mixins/bindings.rb +73 -0
  42. data/lib/cdk/mixins/borders.rb +62 -0
  43. data/lib/cdk/mixins/common_controls.rb +14 -0
  44. data/lib/cdk/mixins/converters.rb +358 -0
  45. data/lib/cdk/mixins/exit_conditions.rb +31 -0
  46. data/lib/cdk/mixins/focusable.rb +17 -0
  47. data/lib/cdk/mixins/formattable.rb +15 -0
  48. data/lib/cdk/mixins/has_screen.rb +23 -0
  49. data/lib/cdk/mixins/has_title.rb +64 -0
  50. data/lib/cdk/mixins/justifications.rb +26 -0
  51. data/lib/cdk/mixins/list_support.rb +31 -0
  52. data/lib/cdk/mixins/movement.rb +140 -0
  53. data/lib/cdk/mixins/window_hooks.rb +18 -0
  54. data/lib/cdk/mixins/window_input.rb +61 -0
  55. data/lib/cdk/screen.rb +27 -3
  56. metadata +51 -29
  57. data/lib/cdk/dialog.rb +0 -727
@@ -1,4 +1,4 @@
1
- require_relative 'cdk_objs'
1
+ require_relative '../cdk_objs'
2
2
  module CDK
3
3
  class SCROLLER < CDK::CDKOBJS
4
4
  def initialize
@@ -64,7 +64,7 @@ module CDK
64
64
  # Rejustify the x and y positions if we need to.
65
65
  xtmp = [xplace]
66
66
  ytmp = [yplace]
67
- CDK.alignxy(cdkscreen.window, xtmp, ytmp, @box_width, @box_height)
67
+ alignxy(cdkscreen.window, xtmp, ytmp, @box_width, @box_height)
68
68
  xpos = xtmp[0]
69
69
  ypos = ytmp[0]
70
70
 
@@ -108,7 +108,7 @@ module CDK
108
108
  # Each choice has to be converted from string to chtype array
109
109
  (0...choice_count).each do |j|
110
110
  choicelen = []
111
- @choice << CDK.char2Chtype(choices[j], choicelen, [])
111
+ @choice << char2Chtype(choices[j], choicelen, [])
112
112
  @choicelen << choicelen[0]
113
113
  @maxchoicelen = [@maxchoicelen, choicelen[0]].max
114
114
  end
@@ -147,7 +147,7 @@ module CDK
147
147
  xpos = self.SCREEN_XPOS(0) + scrollbar_adj
148
148
 
149
149
  @input_window.wmove(ypos, xpos)
150
- @input_window.wrefresh
150
+ wrefresh(@input_window)
151
151
  end
152
152
 
153
153
  # This actually manages the selection widget
@@ -185,7 +185,7 @@ module CDK
185
185
  def inject(input)
186
186
  pp_return = 1
187
187
  ret = -1
188
- complete = false
188
+ @complete = false
189
189
 
190
190
  # Set the exit type
191
191
  self.setExitType(0)
@@ -203,7 +203,7 @@ module CDK
203
203
  if pp_return != 0
204
204
  # Check for a predefined binding.
205
205
  if self.checkBind(:SELECTION, input)
206
- complete = true
206
+ @complete = true
207
207
  else
208
208
  case input
209
209
  when Ncurses::KEY_UP
@@ -238,14 +238,14 @@ module CDK
238
238
  end
239
239
  when CDK::KEY_ESC
240
240
  self.setExitType(input)
241
- complete = true
241
+ @complete = true
242
242
  when Ncurses::ERR
243
243
  self.setExitType(input)
244
- complete = true
244
+ @complete = true
245
245
  when Ncurses::KEY_ENTER, CDK::KEY_TAB, CDK::KEY_RETURN
246
246
  self.setExitType(input)
247
247
  ret = 1
248
- complete = true
248
+ @complete = true
249
249
  when CDK::REFRESH
250
250
  @screen.erase
251
251
  @screen.refresh
@@ -253,12 +253,12 @@ module CDK
253
253
  end
254
254
 
255
255
  # Should we call a post-process?
256
- if !complete && !(@post_process_func.nil?)
256
+ if !@complete && !(@post_process_func.nil?)
257
257
  @post_process_func.call(:SELECTION, self, @post_process_data, input)
258
258
  end
259
259
  end
260
260
 
261
- unless complete
261
+ unless @complete
262
262
  self.drawList(@box)
263
263
  self.setExitType(0)
264
264
  end
@@ -412,7 +412,7 @@ module CDK
412
412
 
413
413
  def getItems(list)
414
414
  @item.each do |item|
415
- list << CDK.chtype2Char(item)
415
+ list << chtype2Char(item)
416
416
  end
417
417
  return @list_size
418
418
  end
@@ -429,7 +429,7 @@ module CDK
429
429
  end
430
430
 
431
431
  def getTitle
432
- return CDK.chtype2Char(@title)
432
+ return chtype2Char(@title)
433
433
  end
434
434
 
435
435
  # This sets the highlight bar.
@@ -558,7 +558,7 @@ module CDK
558
558
  (0...list_size).each do |j|
559
559
  lentmp = []
560
560
  postmp = []
561
- new_list << CDK.char2Chtype(list[j], lentmp, postmp)
561
+ new_list << char2Chtype(list[j], lentmp, postmp)
562
562
  new_len << lentmp[0]
563
563
  new_pos << postmp[0]
564
564
  #if new_list[j].size == 0
@@ -567,7 +567,7 @@ module CDK
567
567
  break
568
568
  end
569
569
  new_pos[j] =
570
- CDK.justifyString(box_width, new_len[j], new_pos[j]) + adjust
570
+ justify_string(box_width, new_len[j], new_pos[j]) + adjust
571
571
  widest_item = [widest_item, new_len[j]].max
572
572
  end
573
573
 
@@ -1,4 +1,4 @@
1
- require_relative 'cdk_objs'
1
+ require_relative '../cdk_objs'
2
2
 
3
3
  module CDK
4
4
  class SLIDER < CDK::CDKOBJS
@@ -33,7 +33,7 @@ module CDK
33
33
  # Translate the label string to a chtype array.
34
34
  if !(label.nil?) && label.size > 0
35
35
  label_len = []
36
- @label = CDK.char2Chtype(label, label_len, [])
36
+ @label = char2Chtype(label, label_len, [])
37
37
  @label_len = label_len[0]
38
38
  box_width = @label_len + field_width +
39
39
  high_value_len + 2 * @border_size
@@ -56,7 +56,7 @@ module CDK
56
56
  # Rejustify the x and y positions if we need to.
57
57
  xtmp = [xplace]
58
58
  ytmp = [yplace]
59
- CDK.alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
59
+ alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
60
60
  xpos = xtmp[0]
61
61
  ypos = ytmp[0]
62
62
 
@@ -190,7 +190,7 @@ module CDK
190
190
  return false
191
191
  end
192
192
  ch = @field_win.winch
193
- if CDK.CharOf(ch) != ' '
193
+ if charOf(ch) != ' '
194
194
  return true
195
195
  end
196
196
  if new_position > 1
@@ -199,7 +199,7 @@ module CDK
199
199
  return false
200
200
  end
201
201
  ch = @field_win.winch
202
- return CDK.CharOf(ch) != ' '
202
+ return charOf(ch) != ' '
203
203
  end
204
204
  return false
205
205
  end
@@ -290,7 +290,7 @@ module CDK
290
290
  def inject(input)
291
291
  pp_return = 1
292
292
  ret = -1
293
- complete = false
293
+ @complete = false
294
294
 
295
295
  # Set the exit type.
296
296
  self.setExitType(0)
@@ -309,7 +309,7 @@ module CDK
309
309
  if pp_return != 0
310
310
  # Check for a key binding.
311
311
  if self.checkBind(:SLIDER, input)
312
- complete = true
312
+ @complete = true
313
313
  else
314
314
  case input
315
315
  when Ncurses::KEY_LEFT
@@ -331,13 +331,13 @@ module CDK
331
331
  when CDK::KEY_TAB, CDK::KEY_RETURN, Ncurses::KEY_ENTER
332
332
  self.setExitType(input)
333
333
  ret = @current
334
- complete = true
334
+ @complete = true
335
335
  when CDK::KEY_ESC
336
336
  self.setExitType(input)
337
- complete = true
337
+ @complete = true
338
338
  when Ncurses::ERR
339
339
  self.setExitType(input)
340
- complete = true
340
+ @complete = true
341
341
  when CDK::REFRESH
342
342
  @screen.erase
343
343
  @screen.refresh
@@ -367,12 +367,12 @@ module CDK
367
367
  self.limitCurrentValue
368
368
 
369
369
  # Should we call a post-process?
370
- if !complete && !(@post_process_func.nil?)
370
+ if !@complete && !(@post_process_func.nil?)
371
371
  @post_process_func.call(:SLIDER, self, @post_process_data, input)
372
372
  end
373
373
  end
374
374
 
375
- if !complete
375
+ if !@complete
376
376
  self.drawField
377
377
  self.setExitType(0)
378
378
  end
@@ -406,9 +406,9 @@ module CDK
406
406
  unless @label_win.nil?
407
407
  Draw.writeChtype(@label_win, 0, 0, @label, CDK::HORIZONTAL,
408
408
  0, @label_len)
409
- @label_win.wrefresh
409
+ wrefresh(@label_win)
410
410
  end
411
- @win.wrefresh
411
+ wrefresh
412
412
 
413
413
  # Draw the field window.
414
414
  self.drawField
@@ -433,7 +433,7 @@ module CDK
433
433
  Ncurses::A_NORMAL, CDK::HORIZONTAL, 0, @current.to_s.size)
434
434
 
435
435
  self.moveToEditPosition(@field_edit)
436
- @field_win.wrefresh
436
+ wrefresh(@field_win)
437
437
  end
438
438
 
439
439
  # This sets the background attribute of the widget.
@@ -1,4 +1,4 @@
1
- require_relative 'cdk_objs'
1
+ require_relative '../cdk_objs'
2
2
 
3
3
  module CDK
4
4
  class SWINDOW < CDK::CDKOBJS
@@ -45,7 +45,7 @@ module CDK
45
45
  # Rejustify the x and y positions if we need to.
46
46
  xtmp = [xplace]
47
47
  ytmp = [yplace]
48
- CDK.alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
48
+ alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
49
49
  xpos = xtmp[0]
50
50
  ypos = ytmp[0]
51
51
 
@@ -109,9 +109,9 @@ module CDK
109
109
  def setupLine(list, x)
110
110
  list_len = []
111
111
  list_pos = []
112
- @list[x] = CDK.char2Chtype(list, list_len, list_pos)
112
+ @list[x] = char2Chtype(list, list_len, list_pos)
113
113
  @list_len[x] = list_len[0]
114
- @list_pos[x] = CDK.justifyString(@box_width, list_len[0], list_pos[0])
114
+ @list_pos[x] = justify_string(@box_width, list_len[0], list_pos[0])
115
115
  @widest_line = [@widest_line, @list_len[x]].max
116
116
  end
117
117
 
@@ -328,7 +328,7 @@ module CDK
328
328
  def inject(input)
329
329
  pp_return = 1
330
330
  ret = -1
331
- complete = false
331
+ @complete = false
332
332
 
333
333
  # Set the exit type.
334
334
  self.setExitType(0)
@@ -347,7 +347,7 @@ module CDK
347
347
  if pp_return != 0
348
348
  # Check for a key binding.
349
349
  if self.checkBind(:SWINDOW, input)
350
- complete = true
350
+ @complete = true
351
351
  else
352
352
  case input
353
353
  when Ncurses::KEY_UP
@@ -409,13 +409,13 @@ module CDK
409
409
  when CDK::KEY_TAB, CDK::KEY_RETURN, Ncurses::KEY_ENTER
410
410
  self.setExitType(input)
411
411
  ret = 1
412
- complete = true
412
+ @complete = true
413
413
  when CDK::KEY_ESC
414
414
  self.setExitType(input)
415
- complete = true
415
+ @complete = true
416
416
  when Ncurses::ERR
417
417
  self.setExitType(input)
418
- complete = true
418
+ @complete = true
419
419
  when CDK::REFRESH
420
420
  @screen.erase
421
421
  @screen.refresh
@@ -423,12 +423,12 @@ module CDK
423
423
  end
424
424
 
425
425
  # Should we call a post-process?
426
- if !complete && !(@post_process_func.nil?)
426
+ if !@complete && !(@post_process_func.nil?)
427
427
  @post_process_func.call(:SWINDOW, self, @post_process_data, input)
428
428
  end
429
429
  end
430
430
 
431
- if !complete
431
+ if !@complete
432
432
  self.drawList(@box)
433
433
  self.setExitType(0)
434
434
  end
@@ -456,7 +456,7 @@ module CDK
456
456
 
457
457
  self.drawTitle(@win)
458
458
 
459
- @win.wrefresh
459
+ wrefresh
460
460
 
461
461
  # Draw in the list.
462
462
  self.drawList(box)
@@ -490,7 +490,7 @@ module CDK
490
490
  end
491
491
  end
492
492
 
493
- @field_win.wrefresh
493
+ wrefresh(@field_win)
494
494
  end
495
495
 
496
496
  # This sets the background attribute of the widget.
@@ -713,7 +713,7 @@ module CDK
713
713
 
714
714
  # Start writing out the file.
715
715
  @list.each do |item|
716
- raw_line = CDK.chtype2Char(item)
716
+ raw_line = chtype2Char(item)
717
717
  output_file << "%s\n" % raw_line
718
718
  end
719
719
 
@@ -1,4 +1,4 @@
1
- require_relative 'cdk_objs'
1
+ require_relative '../cdk_objs'
2
2
 
3
3
  module CDK
4
4
  class TEMPLATE < CDK::CDKOBJS
@@ -26,17 +26,17 @@ module CDK
26
26
 
27
27
  # Translate the label string to achtype array
28
28
  if !(label.nil?) && label.size > 0
29
- label_len = []
30
- @label = CDK.char2Chtype(label, label_len, [])
29
+ label_len = []
30
+ @label = char2Chtype(label, label_len, [])
31
31
  @label_len = label_len[0]
32
32
  end
33
33
 
34
34
  # Translate the char * overlay to a chtype array
35
35
  if !(overlay.nil?) && overlay.size > 0
36
- overlay_len = []
37
- @overlay = CDK.char2Chtype(overlay, overlay_len, [])
36
+ overlay_len = []
37
+ @overlay = char2Chtype(overlay, overlay_len, [])
38
38
  @overlay_len = overlay_len[0]
39
- @field_attr = @overlay[0] & Ncurses::A_ATTRIBUTES
39
+ @field_attr = @overlay[0] & Ncurses::A_ATTRIBUTES
40
40
  else
41
41
  @overlay = []
42
42
  @overlay_len = 0
@@ -61,7 +61,7 @@ module CDK
61
61
  # Rejustify the x and y positions if we need to.
62
62
  xtmp = [xplace]
63
63
  ytmp = [yplace]
64
- CDK.alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
64
+ alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
65
65
  xpos = xtmp[0]
66
66
  ypos = ytmp[0]
67
67
 
@@ -222,7 +222,7 @@ module CDK
222
222
  # This injects a character into the widget.
223
223
  def inject(input)
224
224
  pp_return = 1
225
- complete = false
225
+ @complete = false
226
226
  ret = -1
227
227
 
228
228
  self.setExitType(0)
@@ -240,7 +240,7 @@ module CDK
240
240
  if pp_return != 0
241
241
  # Check a predefined binding
242
242
  if self.checkBind(:TEMPLATE, input)
243
- complete = true
243
+ @complete = true
244
244
  else
245
245
  case input
246
246
  when CDK::ERASE
@@ -280,14 +280,14 @@ module CDK
280
280
  else
281
281
  self.setExitType(input)
282
282
  ret = @info
283
- complete = true
283
+ @complete = true
284
284
  end
285
285
  when CDK::KEY_ESC
286
286
  self.setExitType(input)
287
- complete = true
287
+ @complete = true
288
288
  when Ncurses::ERR
289
289
  self.setExitType(input)
290
- complete = true
290
+ @complete = true
291
291
  when CDK::REFRESH
292
292
  @screen.erase
293
293
  @screen.refresh
@@ -297,12 +297,12 @@ module CDK
297
297
  end
298
298
 
299
299
  # Should we call a post-process?
300
- if !complete && !(@post_process_func.nil?)
300
+ if !@complete && !(@post_process_func.nil?)
301
301
  @post_process_func.call(:TEMPLATE, self, @post_process_data, input)
302
302
  end
303
303
  end
304
304
 
305
- if !complete
305
+ if !@complete
306
306
  self.setExitType(0)
307
307
  end
308
308
 
@@ -399,7 +399,7 @@ module CDK
399
399
 
400
400
  self.drawTitle(@win)
401
401
 
402
- @win.wrefresh
402
+ wrefresh
403
403
 
404
404
  self.drawField
405
405
  end
@@ -412,7 +412,7 @@ module CDK
412
412
  unless @label_win.nil?
413
413
  Draw.writeChtype(@label_win, 0, 0, @label, CDK::HORIZONTAL,
414
414
  0, @label_len)
415
- @label_win.wrefresh
415
+ wrefresh(@label_win)
416
416
  end
417
417
 
418
418
  # Draw in the template
@@ -435,7 +435,7 @@ module CDK
435
435
  else
436
436
  self.adjustCursor(1)
437
437
  end
438
- @field_win.wrefresh
438
+ wrefresh(@field_win)
439
439
  end
440
440
 
441
441
  # Adjust the cursor for the template
@@ -446,7 +446,7 @@ module CDK
446
446
  @screen_pos += direction
447
447
  end
448
448
  @field_win.wmove(0, @screen_pos)
449
- @field_win.wrefresh
449
+ wrefresh(@field_win)
450
450
  end
451
451
 
452
452
  # Set the background attribute of the widget.
@@ -1,4 +1,4 @@
1
- require_relative 'cdk_objs'
1
+ require_relative '../cdk_objs'
2
2
 
3
3
  module CDK
4
4
  class VIEWER < CDK::CDKOBJS
@@ -35,7 +35,7 @@ module CDK
35
35
  # Rejustify the x and y positions if we need to.
36
36
  xtmp = [xplace]
37
37
  ytmp = [yplace]
38
- CDK.alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
38
+ alignxy(cdkscreen.window, xtmp, ytmp, box_width, box_height)
39
39
  xpos = xtmp[0]
40
40
  ypos = ytmp[0]
41
41
 
@@ -57,7 +57,7 @@ module CDK
57
57
  if button_count > 0
58
58
  (0...button_count).each do |x|
59
59
  button_len = []
60
- @button << CDK.char2Chtype(buttons[x], button_len, [])
60
+ @button << char2Chtype(buttons[x], button_len, [])
61
61
  @button_len << button_len[0]
62
62
  button_width += @button_len[x] + 1
63
63
  end
@@ -137,9 +137,9 @@ module CDK
137
137
  if interpret
138
138
  list_len = []
139
139
  list_pos = []
140
- @list[x] = CDK.char2Chtype(list, list_len, list_pos)
140
+ @list[x] = char2Chtype(list, list_len, list_pos)
141
141
  @list_len[x] = list_len[0]
142
- @list_pos[x] = CDK.justifyString(@box_width, @list_len[x], list_pos[0])
142
+ @list_pos[x] = justify_string(@box_width, @list_len[x], list_pos[0])
143
143
  else
144
144
  # We must convert tabs and other nonprinting characters. The curses
145
145
  # library normally does this, but we are bypassing it by writing
@@ -152,8 +152,8 @@ module CDK
152
152
  t << ' '
153
153
  len += 1
154
154
  end while (len & 7) != 0
155
- elsif CDK.CharOf(list[y].ord).match(/^[[:print:]]$/)
156
- t << CDK.CharOf(list[y].ord)
155
+ elsif charOf(list[y].ord).match(/^[[:print:]]$/)
156
+ t << charOf(list[y].ord)
157
157
  len += 1
158
158
  else
159
159
  t << Ncurses.unctrl(list[y].ord)
@@ -187,7 +187,7 @@ module CDK
187
187
  if list.size > 0 && interpret
188
188
  (0...list_size).each do |x|
189
189
  filename = ''
190
- if CDK.checkForLink(list[x], filename) == 1
190
+ if check_for_link(list[x], filename) == 1
191
191
  file_contents = []
192
192
  file_len = CDK.readFile(filename, file_contents)
193
193
 
@@ -218,7 +218,7 @@ module CDK
218
218
  else
219
219
  # Check if we have a file link in this line.
220
220
  filename = []
221
- if CDK.checkForLink(list[x], filename) == 1
221
+ if check_for_link(list[x], filename) == 1
222
222
  # We have a link, open the file.
223
223
  file_contents = []
224
224
  file_len = 0
@@ -555,10 +555,10 @@ module CDK
555
555
  pos = 0
556
556
  y = 0
557
557
  while y < @list[x].size
558
- plain_char = CDK.CharOf(@list[x][y])
558
+ plain_char = charOf(@list[x][y])
559
559
 
560
560
  pos += 1
561
- if @CDK.CharOf(pattern[pos-1]) != plain_char
561
+ if charOf(pattern[pos-1]) != plain_char
562
562
  y -= (pos - 1)
563
563
  pos = 0
564
564
  elsif pos == pattern.size
@@ -578,10 +578,10 @@ module CDK
578
578
  y = 0
579
579
  pos = 0
580
580
  while y < @list[x].size
581
- plain_char = CDK.CharOf(@list[x][y])
581
+ plain_char = charOf(@list[x][y])
582
582
 
583
583
  pos += 1
584
- if CDK.CharOf(pattern[pos-1]) != plain_char
584
+ if charOf(pattern[pos-1]) != plain_char
585
585
  y -= (pos - 1)
586
586
  pos = 0
587
587
  elsif pos == pattern.size
@@ -596,7 +596,7 @@ module CDK
596
596
  end
597
597
  return found
598
598
  end
599
-
599
+
600
600
  # This allows us to 'jump' to a given line in the file.
601
601
  def jumpToLine
602
602
  newline = CDK::SCALE.new(@screen, CDK::CENTER, CDK::CENTER,
@@ -637,7 +637,7 @@ module CDK
637
637
  # Box it if it was asked for.
638
638
  if box
639
639
  Draw.drawObjBox(@win, self)
640
- @win.wrefresh
640
+ wrefresh
641
641
  end
642
642
 
643
643
  # Draw the info in the viewer.
@@ -660,7 +660,7 @@ module CDK
660
660
  # Highlight the current button.
661
661
  (0...@button_len[@current_button]).each do |x|
662
662
  # Strip the character of any extra attributes.
663
- character = CDK.CharOf(@button[@current_button][x])
663
+ character = charOf(@button[@current_button][x])
664
664
 
665
665
  # Add the character into the window.
666
666
  @win.mvwaddch(@box_height - 2, @button_pos[@current_button] + x,
@@ -668,7 +668,7 @@ module CDK
668
668
  end
669
669
 
670
670
  # Refresh the window.
671
- @win.wrefresh
671
+ wrefresh
672
672
  end
673
673
 
674
674
  # This sets the background attribute of the widget.
@@ -765,7 +765,7 @@ module CDK
765
765
  # Box it if we have to.
766
766
  if @box
767
767
  Draw.drawObjBox(@win, self)
768
- @win.wrefresh
768
+ wrefresh
769
769
  end
770
770
 
771
771
  # Draw the separation line.
@@ -808,5 +808,75 @@ module CDK
808
808
  def object_type
809
809
  :VIEWER
810
810
  end
811
+
812
+ private
813
+
814
+ # This function checks to see if a link has been requested
815
+ def check_for_link (line, filename)
816
+ f_pos = 0
817
+ x = 3
818
+ if line.nil?
819
+ return -1
820
+ end
821
+
822
+ # Strip out the filename.
823
+ if line[0] == L_MARKER && line[1] == 'F' && line[2] == '='
824
+ while x < line.size
825
+ if line[x] == R_MARKER
826
+ break
827
+ end
828
+ if f_pos < CDK_PATHMAX
829
+ filename << line[x]
830
+ f_pos += 1
831
+ end
832
+ x += 1
833
+ end
834
+ end
835
+ return f_pos != 0
836
+ end
837
+
838
+ # This allows the user to view information.
839
+ def self.viewInfo(screen, title, info, count, buttons, button_count,
840
+ interpret)
841
+ selected = -1
842
+
843
+ # Create the file viewer to view the file selected.
844
+ viewer = CDK::VIEWER.new(screen, CDK::CENTER, CDK::CENTER, -6, -16,
845
+ buttons, button_count, Ncurses::A_REVERSE, true, true)
846
+
847
+ # Set up the viewer title, and the contents to the widget.
848
+ viewer.set(title, info, count, Ncurses::A_REVERSE, interpret, true, true)
849
+
850
+ # Activate the viewer widget.
851
+ selected = viewer.activate([])
852
+
853
+ # Make sure they exited normally.
854
+ if viewer.exit_type != :NORMAL
855
+ viewer.destroy
856
+ return -1
857
+ end
858
+
859
+ # Clean up and return the button index selected
860
+ viewer.destroy
861
+ return selected
862
+ end
863
+
864
+ # This allows the user to view a file.
865
+ def self.viewFile(screen, title, filename, buttons, button_count)
866
+ info = []
867
+ result = 0
868
+
869
+ # Open the file and read the contents.
870
+ lines = CDK.readFile(filename, info)
871
+
872
+ # If we couldn't read the file, return an error.
873
+ if lines == -1
874
+ result = lines
875
+ else
876
+ result = self.viewInfo(screen, title, info, lines, buttons,
877
+ button_count, true)
878
+ end
879
+ return result
880
+ end
811
881
  end
812
882
  end