rbhex-core 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/CHANGELOG +2000 -0
  4. data/LICENSE +56 -0
  5. data/README.md +44 -0
  6. data/examples/abasiclist.rb +179 -0
  7. data/examples/alpmenu.rb +50 -0
  8. data/examples/app.sample +19 -0
  9. data/examples/atree.rb +100 -0
  10. data/examples/bline.rb +136 -0
  11. data/examples/common/file.rb +45 -0
  12. data/examples/data/README.markdown +9 -0
  13. data/examples/data/brew.txt +38 -0
  14. data/examples/data/color.2 +37 -0
  15. data/examples/data/gemlist.txt +60 -0
  16. data/examples/data/lotr.txt +12 -0
  17. data/examples/data/ports.txt +136 -0
  18. data/examples/data/table.txt +37 -0
  19. data/examples/data/tasks.csv +88 -0
  20. data/examples/data/tasks.txt +27 -0
  21. data/examples/data/todo.txt +10 -0
  22. data/examples/data/todo.txt.bak +10 -0
  23. data/examples/data/todocsv.csv +28 -0
  24. data/examples/data/unix1.txt +21 -0
  25. data/examples/data/unix2.txt +11 -0
  26. data/examples/dbdemo.rb +502 -0
  27. data/examples/dirtree.rb +94 -0
  28. data/examples/newtabbedwindow.rb +100 -0
  29. data/examples/newtesttabp.rb +92 -0
  30. data/examples/tabular.rb +146 -0
  31. data/examples/tasks.rb +178 -0
  32. data/examples/term2.rb +84 -0
  33. data/examples/testbuttons.rb +296 -0
  34. data/examples/testcombo.rb +102 -0
  35. data/examples/testfields.rb +195 -0
  36. data/examples/testkeypress.rb +72 -0
  37. data/examples/testlistbox.rb +170 -0
  38. data/examples/testmessagebox.rb +140 -0
  39. data/examples/testprogress.rb +116 -0
  40. data/examples/testree.rb +106 -0
  41. data/examples/testwsshortcuts.rb +66 -0
  42. data/examples/testwsshortcuts2.rb +128 -0
  43. data/lib/rbhex.rb +6 -0
  44. data/lib/rbhex/core/docs/index.txt +73 -0
  45. data/lib/rbhex/core/include/action.rb +80 -0
  46. data/lib/rbhex/core/include/actionmanager.rb +49 -0
  47. data/lib/rbhex/core/include/appmethods.rb +214 -0
  48. data/lib/rbhex/core/include/bordertitle.rb +48 -0
  49. data/lib/rbhex/core/include/chunk.rb +203 -0
  50. data/lib/rbhex/core/include/io.rb +553 -0
  51. data/lib/rbhex/core/include/listbindings.rb +74 -0
  52. data/lib/rbhex/core/include/listcellrenderer.rb +140 -0
  53. data/lib/rbhex/core/include/listeditable.rb +317 -0
  54. data/lib/rbhex/core/include/listscrollable.rb +663 -0
  55. data/lib/rbhex/core/include/listselectable.rb +271 -0
  56. data/lib/rbhex/core/include/multibuffer.rb +83 -0
  57. data/lib/rbhex/core/include/orderedhash.rb +77 -0
  58. data/lib/rbhex/core/include/ractionevent.rb +73 -0
  59. data/lib/rbhex/core/include/rchangeevent.rb +27 -0
  60. data/lib/rbhex/core/include/rhistory.rb +95 -0
  61. data/lib/rbhex/core/include/rinputdataevent.rb +47 -0
  62. data/lib/rbhex/core/include/vieditable.rb +172 -0
  63. data/lib/rbhex/core/include/widgetmenu.rb +66 -0
  64. data/lib/rbhex/core/system/colormap.rb +165 -0
  65. data/lib/rbhex/core/system/keyboard.rb +150 -0
  66. data/lib/rbhex/core/system/keydefs.rb +30 -0
  67. data/lib/rbhex/core/system/ncurses.rb +236 -0
  68. data/lib/rbhex/core/system/panel.rb +162 -0
  69. data/lib/rbhex/core/system/window.rb +913 -0
  70. data/lib/rbhex/core/util/ansiparser.rb +119 -0
  71. data/lib/rbhex/core/util/app.rb +1228 -0
  72. data/lib/rbhex/core/util/basestack.rb +410 -0
  73. data/lib/rbhex/core/util/bottomline.rb +1859 -0
  74. data/lib/rbhex/core/util/colorparser.rb +77 -0
  75. data/lib/rbhex/core/util/focusmanager.rb +31 -0
  76. data/lib/rbhex/core/util/padreader.rb +192 -0
  77. data/lib/rbhex/core/util/rcommandwindow.rb +604 -0
  78. data/lib/rbhex/core/util/rdialogs.rb +574 -0
  79. data/lib/rbhex/core/util/viewer.rb +149 -0
  80. data/lib/rbhex/core/util/widgetshortcuts.rb +506 -0
  81. data/lib/rbhex/core/version.rb +5 -0
  82. data/lib/rbhex/core/widgets/applicationheader.rb +103 -0
  83. data/lib/rbhex/core/widgets/box.rb +58 -0
  84. data/lib/rbhex/core/widgets/divider.rb +310 -0
  85. data/lib/rbhex/core/widgets/keylabelprinter.rb +194 -0
  86. data/lib/rbhex/core/widgets/rcombo.rb +253 -0
  87. data/lib/rbhex/core/widgets/rcontainer.rb +415 -0
  88. data/lib/rbhex/core/widgets/rlink.rb +30 -0
  89. data/lib/rbhex/core/widgets/rlist.rb +696 -0
  90. data/lib/rbhex/core/widgets/rmenu.rb +958 -0
  91. data/lib/rbhex/core/widgets/rmenulink.rb +22 -0
  92. data/lib/rbhex/core/widgets/rmessagebox.rb +387 -0
  93. data/lib/rbhex/core/widgets/rprogress.rb +118 -0
  94. data/lib/rbhex/core/widgets/rtabbedpane.rb +634 -0
  95. data/lib/rbhex/core/widgets/rtabbedwindow.rb +70 -0
  96. data/lib/rbhex/core/widgets/rtextarea.rb +960 -0
  97. data/lib/rbhex/core/widgets/rtextview.rb +739 -0
  98. data/lib/rbhex/core/widgets/rtree.rb +768 -0
  99. data/lib/rbhex/core/widgets/rwidget.rb +3277 -0
  100. data/lib/rbhex/core/widgets/scrollbar.rb +143 -0
  101. data/lib/rbhex/core/widgets/statusline.rb +113 -0
  102. data/lib/rbhex/core/widgets/tabular.rb +264 -0
  103. data/lib/rbhex/core/widgets/tabularwidget.rb +1142 -0
  104. data/lib/rbhex/core/widgets/textpad.rb +995 -0
  105. data/lib/rbhex/core/widgets/tree/treecellrenderer.rb +150 -0
  106. data/lib/rbhex/core/widgets/tree/treemodel.rb +428 -0
  107. data/rbhex-core.gemspec +32 -0
  108. metadata +172 -0
data/examples/term2.rb ADDED
@@ -0,0 +1,84 @@
1
+ require 'rbhex/core/util/app'
2
+ require 'rbhex/core/widgets/tabular'
3
+ require 'rbhex/core/widgets/scrollbar'
4
+
5
+ def my_help_text
6
+ <<-eos
7
+ term2.rb
8
+ =========================================================================
9
+ Basic Usage
10
+
11
+ This example shows different ways of putting data in tabular format.
12
+
13
+ The 2 tables on the right differ in behaviour. The first puts tabular data
14
+ into a listbox so you get single/multiple selection. The second puts tabular
15
+ data into a textview, so there's no selection. <space> scrolls instead of
16
+ selects <ENTER> allows us to use the word under cursor for further actions.
17
+
18
+ To see an example of placing tabular data in a tabular widget, see tabular.rb.
19
+ The advantage of tabular_widget is column resizing, hiding, aligning and sorting.
20
+
21
+ =========================================================================
22
+ :n or Alt-n for next buffer. 'q' to quit.
23
+
24
+ eos
25
+ end
26
+ App.new do
27
+ header = app_header "rbhex #{Rbhex::Core::VERSION}", :text_center => "Tabular Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
28
+ message "F10 quit, F1 Help, ? Bindings"
29
+ #install_help_text my_help_text
30
+ @form.help_manager.help_text = my_help_text
31
+
32
+ flow :width => FFI::NCurses.COLS , :height => FFI::NCurses.LINES-2 do
33
+ stack :margin_top => 1, :width_pc => 20 do
34
+ t = Tabular.new(['a', 'b'], [1, 2], [3, 4])
35
+ listbox :list => t.render
36
+
37
+ t = Tabular.new ['a', 'b']
38
+ t << [1, 2]
39
+ t << [3, 4]
40
+ t << [4, 6]
41
+ #list_box :list => t.to_s.split("\n")
42
+ listbox :list => t.render
43
+ end # stack
44
+ file = File.expand_path("../data/tasks.csv", __FILE__)
45
+ lines = File.open(file,'r').readlines
46
+ heads = %w[ id sta type prio title ]
47
+ t = Tabular.new do |t|
48
+ t.headings = heads
49
+ lines.each { |e| t.add_row e.split '|' }
50
+ end
51
+
52
+ t = t.render
53
+ wid = t[0].length + 2
54
+ wid = 30
55
+ stack :margin_top => 1, :width_pc => 80 , :height_pc => 100 do
56
+ listbox :list => t, :title => '[ tasks ]', :height_pc => 60
57
+
58
+ r = `ls -l`
59
+ res = r.split("\n")
60
+
61
+ t = Tabular.new do
62
+ # self.headings = 'Perm', 'Gr', 'User', 'U', 'Size', 'Mon', 'Date', 'Time', 'File' # changed 2011 dts
63
+ self.headings = 'User', 'Size', 'Mon', 'Date', 'Time', 'File'
64
+ res.each { |e|
65
+ cols = e.split
66
+ next if cols.count < 6
67
+ cols = cols[3..-1]
68
+ cols = cols[0..5] if cols.count > 6
69
+ add_row cols
70
+ }
71
+ column_width 1, 6
72
+ align_column 1, :right
73
+ end
74
+ #lb = list_box :list => t.render2
75
+ lb = textview :set_content => t.render, :title => '[ls -l]', :height_pc => 40
76
+ lb.bind(:PRESS){|tae|
77
+ alert "Pressed list on line #{tae.current_index} #{tae.word_under_cursor(nil, nil, "|")} "
78
+ }
79
+ Scrollbar.new @form, :parent => lb
80
+ #make a textview that is vienabled by default.
81
+ end
82
+ end # end
83
+
84
+ end # app
@@ -0,0 +1,296 @@
1
+ # This program tests out various buttons.
2
+ ## I have used both DSL and conventional constructors for each button to test out.
3
+ ## Had to fix checkbox code (text and mnemonic to return self).
4
+ # Had to fix radio button code, remove raise from constructor
5
+ ## -----
6
+ ## -- THIS WILL NOT WORK WITH < 0.0.15. WILL REQUIRE DOWNLOADING FIXES FROM GITHUB
7
+ ## OR HAVING AT LEAST 0.0.15
8
+ #
9
+ require 'logger'
10
+ require 'rbhex'
11
+ require 'rbhex/core/include/appmethods.rb'
12
+ def help_text
13
+ <<-eos
14
+ BUTTONS HELP
15
+
16
+ This is some help text for testbuttons.
17
+ To select any button press the SPACEBAR, although ENTER will also work.
18
+ You may also press the mnemonic or hotkey on the label..
19
+
20
+ The toggle button toggles the kind of dialog for the Cancel button. Modern look
21
+ and feel refers to a popup with buttons. This is like the links editor.
22
+
23
+ Classic look and feel refers to a line at the bottom of the screen, with a y/n prompt.
24
+ THis is like a lot of older apps, i think Pine and maybe vim.
25
+
26
+
27
+ Alt-c/F10 - Exit application
28
+
29
+
30
+
31
+ -----------------------------------------------------------------------
32
+ eos
33
+ end
34
+ if $0 == __FILE__
35
+
36
+ include RubyCurses
37
+ include RubyCurses::Utils
38
+
39
+ begin
40
+ # Initialize curses
41
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
42
+ path = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
43
+ file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
44
+ $log = Logger.new(path)
45
+ $log.level = Logger::DEBUG
46
+
47
+ @lookfeel = :classic # :dialog # or :classic
48
+ @lookfeel = :dialog # or :classic
49
+
50
+ @window = VER::Window.root_window
51
+ # Initialize few color pairs
52
+ # Create the window to be associated with the form
53
+ # Un post form and free the memory
54
+
55
+ catch(:close) do
56
+ colors = Ncurses.COLORS
57
+ $log.debug "START #{colors} colors test2.rb --------- #{@window} "
58
+ @form = Form.new @window
59
+ title = (" "*30) + "Original Demo of basic Ruby Curses Widgets " + Rbhex::Core::VERSION
60
+ Label.new @form, {'text' => title, :row => 0, :col => 0, :color => 'green', :bgcolor => 'black'}
61
+ r = 1; fc = 12;
62
+ r += 1
63
+ row = 5
64
+ col = 3
65
+
66
+ $message = Variable.new
67
+ $message.value = "Message Comes Here"
68
+ message_label = RubyCurses::Label.new @form, {'text_variable' => $message,
69
+ "name"=>"message_label","row" => Ncurses.LINES-1, "col" => 1, "display_length" => 60,
70
+ "height" => 2, 'color' => 'cyan'}
71
+
72
+ $results = Variable.new
73
+ $results.value = "A variable"
74
+
75
+ row += 1
76
+ checkbutton = CheckBox.new(@form).
77
+ variable($results).
78
+ onvalue("Selected bold ").
79
+ offvalue("UNselected bold").
80
+ display_length(18).
81
+ text("Bold attribute ").
82
+ mnemonic('B').
83
+ row(row).
84
+ col(col)
85
+ row += 1
86
+ @cb_rev = Variable.new false # related to checkbox reverse
87
+ cbb = @cb_rev
88
+ checkbutton1 = CheckBox.new @form do
89
+ variable cbb # $cb_rev
90
+ #value = true
91
+ onvalue "Selected reverse "
92
+ offvalue "UNselected reverse"
93
+ text "Reverse attribute "
94
+ display_length 18
95
+ row row
96
+ col col
97
+ mnemonic 'R'
98
+ end
99
+ row += 1
100
+ togglebutton = ToggleButton.new(@form).
101
+ value( true).
102
+ onvalue( " Toggle Down ").
103
+ offvalue(" Untoggle ").
104
+ row(row).
105
+ col(col).
106
+ mnemonic('T')
107
+ #underline 0
108
+ togglebutton.command do
109
+ if togglebutton.value
110
+ $message.value = "Modern look and feel for dialogs"
111
+ else
112
+ $message.value = "Classic look and feel for dialogs"
113
+ end
114
+ end
115
+ # a special case required since another form (combo popup also modifies)
116
+ $message.update_command() { message_label.repaint }
117
+
118
+ @form.bind(:ENTER) { |f| f.label && f.label.bgcolor = 'red' if f.respond_to? :label}
119
+ @form.bind(:LEAVE) { |f| f.label && f.label.bgcolor = 'black' if f.respond_to? :label}
120
+
121
+ row += 1
122
+ colorlabel = Label.new @form, {'text' => "Select a color:", "row" => row, "col" => col,
123
+ "color"=>"cyan", "mnemonic" => 'S'}
124
+ $radio = Variable.new
125
+ $radio.update_command(colorlabel) {|tv, label| label.color tv.value; }
126
+ #$radio.update_command() {|tv| message_label.color tv.value; align.bgcolor tv.value; combo1.bgcolor tv.value}
127
+ $radio.update_command() {|tv| @form.widgets.each { |e| next unless e.is_a? Widget;
128
+ e.bgcolor tv.value }; }
129
+
130
+ # whenever updated set colorlabel and messagelabel to bold
131
+ $results.update_command(colorlabel,checkbutton) {|tv, label, cb|
132
+ attrs = cb.value ? 'bold' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
133
+
134
+
135
+ # whenever updated set colorlabel and messagelabel to reverse
136
+ #@cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb| attrs = cb.value ? 'reverse' : nil; label.attr(attrs); message_label.attr(attrs)}
137
+ # changing nil to normal since PROP CHAN handler will not fire if nil being set.
138
+ @cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb|
139
+ attrs = cb.value ? 'reverse' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
140
+
141
+ row += 1
142
+ dlen = 10
143
+ # if we try conventional style then constructor throws exception since @variable must be set
144
+ radio1 = RadioButton.new(@form).
145
+ variable($radio).
146
+ text("red").
147
+ value("red").
148
+ color("red").
149
+ display_length(dlen). # helps when right aligning
150
+ row(row).
151
+ col(col)
152
+
153
+ radio11 = RadioButton.new @form do
154
+ variable $radio
155
+ text "c&yan"
156
+ value "cyan"
157
+ color "cyan"
158
+ display_length dlen # helps when right aligning
159
+ row row
160
+ col col+24
161
+ end
162
+
163
+ row += 1
164
+ radio2 = RadioButton.new @form do
165
+ variable $radio
166
+ text "&green"
167
+ value "green"
168
+ color "green"
169
+ display_length dlen # helps when right aligning
170
+ row row
171
+ col col
172
+ end
173
+ radio22 = RadioButton.new @form do
174
+ variable $radio
175
+ text "magenta"
176
+ value "magenta"
177
+ color "magenta"
178
+ display_length dlen # helps when right aligning
179
+ row row
180
+ col col+24
181
+ end
182
+ colorlabel.label_for radio1
183
+
184
+ # instead of using frozen, I will use a PropertyVeto
185
+ # to disallow changes to color itself
186
+ veto = lambda { |e, name|
187
+ if e.property_name == 'color'
188
+ if e.newvalue != name
189
+ raise PropertyVetoException.new("Cannot change this at all!", e)
190
+ end
191
+ elsif e.property_name == 'bgcolor'
192
+ raise PropertyVetoException.new("Cannot change this!", e)
193
+ end
194
+ }
195
+ [radio1, radio2, radio11, radio22].each { |r|
196
+ r.bind(:PROPERTY_CHANGE) do |e| veto.call(e, r.text) end
197
+ }
198
+
199
+ @status_line = status_line :row => Ncurses.LINES-2
200
+ @status_line.command {
201
+ "F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [$message.value]
202
+ }
203
+ row += 1 #2
204
+ ## DSL style of construction
205
+ ok_button = Button.new @form do
206
+ text "OK"
207
+ name "OK"
208
+ row row
209
+ col col
210
+ #attr 'reverse'
211
+ #highlight_background "white"
212
+ #highlight_foreground "blue"
213
+ mnemonic 'O'
214
+ end
215
+ ok_button.command() { |eve|
216
+ alert("Hope you enjoyed this demo - Press the Cancel button to quit", {'title' => "Hello", :bgcolor => :blue , :color => :white})
217
+ }
218
+
219
+ ## conventional style of construction
220
+ # using ampersand to set mnemonic
221
+ cancel_button = Button.new(@form).
222
+ text("&Cancel").
223
+ name("Cancel").
224
+ row(row).
225
+ col(col + 10)
226
+ #attr 'reverse'
227
+ #highlight_background "white"
228
+ #highlight_foreground "blue"
229
+ #surround_chars ['{ ',' }'] ## change the surround chars
230
+ cancel_button.command { |aeve|
231
+ #if @lookfeel == :dialog
232
+ if togglebutton.value == true
233
+ ret = confirm("Do your really want to quit?")
234
+ else
235
+ ret = confirm_window("Do your really want to quit?")
236
+ end
237
+ if ret == :YES || ret == true
238
+ throw(:close);
239
+ else
240
+ $message.value = "Quit aborted"
241
+ end
242
+ }
243
+ #col += 22
244
+ @form.repaint
245
+ @window.wrefresh
246
+ Ncurses::Panel.update_panels
247
+
248
+ # the main loop
249
+
250
+ while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
251
+ break if ch == ?\C-q.getbyte(0)
252
+ begin
253
+ @form.handle_key(ch)
254
+
255
+ rescue FieldValidationException => fve
256
+ alert fve.to_s
257
+
258
+ f = @form.get_current_field
259
+ # lets restore the value
260
+ if f.respond_to? :restore_original_value
261
+ f.restore_original_value
262
+ @form.repaint
263
+ end
264
+ $error_message.value = ""
265
+ rescue => err
266
+ $log.error( err) if err
267
+ $log.error(err.backtrace.join("\n")) if err
268
+ textdialog err
269
+ $error_message.value = ""
270
+ end
271
+
272
+ # this should be avoided, we should not muffle the exception and set a variable
273
+ # However, we have been doing that
274
+ if $error_message.get_value != ""
275
+ if @lookfeel == :dialog
276
+ alert($error_message, {:bgcolor => :red, 'color' => 'yellow'}) if $error_message.get_value != ""
277
+ else
278
+ print_error_message $error_message, {:bgcolor => :red, :color => :yellow}
279
+ end
280
+ $error_message.value = ""
281
+ end
282
+
283
+ @window.wrefresh
284
+ end # while loop
285
+ end # catch
286
+ rescue => ex
287
+ ensure
288
+ $log.debug " -==== EXCEPTION =====-"
289
+ $log.debug( ex) if ex
290
+ $log.debug(ex.backtrace.join("\n")) if ex
291
+ @window.destroy if !@window.nil?
292
+ VER::stop_ncurses
293
+ puts ex if ex
294
+ puts(ex.backtrace.join("\n")) if ex
295
+ end
296
+ end
@@ -0,0 +1,102 @@
1
+ require 'logger'
2
+ require 'rbhex'
3
+ require 'rbhex/core/widgets/rcombo'
4
+ require 'rbhex/core/include/appmethods.rb'
5
+ def help_text
6
+ <<-eos
7
+ COMBO HELP
8
+
9
+ This is some help text for Combos
10
+
11
+ You may press SPACE to invoke the popup and then use arrow keys to traverse. (j and k may also work)
12
+ SPACE on the popup to select.
13
+
14
+ You may press the first character of the desired item to see all those items starting with that char.
15
+ e.g. pressing "v" will cycle through vt100 and vt102
16
+
17
+
18
+ If the arrow_key_policy is set to :popup then a down arrow will also invoke popup. However, if you
19
+ prefer the down arrow to go to the next field, use :ignore. In that case, only SPACE can trigger POPUP.
20
+
21
+ -----------------------------------------------------------------------
22
+ eos
23
+ end
24
+ if $0 == __FILE__
25
+
26
+ include RubyCurses
27
+ include RubyCurses::Utils
28
+
29
+ begin
30
+ # Initialize curses
31
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
32
+ path = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
33
+ file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
34
+ $log = Logger.new(path)
35
+ $log.level = Logger::DEBUG
36
+
37
+ @window = VER::Window.root_window
38
+ # Initialize few color pairs
39
+ # Create the window to be associated with the form
40
+ # Un post form and free the memory
41
+
42
+ catch(:close) do
43
+ colors = Ncurses.COLORS
44
+ $log.debug "START #{colors} colors testcombo.rb --------- #{@window} "
45
+ @form = Form.new @window
46
+ title = (" "*30) + "Demo of Combo (F10 quits, F1 help, SPACE to popup combo) " + Rbhex::Core::VERSION
47
+ Label.new @form, {:text => title, :row => 1, :col => 0, :color => :green, :bgcolor => :black}
48
+ r = 3; fc = 12;
49
+
50
+
51
+
52
+ cb = ComboBox.new @form, :row => 7, :col => 2, :display_length => 20,
53
+ :list => %w[xterm xterm-color xterm-256color screen vt100 vt102],
54
+ :arrow_key_policy => :popup,
55
+ :label => "Declare terminal as: "
56
+
57
+ # arrow_key_policy can be popup or ignore
58
+ # display_length is used to place combo symbol and popup and should be calculated
59
+ # from label.text
60
+
61
+ @form.help_manager.help_text = help_text
62
+ #@form.bind_key(FFI::NCurses::KEY_F1, 'help') { display_app_help help_text() }
63
+ @form.bind_key(FFI::NCurses::KEY_F1, 'help') { display_app_help }
64
+ @form.repaint
65
+ @window.wrefresh
66
+ Ncurses::Panel.update_panels
67
+
68
+ # the main loop
69
+
70
+ while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
71
+ break if ch == ?\C-q.getbyte(0)
72
+ begin
73
+ @form.handle_key(ch)
74
+
75
+ rescue => err
76
+ $log.error( err) if err
77
+ $log.error(err.backtrace.join("\n")) if err
78
+ textdialog err
79
+ $error_message.value = ""
80
+ end
81
+
82
+ # this should be avoided, we should not muffle the exception and set a variable
83
+ # However, we have been doing that
84
+ if $error_message.get_value != ""
85
+ alert($error_message, {:bgcolor => :red, 'color' => 'yellow'}) if $error_message.get_value != ""
86
+ $error_message.value = ""
87
+ end
88
+
89
+ @window.wrefresh
90
+ end # while loop
91
+ end # catch
92
+ rescue => ex
93
+ ensure
94
+ $log.debug " -==== EXCEPTION =====-"
95
+ $log.debug( ex) if ex
96
+ $log.debug(ex.backtrace.join("\n")) if ex
97
+ @window.destroy if !@window.nil?
98
+ VER::stop_ncurses
99
+ puts ex if ex
100
+ puts(ex.backtrace.join("\n")) if ex
101
+ end
102
+ end