redcar 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,27 @@
1
+ module DocumentSearch
2
+ class ReplaceAllCommand < ReplaceCommand
3
+ def execute
4
+ startoff, endoff = nil
5
+ text = doc.get_all_text
6
+ count = 0
7
+ sc = StringScanner.new(text)
8
+ while sc.scan_until(query)
9
+ count += 1
10
+
11
+ startoff = sc.pos - sc.matched_size
12
+ replacement_text = text.slice(startoff, sc.matched_size).gsub(query, replace)
13
+ endoff = startoff + replacement_text.length
14
+
15
+ text[startoff...sc.pos] = replacement_text
16
+ sc.string = text
17
+ sc.pos = startoff + replacement_text.length
18
+ end
19
+ if count > 0
20
+ doc.text = text
21
+ doc.set_selection_range(startoff + replacement_text.length, startoff)
22
+ doc.scroll_to_line(doc.line_at_offset(startoff))
23
+ end
24
+ count
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,38 @@
1
+ module DocumentSearch
2
+ class ReplaceCommand < Redcar::DocumentCommand
3
+ attr_reader :query, :replace
4
+
5
+ def initialize(query, replace, search_method)
6
+ @replace = replace
7
+ @query = send(search_method, query)
8
+ end
9
+
10
+ # An instance of a search type method: Regular expression
11
+ def regex_search_query(query)
12
+ /#{query}/
13
+ end
14
+
15
+ # An instance of a search type method: Plain text search
16
+ def plain_search_query(query)
17
+ regex_search_query(Regexp.escape(query))
18
+ end
19
+
20
+ # An instance of a search type method: Glob text search
21
+ # Converts a glob pattern (* or ?) into a regex pattern
22
+ def glob_search_query(query)
23
+ # convert the glob pattern to a regex pattern
24
+ new_query = ""
25
+ query.each_char do |c|
26
+ case c
27
+ when "*"
28
+ new_query << ".*"
29
+ when "?"
30
+ new_query << "."
31
+ else
32
+ new_query << Regexp.escape(c)
33
+ end
34
+ end
35
+ regex_search_query(new_query)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ module DocumentSearch
2
+ class ReplaceNextCommand < ReplaceCommand
3
+ # The current selection is usually not used for the next replacement, unless
4
+ # it matches the query string, in which case we assume that the user meant replace it, too
5
+ def start_position
6
+ offsets = [doc.cursor_offset, doc.selection_offset]
7
+ return offsets.min if query == doc.selected_text
8
+ offsets.max
9
+ end
10
+
11
+ def execute
12
+ sc = StringScanner.new(doc.get_all_text)
13
+ sc.pos = start_position
14
+ sc.scan_until(query) || sc.reset && sc.scan_until(query)
15
+
16
+ return 0 unless sc.matched?
17
+ startoff = sc.pos - sc.matched_size
18
+
19
+ text = doc.get_range(startoff, sc.matched_size)
20
+ replacement_text = text.gsub(query, replace)
21
+ doc.replace(sc.pos - sc.matched_size, sc.matched_size, replacement_text)
22
+ doc.set_selection_range(startoff + replacement_text.length, startoff)
23
+ doc.scroll_to_line(doc.line_at_offset(startoff))
24
+ 1
25
+ end
26
+ end
27
+ end
@@ -16,44 +16,47 @@ module DocumentSearch
16
16
  self.search_type.value = SearchAndReplaceSpeedbar.previous_search_type
17
17
  self.query.edit_view.document.select_all
18
18
  end
19
-
19
+
20
20
  label :label_search, "Search:"
21
21
  textbox :query
22
-
22
+
23
23
  label :label_replace, "Replace:"
24
24
  textbox :replace
25
-
25
+
26
26
  combo :search_type, ["Regex", "Plain", "Glob"], "RegEx" do |v|
27
27
  SearchAndReplaceSpeedbar.previous_search_type = v
28
28
  end
29
-
29
+
30
30
  button :single_replace, "Replace", "Return" do
31
31
  SearchAndReplaceSpeedbar.previous_query = query.value
32
32
  SearchAndReplaceSpeedbar.previous_replace = replace.value
33
33
  SearchAndReplaceSpeedbar.previous_search_type = search_type.value || "Regex" # Hack to work around fact that default value not being picked up
34
34
  success = SearchAndReplaceSpeedbar.search_replace
35
35
  end
36
-
36
+
37
37
  button :all_replace, "Replace All", nil do
38
38
  SearchAndReplaceSpeedbar.previous_query = query.value
39
39
  SearchAndReplaceSpeedbar.previous_replace = replace.value
40
40
  SearchAndReplaceSpeedbar.previous_search_type = search_type.value || "Regex" # Hack to work around fact that default value not being picked up
41
41
  success = SearchAndReplaceSpeedbar.search_replace_all
42
42
  end
43
-
44
- def self.search_replace
45
- current_query = @previous_query
46
- current_replace = @previous_replace
43
+
44
+ def self.search_method
47
45
  case @previous_search_type
48
46
  when "Regex"
49
- search_method = :regex_search_method
47
+ search_method = :regex_search_query
50
48
  when "Plain"
51
- search_method = :plain_search_method
49
+ search_method = :plain_search_query
52
50
  when "Glob"
53
- search_method = :glob_search_method
51
+ search_method = :glob_search_query
54
52
  else
55
- search_method = :regex_search_method
53
+ search_method = :regex_search_query
56
54
  end
55
+ end
56
+
57
+ def self.search_replace
58
+ current_query = @previous_query
59
+ current_replace = @previous_replace
57
60
  adoc = Redcar.app.focussed_notebook_tab.document
58
61
  cmd = ReplaceNextCommand.new(current_query, current_replace, search_method)
59
62
  count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
@@ -61,20 +64,10 @@ module DocumentSearch
61
64
  Redcar::Application::Dialog.message_box("No instance of the search string were found", {:type => :info, :buttons => :ok})
62
65
  end
63
66
  end
64
-
67
+
65
68
  def self.search_replace_all
66
69
  current_query = @previous_query
67
70
  current_replace = @previous_replace
68
- case @previous_search_type
69
- when "Regex"
70
- search_method = :regex_search_method
71
- when "Plain"
72
- search_method = :plain_search_method
73
- when "Glob"
74
- search_method = :glob_search_method
75
- else
76
- search_method = :regex_search_method
77
- end
78
71
  cmd = ReplaceAllCommand.new(current_query, current_replace, search_method)
79
72
  count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
80
73
  if count == 0 or count > 1
@@ -143,7 +143,7 @@ Then /^the selection should be on line (.*)$/ do |line_num|
143
143
  doc.line_at_offset(r.begin).should == line_num
144
144
  doc.line_at_offset(r.end).should == line_num
145
145
  end
146
-
146
+
147
147
  Then /^there should not be any text selected$/ do
148
148
  doc = Redcar::EditView.focussed_edit_view_document
149
149
  doc.selected_text.should == ""
@@ -151,7 +151,7 @@ end
151
151
 
152
152
  Then /^the selected text should be "([^"]*)"$/ do |selected_text|
153
153
  doc = Redcar::EditView.focussed_edit_view_document
154
- doc.selected_text.should == selected_text
154
+ doc.selected_text.should == unescape_text(selected_text)
155
155
  end
156
156
 
157
157
  Then /the line delimiter should be "(.*)"/ do |delim|
@@ -234,8 +234,8 @@ Given /^the contents? is:$/ do |string|
234
234
  selection_index = string.index('<s>')
235
235
  string = string.gsub('<s>', '').gsub('<c>', '')
236
236
  When %{I replace the contents with "#{string}"}
237
-
238
- if cursor_index and selection_index
237
+
238
+ if cursor_index and selection_index
239
239
  if cursor_index < selection_index
240
240
  selection_index -= 3
241
241
  else
@@ -93,3 +93,12 @@ Then /^my active tab should have an "([^"]*)" icon$/ do |arg1|
93
93
  focussed_tab.icon.should == :"#{arg1}"
94
94
  end
95
95
 
96
+ Then /^the tab should (not )?have annotations$/ do |negated|
97
+ annotations = focussed_tab.controller.edit_view.annotations
98
+ negated ? (annotations.should be_empty) : (annotations.should_not be_empty)
99
+ end
100
+
101
+ Then /^the tab should (not )?have an annotation on line (\d+)$/ do |negated, num|
102
+ annotations = focussed_tab.controller.edit_view.annotations(:line => num.to_i)
103
+ negated ? (annotations.should be_empty) : (annotations.should_not be_empty)
104
+ end
@@ -25,18 +25,6 @@ When /I open a new window(?: with title "(.*)")?/ do |title|
25
25
  Redcar::Top::NewWindowCommand.new(title).run
26
26
  end
27
27
 
28
- class FakeEvent
29
- def initialize(event_type, widget)
30
- untyped_event = Swt::Widgets::Event.new.tap do |e|
31
- e.display = Swt.display
32
- e.widget = widget
33
- e.x = 0
34
- e.y = 0
35
- end
36
- widget.notify_listeners(event_type, untyped_event)
37
- end
38
- end
39
-
40
28
  When /^I maximize the window size$/ do
41
29
  Redcar.app.focussed_window.controller.shell.maximized = true
42
30
  end
@@ -82,6 +82,8 @@ module Redcar
82
82
  @mirror.commit(to_s)
83
83
  @edit_view.reset_last_checked
84
84
  set_modified(false)
85
+ notify_listeners(:mirror_committed,@mirror)
86
+ Redcar.app.repeat_event(:mirror_committed) if Redcar.app
85
87
  end
86
88
  end
87
89
 
@@ -1,25 +1,25 @@
1
1
  module Redcar
2
- class DocumentCommand < Command
2
+ class DocumentCommand < TabCommand
3
3
  sensitize :edit_view_focussed
4
-
4
+
5
5
  def _finished
6
- edit_view.history.record(self)
6
+ edit_view.history.record(self) if edit_view
7
7
  end
8
-
8
+
9
9
  def run_in_focussed_tab_edit_view
10
10
  if edit_view = Redcar::EditView.focussed_tab_edit_view
11
11
  run(:env => {:edit_view => edit_view})
12
12
  end
13
13
  end
14
-
14
+
15
15
  private
16
-
16
+
17
17
  def edit_view
18
18
  env[:edit_view] || EditView.focussed_edit_view
19
19
  end
20
-
20
+
21
21
  def doc
22
22
  edit_view.document
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -8,17 +8,31 @@ module Redcar
8
8
  create_edit_view
9
9
  end
10
10
 
11
- def update_for_file_changes
12
- old_icon = @icon
11
+ def icon
12
+ i = DEFAULT_ICON
13
13
  doc = @edit_view.document
14
14
  if doc and doc.path
15
- if File.exists?(doc.path)
16
- @icon = :file if icon == :exclamation
17
- else
18
- @icon = :exclamation
15
+ unless doc.mirror.adapter.is_a?(Redcar::Project::Adapters::Remote)
16
+ if File.exists?(doc.path)
17
+ if File.writable?(doc.path)
18
+ i = DEFAULT_ICON
19
+ else
20
+ i = NO_WRITE_ICON
21
+ end
22
+ else
23
+ i = MISSING_ICON
24
+ end
19
25
  end
20
26
  end
21
- notify_listeners(:changed_icon, @icon) if old_icon != @icon
27
+ i
28
+ end
29
+
30
+ def update_for_file_changes
31
+ new_icon = icon
32
+ if new_icon and new_icon != @icon
33
+ @icon = new_icon
34
+ notify_listeners(:changed_icon, @icon)
35
+ end
22
36
  end
23
37
 
24
38
  def create_edit_view
@@ -34,6 +34,12 @@ module Redcar
34
34
  end
35
35
  end
36
36
 
37
+ def moved_to(text, ix)
38
+ if @last_list
39
+ Redcar::EditView.font = text
40
+ end
41
+ end
42
+
37
43
  end
38
44
  end
39
45
  end
@@ -31,6 +31,12 @@ module Redcar
31
31
  end
32
32
  end
33
33
 
34
+ def moved_to(text, ix)
35
+ if @last_list
36
+ Redcar::EditView.theme = text
37
+ end
38
+ end
39
+
34
40
  end
35
41
  end
36
42
  end
@@ -28,7 +28,7 @@ module Redcar
28
28
  :WINDOW_START => 17039365,
29
29
  :WINDOW_END => 17039366
30
30
  }
31
-
31
+
32
32
  SELECTION_COMMANDS = {
33
33
  :SELECT_ALL => 262209,
34
34
  :SELECT_LINE_UP => 16908289,
@@ -46,7 +46,7 @@ module Redcar
46
46
  :SELECT_WINDOW_START => 17170437,
47
47
  :SELECT_WINDOW_END => 17170438
48
48
  }
49
-
49
+
50
50
  MODIFICATION_COMMANDS = {
51
51
  :CUT => 131199,
52
52
  :COPY => 17039369,
@@ -56,7 +56,7 @@ module Redcar
56
56
  :DELETE_WORD_PREVIOUS => 262152,
57
57
  :DELETE_WORD_NEXT => 262271
58
58
  }
59
-
59
+
60
60
  ALL_ACTIONS = NAVIGATION_COMMANDS.merge(SELECTION_COMMANDS).merge(MODIFICATION_COMMANDS)
61
61
 
62
62
  include Redcar::Observable
@@ -107,42 +107,42 @@ module Redcar
107
107
  mate_text.add_grammar_listener do |new_grammar|
108
108
  @model.set_grammar(new_grammar)
109
109
  end
110
-
110
+
111
111
  create_model_listeners
112
112
  end
113
-
113
+
114
114
  def create_mate_text
115
115
  @mate_text = JavaMateView::MateText.new(@parent, !!@options[:single_line])
116
116
  @mate_text.set_font(EditView.font, EditView.font_size)
117
117
 
118
118
  @model.controller = self
119
-
119
+
120
120
  add_styled_text_command_key_listeners
121
121
  end
122
-
122
+
123
123
  class CommandKeyListener
124
-
124
+
125
125
  attr_reader :st
126
-
126
+
127
127
  def initialize(styled_text, edit_view)
128
128
  @edit_view = edit_view
129
129
  @st = styled_text
130
130
  end
131
-
131
+
132
132
  def key_pressed(event)
133
133
  end
134
-
134
+
135
135
  def key_released(event)
136
136
  record_action(event)
137
137
  end
138
-
138
+
139
139
  # This pile of crap is copied from StyledText#handleKey. Wouldn't
140
140
  # it be great if this logic was accessible on StyledText somehow?
141
141
  def record_action(event)
142
142
  if (event.keyCode != 0)
143
143
  # special key pressed (e.g., F1)
144
144
  action = st.getKeyBinding(event.keyCode | event.stateMask)
145
- else
145
+ else
146
146
  # character key pressed
147
147
  action = st.getKeyBinding(event.character | event.stateMask)
148
148
  if (action == Swt::SWT::NULL)
@@ -155,31 +155,31 @@ module Redcar
155
155
  end
156
156
  end
157
157
  end
158
-
158
+
159
159
  if (action == Swt::SWT::NULL)
160
160
  ignore = false
161
-
161
+
162
162
  if (Redcar.platform == :osx)
163
- # Ignore accelerator key combinations (we do not want to
164
- # insert a character in the text in this instance). Do not
163
+ # Ignore accelerator key combinations (we do not want to
164
+ # insert a character in the text in this instance). Do not
165
165
  # ignore COMMAND+ALT combinations since that key sequence
166
166
  # produces characters on the mac.
167
167
  ignore = (event.stateMask & Swt::SWT::COMMAND) != 0 ||
168
168
  (event.stateMask & Swt::SWT::CTRL) != 0
169
169
  else
170
- # Ignore accelerator key combinations (we do not want to
171
- # insert a character in the text in this instance). Don't
172
- # ignore CTRL+ALT combinations since that is the Alt Gr
173
- # key on some keyboards. See bug 20953.
174
- ignore = (event.stateMask ^ Swt::SWT::ALT) == 0 ||
170
+ # Ignore accelerator key combinations (we do not want to
171
+ # insert a character in the text in this instance). Don't
172
+ # ignore CTRL+ALT combinations since that is the Alt Gr
173
+ # key on some keyboards. See bug 20953.
174
+ ignore = (event.stateMask ^ Swt::SWT::ALT) == 0 ||
175
175
  (event.stateMask ^ Swt::SWT::CTRL) == 0 ||
176
176
  (event.stateMask ^ (Swt::SWT::ALT | Swt::SWT::SHIFT)) == 0 ||
177
177
  (event.stateMask ^ (Swt::SWT::CTRL | Swt::SWT::SHIFT)) == 0
178
178
  end
179
179
  # -ignore anything below SPACE except for line delimiter keys and tab.
180
- # -ignore DEL
181
- if (!ignore && event.character > 31 && event.character != Swt::SWT::DEL ||
182
- event.character == Swt::SWT::CR || event.character == Swt::SWT::LF ||
180
+ # -ignore DEL
181
+ if (!ignore && event.character > 31 && event.character != Swt::SWT::DEL ||
182
+ event.character == Swt::SWT::CR || event.character == Swt::SWT::LF ||
183
183
  event.character == Swt::SWT::TAB)
184
184
  @edit_view.history.record(event.character)
185
185
  end
@@ -188,7 +188,7 @@ module Redcar
188
188
  end
189
189
  end
190
190
  end
191
-
191
+
192
192
  def add_styled_text_command_key_listeners
193
193
  st = @mate_text.get_text_widget
194
194
  st.add_key_listener(CommandKeyListener.new(st, @model))
@@ -210,7 +210,7 @@ module Redcar
210
210
 
211
211
  def undoable?
212
212
  # The override malarky is because the JFace::TextViewerUndoManager doesn't
213
- # recognize that typing while in Block Selection mode makes the edit view
213
+ # recognize that typing while in Block Selection mode makes the edit view
214
214
  # undoable. (Even though it faithfully records the actions, and responds
215
215
  # correctly to "undo".) So we override the undo manager for this case.
216
216
  @undoable_override || @undo_manager.undoable
@@ -248,7 +248,7 @@ module Redcar
248
248
  def annotations(options = nil)
249
249
  return @mate_text.annotations unless options
250
250
  if options[:line]
251
- @mate_text.annotationsOnLine(line + 1)
251
+ @mate_text.annotationsOnLine(options[:line] - 1)
252
252
  elsif options[:type]
253
253
  annotations_of_type(options[:type])
254
254
  end
@@ -278,6 +278,32 @@ module Redcar
278
278
  end
279
279
  end
280
280
 
281
+ def reset_right_margin
282
+ return if @options[:single_line]
283
+ if @model.word_wrap?
284
+ size = @mate_text.get_text_widget.get_size
285
+ width = size.x
286
+ @mate_text.get_text_widget.right_margin = width - char_width*(@model.margin_column||0) - 3*char_width
287
+ else
288
+ @mate_text.get_text_widget.right_margin = 0
289
+ end
290
+ end
291
+
292
+ def char_width
293
+ return 0 if !!@options[:single_line]
294
+ @char_width ||= begin
295
+ gc = Swt::Graphics::GC.new(@mate_text.get_text_widget)
296
+ fm = gc.getFontMetrics
297
+ width = fm.getAverageCharWidth
298
+ gc.dispose
299
+ width
300
+ end
301
+ end
302
+
303
+ def clear_char_width
304
+ @char_width = nil
305
+ end
306
+
281
307
  def create_document
282
308
  @document = EditViewSWT::Document.new(@model.document, @mate_text.mate_document)
283
309
  @model.document.controller = @document
@@ -291,21 +317,17 @@ module Redcar
291
317
  h5 = @model.add_listener(:invisibles_changed) do |new_bool|
292
318
  @mate_text.showInvisibles(new_bool)
293
319
  end
294
- h6 = @model.add_listener(:word_wrap_changed) do |new_bool|
295
- @mate_text.set_word_wrap(new_bool)
296
- end
297
- h7 = @model.add_listener(:font_changed) do
298
- @mate_text.set_font(EditView.font, EditView.font_size)
299
- end
300
- h8 = @model.add_listener(:theme_changed) do
301
- @mate_text.set_theme_by_name(EditView.theme)
302
- end
303
- h9 = @model.add_listener(:line_number_visibility_changed) do |new_bool|
304
- @mate_text.set_line_numbers_visible(new_bool)
320
+
321
+ h6 = @model.add_listener(:word_wrap_changed) do |should_word_wrap|
322
+ @mate_text.set_word_wrap(should_word_wrap)
323
+ reset_right_margin
305
324
  end
325
+
306
326
  h11 = @model.add_listener(:margin_column_changed) do |new_column|
307
327
  @mate_text.set_margin_column(new_column)
328
+ reset_right_margin
308
329
  end
330
+
309
331
  h12 = @model.add_listener(:show_margin_changed) do |new_bool|
310
332
  if new_bool
311
333
  @mate_text.set_margin_column(@model.margin_column)
@@ -313,6 +335,19 @@ module Redcar
313
335
  @mate_text.set_margin_column(-1)
314
336
  end
315
337
  end
338
+
339
+ h7 = @model.add_listener(:font_changed) do
340
+ @mate_text.set_font(EditView.font, EditView.font_size)
341
+ clear_char_width
342
+ reset_right_margin
343
+ end
344
+
345
+ h8 = @model.add_listener(:theme_changed) do
346
+ @mate_text.set_theme_by_name(EditView.theme)
347
+ end
348
+ h9 = @model.add_listener(:line_number_visibility_changed) do |new_bool|
349
+ @mate_text.set_line_numbers_visible(new_bool)
350
+ end
316
351
  h13 = @model.document.add_listener(:changed) do
317
352
  @undoable_override = true
318
353
  end
@@ -336,19 +371,19 @@ module Redcar
336
371
  end
337
372
  end
338
373
  end
339
-
374
+
340
375
  def type_character(character)
341
376
  mate_text.get_text_widget.doContent(character)
342
377
  mate_text.get_text_widget.update
343
378
  end
344
-
379
+
345
380
  model_listener :type_character
346
-
381
+
347
382
  def invoke_action(action_symbol)
348
383
  const = EditViewSWT::ALL_ACTIONS[action_symbol]
349
384
  mate_text.get_text_widget.invokeAction(const)
350
385
  end
351
-
386
+
352
387
  model_listener :invoke_action
353
388
 
354
389
  class VerifyKeyListener
@@ -430,6 +465,20 @@ module Redcar
430
465
  # h = @document.add_listener(:set_text, &method(:reparse))
431
466
  # @handlers << [@document, h]
432
467
  @mate_text.get_text_widget.add_word_movement_listener(WordMoveListener.new(self))
468
+ @mate_text.get_text_widget.add_control_listener(ControlListener.new(self))
469
+ end
470
+
471
+ class ControlListener
472
+ def initialize(edit_view_swt)
473
+ @edit_view_swt = edit_view_swt
474
+ end
475
+
476
+ def controlMoved(*_)
477
+ end
478
+
479
+ def controlResized(e)
480
+ @edit_view_swt.reset_right_margin
481
+ end
433
482
  end
434
483
 
435
484
  def reparse