redcar 0.3.7.1 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/CHANGES +16 -0
  2. data/README.md +5 -0
  3. data/ROADMAP.md +7 -9
  4. data/Rakefile +55 -22
  5. data/lib/redcar.rb +12 -6
  6. data/lib/redcar/installer.rb +119 -44
  7. data/plugins/application/features/step_definitions/speedbar_steps.rb +62 -0
  8. data/plugins/application/features/step_definitions/tree_steps.rb +3 -3
  9. data/plugins/application/features/support/env.rb +2 -1
  10. data/plugins/application/lib/application/notebook.rb +53 -7
  11. data/plugins/application/lib/application/speedbar.rb +12 -0
  12. data/plugins/application/lib/application/tab.rb +16 -5
  13. data/plugins/application/lib/application/treebook.rb +21 -1
  14. data/plugins/application_swt/lib/application_swt.rb +12 -2
  15. data/plugins/application_swt/lib/application_swt/html_tab.rb +4 -0
  16. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -3
  17. data/plugins/application_swt/lib/application_swt/speedbar.rb +15 -27
  18. data/plugins/application_swt/lib/application_swt/swt_wrapper.rb +1 -0
  19. data/plugins/application_swt/lib/application_swt/tab.rb +1 -0
  20. data/plugins/application_swt/lib/application_swt/treebook.rb +36 -8
  21. data/plugins/application_swt/lib/application_swt/window.rb +24 -18
  22. data/plugins/auto_completer/lib/auto_completer.rb +5 -20
  23. data/plugins/core/lib/core.rb +7 -4
  24. data/plugins/core/lib/core/observable_struct.rb +2 -2
  25. data/plugins/declarations/lib/declarations.rb +3 -17
  26. data/plugins/document_search/features/search.feature +163 -0
  27. data/plugins/document_search/features/support/env.rb +4 -0
  28. data/plugins/document_search/lib/document_search.rb +121 -0
  29. data/plugins/document_search/plugin.rb +8 -0
  30. data/plugins/edit_view/features/line_delimiter.feature +7 -0
  31. data/plugins/edit_view/features/step_definitions/editing_steps.rb +49 -1
  32. data/plugins/edit_view/features/step_definitions/tab_steps.rb +10 -11
  33. data/plugins/edit_view/features/switch_tabs.feature +61 -10
  34. data/plugins/edit_view/lib/edit_view.rb +4 -0
  35. data/plugins/edit_view/lib/edit_view/document.rb +56 -0
  36. data/plugins/edit_view/lib/edit_view/document/command.rb +1 -1
  37. data/plugins/edit_view/lib/edit_view/edit_tab.rb +0 -8
  38. data/plugins/edit_view_swt/lib/edit_view_swt.rb +4 -0
  39. data/plugins/html_view/lib/html_controller.rb +19 -1
  40. data/plugins/html_view/lib/html_view.rb +28 -1
  41. data/plugins/html_view/lib/html_view/html_tab.rb +10 -1
  42. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +3 -1
  43. data/plugins/project/features/open_directory_tree.feature +3 -3
  44. data/plugins/project/lib/project.rb +4 -6
  45. data/plugins/project/lib/project/commands.rb +17 -0
  46. data/plugins/project/lib/project/dir_controller.rb +2 -1
  47. data/plugins/project/lib/project/dir_mirror.rb +8 -0
  48. data/plugins/project/lib/project/manager.rb +2 -0
  49. data/plugins/project/plugin.rb +2 -1
  50. data/plugins/project/vendor/net-sftp/Manifest +55 -0
  51. data/plugins/project/vendor/net-sftp/Rakefile +30 -0
  52. data/plugins/project/vendor/net-sftp/lib/net/sftp.rb +70 -0
  53. data/plugins/project/vendor/net-sftp/lib/net/sftp/constants.rb +187 -0
  54. data/plugins/project/vendor/net-sftp/lib/net/sftp/errors.rb +39 -0
  55. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/dir.rb +93 -0
  56. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/download.rb +364 -0
  57. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file.rb +176 -0
  58. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/file_factory.rb +60 -0
  59. data/plugins/project/vendor/net-sftp/lib/net/sftp/operations/upload.rb +387 -0
  60. data/plugins/project/vendor/net-sftp/lib/net/sftp/packet.rb +21 -0
  61. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol.rb +32 -0
  62. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/attributes.rb +315 -0
  63. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/base.rb +268 -0
  64. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/01/name.rb +43 -0
  65. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/02/base.rb +31 -0
  66. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/03/base.rb +35 -0
  67. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/attributes.rb +152 -0
  68. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/base.rb +94 -0
  69. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/04/name.rb +67 -0
  70. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/05/base.rb +66 -0
  71. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/attributes.rb +107 -0
  72. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/06/base.rb +63 -0
  73. data/plugins/project/vendor/net-sftp/lib/net/sftp/protocol/base.rb +50 -0
  74. data/plugins/project/vendor/net-sftp/lib/net/sftp/request.rb +91 -0
  75. data/plugins/project/vendor/net-sftp/lib/net/sftp/response.rb +76 -0
  76. data/plugins/project/vendor/net-sftp/lib/net/sftp/session.rb +951 -0
  77. data/plugins/project/vendor/net-sftp/lib/net/sftp/version.rb +18 -0
  78. data/plugins/project/vendor/net-sftp/setup.rb +1331 -0
  79. data/plugins/project/vendor/net-sftp/test/common.rb +171 -0
  80. data/plugins/project/vendor/net-sftp/test/protocol/01/test_attributes.rb +97 -0
  81. data/plugins/project/vendor/net-sftp/test/protocol/01/test_base.rb +210 -0
  82. data/plugins/project/vendor/net-sftp/test/protocol/01/test_name.rb +27 -0
  83. data/plugins/project/vendor/net-sftp/test/protocol/02/test_base.rb +26 -0
  84. data/plugins/project/vendor/net-sftp/test/protocol/03/test_base.rb +27 -0
  85. data/plugins/project/vendor/net-sftp/test/protocol/04/test_attributes.rb +148 -0
  86. data/plugins/project/vendor/net-sftp/test/protocol/04/test_base.rb +74 -0
  87. data/plugins/project/vendor/net-sftp/test/protocol/04/test_name.rb +53 -0
  88. data/plugins/project/vendor/net-sftp/test/protocol/05/test_base.rb +62 -0
  89. data/plugins/project/vendor/net-sftp/test/protocol/06/test_attributes.rb +124 -0
  90. data/plugins/project/vendor/net-sftp/test/protocol/06/test_base.rb +51 -0
  91. data/plugins/project/vendor/net-sftp/test/protocol/test_base.rb +42 -0
  92. data/plugins/project/vendor/net-sftp/test/test_all.rb +7 -0
  93. data/plugins/project/vendor/net-sftp/test/test_dir.rb +47 -0
  94. data/plugins/project/vendor/net-sftp/test/test_download.rb +252 -0
  95. data/plugins/project/vendor/net-sftp/test/test_file.rb +159 -0
  96. data/plugins/project/vendor/net-sftp/test/test_file_factory.rb +48 -0
  97. data/plugins/project/vendor/net-sftp/test/test_packet.rb +9 -0
  98. data/plugins/project/vendor/net-sftp/test/test_protocol.rb +17 -0
  99. data/plugins/project/vendor/net-sftp/test/test_request.rb +71 -0
  100. data/plugins/project/vendor/net-sftp/test/test_response.rb +53 -0
  101. data/plugins/project/vendor/net-sftp/test/test_session.rb +741 -0
  102. data/plugins/project/vendor/net-sftp/test/test_upload.rb +219 -0
  103. data/plugins/project/vendor/net-ssh/Manifest +110 -0
  104. data/plugins/project/vendor/net-ssh/Rakefile +85 -0
  105. data/plugins/project/vendor/net-ssh/Rudyfile +96 -0
  106. data/plugins/project/vendor/net-ssh/lib/net/ssh.rb +215 -0
  107. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/agent.rb +179 -0
  108. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/constants.rb +18 -0
  109. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/key_manager.rb +193 -0
  110. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/abstract.rb +60 -0
  111. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/hostbased.rb +71 -0
  112. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/keyboard_interactive.rb +66 -0
  113. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/password.rb +39 -0
  114. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/methods/publickey.rb +92 -0
  115. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/pageant.rb +183 -0
  116. data/plugins/project/vendor/net-ssh/lib/net/ssh/authentication/session.rb +134 -0
  117. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffer.rb +340 -0
  118. data/plugins/project/vendor/net-ssh/lib/net/ssh/buffered_io.rb +198 -0
  119. data/plugins/project/vendor/net-ssh/lib/net/ssh/config.rb +202 -0
  120. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/channel.rb +630 -0
  121. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/constants.rb +33 -0
  122. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/session.rb +597 -0
  123. data/plugins/project/vendor/net-ssh/lib/net/ssh/connection/term.rb +178 -0
  124. data/plugins/project/vendor/net-ssh/lib/net/ssh/errors.rb +85 -0
  125. data/plugins/project/vendor/net-ssh/lib/net/ssh/key_factory.rb +102 -0
  126. data/plugins/project/vendor/net-ssh/lib/net/ssh/known_hosts.rb +129 -0
  127. data/plugins/project/vendor/net-ssh/lib/net/ssh/loggable.rb +61 -0
  128. data/plugins/project/vendor/net-ssh/lib/net/ssh/packet.rb +102 -0
  129. data/plugins/project/vendor/net-ssh/lib/net/ssh/prompt.rb +93 -0
  130. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/command.rb +75 -0
  131. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/errors.rb +14 -0
  132. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/http.rb +94 -0
  133. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks4.rb +70 -0
  134. data/plugins/project/vendor/net-ssh/lib/net/ssh/proxy/socks5.rb +142 -0
  135. data/plugins/project/vendor/net-ssh/lib/net/ssh/ruby_compat.rb +43 -0
  136. data/plugins/project/vendor/net-ssh/lib/net/ssh/service/forward.rb +288 -0
  137. data/plugins/project/vendor/net-ssh/lib/net/ssh/test.rb +89 -0
  138. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/channel.rb +129 -0
  139. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/extensions.rb +152 -0
  140. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/kex.rb +44 -0
  141. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/local_packet.rb +51 -0
  142. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/packet.rb +81 -0
  143. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/remote_packet.rb +38 -0
  144. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/script.rb +157 -0
  145. data/plugins/project/vendor/net-ssh/lib/net/ssh/test/socket.rb +64 -0
  146. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/algorithms.rb +384 -0
  147. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/cipher_factory.rb +97 -0
  148. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/constants.rb +30 -0
  149. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac.rb +31 -0
  150. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/abstract.rb +79 -0
  151. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5.rb +12 -0
  152. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/md5_96.rb +11 -0
  153. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/none.rb +15 -0
  154. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1.rb +13 -0
  155. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/hmac/sha1_96.rb +11 -0
  156. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/identity_cipher.rb +55 -0
  157. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex.rb +13 -0
  158. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +208 -0
  159. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +77 -0
  160. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/openssl.rb +128 -0
  161. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/packet_stream.rb +235 -0
  162. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/server_version.rb +71 -0
  163. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/session.rb +276 -0
  164. data/plugins/project/vendor/net-ssh/lib/net/ssh/transport/state.rb +206 -0
  165. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/lenient.rb +30 -0
  166. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/null.rb +12 -0
  167. data/plugins/project/vendor/net-ssh/lib/net/ssh/verifiers/strict.rb +53 -0
  168. data/plugins/project/vendor/net-ssh/lib/net/ssh/version.rb +62 -0
  169. data/plugins/project/vendor/net-ssh/net-ssh.gemspec +138 -0
  170. data/plugins/project/vendor/net-ssh/setup.rb +1585 -0
  171. data/plugins/project/vendor/net-ssh/support/arcfour_check.rb +20 -0
  172. data/plugins/project/vendor/net-ssh/support/ssh_tunnel_bug.rb +65 -0
  173. data/plugins/project/vendor/net-ssh/test/README.txt +42 -0
  174. data/plugins/project/vendor/net-ssh/test/authentication/methods/common.rb +28 -0
  175. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_abstract.rb +51 -0
  176. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_hostbased.rb +114 -0
  177. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_keyboard_interactive.rb +98 -0
  178. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_password.rb +50 -0
  179. data/plugins/project/vendor/net-ssh/test/authentication/methods/test_publickey.rb +127 -0
  180. data/plugins/project/vendor/net-ssh/test/authentication/test_agent.rb +205 -0
  181. data/plugins/project/vendor/net-ssh/test/authentication/test_key_manager.rb +105 -0
  182. data/plugins/project/vendor/net-ssh/test/authentication/test_session.rb +93 -0
  183. data/plugins/project/vendor/net-ssh/test/common.rb +107 -0
  184. data/plugins/project/vendor/net-ssh/test/configs/eqsign +3 -0
  185. data/plugins/project/vendor/net-ssh/test/configs/exact_match +8 -0
  186. data/plugins/project/vendor/net-ssh/test/configs/host_plus +10 -0
  187. data/plugins/project/vendor/net-ssh/test/configs/multihost +4 -0
  188. data/plugins/project/vendor/net-ssh/test/configs/nohost +19 -0
  189. data/plugins/project/vendor/net-ssh/test/configs/numeric_host +4 -0
  190. data/plugins/project/vendor/net-ssh/test/configs/wild_cards +14 -0
  191. data/plugins/project/vendor/net-ssh/test/connection/test_channel.rb +467 -0
  192. data/plugins/project/vendor/net-ssh/test/connection/test_session.rb +488 -0
  193. data/plugins/project/vendor/net-ssh/test/manual/test_forward.rb +185 -0
  194. data/plugins/project/vendor/net-ssh/test/test_all.rb +9 -0
  195. data/plugins/project/vendor/net-ssh/test/test_buffer.rb +336 -0
  196. data/plugins/project/vendor/net-ssh/test/test_buffered_io.rb +63 -0
  197. data/plugins/project/vendor/net-ssh/test/test_config.rb +117 -0
  198. data/plugins/project/vendor/net-ssh/test/test_key_factory.rb +67 -0
  199. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5.rb +39 -0
  200. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_md5_96.rb +25 -0
  201. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_none.rb +34 -0
  202. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1.rb +34 -0
  203. data/plugins/project/vendor/net-ssh/test/transport/hmac/test_sha1_96.rb +25 -0
  204. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group1_sha1.rb +146 -0
  205. data/plugins/project/vendor/net-ssh/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +92 -0
  206. data/plugins/project/vendor/net-ssh/test/transport/test_algorithms.rb +302 -0
  207. data/plugins/project/vendor/net-ssh/test/transport/test_cipher_factory.rb +213 -0
  208. data/plugins/project/vendor/net-ssh/test/transport/test_hmac.rb +34 -0
  209. data/plugins/project/vendor/net-ssh/test/transport/test_identity_cipher.rb +40 -0
  210. data/plugins/project/vendor/net-ssh/test/transport/test_packet_stream.rb +441 -0
  211. data/plugins/project/vendor/net-ssh/test/transport/test_server_version.rb +78 -0
  212. data/plugins/project/vendor/net-ssh/test/transport/test_session.rb +315 -0
  213. data/plugins/project/vendor/net-ssh/test/transport/test_state.rb +173 -0
  214. data/plugins/redcar/plugin.rb +3 -1
  215. data/plugins/redcar/redcar.rb +108 -121
  216. data/plugins/redcar_debug/lib/redcar_debug.rb +2 -0
  217. data/plugins/runnables/lib/runnables.rb +80 -23
  218. data/plugins/runnables/lib/runnables/command_output_controller.rb +102 -0
  219. data/plugins/runnables/lib/runnables/running_process_checker.rb +34 -0
  220. data/plugins/runnables/{plugin_no_load.rb → plugin.rb} +2 -1
  221. data/plugins/runnables/vendor/session-2.4.0/HISTORY +73 -0
  222. data/plugins/runnables/vendor/session-2.4.0/README +89 -0
  223. data/plugins/runnables/vendor/session-2.4.0/TODO +3 -0
  224. data/plugins/runnables/vendor/session-2.4.0/VERSION +1 -0
  225. data/plugins/runnables/vendor/session-2.4.0/gemspec.rb +22 -0
  226. data/plugins/runnables/vendor/session-2.4.0/install.rb +143 -0
  227. data/plugins/runnables/vendor/session-2.4.0/lib/session.rb +757 -0
  228. data/plugins/runnables/vendor/session-2.4.0/sample/bash.rb +60 -0
  229. data/plugins/runnables/vendor/session-2.4.0/sample/driver.rb +47 -0
  230. data/plugins/runnables/vendor/session-2.4.0/sample/session_idl.rb +25 -0
  231. data/plugins/runnables/vendor/session-2.4.0/sample/session_sh.rb +29 -0
  232. data/plugins/runnables/vendor/session-2.4.0/sample/sh0.rb +23 -0
  233. data/plugins/runnables/vendor/session-2.4.0/sample/stdin.rb +17 -0
  234. data/plugins/runnables/vendor/session-2.4.0/sample/threadtest.rb +42 -0
  235. data/plugins/runnables/vendor/session-2.4.0/session-2.4.0.gem +0 -0
  236. data/plugins/runnables/vendor/session-2.4.0/test/session.rb +227 -0
  237. data/plugins/runnables/views/command_output.html.erb +32 -0
  238. data/plugins/task_manager/lib/task_manager.rb +2 -0
  239. data/plugins/textmate/lib/textmate/plist.rb +1 -1
  240. data/plugins/textmate/lib/textmate/snippet.rb +1 -0
  241. data/plugins/tree/lib/tree/mirror.rb +8 -1
  242. data/plugins/tree_view_swt/lib/tree_view_swt.rb +29 -2
  243. metadata +191 -6
  244. data/plugins/declarations/TODO +0 -3
  245. data/plugins/redcar/spec/redcar/redcar_spec.rb +0 -70
  246. data/plugins/redcar/spec/spec_helper.rb +0 -4
@@ -0,0 +1,8 @@
1
+
2
+ Plugin.define do
3
+ name "document_search"
4
+ version "1.0"
5
+ file "lib", "document_search"
6
+ object "DocumentSearch"
7
+ dependencies "edit_view", ">0"
8
+ end
@@ -37,4 +37,11 @@ Feature: Line delimiter
37
37
  And I move the cursor to 4
38
38
  And I press the Backspace key in the edit tab
39
39
  Then the contents should be "foobar\nbaz\n"
40
+
41
+ Scenario: End goes to end of line (Windows)
42
+ When I open a new edit tab
43
+ And I replace the contents with "foo\r\nbar\r\nbaz\r\n"
44
+ And I move the cursor to 0
45
+ And I run the command Redcar::Top::MoveEndCommand
46
+ Then the cursor should be at 3
40
47
 
@@ -132,7 +132,25 @@ Then /^the selection range should be from (\d+) to (\d+)$/ do |from_str, to_str|
132
132
  r.begin.should == from_str.to_i
133
133
  r.end.should == to_str.to_i
134
134
  end
135
+
136
+ Then /^the selection should be on line (.*)$/ do |line_num|
137
+ line_num = line_num.to_i
138
+ doc = Redcar::EditView.focussed_edit_view_document
139
+ r = doc.selection_range
140
+ doc.line_at_offset(r.begin).should == line_num
141
+ doc.line_at_offset(r.end).should == line_num
142
+ end
135
143
 
144
+ Then /^there should not be any text selected$/ do
145
+ doc = Redcar::EditView.focussed_edit_view_document
146
+ doc.selected_text.should == ""
147
+ end
148
+
149
+ Then /^the selected text should be "([^"]*)"$/ do |selected_text|
150
+ doc = Redcar::EditView.focussed_edit_view_document
151
+ doc.selected_text.should == selected_text
152
+ end
153
+
136
154
  Then /the line delimiter should be "(.*)"/ do |delim|
137
155
  doc = Redcar::EditView.focussed_edit_view_document
138
156
  doc.delim.should == unescape_text(delim)
@@ -148,4 +166,34 @@ Then /^the cursor should be on line (\d+)$/ do |num|
148
166
  doc.cursor_line.should == num.to_i
149
167
  end
150
168
 
151
-
169
+ When /^I replace the contents with "([^\"]*)"$/ do |contents|
170
+ contents = unescape_text(contents)
171
+ doc = Redcar::EditView.focussed_edit_view_document
172
+ cursor_offset = (contents =~ /<c>/)
173
+ contents = contents.gsub("<c>", "")
174
+ doc.text = contents
175
+ doc.cursor_offset = cursor_offset
176
+ end
177
+
178
+ When /^I replace the contents with 100 lines of "([^"]*)" then "([^"]*)"$/ do |contents1, contents2|
179
+ contents1 = unescape_text(contents1)
180
+ contents2 = unescape_text(contents2)
181
+ doc = Redcar::EditView.focussed_edit_view_document
182
+ doc.text = (contents1 + "\n")*100 + contents2
183
+ end
184
+
185
+ When /^I scroll to the top of the document$/ do
186
+ doc = Redcar::EditView.focussed_edit_view_document
187
+ doc.scroll_to_line(0)
188
+ end
189
+
190
+ Then /^line number (\d+) should be visible$/ do |line_num|
191
+ line_num = line_num.to_i
192
+ doc = Redcar::EditView.focussed_edit_view_document
193
+ (doc.biggest_visible_line >= line_num).should be_true
194
+ (doc.smallest_visible_line <= line_num).should be_true
195
+ end
196
+
197
+
198
+
199
+
@@ -18,22 +18,21 @@ When /^I close the focussed tab$/ do
18
18
  Redcar::Top::CloseTabCommand.new.run
19
19
  end
20
20
 
21
- When /^I replace the contents with "([^\"]*)"$/ do |contents|
22
- contents = unescape_text(contents)
23
- win = Redcar.app.windows.first
24
- tab = win.focussed_notebook.focussed_tab
25
- cursor_offset = (contents =~ /<c>/)
26
- contents = contents.gsub("<c>", "")
27
- tab.edit_view.document.text = contents
28
- tab.edit_view.document.cursor_offset = cursor_offset
21
+ When /I switch (up|down) a tab/ do |type|
22
+ case type
23
+ when "down"
24
+ Redcar::Top::SwitchTabDownCommand.new.run
25
+ when "up"
26
+ Redcar::Top::SwitchTabUpCommand.new.run
27
+ end
29
28
  end
30
29
 
31
30
  When /I move (up|down) a tab/ do |type|
32
31
  case type
33
32
  when "down"
34
- Redcar::Top::SwitchTabDownCommand.new.run
33
+ Redcar::Top::MoveTabDownCommand.new.run
35
34
  when "up"
36
- Redcar::Top::SwitchTabUpCommand.new.run
35
+ Redcar::Top::MoveTabUpCommand.new.run
37
36
  end
38
37
  end
39
38
 
@@ -45,7 +44,7 @@ Then /^there should be (one|\d+) (.*) tabs?$/ do |num, tab_type|
45
44
  end
46
45
 
47
46
  # in the model
48
- tabs = Redcar.app.windows.first.notebooks.map {|nb| nb.tabs }.flatten
47
+ tabs = Redcar.app.focussed_window.notebooks.map {|nb| nb.tabs }.flatten
49
48
  tabs.length.should == num
50
49
 
51
50
  # in the GUI
@@ -6,18 +6,18 @@ Feature: Switch and move tabs within a notebook
6
6
  And I open a new edit tab
7
7
  And I replace the contents with "Elizabeth Woodville"
8
8
  Then I should see "Elizabeth Woodville" in the edit tab
9
- And I move down a tab
9
+ And I switch down a tab
10
10
  Then I should see "Anne Boleyn" in the edit tab
11
11
 
12
- Scenario: Switch tab down too far
12
+ Scenario: Switching tabs down will wrap
13
13
  When I open a new edit tab
14
14
  And I replace the contents with "Anne Boleyn"
15
15
  And I open a new edit tab
16
16
  And I replace the contents with "Elizabeth Woodville"
17
17
  Then I should see "Elizabeth Woodville" in the edit tab
18
- And I move down a tab
19
- And I move down a tab
20
- Then I should see "Anne Boleyn" in the edit tab
18
+ And I switch down a tab
19
+ And I switch down a tab
20
+ Then I should see "Elizabeth Woodville" in the edit tab
21
21
 
22
22
  Scenario: Switch tab up
23
23
  When I open a new edit tab
@@ -25,18 +25,18 @@ Feature: Switch and move tabs within a notebook
25
25
  And I open a new edit tab
26
26
  And I replace the contents with "Elizabeth Woodville"
27
27
  Then I should see "Elizabeth Woodville" in the edit tab
28
- And I move down a tab
29
- And I move up a tab
28
+ And I switch down a tab
29
+ And I switch up a tab
30
30
  Then I should see "Elizabeth Woodville" in the edit tab
31
31
 
32
- Scenario: Switch tab up too far
32
+ Scenario: Switching tabs up will wrap
33
33
  When I open a new edit tab
34
34
  And I replace the contents with "Anne Boleyn"
35
35
  And I open a new edit tab
36
36
  And I replace the contents with "Elizabeth Woodville"
37
37
  Then I should see "Elizabeth Woodville" in the edit tab
38
- And I move up a tab
39
- Then I should see "Elizabeth Woodville" in the edit tab
38
+ And I switch up a tab
39
+ Then I should see "Anne Boleyn" in the edit tab
40
40
 
41
41
  Scenario: Switch notebooks
42
42
  When I open a new edit tab
@@ -48,8 +48,59 @@ Feature: Switch and move tabs within a notebook
48
48
  When I switch notebooks
49
49
  Then I should see "Anne Boleyn" in the edit tab
50
50
 
51
+ Scenario: Move tab up
52
+ When I open a new edit tab
53
+ And I replace the contents with "Anne Boleyn"
54
+ And I open a new edit tab
55
+ And I replace the contents with "Elizabeth Woodville"
56
+ Then I should see "Elizabeth Woodville" in the edit tab
57
+ And I switch down a tab
58
+ Then I should see "Anne Boleyn" in the edit tab
59
+ And I move up a tab
60
+ Then I should see "Anne Boleyn" in the edit tab
61
+ And I switch down a tab
62
+ Then I should see "Elizabeth Woodville" in the edit tab
63
+
51
64
 
65
+ Scenario: Moving tabs up will wrap
66
+ When I open a new edit tab
67
+ And I replace the contents with "Anne Boleyn"
68
+ And I open a new edit tab
69
+ And I replace the contents with "Elizabeth Woodville"
70
+ And I open a new edit tab
71
+ And I replace the contents with "Catherine of Aragon"
72
+ Then I should see "Catherine of Aragon" in the edit tab
73
+ And I move up a tab
74
+ And I move up a tab
75
+ And I move up a tab
76
+ And I move up a tab
77
+ And I switch up a tab
78
+ Then I should see "Anne Boleyn" in the edit tab
52
79
 
80
+ Scenario: Move tab down
81
+ When I open a new edit tab
82
+ And I replace the contents with "Anne Boleyn"
83
+ And I open a new edit tab
84
+ And I replace the contents with "Elizabeth Woodville"
85
+ Then I should see "Elizabeth Woodville" in the edit tab
86
+ And I move down a tab
87
+ Then I should see "Elizabeth Woodville" in the edit tab
88
+ And I switch up a tab
89
+ Then I should see "Anne Boleyn" in the edit tab
53
90
 
91
+ Scenario: Moving tabs down will wrap
92
+ When I open a new edit tab
93
+ And I replace the contents with "Anne Boleyn"
94
+ And I open a new edit tab
95
+ And I replace the contents with "Elizabeth Woodville"
96
+ And I open a new edit tab
97
+ And I replace the contents with "Catherine of Aragon"
98
+ Then I should see "Catherine of Aragon" in the edit tab
99
+ And I move down a tab
100
+ And I move down a tab
101
+ And I move down a tab
102
+ And I move down a tab
103
+ And I switch down a tab
104
+ Then I should see "Anne Boleyn" in the edit tab
54
105
 
55
106
 
@@ -301,6 +301,10 @@ module Redcar
301
301
  def focus
302
302
  notify_listeners(:focussed)
303
303
  end
304
+
305
+ def exists?
306
+ controller.exists?
307
+ end
304
308
 
305
309
  def tab_width
306
310
  @tab_width
@@ -8,6 +8,8 @@ module Redcar
8
8
  include Redcar::Observable
9
9
  extend Forwardable
10
10
 
11
+ WORDCHARS = /\w|_/
12
+
11
13
  def self.all_document_controller_types
12
14
  result = []
13
15
  Redcar.plugin_manager.objects_implementing(:document_controller_types).each do |object|
@@ -71,6 +73,10 @@ module Redcar
71
73
  end
72
74
  end
73
75
 
76
+ def exists?
77
+ edit_view.exists?
78
+ end
79
+
74
80
  def mirror=(new_mirror)
75
81
  notify_listeners(:new_mirror, new_mirror) do
76
82
  @mirror = new_mirror
@@ -278,6 +284,54 @@ module Redcar
278
284
  end
279
285
  end
280
286
 
287
+ # The word at an offset.
288
+ #
289
+ # @param [Integer] an offset
290
+ # @return [String] the text of the word
291
+ def word_at_offset(offset)
292
+ range = word_range_at_offset(offset)
293
+ get_range(range.first, range.last - range.first)
294
+ end
295
+
296
+ # The word found at the current cursor offset.
297
+ #
298
+ # @return [String] the text of the word
299
+ def current_word
300
+ word_at_offset(cursor_offset)
301
+ end
302
+
303
+ # The range of the word at an offset.
304
+ #
305
+ # @param [Integer] an offset
306
+ # @return [Range<Integer>] a range between two character offsets
307
+ def word_range_at_offset(offset)
308
+ line_index = line_at_offset(offset)
309
+ line_start_offset = offset_at_line(line_index)
310
+ line_chars = get_line(line_index)
311
+ left_range = 0
312
+ right_range = 0
313
+ left = offset - line_start_offset - 1
314
+ right = offset - line_start_offset
315
+
316
+ until left == -1 || (line_chars[left].chr !~ WORDCHARS)
317
+ left -= 1
318
+ left_range -= 1
319
+ end
320
+
321
+ until right == length || (line_chars[right].chr !~ WORDCHARS)
322
+ right += 1
323
+ right_range += 1
324
+ end
325
+ (offset + left_range..offset + right_range)
326
+ end
327
+
328
+ # The range of the word at the current cursor position.
329
+ #
330
+ # @return [Range<Integer>] a range between two character offsets
331
+ def current_word_range
332
+ word_range_at_offset(cursor_offset)
333
+ end
334
+
281
335
  # The range of text selected by the user.
282
336
  #
283
337
  # @return [Range<Integer>] a range between two character offsets
@@ -321,10 +375,12 @@ module Redcar
321
375
  get_range(selection_range.begin, selection_range.count)
322
376
  end
323
377
 
378
+ # Is the document in block selection mode.
324
379
  def block_selection_mode?
325
380
  controller.block_selection_mode?
326
381
  end
327
382
 
383
+ # Turn the block selection mode on or off.
328
384
  def block_selection_mode=(boolean)
329
385
  controller.block_selection_mode = !!boolean
330
386
  end
@@ -5,7 +5,7 @@ module Redcar
5
5
  private
6
6
 
7
7
  def doc
8
- EditView.current.document
8
+ EditView.focussed_edit_view.document
9
9
  end
10
10
  end
11
11
  end
@@ -19,13 +19,5 @@ module Redcar
19
19
  def edit_view_focussed
20
20
  notify_listeners(:focus)
21
21
  end
22
-
23
- def serialize
24
- { :title => title }
25
- end
26
-
27
- def deserialize(data)
28
- self.title = data[:title]
29
- end
30
22
  end
31
23
  end
@@ -219,6 +219,10 @@ module Redcar
219
219
  focus_control = ApplicationSWT.display.get_focus_control
220
220
  focus_control == @mate_text.get_control
221
221
  end
222
+
223
+ def exists?
224
+ @mate_text.get_control and !@mate_text.get_control.disposed
225
+ end
222
226
 
223
227
  def attach_listeners
224
228
  # h = @document.add_listener(:set_text, &method(:reparse))
@@ -1,5 +1,23 @@
1
1
 
2
2
  module Redcar
3
- class HtmlController
3
+ module HtmlController
4
+ include Redcar::Observable
5
+
6
+ # Override this to return a message if the user should be prompted
7
+ # before closing the tab.
8
+ def ask_before_closing
9
+ nil
10
+ end
11
+
12
+ # Override this to run code right before the tab is closed.
13
+ def close
14
+ nil
15
+ end
16
+
17
+ # Call execute with a string of javascript to execute the script
18
+ # in the context of the browser widget.
19
+ def execute(script)
20
+ notify_listeners(:execute_script, script)
21
+ end
4
22
  end
5
23
  end
@@ -1,5 +1,6 @@
1
1
 
2
2
  require 'html_view/html_tab'
3
+ require 'html_controller'
3
4
 
4
5
  module Redcar
5
6
  class HtmlView
@@ -24,6 +25,28 @@ module Redcar
24
25
  func = RubyFunc.new(@html_tab.controller.browser, "rubyCall")
25
26
  func.controller = @controller
26
27
  controller_action("index")
28
+ attach_controller_listeners
29
+ end
30
+
31
+ def attach_controller_listeners
32
+ @controller.add_listener(:execute_script) do |script|
33
+ begin
34
+ Redcar.update_gui do
35
+ begin
36
+ browser = @html_tab.controller.browser
37
+ unless browser.is_disposed
38
+ browser.execute(script)
39
+ end
40
+ rescue => e
41
+ puts e.message
42
+ puts e.backtrace
43
+ end
44
+ end
45
+ rescue => e
46
+ puts e.message
47
+ puts e.backtrace
48
+ end
49
+ end
27
50
  end
28
51
 
29
52
  def controller_action(action_name, params=nil)
@@ -58,7 +81,11 @@ module Redcar
58
81
  def function(args)
59
82
  func_name = args.to_a.first
60
83
  func_args = args.to_a.last.to_a
61
- JSON(controller.send(func_name.to_sym, *func_args))
84
+ begin
85
+ JSON(controller.send(func_name.to_sym, *func_args))
86
+ rescue JSON::GeneratorError => e
87
+ nil
88
+ end
62
89
  end
63
90
 
64
91
  attr_accessor :controller
@@ -9,6 +9,11 @@ module Redcar
9
9
  create_html_view
10
10
  end
11
11
 
12
+ def close
13
+ html_view.controller.close if html_view.controller
14
+ super
15
+ end
16
+
12
17
  def create_html_view
13
18
  @html_view = HtmlView.new(self)
14
19
  end
@@ -16,5 +21,9 @@ module Redcar
16
21
  def controller_action(action, params)
17
22
  notify_listeners(:controller_action, action, params)
18
23
  end
24
+
25
+ def go_to_location(url)
26
+ controller.go_to_location(url)
27
+ end
19
28
  end
20
- end
29
+ end