rbcurse 1.4.1 → 1.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/CHANGELOG +31 -0
  2. data/README.markdown +69 -11
  3. data/VERSION +1 -1
  4. data/lib/rbcurse.rb +5 -5
  5. metadata +10 -198
  6. data/Makefile +0 -21
  7. data/Manifest.txt +0 -91
  8. data/TODO +0 -372
  9. data/TODO2.txt +0 -118
  10. data/examples/README.txt +0 -67
  11. data/examples/abasiclist.rb +0 -33
  12. data/examples/alpmenu.rb +0 -42
  13. data/examples/app.rb +0 -859
  14. data/examples/app.sample +0 -10
  15. data/examples/appdirtree.rb +0 -75
  16. data/examples/appemail.rb +0 -191
  17. data/examples/appemaillb.rb +0 -308
  18. data/examples/appgcompose.rb +0 -315
  19. data/examples/atree.rb +0 -64
  20. data/examples/common/file.rb +0 -40
  21. data/examples/common/rmail.rb +0 -257
  22. data/examples/data.txt +0 -683
  23. data/examples/data/README.markdown +0 -9
  24. data/examples/data/brew.txt +0 -38
  25. data/examples/data/color.2 +0 -37
  26. data/examples/data/gemlist.txt +0 -60
  27. data/examples/data/lotr.txt +0 -12
  28. data/examples/data/ports.txt +0 -136
  29. data/examples/data/tasks.txt +0 -27
  30. data/examples/data/todocsv.csv +0 -28
  31. data/examples/data/unix1.txt +0 -21
  32. data/examples/data/unix2.txt +0 -11
  33. data/examples/dbdemo.rb +0 -495
  34. data/examples/deprecated/appgmail.rb +0 -952
  35. data/examples/deprecated/splitp.rb +0 -56
  36. data/examples/deprecated/testscrolllb.rb +0 -86
  37. data/examples/deprecated/testscrollp.rb +0 -88
  38. data/examples/deprecated/testscrollta.rb +0 -80
  39. data/examples/deprecated/testscrolltable.rb +0 -165
  40. data/examples/deprecated/testsplit.rb +0 -87
  41. data/examples/deprecated/testsplit2.rb +0 -123
  42. data/examples/deprecated/testsplit3.rb +0 -215
  43. data/examples/deprecated/testsplit3_1.rb +0 -244
  44. data/examples/deprecated/testsplit3a.rb +0 -215
  45. data/examples/deprecated/testsplit3b.rb +0 -237
  46. data/examples/deprecated/testsplitta.rb +0 -148
  47. data/examples/deprecated/testsplittv.rb +0 -142
  48. data/examples/deprecated/testsplittvv.rb +0 -144
  49. data/examples/deprecated/testtpane.rb +0 -215
  50. data/examples/deprecated/testtpane2.rb +0 -145
  51. data/examples/deprecated/testtpanetable.rb +0 -203
  52. data/examples/dirtree.rb +0 -88
  53. data/examples/experimental/resultsetdemo.rb +0 -280
  54. data/examples/experimental/testmform.rb +0 -35
  55. data/examples/experimental/testscroller.rb +0 -117
  56. data/examples/experimental/teststackflow.rb +0 -111
  57. data/examples/menu1.rb +0 -112
  58. data/examples/multispl.rb +0 -86
  59. data/examples/newmessagebox.rb +0 -130
  60. data/examples/newtabbedwindow.rb +0 -100
  61. data/examples/newtesttabp.rb +0 -121
  62. data/examples/qdfilechooser.rb +0 -68
  63. data/examples/rfe.rb +0 -1195
  64. data/examples/rfe_renderer.rb +0 -121
  65. data/examples/sqlc.rb +0 -454
  66. data/examples/sqlm.rb +0 -437
  67. data/examples/sqlt.rb +0 -408
  68. data/examples/status.txt +0 -68
  69. data/examples/table1.rb +0 -24
  70. data/examples/term2.rb +0 -84
  71. data/examples/test1.rb +0 -239
  72. data/examples/test2.rb +0 -674
  73. data/examples/testapp.rb +0 -44
  74. data/examples/testapp2.rb +0 -58
  75. data/examples/testchars.rb +0 -137
  76. data/examples/testcombo.rb +0 -91
  77. data/examples/testkeypress.rb +0 -66
  78. data/examples/testlistbox.rb +0 -113
  79. data/examples/testmenu.rb +0 -101
  80. data/examples/testmulticomp.rb +0 -70
  81. data/examples/testmulticontainer.rb +0 -94
  82. data/examples/testmultispl.rb +0 -199
  83. data/examples/testree.rb +0 -106
  84. data/examples/testtable.rb +0 -263
  85. data/examples/testtabp.rb +0 -107
  86. data/examples/testtodo.rb +0 -584
  87. data/examples/testvimsplit.rb +0 -112
  88. data/examples/testwsshortcuts.rb +0 -64
  89. data/examples/testwsshortcuts2.rb +0 -126
  90. data/examples/todo.db +0 -0
  91. data/examples/todo.yml +0 -191
  92. data/examples/viewtodo.rb +0 -574
  93. data/lib/rbcurse/action.rb +0 -40
  94. data/lib/rbcurse/app.rb +0 -1374
  95. data/lib/rbcurse/applicationheader.rb +0 -102
  96. data/lib/rbcurse/celleditor.rb +0 -112
  97. data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
  98. data/lib/rbcurse/colormap.rb +0 -159
  99. data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
  100. data/lib/rbcurse/common/ansiparser.rb +0 -117
  101. data/lib/rbcurse/common/appmethods.rb +0 -112
  102. data/lib/rbcurse/common/basestack.rb +0 -407
  103. data/lib/rbcurse/common/bordertitle.rb +0 -41
  104. data/lib/rbcurse/common/chunk.rb +0 -177
  105. data/lib/rbcurse/common/colorparser.rb +0 -71
  106. data/lib/rbcurse/common/keydefs.rb +0 -30
  107. data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
  108. data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
  109. data/lib/rbcurse/deprecated/README.markdown +0 -12
  110. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  111. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  112. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  113. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  114. data/lib/rbcurse/experimental/README.markdown +0 -14
  115. data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
  116. data/lib/rbcurse/experimental/stackflow.rb +0 -478
  117. data/lib/rbcurse/extras/bottomline.rb +0 -1850
  118. data/lib/rbcurse/extras/box.rb +0 -58
  119. data/lib/rbcurse/extras/directorylist.rb +0 -467
  120. data/lib/rbcurse/extras/directorytree.rb +0 -69
  121. data/lib/rbcurse/extras/divider.rb +0 -310
  122. data/lib/rbcurse/extras/focusmanager.rb +0 -31
  123. data/lib/rbcurse/extras/horizlist.rb +0 -203
  124. data/lib/rbcurse/extras/listselectable.rb +0 -264
  125. data/lib/rbcurse/extras/masterdetail.rb +0 -166
  126. data/lib/rbcurse/extras/menutree.rb +0 -63
  127. data/lib/rbcurse/extras/multiform.rb +0 -330
  128. data/lib/rbcurse/extras/multilinelabel.rb +0 -142
  129. data/lib/rbcurse/extras/newmessagebox.rb +0 -328
  130. data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
  131. data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
  132. data/lib/rbcurse/extras/padreader.rb +0 -189
  133. data/lib/rbcurse/extras/rcomboedit.rb +0 -256
  134. data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
  135. data/lib/rbcurse/extras/rlink.rb +0 -27
  136. data/lib/rbcurse/extras/rmenulink.rb +0 -21
  137. data/lib/rbcurse/extras/scrollbar.rb +0 -143
  138. data/lib/rbcurse/extras/statusline.rb +0 -94
  139. data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
  140. data/lib/rbcurse/extras/tableextended.rb +0 -40
  141. data/lib/rbcurse/extras/tabular.rb +0 -264
  142. data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
  143. data/lib/rbcurse/extras/textpad.rb +0 -516
  144. data/lib/rbcurse/extras/viewer.rb +0 -136
  145. data/lib/rbcurse/io.rb +0 -850
  146. data/lib/rbcurse/keylabelprinter.rb +0 -178
  147. data/lib/rbcurse/listcellrenderer.rb +0 -140
  148. data/lib/rbcurse/listeditable.rb +0 -310
  149. data/lib/rbcurse/listkeys.rb +0 -37
  150. data/lib/rbcurse/listscrollable.rb +0 -564
  151. data/lib/rbcurse/listselectable.rb +0 -142
  152. data/lib/rbcurse/mapper.rb +0 -130
  153. data/lib/rbcurse/orderedhash.rb +0 -77
  154. data/lib/rbcurse/ractionevent.rb +0 -67
  155. data/lib/rbcurse/rbasiclistbox.rb +0 -768
  156. data/lib/rbcurse/rchangeevent.rb +0 -27
  157. data/lib/rbcurse/rcombo.rb +0 -238
  158. data/lib/rbcurse/rcommandwindow.rb +0 -587
  159. data/lib/rbcurse/rcontainer.rb +0 -415
  160. data/lib/rbcurse/rdialogs.rb +0 -451
  161. data/lib/rbcurse/rinputdataevent.rb +0 -47
  162. data/lib/rbcurse/rlistbox.rb +0 -1196
  163. data/lib/rbcurse/rmenu.rb +0 -939
  164. data/lib/rbcurse/rmessagebox.rb +0 -348
  165. data/lib/rbcurse/rmulticontainer.rb +0 -304
  166. data/lib/rbcurse/rmultisplit.rb +0 -722
  167. data/lib/rbcurse/rmultitextview.rb +0 -306
  168. data/lib/rbcurse/rpopupmenu.rb +0 -755
  169. data/lib/rbcurse/rprogress.rb +0 -118
  170. data/lib/rbcurse/rscrollform.rb +0 -418
  171. data/lib/rbcurse/rtabbedpane.rb +0 -1158
  172. data/lib/rbcurse/rtabbedwindow.rb +0 -167
  173. data/lib/rbcurse/rtable.rb +0 -1718
  174. data/lib/rbcurse/rtextarea.rb +0 -920
  175. data/lib/rbcurse/rtextview.rb +0 -761
  176. data/lib/rbcurse/rtree.rb +0 -780
  177. data/lib/rbcurse/rvimsplit.rb +0 -763
  178. data/lib/rbcurse/rwidget.rb +0 -2915
  179. data/lib/rbcurse/scrollable.rb +0 -301
  180. data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
  181. data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
  182. data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
  183. data/lib/rbcurse/tree/treemodel.rb +0 -428
  184. data/lib/rbcurse/undomanager.rb +0 -188
  185. data/lib/rbcurse/vieditable.rb +0 -144
  186. data/lib/ver/keyboard.rb +0 -150
  187. data/lib/ver/keyboard2.rb +0 -170
  188. data/lib/ver/ncurses.rb +0 -218
  189. data/lib/ver/panel.rb +0 -162
  190. data/lib/ver/rpad.rb +0 -375
  191. data/lib/ver/window.rb +0 -882
  192. data/test/test_rbcurse.rb +0 -0
@@ -1,136 +0,0 @@
1
- require 'rbcurse/rtextview'
2
- require 'fileutils'
3
-
4
- # NOTE: experimental, not yet firmed up
5
- # If you use in application, please copy to some application folder in case i change this.
6
- # Can be used for print_help_page
7
- # TODO: add vi_keys here
8
- # SUGGESTIONS WELCOME.
9
- # @since 1.2.0
10
- module RubyCurses
11
- # a data viewer for viewing some text or filecontents
12
- # view filename, :close_key => KEY_RETURN
13
- # send data in an array
14
- # view Array, :close_key => KEY_RETURN, :layout => [0,0,23,80]
15
- # when passing layout reserve 4 rows for window and border. So for 2 lines of text
16
- # give 6 rows.
17
- class Viewer
18
- # @param filename as string or content as array
19
- # @yield textview object for further configuration before display
20
- # NOTE: i am experimentally yielding textview object so i could supress borders
21
- # just for kicks, but on can also bind_keys or events if one wanted.
22
- def self.view what, config={} #:yield: textview
23
- case what
24
- when String # we have a path
25
- content = _get_contents(what)
26
- when Array
27
- content = what
28
- else
29
- raise ArgumentError, "Expecting Filename or Contents (array), but got #{what.class} "
30
- end
31
- wt = 0 # top margin
32
- wl = 0 # left margin
33
- wh = Ncurses.LINES-wt # height, goes to bottom of screen
34
- ww = Ncurses.COLS-wl # width, goes to right end
35
- wt, wl, wh, ww = config[:layout] if config.has_key? :layout
36
-
37
- fp = config[:title] || ""
38
- pf = config.fetch(:print_footer, true)
39
- ta = config.fetch(:title_attrib, 'bold')
40
- fa = config.fetch(:footer_attrib, 'bold')
41
-
42
- layout = { :height => wh, :width => ww, :top => wt, :left => wl }
43
- v_window = VER::Window.new(layout)
44
- v_form = RubyCurses::Form.new v_window
45
- textview = TextView.new v_form do
46
- name "Viewer"
47
- row 0
48
- col 0
49
- width ww
50
- height wh-0 # earlier 2 but seems to be leaving space.
51
- title fp
52
- title_attrib ta
53
- print_footer pf
54
- footer_attrib fa
55
- end
56
-
57
- t = textview
58
- t.bind_key('<'){ f = t.form.window; c = f.left - 1; f.hide; f.mvwin(f.top, c); f.show;
59
- f.reset_layout([f.height, f.width, f.top, c]);
60
- }
61
- t.bind_key('>'){ f = t.form.window; c = f.left + 1; f.hide; f.mvwin(f.top, c);
62
- f.reset_layout([f.height, f.width, f.top, c]); f.show;
63
- }
64
- t.bind_key('^'){ f = t.form.window; c = f.top - 1 ; f.hide; f.mvwin(c, f.left);
65
- f.reset_layout([f.height, f.width, c, f.left]) ; f.show;
66
- }
67
- t.bind_key('V'){ f = t.form.window; c = f.top + 1 ; f.hide; f.mvwin(c, f.left);
68
- f.reset_layout([f.height, f.width, c, f.left]); f.show;
69
- }
70
- # yielding textview so you may further configure or bind keys or events
71
- begin
72
- textview.set_content content #, :WRAP_WORD
73
- yield textview if block_given? # tentative
74
- v_form.repaint
75
- v_window.wrefresh
76
- Ncurses::Panel.update_panels
77
- # allow closing using q and Ctrl-q in addition to any key specified
78
- # user should not need to specify key, since that becomes inconsistent across usages
79
- while((ch = v_window.getchar()) != ?\C-q.getbyte(0) )
80
- break if ch == config[:close_key] || ch == ?q.ord
81
- # if you've asked for RETURN then i also check for 10 and 13
82
- break if (ch == 10 || ch == 13) && config[:close_key] == KEY_RETURN
83
- v_form.handle_key ch
84
- v_form.repaint
85
- end
86
- rescue => err
87
- $log.error " VIEWER ERROR #{err} "
88
- $log.debug(err.backtrace.join("\n"))
89
- alert err.to_s
90
- ensure
91
- v_window.destroy if !v_window.nil?
92
- end
93
- end
94
- private
95
- def self._get_contents fp
96
- return "File #{fp} not readable" unless File.readable? fp
97
- return Dir.new(fp).entries if File.directory? fp
98
- case File.extname(fp)
99
- when '.tgz','.gz'
100
- cmd = "tar -ztvf #{fp}"
101
- content = %x[#{cmd}]
102
- when '.zip'
103
- cmd = "unzip -l #{fp}"
104
- content = %x[#{cmd}]
105
- when '.jar', '.gem'
106
- cmd = "tar -tvf #{fp}"
107
- content = %x[#{cmd}]
108
- when '.png', '.out','.jpg', '.gif','.pdf'
109
- content = "File #{fp} not displayable"
110
- when '.sqlite'
111
- cmd = "sqlite3 #{fp} 'select name from sqlite_master;'"
112
- content = %x[#{cmd}]
113
- else
114
- content = File.open(fp,"r").readlines
115
- end
116
- end
117
- end # class
118
- end # module
119
- if __FILE__ == $PROGRAM_NAME
120
- require 'rbcurse/app'
121
-
122
- App.new do
123
- header = app_header "rbcurse 1.2.0", :text_center => "Viewer Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
124
- message "Press F1 to exit from here"
125
-
126
- RubyCurses::Viewer.view(ARGV[0] || $0, :close_key => KEY_RETURN, :title => "Enter to close") do |t|
127
- # you may configure textview further here.
128
- #t.suppress_borders true
129
- #t.color = :black
130
- #t.bgcolor = :white
131
- # or
132
- #t.attr = :reverse
133
- end
134
-
135
- end # app
136
- end
data/lib/rbcurse/io.rb DELETED
@@ -1,850 +0,0 @@
1
- #*******************************************************
2
- # Some common io routines for getting data or putting
3
- # at some point
4
- # Arunachalesha
5
- # 2010-03-06 12:10
6
- # Some are outdated.
7
- # Current are:
8
- # * rbgetstr (and those it calls)
9
- # * display_cmenu and create_mitem
10
- #*******************************************************#
11
- ##
12
- # added RK 2010-11-02 18:11 so can be used in widgets too
13
- # maybe can be removed from app, if accessible there too.
14
- require 'forwardable'
15
- require 'rbcurse/extras/bottomline'
16
- #$terminal = RubyCurses::Bottomline.new
17
- #$terminal.name = "$terminal io.rb"
18
- #module Kernel
19
- #extend Forwardable
20
- #def_delegators :$terminal, :agree, :ask, :choose, :say
21
- #end
22
- #$tt.window = @window; $tt.message_row = @message_row # <<-- TODO somewhere
23
- module Io
24
-
25
- # from which line to print in footer_win
26
- LINEONE = 1
27
- FOOTER_COLOR_PAIR = 6
28
- MAIN_WINDOW_COLOR_PAIR = 5
29
- ERROR_COLOR_PAIR = 7
30
-
31
-
32
- # complex version of get_string that allows for trappng of control character
33
- # such as C-c and C-h and TAB for completion
34
- # validints contains int codes not chars.
35
- # NOTE: change. C-g was help key in alpine but abort key in emacs. C-c sometimes
36
- # crashes app, so i am using C-g as abort. Help on M-h
37
- # TODO We should put a field there, make it visible and mv it to after the prompt
38
- # and handle all editing events on it.
39
- # @return status_code, string (0 if okay, 7 if help asked for, -1 for abort
40
- #def rbgetstr(win, r, c, prompt, maxlen, default, labels, validints=[], helptext="")
41
- def rbgetstr(win, r, c, prompt, maxlen, config={})
42
- #win ||= @target_window
43
- raise "rbgetstr got no window. io.rb" if win.nil?
44
- $log.debug " inside io.rb rbgetstr #{win} r:#{r} c:#{c} p:#{prompt} m:#{maxlen} #{win.name} "
45
- ins_mode = false
46
- default = config[:default] || ""
47
- prompt = "#{prompt} [#{default}]: " unless default
48
- len = prompt.length
49
-
50
- # clear the area of len+maxlen
51
- color = $datacolor
52
- str = default
53
- clear_this win, r, c, color, len+maxlen+1
54
- print_this(win, prompt+str, color, r, c)
55
- len = prompt.length + str.length
56
- #x mylabels=["^G~Help ", "^C~Cancel"]
57
- #x mylabels += labels if !labels.nil?
58
- begin
59
- Ncurses.noecho(); # FFI RK 2011-09-11 seems this was causing issue of writing on top
60
- #x print_key_labels( 0, 0, mylabels)
61
- #curpos = 0
62
- curpos = str.length
63
- prevchar = 0
64
- entries = nil
65
- #win.mvwgetnstr(LINEONE-3,askstr.length,yn,maxlen)
66
- while true
67
- #ch=win.mvwgetch(r, len) # get to right of prompt - WHY NOT WORKING ???
68
- ch=win.getchar()
69
- $log.debug "io.rb rbgetstr got ch:#{ch}, #{win} , str:#{str}, len: #{len} "
70
- case ch
71
- when 3 # -1 # C-c
72
- return -1, nil
73
- when ?\C-g.getbyte(0) # ABORT
74
- return -1, nil
75
- when 10, 13 # hits ENTER
76
- break
77
- when ?\C-h.getbyte(0), ?\C-?.getbyte(0), KEY_BSPACE, 263 # delete previous character/backspace
78
- # currently hitting C-h is giving 263 instead of 8
79
- len -= 1 if len > prompt.length
80
- curpos -= 1 if curpos > 0
81
- str.slice!(curpos)
82
- clear_this win, r, c, color, len+maxlen+1
83
- #print_this(win, prompt+str, color, r, c)
84
- when 330 # delete character on cursor
85
- #len -= 1 if len > prompt.length
86
- #curpos -= 1 if curpos > 0
87
- str.slice!(curpos) #rescue next
88
- clear_this win, r, c, color, len+maxlen+1
89
- when ?\M-h.getbyte(0) # HELP KEY
90
- #x print_footer_help(helptext)
91
- helptext = config[:helptext] || "No help provided"
92
- print_help(win, r, c, color, helptext)
93
- return 7, nil
94
- when KEY_LEFT
95
- curpos -= 1 if curpos > 0
96
- len -= 1 if len > prompt.length
97
- win.wmove r, c+len # since getchar is not going back on del and bs
98
- win.wrefresh # FFI 2011-09-19 otherwise not showing
99
- next
100
- when KEY_RIGHT
101
- if curpos < str.length
102
- curpos += 1 #if curpos < str.length
103
- len += 1
104
- win.wmove r, c+len # since getchar is not going back on del and bs
105
- win.wrefresh # FFI 2011-09-19 otherwise not showing
106
- end
107
- next
108
- when ?\C-a.getbyte(0)
109
- #olen = str.length
110
- #clear_this win, r, c, color, len+maxlen+1
111
- #clear_line len+maxlen+1, @prompt_length
112
- len -= curpos
113
- curpos = 0
114
- win.move r, c+len # since getchar is not going back on del and bs
115
- win.wrefresh # FFI 2011-09-19 otherwise not showing
116
- when ?\C-e.getbyte(0)
117
- olen = str.length
118
- len += (olen - curpos)
119
- curpos = olen
120
- #clear_line len+maxlen+1, @prompt_length
121
- win.move r, c+len # since getchar is not going back on del and bs
122
- win.wrefresh # FFI 2011-09-19 otherwise not showing
123
- when ?\M-i.getbyte(0)
124
- ins_mode = !ins_mode
125
- next
126
- when KEY_TAB # TAB
127
- if config
128
- if prevchar == 9
129
- if !entries.nil? and !entries.empty?
130
- str = entries.delete_at(0)
131
- end
132
- else
133
- tabc = config[:tab_completion] unless tabc
134
- next unless tabc
135
- entries = tabc.call(str)
136
- $log.debug " tab got #{entries} "
137
- str = entries.delete_at(0) unless entries.nil? or entries.empty?
138
- end
139
- end
140
- else
141
- #if validints.include?ch
142
- #print_status("Found in validints")
143
- #return ch, nil
144
- #else
145
- if ch < 0 || ch > 255
146
- Ncurses.beep
147
- next
148
- end
149
- # if control char, beep
150
- if ch.chr =~ /[[:cntrl:]]/
151
- Ncurses.beep
152
- next
153
- end
154
- # we need to trap KEY_LEFT and RIGHT and what of UP for history ?
155
- #end
156
- #str << ch.chr
157
- if ins_mode
158
- str[curpos] = ch.chr
159
- else
160
- str.insert(curpos, ch.chr)
161
- end
162
- len += 1
163
- curpos += 1
164
- break if str.length > maxlen
165
- end
166
- print_this(win, prompt+str, color, r, c)
167
- win.wmove r, c+len # more for arrow keys, curpos may not be end
168
- win.wrefresh
169
- prevchar = ch
170
- end
171
- str = default if str == ""
172
- ensure
173
- Ncurses.noecho();
174
- #x restore_application_key_labels # must be done after using print_key_labels
175
- end
176
- return 0, str
177
- end
178
- def clear_this win, r, c, color, len
179
- print_this(win, "%-*s" % [len," "], color, r, c)
180
- end
181
- def print_help(win, r, c, color, helptext)
182
- print_this(win, "%-*s" % [helptext.length+2," "], color, r, c)
183
- print_this(win, "%s" % helptext, color, r, c)
184
- sleep(5)
185
- end
186
- # @table_width is a constant in caller based on which we decide where to show
187
- # key_labels and error messages.
188
- # WHEN WE CREATE A PANEL BWLOW we can do away wit that. FIXME XXX
189
- # return true for y, false for n
190
- # e.g.
191
- # <code>
192
- # ret = @main.askyesno(nil, "Are you sure you wish to proceed?")
193
- # </code>
194
- # 2008-10-09 18:27 added call to print_footer_help
195
- def askyesno(win, askstr, default = "N", helptext="Helptext for this question")
196
- win ||= @footer_win
197
- askstr = "#{askstr} [#{default}]: "
198
- len = askstr.length
199
-
200
- clear_error # 2008-10-13 20:26
201
- print_this(win, askstr, 4, LINEONE, 0)
202
- labels=["?~Help "," ~ ", "N~No ", "Y~Yes "]
203
- print_key_labels( 0, 0, labels)
204
- win.refresh
205
- #Ncurses.echo();
206
- yn=''
207
- #win.mvwgetnstr(Ncurses.LINES-3,askstr.length,yn,maxlen)
208
- while true
209
- ch=win.mvwgetch(LINEONE,askstr.length)
210
- if ch < 0 || ch > 255
211
- next
212
- end
213
- yn = ch.chr
214
- yn = default if yn == '' or ch == 10 # KEY_ENTER
215
- yn.downcase!
216
- break if yn =~/[yn]/
217
- if yn == '?'
218
- print_footer_help(helptext)
219
- print_key_labels( 0, 0, labels)
220
- next
221
- end
222
- Ncurses.beep
223
- end
224
- #Ncurses.noecho();
225
- clear_error # 2008-11-06 19:27
226
- restore_application_key_labels # must be done after using print_key_labels
227
- win.refresh
228
- return yn == 'y'
229
- end
230
-
231
- # return y or n or c
232
-
233
- def askyesnocancel(win, askstr, default = "N")
234
- win ||= @footer_win
235
- askstr = "#{askstr} [#{default}]: "
236
- len = askstr.length
237
-
238
- clear_error # 2008-10-13 20:26
239
- print_this(win, askstr, 4, LINEONE, 0)
240
- labels=["N~No ", "Y~Yes ","C~Cancel"," ~ "]
241
- print_key_labels( 0, 0, labels)
242
- win.refresh
243
- yn=''
244
- #win.mvwgetnstr(LINEONE,askstr.length,yn,maxlen)
245
- while true
246
- ch=win.mvwgetch(LINEONE,askstr.length)
247
- yn = ch.chr
248
- yn = default if yn == '' or ch == 10 # KEY_ENTER
249
- yn.downcase!
250
- break if yn =~/[ync]/
251
- Ncurses.beep
252
- end
253
- restore_application_key_labels # must be done after using print_key_labels
254
- return yn
255
- end
256
-
257
- # return single digit from given choices
258
- # e.g.
259
- # <code>
260
- # labels=["N~No ", "Y~Yes ","C~Cancel"," ~ ","S~SurpiseMe","G~GoAway! "]
261
- # ret = @main.askchoice(nil, "Are you sure you wish to proceed?","N",labels,"NYCSG")
262
- # @main.clear_error
263
- # </code>
264
-
265
- def askchoice(win, askstr, default, labels, validchars, config={})
266
- win ||= @footer_win
267
- askstr = "#{askstr} [#{default}]: "
268
- len = askstr.length
269
- helptext = config.fetch("helptext", "No helptext provided for this action")
270
-
271
- clear_error # 2008-10-13 20:26
272
- print_this(win, askstr, 4, LINEONE, 0)
273
- #labels=["N~No ", "Y~Yes ","C~Cancel"," ~ "]
274
- print_key_labels( 0, 0, labels)
275
- yn=''
276
- validchars.downcase!
277
- #win.mvwgetnstr(LINEONE-3,askstr.length,yn,maxlen)
278
- while true
279
- ch=win.mvwgetch(LINEONE,askstr.length)
280
- yn = ch.chr
281
- # 2008-10-31 18:08
282
- if ch == ?\C-g or yn == '?'
283
- print_footer_help(helptext)
284
- print_key_labels( 0, 0, labels)
285
- next
286
- end
287
- yn = default if yn == '' or ch == 10 # KEY_ENTER
288
- yn.downcase!
289
- break if validchars.include?yn
290
- Ncurses.beep
291
- end
292
- restore_application_key_labels # must be done after using print_key_labels
293
- return yn
294
- end
295
- def get_string(win, askstr, maxlen=20, default="", labels=nil )
296
- win ||= @footer_win
297
- askstr = "#{askstr} [#{default}]: "
298
- len = askstr.length
299
-
300
- clear_error # 2008-11-06 19:25
301
- print_this(win, askstr, 4, LINEONE, 0)
302
- #labels=["N~No ", "Y~Yes ","C~Cancel"," ~ "]
303
- mylabels = ["^G~Help ", "^C~Cancel"]
304
- mylabels = (mylabels + labels) if !labels.nil?
305
-
306
- print_key_labels( 0, 0, mylabels)
307
- Ncurses.echo();
308
- yn=''
309
- begin
310
- Signal.trap("INT"){ return nil }
311
- win.mvwgetnstr(LINEONE,askstr.length,yn,maxlen)
312
- rescue
313
- yn=''
314
- ensure
315
- Ncurses.noecho();
316
- clear_error # 2008-11-02 11:51
317
- restore_application_key_labels # must be done after using print_key_labels
318
- end
319
- yn = default if yn == "" # 2008-10-31 18:59
320
- return yn
321
- end
322
-
323
-
324
- ##
325
- # prints given text to window, in color at x and y coordinates
326
- # @param [Window] window to write to
327
- # @param [String] text to print
328
- # @param [int] color pair such as $datacolor or $promptcolor
329
- # @param [int] x row
330
- # @param [int] y col
331
- # @see Window#printstring
332
- # Consider using Window#printstring
333
- def print_this(win, text, color, x, y)
334
- if !win
335
- raise "win nil in print_this"
336
- end
337
- #$log.debug " printthis #{win} , #{text} , #{x} , #{y} "
338
- color=Ncurses.COLOR_PAIR(color);
339
- win.attron(color);
340
- #win.mvprintw(x, y, "%-40s" % text);
341
- win.mvprintw(x, y, "%s" % text);
342
- win.attroff(color);
343
- win.refresh
344
- end
345
- # prints error in footer_win only
346
- def print_error(text)
347
- clear_error
348
- print_in_middle(@footer_win, LINEONE, 10, 80, text, Ncurses.COLOR_PAIR(ERROR_COLOR_PAIR))
349
- end
350
- # prints status in footer_win only
351
- def print_status(text)
352
- text = text[text.length-80..-1] if text.length > 80
353
- print_error(text)
354
- end
355
- # clear previous error, call inside getch loop after each ch.
356
- def clear_error
357
- print_this(@footer_win, "%-*s" % [Ncurses.COLS," "], 5, LINEONE, 0)
358
- end
359
- # This is only for the menu program, in which we print current action/menu string in the
360
- # key labels below.
361
- # Its a dirty hack edpending on:
362
- # * String CurRow present in key labels
363
- # * field_init_proc called this method to set it.
364
- def print_action(text)
365
- print_this(@footer_win, " %-10s" % ("["+text+"]"), FOOTER_COLOR_PAIR, @action_posy, @action_posx)
366
- end
367
-
368
- # the old historical program which prints a string in middle of whereever
369
- # thanks to this i was using stdscr which must never be used
370
-
371
- def print_in_middle(win, starty, startx, width, string, color)
372
- if(win == nil)
373
- raise "window is nil"
374
- end
375
- x = Array.new
376
- y = Array.new
377
- Ncurses.getyx(win, y, x);
378
- if(startx != 0)
379
- x[0] = startx;
380
- end
381
- if(starty != 0)
382
- y[0] = starty;
383
- end
384
- if(width == 0)
385
- width = 80;
386
- end
387
- length = string.length;
388
- temp = (width - length)/ 2;
389
- x[0] = startx + temp.floor;
390
- win.attron(color);
391
- win.mvprintw(y[0], x[0], "%s", string);
392
- win.attroff(color);
393
- win.refresh();
394
- end
395
- # splits that bad hack array into even and odd arrays
396
- # and prints on last 2 lines
397
-
398
- def print_key_labels(posy, posx, arr)
399
- ## paint so-called key bindings from key_labels
400
- posx = 0
401
- even = []
402
- odd = []
403
- arr.each_index { |i|
404
- if i % 2 == 0
405
- even << arr[i]
406
- else
407
- odd << arr[i]
408
- end
409
- }
410
- posy = LINEONE+1
411
- print_key_labels_row(posy, posx, even)
412
- posy = LINEONE+2
413
- print_key_labels_row(posy, posx, odd)
414
- # 2008-09-29 21:58
415
- @footer_win.wrefresh # needed else secod row not shown after askchoice XXX
416
- end
417
-
418
- def print_key_labels_row(posy, posx, arr)
419
- #clear first
420
- my_form_win = @footer_win
421
- # first clear the line
422
- print_this(my_form_win, "%-*s" % [Ncurses.COLS," "], FOOTER_COLOR_PAIR, posy, 0)
423
- padding = 8
424
- padding = 4 if arr.length > 5
425
- padding = 0 if arr.length > 7
426
- arr.each_index { |i|
427
- kl = arr[i].split('~')
428
- if kl[0].strip !="" # don't print that white blank space for fillers
429
- color_pair=2
430
- my_form_win.attron(Ncurses.COLOR_PAIR(color_pair))
431
- my_form_win.mvprintw(posy, posx, "%s" % kl[0] );
432
- my_form_win.attroff(Ncurses.COLOR_PAIR(color_pair))
433
- end
434
- color_pair=FOOTER_COLOR_PAIR
435
- posx = posx + kl[0].length
436
- my_form_win.attron(Ncurses.COLOR_PAIR(color_pair))
437
- lab = sprintf(" %s %*s" , kl[1], padding, " ");
438
- # hack
439
- if kl[1].strip == "CurRow"
440
- @action_posx = posx
441
- @action_posy = posy
442
- end
443
- my_form_win.mvprintw(posy, posx, lab)
444
- my_form_win.attroff(Ncurses.COLOR_PAIR(color_pair))
445
- posx = posx + lab.length
446
- }
447
- end
448
-
449
- # since it must always be @header_win, we should remove the first param
450
- # why should user have any direct access to those 2 windows.
451
- def old_print_header(win, htext, posy = 0, posx = 0)
452
- win.attron(Ncurses.COLOR_PAIR(6))
453
- win.mvprintw(posy, posx, "%-*s" % [Ncurses.COLS, htext] );
454
- win.attroff(Ncurses.COLOR_PAIR(6))
455
- end
456
- def print_header(htext, posy = 0, posx = 0)
457
- win = @header_win
458
- win.attron(Ncurses.COLOR_PAIR(6))
459
- win.mvprintw(posy, posx, "%-*s" % [Ncurses.COLS, htext] );
460
- win.attroff(Ncurses.COLOR_PAIR(6))
461
- end
462
-
463
- # since it must always be @header_win, we should remove the first param
464
- # why should user have any direct access to those 2 windows.
465
- def old_print_top_right(win, htext)
466
- hlen = htext.length
467
- win.attron(Ncurses.COLOR_PAIR(6))
468
- win.mvprintw(0, Ncurses.COLS-hlen, htext );
469
- win.attroff(Ncurses.COLOR_PAIR(6))
470
- #win.refresh
471
- end
472
- def print_top_right(htext)
473
- hlen = htext.length
474
- win = @header_win
475
- win.attron(Ncurses.COLOR_PAIR(6))
476
- win.mvprintw(0, Ncurses.COLS-hlen, htext );
477
- win.attroff(Ncurses.COLOR_PAIR(6))
478
- #win.refresh
479
- end
480
- # prints labels defined by user in the DSL.
481
- #
482
- # Array of labels with:
483
- #
484
- # * position = [y,x] i.e, row, column
485
- # * text = "label text"
486
- # * color_pair = 6 (optional, default 6)
487
-
488
- def print_screen_labels(my_form_win, labelarr)
489
- table_width = @table_width || Ncurses.LINES-1
490
- return if labelarr.nil?
491
- labelarr.each{ |lhash|
492
- posy, posx = lhash["position"]
493
- posy = table_width + posy if posy < 0
494
- posx = Ncurses.COLS + posy if posx < 0
495
-
496
- text = lhash["text"]
497
- color_pair = lhash["color_pair"] || 6
498
- my_form_win.attron(Ncurses.COLOR_PAIR(color_pair))
499
- my_form_win.mvprintw(posy, posx, "%-s" % text );
500
- my_form_win.attroff(Ncurses.COLOR_PAIR(color_pair))
501
- }
502
- end
503
-
504
- @deprecated
505
- def print_headers(form_hash)
506
- header = form_hash["header"]
507
- header_top_left = form_hash["header_top_left"] || ""
508
- header_top_center = form_hash["header_top_center"] || ""
509
- header_top_right = form_hash["header_top_right"] || ""
510
- posy = 0
511
- posx = 0
512
- htext = " <APP NAME> <VERSION> MAIN MENU"
513
-
514
- posy, posx, htext = header if !header.nil?
515
- print_header(htext + " %15s " % header_top_left + " %20s" % header_top_center , posy, posx)
516
- print_top_right(header_top_right)
517
- @header_win.wrefresh();
518
- end
519
-
520
-
521
- # 2008-10-09 18:27 askyesno and ask_string can be passed some text
522
- # to be popped up when a user enters ?
523
- @deprecated
524
- def print_footer_help(helptext)
525
- print_this(@footer_win, "%-*s" % [Ncurses.COLS," "], 6, LINEONE+1, 0)
526
- print_this(@footer_win, "%-*s" % [Ncurses.COLS," "], 6, LINEONE+2, 0)
527
- print_this(@footer_win, "%s" % helptext, 6, LINEONE+1, 0)
528
- sleep(5)
529
- end
530
- def print_help_page(filename = "TODO")
531
- #require 'panelreader' obsolete used FORN and fiELD
532
- #tp = PanelReader.new()
533
- #tp.view_file(filename)
534
-
535
- end
536
- #def newaskyesno(win, askstr, default = "N", helptext="Helptext for this question")
537
- ##
538
- # user may pass in actions for each key along with other config values in config hash.
539
- # config can contain default, helptext, labels and 'y', 'n'
540
- @deprecated
541
- def newaskyesno(win, askstr, config = {})
542
- win ||= @footer_win
543
- default = config.fetch("default", "N")
544
- helptext = config.fetch("helptext", "This is helptext for this action")
545
- askstr = "#{askstr} [#{default}]: "
546
- len = askstr.length
547
-
548
- clear_error # 2008-10-13 20:26
549
- print_this(win, askstr, 4, LINEONE, 0)
550
- labels=config.fetch("labels", ["?~Help "," ~ ", "N~No ", "Y~Yes "])
551
- print_key_labels( 0, 0, labels)
552
- win.refresh
553
- yn=''
554
- #win.mvwgetnstr(Ncurses.LINES-3,askstr.length,yn,maxlen)
555
- while true
556
- ch=win.mvwgetch(LINEONE,askstr.length)
557
- if ch < 0 || ch > 255
558
- next
559
- end
560
- yn = ch.chr
561
- yn = default if yn == '' or ch == 10 # KEY_ENTER
562
- yn.downcase!
563
- break if yn =~/[yn]/
564
- if yn == '?'
565
- print_footer_help(helptext)
566
- print_key_labels( 0, 0, labels)
567
- next
568
- end
569
- Ncurses.beep
570
- end # while
571
-
572
- begin
573
- config[yn].call if config.include? yn
574
- ensure
575
- restore_application_key_labels # must be done after using print_key_labels
576
- win.refresh
577
- end
578
-
579
- return yn == 'y'
580
- end
581
-
582
- #
583
- # warn user: currently flashes and places error in log file
584
- # experimental, may change interface later
585
- # it does not say anything on screen
586
- # @param [String] text of error/warning to put in log
587
- # @since 1.1.5
588
- def warn string
589
- $log.warn string
590
- Ncurses.beep
591
- end
592
-
593
- #def add_item hotkey, label, desc,action
594
- #
595
- ## A *simple* way of creating menus that will appear in a single row.
596
- # This copies the menu at the bottom of "most" upon pressing ":".
597
- # hotkey is the key to invoke an item (a single digit letter)
598
- #
599
- # label is an action name
600
- #
601
- # desc is a description displayed after an item is chosen. Usually, its like:
602
- #+ "Folding has been enabled" or "Searches will now be case sensitive"
603
- #
604
- # action may be a Proc or a symbol which will be called if item selected
605
- #+ action may be another menu, so recursive menus can be built, but each
606
- #+ should fit in a line, its a simple system.
607
-
608
- CMenuItem = Struct.new( :hotkey, :label, :desc, :action )
609
-
610
-
611
- ## An encapsulated form of yesterday's Most Menu
612
- # It keeps the internals away from the user.
613
- # Its not really OOP in the sense that the PromptMenu is not a MenuItem. That's how it is in
614
- # our Menu system, and that led to a lot of painful coding (at least for me). This is quite
615
- # simple. A submenu contains a PromptMenu in its action object and is evaluated in a switch.
616
- # A recursive loop handles submenus.
617
- #
618
- # Prompting of menu options with suboptions etc.
619
- # A block of code or symbol or proc is executed for any leaf node
620
- # This allows us to define different menus for different objects on the screen, and not have to map
621
- # all kinds of control keys for operations, and have the user remember them. Only one key invokes the menu
622
- # and the rest are ordinary characters.
623
- #
624
- # == Example
625
- # menu = PromptMenu.new self do
626
- # item :s, :goto_start
627
- # item :b, :goto_bottom
628
- # item :r, :scroll_backward
629
- # item :l, :scroll_forward
630
- # submenu :m, "submenu" do
631
- # item :p, :goto_last_position
632
- # item :r, :scroll_backward
633
- # item :l, :scroll_forward
634
- # end
635
- # end
636
- # menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
637
-
638
- class PromptMenu
639
- include Io
640
- attr_reader :text
641
- attr_reader :options
642
- def initialize caller, text="Choose:", &block
643
- @caller = caller
644
- @text = text
645
- @options = []
646
- instance_eval &block if block_given?
647
- end
648
- def add *menuitem
649
- item = nil
650
- case menuitem.first
651
- when CMenuItem
652
- item = menuitem.first
653
- @options << item
654
- else
655
- case menuitem.size
656
- when 4
657
- item = CMenuItem.new(*menuitem.flatten)
658
- when 2
659
- # if user only sends key and symbol
660
- menuitem[3] = menuitem[1]
661
- item = CMenuItem.new(*menuitem.flatten)
662
- end
663
- @options << item
664
- end
665
- return item
666
- end
667
- alias :item :add
668
- def create_mitem *args
669
- item = CMenuItem.new(*args.flatten)
670
- end
671
- # create the whole thing using a MenuTree which has minimal information.
672
- # It uses a hotkey and a code only. We are supposed to resolve the display text
673
- # and actual proc from the caller using this code.
674
- def menu_tree mt, pm = self
675
- mt.each_pair { |ch, code|
676
- if code.is_a? RubyCurses::MenuTree
677
- item = pm.add(ch, code.value, "")
678
- current = PromptMenu.new @caller, code.value
679
- item.action = current
680
- menu_tree code, current
681
- else
682
- item = pm.add(ch, code.to_s, "", code)
683
- end
684
- }
685
- end
686
- #
687
- # To allow a more rubyesque way of defining menus and submenus
688
- def submenu key, label, &block
689
- item = CMenuItem.new(key, label)
690
- @options << item
691
- item.action = PromptMenu.new @caller, label, &block
692
- end
693
- #
694
- # Display prompt_menu in columns using commandwindow
695
- # This is an improved way of showing the "most" like menu. The earlier
696
- # format would only print in one row.
697
- #
698
- def display_columns config={}
699
- prompt = config[:prompt] || "Choose: "
700
- require 'rbcurse/rcommandwindow'
701
- layout = { :height => 5, :width => Ncurses.COLS-1, :top => Ncurses.LINES-6, :left => 0 }
702
- rc = CommandWindow.new nil, :layout => layout, :box => true, :title => config[:title] || "Menu"
703
- w = rc.window
704
- r = 4
705
- c = 1
706
- color = $datacolor
707
- begin
708
- menu = @options
709
- $log.debug " DISP MENU "
710
- ret = 0
711
- len = 80
712
- while true
713
- h = {}
714
- valid = []
715
- labels = []
716
- menu.each{ |item|
717
- hk = item.hotkey.to_s
718
- labels << "%c. %s " % [ hk, item.label ]
719
- h[hk] = item
720
- valid << hk
721
- }
722
- #$log.debug " valid are #{valid} "
723
- color = $datacolor
724
- #print_this(win, str, color, r, c)
725
- rc.display_menu labels, :indexing => :custom
726
- ch=w.getchar()
727
- rc.clear
728
- #$log.debug " got ch #{ch} "
729
- next if ch < 0 or ch > 255
730
- if ch == 3 || ch == ?\C-g.getbyte(0)
731
- clear_this w, r, c, color, len
732
- print_this(w, "Aborted.", color, r,c)
733
- break
734
- end
735
- ch = ch.chr
736
- index = valid.index ch
737
- if index.nil?
738
- clear_this w, r, c, color, len
739
- print_this(w, "Not valid. Valid are #{valid}. C-c/C-g to abort.", color, r,c)
740
- sleep 1
741
- next
742
- end
743
- #$log.debug " index is #{index} "
744
- item = h[ch]
745
- desc = item.desc
746
- #desc ||= "Could not find desc for #{ch} "
747
- desc ||= ""
748
- clear_this w, r, c, color, len
749
- print_this(w, desc, color, r,c)
750
- action = item.action
751
- case action
752
- #when Array
753
- when PromptMenu
754
- # submenu
755
- menu = action.options
756
- title = rc.title
757
- rc.title title +" => " + action.text # set title of window to submenu
758
- when Proc
759
- ret = action.call
760
- break
761
- when Symbol
762
- ret = @caller.send(action)
763
- break
764
- else
765
- $log.debug " Unidentified flying class #{action.class} "
766
- break
767
- end
768
- end # while
769
- ensure
770
- rc.destroy
771
- rc = nil
772
- end
773
- end
774
- alias :display_new :display_columns
775
-
776
- # Display the top level menu and accept user input
777
- # Calls actions or symbols upon selection, or traverses submenus
778
- # @return retvalue of last call or send, or 0
779
- # @param win window
780
- # @param r, c row and col to display on
781
- # @param color text color (use $datacolor if in doubt)
782
- # @see display_new - it presents in a much better manner
783
- # and is not restricted to one row. Avoid this.
784
- def display win, r, c, color
785
- # FIXME use a oneline window, user should not have to give all this crap.
786
- # What about panning if we can;t fit, should we use horiz list to show ?
787
- menu = @options
788
- $log.debug " DISP MENU "
789
- ret = 0
790
- while true
791
- str = @text.dup
792
- h = {}
793
- valid = []
794
- menu.each{ |item|
795
- hk = item.hotkey.to_s
796
- str << "(%c) %s " % [ hk, item.label ]
797
- h[hk] = item
798
- valid << hk
799
- }
800
- #$log.debug " valid are #{valid} "
801
- color = $datacolor
802
- print_this(win, str, color, r, c)
803
- ch=win.getchar()
804
- #$log.debug " got ch #{ch} "
805
- next if ch < 0 or ch > 255
806
- if ch == 3 || ch == ?\C-g.getbyte(0)
807
- clear_this win, r, c, color, str.length
808
- print_this(win, "Aborted.", color, r,c)
809
- break
810
- end
811
- ch = ch.chr
812
- index = valid.index ch
813
- if index.nil?
814
- clear_this win, r, c, color, str.length
815
- print_this(win, "Not valid. Valid are #{valid}", color, r,c)
816
- sleep 1
817
- next
818
- end
819
- #$log.debug " index is #{index} "
820
- item = h[ch]
821
- desc = item.desc
822
- #desc ||= "Could not find desc for #{ch} "
823
- desc ||= ""
824
- clear_this win, r, c, color, str.length
825
- print_this(win, desc, color, r,c)
826
- action = item.action
827
- case action
828
- #when Array
829
- when PromptMenu
830
- # submenu
831
- menu = action.options
832
- str = "%s: " % action.text
833
- when Proc
834
- ret = action.call
835
- break
836
- when Symbol
837
- ret = @caller.send(action)
838
- break
839
- else
840
- $log.debug " Unidentified flying class #{action.class} "
841
- break
842
- end
843
- end # while
844
- return ret # ret val of last send or call
845
- end
846
- end # class PromptMenu
847
-
848
- ### ADD HERE ###
849
-
850
- end # module