redcar 0.9.2 → 0.10

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 (234) hide show
  1. data/CHANGES +34 -4
  2. data/Rakefile +2 -1
  3. data/lib/redcar.rb +3 -3
  4. data/lib/redcar/installer.rb +2 -3
  5. data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
  6. data/plugins/application/features/step_definitions/key_steps.rb +18 -0
  7. data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
  8. data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
  9. data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
  10. data/plugins/application/features/support/env.rb +39 -5
  11. data/plugins/application/features/support/fake_event.rb +12 -0
  12. data/plugins/application/lib/application.rb +5 -6
  13. data/plugins/application/lib/application/dialog.rb +53 -10
  14. data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
  15. data/plugins/application/lib/application/keymap.rb +10 -8
  16. data/plugins/application/lib/application/menu.rb +38 -16
  17. data/plugins/application/lib/application/treebook.rb +30 -0
  18. data/plugins/application/lib/application/window.rb +20 -2
  19. data/plugins/application/spec/application/command/executor_spec.rb +1 -0
  20. data/plugins/application/spec/application/menu_spec.rb +26 -26
  21. data/plugins/application/spec/application/treebook_spec.rb +6 -6
  22. data/plugins/application/spec/spec_helper.rb +10 -1
  23. data/plugins/application_swt/lib/application_swt.rb +25 -3
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
  26. data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
  27. data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
  28. data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
  29. data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
  30. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
  31. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
  32. data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
  33. data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
  34. data/plugins/application_swt/lib/application_swt/window.rb +85 -57
  35. data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
  36. data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
  37. data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
  38. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
  39. data/plugins/auto_completer/lib/auto_completer.rb +10 -42
  40. data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
  41. data/plugins/clojure/lib/clojure.rb +33 -0
  42. data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
  43. data/plugins/clojure/plugin.rb +9 -0
  44. data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
  45. data/plugins/clojure/spec/spec_helper.rb +5 -0
  46. data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
  47. data/plugins/{repl → clojure}/vendor/dummy +0 -0
  48. data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
  49. data/plugins/connection_manager/lib/connection_manager.rb +13 -13
  50. data/plugins/declarations/lib/declarations.rb +17 -6
  51. data/plugins/document_search/features/find.feature +389 -0
  52. data/plugins/document_search/features/find_and_replace.feature +723 -0
  53. data/plugins/document_search/features/replace.feature +69 -62
  54. data/plugins/document_search/lib/document_search.rb +81 -64
  55. data/plugins/document_search/lib/document_search/commands.rb +258 -0
  56. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
  57. data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
  58. data/plugins/document_search/lib/document_search/query_options.rb +45 -0
  59. data/plugins/edit_view/features/case_change.feature +9 -5
  60. data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
  61. data/plugins/edit_view/lib/edit_view.rb +15 -12
  62. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
  63. data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
  64. data/plugins/edit_view/lib/edit_view/document.rb +129 -99
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
  66. data/plugins/encryption/encryption.rb +2 -0
  67. data/plugins/find-in-project/lib/find_in_project.rb +3 -5
  68. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
  69. data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
  70. data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
  71. data/plugins/groovy/lib/groovy.rb +38 -0
  72. data/plugins/groovy/lib/groovy/commands.rb +10 -0
  73. data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
  74. data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
  75. data/plugins/groovy/plugin.rb +5 -4
  76. data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
  77. data/plugins/groovy/spec/spec_helper.rb +5 -0
  78. data/plugins/html_view/assets/json2.js +476 -0
  79. data/plugins/html_view/lib/html_view.rb +1 -0
  80. data/plugins/java/features/fixtures/test.java +0 -0
  81. data/plugins/java/features/support/env.rb +27 -0
  82. data/plugins/java/features/syntax_check_java.feature +86 -0
  83. data/plugins/java/lib/syntax_check/java.rb +86 -0
  84. data/plugins/java/plugin.rb +7 -0
  85. data/plugins/javascript/features/fixtures/test2.js +5 -0
  86. data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
  87. data/plugins/javascript/features/support/env.rb +14 -0
  88. data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
  89. data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
  90. data/plugins/line_tools/features/trim_line.feature +49 -0
  91. data/plugins/line_tools/lib/line_tools.rb +5 -1
  92. data/plugins/mirah/README +7 -0
  93. data/plugins/mirah/features/fixtures/test.mirah +2 -0
  94. data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
  95. data/plugins/mirah/lib/mirah.rb +43 -0
  96. data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
  97. data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
  98. data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
  99. data/plugins/mirah/plugin.rb +8 -0
  100. data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
  101. data/plugins/mirah/spec/spec_helper.rb +5 -0
  102. data/plugins/mirah/vendor/mirah-parser.jar +0 -0
  103. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
  104. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
  105. data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
  106. data/plugins/project/features/find_file.feature +40 -16
  107. data/plugins/project/features/highlight_focussed_tab.feature +16 -10
  108. data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
  109. data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
  110. data/plugins/project/features/support/env.rb +5 -0
  111. data/plugins/project/lib/project/commands.rb +8 -1
  112. data/plugins/project/lib/project/dir_controller.rb +4 -1
  113. data/plugins/project/lib/project/find_file_dialog.rb +16 -12
  114. data/plugins/project/lib/project/manager.rb +30 -1
  115. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  116. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  117. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  118. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  119. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  120. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  121. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  122. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  123. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  124. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  125. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  126. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  127. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  128. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  129. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  130. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  131. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  132. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  133. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  134. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  135. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  136. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  137. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  138. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  139. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  140. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  141. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  142. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  143. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  144. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  145. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  146. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  147. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  148. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  149. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  150. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  151. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  152. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  153. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  154. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  155. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  156. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  157. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  158. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  159. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  160. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  161. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  162. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  163. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  164. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  165. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  166. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  167. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  168. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  169. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  170. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  171. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  172. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  173. data/plugins/redcar/features/alter_font_size.feature +25 -0
  174. data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
  175. data/plugins/redcar/redcar.rb +256 -43
  176. data/plugins/repl/features/command_editing.feature +55 -0
  177. data/plugins/repl/features/command_history.feature +75 -0
  178. data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
  179. data/plugins/repl/features/support/env.rb +24 -0
  180. data/plugins/repl/features/support/fake_repl.rb +16 -0
  181. data/plugins/repl/lib/repl.rb +17 -74
  182. data/plugins/repl/lib/repl/repl_command.rb +20 -0
  183. data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
  184. data/plugins/repl/lib/repl/repl_tab.rb +131 -6
  185. data/plugins/repl/plugin.rb +1 -1
  186. data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
  187. data/plugins/repl/spec/spec_helper.rb +1 -1
  188. data/plugins/repl_swt/lib/repl_swt.rb +7 -0
  189. data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
  190. data/plugins/repl_swt/plugin.rb +8 -0
  191. data/plugins/ruby/lib/ruby.rb +35 -0
  192. data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
  193. data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
  194. data/plugins/ruby/plugin.rb +5 -4
  195. data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
  196. data/plugins/ruby/spec/spec_helper.rb +5 -0
  197. data/plugins/runnables/lib/runnables.rb +2 -0
  198. data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
  199. data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
  200. data/plugins/runnables/views/command_output.html.erb +3 -2
  201. data/plugins/scm/lib/scm.rb +4 -2
  202. data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
  203. data/plugins/scm_git/lib/scm_git.rb +136 -107
  204. data/plugins/scm_git/lib/scm_git/change.rb +28 -19
  205. data/plugins/snippets/lib/snippets/explorer.rb +2 -2
  206. data/plugins/swt/lib/swt/full_swt.rb +1 -0
  207. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
  208. data/plugins/syntax_check/features/support/env.rb +3 -0
  209. data/plugins/syntax_check/lib/syntax_check.rb +71 -5
  210. data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
  211. data/plugins/test_runner/lib/test_runner.rb +39 -0
  212. data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
  213. data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
  214. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
  215. data/plugins/test_runner/plugin.rb +8 -0
  216. data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
  217. data/plugins/test_runner/spec/spec_helper.rb +5 -0
  218. data/plugins/textmate/lib/textmate.rb +12 -2
  219. data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
  220. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
  221. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
  222. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
  223. data/plugins/todo_list/lib/todo_list.rb +7 -0
  224. data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
  225. data/plugins/tree/lib/tree.rb +4 -0
  226. data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
  227. data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
  228. metadata +137 -22
  229. data/plugins/document_search/features/search.feature +0 -163
  230. data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
  231. data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
  232. data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
  233. data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
  234. data/plugins/ruby/README +0 -6
@@ -0,0 +1,142 @@
1
+ module DocumentSearch
2
+ class FindAndReplaceSpeedbar < Redcar::Speedbar
3
+ NotFoundMessage = 'Not found!'
4
+
5
+ class << self
6
+ attr_accessor :previous_replace
7
+ end
8
+ @@previous_replace = ''
9
+
10
+ attr_accessor :initial_query
11
+
12
+ def doc
13
+ win = Redcar.app.focussed_window
14
+ tab = win.focussed_notebook_tab
15
+ tab.document if tab
16
+ end
17
+
18
+ ### UI ###
19
+
20
+ # Override num_columns to control number of rows.
21
+ def num_columns
22
+ return 7
23
+ end
24
+
25
+ label :label_find, "Find:"
26
+ textbox :query do
27
+ if doc
28
+ update_options_from_ui
29
+ FindSpeedbar.find_incremental
30
+ end
31
+ end
32
+
33
+ combo :query_type, ["Plain", "Regex", "Glob"], "Plain" do |val|
34
+ FindSpeedbar.previous_options.query_type = QueryOptions.query_type_to_symbol(val)
35
+ update_options_from_ui
36
+ FindSpeedbar.find_incremental
37
+ end
38
+
39
+ toggle :match_case, 'Match case', nil, false do |val|
40
+ FindSpeedbar.previous_options.match_case = val
41
+ update_options_from_ui
42
+ FindSpeedbar.find_incremental
43
+ end
44
+
45
+ toggle :wrap_around, 'Wrap around', nil, true do |val|
46
+ FindSpeedbar.previous_options.wrap_around = val
47
+ update_options_from_ui
48
+ FindSpeedbar.find_incremental
49
+ end
50
+
51
+ label :label_not_found, NotFoundMessage # Hack: Set label for sizing, clear in after_draw
52
+ label :label_space_end_row1, ""
53
+ label :label_spacer_start_row2, ""
54
+
55
+ label :label_replace, "Replace:"
56
+ textbox :replace
57
+
58
+ button :replace_find, 'Replace && Find', "Return" do
59
+ update_options_from_ui
60
+ FindAndReplaceSpeedbar.replace_and_find(
61
+ FindSpeedbar.previous_query, FindAndReplaceSpeedbar.previous_replace, FindSpeedbar.previous_options) or not_found
62
+ end
63
+
64
+ button :replace_all, "Replace All", nil do
65
+ update_options_from_ui
66
+ FindAndReplaceSpeedbar.replace_all(
67
+ FindSpeedbar.previous_query, FindAndReplaceSpeedbar.previous_replace, FindSpeedbar.previous_options) or not_found
68
+ end
69
+
70
+ label :label_spacer_mid_row2, ""
71
+
72
+ button :find_previous, "Previous", nil do
73
+ update_options_from_ui
74
+ FindSpeedbar.find_previous or not_found
75
+ end
76
+
77
+ button :find_next, "Next", nil do
78
+ update_options_from_ui
79
+ FindSpeedbar.find_next or not_found
80
+ end
81
+
82
+ # Initializes UI elements.
83
+ def after_draw
84
+ clear_not_found
85
+ self.query.value = @initial_query || FindSpeedbar.previous_query
86
+ self.replace.value = FindAndReplaceSpeedbar.previous_replace || ""
87
+ self.query_type.value = QueryOptions.query_type_to_text(FindSpeedbar.previous_options.query_type)
88
+ self.match_case.value = FindSpeedbar.previous_options.match_case
89
+ self.wrap_around.value = FindSpeedbar.previous_options.wrap_around
90
+ self.query.edit_view.document.select_all
91
+ end
92
+
93
+ # Store options specified in the UI, to be called before executing a command.
94
+ def update_options_from_ui
95
+ clear_not_found
96
+ FindSpeedbar.previous_query = query.value
97
+ FindAndReplaceSpeedbar.previous_replace = replace.value
98
+ FindSpeedbar.previous_options.query_type = QueryOptions.query_type_to_symbol(query_type.value)
99
+ FindSpeedbar.previous_options.match_case = match_case.value
100
+ FindSpeedbar.previous_options.wrap_around = wrap_around.value
101
+ end
102
+
103
+ # Sets the "Not found" label message, invoking the system beep.
104
+ def not_found
105
+ Swt::Widgets::Display.get_current.beep
106
+ self.label_not_found.text = NotFoundMessage
107
+ end
108
+
109
+ # Clears the "Not found" label message.
110
+ def clear_not_found
111
+ self.label_not_found.text = ''
112
+ end
113
+
114
+ ### COMMANDS ###
115
+
116
+ def self.repeat_find_next
117
+ find_next(FindSpeedbar.previous_query, FindSpeedbar.previous_options) or not_found
118
+ end
119
+
120
+ def self.repeat_find_previous
121
+ find_previous(FindSpeedbar.previous_query, FindSpeedbar.previous_options) or not_found
122
+ end
123
+
124
+ def self.replace_and_find(query, replace, options)
125
+ cmd = ReplaceAndFindCommand.new(query, replace, options)
126
+ cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
127
+ end
128
+
129
+ def self.replace_all(query, replace, options)
130
+ cmd = ReplaceAllCommand.new(query, replace, options)
131
+ cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
132
+ end
133
+
134
+ def self.use_selection_for_replace(doc, active_speedbar=nil)
135
+ return unless doc.selection?
136
+ FindAndReplaceSpeedbar.previous_replace = doc.selected_text
137
+ if active_speedbar && (active_speedbar.instance_of? FindAndReplaceSpeedbar)
138
+ active_speedbar.replace.value = FindAndReplaceSpeedbar.previous_replace
139
+ end
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,102 @@
1
+ module DocumentSearch
2
+ class FindSpeedbar < Redcar::Speedbar
3
+ class << self
4
+ attr_accessor :previous_query, :previous_options
5
+ end
6
+ @previous_query = ''
7
+ @previous_options = QueryOptions.new
8
+
9
+ attr_accessor :initial_query
10
+
11
+ def doc
12
+ win = Redcar.app.focussed_window
13
+ tab = win.focussed_notebook_tab
14
+ tab.document if tab
15
+ end
16
+
17
+ def after_draw
18
+ FindSpeedbar.previous_query ||= ""
19
+ self.query.value = @initial_query || FindSpeedbar.previous_query
20
+ self.query_type.value = QueryOptions.query_type_to_text(
21
+ FindSpeedbar.previous_options.query_type)
22
+ self.match_case.value = FindSpeedbar.previous_options.match_case
23
+ self.wrap_around.value = FindSpeedbar.previous_options.wrap_around
24
+ self.query.edit_view.document.select_all
25
+ end
26
+
27
+ label :label, "Find:"
28
+ textbox :query do |value|
29
+ if doc
30
+ update_options_from_ui
31
+ FindSpeedbar.find_incremental
32
+ end
33
+ end
34
+
35
+ combo :query_type, ["Plain", "Regex", "Glob"], "Plain" do |val|
36
+ FindSpeedbar.previous_options.query_type = QueryOptions.query_type_to_symbol(val)
37
+ update_options_from_ui
38
+ FindSpeedbar.find_incremental
39
+ end
40
+
41
+ toggle :match_case, 'Match case', nil, false do |val|
42
+ FindSpeedbar.previous_options.match_case = val
43
+ update_options_from_ui
44
+ FindSpeedbar.find_incremental
45
+ end
46
+
47
+ toggle :wrap_around, 'Wrap around', nil, true do |val|
48
+ FindSpeedbar.previous_options.wrap_around = val
49
+ update_options_from_ui
50
+ FindSpeedbar.find_incremental
51
+ end
52
+
53
+ button :previous, "Previous", "Alt+Return" do
54
+ if doc
55
+ update_options_from_ui
56
+ FindSpeedbar.find_previous
57
+ end
58
+ end
59
+
60
+ button :next, "Next", "Return" do
61
+ if doc
62
+ update_options_from_ui
63
+ FindSpeedbar.find_next
64
+ end
65
+ end
66
+
67
+ def update_options_from_ui
68
+ if doc and self.query.value and self.query.value != ""
69
+ FindSpeedbar.previous_query = self.query.value
70
+ FindSpeedbar.previous_options.query_type =
71
+ QueryOptions.query_type_to_symbol(self.query_type.value)
72
+ FindSpeedbar.previous_options.match_case = self.match_case.value
73
+ FindSpeedbar.previous_options.wrap_around = self.wrap_around.value
74
+ end
75
+ end
76
+
77
+ def self.find_incremental
78
+ cmd = FindIncrementalCommand.new(FindSpeedbar.previous_query, FindSpeedbar.previous_options)
79
+ cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
80
+ end
81
+
82
+ def self.find_next
83
+ cmd = FindNextCommand.new(FindSpeedbar.previous_query, FindSpeedbar.previous_options)
84
+ cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
85
+ end
86
+
87
+ def self.find_previous
88
+ cmd = FindPreviousCommand.new(FindSpeedbar.previous_query, FindSpeedbar.previous_options)
89
+ cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
90
+ end
91
+
92
+ # Note: The assumption that we set find only from selected text means we don't have to update
93
+ # search.
94
+ def self.use_selection_for_find(doc, active_speedbar=nil)
95
+ return unless doc.selection?
96
+ FindSpeedbar.previous_query = doc.selected_text
97
+ if active_speedbar
98
+ active_speedbar.query.value = FindSpeedbar.previous_query
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,45 @@
1
+ module DocumentSearch
2
+ # Encapsulates options for search queries.
3
+ class QueryOptions
4
+ attr_accessor :query_type
5
+ attr_accessor :match_case
6
+ attr_accessor :wrap_around
7
+
8
+ # Initializes with default options.
9
+ def initialize
10
+ @query_type = :query_plain
11
+ @match_case = false
12
+ @wrap_around = true
13
+ end
14
+
15
+ ### UTILITY ###
16
+
17
+ # Maps a search type combo box value to the corresponding search type symbol.
18
+ def self.query_type_to_symbol(query_type_text)
19
+ case query_type_text
20
+ when "Plain"
21
+ :query_plain
22
+ when "Regex"
23
+ :query_regex
24
+ when "Glob"
25
+ :query_glob
26
+ else
27
+ raise "Invalid query type: #{query_type_text}"
28
+ end
29
+ end
30
+
31
+ # Maps a search type symbol to a text value for the search type combo box.
32
+ def self.query_type_to_text(query_type_symbol)
33
+ case query_type_symbol
34
+ when :query_plain
35
+ 'Plain'
36
+ when :query_regex
37
+ 'Regex'
38
+ when :query_glob
39
+ 'Glob'
40
+ else
41
+ raise "Invalid query type symbol: #{query_type_symbol}"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -32,25 +32,29 @@ Feature: Change Case
32
32
  And I select from 0 to 13
33
33
  And I run the command Redcar::EditView::TitlizeTextCommand
34
34
  Then the contents should be "<s>Curry Chicken<c>"
35
-
35
+ When I replace the contents with "CURRY CHICKEN"
36
+ And I select from 0 to 13
37
+ And I run the command Redcar::EditView::TitlizeTextCommand
38
+ Then the contents should be "<s>Curry Chicken<c>"
39
+
36
40
  Scenario: Opposite case
37
41
  When I replace the contents with "Curry Chicken"
38
42
  And I select from 0 to 13
39
43
  And I run the command Redcar::EditView::OppositeCaseTextCommand
40
44
  Then the contents should be "<s>cURRY cHICKEN<c>"
41
-
45
+
42
46
  Scenario: Camel case
43
47
  When I replace the contents with "curry_chicken"
44
48
  And I move the cursor to 13
45
49
  And I run the command Redcar::EditView::CamelCaseTextCommand
46
50
  Then the contents should be "CurryChicken<c>"
47
-
51
+
48
52
  Scenario: Underscore
49
53
  When I replace the contents with "CurryChicken"
50
54
  And I move the cursor to 12
51
55
  And I run the command Redcar::EditView::UnderscoreTextCommand
52
56
  Then the contents should be "curry_chicke<c>n"
53
-
57
+
54
58
  Scenario: Pascal to Underscore to Camel Case rotation
55
59
  When I replace the contents with "CurryChicken"
56
60
  And I move the cursor to 12
@@ -60,4 +64,4 @@ Feature: Change Case
60
64
  Then the contents should be "curryChicken<c>"
61
65
  When I run the command Redcar::EditView::CamelSnakePascalRotateTextCommand
62
66
  Then the contents should be "CurryChicken<c>"
63
-
67
+
@@ -37,6 +37,11 @@ When /^I move the cursor to (\d+)$/ do |offset|
37
37
  doc.cursor_offset = offset.to_i
38
38
  end
39
39
 
40
+ When /^I move the cursor to the end of the document$/ do
41
+ doc = Redcar.app.focussed_window.focussed_notebook.focussed_tab.edit_view.document
42
+ doc.cursor_offset = doc.length
43
+ end
44
+
40
45
  Then /^the cursor should be at (\d+)$/ do |offset|
41
46
  doc = Redcar::EditView.focussed_tab_edit_view.document
42
47
  doc.cursor_offset.should == offset.to_i
@@ -184,6 +189,13 @@ When /^I replace the contents with 100 lines of "([^"]*)" then "([^"]*)"$/ do |c
184
189
  doc.text = (contents1 + "\n")*100 + contents2
185
190
  end
186
191
 
192
+ When /^I replace the contents with (\d+) "([^"]*)" then "([^"]*)"$/ do |count, contents1, contents2|
193
+ contents1 = unescape_text(contents1)
194
+ contents2 = unescape_text(contents2)
195
+ doc = Redcar::EditView.focussed_edit_view_document
196
+ doc.text = (contents1)*count.to_i + contents2
197
+ end
198
+
187
199
  When /^I scroll to the top of the document$/ do
188
200
  doc = Redcar::EditView.focussed_edit_view_document
189
201
  doc.scroll_to_line(0)
@@ -196,6 +208,13 @@ Then /^line number (\d+) should be visible$/ do |line_num|
196
208
  (doc.smallest_visible_line <= line_num).should be_true
197
209
  end
198
210
 
211
+ Then /^horizontal offset (\d+) should be visible$/ do |offset|
212
+ offset = offset.to_i
213
+ doc = Redcar::EditView.focussed_edit_view_document
214
+ (doc.largest_visible_horizontal_index >= offset).should be_true
215
+ (doc.smallest_visible_horizontal_index <= offset).should be_true
216
+ end
217
+
199
218
  When /^I select the word (right of|left of|around|at) (\d+)$/ do |direction, offset|
200
219
  offset = offset.to_i
201
220
  doc = Redcar::EditView.focussed_edit_view_document
@@ -63,7 +63,10 @@ module Redcar
63
63
  :DELETE_WORD_PREVIOUS,
64
64
  :DELETE_WORD_NEXT
65
65
  ]
66
-
66
+
67
+ MAX_FONT_SIZE = 25
68
+ MIN_FONT_SIZE = 1
69
+
67
70
  include Redcar::Model
68
71
  extend Redcar::Observable
69
72
  include Redcar::Observable
@@ -110,7 +113,7 @@ module Redcar
110
113
  end
111
114
  end
112
115
  end
113
-
116
+
114
117
  def self.toolbars
115
118
  ToolBar::Builder.build do
116
119
  item "Cut", :command => Redcar::Top::CutCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "scissors-blue.png"), :barname => :edit
@@ -174,7 +177,7 @@ module Redcar
174
177
  def self.esc_handlers
175
178
  [Actions::EscapeHandler]
176
179
  end
177
-
180
+
178
181
  def self.cmd_enter_handlers
179
182
  [Actions::CmdEnterHandler]
180
183
  end
@@ -202,7 +205,7 @@ module Redcar
202
205
  def self.all_backspace_handlers
203
206
  all_handlers(:backspace)
204
207
  end
205
-
208
+
206
209
  def self.all_cmd_enter_handlers
207
210
  all_handlers(:cmd_enter)
208
211
  end
@@ -242,7 +245,7 @@ module Redcar
242
245
  def backspace_pressed(modifiers)
243
246
  handle_key(EditView.all_backspace_handlers, modifiers)
244
247
  end
245
-
248
+
246
249
  def cmd_enter_pressed(modifiers)
247
250
  handle_key(EditView.all_cmd_enter_handlers, modifiers)
248
251
  end
@@ -380,7 +383,7 @@ module Redcar
380
383
  @focussed = nil
381
384
  create_history
382
385
  end
383
-
386
+
384
387
  def create_history
385
388
  @history = Document::History.new(500)
386
389
  @history.subscribe do |action|
@@ -574,25 +577,25 @@ module Redcar
574
577
  end
575
578
  @last_checked = Time.now
576
579
  end
577
-
580
+
578
581
  # This characters have custom Redcar behaviour.
579
582
  OVERRIDDEN_CHARACTERS = {
580
583
  9 => [:tab_pressed, []]
581
584
  }
582
-
585
+
583
586
  def type_character(character)
584
587
  unless custom_character_handle(character)
585
588
  notify_listeners(:type_character, character)
586
589
  end
587
590
  history.record(character)
588
591
  end
589
-
592
+
590
593
  def custom_character_handle(character)
591
594
  if method_call = OVERRIDDEN_CHARACTERS[character]
592
595
  send(*method_call)
593
596
  end
594
597
  end
595
-
598
+
596
599
  # These actions have custom Redcar implementations that
597
600
  # override the default StyledText implementation. (Mainly for
598
601
  # soft tabs purposes.)
@@ -604,13 +607,13 @@ module Redcar
604
607
  :DELETE_PREVIOUS => Actions::BackspaceHandler,
605
608
  :DELETE_NEXT => Actions::DeleteHandler
606
609
  }
607
-
610
+
608
611
  def invoke_overridden_action(action_symbol)
609
612
  if handler = OVERRIDDEN_ACTIONS[action_symbol]
610
613
  handler.send(action_symbol.to_s.downcase, self)
611
614
  end
612
615
  end
613
-
616
+
614
617
  def invoke_action(action_symbol)
615
618
  unless invoke_overridden_action(action_symbol)
616
619
  notify_listeners(:invoke_action, action_symbol)