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,130 +0,0 @@
1
- # this is a test program, tests out tabbed panes. type F1 to exit
2
- #
3
- require 'rbcurse'
4
- require 'rbcurse/extras/newmessagebox'
5
-
6
- def alertme mess, config={}
7
-
8
- _title = config[:title] || "Alert"
9
- tp = NewMessagebox.new config do
10
- title _title
11
- button_type :ok
12
- message mess
13
- #text mess
14
- end
15
- tp.run
16
- end
17
- def textdialog mess, config={}
18
- config[:title] ||= "Alert"
19
- tp = NewMessagebox.new config do
20
- button_type :ok
21
- text mess
22
- end
23
- tp.run
24
- end
25
- #
26
- def newget_string label, config={}
27
- config[:title] ||= "Entry"
28
- label_config = config[:label_config] || {}
29
- label_config[:row] ||= 2
30
- label_config[:col] ||= 2
31
- label_config[:text] = label
32
-
33
- field_config = config[:field_config] || {}
34
- field_config[:row] ||= 3
35
- field_config[:col] ||= 2
36
- field_config[:attr] = :reverse
37
- field_config[:maxlen] ||= config[:maxlen]
38
- field_config[:default] ||= config[:default]
39
- #field_config[:display_length] ||= 50 # i want it to extend since i don't know the actual width
40
- field_config[:width] ||= 50 # i want it to extend since i don't know the actual width
41
-
42
- tp = NewMessagebox.new config do
43
- button_type :ok_cancel
44
- item Label.new nil, label_config
45
- item Field.new nil, field_config
46
- end
47
- tp.run
48
- end
49
- include RubyCurses
50
- class SetupMessagebox
51
- def run
52
- $config_hash ||= Variable.new Hash.new
53
- #configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
54
-
55
- #tp = NewMessagebox.new :row => 3, :col => 7, :width => 60, :height => 20 , :color => :white, :bgcolor => :blue do
56
- tp = NewMessagebox.new :color => :white, :bgcolor => :blue do
57
- title "User Setup"
58
- button_type :ok_apply_cancel
59
- item Field.new nil, :row => 2, :col => 2, :text => "enter your name", :label => ' Name: '
60
- item Field.new nil, :row => 3, :col => 2, :text => "enter your email", :label => 'Email: '
61
- r = 4
62
- item Label.new nil, :text => "Text", :row => r+1, :col => 2, :attr => :bold
63
- item CheckBox.new nil, :row => r+2, :col => 2, :text => "Antialias text"
64
- item CheckBox.new nil, :row => r+3, :col => 2, :text => "Use bold fonts"
65
- item CheckBox.new nil, :row => r+4, :col => 2, :text => "Allow blinking text"
66
- item CheckBox.new nil, :row => r+5, :col => 2, :text => "Display ANSI Colors"
67
- =begin
68
- item Label.new nil, :text => "Cursor", :row => 7, :col => 2, :attr => 'bold'
69
- $config_hash.set_value Variable.new, :cursor
70
- item RadioButton.new nil, :row => 8, :col => 2, :text => "Block", :value => "block", :variable => $config_hash[:cursor]
71
- item RadioButton.new nil, :row => 9, :col => 2, :text => "Blink", :value => "blink", :variable => $config_hash[:cursor]
72
- item RadioButton.new nil, :row => 10, :col => 2, :text => "Underline", :value => "underline", :variable => $config_hash[:cursor]
73
- end
74
- tab "&Term" do
75
-
76
- item Label.new nil, :text => "Arrow Key in Combos", :row => 2, :col => 2, :attr => 'bold'
77
- x = Variable.new
78
- $config_hash.set_value x, :term
79
- item RadioButton.new nil, :row => 3, :col => 2, :text => "ignore", :value => "ignore", :variable => $config_hash[:term]
80
- item RadioButton.new nil, :row => 4, :col => 2, :text => "popup", :value => "popup", :variable => $config_hash[:term]
81
- item RadioButton.new nil, :row => 5, :col => 2, :text => "next", :value => "next", :variable => $config_hash[:term]
82
- cb = ComboBox.new nil, :row => 7, :col => 2, :display_length => 15,
83
- :list => %w[xterm xterm-color xterm-256color screen vt100 vt102],
84
- :label => "Declare terminal as: "
85
- #radio.update_command() {|rb| ENV['TERM']=rb.value }
86
- item cb
87
- x.update_command do |rb|
88
- cb.arrow_key_policy=rb.value.to_sym
89
- end
90
-
91
- end
92
- tab "Conta&iner" do
93
- item r
94
- end
95
- # tell tabbedpane what to do if a button is pressed (ok/apply/cancel)
96
- =end
97
- command do |eve|
98
- case eve.event
99
- when 0,2 # ok cancel
100
- newget_string "Enter name: ", :default => "john", :maxlen => 50
101
- alertme "user pressed button index:#{eve.event}, #{eve.action_command} "
102
- throw :close, eve.event
103
- when 1 # apply
104
- textdialog "user pressed apply: #{eve.to_s.length} : #{eve} "
105
- end
106
- end
107
- end
108
- tp.run
109
- end
110
-
111
- end
112
- if $0 == __FILE__
113
- # Initialize curses
114
- begin
115
- # XXX update with new color and kb
116
- VER::start_ncurses # this is initializing colors via ColorMap.setup
117
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
118
- $log.level = Logger::DEBUG
119
- tp = SetupMessagebox.new()
120
- buttonindex = tp.run
121
- $log.debug "XXX: MESSAGEBOX retirned #{buttonindex} "
122
- rescue => ex
123
- ensure
124
- VER::stop_ncurses
125
- p ex if ex
126
- p(ex.backtrace.join("\n")) if ex
127
- $log.debug( ex) if ex
128
- $log.debug(ex.backtrace.join("\n")) if ex
129
- end
130
- end
@@ -1,100 +0,0 @@
1
- # this is a test program, tests out tabbed panes. type F1 to exit
2
- #
3
- require 'logger'
4
- require 'rbcurse'
5
- require 'rbcurse/extras/newtabbedpane'
6
- require 'rbcurse/rcontainer'
7
- require 'rbcurse/rcombo'
8
- require 'rbcurse/extras/newtabbedwindow'
9
-
10
- include RubyCurses
11
- class SetupTabbedPane
12
- def run
13
- $config_hash ||= Variable.new Hash.new
14
- #configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
15
-
16
- r = Container.new nil, :suppress_borders => true
17
- l1 = Label.new nil, :name => "profile", :attr => 'bold', :text => "Profile"
18
- f1 = Field.new nil, :name => "name", :maxlen => 20, :display_length => 20, :bgcolor => :white,
19
- :color => :black, :text => "abc", :label => ' Name: '
20
- f2 = Field.new nil, :name => "email", :display_length => 20, :bgcolor => :white,
21
- :color => :blue, :text => "me@google.com", :label => 'Email: '
22
- f3 = RadioButton.new nil, :variable => $config_hash, :text => "red", :value => "RED", :color => :red
23
- f4 = RadioButton.new nil, :variable => $config_hash, :text => "blue", :value => "BLUE", :color => :blue
24
- f5 = RadioButton.new nil, :variable => $config_hash, :text => "green", :value => "GREEN", :color => :green
25
- r.add(l1,f1)
26
- r.add(f2)
27
- r.add(f3,f4,f5)
28
-
29
- tp = NewTabbedWindow.new :row => 3, :col => 7, :width => 60, :height => 20 do
30
- title "User Setup"
31
- button_type :ok_apply_cancel
32
- tab "&Profile" do
33
- item Field.new nil, :row => 2, :col => 2, :text => "enter your name", :label => ' Name: '
34
- item Field.new nil, :row => 3, :col => 2, :text => "enter your email", :label => 'Email: '
35
- end
36
- tab "&Settings" do
37
- item Label.new nil, :text => "Text", :row => 1, :col => 2, :attr => 'bold'
38
- item CheckBox.new nil, :row => 2, :col => 2, :text => "Antialias text"
39
- item CheckBox.new nil, :row => 3, :col => 2, :text => "Use bold fonts"
40
- item CheckBox.new nil, :row => 4, :col => 2, :text => "Allow blinking text"
41
- item CheckBox.new nil, :row => 5, :col => 2, :text => "Display ANSI Colors"
42
- item Label.new nil, :text => "Cursor", :row => 7, :col => 2, :attr => 'bold'
43
- $config_hash.set_value Variable.new, :cursor
44
- item RadioButton.new nil, :row => 8, :col => 2, :text => "Block", :value => "block", :variable => $config_hash[:cursor]
45
- item RadioButton.new nil, :row => 9, :col => 2, :text => "Blink", :value => "blink", :variable => $config_hash[:cursor]
46
- item RadioButton.new nil, :row => 10, :col => 2, :text => "Underline", :value => "underline", :variable => $config_hash[:cursor]
47
- end
48
- tab "&Term" do
49
-
50
- item Label.new nil, :text => "Arrow Key in Combos", :row => 2, :col => 2, :attr => 'bold'
51
- x = Variable.new
52
- $config_hash.set_value x, :term
53
- item RadioButton.new nil, :row => 3, :col => 2, :text => "ignore", :value => "ignore", :variable => $config_hash[:term]
54
- item RadioButton.new nil, :row => 4, :col => 2, :text => "popup", :value => "popup", :variable => $config_hash[:term]
55
- item RadioButton.new nil, :row => 5, :col => 2, :text => "next", :value => "next", :variable => $config_hash[:term]
56
- cb = ComboBox.new nil, :row => 7, :col => 2, :display_length => 15,
57
- :list => %w[xterm xterm-color xterm-256color screen vt100 vt102],
58
- :label => "Declare terminal as: "
59
- #radio.update_command() {|rb| ENV['TERM']=rb.value }
60
- item cb
61
- x.update_command do |rb|
62
- cb.arrow_key_policy=rb.value.to_sym
63
- end
64
-
65
- end
66
- tab "Conta&iner" do
67
- item r
68
- end
69
- # tell tabbedpane what to do if a button is pressed (ok/apply/cancel)
70
- command do |eve|
71
- alert "user pressed button index:#{eve.event} , Name: #{eve.action_command}, Tab: #{eve.source.current_tab} "
72
- case eve.event
73
- when 0,2 # ok cancel
74
- throw :close, eve.event
75
- when 1 # apply
76
- end
77
- end
78
- end
79
- tp.run
80
- end
81
-
82
- end
83
- if $0 == __FILE__
84
- # Initialize curses
85
- begin
86
- # XXX update with new color and kb
87
- VER::start_ncurses # this is initializing colors via ColorMap.setup
88
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
89
- $log.level = Logger::DEBUG
90
- tp = SetupTabbedPane.new()
91
- buttonindex = tp.run
92
- rescue => ex
93
- ensure
94
- VER::stop_ncurses
95
- p ex if ex
96
- p(ex.backtrace.join("\n")) if ex
97
- $log.debug( ex) if ex
98
- $log.debug(ex.backtrace.join("\n")) if ex
99
- end
100
- end
@@ -1,121 +0,0 @@
1
- # this is a test program, tests out tabbed panes. type F1 to exit
2
- #
3
- require 'logger'
4
- require 'rbcurse'
5
- #require 'rbcurse/newtabbedpane'
6
- require 'rbcurse/rtabbedpane'
7
-
8
- class TestTabbedPane
9
- def initialize
10
- acolor = $reversecolor
11
- #$config_hash ||= {}
12
- end
13
- def run
14
- $config_hash ||= Variable.new Hash.new
15
- #configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
16
- @window = VER::Window.root_window
17
- @form = Form.new @window
18
- r = 1; c = 30;
19
- @tp = RubyCurses::TabbedPane.new @form do
20
- height 12
21
- width 50
22
- row 13
23
- col 10
24
- button_type :ok
25
- end
26
- @tab1 = @tp.add_tab "&Language"
27
- #f1 = @tab1.form
28
- f1 = @tp.form @tab1
29
- #$radio = Variable.new
30
- radio1 = RadioButton.new f1 do
31
- #variable $radio
32
- variable $config_hash
33
- name "radio1"
34
- text "ruby"
35
- value "ruby"
36
- color "red"
37
- row 4
38
- col 5
39
- end
40
- radio2 = RadioButton.new f1 do
41
- #variable $radio
42
- variable $config_hash
43
- name "radio1"
44
- text "jruby"
45
- value "jruby"
46
- color "green"
47
- row 5
48
- col 5
49
- end
50
- radio3 = RadioButton.new f1 do
51
- #variable $radio
52
- variable $config_hash
53
- name "radio1"
54
- text "macruby"
55
- value "macruby"
56
- color "cyan"
57
- row 6
58
- col 5
59
- end
60
- @tab2 = @tp.add_tab "&Settings"
61
- #f2 = @tab2.form
62
- f2 = @tp.form @tab2
63
- r = 4
64
- butts = [ "Use &HTTP/1.0", "Use &frames", "&Use SSL" ]
65
- bcodes = %w[ HTTP, FRAMES, SSL ]
66
- butts.each_with_index do |t, i|
67
- RubyCurses::CheckBox.new f2 do
68
- text butts[i]
69
- variable $config_hash
70
- name bcodes[i]
71
- row r+i
72
- col 5
73
- end
74
- end
75
- @tab3 = @tp.add_tab "&Editors"
76
- #f3 = @tab3.form
77
- f3 = @tp.form @tab3
78
- butts = %w[ &Vim E&macs &Jed &Other ]
79
- bcodes = %w[ VIM EMACS JED OTHER]
80
- row = 4
81
- butts.each_with_index do |name, i|
82
- RubyCurses::CheckBox.new f3 do
83
- text name
84
- variable $config_hash
85
- name bcodes[i]
86
- row row+i
87
- col 5
88
- end
89
- end
90
- @help = "q to quit. Use any key of key combination to see what's caught. Check logger too"
91
- RubyCurses::Label.new @form, {'text' => @help, "row" => 11, "col" => 2, "color" => "yellow"}
92
- @form.repaint
93
- @window.wrefresh
94
- Ncurses::Panel.update_panels
95
- while((ch = @window.getchar()) != ?q.getbyte(0) )
96
- # @tp.repaint
97
- @form.handle_key(ch)
98
- @window.wrefresh
99
- end
100
- #@tp.show
101
- #@tp.handle_keys
102
- end
103
- end
104
- if $0 == __FILE__
105
- # Initialize curses
106
- begin
107
- # XXX update with new color and kb
108
- VER::start_ncurses # this is initializing colors via ColorMap.setup
109
- $log = Logger.new("rbc13.log")
110
- $log.level = Logger::DEBUG
111
- n = TestTabbedPane.new
112
- n.run
113
- rescue => ex
114
- ensure
115
- VER::stop_ncurses
116
- p ex if ex
117
- p(ex.backtrace.join("\n")) if ex
118
- $log.debug( ex) if ex
119
- $log.debug(ex.backtrace.join("\n")) if ex
120
- end
121
- end
@@ -1,68 +0,0 @@
1
- # this is a test program, tests out messageboxes. type F1 to exit
2
- # a quick dirty file chooser in 2 lines of code.
3
- require 'logger'
4
- require 'ver/ncurses'
5
- require 'ver/window'
6
- require 'rbcurse/rwidget'
7
-
8
- ##
9
- # a quick dirty file chooser - only temporary till we make something better.
10
- class QDFileChooser
11
- attr_accessor :show_folders # bool
12
- attr_accessor :traverse_folders # bool
13
- attr_accessor :default_pattern # e.g. "*.*"
14
- attr_accessor :dialog_title # File Chooser
15
- def initialize
16
-
17
- end
18
- def show_open_dialog
19
- @form = RubyCurses::Form.new nil
20
- label = RubyCurses::Label.new @form, {'text' => 'File', 'row'=>3, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white', 'mnemonic'=>'F'}
21
- field = RubyCurses::Field.new @form do
22
- name "file"
23
- row 3
24
- col 10
25
- display_length 40
26
- set_label label
27
- end
28
- default_pattern ||= "*.*"
29
- flist = Dir.glob(default_pattern)
30
- @listb = RubyCurses::Listbox.new @form do
31
- name "mylist"
32
- row 5
33
- col 10
34
- width 40
35
- height 10
36
- list flist
37
- title "File list"
38
- title_attrib 'bold'
39
- end
40
- #@listb.list.bind(:ENTER_ROW) { field.set_buffer @listb.selected_item }
41
- listb = @listb
42
- field.bind(:CHANGE) do |f|
43
- flist = Dir.glob(f.getvalue+"*")
44
- l = listb.list
45
- l.remove_all
46
- l.insert 0, *flist
47
- end
48
- atitle = @dialog_title || "Quick Dirty(TM) File Chooser"
49
- @mb = RubyCurses::MessageBox.new @form do
50
- title atitle
51
- type :override
52
- height 20
53
- width 60
54
- top 5
55
- left 20
56
- default_button 0
57
- button_type :ok_cancel
58
- end
59
- #$log.debug "MBOX :selected #{@listb.selected_item}, #{@listb[@listb.getvalue[0]]} "
60
- return @mb.selected_index == 0 ? :OK : :CANCEL
61
- end
62
- def get_selected_file
63
- #return @mb.selected_index == 0 ? @listb.selected_item : nil
64
- #return @mb.selected_index == 0 ? @listb[@listb.getvalue[0]] : nil
65
- # return either the selected_value or if user pressed okay, then focussed item
66
- return @mb.selected_index == 0 ? @listb.selected_value || @listb.selected_item : nil
67
- end
68
- end
data/examples/rfe.rb DELETED
@@ -1,1195 +0,0 @@
1
- #####################################################
2
- # This is a sample program demonstrating a 2 pane file explorer using
3
- # rbcurse's widgets.
4
- # I have used a listbox here, perhaps a Table would be more configurable
5
- # than a listbox.
6
- #
7
- # Copyright rkumar 2009, 2010 under Ruby License.
8
- #
9
- ####################################################
10
- #require 'rubygems'
11
- #require 'ncurses'
12
- #require 'logger'
13
- require 'rbcurse'
14
- require 'rbcurse/rcombo'
15
- require 'rbcurse/rlistbox'
16
- require './rfe_renderer'
17
- require 'rbcurse/keylabelprinter'
18
- require 'rbcurse/applicationheader'
19
- require 'rbcurse/action'
20
- require 'fileutils'
21
- require 'yaml' ## added for 1.9
22
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
23
-
24
- # TODO
25
- # operations on selected files: move, delete, zip, copy
26
- # - delete should move to Trash if exists - DONE
27
- # global - don't ask confirm
28
- # Select based on pattern.
29
- # This class represents the finder pane. There are 2
30
- # on this sample app
31
- # NOTE: rfe_renderer uses entries so you may need to sync it with list_data_model
32
- # actually, renderer should refer back to list data model!
33
- class FileExplorer
34
- include FileUtils
35
- attr_reader :wdir
36
- attr_reader :list # listbox
37
- attr_reader :dir
38
- attr_reader :prev_dirs
39
- attr_reader :other_list # the opposite list
40
- attr_reader :entries # avoid, can be outdated
41
- attr_accessor :filter_pattern
42
-
43
- def initialize form, rfe, row, col, height, width
44
- @form = form
45
- @rfe = rfe
46
- @row, @col, @ht, @wid = row, col, height, width
47
- @dir = Dir.new(Dir.getwd)
48
- @wdir = @dir.path
49
- @filter_pattern = '*'
50
- @prev_dirs=[]
51
- @inside_block = false
52
- $entry_count = 0 # just for show... may not be accurate after deletes etc
53
-
54
- end
55
- def title str
56
- @list.title = str
57
- end
58
- def selected_color
59
- @list.selected_color
60
- end
61
- def selected_bgcolor
62
- @list.selected_bgcolor
63
- end
64
-
65
- # changes to given dir
66
- # ensure that path is provided since other list
67
- # may have cd'd elsewhere
68
- def change_dir adir
69
- list = @list
70
- begin
71
- #dir = File.expand_path dir
72
- #cd "#{@dir.path}/#{adir}"
73
- cd adir
74
- list.title = pwd()
75
- @dir = Dir.new(Dir.getwd)
76
- @wdir = @dir.path
77
- @prev_dirs << @wdir
78
- rescan
79
- rescue => err
80
- @rfe.status_row.text = err.to_s
81
- end
82
- end
83
- def goto_previous_dir
84
- #alert "Previous dirs contain #{@prev_dirs} "
85
- d = @prev_dirs.pop
86
- if !d.nil? and d == @wdir
87
- d = @prev_dirs.pop
88
- end
89
- change_dir d unless d.nil?
90
- end
91
- def filter list
92
- list.delete_if { |f|
93
- !File.directory? @wdir +"/"+ f and !File.fnmatch?(@filter_pattern, f)
94
- }
95
- #$log.debug " FILTER CALLED AFTER #{list.size}, #{list.entries}"
96
- end
97
- def rescan
98
- flist = @dir.entries
99
- $entry_count = flist.size # just for show... may not be accurate after deletes etc
100
- flist.shift
101
- #populate @entries
102
- populate flist
103
- end
104
- def populate flist
105
- #fl << format_string("..", nil)
106
- #fl = []
107
- #flist.each {|f| ff = "#{@wdir}/#{f}"; stat = File.stat(ff)
108
- # fl << format_string(f, stat)
109
- #}
110
- filter(flist) if @filter_pattern != '*'
111
- @entries = flist
112
- list.list_data_model.remove_all
113
- #list.list_data_model.insert 0, *fl
114
- list.list_data_model.insert 0, *flist
115
- list.set_form_row
116
- #$entry_count = list.size # just for show... may not be accurate after deletes etc
117
- end
118
- def sort key, reverse=false
119
- # remove parent before sorting, keep at top
120
- first = @entries.delete_at(0) if @entries[0]==".."
121
- key ||= @sort_key
122
- cdir=cur_dir()+"/"
123
- case key
124
- when :size
125
- @entries.sort! {|x,y| xs = File.stat(cdir+x); ys = File.stat(cdir+y);
126
- if reverse
127
- xs.size <=> ys.size
128
- else
129
- ys.size <=> xs.size
130
- end
131
- }
132
- when :mtime
133
- @entries.sort! {|x,y| xs = File.stat(cdir+x); ys = File.stat(cdir+y);
134
- if reverse
135
- xs.mtime <=> ys.mtime
136
- else
137
- ys.mtime <=> xs.mtime
138
- end
139
- }
140
- when :atime
141
- @entries.sort! {|x,y| xs = File.stat(cdir+x); ys = File.stat(cdir+y);
142
- if reverse
143
- xs.atime <=> ys.atime
144
- else
145
- ys.atime <=> xs.atime
146
- end
147
- }
148
- when :name
149
- @entries.sort! {|x,y| x <=> y
150
- if reverse
151
- x <=> y
152
- else
153
- y <=> x
154
- end
155
- }
156
- when :ext
157
- @entries.sort! {|x,y|
158
- if reverse
159
- File.extname(cdir+x) <=> File.extname(cdir+y)
160
- else
161
- File.extname(cdir+y) <=> File.extname(cdir+x)
162
- end
163
- }
164
- end
165
- @sort_key = key
166
- @entries.insert 0, first unless first.nil? # keep parent on top
167
- populate @entries
168
- end
169
- GIGA_SIZE = 1073741824.0
170
- MEGA_SIZE = 1048576.0
171
- KILO_SIZE = 1024.0
172
-
173
- # Return the file size with a readable style.
174
- def readable_file_size(size, precision)
175
- case
176
- #when size == 1 : "1 B"
177
- when size < KILO_SIZE then "%d B" % size
178
- when size < MEGA_SIZE then "%.#{precision}f K" % (size / KILO_SIZE)
179
- when size < GIGA_SIZE then "%.#{precision}f M" % (size / MEGA_SIZE)
180
- else "%.#{precision}f G" % (size / GIGA_SIZE)
181
- end
182
- end
183
- def date_format t
184
- t.strftime "%Y/%m/%d"
185
- end
186
- def oldformat_string fn, stat
187
- max_len = 30
188
- f = fn.dup
189
- if File.directory? f
190
- #"%-*s\t(dir)" % [max_len,f]
191
- #f = "/"+f # disallows search on keypress
192
- f = f + "/ "
193
- end
194
- if f.size > max_len
195
- f = f[0..max_len-1]
196
- end
197
- "%-*s\t%10s\t%s" % [max_len,f, readable_file_size(stat.size,1), date_format(stat.mtime)]
198
- end
199
- def cur_dir
200
- @dir.path
201
- end
202
- alias :current_dir :cur_dir
203
- def draw_screen dir=nil
204
- # I get an error here if dir in yaml file is non-existent, like deleted or copied from another machine
205
- # 2010-08-22 19:25
206
- if dir
207
- if File.exists?(dir) && File.directory?(dir)
208
- cd dir unless dir.nil?
209
- else
210
- dir = nil
211
- end
212
- end
213
-
214
- wdir = FileUtils.pwd
215
- @prev_dirs << wdir
216
- @dir = Dir.new(Dir.getwd)
217
- @wdir = @dir.path
218
- r = @row
219
- c = @col
220
- #cola = 1
221
- #colb = Ncurses.COLS/2
222
- ht = @ht
223
- wid = @wid
224
- #fl = Dir.glob(default_pattern)
225
- #flist << format_string("..", nil)
226
- fl = @dir.entries
227
- fl.shift
228
- filter(fl)
229
- #flist = []
230
- #fl.each {|f| stat = File.stat(f)
231
- # flist << format_string(f, stat)
232
- #}
233
- @entries = fl
234
- $entry_count = @entries.size
235
- title = pwd()
236
- @wdir = title
237
- rfe = self
238
-
239
- lista = Listbox.new @form do
240
- name "lista"
241
- row r
242
- col c
243
- width wid
244
- height ht
245
- #list flist
246
- list fl
247
- title wdir
248
- #title_attrib 'reverse'
249
- cell_renderer RfeRenderer.new "", {"color"=>@color, "bgcolor"=>@bgcolor, "parent" => rfe, "display_length"=> wid-2}
250
- KEY_ROW_SELECTOR 0 # C-space since space used for preview
251
- end
252
- @list = lista
253
- lista.bind(:ENTER) {|l| @rfe.current_list(self); l.title_attrib 'reverse'; }
254
- lista.bind(:LEAVE) {|l| l.title_attrib 'normal'; }
255
-
256
-
257
- #row_cmd = lambda {|list| file = list.list_data_model[list.current_index].split(/\t/)[0].strip; @rfe.status_row.text = File.stat("#{cur_dir()}/#{file}").inspect }
258
- row_cmd = lambda {|lb, list| file = list.entries[lb.current_index]; @rfe.status_row.text = file; # File.stat("#{cur_dir()}/#{file}").inspect
259
- }
260
- lista.bind(:ENTER_ROW, self) {|lb,list| row_cmd.call(lb,list) }
261
-
262
- end
263
- def list_data
264
- @list.list_data_model
265
- end
266
- def current_index
267
- @list.current_index
268
- end
269
- def filename ix=current_index()
270
- #@entries[@list.current_index]
271
- list_data()[ix]
272
- end
273
- def filepath ix=current_index()
274
- f = filename(ix)
275
- return unless f
276
- if f[0,1]=='/'
277
- f
278
- else
279
- cur_dir() + "/" + f
280
- end
281
- end
282
- # delete the item at position i
283
- def delete_at i=@list.current_index
284
- ret = @list.list_data_model.delete_at i
285
- ret = @entries.delete_at i
286
- end
287
- def delete obj
288
- ret = @list.list_data_model.delete obj
289
- ret = @entries.delete_at obj
290
- end
291
- def insert_at obj, ix = @list.current_index
292
- @list.list_data_model.insert ix, f
293
- @entries.insert ix, obj
294
- end
295
- def remove_selected_rows
296
- rows = @list.selected_rows
297
- rows=rows.sort! {|x,y| y <=> x }
298
- rows.each do |i|
299
- ret = @list.list_data_model.delete_at i
300
- ret = @entries.delete_at i
301
- end
302
- end
303
-
304
- # ADD
305
- end
306
- class RFe
307
- attr_reader :status_row
308
- def initialize
309
- @window = VER::Window.root_window
310
- @form = Form.new @window
311
- status_row = RubyCurses::Label.new @form, {'text' => "", :row => Ncurses.LINES-4, :col => 0, :display_length=>Ncurses.COLS-2}
312
- @status_row = status_row
313
- colb = Ncurses.COLS/2
314
- ht = Ncurses.LINES - 5
315
- wid = Ncurses.COLS/2 - 0
316
- @trash_path = File.expand_path("~/.Trash")
317
- @trash_exists = File.directory? @trash_path
318
- $log.debug " trash_path #{@trash_path}, #{@trash_exists}"
319
- @lista = FileExplorer.new @form, self, row=1, col=1, ht, wid
320
- @listb = FileExplorer.new @form, self, row=1, col=colb, ht, wid
321
-
322
- init_vars
323
- end
324
- def init_vars
325
- @bookmarks=[]
326
- @config_name = File.expand_path("~/.rfe.yml")
327
- if File.exist? @config_name
328
- @config = YAML::load( File.open(@config_name));
329
- if !@config.nil?
330
- @bookmarks = @config["bookmarks"]||[]
331
- @last_dirs = @config["last_dirs"]
332
- end
333
- end
334
- @config ||={}
335
- @stopping = false
336
- end
337
- def save_config
338
- @config["last_dirs"]=[@lista.current_dir(),@listb.current_dir()]
339
- File.open(@config_name, "w") { | f | YAML.dump( @config, f )}
340
- end
341
- def move
342
- fp = @current_list.filepath #.gsub(' ',"\ ")
343
- fn = @current_list.filename
344
- $log.debug " FP #{fp}"
345
- other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
346
- other_dir = other_list.cur_dir
347
- $log.debug " OL #{other_list.cur_dir}"
348
- if @current_list.list.selected_row_count == 0
349
- str= "#{fn}"
350
- else
351
- str= "#{@current_list.list.selected_row_count} files "
352
- end
353
- mb = RubyCurses::MessageBox.new do
354
- title "Move"
355
- message "Move #{str} to"
356
- type :input
357
- width 80
358
- default_value other_dir
359
- button_type :ok_cancel
360
- default_button 0
361
- end
362
- #confirm "selected :#{mb.input_value}, #{mb.selected_index}"
363
- if mb.selected_index == 0
364
- if @current_list.list.selected_row_count == 0
365
- FileUtils.move(fp, mb.input_value)
366
- #ret = @current_list.list.list().delete_at @current_list.list.current_index # ???
367
- # @current_list.entries.delete_at @current_list.current_index
368
- @current_list.delete_at
369
- else
370
- each_selected_row do |f|
371
- FileUtils.move(f, mb.input_value)
372
- end
373
- @current_list.remove_selected_rows
374
- @current_list.list.clear_selection
375
- end
376
- other_list.rescan
377
- end
378
- end
379
- def each_selected_row #title, message, default_value
380
- rows = @current_list.list.selected_rows
381
- rows = rows.dup
382
- rows.each do |i|
383
- fp = @current_list.filepath i
384
- #$log.debug " moving #{i}: #{fp}"
385
- #FileUtils.move(fp, mb.input_value)
386
- yield fp
387
- end
388
- end
389
- def copy
390
- fp = @current_list.filepath #.gsub(' ',"\ ")
391
- fn = @current_list.filename
392
- $log.debug " FP #{fp}"
393
- other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
394
- other_dir = other_list.cur_dir
395
- $log.debug " OL #{other_list.cur_dir}"
396
- if @current_list.list.selected_row_count == 0
397
- str= "#{fn}"
398
- else
399
- str= "#{@current_list.list.selected_row_count} files "
400
- end
401
- mb = RubyCurses::MessageBox.new do
402
- title "Copy"
403
- message "Copy #{str} to"
404
- type :input
405
- width 80
406
- default_value other_dir
407
- button_type :ok_cancel
408
- default_button 0
409
- end
410
- if mb.selected_index == 0
411
- if @current_list.list.selected_row_count == 0
412
- FileUtils.copy(fp, mb.input_value)
413
- else
414
- each_selected_row do |f|
415
- FileUtils.copy(f, mb.input_value)
416
- end
417
- @current_list.list.clear_selection
418
- end
419
- other_list.rescan
420
- end
421
- end
422
- def delete
423
- fp = @current_list.filepath #.gsub(' ',"\ ")
424
- fn = @current_list.filename
425
- if @current_list.list.selected_row_count == 0
426
- str= "#{fn}"
427
- else
428
- str= "#{@current_list.list.selected_row_count} files "
429
- end
430
- if confirm("delete #{str}")==:YES
431
- if @current_list.list.selected_row_count == 0
432
- if @trash_exists
433
- FileUtils.mv fp, @trash_path
434
- else
435
- FileUtils.rm fp
436
- end
437
- ret=@current_list.delete_at
438
- else
439
- each_selected_row do |f|
440
- if @trash_exists
441
- FileUtils.mv f, @trash_path
442
- else
443
- FileUtils.rm f
444
- end
445
- end
446
- @current_list.remove_selected_rows
447
- @current_list.list.clear_selection
448
- end
449
- end
450
- end
451
- def copy1
452
- fp = @current_list.filepath
453
- fn = @current_list.filename
454
- $log.debug " FP #{fp}"
455
- other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
456
- other_dir = other_list.cur_dir
457
- $log.debug " OL #{other_list.cur_dir}"
458
- str= "copy #{fn} to #{other_list.cur_dir}"
459
- $log.debug " copy #{fp}"
460
- #confirm "#{str}"
461
- mb = RubyCurses::MessageBox.new do
462
- title "Copy"
463
- message "Copy #{fn} to"
464
- type :input
465
- width 60
466
- default_value other_dir
467
- button_type :ok_cancel
468
- default_button 0
469
- end
470
- #confirm "selected :#{mb.input_value}, #{mb.selected_index}"
471
- if mb.selected_index == 0
472
- # need to redraw directories
473
- FileUtils.copy(fp, mb.input_value)
474
- other_list.rescan
475
- end
476
- end
477
- ## TODO : make this separate and callable with its own keylabels
478
- def view content=nil # can throw IO errors
479
- require 'rbcurse/rtextview'
480
- wt = 0
481
- wl = 0
482
- wh = Ncurses.LINES-wt
483
- ww = Ncurses.COLS-wl
484
- if content.nil?
485
- begin
486
- fp = @current_list.filepath
487
- content = get_contents(fp)
488
- rescue => err
489
- $log.debug err.to_s
490
- $log.debug(err.backtrace.join("\n"))
491
- alert err.to_s
492
- return
493
- end
494
- else
495
- fp=""
496
- end
497
- @layout = { :height => wh, :width => ww, :top => wt, :left => wl }
498
- @v_window = VER::Window.new(@layout)
499
- @v_form = RubyCurses::Form.new @v_window
500
- @textview = TextView.new @v_form do
501
- name "myView"
502
- row 0
503
- col 0
504
- width ww
505
- height wh-2
506
- title fp
507
- title_attrib 'bold'
508
- print_footer true
509
- footer_attrib 'bold'
510
- end
511
- #content = File.open(fp,"r").readlines
512
- begin
513
- @textview.set_content content #, :WRAP_WORD
514
- @v_form.repaint
515
- @v_window.wrefresh
516
- Ncurses::Panel.update_panels
517
- while((ch = @v_window.getchar()) != ?\C-q.getbyte(0) )
518
- break if ch == FFI::NCurses::KEY_F3
519
- @v_form.handle_key ch
520
- @v_form.repaint
521
- ##@v_window.wrefresh
522
- end
523
- rescue => err
524
- alert err.to_s
525
- ensure
526
- @v_window.destroy if !@v_window.nil?
527
- end
528
- end
529
- def get_contents fp
530
- return nil unless File.readable? fp
531
- return Dir.new(fp).entries if File.directory? fp
532
- case File.extname(fp)
533
- when '.tgz','.gz'
534
- cmd = "tar -ztvf #{fp}"
535
- content = %x[#{cmd}]
536
- when '.zip'
537
- cmd = "unzip -l #{fp}"
538
- content = %x[#{cmd}]
539
- else
540
- content = File.open(fp,"r").readlines
541
- end
542
- end
543
- def opt_file c
544
- fp = @current_list.filepath
545
- fn = @current_list.filename
546
- other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
547
- case c
548
- when 'c'
549
- copy
550
- when 'm'
551
- move
552
- when 'd'
553
- delete
554
- when 'u'
555
- str= "move #{fn} to #{other_list.cur_dir}"
556
- if confirm("#{str}")==:YES
557
- $log.debug " MOVE #{str}"
558
- end
559
- when 'v'
560
- str= "view #{fp}"
561
- #if confirm("#{str}")==:YES
562
- $log.debug " VIEW #{fp}"
563
- view
564
- #end
565
- when 'r'
566
- str= "ruby #{fn}"
567
- if confirm("#{str}")=='y'
568
- $log.debug " #{str} "
569
- end
570
- when 'e'
571
- str= "edit #{fp}"
572
- #if confirm("#{str}")==:YES
573
- edit fp
574
- when 'x'
575
- str= "exec #{fp}"
576
- exec_popup fp
577
- when 'p'
578
- page fp
579
- when 'q'
580
- qlmanage fp
581
- end
582
- end
583
- def opt_dir c
584
- fp = @current_list.filepath
585
- fn = @current_list.filename
586
- case c
587
- when 'O'
588
- # str= "copy #{fn} to #{other_list.cur_dir}"
589
- if File.directory? @current_list.filepath
590
- @current_list.change_dir fp
591
- end
592
- when 'o'
593
- if File.directory? @current_list.filepath
594
- @other_list.change_dir fp
595
- end
596
- @open_in_other = true # ???basically keep opening in other
597
- when 'd'
598
- str= "delete #{fn} "
599
- if confirm("#{str}")==:YES
600
- $log.debug " delete #{fp}"
601
- FileUtils.rm fp
602
- ret=@current_list.list.list_data_model.delete_at @current_list.list.current_index # ???
603
- $log.debug " DEL RET #{ret},#{@current_list.list.current_index}"
604
- end
605
- when 'u'
606
- str= "move #{fn} to #{other_list.cur_dir}"
607
- if confirm("#{str}")==:YES
608
- $log.debug " MOVE #{str}"
609
- end
610
- when 'b'
611
- dd = @current_list.wdir
612
- @bookmarks << dd unless @bookmarks.include? dd
613
- when 'u'
614
- dd = @current_list.wdir
615
- @bookmarks.delete dd
616
- when 'l'
617
- @current_list.populate @bookmarks
618
- when 's'
619
- @config["bookmarks"] = @bookmarks
620
- save_config
621
- when 'e'
622
- str= "edit #{fp}"
623
- #if confirm("#{str}")==:YES
624
- edit fp
625
- when 'm'
626
- f = get_string("Enter a directory to create", 20 )
627
- if f != ""
628
- FileUtils.mkdir f
629
- @current_list.list.list_data_model.insert @current_list.list.current_index, f # ???
630
- @current_list.entries.insert @current_list.list.current_index, f # ???
631
- end
632
-
633
- when 'x'
634
- str= "exec #{fp}"
635
- exec_popup fp
636
- end
637
- end
638
- def exec_popup fp
639
- last_exec_def1 = @last_exec_def1 || ""
640
- last_exec_def2 = @last_exec_def2 || false
641
-
642
- sel, inp, hash = get_string_with_options("Enter a command to execute on #{fp}", 30, last_exec_def1, {"checkboxes" => ["view result"], "checkbox_defaults"=>[last_exec_def2]})
643
- if sel == 0
644
- @last_exec_def1 = inp
645
- @last_exec_def2 = hash["view result"]
646
- cmd = "#{inp} #{fp}"
647
- filestr = %x[ #{cmd} 2>/dev/null ]
648
- if hash["view result"]==true
649
- view filestr
650
- end
651
- end
652
- end
653
- def edit fp=@current_list.filepath
654
- $log.debug " edit #{fp}"
655
- editor = ENV['EDITOR'] || 'vi'
656
- vimp = %x[which #{editor}].chomp
657
- shell_out "#{vimp} #{fp}"
658
- end
659
-
660
- # TODO we need to move these to some common file so differnt programs and demos
661
- # can use them on pressing space or enter.
662
- def page fp=@current_list.filepath
663
- ft=%x[file #{fp}]
664
- if ft.index("text")
665
- pager = ENV['PAGER'] || 'less'
666
- vimp = %x[which #{pager}].chomp
667
- shell_out "#{vimp} #{fp}"
668
- elsif ft.index(/zip/i)
669
- shell_out "tar tvf #{fp} | less"
670
- elsif ft.index(/directory/i)
671
- shell_out "ls -lh #{fp} | less"
672
- else
673
- alert "#{fp} is not text, not paging "
674
- #use_on_file "als", fp # only zip or archive
675
- end
676
- end
677
- def qlmanage fp=@current_list.filepath
678
- begin
679
- a=%x[which qlmanage]
680
- if a != ""
681
- cmd="qlmanage -p #{@current_list.filepath} 2>/dev/null"
682
- %x[#{cmd}]
683
- else
684
- alert "qlmanage not present on your system. Trying pager"
685
- page fp
686
- end
687
- rescue Interrupt
688
- rescue => err
689
- alert err.to_s
690
- end
691
- end
692
- # also if calling program gives output but does not stop
693
- # or take control, then nothing will show up
694
- def use_on_file prog, args, fp=@current_list.filepath
695
- vimp = %x[which #{prog}].chomp
696
- if vimp != ""
697
- alert "using #{prog} "
698
- shell_out "#{vimp} #{args } #{fp}"
699
- else
700
- alert "could not locate #{prog} "
701
- end
702
- end
703
- def stopping?
704
- @stopping
705
- end
706
- def draw_screens
707
- lasta = lastb = nil
708
- if !@config["last_dirs"].nil?
709
- lasta = @config["last_dirs"][0]
710
- lastb = @config["last_dirs"][1]
711
- end
712
- @lista.draw_screen lasta
713
- @listb.draw_screen lastb
714
-
715
- # @form.bind_key(?\M-x){
716
- # @current_list.mark_block
717
- # }
718
- # i am just testing out double key bindings
719
- @form.bind_key([?\C-w,?v]){
720
- @status_row.text = "got C-w, v"
721
- $log.debug " Got C-w v "
722
- view()
723
- }
724
- @form.bind_key([?\C-w,?e]){
725
- @status_row.text = "got C-w, e"
726
- $log.debug " Got C-w e "
727
- edit()
728
- }
729
- # bind dd to delete file
730
- # actually this should be in listbox, and we should listen for row delete and then call opt_file
731
- @form.bind_key([?d,?d]){
732
- opt_file 'd'
733
- }
734
- @form.bind_key([?q,?q]){
735
- @stopping = true
736
- }
737
- # this won't work since the listbox will consume the d first
738
- @form.bind_key(?@){
739
- @current_list.change_dir File.expand_path("~/")
740
- }
741
- @form.bind_key(?^){
742
- @current_list.change_dir @current_list.prev_dirs[0] unless @current_list.prev_dirs.empty?
743
- }
744
- @form.bind_key(?\C-f){
745
- @klp.mode :file
746
- @klp.repaint
747
- while((ch = @window.getchar()) != ?\C-c.getbyte(0) )
748
- if ch < 33 || ch > 126
749
- Ncurses.beep
750
- elsif "cmdsuvrexpq".index(ch.chr) == nil
751
- Ncurses.beep
752
- else
753
- opt_file ch.chr
754
- break
755
- end
756
- end
757
- @klp.mode :normal
758
- }
759
- @form.bind_key(?\C-d){
760
- @klp.mode :dir
761
- @klp.repaint
762
- keys = @klp.get_current_keys
763
- while((ch = @window.getchar()) != ?\C-c.getbyte(0) )
764
- if ch < 33 || ch > 126
765
- Ncurses.beep
766
- elsif !keys.include?(ch.chr)
767
- Ncurses.beep
768
- else
769
- opt_dir ch.chr
770
- break
771
- end
772
- end
773
- @klp.mode :normal
774
- }
775
- # backspace
776
- @form.bind_key(127){
777
- @current_list.goto_previous_dir
778
- }
779
- # form gives this to list which consumes it for selection.
780
- # need to bind to list's LIST_SELECTION_EVENT
781
- @form.bind_key(32){
782
- fp = @current_list.filepath
783
- page fp
784
- }
785
- @form.bind_key(FFI::NCurses::KEY_F3){
786
- begin
787
- view()
788
- rescue => err
789
- alert err.to_s
790
- end
791
- }
792
- @form.bind_key(FFI::NCurses::KEY_F1){
793
- #Io.view(["this is some help text","hello there"])
794
- color0 = get_color($promptcolor, 'black','green')
795
- color1 = get_color($reversecolor, 'green','black')
796
- color2 = get_color($reversecolor, 'magenta','black')
797
- arr = []
798
- #arr << " FILE BROWSER HELP "
799
- arr << [color0," FILE BROWSER HELP ", FFI::NCurses::A_NORMAL]
800
- arr << " "
801
- arr << [[color1," <tab> ",nil],[color2, "- switch between windows", nil]]
802
- arr << [[color1," <enter> ",nil],[color2, "- open dir", nil]]
803
- arr << [[color1," F3 ",nil],[color2, "- view file/dir/zip contents (toggle) ", nil]]
804
- arr << [[color1," F4 ",nil],[color2, "- edit file content", nil]]
805
- arr << [[color1," <char> ", nil],[color2, "first file starting with <char>",nil]]
806
- #arr << " VIM MODE "
807
- arr << [color0," VIM MODE ", FFI::NCurses::A_NORMAL]
808
- arr << [[color1," M",nil],[color2, "-v - Vim like bindings for navigation (toggle)", nil]]
809
- arr << " jk gg G up down motion, C-n C-p, Alt-0, Alt-9 "
810
- arr << [[color1," p or Space ",nil],[color2, "- use pager on current file", nil]]
811
- arr << [[color1," q ",nil],[color2, "- use qlmanage on file ",nil],[$promptcolor, " (OSX)", nil]]
812
- arr << [[color1," f<char> ",nil],[color2, "- first file starting with <char>", nil]]
813
-
814
- arr << " "
815
- arr << " < > ^ V - move help window "
816
- arr << " "
817
- # next line does not work due to chunks
818
- w = arr.max_by(&:length).length
819
- #arr = ["this is some help text","hello there"]
820
-
821
- require 'rbcurse/extras/viewer'
822
- RubyCurses::Viewer.view(arr, :layout => [10,10, 4+arr.size, w+2],:close_key => KEY_RETURN, :title => "<Enter> to close", :print_footer => false) do |t|
823
- # you may configure textview further here.
824
- #t.suppress_borders true
825
- #t.color = :black
826
- #t.bgcolor = :white
827
- # or
828
- #t.attr = :reverse
829
- t.attr = :normal
830
- #t.bind_key(KEY_F1){ alert "closing up!"; throw :close }
831
- # just for kicks move window around
832
- t.bind_key('<'){ f = t.form.window; c = f.left - 1; f.hide; f.mvwin(f.top, c); f.show;
833
- f.reset_layout([f.height, f.width, f.top, c]);
834
- }
835
- t.bind_key('>'){ f = t.form.window; c = f.left + 1; f.hide; f.mvwin(f.top, c);
836
- f.reset_layout([f.height, f.width, f.top, c]); f.show;
837
- }
838
- t.bind_key('^'){ f = t.form.window; c = f.top - 1 ; f.hide; f.mvwin(c, f.left);
839
- f.reset_layout([f.height, f.width, c, f.left]) ; f.show;
840
- }
841
- t.bind_key('V'){ f = t.form.window; c = f.top + 1 ; f.hide; f.mvwin(c, f.left);
842
- f.reset_layout([f.height, f.width, c, f.left]); f.show;
843
- }
844
- end
845
- }
846
- @form.bind_key(FFI::NCurses::KEY_F4){
847
- edit()
848
- }
849
- @form.bind_key(FFI::NCurses::KEY_F6){
850
- selected_index, sort_key, reverse, case_sensitive = sort_popup
851
- if selected_index == 0
852
- @current_list.sort(sort_key, reverse)
853
- end
854
- }
855
- @form.bind_key(FFI::NCurses::KEY_F5){
856
- filter()
857
- }
858
- @form.bind_key(FFI::NCurses::KEY_F7){
859
- grep_popup()
860
- }
861
- @form.bind_key(FFI::NCurses::KEY_F8){
862
- system_popup()
863
- }
864
- # will work if you are in vim mode
865
- @form.bind_key(?p){
866
- page
867
- }
868
- @form.bind_key(?q){
869
- qlmanage
870
- }
871
- # will no longer come here. list event has to be used
872
- #@form.bind_key(?\C-m){ # listbox has eaten it up
873
- @lista.list.bind(:PRESS){
874
- dir = @current_list.filepath
875
- if File.directory? @current_list.filepath
876
- @current_list.change_dir dir
877
- end
878
- }
879
- @listb.list.bind(:PRESS){
880
- dir = @current_list.filepath
881
- if File.directory? @current_list.filepath
882
- @current_list.change_dir dir
883
- end
884
- }
885
- gw = get_color($reversecolor, 'green', 'black')
886
- bw = get_color($datacolor, 'blue', 'black')
887
- @klp = RubyCurses::KeyLabelPrinter.new @form, get_key_labels
888
- @klp.footer_color_pair = bw
889
- @klp.footer_mnemonic_color_pair = gw
890
- @klp.set_key_labels get_key_labels(:file), :file
891
- @klp.set_key_labels get_key_labels(:view), :view
892
- @klp.set_key_labels get_key_labels(:dir), :dir
893
- @form.repaint
894
- @window.wrefresh
895
- Ncurses::Panel.update_panels
896
- begin
897
- chunks=["File","Key"]
898
- color0 = get_color($promptcolor, 'black','cyan')
899
- color1 = get_color($datacolor, 'white','cyan')
900
-
901
- ## qq stops program, but only if M-v (vim mode)
902
- while(!stopping? && (ch = @window.getchar()) != ?\C-q.getbyte(0) )
903
- s = keycode_tos ch
904
- #status_row.text = "| Pressed #{ch} , #{s}"
905
- @form.handle_key(ch)
906
-
907
- # the following is just a test of show_colored_chunks
908
- #count = @current_list.list.size
909
- count1 = @lista.list.size
910
- count2 = @listb.list.size
911
- x, y = FFI::NCurses::getyx @window.get_window
912
- chunks[0]=[color0, "%-30s" % status_row.text, FFI::NCurses::A_BOLD]
913
- chunks[1]=[color1, "%-18s" % " | #{ch}, #{s} |", FFI::NCurses::A_NORMAL]
914
- chunks[2]=[color0, " Total: #{count1}, #{count2}"]
915
- @window.wmove(Ncurses.LINES-3,0)
916
- @window.color_set(color0, nil)
917
- @window.print_empty_line
918
- @window.wmove(Ncurses.LINES-3,0)
919
- @window.show_colored_chunks chunks
920
- @window.wmove(x,y)
921
-
922
- #@form.repaint
923
- @window.wrefresh
924
- end
925
- ensure
926
- @window.destroy if !@window.nil?
927
- save_config
928
- end
929
-
930
- end
931
- # TODO
932
- #
933
- #
934
- #
935
-
936
- # current_list
937
- ##
938
- # getter and setter for current_list
939
- def current_list(*val)
940
- if val.empty?
941
- @current_list
942
- else
943
- @current_list = val[0]
944
- @other_list = [@lista, @listb].index(@current_list)==0 ? @listb : @lista
945
- end
946
- end
947
- def get_key_labels categ=nil
948
- if categ.nil?
949
- key_labels = [
950
- ['C-q', 'Exit'], ['C-v', 'View'],
951
- ['C-f', 'File'], ['C-d', 'Dir'],
952
- ['C-Sp','Select'], ['Spc', "Preview"],
953
- ['F3', 'View'], ['F4', 'Edit'],
954
- ['F5', 'Filter'], ['F6', 'Sort'],
955
- ['F7', 'Grep'], ['F8', 'System'],
956
- ['M-0', 'Top'], ['M-9', 'End'],
957
- ['C-p', 'PgUp'], ['C-n', 'PgDn'],
958
- ['M-v', 'Vim Mode'], ['BSpc', 'PrevDir']
959
- ]
960
- elsif categ == :file
961
- key_labels = [
962
- ['c', 'Copy'], ['m', 'Move'],
963
- ['d', 'Delete'], ['v', 'View'],
964
- ['s', 'Select'], ['u', 'Unselect'],
965
- ['p', 'Page'], ['x', 'Exec Cmd'],
966
- ['r', 'ruby'], ['e', "Edit"],
967
- ['C-c', 'Cancel']
968
- ]
969
- elsif categ == :view
970
- key_labels = [
971
- ['c', 'Date'], ['m', 'Size'],
972
- ['d', 'Delete'], ['v', 'View'],
973
- ['C-c', 'Cancel']
974
- ]
975
- elsif categ == :dir
976
- key_labels = [
977
- ['o', 'open'], ['O', 'Open in right'],
978
- ['d', 'Delete'], ['R', 'Del Recurse'],
979
- ['t', 'tree'], ['p', 'Previous'],
980
- ['b', 'Bookmark'], ['u', 'Unbookmark'],
981
- ['l', 'List'], ['s', 'Save'],
982
- ['m', 'mkdir'], nil,
983
- ['C-c', 'Cancel']
984
- ]
985
- end
986
- return key_labels
987
- end
988
- def get_key_labels_table
989
- key_labels = [
990
- ['M-n','NewRow'], ['M-d','DelRow'],
991
- ['C-x','Select'], nil,
992
- ['M-0', 'Top'], ['M-9', 'End'],
993
- ['C-p', 'PgUp'], ['C-n', 'PgDn'],
994
- ['M-Tab','Nxt Fld'], ['Tab','Nxt Col'],
995
- ['+','Widen'], ['-','Narrow']
996
- ]
997
- return key_labels
998
- end
999
- def sort_popup
1000
- mform = RubyCurses::Form.new nil
1001
- field_list = []
1002
- r = 4
1003
- $radio = RubyCurses::Variable.new
1004
- rtextvalue = [:name, :ext, :size, :mtime, :atime]
1005
- ["Name", "Extension", "Size", "Modify Time", "Access Time" ].each_with_index do |rtext,ix|
1006
- field = RubyCurses::RadioButton.new mform do
1007
- variable $radio
1008
- text rtext
1009
- value rtextvalue[ix]
1010
- color 'black'
1011
- bgcolor 'white'
1012
- row r
1013
- col 5
1014
- end
1015
- field_list << field
1016
- r += 1
1017
- end
1018
- r = 4
1019
- ["Reverse", "case sensitive"].each do |cbtext|
1020
- field = RubyCurses::CheckBox.new mform do
1021
- text cbtext
1022
- name cbtext
1023
- color 'black'
1024
- bgcolor 'white'
1025
- row r
1026
- col 30
1027
- end
1028
- field_list << field
1029
- r += 1
1030
- end
1031
- mb = RubyCurses::MessageBox.new mform do
1032
- title "Sort Options"
1033
- button_type :ok_cancel
1034
- default_button 0
1035
- end
1036
- if mb.selected_index == 0
1037
- $log.debug " SORT POPUP #{$radio.value}"
1038
- #$log.debug " SORT POPUP #{mb.inspect}"
1039
- $log.debug " SORT POPUP #{mform.by_name["Reverse"].value}"
1040
- $log.debug " SORT POPUP #{mform.by_name["case sensitive"].value}"
1041
- end
1042
- return mb.selected_index, $radio.value, mform.by_name["Reverse"].value, mform.by_name["case sensitive"].value
1043
- end
1044
- def filter
1045
- f = get_string("Enter a filter pattern", 20, "*")
1046
- f = "*" if f.nil? or f == ""
1047
- @current_list.filter_pattern = f
1048
- @current_list.rescan
1049
- end
1050
-
1051
- # ask user for pattern to grep through files
1052
- # and display file names in same list
1053
-
1054
- def grep_popup
1055
- last_regex = @last_regex || ""
1056
- last_pattern = @last_pattern || "*"
1057
- mform = RubyCurses::Form.new nil
1058
- r = 4
1059
- field = RubyCurses::Field.new mform do
1060
- name "regex"
1061
- row r
1062
- col 30
1063
- set_buffer last_regex
1064
- set_label Label.new @form, {'text' => 'Regex', 'col'=>5, :color=>'black',:bgcolor=>'white','mnemonic'=> 'R'}
1065
- end
1066
- r += 1
1067
- field = RubyCurses::Field.new mform do
1068
- name "filepattern"
1069
- row r
1070
- col 30
1071
- set_buffer last_pattern
1072
- set_label Label.new @form, {'text' => 'File Pattern','col'=>5, :color=>'black',:bgcolor=>'white','mnemonic'=> 'F'}
1073
- end
1074
- r += 1
1075
- ["Recurse", "case insensitive"].each do |cbtext|
1076
- field = RubyCurses::CheckBox.new mform do
1077
- text cbtext
1078
- name cbtext
1079
- color 'black'
1080
- bgcolor 'white'
1081
- row r
1082
- col 5
1083
- end
1084
- r += 1
1085
- end
1086
- mb = RubyCurses::MessageBox.new mform do
1087
- title "Grep Options"
1088
- button_type :ok_cancel
1089
- default_button 0
1090
- end
1091
- if mb.selected_index == 0
1092
- return if mform.by_name["regex"].getvalue()==""
1093
- @last_regex = mform.by_name["regex"].getvalue
1094
- inp = mform.by_name["regex"].getvalue
1095
- fp = mform.by_name["filepattern"].getvalue
1096
- @last_pattern = fp
1097
- flags=""
1098
- flags << " -i " if mform.by_name["case insensitive"].value==true
1099
- flags << " -R " if mform.by_name["Recurse"].value==true
1100
- # sometimes grep pukes "No such file or directory if you specify some
1101
- # filespec that is not present. I don't want it to come in filestr
1102
- # so i am not piping stderr to stdout
1103
- cmd = "cd #{@current_list.cur_dir()};grep -l #{flags} #{inp} #{fp}"
1104
- filestr = %x[ #{cmd} ]
1105
- files = nil
1106
- files = filestr.split(/\n/) unless filestr.nil?
1107
- #view filestr
1108
- if !files || files.empty?
1109
- alert "Sorry! No files for regex #{inp}"
1110
- return
1111
- end
1112
- @current_list.title "grep #{inp}"
1113
- @current_list.populate files
1114
- # Use backspace to go back
1115
- end
1116
- return mb.selected_index, mform.by_name["regex"].getvalue, mform.by_name["filepattern"].getvalue, mform.by_name["Recurse"].value, mform.by_name["case insensitive"].value
1117
- end
1118
-
1119
- def system_popup
1120
- deflt = @last_system || ""
1121
- options=["run in shell","view output","file explorer"]
1122
- #inp = get_string("Enter a system command", 30, deflt)
1123
- sel, inp, hash = get_string_with_options("Enter a system command", 40, deflt, {"radiobuttons" => options, "radio_default"=>@last_system_radio || options[0]})
1124
- if sel == 0
1125
- if !inp.nil?
1126
- @last_system = inp
1127
- @last_system_radio = hash["radio"]
1128
- case hash["radio"]
1129
- when options[0]
1130
- shell_out inp
1131
- when options[1]
1132
- filestr = %x[ #{inp} ]
1133
- view filestr
1134
- when options[2]
1135
- filestr = %x[ #{inp} ]
1136
- files = nil
1137
- files = filestr.split(/\n/) unless filestr.nil?
1138
- @current_list.title inp
1139
- @current_list.populate files
1140
- $log.debug " SYSTEM got #{files.size}, #{files.inspect}"
1141
- end
1142
- end
1143
- end
1144
- end
1145
- def popup
1146
- deflt = @last_regexp || ""
1147
- #sel, inp, hash = get_string_with_options("Enter a filter pattern", 20, "*", {"checkboxes" => ["case sensitive","reverse"], "checkbox_defaults"=>[true, false]})
1148
- sel, inp, hash = get_string_with_options("Enter a grep pattern", 20, deflt, {"checkboxes" => ["case insensitive","not-including"]})
1149
- if sel == 0
1150
- @last_regexp = inp
1151
- flags=""
1152
- flags << " -i " if hash["case insensitive"]==true
1153
- flags << " -v " if hash["not-including"]==true
1154
- cmd = "grep -l #{flags} #{inp} *"
1155
- filestr = %x[ #{cmd} ]
1156
- files = nil
1157
- files = filestr.split(/\n/) unless filestr.nil?
1158
- view filestr
1159
- end
1160
- $log.debug " POPUP: #{sel}: #{inp}, #{hash['case sensitive']}, #{hash['reverse']}"
1161
- end
1162
- def shell_out command
1163
- @window.hide
1164
- Ncurses.endwin
1165
- system command
1166
- Ncurses.refresh
1167
- #Ncurses.curs_set 0 # why ?
1168
- @window.show
1169
- end
1170
- end
1171
- if $0 == __FILE__
1172
- include RubyCurses
1173
- include RubyCurses::Utils
1174
-
1175
- begin
1176
- # Initialize curses
1177
- VER::start_ncurses # this is initializing colors via ColorMap.setup
1178
- #$log = Logger.new("rbc13.log")
1179
- $log = Logger.new(ENV['LOGDIR'] || "" + "rbc13.log")
1180
-
1181
- $log.level = Logger::DEBUG
1182
-
1183
- catch(:close) do
1184
- t = RFe.new
1185
- t.draw_screens
1186
- end
1187
- rescue => ex
1188
- ensure
1189
- VER::stop_ncurses
1190
- p ex if ex
1191
- p(ex.backtrace.join("\n")) if ex
1192
- $log.debug( ex) if ex
1193
- $log.debug(ex.backtrace.join("\n")) if ex
1194
- end
1195
- end