redcar 0.3.4.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. data/CHANGES +45 -0
  2. data/README.md +2 -1
  3. data/ROADMAP.md +0 -1
  4. data/Rakefile +10 -4
  5. data/bin/redcar +2 -2
  6. data/lib/openssl/build.properties +7 -0
  7. data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
  8. data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
  9. data/lib/redcar.rb +12 -8
  10. data/lib/redcar/installer.rb +16 -15
  11. data/lib/redcar/ruby_extensions.rb +146 -1
  12. data/lib/redcar/runner.rb +16 -7
  13. data/lib/redcar/usage.rb +4 -7
  14. data/lib/redcar_quick_start.rb +5 -5
  15. data/lib/regex_replace.rb +0 -7
  16. data/plugins/application/features/step_definitions/command_steps.rb +5 -0
  17. data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
  18. data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
  19. data/plugins/application/features/step_definitions/window_steps.rb +1 -1
  20. data/plugins/application/features/support/env.rb +44 -8
  21. data/plugins/application/lib/application.rb +32 -33
  22. data/plugins/application/lib/application/command.rb +32 -2
  23. data/plugins/application/lib/application/command/executor.rb +2 -12
  24. data/plugins/application/lib/application/dialog.rb +14 -14
  25. data/plugins/application/lib/application/event_spewer.rb +32 -0
  26. data/plugins/application/lib/application/menu.rb +5 -5
  27. data/plugins/application/lib/application/menu/builder.rb +5 -0
  28. data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
  29. data/plugins/application/lib/application/notebook.rb +4 -3
  30. data/plugins/application/lib/application/tab.rb +6 -2
  31. data/plugins/application/lib/application/window.rb +8 -4
  32. data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
  33. data/plugins/application/spec/application/notebook_spec.rb +1 -1
  34. data/plugins/application_swt/build.xml +74 -0
  35. data/plugins/application_swt/lib/application_swt.rb +79 -0
  36. data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
  37. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
  38. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
  39. data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
  40. data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
  41. data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
  42. data/plugins/application_swt/lib/application_swt/window.rb +11 -11
  43. data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
  44. data/plugins/auto_completer/lib/auto_completer.rb +74 -67
  45. data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
  46. data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
  47. data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
  48. data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
  49. data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
  50. data/plugins/auto_indenter/features/support/env.rb +2 -0
  51. data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
  52. data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
  53. data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
  54. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
  55. data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
  56. data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
  57. data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
  58. data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
  59. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
  60. data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
  61. data/plugins/core/lib/core.rb +12 -1
  62. data/plugins/core/lib/core/observable.rb +7 -7
  63. data/plugins/core/lib/core/persistent_cache.rb +14 -2
  64. data/plugins/core/lib/core/plugin.rb +7 -0
  65. data/plugins/core/lib/core/resource.rb +78 -0
  66. data/plugins/core/lib/core/task.rb +62 -0
  67. data/plugins/core/lib/core/task_queue.rb +72 -0
  68. data/plugins/core/spec/core/resource_spec.rb +124 -0
  69. data/plugins/core/spec/core/task_queue_spec.rb +202 -0
  70. data/plugins/core/spec/spec_helper.rb +23 -1
  71. data/plugins/declarations/TODO +3 -0
  72. data/plugins/declarations/lib/declarations.rb +144 -0
  73. data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
  74. data/plugins/declarations/lib/declarations/file.rb +68 -0
  75. data/plugins/declarations/lib/declarations/parser.rb +94 -0
  76. data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
  77. data/plugins/declarations/plugin.rb +7 -0
  78. data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
  79. data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
  80. data/plugins/declarations/spec/spec_helper.rb +4 -0
  81. data/plugins/edit_view/features/indentation_commands.feature +40 -0
  82. data/plugins/edit_view/features/line_delimiter.feature +40 -0
  83. data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
  84. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
  85. data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
  86. data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
  87. data/plugins/edit_view/features/support/env.rb +3 -5
  88. data/plugins/edit_view/features/undo_and_redo.feature +21 -0
  89. data/plugins/edit_view/lib/edit_view.rb +57 -4
  90. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
  91. data/plugins/edit_view/lib/edit_view/document.rb +46 -11
  92. data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
  93. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
  94. data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
  95. data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
  96. data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
  97. data/plugins/edit_view/spec/spec_helper.rb +1 -0
  98. data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
  99. data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
  100. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
  101. data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
  102. data/plugins/encryption/encryption.rb +13 -6
  103. data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
  104. data/plugins/html_view/assets/redcar.css +32 -1
  105. data/plugins/html_view/lib/html_view.rb +23 -3
  106. data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
  107. data/plugins/my_plugin/lib/my_plugin.rb +4 -12
  108. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
  109. data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
  110. data/plugins/project/features/find_file.feature +75 -0
  111. data/plugins/project/features/open_and_save_files.feature +7 -7
  112. data/plugins/project/features/open_directory_tree.feature +11 -3
  113. data/plugins/project/features/refresh_directory_tree.feature +7 -1
  114. data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
  115. data/plugins/project/features/step_definitions/file_steps.rb +10 -0
  116. data/plugins/project/features/support/env.rb +6 -1
  117. data/plugins/project/features/watch_for_modified_files.feature +79 -0
  118. data/plugins/project/lib/project.rb +72 -306
  119. data/plugins/project/lib/project/commands.rb +128 -0
  120. data/plugins/project/lib/project/dir_mirror.rb +5 -1
  121. data/plugins/project/lib/project/drb_service.rb +21 -31
  122. data/plugins/project/lib/project/file_list.rb +76 -0
  123. data/plugins/project/lib/project/file_mirror.rb +13 -1
  124. data/plugins/project/lib/project/find_file_dialog.rb +22 -52
  125. data/plugins/project/lib/project/manager.rb +210 -0
  126. data/plugins/project/lib/project/recent_directories.rb +16 -3
  127. data/plugins/project/plugin.rb +1 -1
  128. data/plugins/project/spec/fixtures/myproject/README +2 -0
  129. data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
  130. data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
  131. data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
  132. data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
  133. data/plugins/project/spec/project/file_list_spec.rb +140 -0
  134. data/plugins/project/spec/spec_helper.rb +20 -0
  135. data/plugins/redcar/plugin.rb +1 -0
  136. data/plugins/redcar/redcar.rb +254 -84
  137. data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
  138. data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
  139. data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
  140. data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
  141. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
  142. data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
  143. data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
  144. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
  145. data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
  146. data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
  147. data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
  148. data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
  149. data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
  150. data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
  151. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
  152. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
  153. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
  154. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
  155. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
  156. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
  157. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
  158. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
  159. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
  160. data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
  161. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
  162. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
  163. data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
  164. data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
  165. data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
  166. data/plugins/redcar_debug/views/history.html.erb +33 -0
  167. data/plugins/redcar_debug/views/index.html.erb +33 -0
  168. data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
  169. data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
  170. data/plugins/snippets/lib/snippets.rb +0 -1
  171. data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
  172. data/plugins/task_manager/lib/task_manager.rb +28 -0
  173. data/plugins/task_manager/plugin.rb +11 -0
  174. data/plugins/task_manager/views/index.html.erb +67 -0
  175. data/plugins/textmate/lib/textmate.rb +17 -21
  176. data/plugins/textmate/lib/textmate/plist.rb +1 -2
  177. data/plugins/textmate/lib/textmate/preference.rb +5 -1
  178. data/plugins/textmate/lib/textmate/snippet.rb +6 -1
  179. data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
  180. data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
  181. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
  182. data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
  183. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
  184. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
  185. data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
  186. data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
  187. data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
  188. data/textmate/Themes/Emacs Strict.tmTheme +241 -0
  189. data/textmate/Themes/IR_White.tmTheme +792 -0
  190. data/textmate/Themes/Monokai.tmTheme +291 -0
  191. data/textmate/Themes/WhysPoignant.tmTheme +191 -0
  192. metadata +92 -7
  193. data/plugins/application/features/main_window.feature +0 -8
  194. data/plugins/project/lib/project/project_command.rb +0 -5
  195. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
  196. data/textmate/Bundles/Cucumber.tmbundle/Snippets/Story.tmSnippet +0 -25
@@ -8,6 +8,7 @@ Plugin.define do
8
8
  "application", ">0",
9
9
  "project", ">0",
10
10
  "Auto Completer", ">0",
11
+ "auto_indenter", ">0",
11
12
  "HTML View", ">=0.3.2",
12
13
  "Plugin Manager UI", ">=0.3.2"
13
14
  end
@@ -1,5 +1,18 @@
1
1
  module Redcar
2
2
  module Top
3
+ class QuitCommand < Command
4
+
5
+ def execute
6
+ EditView::ModifiedTabsChecker.new(
7
+ Redcar.app.all_tabs.select {|t| t.is_a?(EditTab)},
8
+ "Save all before quitting?",
9
+ :none => lambda { Redcar.app.quit },
10
+ :continue => lambda { Redcar.app.quit },
11
+ :cancel => nil
12
+ ).check
13
+ end
14
+ end
15
+
3
16
  class NewCommand < Command
4
17
 
5
18
  def execute
@@ -38,7 +51,50 @@ module Redcar
38
51
  end
39
52
 
40
53
  def execute
41
- (@window||win).close
54
+ check_for_modified_tabs_and_close_window
55
+ quit_if_no_windows if [:linux, :windows].include?(Redcar.platform)
56
+ @window = nil
57
+ end
58
+
59
+ private
60
+
61
+ def quit_if_no_windows
62
+ if Redcar.app.windows.length == 0
63
+ if Application.storage['stay_resident_after_last_window_closed'] && !(ARGV.include?("--multiple-instance"))
64
+ puts 'continuing to run to wait for incoming drb connections later'
65
+ else
66
+ QuitCommand.new.run
67
+ end
68
+ end
69
+ end
70
+
71
+ def check_for_modified_tabs_and_close_window
72
+ EditView::ModifiedTabsChecker.new(
73
+ win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(EditTab)},
74
+ "Save all before closing the window?",
75
+ :none => lambda { win.close },
76
+ :continue => lambda { win.close },
77
+ :cancel => nil
78
+ ).check
79
+ end
80
+
81
+ def win
82
+ @window || super
83
+ end
84
+ end
85
+
86
+ class FocusWindowCommand < Command
87
+ def initialize(window=nil)
88
+ @window = window
89
+ end
90
+
91
+ def execute
92
+ win.focus
93
+ @window = nil
94
+ end
95
+
96
+ def win
97
+ @window || super
42
98
  end
43
99
  end
44
100
 
@@ -84,41 +140,28 @@ module Redcar
84
140
 
85
141
  class AboutCommand < Command
86
142
  def execute
87
- new_tab = Top::NewCommand.new.run
88
- new_tab.document.text = "About: Redcar\nVersion: #{Redcar::VERSION}\n" +
89
- "Ruby Version: #{RUBY_VERSION}\n" +
90
- "Jruby version: #{JRUBY_VERSION}\n" +
91
- "Redcar.environment: #{Redcar.environment}\n" +
92
- "http://redcareditor.com"
93
- new_tab.title= 'About'
143
+ new_tab = Top::NewCommand.new.run
144
+ new_tab.document.text = "About: Redcar\nVersion: #{Redcar::VERSION}\n" +
145
+ "Ruby Version: #{RUBY_VERSION}\n" +
146
+ "Jruby version: #{JRUBY_VERSION}\n" +
147
+ "Redcar.environment: #{Redcar.environment}\n" +
148
+ "http://redcareditor.com"
149
+ new_tab.title= 'About'
150
+ new_tab.edit_view.reset_undo
151
+ new_tab.document.set_modified(false)
94
152
  end
95
153
  end
96
154
 
97
155
  class ChangelogCommand < Command
98
156
  def execute
99
- new_tab = Top::NewCommand.new.run
100
- new_tab.document.text = File.read(File.join(File.dirname(__FILE__), "..", "..", "CHANGES"))
101
- new_tab.title = 'Changes'
157
+ new_tab = Top::NewCommand.new.run
158
+ new_tab.document.text = File.read(File.join(File.dirname(__FILE__), "..", "..", "CHANGES"))
159
+ new_tab.title = 'Changes'
160
+ new_tab.edit_view.reset_undo
161
+ new_tab.edit_view.document.set_modified(false)
102
162
  end
103
163
  end
104
164
 
105
- class PrintContents < EditTabCommand
106
-
107
- def execute
108
- puts "printing contents"
109
- p tab.edit_view.document.to_s
110
- end
111
- end
112
-
113
- class PrintHistoryCommand < Command
114
- def execute
115
- Redcar.app.history.each do |c|
116
- puts c
117
- end
118
- end
119
- end
120
-
121
-
122
165
  class PrintScopeTreeCommand < Command
123
166
  def execute
124
167
  puts tab.edit_view.controller.mate_text.parser.root.pretty(0)
@@ -127,22 +170,41 @@ module Redcar
127
170
 
128
171
  class PrintScopeCommand < Command
129
172
  def execute
130
- p tab.edit_view.document.cursor_scope
173
+ Application::Dialog.tool_tip(tab.edit_view.document.cursor_scope.gsub(" ", "\n"))
131
174
  end
132
175
  end
133
176
 
134
- class CloseTabCommand < Command
177
+ class CloseTabCommand < TabCommand
178
+ def initialize(tab=nil)
179
+ @tab = tab
180
+ end
181
+
182
+ def tab
183
+ @tab || super
184
+ end
135
185
 
136
186
  def execute
137
- if tab = win.focussed_notebook_tab
187
+ if tab.is_a?(EditTab)
188
+ if tab.edit_view.document.modified?
189
+ result = Application::Dialog.message_box(
190
+ "This tab has unsaved changes. \n\nSave before closing?",
191
+ :buttons => :yes_no_cancel
192
+ )
193
+ case result
194
+ when :yes
195
+ tab.edit_view.document.save!
196
+ tab.close
197
+ when :no
198
+ tab.close
199
+ when :cancel
200
+ end
201
+ else
202
+ tab.close
203
+ end
204
+ else
138
205
  tab.close
139
206
  end
140
- end
141
- end
142
-
143
- class ListTabsCommand < Command
144
- def execute
145
- p win.focussed_notebook.tabs.map {|tab| tab.class}
207
+ @tab = nil
146
208
  end
147
209
  end
148
210
 
@@ -182,6 +244,7 @@ module Redcar
182
244
  doc = tab.edit_view.document
183
245
  line_ix = doc.line_at_offset(doc.cursor_offset)
184
246
  doc.cursor_offset = doc.offset_at_line(line_ix)
247
+ doc.ensure_visible(doc.cursor_offset)
185
248
  end
186
249
  end
187
250
 
@@ -195,30 +258,35 @@ module Redcar
195
258
  else
196
259
  doc.cursor_offset = doc.offset_at_line(line_ix + 1) - 1
197
260
  end
261
+ doc.ensure_visible(doc.cursor_offset)
198
262
  end
199
263
  end
200
264
 
201
265
  class ChangeIndentCommand < EditTabCommand
202
266
  def execute
203
267
  doc = tab.edit_view.document
204
- if doc.selection?
205
- first_line_ix = doc.line_at_offset(doc.selection_range.begin)
206
- last_line_ix = doc.line_at_offset(doc.selection_range.end)
207
- if doc.selection_range.end == doc.offset_at_line(last_line_ix)
208
- last_line_ix -= 1
209
- end
210
- first_line_ix.upto(last_line_ix) do |line_ix|
211
- indent_line(doc, line_ix)
212
- end
213
- start_selection = doc.offset_at_line(first_line_ix)
214
- if last_line_ix == doc.line_count - 1
215
- end_selection = doc.length
216
- else
217
- end_selection = doc.offset_at_line(last_line_ix + 1)
268
+ doc.compound do
269
+ doc.edit_view.delay_parsing do
270
+ if doc.selection?
271
+ first_line_ix = doc.line_at_offset(doc.selection_range.begin)
272
+ last_line_ix = doc.line_at_offset(doc.selection_range.end)
273
+ if doc.selection_range.end == doc.offset_at_line(last_line_ix)
274
+ last_line_ix -= 1
275
+ end
276
+ first_line_ix.upto(last_line_ix) do |line_ix|
277
+ indent_line(doc, line_ix)
278
+ end
279
+ start_selection = doc.offset_at_line(first_line_ix)
280
+ if last_line_ix == doc.line_count - 1
281
+ end_selection = doc.length
282
+ else
283
+ end_selection = doc.offset_at_line(last_line_ix + 1)
284
+ end
285
+ doc.set_selection_range(start_selection, end_selection)
286
+ else
287
+ indent_line(doc, doc.cursor_line)
288
+ end
218
289
  end
219
- doc.set_selection_range(start_selection, end_selection)
220
- else
221
- indent_line(doc, doc.cursor_line)
222
290
  end
223
291
  end
224
292
  end
@@ -229,12 +297,21 @@ module Redcar
229
297
  use_spaces = true
230
298
  num_spaces = 2
231
299
  line = doc.get_line(line_ix)
232
- if line[0..0] == "\t"
300
+ if doc.edit_view.soft_tabs?
233
301
  line_start = doc.offset_at_line(line_ix)
234
- to = line_start + 1
235
- elsif line[0...num_spaces] == " "*num_spaces
302
+ re = /^ {0,#{doc.edit_view.tab_width}}/
303
+ if md = line.match(re)
304
+ to = line_start + md[0].length
305
+ else
306
+ to = line_start
307
+ end
308
+ else
236
309
  line_start = doc.offset_at_line(line_ix)
237
- to = line_start + num_spaces
310
+ if line =~ /^\t/
311
+ to = line_start + 1
312
+ else
313
+ to = line_start
314
+ end
238
315
  end
239
316
  doc.delete(line_start, to - line_start) unless line_start == to
240
317
  end
@@ -244,18 +321,15 @@ module Redcar
244
321
 
245
322
  def indent_line(doc, line_ix)
246
323
  line = doc.get_line(line_ix)
247
- whitespace_type = line[/^( |\t)/, 1] || " "
248
- doc.insert(doc.offset_at_line(line_ix), whitespace_type)
324
+ if doc.edit_view.soft_tabs?
325
+ whitespace = " "*doc.edit_view.tab_width
326
+ else
327
+ whitespace = "\t"
328
+ end
329
+ doc.insert(doc.offset_at_line(line_ix), whitespace)
249
330
  end
250
331
  end
251
332
 
252
- class StripWhitespaceCommand < Redcar::EditTabCommand
253
-
254
- def execute
255
- doc.text = doc.to_s.gsub(/\s+$/, "\n")
256
- end
257
- end
258
-
259
333
  class SelectAllCommand < Redcar::EditTabCommand
260
334
 
261
335
  def execute
@@ -338,12 +412,32 @@ module Redcar
338
412
  doc.offset_at_line(line_ix) + line_offset,
339
413
  text
340
414
  )
415
+ doc.cursor_offset = doc.offset_at_line(line_ix) + line_offset + text.length
341
416
  end
342
- new_offset = doc.offset_at_line(cursor_line) + cursor_line_offset + Redcar.app.clipboard.last.first.length
343
- doc.cursor_offset = new_offset
344
417
  end
345
418
  end
346
419
 
420
+ class DuplicateCommand < Redcar::DocumentCommand
421
+
422
+ def execute
423
+ doc = tab.edit_view.document
424
+ if doc.selection?
425
+ first_line_ix = doc.line_at_offset(doc.selection_range.begin)
426
+ last_line_ix = doc.line_at_offset(doc.selection_range.end)
427
+ text = doc.get_slice(doc.offset_at_line(first_line_ix),
428
+ doc.offset_at_line_end(last_line_ix))
429
+ else
430
+ last_line_ix = doc.cursor_line
431
+ text = doc.get_line(doc.cursor_line)
432
+ end
433
+ if last_line_ix == (doc.line_count - 1)
434
+ text = "\n#{text}"
435
+ end
436
+ doc.insert(doc.offset_at_line_end(last_line_ix), text)
437
+ doc.scroll_to_line(last_line_ix + 1)
438
+ end
439
+ end
440
+
347
441
  class DialogExample < Redcar::Command
348
442
  def execute
349
443
  builder = Menu::Builder.new do
@@ -506,6 +600,23 @@ module Redcar
506
600
  end
507
601
  end
508
602
 
603
+ # define commands from SelectTab1Command to SelectTab9Command
604
+ (1..9).each do |tab_num|
605
+ const_set("SelectTab#{tab_num}Command", Class.new(Redcar::Command)).class_eval do
606
+ define_method :execute do
607
+ notebook = Redcar.app.focussed_window_notebook
608
+ notebook.tabs[tab_num-1].focus if notebook.tabs[tab_num-1]
609
+ end
610
+ end
611
+ end
612
+
613
+ class ToggleInvisibles < Redcar::EditTabCommand
614
+ def execute
615
+ EditView.show_invisibles = !EditView.show_invisibles?
616
+ end
617
+ end
618
+
619
+
509
620
  def self.keymaps
510
621
  osx = Redcar::Keymap.build("main", :osx) do
511
622
  link "Cmd+N", NewCommand
@@ -517,6 +628,7 @@ module Redcar
517
628
  link "Cmd+Shift+S", Project::FileSaveAsCommand
518
629
  link "Cmd+W", CloseTabCommand
519
630
  link "Cmd+Shift+W", CloseWindowCommand
631
+ link "Cmd+Q", QuitCommand
520
632
 
521
633
  link "Cmd+Shift+E", EditView::InfoSpeedbarCommand
522
634
  link "Cmd+Z", UndoCommand
@@ -524,10 +636,12 @@ module Redcar
524
636
  link "Cmd+X", CutCommand
525
637
  link "Cmd+C", CopyCommand
526
638
  link "Cmd+V", PasteCommand
639
+ link "Cmd+D", DuplicateCommand
527
640
  link "Ctrl+A", MoveHomeCommand
528
641
  link "Ctrl+E", MoveEndCommand
529
642
  link "Cmd+[", DecreaseIndentCommand
530
643
  link "Cmd+]", IncreaseIndentCommand
644
+ link "Cmd+Shift+I", AutoIndenter::IndentCommand
531
645
  link "Cmd+L", GotoLineCommand
532
646
  link "Cmd+F", SearchForwardCommand
533
647
  link "Cmd+G", RepeatPreviousSearchForwardCommand
@@ -542,10 +656,18 @@ module Redcar
542
656
  link "Cmd+Shift+[", SwitchTabDownCommand
543
657
  link "Cmd+Shift+]", SwitchTabUpCommand
544
658
 
659
+ link "Ctrl+Shift+P", PrintScopeCommand
660
+
545
661
  link "Cmd+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
546
662
 
547
663
  link "Cmd+Alt+S", Snippets::OpenSnippetExplorer
548
664
  #Textmate.attach_keybindings(self, :osx)
665
+
666
+ # map SelectTab<number>Command
667
+ (1..9).each do |tab_num|
668
+ link "Cmd+#{tab_num}", Top.const_get("SelectTab#{tab_num}Command")
669
+ end
670
+
549
671
  end
550
672
 
551
673
  linwin = Redcar::Keymap.build("main", [:linux, :windows]) do
@@ -558,18 +680,21 @@ module Redcar
558
680
  link "Ctrl+Shift+S", Project::FileSaveAsCommand
559
681
  link "Ctrl+W", CloseTabCommand
560
682
  link "Ctrl+Shift+W", CloseWindowCommand
561
-
683
+ link "Ctrl+Q", QuitCommand
684
+
562
685
  link "Ctrl+Shift+E", EditView::InfoSpeedbarCommand
563
686
  link "Ctrl+Z", UndoCommand
564
687
  link "Ctrl+Y", RedoCommand
565
688
  link "Ctrl+X", CutCommand
566
689
  link "Ctrl+C", CopyCommand
567
690
  link "Ctrl+V", PasteCommand
691
+ link "Ctrl+D", DuplicateCommand
568
692
  link "Ctrl+A", MoveHomeCommand
569
693
  link "Ctrl+E", MoveEndCommand
570
694
  link "Ctrl+[", DecreaseIndentCommand
571
695
  link "Ctrl+]", IncreaseIndentCommand
572
- link "Ctrl+G", GotoLineCommand
696
+ link "Ctrl+Shift+[", AutoIndenter::IndentCommand
697
+ link "Ctrl+L", GotoLineCommand
573
698
  link "Ctrl+F", SearchForwardCommand
574
699
  link "F3", RepeatPreviousSearchForwardCommand
575
700
  link "Ctrl+A", SelectAllCommand
@@ -580,6 +705,8 @@ module Redcar
580
705
  link "Ctrl+T", Project::FindFileCommand
581
706
  link "Ctrl+Shift+Alt+O", MoveTabToOtherNotebookCommand
582
707
 
708
+ link "Ctrl+Shift+P", PrintScopeCommand
709
+
583
710
  link "Ctrl+Alt+O", SwitchNotebookCommand
584
711
 
585
712
  link "Ctrl+Page Up", SwitchTabDownCommand
@@ -589,6 +716,11 @@ module Redcar
589
716
  link "Ctrl+Alt+S", Snippets::OpenSnippetExplorer
590
717
  #Textmate.attach_keybindings(self, :linux)
591
718
 
719
+ # map SelectTab<number>Command
720
+ (1..9).each do |tab_num|
721
+ link "Alt+#{tab_num}", Top.const_get("SelectTab#{tab_num}Command")
722
+ end
723
+
592
724
  end
593
725
 
594
726
  [linwin, osx]
@@ -602,7 +734,7 @@ module Redcar
602
734
  item "New Window", NewWindowCommand
603
735
  item "Open", Project::FileOpenCommand
604
736
  item "Open Directory", Project::DirectoryOpenCommand
605
- sub_menu "Open Recent" do
737
+ lazy_sub_menu "Open Recent" do
606
738
  Project::RecentDirectories.generate_menu(self)
607
739
  end
608
740
 
@@ -611,9 +743,16 @@ module Redcar
611
743
  item "Save As", Project::FileSaveAsCommand
612
744
  separator
613
745
  item "Close Tab", CloseTabCommand
746
+ sub_menu "Switch Tab" do
747
+ (1..9).each do |num|
748
+ item "Tab #{num}", Top.const_get("SelectTab#{num}Command")
749
+ end
750
+ end
614
751
  item "Close Notebook", CloseNotebookCommand
615
752
  item "Close Window", CloseWindowCommand
616
753
  item "Close Directory", Project::DirectoryCloseCommand
754
+ separator
755
+ item "Quit", QuitCommand
617
756
  end
618
757
  sub_menu "Edit" do
619
758
  item "Tab Info", EditView::InfoSpeedbarCommand
@@ -624,14 +763,14 @@ module Redcar
624
763
  item "Cut", CutCommand
625
764
  item "Copy", CopyCommand
626
765
  item "Paste", PasteCommand
766
+ item "Duplicate Region", DuplicateCommand
627
767
  separator
628
768
  item "Home", MoveHomeCommand
629
769
  item "End", MoveEndCommand
630
770
  separator
631
771
  item "Increase Indent", IncreaseIndentCommand
632
772
  item "Decrease Indent", DecreaseIndentCommand
633
- separator
634
- item "Strip Whitespace", StripWhitespaceCommand
773
+ item "Indent", AutoIndenter::IndentCommand
635
774
  separator
636
775
  item "Goto Line", GotoLineCommand
637
776
  item "Regex Search", SearchForwardCommand
@@ -647,15 +786,12 @@ module Redcar
647
786
  end
648
787
  sub_menu "Project" do
649
788
  item "Find File", Project::FindFileCommand
789
+ item "Refresh Directory", Project::RefreshDirectoryCommand
650
790
  end
651
791
  sub_menu "Debug" do
652
- item "Print Command History", PrintHistoryCommand
653
- item "Print Contents", PrintContents
654
- item "List Tabs", ListTabsCommand
655
- item "Refresh Directory", Project::RefreshDirectoryCommand
656
- item "Dialog Tester", DialogExample
792
+ item "Task Manager", TaskManager::OpenCommand
657
793
  separator
658
- item "Print Scope Tree", PrintScopeTreeCommand
794
+ #item "Print Scope Tree", PrintScopeTreeCommand
659
795
  item "Print Scope at Cursor", PrintScopeCommand
660
796
  end
661
797
  sub_menu "View" do
@@ -665,11 +801,13 @@ module Redcar
665
801
  separator
666
802
  item "Previous Tab", SwitchTabDownCommand
667
803
  item "Next Tab", SwitchTabUpCommand
804
+ separator
805
+ item "Show/Hide Invisibles", ToggleInvisibles
668
806
  end
669
807
  sub_menu "Plugins" do
670
808
  item "Plugin Manager", PluginManagerUi::OpenCommand
671
809
  item "Reload Again", PluginManagerUi::ReloadLastReloadedCommand
672
- item("Edit Preferences") { Project.open_dir(Redcar::Plugin::Storage.storage_dir, Redcar.app.new_window) }
810
+ item("Edit Preferences") { Project::Manager.open_project_for_path(Redcar::Plugin::Storage.storage_dir) }
673
811
  separator
674
812
  end
675
813
  sub_menu "Bundles" do
@@ -684,16 +822,48 @@ module Redcar
684
822
  end
685
823
  end
686
824
 
687
- def self.start
825
+ class ApplicationEventHandler
826
+ def tab_focus(tab)
827
+ tab.focus
828
+ end
829
+
830
+ def tab_close(tab)
831
+ CloseTabCommand.new(tab).run
832
+ end
833
+
834
+ def window_close(win)
835
+ CloseWindowCommand.new(win).run
836
+ end
837
+
838
+ def application_close(app)
839
+ QuitCommand.new.run
840
+ end
841
+
842
+ def window_focus(win)
843
+ FocusWindowCommand.new(win).run
844
+ end
845
+ end
846
+
847
+ def self.application_event_handler
848
+ ApplicationEventHandler.new
849
+ end
850
+
851
+ def self.start(args=[])
852
+ puts "loading plugins took #{Time.now - PROCESS_START_TIME}"
688
853
  Application.start
689
854
  ApplicationSWT.start
855
+ s = Time.now
690
856
  EditViewSWT.start
857
+ puts "EditViewSWT.start took #{Time.now - s}s"
858
+ s = Time.now
691
859
  Redcar.gui = ApplicationSWT.gui
692
860
  Redcar.app.controller = ApplicationSWT.new(Redcar.app)
693
-
694
861
  Redcar.app.refresh_menu!
695
862
  Redcar.app.load_sensitivities
696
- Redcar::Project.start
863
+ puts "initializing gui took #{Time.now - s}s"
864
+ s = Time.now
865
+ Redcar::Project::Manager.start(args)
866
+ puts "project start took #{Time.now - s}s"
697
867
  Redcar.app.make_sure_at_least_one_window_open
698
868
  end
699
869
  end