rbcurse 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CHANGELOG +20 -0
  2. data/NOTES +45 -0
  3. data/README.markdown +47 -68
  4. data/TODO2.txt +29 -32
  5. data/VERSION +1 -1
  6. data/examples/abasiclist.rb +2 -0
  7. data/examples/app.rb +2 -2
  8. data/examples/app.sample +10 -0
  9. data/examples/appemail.rb +29 -2
  10. data/examples/appemaillb.rb +1 -1
  11. data/examples/appgcompose.rb +9 -2
  12. data/examples/appmethods.rb +69 -0
  13. data/examples/atree.rb +2 -2
  14. data/examples/menu1.rb +1 -1
  15. data/examples/newtesttabp.rb +8 -5
  16. data/examples/qdfilechooser.rb +6 -3
  17. data/examples/rfe.rb +71 -16
  18. data/examples/rmail.rb +76 -7
  19. data/examples/sqlc.rb +14 -3
  20. data/examples/sqlm.rb +3 -3
  21. data/examples/term.rb +48 -0
  22. data/examples/term2.rb +48 -21
  23. data/examples/test1.rb +2 -2
  24. data/examples/test2.rb +162 -71
  25. data/examples/testapp.rb +2 -2
  26. data/examples/testapp2.rb +1 -1
  27. data/examples/testchars.rb +47 -46
  28. data/examples/testcombo.rb +2 -2
  29. data/examples/testkeypress.rb +2 -2
  30. data/examples/testlistbox.rb +2 -2
  31. data/examples/testmenu.rb +1 -1
  32. data/examples/testmulticomp.rb +1 -1
  33. data/examples/testmultispl.rb +1 -1
  34. data/examples/testree.rb +1 -22
  35. data/examples/testscroller.rb +2 -2
  36. data/examples/testscrolllb.rb +2 -2
  37. data/examples/testscrollp.rb +2 -2
  38. data/examples/testscrollta.rb +2 -2
  39. data/examples/testscrolltable.rb +2 -2
  40. data/examples/testsplit.rb +2 -2
  41. data/examples/testsplit2.rb +2 -2
  42. data/examples/testsplit3.rb +2 -2
  43. data/examples/testsplit3_1.rb +2 -2
  44. data/examples/testsplit3a.rb +2 -2
  45. data/examples/testsplit3b.rb +2 -2
  46. data/examples/testsplitta.rb +2 -2
  47. data/examples/testsplittv.rb +2 -2
  48. data/examples/testsplittvv.rb +2 -2
  49. data/examples/testtable.rb +2 -2
  50. data/examples/testtabp.rb +2 -2
  51. data/examples/testtodo.rb +1 -1
  52. data/examples/testtpane.rb +2 -2
  53. data/examples/testtpane2.rb +2 -2
  54. data/examples/testtpanetable.rb +6 -5
  55. data/examples/testvimsplit.rb +2 -2
  56. data/examples/viewtodo.rb +1 -1
  57. data/lib/rbcurse.rb +2 -1
  58. data/lib/rbcurse/action.rb +1 -1
  59. data/lib/rbcurse/app.rb +51 -14
  60. data/lib/rbcurse/applicationheader.rb +1 -1
  61. data/lib/rbcurse/celleditor.rb +1 -1
  62. data/lib/rbcurse/colormap.rb +11 -11
  63. data/lib/rbcurse/comboboxcellrenderer.rb +1 -1
  64. data/lib/rbcurse/extras/bottomline.rb +22 -10
  65. data/lib/rbcurse/extras/directorylist.rb +14 -1
  66. data/lib/rbcurse/extras/divider.rb +1 -1
  67. data/lib/rbcurse/extras/listselectable.rb +2 -2
  68. data/lib/rbcurse/extras/masterdetail.rb +3 -1
  69. data/lib/rbcurse/extras/scrollbar.rb +1 -1
  70. data/lib/rbcurse/extras/stdscrwindow.rb +75 -24
  71. data/lib/rbcurse/extras/tabular.rb +8 -3
  72. data/lib/rbcurse/extras/viewer.rb +18 -2
  73. data/lib/rbcurse/io.rb +26 -13
  74. data/lib/rbcurse/keylabelprinter.rb +3 -2
  75. data/lib/rbcurse/listcellrenderer.rb +1 -0
  76. data/lib/rbcurse/listkeys.rb +3 -2
  77. data/lib/rbcurse/listselectable.rb +4 -3
  78. data/lib/rbcurse/rbasiclistbox.rb +12 -5
  79. data/lib/rbcurse/rcombo.rb +2 -2
  80. data/lib/rbcurse/rcommandwindow.rb +5 -3
  81. data/lib/rbcurse/rdialogs.rb +8 -2
  82. data/lib/rbcurse/rlistbox.rb +10 -2
  83. data/lib/rbcurse/rmenu.rb +4 -4
  84. data/lib/rbcurse/rmessagebox.rb +10 -5
  85. data/lib/rbcurse/rmulticontainer.rb +21 -8
  86. data/lib/rbcurse/rmultisplit.rb +2 -2
  87. data/lib/rbcurse/rmultitextview.rb +5 -3
  88. data/lib/rbcurse/rpopupmenu.rb +3 -3
  89. data/lib/rbcurse/rprogress.rb +3 -2
  90. data/lib/rbcurse/rscrollform.rb +2 -2
  91. data/lib/rbcurse/rscrollpane.rb +9 -9
  92. data/lib/rbcurse/rsplitpane.rb +2 -2
  93. data/lib/rbcurse/rsplitpane2.rb +2 -2
  94. data/lib/rbcurse/rtabbedpane.rb +48 -12
  95. data/lib/rbcurse/rtabbedwindow.rb +4 -4
  96. data/lib/rbcurse/rtable.rb +6 -3
  97. data/lib/rbcurse/rtextarea.rb +8 -8
  98. data/lib/rbcurse/rtextview.rb +3 -2
  99. data/lib/rbcurse/rtree.rb +2 -2
  100. data/lib/rbcurse/rviewport.rb +2 -2
  101. data/lib/rbcurse/rvimsplit.rb +3 -2
  102. data/lib/rbcurse/rwidget.rb +63 -26
  103. data/lib/rbcurse/scrollable.rb +1 -1
  104. data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
  105. data/lib/rbcurse/table/tabledatecellrenderer.rb +1 -1
  106. data/lib/rbcurse/tree/treemodel.rb +1 -1
  107. data/lib/rbcurse/vieditable.rb +1 -0
  108. data/lib/ver/ncurses.rb +122 -4
  109. data/lib/ver/panel.rb +162 -0
  110. data/lib/ver/window.rb +262 -120
  111. metadata +19 -7
  112. data/examples/keytest.rb +0 -178
  113. data/examples/mpad2.rb +0 -156
data/lib/rbcurse/rmenu.rb CHANGED
@@ -21,11 +21,11 @@ NOTE on 2010-09-10 11:40 : this interface is based on Java's and is not block fr
21
21
 
22
22
  =end
23
23
  require 'rubygems'
24
- require 'ncurses'
24
+ #require 'ncurses'
25
25
  require 'logger'
26
26
  require 'rbcurse'
27
27
 
28
- include Ncurses
28
+ #include Ncurses # FFI 2011-09-8
29
29
  include RubyCurses
30
30
  module RubyCurses
31
31
  extend self
@@ -388,7 +388,7 @@ module RubyCurses
388
388
  return if @window.nil?
389
389
  @visible = false
390
390
  panel = @window.panel
391
- Ncurses::Panel.del_panel(panel) if !panel.nil?
391
+ Ncurses::Panel.del_panel(panel.pointer) if !panel.nil?
392
392
  @window.delwin if !@window.nil?
393
393
  @items.each do |item|
394
394
  #next if item == :SEPARATOR
@@ -662,7 +662,7 @@ module RubyCurses
662
662
  $log.debug "DESTRY menubar "
663
663
  @visible = false
664
664
  panel = @window.panel
665
- Ncurses::Panel.del_panel(panel) if !panel.nil?
665
+ Ncurses::Panel.del_panel(panel.pointer) if !panel.nil?
666
666
  @window.delwin if !@window.nil?
667
667
  @items.each do |item|
668
668
  item.destroy
@@ -214,7 +214,7 @@ module RubyCurses
214
214
  def print_borders
215
215
  width = @layout[:width]
216
216
  height = @layout[:height]
217
- @window.print_border_mb 1,2, height, width, $normalcolor, A_REVERSE
217
+ @window.print_border_mb 1,2, height, width, $normalcolor, FFI::NCurses::A_REVERSE
218
218
  =begin
219
219
  start = 2
220
220
  hline = "+%s+" % [ "-"*(width-((start+1)*2)) ]
@@ -268,7 +268,11 @@ module RubyCurses
268
268
  # 2008-12-30 19:45 experimenting with label so we can get justify and wrapping.
269
269
  #@window.printstring( row, @message_col , message, color=$reversecolor)
270
270
  #$log.debug " print_message: row #{row}, col #{@message_col} "
271
- message_label = RubyCurses::Label.new @form, {'text' => message, "name"=>"message_label","row" => row, "col" => @message_col, "display_length" => display_length, "height" => @message_height, "attr"=>"reverse"}
271
+ #message_label = RubyCurses::Label.new @form, {'text' => message, "name"=>"message_label","row" => row, "col" => @message_col, "display_length" => display_length, "height" => @message_height, "attr"=>"reverse"}
272
+ # 2011-09-20 trying to take care of when user changes color and bgcolor while calling.
273
+ clr = @color || :black
274
+ bgclr = @bgcolor || :white
275
+ message_label = RubyCurses::Label.new @form, {'text' => message, "name"=>"message_label","row" => row, "col" => @message_col, "display_length" => display_length, "height" => @message_height, 'bgcolor' => bgclr , 'color' => clr}
272
276
 
273
277
  end
274
278
  def print_input
@@ -280,7 +284,7 @@ module RubyCurses
280
284
  c = @message_col
281
285
  disp_len = @layout[:width]-8
282
286
  defaultvalue = @default_value || ""
283
- input_config = @config["input_config"] || {}
287
+ input_config = @config["input_config"] || {} # see test1.rb for usage example
284
288
  case @type.to_s
285
289
  when "input"
286
290
  @input = RubyCurses::Field.new @form, input_config do
@@ -337,9 +341,10 @@ module RubyCurses
337
341
  @layout = { :height => height, :width => width, :top => top, :left => left }
338
342
  end
339
343
  def destroy
340
- $log.debug "DESTROY : widget"
344
+ $log.debug "DESTROY : messagebox"
341
345
  panel = @window.panel
342
- Ncurses::Panel.del_panel(panel) if !panel.nil?
346
+ #Ncurses::Panel.del_panel(panel) if !panel.nil?
347
+ panel.del_panel if !panel.nil?
343
348
  @window.delwin if !@window.nil?
344
349
  end
345
350
  end
@@ -9,11 +9,11 @@
9
9
 
10
10
  =end
11
11
  #require 'rubygems'
12
- #require 'ncurses'
12
+ ##require 'ncurses'
13
13
  #require 'logger'
14
14
  require 'rbcurse'
15
15
 
16
- include Ncurses
16
+ #include Ncurses # FFI 2011-09-8
17
17
  include RubyCurses
18
18
  module RubyCurses
19
19
  extend self
@@ -37,10 +37,15 @@ module RubyCurses
37
37
  end
38
38
  def init_vars
39
39
  super
40
+ # the following allows us to navigate buffers with :bn :bp etc (with Alt pressed)
40
41
  bind_key(?\M-:, :buffer_menu)
42
+ bind_key(?\M-;, :buffer_menu)
41
43
  # bind_key([?\C-x, ?f], :file_edit)
42
44
  bind_key([?\C-x, ?k], :delete_component)
43
45
  bind_key([?\C-x, ?\C-b], :list_components)
46
+ bind_key(?\M-n, :goto_next_component)
47
+ bind_key(?\M-p, :goto_prev_component)
48
+ bind_key(?\M-1, :goto_first_component)
44
49
  # easily cycle using p. n is used for next search.
45
50
  #bind_key(?p, :buffer_previous)
46
51
  @suppress_borders = false
@@ -55,16 +60,21 @@ module RubyCurses
55
60
  ##
56
61
  # multi-container
57
62
  def handle_key ch #:nodoc:
58
- $log.debug " MULTI handlekey #{ch}, #{@current_component} "
63
+ #$log.debug " MULTI handlekey #{ch}, #{@current_component}"
59
64
  ret = :UNHANDLED
60
65
  return :UNHANDLED unless @current_component
61
66
  ret = @current_component.handle_key(ch)
62
- $log.debug " MULTI = comp returned #{ret} "
67
+ $log.debug " MULTI = comp #{@current_component} returned #{ret} "
63
68
  if ret == :UNHANDLED
64
69
  # check for bindings, these cannot override above keys since placed at end
65
70
  begin
66
71
  ret = process_key ch, self
67
72
  $log.debug " MULTI = process_key returned #{ret} "
73
+ if ch > 177 && ch < 187
74
+ n = ch - 177
75
+ component_at(n)
76
+ # go to component n
77
+ end
68
78
  rescue => err
69
79
  # $error_message = err # changed 2010 dts
70
80
  $error_message.value = err
@@ -155,8 +165,10 @@ module RubyCurses
155
165
  end
156
166
 
157
167
  def component_at index
158
- @current_component = @bmanager.element_at index
159
- $log.debug " buffer_last got #{@current_component} "
168
+ cc = @bmanager.element_at index
169
+ return unless cc
170
+ @current_component = cc
171
+ #$log.debug " buffer_last got #{@current_component} "
160
172
  set_current_component
161
173
  end
162
174
  ##
@@ -164,14 +176,15 @@ module RubyCurses
164
176
  # @param [Widget] component
165
177
  # @param [String] title
166
178
  def add component, title
167
- component.row = @row+@row_offset+0 # changed 1 to 0 2011-09-14
168
- component.col = @col+@col_offset+0 # changed 1 to 0 2011-09-14
179
+ component.row = @row+@row_offset+0 # FFI changed 1 to 0 2011-09-12
180
+ component.col = @col+@col_offset+0 # FFI changed 1 to 0 2011-09-12
169
181
  component.width = @width-2
170
182
  component.height = @height-2
171
183
  component.form = @form
172
184
  component.override_graphic(@graphic)
173
185
  @current_component = @bmanager.add component, title
174
186
  set_current_component
187
+ set_form_row ## FFI added 2011-09-12 to get cursor at start when adding
175
188
  $log.debug " ADD got cb : #{@current_component} "
176
189
  end
177
190
  def set_current_component
@@ -18,11 +18,11 @@ Todo:
18
18
 
19
19
  =end
20
20
  #require 'rubygems'
21
- require 'ncurses'
21
+ #require 'ncurses'
22
22
  require 'logger'
23
23
  require 'rbcurse'
24
24
 
25
- include Ncurses
25
+ #include Ncurses # FFI 2011-09-8
26
26
  include RubyCurses
27
27
  module RubyCurses
28
28
  extend self
@@ -12,13 +12,13 @@
12
12
 
13
13
  =end
14
14
  require 'rubygems'
15
- require 'ncurses'
15
+ #require 'ncurses'
16
16
  require 'logger'
17
17
  require 'rbcurse'
18
18
  require 'rbcurse/rtextview'
19
19
  require 'rbcurse/listscrollable'
20
20
 
21
- include Ncurses
21
+ #include Ncurses # FFI 2011-09-8
22
22
  include RubyCurses
23
23
  module RubyCurses
24
24
  extend self
@@ -258,7 +258,9 @@ module RubyCurses
258
258
  end
259
259
  def insert filename, position, title=nil
260
260
  # read up file
261
- list = @source.set_content File.open(filename,"r").readlines
261
+ lines = File.open(filename,"r").readlines
262
+ $log.debug "multitextview loaded #{filename}, #{lines.size} lines " if $log.debug?
263
+ list = @source.set_content lines
262
264
  # set new RBuffer
263
265
  title = filename unless title
264
266
  raise "invalid value for list, Should be an array #{list.class} " unless list.is_a? Array
@@ -394,7 +394,7 @@ module RubyCurses
394
394
  return if @window.nil?
395
395
  @visible = false
396
396
  panel = @window.panel
397
- Ncurses::Panel.del_panel(panel) if !panel.nil?
397
+ Ncurses::Panel.del_panel(panel.pointer) if !panel.nil?
398
398
  @window.delwin if !@window.nil? # FFI
399
399
  @items.each do |item|
400
400
  #next if item == :SEPARATOR
@@ -527,7 +527,7 @@ module RubyCurses
527
527
  $log.debug "DESTRY popup "
528
528
  @visible = false
529
529
  panel = @window.panel
530
- Ncurses::Panel.del_panel(panel) if !panel.nil?
530
+ Ncurses::Panel.del_panel(panel.pointer) if !panel.nil?
531
531
  @window.delwin if !@window.nil? # FFI
532
532
  @items.each do |item|
533
533
  item.destroy
@@ -699,7 +699,7 @@ module RubyCurses
699
699
  $log.debug "DESTRY menubar "
700
700
  @visible = false
701
701
  panel = @window.panel
702
- Ncurses::Panel.del_panel(panel) if !panel.nil?
702
+ Ncurses::Panel.del_panel(panel.pointer) if !panel.nil?
703
703
  @window.delwin if !@window.nil?
704
704
  @items.each do |item|
705
705
  item.destroy
@@ -1,8 +1,8 @@
1
- require 'ncurses'
1
+ #require 'ncurses'
2
2
  require 'logger'
3
3
  require 'rbcurse'
4
4
 
5
- include Ncurses
5
+ #include Ncurses # FFI 2011-09-8
6
6
  include RubyCurses
7
7
  module RubyCurses
8
8
  extend self
@@ -22,6 +22,7 @@ module RubyCurses
22
22
  @col = config.fetch("col",-1)
23
23
  @bgcolor = config.fetch("bgcolor", $def_bg_color)
24
24
  @color = config.fetch("color", $def_fg_color)
25
+ @name = config.fetch("name", "pbar")
25
26
  @editable = false
26
27
  @focusable = false
27
28
  super
@@ -19,11 +19,11 @@ area but finish outside, or vice versa.
19
19
  What if we wish some static text to be displayed at top or bottom of ScrollForm
20
20
  =end
21
21
  require 'rubygems'
22
- require 'ncurses'
22
+ #require 'ncurses'
23
23
  require 'logger'
24
24
  require 'rbcurse'
25
25
 
26
- include Ncurses
26
+ #include Ncurses # FFI 2011-09-8
27
27
  include RubyCurses
28
28
  module RubyCurses
29
29
  extend self
@@ -31,12 +31,12 @@ Major changes 2010-02-11 19:51 to simplify version RFED16
31
31
 
32
32
  =end
33
33
  #require 'rubygems'
34
- require 'ncurses'
34
+ #require 'ncurses'
35
35
  require 'logger'
36
36
  require 'rbcurse'
37
37
  require 'rbcurse/rviewport'
38
38
 
39
- include Ncurses
39
+ #include Ncurses # FFI 2011-09-8
40
40
  include RubyCurses
41
41
  module RubyCurses
42
42
  extend self
@@ -449,10 +449,10 @@ module RubyCurses
449
449
  r = @row #+ @ext_row_offset # 2010-02-11 11:57 RFED16
450
450
  c = @col #+ @ext_col_offset # 2010-02-11 11:57 RFED16
451
451
  $log.debug " h_scroll_bar start #{start}, r #{r} c #{c} h:#{@height} "
452
- @graphic.rb_mvwhline(r+@height-1, c+1, ACS_HLINE, @width-2)
452
+ @graphic.rb_mvwhline(r+@height-1, c+1, FFI::NCurses::ACS_HLINE, @width-2)
453
453
  # draw scroll bar
454
- #sz.times{ |i| @graphic.mvaddch(r+@height-1, c+start+1+i, ACS_CKBOARD) }
455
- sz.times{ |i| @graphic.rb_mvaddch(r+@height-1, c+start+1+i, ACS_CKBOARD) }
454
+ #sz.times{ |i| @graphic.mvaddch(r+@height-1, c+start+1+i, FFI::NCurses::ACS_CKBOARD) }
455
+ sz.times{ |i| @graphic.rb_mvaddch(r+@height-1, c+start+1+i, FFI::NCurses::ACS_CKBOARD) }
456
456
  end
457
457
  def v_scroll_bar
458
458
  return if @viewport.nil?
@@ -470,11 +470,11 @@ module RubyCurses
470
470
  # # the problem with next 2 lines is that attributes of border could be overwritten
471
471
  # draw verti line
472
472
  # this is needed to erase previous bar when shrinking
473
- #@graphic.mvwvline(r+1,c+@width-1, ACS_VLINE, @height-2)
474
- @graphic.rb_mvwvline(r+1,c+@width-1, ACS_VLINE, @height-2)
473
+ #@graphic.mvwvline(r+1,c+@width-1, FFI::NCurses::ACS_VLINE, @height-2)
474
+ @graphic.rb_mvwvline(r+1,c+@width-1, FFI::NCurses::ACS_VLINE, @height-2)
475
475
  # draw scroll bar
476
- #sz.times{ |i| @graphic.mvaddch(r+start+1+i, c+@width-1, ACS_CKBOARD) }
477
- sz.times{ |i| @graphic.rb_mvaddch(r+start+1+i, c+@width-1, ACS_CKBOARD) }
476
+ #sz.times{ |i| @graphic.mvaddch(r+start+1+i, c+@width-1, FFI::NCurses::ACS_CKBOARD) }
477
+ sz.times{ |i| @graphic.rb_mvaddch(r+start+1+i, c+@width-1, FFI::NCurses::ACS_CKBOARD) }
478
478
  end
479
479
  # set height
480
480
  # a container must pass down changes in size to it's children
@@ -18,11 +18,11 @@ Todo:
18
18
 
19
19
  =end
20
20
  #require 'rubygems'
21
- require 'ncurses'
21
+ #require 'ncurses'
22
22
  require 'logger'
23
23
  require 'rbcurse'
24
24
 
25
- include Ncurses
25
+ #include Ncurses # FFI 2011-09-8
26
26
  include RubyCurses
27
27
  module RubyCurses
28
28
  extend self
@@ -22,11 +22,11 @@ Todo:
22
22
 
23
23
  =end
24
24
  #require 'rubygems'
25
- require 'ncurses'
25
+ #require 'ncurses'
26
26
  require 'logger'
27
27
  require 'rbcurse'
28
28
 
29
- include Ncurses
29
+ #include Ncurses # FFI 2011-09-8
30
30
  include RubyCurses
31
31
  module RubyCurses
32
32
  extend self
@@ -3,6 +3,9 @@
3
3
  * Description:
4
4
  * A tabbed pane, mostly based (iirc) on the Terminal Preferences in OSX PPC 10.5.x
5
5
  * Starting a new version using pads 2009-10-25 12:05
6
+ TODO - need to rewrite this pronto. 1.3.1 or 1.3.2 should have a rewritten TabbedPane
7
+ NOTE: PLEASE AVOID THIS. USE MULTI_CONTAINERS if you need inside a form.
8
+ TABBEDWINDOW IS OKAY IF YOU ARE POPPING A TABBEDPANE UP.
6
9
  * Author: rkumar
7
10
 
8
11
  --------
@@ -22,13 +25,13 @@ NOTE:
22
25
  # TODO : disable/hide tab ???
23
26
  =end
24
27
  require 'rubygems'
25
- require 'ncurses'
28
+ #require 'ncurses'
26
29
  require 'logger'
27
30
  require 'rbcurse'
28
31
 
29
32
  KEY_TAB = 9
30
33
  KEY_BTAB = 353
31
- include Ncurses
34
+ #include Ncurses # FFI 2011-09-8
32
35
  include RubyCurses
33
36
  module RubyCurses
34
37
  extend self
@@ -112,7 +115,7 @@ module RubyCurses
112
115
  end
113
116
  # In order to get tab display as we traverse buttons, we need to tamper with KEY_DOWN
114
117
  # since that's the only way of getting down to selected tab in this case.
115
- def handle_key ch
118
+ def handle_key ch # tabbed button
116
119
  case ch
117
120
  when KEY_DOWN
118
121
  # form will not do a next_field, it will ignore this
@@ -299,7 +302,7 @@ module RubyCurses
299
302
  ## create a form for tab, if multiple components are to be placed inside tab.
300
303
  # Tabbedpane has no control over placement and width etc of what's inside a form
301
304
  def form tab
302
- if tab.form.nil?
305
+ if !tab.has_form?
303
306
  @forms << create_tab_form(tab)
304
307
  tab.form = @forms.last
305
308
  end
@@ -338,6 +341,7 @@ module RubyCurses
338
341
  _recreate_buttons if @recreate_buttons
339
342
  $log.debug " tabbedpane repaint #{@window.name} "
340
343
  @window.show
344
+ @window.wrefresh # trying out FFI 2011-09-19 since form not being refreshed
341
345
  #x set_buffer_modified()
342
346
  end
343
347
  def show
@@ -380,12 +384,13 @@ module RubyCurses
380
384
  # if col exceeds pad_w then we need to expand pad
381
385
  # but here we don't know that a pad is being used
382
386
  $log.debug " button col #{col} "
383
- form = tab.form
387
+ # form = tab.form # changed 2011 2011-09-26
388
+ form = form(tab)
384
389
  form.set_parent_buffer(@window) if form
385
390
 
386
391
  b = @buttons.last
387
392
  b.command(b) {
388
- $log.debug " calling display form from button press #{b.name} #{b.state} "
393
+ $log.debug " calling tab.repaint,button_form_repaint from button press #{b.name} #{b.state} "
389
394
  # form.rep essentially sees that buttons get correct attributes
390
395
  # when triggering M-<char>. This button should get highlighted.
391
396
  tab.repaint
@@ -456,7 +461,8 @@ module RubyCurses
456
461
  # repaint form and refresh pad
457
462
  @form.repaint
458
463
  else
459
- # only refresh pad
464
+ # only refresh pad
465
+ # - 2011-09-19 I don't think this is called, prolly give an error
460
466
  @form.prefresh
461
467
  end
462
468
  end
@@ -632,7 +638,7 @@ module RubyCurses
632
638
  attr_accessor :text
633
639
  attr_reader :config
634
640
  attr_reader :component
635
- attr_accessor :form
641
+ #attr_accessor :form
636
642
  attr_accessor :parent_component
637
643
  attr_accessor :index
638
644
  def initialize text, parent_component, aconfig={}, &block
@@ -661,13 +667,20 @@ module RubyCurses
661
667
  end
662
668
  # tab should handle key instead of TP.
663
669
  # Pass to component or form
664
- def handle_key ch
670
+ def handle_key ch # Tab
665
671
  kh = @component || @form
666
672
  ret = kh.handle_key(ch)
673
+ $log.debug "DEBUG : handle_key Tab got ret #{ret} "
667
674
  # forms seem to returning a nil when the pad has been updated. We need to copy it
668
675
  ret ||= 0
669
- if ret == 0
676
+ if ret == 0 || ret == :UNHANDLED
677
+ $log.debug "COMPONENT REPAINT CALLING " if $log.debug?
670
678
  @component.repaint if @component
679
+ #@form.window.refresh
680
+ #$log.debug "DEBUG calling display form(false) from handle_key XXX" if @form
681
+ #display_form false if @form # this caused others to go blank 2011-09-26
682
+ elsif ret != :UNHANDLED # FFI trying out, since forms with components not displaying changes
683
+ # since moving to FFI.
671
684
  display_form false if @form
672
685
  end
673
686
  # XXX i need to call repaint of compoent if updated !!
@@ -675,6 +688,7 @@ module RubyCurses
675
688
  end
676
689
  def repaint # Tab
677
690
  if @form
691
+ $log.debug "DEBUG calling display form(true) from repaint XXX" if $log.debug?
678
692
  display_form
679
693
  elsif @component
680
694
  # we ask the component to paint its buffer only, no actual repainting
@@ -706,7 +720,7 @@ module RubyCurses
706
720
  if !@form.nil?
707
721
  # move to first field of existing form
708
722
  #@current_form = @current_tab.form # 2010-02-27 20:22
709
- $log.debug " calling display form from handle_key NO_NEXT_FIELD: #{first_last} "
723
+ $log.debug " calling display form(true) from handle_key NO_NEXT_FIELD: #{first_last} "
710
724
  first_last == :FIRST ? @form.req_first_field : @form.req_last_field
711
725
  display_form
712
726
  else
@@ -734,7 +748,7 @@ module RubyCurses
734
748
  end
735
749
  pc = @parent_component
736
750
  form.repaint if flag # added 2009-11-03 23:27 paint widgets in inside form
737
- $log.debug " TP display form before pad copy: #{pad.name}, set_backing: #{form}: #{form.name} parent: #{@parent_component} : #{pc.row} , #{pc.col}. #{pc.height} , #{pc.width}: repaint flag #{flag} "
751
+ $log.debug " TP display form(#{flag}) before pad copy: #{pad.name}, set_backing: #{form}: #{form.name} parent: #{@parent_component} : #{pc.row} , #{pc.col}. #{pc.height} , #{pc.width}: repaint flag #{flag} "
738
752
  ret = -1
739
753
  pminr = pminc = 0
740
754
  r = pc.row + 2
@@ -747,6 +761,28 @@ module RubyCurses
747
761
  $log.debug " display form after pad copy #{ret}. #{form.name} "
748
762
  end
749
763
 
764
+ # 2011-09-19 @since 1.3.0 changed so that calling form throws an exception
765
+ # if it's nil. Please use Tabbedpane's form() to get a form. This throws an exception
766
+ # so i can catch old programs that use the incorrect method
767
+ def form(*val)
768
+ if val.empty?
769
+ return @form if @form
770
+ raise "Form is nil. You may be using deprecated method. Use @tp.form, not @tab.form"
771
+ else
772
+ #raise ArgumentError "form should be ... " if val[0] ...
773
+ oldvalue = @form
774
+ @form = val[0]
775
+ end
776
+ self
777
+ end
778
+ # used by TP to set form
779
+ def form=(val)
780
+ @form = val
781
+ end
782
+ # used by TP to check form, since the other methods throws an exception
783
+ def has_form?
784
+ !@form.nil?
785
+ end
750
786
  end # class Tab
751
787
 
752
788
  end # class Tabbedpane