rbcurse 1.4.0 → 1.4.1.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTES +68 -0
- data/README.markdown +73 -330
- data/TODO2.txt +2 -2
- data/VERSION +1 -1
- data/examples/abasiclist.rb +8 -2
- data/examples/alpmenu.rb +1 -1
- data/examples/app.rb +1 -24
- data/examples/appdirtree.rb +1 -1
- data/examples/appemail.rb +8 -14
- data/examples/appemaillb.rb +2 -2
- data/examples/appgcompose.rb +7 -5
- data/examples/common/file.rb +40 -0
- data/examples/{rmail.rb → common/rmail.rb} +0 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +60 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/{todocsv.csv → data/todocsv.csv} +0 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +49 -14
- data/examples/{appgmail.rb → deprecated/appgmail.rb} +1 -1
- data/examples/{splitp.rb → deprecated/splitp.rb} +0 -0
- data/examples/{testscrolllb.rb → deprecated/testscrolllb.rb} +0 -0
- data/examples/{testscrollp.rb → deprecated/testscrollp.rb} +0 -0
- data/examples/{testscrollta.rb → deprecated/testscrollta.rb} +0 -0
- data/examples/{testscrolltable.rb → deprecated/testscrolltable.rb} +0 -0
- data/examples/{testsplit.rb → deprecated/testsplit.rb} +0 -0
- data/examples/{testsplit2.rb → deprecated/testsplit2.rb} +0 -0
- data/examples/{testsplit3.rb → deprecated/testsplit3.rb} +0 -0
- data/examples/{testsplit3_1.rb → deprecated/testsplit3_1.rb} +0 -0
- data/examples/{testsplit3a.rb → deprecated/testsplit3a.rb} +0 -0
- data/examples/{testsplit3b.rb → deprecated/testsplit3b.rb} +0 -0
- data/examples/{testsplitta.rb → deprecated/testsplitta.rb} +0 -0
- data/examples/{testsplittv.rb → deprecated/testsplittv.rb} +0 -0
- data/examples/{testsplittvv.rb → deprecated/testsplittvv.rb} +0 -0
- data/examples/{testtpane.rb → deprecated/testtpane.rb} +0 -0
- data/examples/{testtpane2.rb → deprecated/testtpane2.rb} +0 -0
- data/examples/{testtpanetable.rb → deprecated/testtpanetable.rb} +0 -0
- data/examples/dirtree.rb +17 -7
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/{testscroller.rb → experimental/testscroller.rb} +1 -19
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +1 -0
- data/examples/multispl.rb +4 -4
- data/examples/newmessagebox.rb +130 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +0 -3
- data/examples/qdfilechooser.rb +0 -3
- data/examples/rfe.rb +134 -18
- data/examples/rfe_renderer.rb +48 -2
- data/examples/sqlc.rb +2 -1
- data/examples/sqlm.rb +0 -2
- data/examples/table1.rb +1 -7
- data/examples/term2.rb +4 -1
- data/examples/test1.rb +0 -5
- data/examples/test2.rb +42 -31
- data/examples/testapp2.rb +8 -1
- data/examples/testchars.rb +0 -4
- data/examples/testcombo.rb +5 -9
- data/examples/testkeypress.rb +0 -3
- data/examples/testmenu.rb +0 -4
- data/examples/testmulticomp.rb +3 -5
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testtable.rb +0 -5
- data/examples/testtabp.rb +16 -18
- data/examples/testtodo.rb +1 -5
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/viewtodo.rb +1 -4
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/app.rb +92 -69
- data/lib/rbcurse/applicationheader.rb +46 -6
- data/lib/rbcurse/celleditor.rb +1 -9
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -4
- data/lib/rbcurse/common/ansiparser.rb +117 -0
- data/{examples → lib/rbcurse/common}/appmethods.rb +25 -0
- data/lib/rbcurse/common/basestack.rb +407 -0
- data/lib/rbcurse/common/bordertitle.rb +41 -0
- data/lib/rbcurse/common/chunk.rb +177 -0
- data/lib/rbcurse/common/colorparser.rb +71 -0
- data/lib/rbcurse/common/keydefs.rb +30 -0
- data/lib/rbcurse/common/widgetshortcuts.rb +302 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/{rscrollpane.rb → deprecated/rscrollpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane.rb → deprecated/rsplitpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane2.rb → deprecated/rsplitpane2.rb} +0 -0
- data/lib/rbcurse/{rviewport.rb → deprecated/rviewport.rb} +0 -0
- data/lib/rbcurse/experimental/README.markdown +14 -0
- data/lib/rbcurse/experimental/resultsettextview.rb +585 -0
- data/lib/rbcurse/experimental/stackflow.rb +478 -0
- data/lib/rbcurse/extras/bottomline.rb +85 -16
- data/lib/rbcurse/extras/box.rb +58 -0
- data/lib/rbcurse/extras/directorylist.rb +1 -1
- data/lib/rbcurse/extras/horizlist.rb +203 -0
- data/lib/rbcurse/extras/listselectable.rb +8 -0
- data/lib/rbcurse/extras/multiform.rb +330 -0
- data/lib/rbcurse/extras/multilinelabel.rb +142 -0
- data/lib/rbcurse/extras/newmessagebox.rb +328 -0
- data/lib/rbcurse/extras/newtabbedpane.rb +612 -0
- data/lib/rbcurse/extras/newtabbedwindow.rb +68 -0
- data/lib/rbcurse/extras/padreader.rb +189 -0
- data/lib/rbcurse/extras/rcomboedit.rb +256 -0
- data/lib/rbcurse/extras/resultsetbrowser.rb +281 -0
- data/lib/rbcurse/extras/statusline.rb +44 -6
- data/lib/rbcurse/extras/tabularwidget.rb +141 -104
- data/lib/rbcurse/extras/textpad.rb +516 -0
- data/lib/rbcurse/extras/viewer.rb +2 -0
- data/lib/rbcurse/io.rb +120 -3
- data/lib/rbcurse/listcellrenderer.rb +2 -1
- data/lib/rbcurse/listkeys.rb +1 -1
- data/lib/rbcurse/listscrollable.rb +72 -7
- data/lib/rbcurse/rbasiclistbox.rb +64 -12
- data/lib/rbcurse/rchangeevent.rb +0 -1
- data/lib/rbcurse/rcombo.rb +54 -59
- data/lib/rbcurse/rcommandwindow.rb +46 -10
- data/lib/rbcurse/rcontainer.rb +415 -0
- data/lib/rbcurse/rdialogs.rb +242 -165
- data/lib/rbcurse/rinputdataevent.rb +0 -1
- data/lib/rbcurse/rlistbox.rb +19 -9
- data/lib/rbcurse/rmessagebox.rb +1 -5
- data/lib/rbcurse/rmulticontainer.rb +64 -61
- data/lib/rbcurse/rmultitextview.rb +0 -2
- data/lib/rbcurse/rpopupmenu.rb +0 -2
- data/lib/rbcurse/rscrollform.rb +61 -12
- data/lib/rbcurse/rtabbedpane.rb +89 -73
- data/lib/rbcurse/rtabbedwindow.rb +53 -211
- data/lib/rbcurse/rtable.rb +0 -2
- data/lib/rbcurse/rtextarea.rb +14 -14
- data/lib/rbcurse/rtextview.rb +165 -50
- data/lib/rbcurse/rvimsplit.rb +15 -12
- data/lib/rbcurse/rwidget.rb +404 -150
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -4
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -3
- data/lib/ver/ncurses.rb +1 -9
- data/lib/ver/rpad.rb +375 -0
- data/lib/ver/window.rb +262 -440
- metadata +73 -31
data/lib/rbcurse/rdialogs.rb
CHANGED
@@ -73,14 +73,14 @@ def get_string(message, len=50, default="", config={})
|
|
73
73
|
end
|
74
74
|
return mb.input_value
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
##
|
78
78
|
# Added 2009-02-05 13:16
|
79
79
|
# get a string from user with some additional checkboxes and optionally supply default values
|
80
80
|
# Usage:
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
#sel, inp, hash = get_string_with_options("Enter a filter pattern", 20, "*", {"checkboxes" => ["case sensitive","reverse"], "checkbox_defaults"=>[true, false]})
|
82
|
+
# sel, inp, hash = get_string_with_options("Enter a filter pattern", 20, "*", {"checkboxes" => ["case sensitive","reverse"]})
|
83
|
+
# $log.debug " POPUP: #{sel}: #{inp}, #{hash['case sensitive']}, #{hash['reverse']}"
|
84
84
|
#
|
85
85
|
# @param: message to print,
|
86
86
|
# @param: length of entry field
|
@@ -155,9 +155,9 @@ def get_string_with_options(message, len=20, default="", config={})
|
|
155
155
|
end
|
156
156
|
hash = {}
|
157
157
|
if !checks.nil?
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
checks.each do |c|
|
159
|
+
hash[c] = mform.by_name[c].getvalue
|
160
|
+
end
|
161
161
|
end
|
162
162
|
hash["radio"] = radio.get_value unless radio.nil?
|
163
163
|
# returns button index (0 = OK), value of field, hash containing values of checkboxes
|
@@ -172,176 +172,253 @@ end
|
|
172
172
|
#
|
173
173
|
#
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
175
|
+
# new version with a window created on 2011-10-1 12:37 AM
|
176
|
+
# Now can be separate from window class, needing nothing, just a util class
|
177
|
+
# prints a status message and pauses for a char
|
178
|
+
def print_status_message text, aconfig={}, &block
|
179
|
+
_print_message :status, text, aconfig, &block
|
180
|
+
end
|
181
|
+
# new version with a window created on 2011-10-1 12:30 AM
|
182
|
+
# Now can be separate from window class, needing nothing, just a util class
|
183
|
+
# Why are we dealing with $error_message, that was due to old idea which failed
|
184
|
+
# scrap it and send the message.
|
185
|
+
def print_error_message text, aconfig={}, &block
|
186
|
+
_print_message :error, text, aconfig, &block
|
187
|
+
end
|
188
|
+
def _create_footer_window h = 2 , w = Ncurses.COLS, t = Ncurses.LINES-2, l = 0
|
189
|
+
ewin = VER::Window.new(h, w , t, l)
|
190
|
+
end
|
191
|
+
# @param [:symbol] :error or :status kind of message
|
192
|
+
# @private
|
193
|
+
def _print_message type, text, aconfig={}, &block
|
194
|
+
case text
|
195
|
+
when RubyCurses::Variable # added 2011-09-20 incase variable passed
|
196
|
+
text = text.get_value
|
197
|
+
when Exception
|
198
|
+
text = text.to_s
|
180
199
|
end
|
181
|
-
#
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
200
|
+
# NOTE we are polluting global namespace
|
201
|
+
aconfig.each_pair { |k,v| instance_variable_set("@#{k}",v) }
|
202
|
+
ewin = _create_footer_window #*@layout
|
203
|
+
r = 0; c = 1;
|
204
|
+
case type
|
205
|
+
when :error
|
206
|
+
@color ||= 'red'
|
207
|
+
@bgcolor ||= 'black'
|
208
|
+
else
|
209
|
+
@color ||= :white
|
210
|
+
@bgcolor ||= :black
|
187
211
|
end
|
188
|
-
|
189
|
-
|
212
|
+
color_pair = get_color($promptcolor, @color, @bgcolor)
|
213
|
+
ewin.bkgd(Ncurses.COLOR_PAIR(color_pair));
|
214
|
+
ewin.printstring r, c, text, color_pair
|
215
|
+
ewin.printstring r+1, c, "Press a key", color_pair
|
216
|
+
ewin.wrefresh
|
217
|
+
ewin.getchar
|
218
|
+
ewin.destroy
|
219
|
+
end
|
220
|
+
#
|
221
|
+
# Alternative to confirm dialog, if you want this look and feel, at last 2 lines of screen
|
222
|
+
# @param [String] text to prompt
|
223
|
+
# @return [true, false] 'y' is true, all else if false
|
224
|
+
def confirm_window text, aconfig={}, &block
|
225
|
+
case text
|
226
|
+
when RubyCurses::Variable # added 2011-09-20 incase variable passed
|
227
|
+
text = text.get_value
|
228
|
+
when Exception
|
229
|
+
text = text.to_s
|
190
230
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
@bgcolor ||= 'black'
|
208
|
-
else
|
209
|
-
@color ||= :white
|
210
|
-
@bgcolor ||= :black
|
211
|
-
end
|
212
|
-
color_pair = get_color($promptcolor, @color, @bgcolor)
|
213
|
-
ewin.bkgd(Ncurses.COLOR_PAIR(color_pair));
|
214
|
-
ewin.printstring r, c, text, color_pair
|
215
|
-
ewin.printstring r+1, c, "Press a key", color_pair
|
216
|
-
ewin.wrefresh
|
217
|
-
ewin.getchar
|
231
|
+
ewin = _create_footer_window
|
232
|
+
r = 0; c = 1;
|
233
|
+
aconfig.each_pair { |k,v| instance_variable_set("@#{k}",v) }
|
234
|
+
@color ||= :white
|
235
|
+
@bgcolor ||= :black
|
236
|
+
color_pair = get_color($promptcolor, @color, @bgcolor)
|
237
|
+
ewin.bkgd(Ncurses.COLOR_PAIR(color_pair));
|
238
|
+
ewin.printstring r, c, text, color_pair
|
239
|
+
ewin.printstring r+1, c, "[y/n]", color_pair
|
240
|
+
ewin.wrefresh
|
241
|
+
#retval = false
|
242
|
+
retval = :NO # consistent with confirm
|
243
|
+
begin
|
244
|
+
ch = ewin.getchar
|
245
|
+
retval = :YES if ch.chr == 'y'
|
246
|
+
ensure
|
218
247
|
ewin.destroy
|
219
248
|
end
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
@
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
249
|
+
retval
|
250
|
+
end
|
251
|
+
# class created to display multiple messages without asking for user to hit a key
|
252
|
+
# returns a window to which one can keep calling printstring with 0 or 1 as row.
|
253
|
+
# destroy when finished.
|
254
|
+
# Also, one can pause if one wants, or linger.
|
255
|
+
# This is meant to be a replacement for the message_immediate and message_raw
|
256
|
+
# I was trying out in App.rb. 2011-10-1 1:27 AM
|
257
|
+
# Testing from test2.rb
|
258
|
+
# TODO: add option of putting progress_bar
|
259
|
+
class StatusWindow
|
260
|
+
attr_reader :h, :w, :top, :left # height, width, top row, left col of window
|
261
|
+
attr_reader :win
|
262
|
+
attr_accessor :color_pair
|
263
|
+
def initialize config={}, &block
|
264
|
+
@color_pair = config[:color_pair]
|
265
|
+
@row_offset = config[:row_offset] || 0
|
266
|
+
@col_offset = config[:col_offset] || 0
|
267
|
+
create_window *config[:layout]
|
268
|
+
end
|
269
|
+
def create_window h = 2 , w = Ncurses.COLS-0, t = Ncurses.LINES-2, l = 0
|
270
|
+
return @win if @win
|
271
|
+
@win = VER::Window.new(h, w , t, l)
|
272
|
+
@h = h ; @w = w; @top = t ; @left = l
|
273
|
+
@color_pair ||= get_color($promptcolor, 'white','black')
|
274
|
+
@win.bkgd(Ncurses.COLOR_PAIR(@color_pair));
|
275
|
+
@win
|
276
|
+
end
|
277
|
+
# creates a color pair based on given bg and fg colors as strings
|
278
|
+
#def set_colors bgcolor, fgcolor='white'
|
279
|
+
#@color_pair = get_color($datacolor, 'white','black')
|
280
|
+
#end
|
281
|
+
# prints a string on given row (0 or 1)
|
282
|
+
def printstring r, c, text, color_pair=@color_pair
|
283
|
+
create_window unless @win
|
284
|
+
show unless @visible
|
285
|
+
r = @h-1 if r > @h-1
|
286
|
+
#@win.printstring r, c, ' '*@w, @color_pair
|
287
|
+
# FIXME this padding overwrites the border and the offset means next line wiped
|
288
|
+
# However, now it may now totally clear a long line.
|
289
|
+
@win.printstring r+@row_offset, c+@col_offset, "%-*s" % [@w-(@col_offset*2)-c, text], color_pair
|
290
|
+
@win.wrefresh
|
291
|
+
end
|
292
|
+
# print given strings from first first column onwards
|
293
|
+
def print *textarray
|
294
|
+
create_window unless @win
|
295
|
+
show unless @visible
|
296
|
+
c = 1
|
297
|
+
textarray.each_with_index { |s, i|
|
298
|
+
@win.printstring i+@row_offset, c+@col_offset, "%-*s" % [@w-(@col_offset*2)-c, s], @color_pair
|
299
|
+
}
|
300
|
+
@win.wrefresh
|
301
|
+
end
|
302
|
+
def pause; @win.getchar; end
|
303
|
+
# pauses with the message, but doesn't ask the user to press a key.
|
304
|
+
# If he does, the key should be used by underlying window.
|
305
|
+
# Do not call destroy if you call linger, it does the destroy.
|
306
|
+
def linger caller_window=nil
|
243
307
|
begin
|
244
|
-
|
245
|
-
|
308
|
+
if caller_window
|
309
|
+
ch = @win.getchar
|
310
|
+
caller_window.ungetch(ch) # will this be available to underlying window XXX i think not !!
|
311
|
+
else
|
312
|
+
sleep 1
|
313
|
+
end
|
246
314
|
ensure
|
247
|
-
|
315
|
+
destroy
|
248
316
|
end
|
249
|
-
retval
|
250
317
|
end
|
251
|
-
#
|
252
|
-
#
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
318
|
+
# caller must destroy after he's finished printing messages, unless
|
319
|
+
# user calls linger
|
320
|
+
def destroy; @win.destroy if @win; @win = nil; end
|
321
|
+
def hide
|
322
|
+
@win.hide
|
323
|
+
@visible = false
|
324
|
+
end
|
325
|
+
def show
|
326
|
+
@win.show unless @visible
|
327
|
+
@visible = true
|
328
|
+
end
|
329
|
+
end
|
330
|
+
# returns instance of a status_window for sending multiple
|
331
|
+
# statuses during some process
|
332
|
+
def status_window aconfig={}, &block
|
333
|
+
return StatusWindow.new aconfig
|
334
|
+
end
|
335
|
+
# this is a popup dialog box on which statuses can be printed as a process is taking place.
|
336
|
+
# I am reusing StatusWindow and so there's an issue since I've put a box, so in clearing
|
337
|
+
# the line, I might overwrite the box
|
338
|
+
def progress_dialog aconfig={}, &block
|
339
|
+
aconfig[:layout] = [10,60,10,20]
|
340
|
+
window = status_window aconfig
|
341
|
+
height = 10; width = 60
|
342
|
+
window.win.print_border_mb 1,2, height, width, $normalcolor, FFI::NCurses::A_REVERSE
|
343
|
+
return window
|
344
|
+
end
|
345
|
+
#
|
346
|
+
# Display a popup and return the seliected index from list
|
347
|
+
# Config includes row and col and title of window
|
348
|
+
# You may also pass bgcolor and color
|
349
|
+
# @since 1.4.1 2011-11-1
|
350
|
+
def popuplist list, config={}, &block
|
351
|
+
require 'rbcurse/rbasiclistbox'
|
352
|
+
|
353
|
+
max_visible_items = config[:max_visible_items]
|
354
|
+
row = config[:row] || 5
|
355
|
+
col = config[:col] || 5
|
356
|
+
relative_to = config[:relative_to]
|
357
|
+
if relative_to
|
358
|
+
layout = relative_to.form.window.layout
|
359
|
+
row += layout[:top]
|
360
|
+
col += layout[:left]
|
361
|
+
end
|
362
|
+
config.delete :relative_to
|
363
|
+
width = config[:width] || longest_in_list(list)+2 # borders take 2
|
364
|
+
height = config[:height]
|
365
|
+
height ||= [max_visible_items || 10+2, list.length+2].min
|
366
|
+
#layout(1+height, width+4, row, col)
|
367
|
+
layout = { :height => 0+height, :width => 0+width, :top => row, :left => col }
|
368
|
+
window = VER::Window.new(layout)
|
369
|
+
form = RubyCurses::Form.new window
|
370
|
+
|
371
|
+
listconfig = config[:listconfig] || {}
|
372
|
+
listconfig[:list] = list
|
373
|
+
listconfig[:width] = width
|
374
|
+
listconfig[:height] = height
|
375
|
+
listconfig[:selection_mode] = :single
|
376
|
+
listconfig.merge!(config)
|
377
|
+
listconfig.delete(:row);
|
378
|
+
listconfig.delete(:col);
|
379
|
+
# trying to pass populists block to listbox
|
380
|
+
lb = RubyCurses::BasicListbox.new form, listconfig, &block
|
381
|
+
#
|
382
|
+
# added next line so caller can configure listbox with
|
383
|
+
# events such as ENTER_ROW, LEAVE_ROW or LIST_SELECTION_EVENT or PRESS
|
384
|
+
# 2011-11-11
|
385
|
+
#yield lb if block_given? # No it won't work since this returns
|
386
|
+
window.bkgd(Ncurses.COLOR_PAIR($reversecolor));
|
387
|
+
window.wrefresh
|
388
|
+
Ncurses::Panel.update_panels
|
389
|
+
form.repaint
|
390
|
+
window.wrefresh
|
391
|
+
begin
|
392
|
+
while((ch = window.getchar()) != 999 )
|
393
|
+
case ch
|
394
|
+
when -1
|
395
|
+
next
|
396
|
+
when ?\C-q.getbyte(0)
|
397
|
+
break
|
398
|
+
else
|
399
|
+
lb.handle_key ch
|
400
|
+
form.repaint
|
401
|
+
if ch == 13 || ch == 10
|
402
|
+
return lb.current_index
|
403
|
+
# if multiple selection, then return list of selected_indices and don't catch 32
|
404
|
+
elsif ch == 32 # if single selection
|
405
|
+
return lb.current_index
|
313
406
|
end
|
314
|
-
|
315
|
-
destroy
|
407
|
+
#yield ch if block_given?
|
316
408
|
end
|
317
409
|
end
|
318
|
-
|
319
|
-
|
320
|
-
def destroy; @win.destroy if @win; @win = nil; end
|
321
|
-
def hide
|
322
|
-
@win.hide
|
323
|
-
@visible = false
|
324
|
-
end
|
325
|
-
def show
|
326
|
-
@win.show unless @visible
|
327
|
-
@visible = true
|
328
|
-
end
|
329
|
-
end
|
330
|
-
# returns instance of a status_window for sending multiple
|
331
|
-
# statuses during some process
|
332
|
-
def status_window aconfig={}, &block
|
333
|
-
return StatusWindow.new aconfig
|
334
|
-
end
|
335
|
-
# this is a popup dialog box on which statuses can be printed as a process is taking place.
|
336
|
-
# I am reusing StatusWindow and so there's an issue since I've put a box, so in clearing
|
337
|
-
# the line, I might overwrite the box
|
338
|
-
def progress_dialog aconfig={}, &block
|
339
|
-
aconfig[:layout] = [10,60,10,20]
|
340
|
-
window = status_window aconfig
|
341
|
-
height = 10; width = 60
|
342
|
-
window.win.print_border_mb 1,2, height, width, $normalcolor, FFI::NCurses::A_REVERSE
|
343
|
-
return window
|
410
|
+
ensure
|
411
|
+
window.destroy
|
344
412
|
end
|
413
|
+
return nil
|
414
|
+
end
|
415
|
+
# returns length of longest
|
416
|
+
def longest_in_list list #:nodoc:
|
417
|
+
longest = list.inject(0) do |memo,word|
|
418
|
+
memo >= word.length ? memo : word.length
|
419
|
+
end
|
420
|
+
longest
|
421
|
+
end
|
345
422
|
#
|
346
423
|
=begin
|
347
424
|
http://www.kammerl.de/ascii/AsciiSignature.php
|
@@ -358,7 +435,7 @@ http://www.kammerl.de/ascii/AsciiSignature.php
|
|
358
435
|
| |
|
359
436
|
|_|
|
360
437
|
(_)
|
361
|
-
|
438
|
+
|
362
439
|
|
363
440
|
_____ _ _____
|
364
441
|
| __ \ | | / ____|
|