redcar 0.11.0dev → 0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/CHANGES +14 -1
  2. data/README.md +28 -8
  3. data/Rakefile +23 -18
  4. data/bin/redcar +9 -4
  5. data/lib/redcar.rb +42 -4
  6. data/lib/redcar/installer.rb +7 -2
  7. data/lib/redcar/logger.rb +64 -0
  8. data/lib/redcar/runner.rb +17 -8
  9. data/lib/redcar/usage.rb +2 -0
  10. data/plugins/application/features/step_definitions/tree_steps.rb +4 -4
  11. data/plugins/application/features/support/env.rb +6 -6
  12. data/plugins/application/lib/application.rb +31 -3
  13. data/plugins/application/lib/application/command.rb +6 -0
  14. data/plugins/application/lib/application/command/executor.rb +0 -1
  15. data/plugins/application/lib/application/commands/application_commands.rb +21 -0
  16. data/plugins/application/lib/application/commands/notebook_commands.rb +73 -0
  17. data/plugins/application/lib/application/commands/tab_commands.rb +105 -0
  18. data/plugins/application/lib/application/commands/treebook_commands.rb +117 -0
  19. data/plugins/application/lib/application/commands/window_commands.rb +68 -0
  20. data/plugins/{tree/lib → application/lib/application}/tree.rb +0 -4
  21. data/plugins/{tree/lib → application/lib/application}/tree/command.rb +0 -0
  22. data/plugins/{tree/lib → application/lib/application}/tree/controller.rb +0 -0
  23. data/plugins/{tree/lib → application/lib/application}/tree/mirror.rb +0 -0
  24. data/plugins/application/spec/application/keymap/builder_spec.rb +1 -1
  25. data/plugins/application/spec/application/menu/builder_spec.rb +2 -2
  26. data/plugins/application_swt/lib/application_swt.rb +4 -2
  27. data/plugins/application_swt/lib/swt/vtab_label.rb +6 -3
  28. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +6 -3
  29. data/plugins/clojure/lib/clojure.rb +2 -2
  30. data/plugins/core/lib/core.rb +0 -4
  31. data/plugins/core/lib/core/gui.rb +2 -4
  32. data/plugins/core/lib/core/plugin/storage.rb +68 -21
  33. data/plugins/core/spec/core/base_storage_spec.rb +81 -0
  34. data/plugins/core/spec/core/shared_storage_spec.rb +49 -0
  35. data/plugins/core/spec/core/storage_spec.rb +13 -63
  36. data/plugins/declarations/lib/declarations.rb +3 -1
  37. data/plugins/document_search/features/replace.feature +29 -20
  38. data/plugins/document_search/lib/document_search/find_speedbar.rb +4 -1
  39. data/plugins/edit_view/features/indentation_commands.feature +6 -5
  40. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +4 -4
  41. data/plugins/edit_view/features/step_definitions/tab_steps.rb +7 -7
  42. data/plugins/edit_view/features/step_definitions/window_steps.rb +2 -2
  43. data/plugins/edit_view/lib/edit_view.rb +15 -1
  44. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +7 -7
  45. data/plugins/edit_view_swt/lib/edit_view_swt.rb +7 -6
  46. data/plugins/execute_current_tab/lib/execute_current_tab.rb +1 -1
  47. data/plugins/groovy/lib/groovy.rb +3 -3
  48. data/plugins/groovy/lib/groovy/commands.rb +1 -1
  49. data/plugins/help/lib/help/view_controller.rb +5 -0
  50. data/plugins/help/views/index.html.erb +10 -1
  51. data/plugins/html_view/features/step_definitions/html_view_steps.rb +1 -1
  52. data/plugins/html_view/features/support/env.rb +0 -15
  53. data/plugins/html_view/lib/html_view.rb +3 -4
  54. data/plugins/html_view/lib/html_view/commands.rb +1 -1
  55. data/plugins/key_bindings/lib/key_bindings.rb +34 -0
  56. data/plugins/key_bindings/plugin.rb +8 -0
  57. data/plugins/{tree → key_bindings}/spec/spec_helper.rb +0 -0
  58. data/plugins/line_tools/features/lower_text.feature +3 -4
  59. data/plugins/line_tools/lib/line_tools.rb +6 -5
  60. data/plugins/mirah/lib/mirah.rb +2 -2
  61. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +5 -3
  62. data/plugins/project/features/open_directory_tree.feature +1 -1
  63. data/plugins/project/features/step_definitions/file_steps.rb +5 -5
  64. data/plugins/project/features/step_definitions/find_file_steps.rb +2 -3
  65. data/plugins/project/features/support/env.rb +4 -0
  66. data/plugins/project/lib/project.rb +15 -9
  67. data/plugins/project/lib/project/commands.rb +46 -16
  68. data/plugins/project/lib/project/dir_controller.rb +1 -1
  69. data/plugins/project/lib/project/dir_mirror.rb +3 -2
  70. data/plugins/project/lib/project/drb_service.rb +3 -1
  71. data/plugins/project/lib/project/file_list.rb +99 -21
  72. data/plugins/project/lib/project/find_file_dialog.rb +8 -24
  73. data/plugins/project/lib/project/manager.rb +68 -12
  74. data/plugins/project/lib/project/project_tree_controller.rb +1 -1
  75. data/plugins/project/plugin.rb +1 -2
  76. data/plugins/project_search/features/word_search.feature +1 -1
  77. data/plugins/project_search/lib/project_search.rb +16 -6
  78. data/plugins/project_search/lib/project_search/commands.rb +15 -28
  79. data/plugins/project_search/lib/project_search/hit.rb +4 -0
  80. data/plugins/project_search/lib/project_search/lucene_index.rb +14 -4
  81. data/plugins/project_search/lib/project_search/views/_file.html.erb +11 -11
  82. data/plugins/project_search/lib/project_search/word_search.rb +22 -4
  83. data/plugins/project_search/spec/project_search/word_search_spec.rb +2 -2
  84. data/plugins/redcar/redcar.rb +140 -588
  85. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -3
  86. data/plugins/repl/features/support/fake_repl.rb +1 -1
  87. data/plugins/ruby/lib/ruby.rb +4 -4
  88. data/plugins/runnables/features/fixtures/alternate.ruby +1 -0
  89. data/plugins/runnables/features/fixtures/line_app.rb +1 -0
  90. data/plugins/runnables/features/fixtures/name_app.rb +1 -0
  91. data/plugins/runnables/features/fixtures/params_app.rb +1 -0
  92. data/plugins/runnables/features/fixtures/runnable_app.rb +1 -0
  93. data/plugins/runnables/lib/runnables.rb +21 -0
  94. data/plugins/runnables/lib/runnables/command_output_controller.rb +14 -9
  95. data/plugins/runnables/lib/runnables/output_processor.rb +4 -4
  96. data/plugins/runnables/lib/runnables/running_process_checker.rb +6 -6
  97. data/plugins/runnables/plugin.rb +1 -2
  98. data/plugins/scm/lib/scm.rb +18 -18
  99. data/plugins/scm/lib/scm/commit_mirror.rb +2 -2
  100. data/plugins/scm/lib/scm/scm_changes_controller.rb +1 -1
  101. data/plugins/scm_hg/lib/scm_hg.rb +1 -1
  102. data/plugins/snippets/lib/snippets/document_controller.rb +46 -40
  103. data/plugins/swt/lib/swt.rb +2 -0
  104. data/plugins/test_runner/lib/test_runner.rb +1 -0
  105. data/plugins/test_runner/lib/test_runner/jasmine_test_runner.rb +15 -0
  106. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +21 -5
  107. data/plugins/textmate/lib/textmate.rb +5 -1
  108. data/plugins/textmate/lib/textmate/preference.rb +4 -0
  109. data/plugins/textmate/lib/textmate/snippet.rb +0 -2
  110. data/plugins/textmate/lib/textmate/tree_mirror.rb +6 -5
  111. data/plugins/textmate/plugin.rb +1 -1
  112. data/plugins/textmate/vendor/redcar-bundles/Bundles/C.tmbundle/Syntaxes/C.plist +2 -2
  113. data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/info.plist +2 -0
  114. data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Plain_Text_Feature.tmLanguage +0 -4
  115. data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/info.plist +2 -0
  116. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +3 -1
  117. data/plugins/textmate/vendor/redcar-bundles/Bundles/Palm-WebOS-Development.tmbundle/info.plist +2 -0
  118. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +2 -0
  119. data/plugins/textmate/vendor/redcar-bundles/Bundles/SQL.tmbundle/info.plist +2 -0
  120. data/plugins/textmate/vendor/redcar-bundles/Bundles/Scala.tmbundle/info.plist +2 -0
  121. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/GNU_Smalltalk.tmPreferences +1 -1
  122. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/MIST_Smalltalk_Format.tmPreferences +1 -1
  123. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/info.plist +2 -0
  124. data/plugins/textmate/vendor/redcar-bundles/Bundles/Vala.tmbundle/info.plist +4 -2
  125. data/plugins/textmate/vendor/redcar-bundles/Bundles/Webrat.tmbundle/info.plist +2 -0
  126. data/plugins/textmate/vendor/redcar-bundles/Bundles/YAML.tmbundle/Syntaxes/YAML.plist +1 -0
  127. data/plugins/textmate/vendor/redcar-bundles/Bundles/groovy.tmbundle/info.plist +2 -0
  128. data/plugins/textmate/vendor/redcar-bundles/Themes/Twilight.tmTheme +0 -2
  129. data/plugins/todo_list/lib/todo_list.rb +3 -3
  130. data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
  131. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +1 -1
  132. data/plugins/web_bookmarks/lib/web_bookmarks.rb +11 -4
  133. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -1
  134. data/plugins/web_bookmarks/plugin.rb +1 -2
  135. metadata +29 -20
  136. data/plugins/core/lib/core/logger.rb +0 -28
  137. data/plugins/file_parser/lib/file_parser.rb +0 -125
  138. data/plugins/file_parser/plugin.rb +0 -7
  139. data/plugins/tree/plugin.rb +0 -9
@@ -144,7 +144,21 @@ module Redcar
144
144
  end
145
145
  end
146
146
  end
147
-
147
+
148
+ def self.quit_guard
149
+ EditView::ModifiedTabsChecker.new(
150
+ Redcar.app.all_tabs.select {|t| t.is_a?(EditTab)},
151
+ "Save all before quitting?"
152
+ ).check
153
+ end
154
+
155
+ def self.close_window_guard(win)
156
+ EditView::ModifiedTabsChecker.new(
157
+ win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(EditTab)},
158
+ "Save all before closing the window?"
159
+ ).check
160
+ end
161
+
148
162
  def self.all_handlers(type)
149
163
  result = []
150
164
  method_name = :"#{type}_handlers"
@@ -1,8 +1,8 @@
1
1
  module Redcar
2
2
  class EditView
3
3
  class ModifiedTabsChecker
4
- def initialize(tabs, message, options)
5
- @tabs, @message, @options = tabs, message, options
4
+ def initialize(tabs, message)
5
+ @tabs, @message = tabs, message
6
6
  end
7
7
 
8
8
  def check
@@ -17,16 +17,16 @@ module Redcar
17
17
  when :yes
18
18
  modified_edit_tabs.each do |t|
19
19
  t.focus
20
- Project::FileSaveCommand.new(t).run
20
+ Project::SaveFileCommand.new(t).run
21
21
  end
22
- @options[:continue] ? @options[:continue].call : nil
22
+ true
23
23
  when :no
24
- @options[:continue] ? @options[:continue].call : nil
24
+ true
25
25
  when :cancel
26
- @options[:cancel] ? @options[:cancel].call : nil
26
+ false
27
27
  end
28
28
  else
29
- @options[:none] ? @options[:none].call : nil
29
+ true
30
30
  end
31
31
  end
32
32
  end
@@ -70,13 +70,14 @@ module Redcar
70
70
  end
71
71
 
72
72
  def self.load_textmate_assets
73
- s = Time.now
74
- load_textmate_assets_from_dir(Redcar.root + "/plugins/textmate/vendor/redcar-bundles")
75
- Redcar.plugin_manager.loaded_plugins.each do |plugin|
76
- load_textmate_assets_from_dir(File.dirname(plugin.definition_file) + "/")
73
+ Redcar.log.info("loaded JavaMateView #{JavaMateView::MateText.VERSION}")
74
+ Redcar.log.benchmark("load textmate assets") do
75
+ load_textmate_assets_from_dir(Redcar.root + "/plugins/textmate/vendor/redcar-bundles")
76
+ Redcar.plugin_manager.loaded_plugins.each do |plugin|
77
+ load_textmate_assets_from_dir(File.dirname(plugin.definition_file) + "/")
78
+ end
79
+ load_textmate_assets_from_dir(Redcar.user_dir + "/")
77
80
  end
78
- load_textmate_assets_from_dir(Redcar.user_dir + "/")
79
- puts "took #{Time.now - s}s to load textmate assets"
80
81
  EditView.themes.unshift(*JavaMateView::ThemeManager.themes.to_a.map {|th| th.name })
81
82
  end
82
83
 
@@ -30,7 +30,7 @@ module Redcar
30
30
 
31
31
  def output_tab
32
32
  tabs = win.notebooks.map {|nb| nb.tabs }.flatten
33
- tabs.detect {|t| t.title == TITLE} || Top::NewCommand.new.run
33
+ tabs.detect {|t| t.title == TITLE} || Top::OpenNewEditTabCommand.new.run
34
34
  end
35
35
 
36
36
  def execute_file(path)
@@ -17,7 +17,7 @@ module Redcar
17
17
  Redcar::Menu::Builder.build do
18
18
  sub_menu "Plugins" do
19
19
  sub_menu "REPL" do
20
- item "Open Groovy REPL", GroovyOpenREPL
20
+ item "Open Groovy REPL", OpenGroovyREPL
21
21
  end
22
22
  end
23
23
  end
@@ -25,11 +25,11 @@ module Redcar
25
25
 
26
26
  def self.keymaps
27
27
  osx = Keymap.build("main", :osx) do
28
- link "Cmd+Alt+G", GroovyOpenREPL
28
+ link "Cmd+Alt+G", OpenGroovyREPL
29
29
  end
30
30
 
31
31
  linwin = Keymap.build("main", [:linux, :windows]) do
32
- link "Ctrl+Alt+G", GroovyOpenREPL
32
+ link "Ctrl+Alt+G", OpenGroovyREPL
33
33
  end
34
34
 
35
35
  [linwin, osx]
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Redcar
3
3
  class Groovy
4
- class GroovyOpenREPL < Redcar::REPL::OpenREPL
4
+ class OpenGroovyREPL < Redcar::REPL::OpenREPL
5
5
  def execute
6
6
  open_repl(ReplMirror.new)
7
7
  end
@@ -20,6 +20,11 @@ module Redcar
20
20
  rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "..", "views", "index.html.erb")))
21
21
  rhtml.result(binding)
22
22
  end
23
+
24
+ def add_key_binding(key, command)
25
+ return unless key && key.length > 0
26
+ Redcar::KeyBindings.add_key_binding key, command
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -3,6 +3,15 @@
3
3
  <title>Keyboard Shortcuts</title>
4
4
  <% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins help views default.css))) %>
5
5
  <link rel="stylesheet" href="file://<%= redcar_css %>" type="text/css" media="screen">
6
+ <%= javascript_controller_actions %>
7
+ <script type="text/javascript" src="file://<%= Redcar::HtmlView.jquery_path %>"></script>
8
+ <script>
9
+ function addKeyBinding(command) {
10
+ var key = prompt("Key for " + command, "");
11
+ Controller.addKeyBinding(key, command);
12
+ window.location.href = "controller/index";
13
+ }
14
+ </script>
6
15
  </head>
7
16
  <body>
8
17
  <h1>Keyboard Shortcuts</h1>
@@ -18,7 +27,7 @@
18
27
  <% i = 0 %>
19
28
  <% Redcar.app.main_keymap.map.sort_by{|key, command| clean_name(command)}.each do |key, command| %>
20
29
  <tr class="<%= i % 2 == 0 ? 'even':'odd'%>">
21
- <td><%= clean_name(command) %></td>
30
+ <td><a href="javascript:addKeyBinding('<%=command %>');"><%= clean_name(command) %></a></td>
22
31
  <td><%= key %></td>
23
32
  <% i = i + 1%>
24
33
  </tr>
@@ -60,5 +60,5 @@ When /^I open the browser bar$/ do
60
60
  end
61
61
 
62
62
  When /^I open a web preview$/ do
63
- Redcar::HtmlView::FileWebPreview.new.run
63
+ Redcar::HtmlView::ViewFileInWebBrowserCommand.new.run
64
64
  end
@@ -25,18 +25,3 @@ After do
25
25
  reset_htmlview_fixtures
26
26
  end
27
27
 
28
- $:.push("plugins/html_view/vendor/nokogiri/lib")
29
- require 'nokogiri'
30
-
31
- p Nokogiri::HTML("<h1>afso</h1>")
32
-
33
- $:.push("plugins/html_view/vendor/capybara/lib")
34
- require 'capybara'
35
- require 'capybara/dsl'
36
-
37
- $:.push("plugins/html_view/vendor/capybara-sweet/lib")
38
- require 'capybara/driver/sweet'
39
-
40
- Capybara.default_driver = :sweet
41
-
42
- World(Capybara)
@@ -4,7 +4,6 @@ require 'html_view/browser_bar'
4
4
  require 'html_view/html_tab'
5
5
  require 'html_controller'
6
6
  require 'html_view/default_controller'
7
- require 'json'
8
7
 
9
8
  module Redcar
10
9
  class HtmlView
@@ -19,7 +18,7 @@ module Redcar
19
18
  def self.keymaps
20
19
  map = Redcar::Keymap.build("main", [:osx, :linux, :windows]) do
21
20
  link "Alt+Shift+B", ToggleBrowserBar
22
- link "Alt+Shift+P", FileWebPreview
21
+ link "Alt+Shift+P", ViewFileInWebBrowserCommand
23
22
  end
24
23
  [map]
25
24
  end
@@ -27,7 +26,7 @@ module Redcar
27
26
  def self.menus
28
27
  Redcar::Menu::Builder.build do
29
28
  sub_menu "File" do
30
- item "Web Preview", :command => FileWebPreview, :priority => 8
29
+ item "Web Preview", :command => ViewFileInWebBrowserCommand, :priority => 8
31
30
  end
32
31
  sub_menu "View" do
33
32
  item "Toggle Browser Bar", :command => ToggleBrowserBar, :priority => 11
@@ -42,7 +41,7 @@ module Redcar
42
41
  storage
43
42
  end
44
43
  end
45
-
44
+
46
45
  def self.show_browser_bar?
47
46
  if win = Redcar.app.focussed_window and
48
47
  win.speedbar and win.speedbar.is_a?(BrowserBar)
@@ -30,7 +30,7 @@ module Redcar
30
30
  end
31
31
  end
32
32
 
33
- class FileWebPreview < Redcar::EditTabCommand
33
+ class ViewFileInWebBrowserCommand < Redcar::EditTabCommand
34
34
  def execute
35
35
  mirror = doc.mirror
36
36
  if mirror and path = mirror.path and File.exists?(path)
@@ -0,0 +1,34 @@
1
+
2
+ # $:.push(File.expand_path(File.join(File.dirname(__FILE__),
3
+ # "vendor", "activesupport-3.0.3", "lib")))
4
+ #
5
+ # require 'active_support'
6
+ # require 'active_support/inflections'
7
+ module Redcar
8
+ # This class is your plugin. Try adding new commands in here
9
+ # and putting them in the menus.
10
+ class KeyBindings
11
+
12
+ def self.user_keybindings
13
+ key_bindings = key_binding_prefs.inject({}) do |h, (key, command_class)|
14
+ h[key] = eval(command_class)
15
+ h
16
+ end
17
+ key_bindings
18
+ end
19
+
20
+ def self.storage
21
+ @storage ||= Plugin::Storage.new('key_bindings')
22
+ end
23
+
24
+ def self.key_binding_prefs
25
+ storage["key_bindings"] ||= {}
26
+ end
27
+
28
+ def self.add_key_binding(key, command)
29
+ key_binding_prefs[key] = command
30
+ storage.save
31
+ Redcar.app.refresh_menu!
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,8 @@
1
+
2
+ Plugin.define do
3
+ name "key_bindings"
4
+ version "1.0"
5
+ file "lib", "key_bindings"
6
+ object "Redcar::KeyBindings"
7
+ dependencies "redcar", ">0"
8
+ end
@@ -13,6 +13,7 @@ Scenario: Lowering a multi-line selection
13
13
  And I select from 5 to 9
14
14
  And I lower the text
15
15
  Then I should see "foo\nbonne\nbar\nbaz" in the edit tab
16
+ And the selected text should be "bar\nbaz"
16
17
 
17
18
  Scenario: Lowering the last line of a document
18
19
  When I open a new edit tab
@@ -41,8 +42,9 @@ Scenario: Lowering a multi-line selection including the last line of a document
41
42
  And I replace the contents with "foo\nbar\nbaz\nbonne"
42
43
  And I select from 8 to 12
43
44
  And I lower the text
44
- Then I should see "foo\nbar\nbaz\nbonne" in the edit tab
45
+ Then I should see "foo\nbar\nbonne\nbaz" in the edit tab
45
46
  And I should not see "foo\nbar\n\nbaz\nbonne" in the edit tab
47
+ And the selected text should be "baz"
46
48
 
47
49
  Scenario: Should work with unicode
48
50
  When I open a new edit tab
@@ -50,6 +52,3 @@ Scenario: Should work with unicode
50
52
  And I move the cursor to 5
51
53
  And I lower the text
52
54
  Then the contents should be "foo\nbaz\nbść\nbonne"
53
-
54
-
55
-
@@ -163,7 +163,7 @@ module Redcar
163
163
  doc.cursor_offset = insert_idx + cursor_line_offset
164
164
  if keep_selection
165
165
  doc.set_selection_range(doc.offset_at_line(first_line_ix-1),
166
- doc.offset_at_line(last_line_ix-1) + doc.get_line(last_line_ix-1).length - 1)
166
+ doc.offset_at_inner_end_of_line(last_line_ix-1))
167
167
  end
168
168
  doc.scroll_to_line(top)
169
169
  end
@@ -179,14 +179,14 @@ module Redcar
179
179
  if doc.selection?
180
180
  first_line_ix = doc.line_at_offset(doc.selection_range.begin)
181
181
  last_line_ix = doc.line_at_offset(doc.selection_range.end)
182
-
182
+
183
183
  if doc.selection_range.begin == doc.offset_at_inner_end_of_line(first_line_ix)
184
184
  first_line_ix += 1
185
185
  end
186
186
  if doc.selection_range.end == doc.offset_at_line(last_line_ix)
187
187
  last_line_ix -= 1
188
188
  end
189
-
189
+
190
190
  text = doc.get_slice(doc.offset_at_line(first_line_ix),
191
191
  doc.offset_at_line_end(last_line_ix))
192
192
  keep_selection = true
@@ -211,8 +211,9 @@ module Redcar
211
211
  doc.replace(doc.offset_at_line(first_line_ix), swap_text.split(//).length, new_text)
212
212
  doc.cursor_offset = doc.offset_at_line(last_line_ix+1) + cursor_line_offset
213
213
  if keep_selection
214
- doc.set_selection_range(doc.offset_at_line(first_line_ix+1),
215
- doc.offset_at_line(last_line_ix+1) + doc.get_line(last_line_ix+1).length - 1)
214
+ start_selection = doc.offset_at_line(first_line_ix+1)
215
+ end_selection = doc.offset_at_inner_end_of_line(last_line_ix+1)
216
+ doc.set_selection_range(start_selection, end_selection)
216
217
  end
217
218
  doc.scroll_to_line(last_line_ix+1)
218
219
  end
@@ -10,7 +10,7 @@ module Redcar
10
10
  Menu::Builder.build do
11
11
  sub_menu "Plugins" do
12
12
  sub_menu "REPL" do
13
- item "Open Mirah REPL", MirahOpenREPL
13
+ item "Open Mirah REPL", OpenMirahREPL
14
14
  end
15
15
  end
16
16
  end
@@ -34,7 +34,7 @@ module Redcar
34
34
  end
35
35
  end
36
36
 
37
- class MirahOpenREPL < Redcar::REPL::OpenREPL
37
+ class OpenMirahREPL < Redcar::REPL::OpenREPL
38
38
  def execute
39
39
  open_repl(ReplMirror.new)
40
40
  end
@@ -68,9 +68,11 @@ module Redcar
68
68
 
69
69
  def clear
70
70
  if @highlight.on?
71
- styledText.redrawRange(@highlight.current, 1, false) if @highlight.current < document.length
72
- styledText.redrawRange(@highlight.pair, 1, false) # if on the same line
73
- @highlight.clear
71
+ if @highlight.current < document.length
72
+ styledText.redrawRange(@highlight.current, 1, false)
73
+ styledText.redrawRange(@highlight.pair, 1, false) # if on the same line
74
+ @highlight.clear
75
+ end
74
76
  end
75
77
  end
76
78
 
@@ -14,7 +14,7 @@ Feature: Open directory tree
14
14
  When I open a directory
15
15
  Given I will choose "plugins" from the "open_directory" dialog
16
16
  When I open a directory
17
- Then I should see "core,application,tree" in the tree
17
+ Then I should see "core,application,tree_view_swt" in the tree
18
18
 
19
19
  Scenario: Open a directory and then the same using another Redcar invocation
20
20
  Given I will choose "plugins/project/spec/fixtures/myproject" from the "open_directory" dialog
@@ -1,6 +1,6 @@
1
1
 
2
2
  Given /^I have open a file$/ do
3
- Redcar::Project::FileOpenCommand.new.run
3
+ Redcar::Project::OpenFileCommand.new.run
4
4
  end
5
5
 
6
6
  Given /^I will open a large file from the "([^"]*)" dialog$/ do |arg1|
@@ -9,15 +9,15 @@ Given /^I will open a large file from the "([^"]*)" dialog$/ do |arg1|
9
9
  end
10
10
 
11
11
  When /^I open a file$/ do
12
- Redcar::Project::FileOpenCommand.new.run
12
+ Redcar::Project::OpenFileCommand.new.run
13
13
  end
14
14
 
15
15
  Given /^I have opened "([^\"]*)"$/ do |arg1|
16
- Redcar::Project::FileOpenCommand.new(File.expand_path(arg1)).run
16
+ Redcar::Project::OpenFileCommand.new(File.expand_path(arg1)).run
17
17
  end
18
18
 
19
19
  When /^I save the tab$/ do
20
- Redcar::Project::FileSaveCommand.new.run
20
+ Redcar::Project::SaveFileCommand.new.run
21
21
  end
22
22
 
23
23
  When /^I touch the file "([^\"]*)"$/ do |fn|
@@ -30,7 +30,7 @@ When /^I put "([^\"]*)" into the file "([^\"]*)"$/ do |contents, path|
30
30
  end
31
31
 
32
32
  When /^I save the tab as$/ do
33
- Redcar::Project::FileSaveAsCommand.new.run
33
+ Redcar::Project::SaveFileAsCommand.new.run
34
34
  end
35
35
 
36
36
  Then /^the file "([^\"]*)" should contain "([^\"]*)"$/ do |arg1, arg2|
@@ -1,9 +1,8 @@
1
1
  When /^I prefer not to see files like "([^"]*)" in the find file dialog$/ do |pattern|
2
-
3
- ignored = filter_storage['ignore_files_that_match_these_regexes']
2
+ ignored = shared_ignored_storage['ignored_file_patterns']
4
3
  ignored << /#{pattern}/
5
4
  filter_storage['ignore_file_patterns'] = true
6
- filter_storage['ignore_files_that_match_these_regexes'] = ignored
5
+ shared_ignored_storage['ignored_file_patterns'] = ignored
7
6
  end
8
7
 
9
8
  When /^I open the find file dialog$/ do
@@ -49,6 +49,10 @@ def filter_storage
49
49
  Redcar::Project::FindFileDialog.storage
50
50
  end
51
51
 
52
+ def shared_ignored_storage
53
+ Redcar::Project::FindFileDialog.shared_storage
54
+ end
55
+
52
56
  Before do
53
57
  reset_project_fixtures
54
58
  @original_file_size_limit = Redcar::Project::Manager.file_size_limit
@@ -86,21 +86,21 @@ module Redcar
86
86
  Manager.storage['last_open_dir'] = path
87
87
  Project.window_projects[window] = self
88
88
  end
89
-
89
+
90
90
  def lock
91
91
  File.open(lock_filename, "w") do |fout|
92
92
  fout.puts "#{$$}: Locked by #{$$} at #{Time.now}"
93
93
  end
94
94
  end
95
-
95
+
96
96
  def lock_filename
97
97
  File.join(config_dir, "redcar.lock")
98
98
  end
99
-
99
+
100
100
  def locked?
101
101
  File.exist?(lock_filename)
102
102
  end
103
-
103
+
104
104
  def unlock
105
105
  if locked?
106
106
  if locked_by_this_process?
@@ -112,7 +112,7 @@ module Redcar
112
112
  raise "project not locked"
113
113
  end
114
114
  end
115
-
115
+
116
116
  def locked_by_this_process?
117
117
  return false unless locked?
118
118
  locking_pid = File.read(lock_filename).split(":").first
@@ -128,10 +128,10 @@ module Redcar
128
128
  this_window.title = Window::DEFAULT_TITLE
129
129
  Manager.open_project_sensitivity.recompute
130
130
  Redcar.plugin_manager.objects_implementing(:project_closed).each do |i|
131
- i.project_closed(self)
131
+ i.project_closed(self,this_window)
132
132
  end
133
133
  listeners = {}
134
- unlock
134
+ unlock if locked?
135
135
  end
136
136
 
137
137
  def attach_listeners
@@ -151,12 +151,14 @@ module Redcar
151
151
  end
152
152
 
153
153
  def notebook_focussed(notebook)
154
- RevealInProjectCommand.new.run if notebook.focussed_tab && tree
154
+ if notebook.focussed_tab and tree and Project::Manager.reveal_file?(self)
155
+ RevealInProjectCommand.new.run
156
+ end
155
157
  end
156
158
 
157
159
  def notebook_added(notebook)
158
160
  @listeners.merge!(notebook => notebook.add_listener(:tab_focussed) do |tab|
159
- RevealInProjectCommand.new.run if tree
161
+ RevealInProjectCommand.new.run if tree and window and Project::Manager.reveal_file?(self)
160
162
  end)
161
163
  end
162
164
 
@@ -253,5 +255,9 @@ module Redcar
253
255
  file_glob = File.join("{#{config_dir},#{Redcar.user_dir}}", glob)
254
256
  Dir[file_glob]
255
257
  end
258
+
259
+ def search(query)
260
+ ProjectSearch::WordSearch.new(self, query, false, 0)
261
+ end
256
262
  end
257
263
  end