redcar 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/CHANGES +41 -1
  2. data/README.md +1 -1
  3. data/Rakefile +5 -6
  4. data/lib/plugin_manager/lib/plugin_manager.rb +1 -2
  5. data/lib/redcar.rb +19 -14
  6. data/lib/redcar/installer.rb +21 -17
  7. data/lib/redcar/runner.rb +10 -7
  8. data/lib/redcar/usage.rb +1 -0
  9. data/lib/redcar_quick_start.rb +8 -12
  10. data/lib/regex_replace.rb +3 -3
  11. data/plugins/application/features/step_definitions/menu_steps.rb +10 -0
  12. data/plugins/application/features/step_definitions/speedbar_steps.rb +8 -2
  13. data/plugins/application/features/step_definitions/tree_steps.rb +48 -6
  14. data/plugins/application/features/step_definitions/window_steps.rb +9 -4
  15. data/plugins/application/features/support/env.rb +20 -1
  16. data/plugins/application/features/support/fake_event.rb +14 -0
  17. data/plugins/application/lib/application.rb +29 -12
  18. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +19 -0
  19. data/plugins/application/lib/application/speedbar.rb +23 -17
  20. data/plugins/application/lib/application/tab.rb +20 -15
  21. data/plugins/application/lib/application/treebook.rb +10 -7
  22. data/plugins/application/lib/application/window.rb +1 -1
  23. data/plugins/application/plugin.rb +1 -1
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -4
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +15 -4
  26. data/plugins/application_swt/lib/application_swt/icon.rb +3 -5
  27. data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +4 -4
  28. data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +5 -5
  29. data/plugins/application_swt/lib/application_swt/speedbar.rb +34 -120
  30. data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
  31. data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +38 -0
  32. data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
  33. data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
  34. data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
  35. data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
  36. data/plugins/application_swt/lib/application_swt/tab.rb +1 -3
  37. data/plugins/application_swt/lib/application_swt/toolbar.rb +19 -20
  38. data/plugins/application_swt/lib/application_swt/treebook.rb +24 -9
  39. data/plugins/application_swt/lib/application_swt/window.rb +110 -98
  40. data/plugins/application_swt/lib/swt/vtab_folder.rb +77 -32
  41. data/plugins/application_swt/lib/swt/vtab_item.rb +9 -0
  42. data/plugins/application_swt/lib/swt/vtab_label.rb +63 -23
  43. data/plugins/application_swt/plugin.rb +1 -1
  44. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +2 -2
  45. data/plugins/comment/features/line_comment.feature +116 -4
  46. data/plugins/comment/lib/comment.rb +18 -16
  47. data/plugins/connection_manager/lib/connection_manager/commands.rb +1 -1
  48. data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +5 -3
  49. data/plugins/declarations/lib/declarations.rb +1 -1
  50. data/plugins/declarations/lib/declarations/parser.rb +68 -20
  51. data/plugins/document_search/features/replace.feature +18 -0
  52. data/plugins/document_search/lib/document_search.rb +37 -54
  53. data/plugins/document_search/lib/document_search/replace_all_command.rb +27 -0
  54. data/plugins/document_search/lib/document_search/replace_command.rb +38 -0
  55. data/plugins/document_search/lib/document_search/replace_next_command.rb +27 -0
  56. data/plugins/document_search/lib/document_search/search_and_replace.rb +17 -24
  57. data/plugins/edit_view/features/step_definitions/editing_steps.rb +4 -4
  58. data/plugins/edit_view/features/step_definitions/tab_steps.rb +9 -0
  59. data/plugins/edit_view/features/step_definitions/window_steps.rb +0 -12
  60. data/plugins/edit_view/lib/edit_view/document.rb +2 -0
  61. data/plugins/edit_view/lib/edit_view/document/command.rb +8 -8
  62. data/plugins/edit_view/lib/edit_view/edit_tab.rb +21 -7
  63. data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +6 -0
  64. data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +6 -0
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +92 -43
  66. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +17 -4
  67. data/plugins/find-in-project/lib/find_in_project.rb +1 -4
  68. data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -14
  69. data/plugins/find-in-project/lib/find_in_project/controllers.rb +12 -0
  70. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +5 -0
  71. data/plugins/groovy/features/fixtures/test.groovy +0 -0
  72. data/plugins/groovy/features/step_definitions/groovy_steps.rb +27 -0
  73. data/plugins/groovy/features/support/env.rb +27 -0
  74. data/plugins/groovy/features/syntax_check_groovy.feature +72 -0
  75. data/plugins/groovy/lib/syntax_check/groovy.rb +76 -0
  76. data/plugins/groovy/plugin.rb +7 -0
  77. data/plugins/help/lib/help.rb +28 -4
  78. data/plugins/help/lib/help/help_tab.rb +11 -0
  79. data/plugins/help/lib/help/view_controller.rb +25 -0
  80. data/plugins/help/plugin.rb +2 -1
  81. data/plugins/{view_shortcuts → help}/views/default.css +0 -0
  82. data/plugins/{view_shortcuts → help}/views/index.html.erb +1 -1
  83. data/plugins/{view_shortcuts → help}/views/redcar_small_icon.png +0 -0
  84. data/plugins/html_view/features/browser_bar.feature +47 -0
  85. data/plugins/html_view/features/fixtures/other.html +1 -0
  86. data/plugins/html_view/features/fixtures/sample.html +1 -0
  87. data/plugins/html_view/features/step_definitions/html_view_steps.rb +45 -5
  88. data/plugins/html_view/features/support/env.rb +26 -0
  89. data/plugins/html_view/features/web_preview.feature +21 -0
  90. data/plugins/html_view/lib/html_controller.rb +5 -5
  91. data/plugins/html_view/lib/html_view.rb +62 -10
  92. data/plugins/{web_bookmarks/lib/web_bookmarks → html_view/lib/html_view}/browser_bar.rb +32 -20
  93. data/plugins/html_view/lib/html_view/commands.rb +64 -0
  94. data/plugins/{web_bookmarks/lib/web_bookmarks/view_controller.rb → html_view/lib/html_view/default_controller.rb} +7 -6
  95. data/plugins/html_view/lib/html_view/html_tab.rb +17 -6
  96. data/plugins/html_view/plugin.rb +3 -3
  97. data/plugins/{web_bookmarks → html_view}/views/index.html.erb +0 -0
  98. data/plugins/javascript/features/fixtures/test.js +0 -0
  99. data/plugins/javascript/features/support/env.rb +4 -0
  100. data/plugins/javascript/features/syntax_check_javascript.feature +27 -0
  101. data/plugins/javascript/lib/syntax_check/javascript.rb +52 -0
  102. data/plugins/javascript/plugin.rb +7 -0
  103. data/plugins/javascript/vendor/jslint.js +539 -0
  104. data/plugins/macros/lib/macros/commands.rb +3 -3
  105. data/plugins/open_default_app/lib/open_default_app.rb +29 -3
  106. data/plugins/open_default_app/plugin.rb +1 -1
  107. data/plugins/outline_view/features/outline_view.feature +79 -0
  108. data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
  109. data/plugins/outline_view/lib/outline_view.rb +1 -1
  110. data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
  111. data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
  112. data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
  113. data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
  114. data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
  115. data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
  116. data/plugins/outline_view_swt/lib/outline_view_swt.rb +17 -19
  117. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +1 -4
  118. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +12 -3
  119. data/plugins/project/features/close_directory_tree.feature +27 -0
  120. data/plugins/project/features/highlight_focussed_tab.feature +45 -1
  121. data/plugins/project/features/open_and_save_files.feature +33 -0
  122. data/plugins/project/features/open_directory_tree.feature +37 -11
  123. data/plugins/project/features/step_definitions/directory_steps.rb +1 -1
  124. data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
  125. data/plugins/project/features/support/env.rb +17 -0
  126. data/plugins/project/lib/project.rb +12 -2
  127. data/plugins/project/lib/project/commands.rb +101 -99
  128. data/plugins/project/lib/project/drb_service.rb +55 -65
  129. data/plugins/project/lib/project/manager.rb +29 -4
  130. data/plugins/project/lib/project/project_tree_controller.rb +24 -0
  131. data/plugins/project/lib/project/support/trash.rb +1 -0
  132. data/plugins/redcar/redcar.rb +100 -37
  133. data/plugins/redcar_debug/lib/redcar_debug.rb +3 -3
  134. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -0
  135. data/plugins/repl/lib/repl.rb +4 -11
  136. data/plugins/repl/lib/repl/repl_tab.rb +26 -0
  137. data/plugins/ruby/features/fixtures/test.rb +0 -0
  138. data/plugins/ruby/features/support/env.rb +4 -0
  139. data/plugins/ruby/features/syntax_check_ruby.feature +25 -0
  140. data/plugins/runnables/features/command_tree.feature +28 -0
  141. data/plugins/runnables/lib/runnables.rb +1 -0
  142. data/plugins/runnables/lib/runnables/commands.rb +4 -4
  143. data/plugins/runnables/lib/runnables/output_processor.rb +5 -5
  144. data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +2 -7
  145. data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +13 -8
  146. data/plugins/scm_git/lib/scm_git/change.rb +5 -5
  147. data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
  148. data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
  149. data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +3 -38
  150. data/plugins/swt/lib/swt.rb +5 -13
  151. data/plugins/swt/lib/swt/full_swt.rb +15 -13
  152. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +7 -0
  153. data/plugins/syntax_check/lib/syntax_check.rb +21 -3
  154. data/plugins/syntax_check/lib/syntax_check/error.rb +4 -3
  155. data/plugins/task_manager/lib/task_manager.rb +1 -1
  156. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Autocompletions.tmPreferences +345 -0
  157. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Symbol List Target.tmPreferences +22 -0
  158. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Snippets/Doc Banner.tmSnippet +20 -0
  159. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Syntaxes/Ant.tmLanguage +247 -0
  160. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/info.plist +55 -0
  161. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/Syntaxes/GroovyRepl.plist +40 -0
  162. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +1 -1
  163. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Haml.tmbundle/Syntaxes/Ruby_Haml.tmLanguage +0 -1
  164. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/Syntaxes/Ruby Sass.tmLanguage +626 -0
  165. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/info.plist +16 -0
  166. data/plugins/todo_list/features/support/env.rb +8 -0
  167. data/plugins/todo_list/features/todo_list.feature +26 -0
  168. data/plugins/todo_list/lib/todo_list.rb +1 -0
  169. data/plugins/todo_list/lib/todo_list/file_parser.rb +23 -19
  170. data/plugins/todo_list/lib/todo_list/todo_controller.rb +60 -100
  171. data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
  172. data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
  173. data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
  174. data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
  175. data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
  176. data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
  177. data/plugins/todo_list/spec/spec_helper.rb +6 -0
  178. data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
  179. data/plugins/tree/lib/tree.rb +1 -0
  180. data/plugins/tree/lib/tree/command.rb +5 -0
  181. data/plugins/web_bookmarks/features/bookmark.feature +37 -0
  182. data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
  183. data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
  184. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
  185. data/plugins/web_bookmarks/features/support/env.rb +26 -0
  186. data/plugins/web_bookmarks/lib/web_bookmarks.rb +0 -10
  187. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +10 -1
  188. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -47
  189. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +21 -14
  190. data/{plugins/application → share}/icons/close.png +0 -0
  191. data/{plugins/application → share}/icons/darwin-file.png +0 -0
  192. data/{plugins/application → share}/icons/darwin-folder.png +0 -0
  193. data/share/icons/open-source-flipped.png +0 -0
  194. data/{plugins/application/icons/redcar_icon_beta_dev.png → share/icons/redcar-icon-beta-dev.png} +0 -0
  195. data/{plugins/application/icons/redcar_icon_beta.png → share/icons/redcar-icon-beta.png} +0 -0
  196. data/{plugins/application → share}/icons/redcar-splash.png +0 -0
  197. metadata +90 -30
  198. data/lib/redcar/jvm_options_probe.rb +0 -33
  199. data/plugins/document_search/lib/document_search/replace.rb +0 -113
  200. data/plugins/document_search/lib/document_search/search.rb +0 -45
  201. data/plugins/outline_view_swt/lib/icons/alias.png +0 -0
  202. data/plugins/outline_view_swt/lib/icons/assignment.png +0 -0
  203. data/plugins/outline_view_swt/lib/icons/attribute.png +0 -0
  204. data/plugins/outline_view_swt/lib/icons/class.png +0 -0
  205. data/plugins/outline_view_swt/lib/icons/interface.png +0 -0
  206. data/plugins/outline_view_swt/lib/icons/method.png +0 -0
  207. data/plugins/strip_trailing_spaces/CHANGELOG +0 -12
  208. data/plugins/strip_trailing_spaces/README.md +0 -32
  209. data/plugins/view_shortcuts/lib/view_shortcuts.rb +0 -52
  210. data/plugins/view_shortcuts/plugin.rb +0 -11
@@ -40,10 +40,8 @@ module Redcar
40
40
 
41
41
  def execute
42
42
  if tab.edit_view.document.modified?
43
- result = Application::Dialog.message_box(
44
- "This tab has unsaved changes. \n\nReload?",
45
- :buttons => :yes_no_cancel
46
- )
43
+ result = Application::Dialog.message_box("This tab has unsaved changes. \n\nReload?",
44
+ :buttons => :yes_no_cancel)
47
45
  case result
48
46
  when :yes
49
47
  tab.edit_view.document.update_from_mirror
@@ -82,13 +80,8 @@ module Redcar
82
80
  button :connect, "Connect", "Return" do
83
81
  selected = self.class.connections.find { |c| c.name == connection.value }
84
82
 
85
- Manager.connect_to_remote(
86
- selected[:protocol],
87
- selected[:host],
88
- selected[:user],
89
- selected[:path],
90
- ConnectionManager::PrivateKeyStore.paths
91
- )
83
+ Manager.connect_to_remote(selected[:protocol], selected[:host],
84
+ selected[:user], selected[:path], ConnectionManager::PrivateKeyStore.paths)
92
85
  end
93
86
 
94
87
  button :quick, "Quick Connection", "Ctrl+Q" do
@@ -123,13 +116,8 @@ module Redcar
123
116
  textbox :path
124
117
 
125
118
  button :connect, "Connect", "Return" do
126
- Manager.connect_to_remote(
127
- protocol.value,
128
- host.value,
129
- user.value,
130
- path.value,
131
- ConnectionManager::PrivateKeyStore.paths
132
- )
119
+ Manager.connect_to_remote(protocol.value, host.value, user.value,
120
+ path.value, ConnectionManager::PrivateKeyStore.paths)
133
121
  end
134
122
  end
135
123
 
@@ -217,13 +205,6 @@ module Redcar
217
205
  end
218
206
  end
219
207
 
220
- class DirectoryCloseCommand < ProjectCommand
221
-
222
- def execute
223
- project.close
224
- end
225
- end
226
-
227
208
  class RefreshDirectoryCommand < ProjectCommand
228
209
 
229
210
  def execute
@@ -247,13 +228,17 @@ module Redcar
247
228
  def execute
248
229
  if project and project.window.trees_visible?
249
230
  tab = Redcar.app.focussed_window.focussed_notebook_tab
250
- return unless tab.is_a?(EditTab) && tab.edit_view.document.mirror
231
+ if tab.is_a?(EditTab)
232
+ return unless mirror = tab.edit_view.document.mirror and mirror.respond_to? :path
233
+ else
234
+ return
235
+ end
251
236
 
252
- path = tab.edit_view.document.mirror.path
237
+ path = mirror.path
253
238
  tree = project.tree
254
239
  current = tree.tree_mirror.top
255
240
  while current.any?
256
- ancestor_node = current.detect {|node| path =~ /^#{node.path}($|\/)/}
241
+ ancestor_node = current.detect {|node| path =~ /^#{node.path}($|\/)/ }
257
242
  return unless ancestor_node
258
243
  tree.expand(ancestor_node)
259
244
  current = ancestor_node.children
@@ -264,6 +249,9 @@ module Redcar
264
249
  end
265
250
  end
266
251
 
252
+ # FIXME: XXX: The rest of this file is outright ugly. The Redcar.platform ultimately
253
+ # needs to return a platform object which we can dispatch to for commandlines,
254
+ # configuration, escaping and all that.
267
255
  class OpenCommand < Command
268
256
  attr_reader :path
269
257
 
@@ -286,15 +274,12 @@ module Redcar
286
274
  end
287
275
 
288
276
  def run_application(app, *options)
289
- if SPOON_AVAILABLE and ::Spoon.supported?
277
+ # TODO: Investigate why Spoon doesn't seem to work on osx
278
+ if SPOON_AVAILABLE and ::Spoon.supported? and Redcar.platform != :osx
290
279
  ::Spoon.spawn(app, *options)
291
280
  else
292
281
  # TODO: This really needs proper escaping.
293
- if options
294
- options = options.map {|o| "\"#{o}\""}.join(' ')
295
- else
296
- options = ""
297
- end
282
+ options = options.map {|o| %{ "#{o}" } }.join(' ')
298
283
  Thread.new do
299
284
  system("#{app} #{options}")
300
285
  puts " Finished: #{app} #{options}"
@@ -304,78 +289,95 @@ module Redcar
304
289
  end
305
290
 
306
291
  class OpenDirectoryInExplorerCommand < OpenCommand
307
- def execute(options=nil)
308
- @path ||= options[:value]
309
- command = self
292
+ LinuxApps = { 'Thunar' => '%s',
293
+ 'nautilus' => '%s',
294
+ 'konqueror' => '%s',
295
+ 'kfm' => '%s' }
296
+
297
+ def explorer_osx
298
+ ['open -a Finder', path]
299
+ end
300
+
301
+ def explorer_windows
302
+ ['explorer.exe', path.gsub("/", "\\")]
303
+ end
304
+
305
+ def explorer_linux
310
306
  preferred = Manager.storage['preferred_file_browser']
311
- case Redcar.platform
312
- when :osx
313
- # Spoon doesn't seem to like `open`
314
- system('open', '-a', 'Finder', path)
315
- when :windows
316
- run_application('explorer.exe', path.gsub("/","\\"))
317
- when :linux
318
- app = {
319
- 'Thunar' => [path],
320
- 'nautilus' => [path],
321
- 'konqueror' => [path],
322
- 'kfm' => [path],
323
- }
324
- if preferred and app[preferred] and find(preferred)
325
- run = preferred
326
- else
327
- run = app.keys.map {|a| command.find(a)}.find{|a| a}
328
- Manager.storage['preferred_file_browser'] = run if not preferred
329
- end
330
- if run
331
- run_application(run, *app[File.basename(run)])
332
- else
333
- Application::Dialog.message_box("Sorry, we couldn't find your file manager. Please let us know what file manager you use, so we can fix this!")
334
- end
307
+ run = preferred if LinuxApps[preferred] and find(preferred)
308
+ LinuxApps.keys.detect {|a| run = @command.find(a) } unless run
309
+
310
+ Manager.storage['preferred_file_browser'] = run unless preferred
311
+
312
+ [run, LinuxApps[File.basename(run)] % path ] if run
313
+ end
314
+
315
+ def execute(options = nil)
316
+ @path ||= options[:value]
317
+ @command = self
318
+ cmd = send(:"explorer_#{Redcar.platform}")
319
+ if cmd
320
+ run_application(*cmd)
321
+ else
322
+ Application::Dialog.message_box("Sorry, we couldn't start your file manager. Please let us know what file manager you use, so we can fix this!")
335
323
  end
336
324
  end
337
325
  end
338
326
 
339
327
  class OpenDirectoryInCommandLineCommand < OpenCommand
340
- def execute(options=nil)
341
- @path ||= options[:value]
342
- command = self
343
- preferred = Manager.storage['preferred_command_line']
344
- case Redcar.platform
345
- when :osx
346
- unless preferred
347
- preferred = "Terminal"
348
- Manager.storage['preferred_command_line'] = preferred
349
- end
350
- command = <<-BASH.gsub(/^\s{12}/, '')
351
- osascript <<END
352
- tell application "#{preferred}"
353
- do script "cd \\\"#{path}\\\""
354
- activate
328
+ LinuxApps = { 'xfce4-terminal' => "--working-directory=%s",
329
+ 'gnome-terminal' => "--working-directory=%s",
330
+ 'konsole' => "--workdir %s" }
331
+
332
+ def osx_terminal_script(preferred)
333
+ if preferred.start_with? "iTerm"
334
+ <<-OSASCRIPT
335
+ tell the first terminal
336
+ launch session "Default Session"
337
+ tell the last session
338
+ write text "cd \\\"#{path}\\\""
355
339
  end tell
356
- END
357
- BASH
358
- # Spoon doesn't seem to work with `osascript`
359
- system(command)
360
- when :windows
361
- run_application('start cmd.exe', '/kcd ' + path.gsub("/","\\"))
362
- when :linux
363
- app = {
364
- 'xfce4-terminal' => ["--working-directory=#{path}"],
365
- 'gnome-terminal' => ["--working-directory=#{path}"],
366
- 'konsole' => ["--workdir", path],
367
- }
368
- if preferred and app[preferred] and find(preferred)
369
- run = preferred
370
- else
371
- run = app.keys.map {|a| command.find(a)}.find{|a| a}
372
- Manager.storage['preferred_command_line'] = run if not preferred
373
- end
374
- if run and app[File.basename(run)]
375
- run_application(run, *app[File.basename(run)])
376
- else
377
- Application::Dialog.message_box("Sorry, we couldn't find your command line. Please let us know what command line you use, so we can fix this!")
378
- end
340
+ end tell
341
+ OSASCRIPT
342
+ else
343
+ %{ do script "cd \\\"#{path}\\\"" }
344
+ end
345
+ end
346
+
347
+ def commandline_osx
348
+ preferred = (Manager.storage['preferred_command_line'] ||= "Terminal")
349
+ <<-BASH.gsub(/^\s*/, '')
350
+ osascript <<END
351
+ tell application "#{preferred}"
352
+ #{osx_terminal_script(preferred)}
353
+ activate
354
+ end tell
355
+ END
356
+ BASH
357
+ end
358
+
359
+ def commandline_windows
360
+ ['start cmd.exe /kcd ', path.gsub("/","\\")]
361
+ end
362
+
363
+ def commandline_linux
364
+ preferred = Manager.storage['preferred_command_line']
365
+ run = preferred if LinuxApps[preferred] and find(preferred)
366
+ LinuxApps.keys.detect {|a| run = @command.find(a) } unless run
367
+
368
+ Manager.storage['preferred_command_line'] = run unless preferred
369
+
370
+ [run, LinuxApps[File.basename(run)] % path ] if run
371
+ end
372
+
373
+ def execute(options = nil)
374
+ @path ||= options[:value]
375
+ @command = self
376
+ cmd = send(:"commandline_#{Redcar.platform}")
377
+ if cmd
378
+ run_application(*cmd)
379
+ else
380
+ Application::Dialog.message_box("Sorry, we couldn't start your command line. Please let us know what command line you use, so we can fix this!")
379
381
  end
380
382
  end
381
383
  end
@@ -2,89 +2,79 @@ module Redcar
2
2
  class Project
3
3
  class DrbService
4
4
  def initialize
5
- begin
6
- address = "druby://127.0.0.1:#{DRB_PORT}"
7
- @drb = DRb.start_service(address, self)
8
- rescue Errno::EADDRINUSE => e
9
- puts 'warning--not starting listener (perhaps theres another Redcar already open?)' + e + ' ' + address
5
+ address = "druby://127.0.0.1:#{DRB_PORT}"
6
+ @drb = DRb.start_service(address, self)
7
+ rescue Errno::EADDRINUSE => e
8
+ puts 'warning--not starting listener (perhaps theres another Redcar already open?)' + e + ' ' + address
9
+ end
10
+
11
+ def open_item_drb(full_path, untitled = false, wait = false)
12
+ puts %{drb opening #{"untitled" if untitled} #{full_path}} if $VERBOSE
13
+ if File.directory? full_path
14
+ Swt.sync_exec { open_directory(full_path) }
15
+ elsif full_path == 'just_bring_to_front'
16
+ Swt.sync_exec { bring_to_front }
17
+ elsif File.file?(full_path)
18
+ open_file(full_path, untitled, wait)
10
19
  end
20
+ 'ok'
21
+ rescue Exception => e
22
+ puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
23
+ raise e
11
24
  end
12
25
 
13
- def open_item_drb(full_path, untitled = false)
14
- begin
15
- puts %{drb opening #{"untitled" if untitled} #{full_path}} if $VERBOSE
16
- if File.directory? full_path
17
- Swt.sync_exec do
18
- if Redcar.app.windows.length == 0 and Application.storage['last_open_dir'] == full_path
19
- Project::Manager.restore_last_session
20
- end
21
-
22
- if Redcar.app.windows.length > 0
23
- window = Redcar.app.windows.find do |win|
24
- next unless win
25
- win.treebook.trees.find do |t|
26
- t.tree_mirror.is_a?(Redcar::Project::DirMirror) and t.tree_mirror.path == full_path
27
- end
28
- end
29
- end
30
- Project::Manager.open_project_for_path(full_path)
31
- Redcar.app.focussed_window.controller.bring_to_front
32
- end
33
- 'ok'
34
- elsif full_path == 'just_bring_to_front'
35
- Swt.sync_exec do
36
- if Redcar.app.windows.length == 0
37
- Project::Manager.restore_last_session
38
- end
39
- Redcar.app.focussed_window.controller.bring_to_front
40
- end
41
- 'ok'
42
- elsif File.file?(full_path)
43
- Swt.sync_exec do
44
- if Redcar.app.windows.length == 0
45
- Project::Manager.restore_last_session
46
- end
47
- if untitled
48
- Project::Manager.open_untitled_path(full_path)
49
- else
50
- Project::Manager.open_file(full_path)
51
- end
52
- Redcar.app.focussed_window.controller.bring_to_front
53
- end
54
- 'ok'
55
- end
56
- rescue Exception => e
57
- puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
58
- raise e
26
+ ##
27
+ # Opens the specified directory in a new window, if it was not
28
+ # already open. Brings the project's window to the front, if this
29
+ # directory is already opened. If the specified directory was the last open
30
+ # directory, restores the complete session.
31
+ def open_directory(full_path)
32
+ if Redcar.app.windows.empty? and Application.storage['last_open_dir'] == full_path
33
+ Project::Manager.restore_last_session
59
34
  end
35
+
36
+ Redcar::Project.window_projects.each_pair do |window, project|
37
+ return window.controller.bring_to_front if project.path == full_path
38
+ end
39
+ Project::Manager.open_project_for_path(full_path)
40
+ Redcar.app.focussed_window.controller.bring_to_front
60
41
  end
61
42
 
62
- def open_file_and_wait(file, untitled = false)
63
- semaphore = Mutex.new
64
- handler = nil
65
- tab = nil
66
- Swt.sync_exec do
67
- semaphore.lock
43
+ ## Focuses a Redcar window
44
+ def bring_to_front
45
+ Project::Manager.restore_last_session if Redcar.app.windows.empty?
46
+ Redcar.app.focussed_window.controller.bring_to_front
47
+ end
48
+
49
+ ##
50
+ # Opens a file, optionally untitled, and waits for it to close, if requested
51
+ def open_file(file, untitled, wait)
52
+ file_open_block = Proc.new do
68
53
  Project::Manager.restore_last_session if Redcar.app.windows.empty?
69
54
  if untitled
70
55
  Project::Manager.open_untitled_path(file)
71
56
  else
72
57
  Project::Manager.open_file(file)
73
58
  end
74
- window = Redcar.app.focussed_window
75
- window.controller.bring_to_front
76
- tab = window.focussed_notebook_tab
59
+ Redcar.app.focussed_window.controller.bring_to_front
60
+ end
61
+ wait ? open_file_and_wait(&file_open_block) : Swt.sync_exec(&file_open_block)
62
+ end
63
+
64
+ def open_file_and_wait
65
+ semaphore = Mutex.new
66
+ handler = nil
67
+ tab = nil
68
+ Swt.sync_exec do
69
+ semaphore.lock
70
+ yield
71
+ tab = Redcar.app.focussed_window.focussed_notebook_tab
77
72
  handler = tab.add_listener(:close) { semaphore.unlock }
78
73
  end
79
74
  Thread.new(tab, handler) do
80
75
  semaphore.synchronize { tab.remove_listener(handler) }
81
76
  end.join # Wait until the tab's close event was fired
82
- 'ok'
83
- rescue Exception => e
84
- puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
85
- raise e
86
77
  end
87
-
88
78
  end
89
79
  end
90
80
  end
@@ -162,6 +162,33 @@ module Redcar
162
162
  window.focus
163
163
  end
164
164
 
165
+ def self.pop_first_line_option(args)
166
+ if args.include? '-l'
167
+ argix = args.index('-l')
168
+ raise ArgumentError, "The -l Option expects an Argument" unless args[argix + 1]
169
+ numbers = args[argix + 1].split(',')
170
+ first_num = numbers.delete_at(0)
171
+ if (args[argix + 1] = numbers.join(',')).empty?
172
+ args.delete_at(argix); args.delete_at(argix)
173
+ end
174
+ first_num
175
+ elsif match = args.select {|a| /^\-l\d+$/.match a }.first
176
+ args.delete(args.index(match))
177
+ match[2..-1]
178
+ end
179
+ end
180
+
181
+ def self.scroll_to_line(arg)
182
+ begin
183
+ doc = Redcar.app.focussed_notebook_tab.edit_view.document
184
+ lineix = arg.to_i - 1
185
+ doc.scroll_to_line(lineix)
186
+ doc.cursor_offset = doc.offset_at_line(lineix)
187
+ rescue Exception
188
+ raise ArgumentError, 'The "-l" Option expects a number as Argument'
189
+ end
190
+ end
191
+
165
192
  def self.open_tab_with_content(text)
166
193
  win = Redcar.app.focussed_window || Redcar.app.new_window
167
194
  tab = win.new_tab(Redcar::EditTab)
@@ -224,6 +251,8 @@ module Redcar
224
251
  elsif File.file?(arg)
225
252
  found_path_args = true
226
253
  open_file(arg)
254
+ linearg = pop_first_line_option(args)
255
+ scroll_to_line(linearg) if linearg
227
256
  end
228
257
  end
229
258
  args.each do |arg|
@@ -319,10 +348,6 @@ module Redcar
319
348
  item "Save", Project::FileSaveCommand
320
349
  item "Save As", Project::FileSaveAsCommand
321
350
  end
322
-
323
- group(:priority => 11) do
324
- item "Close Directory", Project::DirectoryCloseCommand
325
- end
326
351
  end
327
352
  sub_menu "Project", :priority => 15 do
328
353
  group(:priority => :first) do