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
@@ -21,7 +21,7 @@
21
21
  # Copyright 2010, Rahul Kumar #
22
22
  #*******************************************************#
23
23
  require 'rubygems'
24
- require 'ncurses'
24
+ #require 'ncurses' # FFI
25
25
  require 'logger'
26
26
  require 'rbcurse'
27
27
  require 'rbcurse/rsplitpane'
@@ -35,7 +35,7 @@ if $0 == __FILE__
35
35
  begin
36
36
  # Initialize curses
37
37
  VER::start_ncurses # this is initializing colors via ColorMap.setup
38
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
38
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
39
39
  $log.level = Logger::DEBUG
40
40
  show_caret_flag = true
41
41
 
@@ -25,7 +25,7 @@
25
25
  # Copyright 2010, Rahul Kumar #
26
26
  #*******************************************************#
27
27
  require 'rubygems'
28
- require 'ncurses'
28
+ #require 'ncurses' # FFI
29
29
  require 'logger'
30
30
  require 'rbcurse'
31
31
  require 'rbcurse/rsplitpane'
@@ -40,7 +40,7 @@ if $0 == __FILE__
40
40
  begin
41
41
  # Initialize curses
42
42
  VER::start_ncurses # this is initializing colors via ColorMap.setup
43
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
43
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
44
44
  $log.level = Logger::DEBUG
45
45
 
46
46
  @window = VER::Window.root_window
@@ -26,7 +26,7 @@
26
26
  # Copyright 2010, Rahul Kumar #
27
27
  #*******************************************************#
28
28
  require 'rubygems'
29
- require 'ncurses'
29
+ #require 'ncurses' # FFI
30
30
  require 'logger'
31
31
  require 'rbcurse'
32
32
  require 'rbcurse/rsplitpane'
@@ -41,7 +41,7 @@ if $0 == __FILE__
41
41
  begin
42
42
  # Initialize curses
43
43
  VER::start_ncurses # this is initializing colors via ColorMap.setup
44
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
44
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
45
45
  $log.level = Logger::DEBUG
46
46
  show_caret_flag = false #true
47
47
 
@@ -11,7 +11,7 @@
11
11
  # Copyright 2010, Rahul Kumar #
12
12
  #*******************************************************#
13
13
  require 'rubygems'
14
- require 'ncurses'
14
+ #require 'ncurses' # FFI
15
15
  require 'logger'
16
16
  require 'rbcurse'
17
17
  require 'rbcurse/rsplitpane'
@@ -31,7 +31,7 @@ if $0 == __FILE__
31
31
  begin
32
32
  # Initialize curses
33
33
  VER::start_ncurses # this is initializing colors via ColorMap.setup
34
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
34
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
35
35
  $log.level = Logger::DEBUG
36
36
 
37
37
  @window = VER::Window.root_window
@@ -11,7 +11,7 @@
11
11
  # Copyright 2010, Rahul Kumar #
12
12
  #*******************************************************#
13
13
  require 'rubygems'
14
- require 'ncurses'
14
+ #require 'ncurses' # FFI
15
15
  require 'logger'
16
16
  require 'rbcurse'
17
17
  require 'rbcurse/rsplitpane'
@@ -29,7 +29,7 @@ if $0 == __FILE__
29
29
  begin
30
30
  # Initialize curses
31
31
  VER::start_ncurses # this is initializing colors via ColorMap.setup
32
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
32
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
33
33
  $log.level = Logger::DEBUG
34
34
 
35
35
  @window = VER::Window.root_window
@@ -12,7 +12,7 @@
12
12
  # Copyright 2010, Rahul Kumar #
13
13
  #*******************************************************#
14
14
  require 'rubygems'
15
- require 'ncurses'
15
+ #require 'ncurses' # FFI
16
16
  require 'logger'
17
17
  require 'rbcurse'
18
18
  require 'rbcurse/rsplitpane'
@@ -30,7 +30,7 @@ if $0 == __FILE__
30
30
  begin
31
31
  # Initialize curses
32
32
  VER::start_ncurses # this is initializing colors via ColorMap.setup
33
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
33
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
34
34
  $log.level = Logger::DEBUG
35
35
 
36
36
  @window = VER::Window.root_window
@@ -1,6 +1,6 @@
1
1
  #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
2
  require 'rubygems'
3
- require 'ncurses'
3
+ #require 'ncurses' # FFI
4
4
  require 'logger'
5
5
  #require 'ver/keyboard'
6
6
  require 'rbcurse'
@@ -37,7 +37,7 @@ if $0 == __FILE__
37
37
  begin
38
38
  # Initialize curses
39
39
  VER::start_ncurses # this is initializing colors via ColorMap.setup
40
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
40
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
41
41
  $log.level = Logger::DEBUG
42
42
 
43
43
  @window = VER::Window.root_window
data/examples/testtabp.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
4
4
  require 'rubygems'
5
- require 'ncurses'
5
+ #require 'ncurses' # FFI
6
6
  require 'logger'
7
7
  require 'rbcurse'
8
8
  #require 'rbcurse/rtabbedpane'
@@ -94,7 +94,7 @@ if $0 == __FILE__
94
94
  begin
95
95
  # XXX update with new color and kb
96
96
  VER::start_ncurses # this is initializing colors via ColorMap.setup
97
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
97
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
98
98
  $log.level = Logger::DEBUG
99
99
  n = TestTabbedPane.new
100
100
  n.run
data/examples/testtodo.rb CHANGED
@@ -566,7 +566,7 @@ module TestTodo
566
566
  begin
567
567
  # Initialize curses
568
568
  VER::start_ncurses # this is initializing colors via ColorMap.setup
569
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
569
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
570
570
  $log.level = Logger::DEBUG
571
571
 
572
572
  colors = Ncurses.COLORS
@@ -17,7 +17,7 @@
17
17
  #
18
18
  #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
19
19
  require 'rubygems'
20
- require 'ncurses'
20
+ #require 'ncurses' # FFI
21
21
  require 'logger'
22
22
  require 'rbcurse'
23
23
  require 'rbcurse/rtabbedpane'
@@ -188,7 +188,7 @@ if $0 == __FILE__
188
188
  begin
189
189
  # XXX update with new color and kb
190
190
  VER::start_ncurses # this is initializing colors via ColorMap.setup
191
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
191
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
192
192
  $log.level = Logger::DEBUG
193
193
  n = TestTabbedPane.new
194
194
  n.run
@@ -15,7 +15,7 @@
15
15
  #
16
16
  #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
17
17
  require 'rubygems'
18
- require 'ncurses'
18
+ #require 'ncurses' # FFI
19
19
  require 'logger'
20
20
  require 'rbcurse'
21
21
  require 'rbcurse/rtabbedpane'
@@ -130,7 +130,7 @@ if $0 == __FILE__
130
130
  begin
131
131
  # XXX update with new color and kb
132
132
  VER::start_ncurses # this is initializing colors via ColorMap.setup
133
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
133
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
134
134
  $log.level = Logger::DEBUG
135
135
  n = TestTabbedPane.new
136
136
  n.run
@@ -11,10 +11,11 @@
11
11
  #*******************************************************#
12
12
 
13
13
  # this is a test program, tests out tabbed panes. type F1 to exit
14
- #
15
- $LOAD_PATH << "/Users/rahul/work/projects/rbcurse/lib/"
14
+ # Avoid using ScrollPane at present, I intend rewriting it some day
15
+ # It sucks. Even the TabbedPane code will be rewritten completely.
16
+ # Don't use this demo.
16
17
  require 'rubygems'
17
- require 'ncurses'
18
+ #require 'ncurses' # FFI
18
19
  require 'logger'
19
20
  require 'rbcurse'
20
21
  require 'rbcurse/rtabbedpane'
@@ -40,7 +41,7 @@ class TestTabbedPane
40
41
  #button_type :ok
41
42
  end
42
43
  @tab1 = @tp.add_tab "&Table"
43
- f1 = @tab1.form
44
+ #f1 = @tab1.form
44
45
  f1 = @tp.form @tab1
45
46
  raise "form f1 nil" unless f1
46
47
  $log.debug " TABLE FORM #{f1} "
@@ -187,7 +188,7 @@ if $0 == __FILE__
187
188
  begin
188
189
  # XXX update with new color and kb
189
190
  VER::start_ncurses # this is initializing colors via ColorMap.setup
190
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
191
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
191
192
  $log.level = Logger::DEBUG
192
193
  n = TestTabbedPane.new
193
194
  n.run
@@ -39,7 +39,7 @@ class Tester
39
39
  lb2 = Listbox.new nil, :list => `gem list --local`.split("\n") , :name => "mylist2"
40
40
 
41
41
  alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
42
- str = "Hello people of this world.\nThis is a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-a/C-n/C-p\n"
42
+ str = "Hello people of this world.\nThis is a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-e/C-n/C-p\n"
43
43
  str << alist.join("\n")
44
44
  stfl = vf == :V ? :FLOW : :STACK
45
45
  @vim.add lb, :FIRST, :AUTO
@@ -96,7 +96,7 @@ end
96
96
  begin
97
97
  # XXX update with new color and kb
98
98
  VER::start_ncurses # this is initializing colors via ColorMap.setup
99
- $log = Logger.new("view.log")
99
+ $log = Logger.new("rbc13.log")
100
100
  $log.level = Logger::DEBUG
101
101
  n = Tester.new
102
102
  n.run
data/examples/viewtodo.rb CHANGED
@@ -557,7 +557,7 @@ if $0 == __FILE__
557
557
  begin
558
558
  # Initialize curses
559
559
  VER::start_ncurses # this is initializing colors via ColorMap.setup
560
- $log = Logger.new("view.log")
560
+ $log = Logger.new("rbc13.log")
561
561
  $log.level = Logger::DEBUG
562
562
 
563
563
  colors = Ncurses.COLORS
data/lib/rbcurse.rb CHANGED
@@ -1,7 +1,8 @@
1
+ require 'ffi-ncurses' # ADDED FFI 2011-09-6
1
2
  require 'ver/ncurses'
2
3
  require 'ver/window'
3
4
  require 'rbcurse/rwidget'
4
5
  require 'rbcurse/rdialogs'
5
6
  class Rbcurse
6
- VERSION = '1.1.2'
7
+ VERSION = '1.3.0'
7
8
  end
@@ -1,5 +1,5 @@
1
1
  require 'rbcurse/rwidget'
2
- include Ncurses
2
+ #include Ncurses # FFI 2011-09-8
3
3
  include RubyCurses
4
4
  module RubyCurses
5
5
  ## encapsulates behaviour allowing centralization
data/lib/rbcurse/app.rb CHANGED
@@ -9,7 +9,7 @@ Todo:
9
9
  Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
10
10
 
11
11
  =end
12
- require 'ncurses'
12
+ #require 'ncurses'
13
13
  require 'logger'
14
14
  require 'rbcurse'
15
15
 
@@ -21,7 +21,7 @@ module Kernel
21
21
  extend Forwardable
22
22
  def_delegators :$tt, :ask, :say, :agree, :choose, :numbered_menu, :display_text, :display_text_interactive, :display_list, :say_with_pause
23
23
  end
24
- include Ncurses
24
+ #include Ncurses # FFI 2011-09-8
25
25
  include RubyCurses
26
26
  include RubyCurses::Utils
27
27
  include Io
@@ -105,7 +105,7 @@ module RubyCurses
105
105
  run &block
106
106
  end
107
107
  def init_vars
108
- @quit_key ||= KEY_F1
108
+ @quit_key ||= FFI::NCurses::KEY_F10
109
109
  # actually this should be maintained inside ncurses pack, so not loaded 2 times.
110
110
  # this way if we call an app from existing program, App won't start ncurses.
111
111
  unless $ncurses_started
@@ -115,8 +115,10 @@ module RubyCurses
115
115
  @message_row = Ncurses.LINES-1
116
116
  @prompt_row = @message_row # hope to use for ask etc
117
117
  unless $log
118
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
119
- $log.level = Logger::DEBUG
118
+ path = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
119
+ file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
120
+ $log = Logger.new(path)
121
+ $log.level = Logger::DEBUG # change to warn when you've tested your app.
120
122
  colors = Ncurses.COLORS
121
123
  $log.debug "START #{colors} colors --------- #{$0} win: #{@window} "
122
124
  end
@@ -193,6 +195,7 @@ module RubyCurses
193
195
  # during a process, when you wish to update status, since ordinarily the thread is busy
194
196
  # and form does not get control back, so the window won't refresh.
195
197
  # NOTE: use this only if +message+ is not working
198
+ # XXX Not sure if this is working after move to ffi-ncurses, check the demos
196
199
  def message_immediate text
197
200
  message text
198
201
  @message_label.repaint
@@ -207,7 +210,7 @@ module RubyCurses
207
210
  # (similar to message_immediate) but faster and less involved
208
211
  def raw_message text
209
212
  # experimentally trying stdscr instead of label
210
- scr = Ncurses.stdscr
213
+ scr = FFI::NCurses.stdscr
211
214
  text = "%-80s" % text
212
215
  Ncurses.mvprintw @message_label.row ,0, text
213
216
  #@_stext ||= ""
@@ -215,7 +218,8 @@ module RubyCurses
215
218
  ## appending is quite a pain, maybe we should make it separate.
216
219
  #stext = "%-80s" % @_stext
217
220
  #Ncurses.mvprintw @message_label.row ,0, stext[-80..-1]
218
- scr.refresh()
221
+ #scr.refresh() # NW w FFI XXX
222
+ #FFI::NCurses.refresh
219
223
  end
220
224
  # shows a simple progress bar on last row, using stdscr
221
225
  # @param [Float, Array<Fixnum,Fixnum>] percentage, or part/total
@@ -239,7 +243,7 @@ module RubyCurses
239
243
  text = "[" + "%-10s" % stext + "]"
240
244
  Ncurses.mvprintw( @message_label.row ,startcol-10, s) if s
241
245
  Ncurses.mvprintw @message_label.row ,startcol, text
242
- scr.refresh()
246
+ #scr.refresh() # XXX FFI NW
243
247
 
244
248
  end
245
249
  # used only by LiveConsole, if enables in an app, usually only during testing.
@@ -287,6 +291,36 @@ module RubyCurses
287
291
  end
288
292
  opts
289
293
  end
294
+ def display_app_help
295
+ if respond_to? :help_text
296
+ arr = help_text
297
+ else
298
+ arr = []
299
+ arr << " NO HELP SPECIFIED FOR APP "
300
+ arr << " "
301
+ arr << " --- General help --- "
302
+ arr << " F10 - exit application "
303
+ arr << " Alt-x - select commands "
304
+ arr << " : - select commands "
305
+ arr << " "
306
+ end
307
+ case arr
308
+ when String
309
+ arr = arr.split("\n")
310
+ when Array
311
+ end
312
+ w = arr.max_by(&:length).length
313
+
314
+ require 'rbcurse/extras/viewer'
315
+ RubyCurses::Viewer.view(arr, :layout => [2, 10, [4+arr.size, 24].min, w+2],:close_key => KEY_RETURN, :title => "<Enter> to close", :print_footer => true) do |t|
316
+ # you may configure textview further here.
317
+ #t.suppress_borders true
318
+ #t.color = :black
319
+ #t.bgcolor = :white
320
+ # or
321
+ t.attr = :reverse
322
+ end
323
+ end
290
324
  # bind a key to a method at global (form) level
291
325
  # Note that individual component may be overriding this.
292
326
  def bind_global
@@ -298,8 +332,8 @@ module RubyCurses
298
332
  end
299
333
  key = []
300
334
  str = ""
301
- raw_message "Enter one or 2 keys. Finish with ENTER:"
302
- raw_message "Enter first key:"
335
+ raw_message "Enter one or 2 keys. Finish with ENTER. Enter first key:"
336
+ #raw_message "Enter first key:"
303
337
  ch = @window.getchar()
304
338
  if [KEY_ENTER, 10, 13, ?\C-g.getbyte(0)].include? ch
305
339
  raw_message "Aborted."
@@ -321,7 +355,8 @@ module RubyCurses
321
355
  if !key.empty?
322
356
  raw_message "Binding #{cmd} to #{str} "
323
357
  key = key[0] if key.size == 1
324
- @form.bind_key(key, cmd.to_sym)
358
+ #@form.bind_key(key, cmd.to_sym) # not finding it, getting called by that comp
359
+ @form.bind_key(key){ send(cmd.to_sym) }
325
360
  end
326
361
  #message "Bound #{str} to #{cmd} "
327
362
  end
@@ -336,7 +371,7 @@ module RubyCurses
336
371
  # Actually, this is naive, you would want to pass some values in like current data value
337
372
  # or lines ??
338
373
  # Also may want command completion, or help so all commands can be displayed
339
- def get_command_from_user choices=nil
374
+ def get_command_from_user choices=["quit"]
340
375
  #code, str = rbgetstr(@window, $lastline, 0, "", 80, :default => ":")
341
376
  #return unless code == 0
342
377
  @_command_history ||= Array.new
@@ -364,9 +399,10 @@ module RubyCurses
364
399
  str = str.to_s #= str[1..-1]
365
400
  cmdline = str.split
366
401
  cmd = cmdline.shift #.to_sym
402
+ return unless cmd # added 2011-09-11 FFI
367
403
  if respond_to?(cmd, true)
368
404
  if cmd == "close"
369
- throw :close
405
+ throw :close # other seg faults in del_panel window.destroy executes 2x
370
406
  else
371
407
  send cmd, *cmdline
372
408
  end
@@ -682,7 +718,7 @@ module RubyCurses
682
718
  @color_pair = config[:color_pair] || $datacolor
683
719
  @attrib = config[:attrib] || Ncurses::A_NORMAL
684
720
  @window.attron(Ncurses.COLOR_PAIR(@color_pair) | @attrib)
685
- @window.mvwhline( row, col, ACS_HLINE, width)
721
+ @window.mvwhline( row, col, FFI::NCurses::ACS_HLINE, width)
686
722
  @window.attron(Ncurses.COLOR_PAIR(@color_pair) | @attrib)
687
723
  @app_row += 1
688
724
  end
@@ -1089,6 +1125,7 @@ module RubyCurses
1089
1125
  end
1090
1126
  end
1091
1127
  }
1128
+ @form.bind_key(KEY_F1){ display_app_help }
1092
1129
  @message = Variable.new
1093
1130
  @message.value = ""
1094
1131
  @message_label = RubyCurses::Label.new @form, {:text_variable => @message, :name=>"message_label",:row => Ncurses.LINES-1, :col => 0, :display_length => Ncurses.COLS, :height => 1, :color => :white}
@@ -1,5 +1,5 @@
1
1
  require 'rbcurse/rwidget'
2
- include Ncurses
2
+ #include Ncurses # FFI 2011-09-8
3
3
  include RubyCurses
4
4
  module RubyCurses
5
5
  class ApplicationHeader < Widget