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.
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/entry.rb CHANGED
@@ -2,11 +2,118 @@ require 'rndk'
2
2
 
3
3
  module RNDK
4
4
 
5
- class ENTRY < RNDK::Widget
5
+ # A text-entry box with a label and an entry field.
6
+ #
7
+ # ## Keybindings
8
+ #
9
+ # Left Arrow:: Moves the cursor to the left.
10
+ # CTRL-B:: Moves the cursor to the left.
11
+ # Right Arrow:: Moves the cursor to the right.
12
+ # CTRL-F:: Moves the cursor to the right.
13
+ # Delete:: Deletes the character at the cursor.
14
+ # Backspace:: Deletes the character before cursor,
15
+ # moves cursor left.
16
+ # CTRL-V:: Pastes from the paste buffer into the widget
17
+ # CTRL-X:: Cuts the contents from the widget into the
18
+ # paste buffer.
19
+ # CTRL-Y:: Copies the contents of the widget into the
20
+ # paste buffer.
21
+ # CTRL-U:: Erases the contents of the widget.
22
+ # CTRL-A:: Moves the cursor to the beginning of the entry field.
23
+ # CTRL-E:: Moves the cursor to the end of the entry field.
24
+ # CTRL-T:: Transposes the character under the cursor
25
+ # with the character to the right.
26
+ # Return:: Exits the widget and returns the text typed
27
+ # into the field.
28
+ # It also sets the widget data exitType to `:NORMAL`.
29
+ # Tab:: Exits the widget and returns the text typed
30
+ # into the field.
31
+ # It also sets the widget data exitType to `:NORMAL`.
32
+ # Escape:: Exits the widget and returns `nil`.
33
+ # It also sets the widget data exitType to `:ESCAPE_HIT`.
34
+ # Ctrl-L:: Refreshes the screen.
35
+ #
36
+ # ## Behavior
37
+ #
38
+ # When passing the `disp_type` argument to Entry#initialize,
39
+ # you can modify the Entry behavior when receiving chars
40
+ # from the user.
41
+ #
42
+ # Send one of those for an action:
43
+ #
44
+ # `:CHAR`:: Only accepts alphabetic characters.
45
+ # `:LCHAR`:: Only accepts alphabetic characters.
46
+ # Maps the character to lower case when a character
47
+ # has been accepted.
48
+ # `:UCHAR`:: Only accepts alphabetic characters.
49
+ # Maps the character to upper case when a character
50
+ # has been accepted.
51
+ # `:HCHAR`:: Only accepts alphabetic characters. Displays
52
+ # a period (.) when a character has been
53
+ # accepted.
54
+ # `:UHCHAR`:: Only accepts alphabetic characters. Displays
55
+ # a period (.) and maps the character to upper
56
+ # case when a character has been accepted.
57
+ # `:LHCHAR`:: Only accepts alphabetic characters. Displays
58
+ # a period (.) and maps the character to lower
59
+ # case when a character has been accepted.
60
+ # `:INT`:: Only accepts numeric characters.
61
+ # `:HINT`:: Only accepts numeric characters. Displays a
62
+ # period (.) when a character has been
63
+ # accepted.
64
+ # `:MIXED`:: Accepts any character types.
65
+ # `:LMIXED`:: Accepts any character types. Maps the char-
66
+ # acter to lower case when an alphabetic char-
67
+ # acter has been accepted.
68
+ # `:UMIXED`:: Accepts any character types. Maps the char-
69
+ # acter to upper case when an alphabetic char-
70
+ # acter has been accepted.
71
+ # `:HMIXED`:: Accepts any character types. Displays a
72
+ # period (.) when a character has been
73
+ # accepted.
74
+ # `:LHMIXED`:: Accepts any character types. Displays a
75
+ # period (.) and maps the character to lower
76
+ # case when a character has been accepted.
77
+ # `:UHMIXED`:: Accepts any character types. Displays a
78
+ # period (.) and maps the character to upper
79
+ # case when a character has been accepted.
80
+ # `:VIEWONLY`:: Uneditable field.
81
+ #
82
+ class Entry < Widget
6
83
  attr_accessor :info, :left_char, :screen_col
7
84
  attr_reader :win, :box_height, :box_width, :max, :field_width
8
85
  attr_reader :min, :max
9
86
 
87
+
88
+ # Creates an Entry Widget.
89
+ #
90
+ # ## Arguments
91
+ #
92
+ # * `xplace` is the x position - can be an integer or
93
+ # `RNDK::LEFT`, `RNDK::RIGHT`, `RNDK::CENTER`.
94
+ # * `yplace` is the y position - can be an integer or
95
+ # `RNDK::TOP`, `RNDK::BOTTOM`, `RNDK::CENTER`.
96
+ # * `title` can be more than one line - just split them
97
+ # with `\n`s.
98
+ # * `label` is the String that will appear on the label
99
+ # of the Entry field.
100
+ # * `field_attr` is the attribute/color of the characters
101
+ # that are typed in.
102
+ # * `filler_char` is the character to display on the
103
+ # empty spaces in the entry field.
104
+ # * `disp_type` tells how the entry field will behave.
105
+ # _See main Entry documentation_.
106
+ # * `f_width` is the width of the field. It it's 0,
107
+ # will be created with full width of the screen.
108
+ # If it's a negative value, will create with full width
109
+ # minus that value.
110
+ # * `min` is the minimum number of characters the user
111
+ # must insert before can exit the entry field.
112
+ # * `max` is the maximum number of characters the user
113
+ # can enter on the entry field.
114
+ # * `box` if the Widget is drawn with a box outside it.
115
+ # * `shadow` turns on/off the shadow around the Widget.
116
+ #
10
117
  def initialize(rndkscreen,
11
118
  xplace,
12
119
  yplace,
@@ -21,20 +128,23 @@ module RNDK
21
128
  box,
22
129
  shadow)
23
130
  super()
24
- parent_width = Ncurses.getmaxx rndkscreen.window
131
+
132
+ parent_width = Ncurses.getmaxx rndkscreen.window
25
133
  parent_height = Ncurses.getmaxy rndkscreen.window
134
+
26
135
  field_width = f_width
27
- box_width = 0
136
+ box_width = 0
137
+
28
138
  xpos = xplace
29
139
  ypos = yplace
30
140
 
31
- self.set_box(box)
32
- box_height = @border_size * 2 + 1
141
+ self.set_box box
142
+ box_height = @border_size*2 + 1
33
143
 
34
144
  # If the field_width is a negative value, the field_width will be
35
145
  # COLS-field_width, otherwise the field_width will be the given width.
36
146
  field_width = RNDK.setWidgetDimension(parent_width, field_width, 0)
37
- box_width = field_width + 2 * @border_size
147
+ box_width = field_width + 2*@border_size
38
148
 
39
149
  # Set some basic values of the entry field.
40
150
  @label = 0
@@ -128,16 +238,16 @@ module RNDK
128
238
  # Update the screen and pointer
129
239
  if entry.screen_col != entry.field_width - 1
130
240
  front = (entry.info[0...(entry.screen_col + entry.left_char)] or '')
131
- back = (entry.info[(entry.screen_col + entry.left_char)..-1] or '')
241
+ back = (entry.info[(entry.screen_col + entry.left_char)..-1] or '')
242
+
132
243
  entry.info = front + plainchar.chr + back
133
244
  entry.screen_col += 1
245
+
134
246
  else
135
247
  # Update the character pointer.
136
248
  entry.info << plainchar
137
249
  # Do not update the pointer if it's the last character
138
- if entry.info.size < entry.max
139
- entry.left_char += 1
140
- end
250
+ entry.left_char += 1 if (entry.info.size < entry.max)
141
251
  end
142
252
 
143
253
  # Update the entry field.
@@ -147,17 +257,25 @@ module RNDK
147
257
 
148
258
  # Do we want a shadow?
149
259
  if shadow
150
- @shadow_win = Ncurses.subwin(rndkscreen.window, box_height, box_width,
151
- ypos + 1, xpos + 1)
260
+ @shadow_win = Ncurses.subwin(rndkscreen.window,
261
+ box_height,
262
+ box_width,
263
+ ypos + 1,
264
+ xpos + 1)
152
265
  end
153
266
 
154
- rndkscreen.register(:ENTRY, self)
267
+ rndkscreen.register(:entry, self)
155
268
  end
156
269
 
157
- # This means you want to use the given entry field. It takes input
158
- # from the keyboard, and when it's done, it fills the entry info
159
- # element of the structure with what was typed.
160
- def activate(actions)
270
+ # Activates the Entry Widget, letting the user interact with it.
271
+ #
272
+ # `actions` is an Array of characters. If it's non-null,
273
+ # will #inject each char on it into the Widget.
274
+ #
275
+ # @return The text currently inside the entry field (and
276
+ # `exit_type` will be `:NORMAL`) or `nil` (and
277
+ # `exit_type` will be `:ESCAPE_HIT`).
278
+ def activate(actions=[])
161
279
  input = 0
162
280
  ret = 0
163
281
 
@@ -192,24 +310,8 @@ module RNDK
192
310
  end
193
311
  end
194
312
 
195
- def setPositionToEnd
196
- if @info.size >= @field_width
197
- if @info.size < @max
198
- char_count = @field_width - 1
199
- @left_char = @info.size - char_count
200
- @screen_col = char_count
201
- else
202
- @left_char = @info.size - @field_width
203
- @screen_col = @info.size - 1
204
- end
205
- else
206
- @left_char = 0
207
- @screen_col = @info.size
208
- end
209
- end
210
-
211
- # This injects a single character into the widget.
212
- def inject(input)
313
+ # @see Widget#inject
314
+ def inject input
213
315
  pp_return = 1
214
316
  ret = 1
215
317
  complete = false
@@ -221,25 +323,29 @@ module RNDK
221
323
  self.drawField
222
324
 
223
325
  unless @pre_process_func.nil?
224
- pp_return = @pre_process_func.call(:ENTRY, self,
326
+ pp_return = @pre_process_func.call(:entry, self,
225
327
  @pre_process_data, input)
226
328
  end
227
329
 
228
330
  # Should we continue?
229
331
  if pp_return != 0
332
+
230
333
  # Check a predefined binding
231
- if self.checkBind(:ENTRY, input)
334
+ if self.checkBind(:entry, input)
232
335
  complete = true
336
+
233
337
  else
234
338
  curr_pos = @screen_col + @left_char
235
339
 
236
340
  case input
237
341
  when Ncurses::KEY_UP, Ncurses::KEY_DOWN
238
342
  RNDK.beep
343
+
239
344
  when Ncurses::KEY_HOME
240
345
  @left_char = 0
241
346
  @screen_col = 0
242
347
  self.drawField
348
+
243
349
  when RNDK::TRANSPOSE
244
350
  if curr_pos >= @info.size - 1
245
351
  RNDK.beep
@@ -249,9 +355,11 @@ module RNDK
249
355
  @info[curr_pos + 1] = holder
250
356
  self.drawField
251
357
  end
358
+
252
359
  when Ncurses::KEY_END
253
360
  self.setPositionToEnd
254
361
  self.drawField
362
+
255
363
  when Ncurses::KEY_LEFT
256
364
  if curr_pos <= 0
257
365
  RNDK.beep
@@ -263,6 +371,7 @@ module RNDK
263
371
  @screen_col -= 1
264
372
  Ncurses.wmove(@field_win, 0, @screen_col)
265
373
  end
374
+
266
375
  when Ncurses::KEY_RIGHT
267
376
  if curr_pos >= @info.size
268
377
  RNDK.beep
@@ -275,6 +384,7 @@ module RNDK
275
384
  @screen_col += 1
276
385
  Ncurses.wmove(@field_win, 0, @screen_col)
277
386
  end
387
+
278
388
  when Ncurses::KEY_BACKSPACE, Ncurses::KEY_DC
279
389
  if @disp_type == :VIEWONLY
280
390
  RNDK.beep
@@ -310,11 +420,13 @@ module RNDK
310
420
  when RNDK::KEY_ESC
311
421
  self.set_exit_type(input)
312
422
  complete = true
423
+
313
424
  when RNDK::ERASE
314
425
  if @info.size != 0
315
426
  self.clean
316
427
  self.drawField
317
428
  end
429
+
318
430
  when RNDK::CUT
319
431
  if @info.size != 0
320
432
  @@g_paste_buffer = @info.clone
@@ -323,19 +435,22 @@ module RNDK
323
435
  else
324
436
  RNDK.beep
325
437
  end
438
+
326
439
  when RNDK::COPY
327
440
  if @info.size != 0
328
441
  @@g_paste_buffer = @info.clone
329
442
  else
330
443
  RNDK.beep
331
444
  end
445
+
332
446
  when RNDK::PASTE
333
447
  if @@g_paste_buffer != 0
334
- self.setValue(@@g_paste_buffer)
448
+ self.set_text(@@g_paste_buffer)
335
449
  self.drawField
336
450
  else
337
451
  RNDK.beep
338
452
  end
453
+
339
454
  when RNDK::KEY_TAB, RNDK::KEY_RETURN, Ncurses::KEY_ENTER
340
455
  if @info.size >= @min
341
456
  self.set_exit_type(input)
@@ -344,9 +459,11 @@ module RNDK
344
459
  else
345
460
  RNDK.beep
346
461
  end
462
+
347
463
  when Ncurses::ERR
348
464
  self.set_exit_type(input)
349
465
  complete = true
466
+
350
467
  when RNDK::REFRESH
351
468
  @screen.erase
352
469
  @screen.refresh
@@ -356,7 +473,7 @@ module RNDK
356
473
  end
357
474
 
358
475
  if !complete && !(@post_process_func.nil?)
359
- @post_process_func.call(:ENTRY, self, @post_process_data, input)
476
+ @post_process_func.call(:entry, self, @post_process_data, input)
360
477
  end
361
478
  end
362
479
 
@@ -368,15 +485,14 @@ module RNDK
368
485
  return ret
369
486
  end
370
487
 
371
- # This moves the entry field to the given location.
488
+ # @see Widget#move
372
489
  def move(xplace, yplace, relative, refresh_flag)
373
490
  windows = [@win, @field_win, @label_win, @shadow_win]
374
- self.move_specific(xplace, yplace, relative, refresh_flag,
375
- windows, [])
491
+
492
+ self.move_specific(xplace, yplace, relative, refresh_flag, windows, [])
376
493
  end
377
494
 
378
- # This erases the information in the entry field and redraws
379
- # a clean and empty entry field.
495
+ # Clears the text from the entry field.
380
496
  def clean
381
497
  width = @field_width
382
498
 
@@ -393,20 +509,17 @@ module RNDK
393
509
  Ncurses.wrefresh @field_win
394
510
  end
395
511
 
396
- # This draws the entry field.
397
- def draw(box)
512
+ # Draws the Widget on the Screen.
513
+ #
514
+ # If `box` is true, it is drawn with a box.
515
+ def draw box
398
516
  # Did we ask for a shadow?
399
- unless @shadow_win.nil?
400
- Draw.drawShadow @shadow_win
401
- end
517
+ Draw.drawShadow @shadow_win unless @shadow_win.nil?
402
518
 
403
519
  # Box the widget if asked.
404
- if box
405
- Draw.drawObjBox(@win, self)
406
- end
520
+ Draw.drawObjBox(@win, self) if box
407
521
 
408
522
  self.drawTitle @win
409
-
410
523
  Ncurses.wrefresh @win
411
524
 
412
525
  # Draw in the label to the widget.
@@ -418,35 +531,14 @@ module RNDK
418
531
  RNDK::HORIZONTAL,
419
532
  0,
420
533
  @label_len)
534
+
421
535
  Ncurses.wrefresh @label_win
422
536
  end
423
537
 
424
538
  self.drawField
425
539
  end
426
540
 
427
- def drawField
428
- # Draw in the filler characters.
429
- Ncurses.mvwhline(@field_win, 0, 0, @filler.ord, @field_width)
430
-
431
- # If there is information in the field then draw it in.
432
- if !(@info.nil?) && @info.size > 0
433
- # Redraw the field.
434
- if Display.is_hidden_display_type(@disp_type)
435
- (@left_char...@info.size).each do |x|
436
- Ncurses.mvwaddch(@field_win, 0, x - @left_char, @hidden)
437
- end
438
- else
439
- (@left_char...@info.size).each do |x|
440
- Ncurses.mvwaddch(@field_win, 0, x - @left_char, @info[x].ord | @field_attr)
441
- end
442
- end
443
- Ncurses.wmove(@field_win, 0, @screen_col)
444
- end
445
-
446
- Ncurses.wrefresh @field_win
447
- end
448
-
449
- # This erases an entry widget from the screen.
541
+ # @see Widget#erase
450
542
  def erase
451
543
  if self.valid_widget?
452
544
  RNDK.window_erase(@field_win)
@@ -456,7 +548,7 @@ module RNDK
456
548
  end
457
549
  end
458
550
 
459
- # This destroys an entry widget.
551
+ # @see Widget#destroy
460
552
  def destroy
461
553
  self.cleanTitle
462
554
 
@@ -465,21 +557,25 @@ module RNDK
465
557
  RNDK.window_delete(@shadow_win)
466
558
  RNDK.window_delete(@win)
467
559
 
468
- self.clean_bindings(:ENTRY)
560
+ self.clean_bindings(:entry)
469
561
 
470
- RNDK::Screen.unregister(:ENTRY, self)
562
+ RNDK::Screen.unregister(:entry, self)
471
563
  end
472
564
 
473
- # This sets specific attributes of the entry field.
474
- def set(value, min, max, box)
475
- self.setValue(value)
476
- self.setMin(min)
477
- self.setMax(max)
565
+ # Sets multiple attributes of the Widget.
566
+ #
567
+ # See Entry#initialize.
568
+ def set(text, min, max, box)
569
+ self.set_text text
570
+ self.set_min min
571
+ self.set_max max
572
+
573
+ ## FIXME TODO
574
+ ## what about the `box`?
478
575
  end
479
576
 
480
- # This removes the old information in the entry field and keeps
481
- # the new information given.
482
- def setValue(new_value)
577
+ # Sets the current text on the entry field.
578
+ def set_text new_value
483
579
  if new_value.nil?
484
580
  @info = ''
485
581
 
@@ -492,66 +588,70 @@ module RNDK
492
588
  end
493
589
  end
494
590
 
495
- def getValue
591
+ # Returns the current text on the entry field.
592
+ def get_text
496
593
  return @info
497
594
  end
498
595
 
499
- # This sets the maximum length of the string that will be accepted
500
- def setMax(max)
596
+ # Sets the maximum length of the string that
597
+ # will be accepted.
598
+ def set_max max
501
599
  @max = max
502
600
  end
503
601
 
504
- def getMax
602
+ def get_max
505
603
  @max
506
604
  end
507
605
 
508
- # This sets the minimum length of the string that will be accepted.
509
- def setMin(min)
606
+ # Sets the minimum length of the string that
607
+ # will be accepted.
608
+ def set_min min
510
609
  @min = min
511
610
  end
512
611
 
513
- def getMin
612
+ def get_min
514
613
  @min
515
614
  end
516
615
 
517
- # This sets the filler character to be used in the entry field.
518
- def setFillerChar(filler_char)
616
+ # Sets the character to draw unused space on the field.
617
+ def set_filler_char(filler_char)
519
618
  @filler = filler_char
520
619
  end
521
620
 
522
- def getFillerChar
621
+ def get_filler_char
523
622
  @filler
524
623
  end
525
624
 
526
- # This sets the character to use when a hidden type is used.
527
- def setHiddenChar(hidden_characer)
528
- @hidden = hidden_character
625
+ # Sets the character to hide input when a hidden
626
+ # type is used.
627
+ #
628
+ # See Entry#initialize
629
+ def set_hidden_char char
630
+ @hidden = char
529
631
  end
530
632
 
531
- def getHiddenChar
633
+ def get_hidden_char
532
634
  @hidden
533
635
  end
534
636
 
535
- # This sets the background attribute of the widget.
536
- def set_bg_attrib(attrib)
637
+ # Sets the background attribute/color of the widget.
638
+ def set_bg_attrib attrib
537
639
  Ncurses.wbkgd(@win, attrib)
538
640
  Ncurses.wbkgd(@field_win, attrib)
539
- unless @label_win.nil?
540
- @label_win.wbkgd(attrib)
541
- end
641
+
642
+ @label_win.wbkgd(attrib) unless @label_win.nil?
542
643
  end
543
644
 
544
- # This sets the attribute of the entry field.
645
+ # Sets the background attribute/color of the entry field.
646
+ #
647
+ # `cursor` tells if we hide the blinking cursor or not.
648
+ # See Ncurses#curs_set.
545
649
  def set_highlight(highlight, cursor)
546
650
  Ncurses.wbkgd(@field_win, highlight)
547
651
  @field_attr = highlight
548
- Ncurses.curs_set(cursor)
549
- # FIXME(original) - if (cursor) { move the cursor to this widget }
550
- end
652
+ Ncurses.curs_set cursor
551
653
 
552
- # This sets the entry field callback function.
553
- def setCB(callback)
554
- @callbackfn = callback
654
+ # FIXME(original) - if (cursor) { move the cursor to this widget }
555
655
  end
556
656
 
557
657
  def focus
@@ -560,16 +660,66 @@ module RNDK
560
660
  end
561
661
 
562
662
  def unfocus
563
- self.draw(box)
663
+ self.draw box
564
664
  Ncurses.wrefresh @field_win
565
665
  end
566
666
 
667
+ # @see Widget#position
567
668
  def position
568
- super(@win)
669
+ super @win
569
670
  end
570
671
 
571
672
  def object_type
572
- :ENTRY
673
+ :entry
674
+ end
675
+
676
+ # Allows the programmer to set a different widget input handler.
677
+ #
678
+ # @note Unless you're very low-level and know what you're doing
679
+ # you shouldn't need this.
680
+ def setCB(callback)
681
+ @callbackfn = callback
682
+ end
683
+
684
+ protected
685
+
686
+ def drawField
687
+ # Draw in the filler characters.
688
+ Ncurses.mvwhline(@field_win, 0, 0, @filler.ord, @field_width)
689
+
690
+ # If there is information in the field then draw it in.
691
+ if (not @info.nil?) and (@info.size > 0)
692
+ # Redraw the field.
693
+ if Display.is_hidden_display_type(@disp_type)
694
+ (@left_char...@info.size).each do |x|
695
+ Ncurses.mvwaddch(@field_win, 0, x - @left_char, @hidden)
696
+ end
697
+ else
698
+ (@left_char...@info.size).each do |x|
699
+ Ncurses.mvwaddch(@field_win, 0, x - @left_char, @info[x].ord | @field_attr)
700
+ end
701
+ end
702
+ Ncurses.wmove(@field_win, 0, @screen_col)
703
+ end
704
+
705
+ Ncurses.wrefresh @field_win
573
706
  end
707
+
708
+ def setPositionToEnd
709
+ if @info.size >= @field_width
710
+ if @info.size < @max
711
+ char_count = @field_width - 1
712
+ @left_char = @info.size - char_count
713
+ @screen_col = char_count
714
+ else
715
+ @left_char = @info.size - @field_width
716
+ @screen_col = @info.size - 1
717
+ end
718
+ else
719
+ @left_char = 0
720
+ @screen_col = @info.size
721
+ end
722
+ end
723
+
574
724
  end
575
725
  end
data/lib/rndk/fscale.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rndk/scale'
2
2
 
3
3
  module RNDK
4
- class FSCALE < RNDK::SCALE
4
+ class FSCALE < SCALE
5
5
  def initialize(rndkscreen,
6
6
  xplace,
7
7
  yplace,