redcar 0.3.4.3 → 0.3.5

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 (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
@@ -0,0 +1,94 @@
1
+
2
+ module Redcar
3
+ JAVA_YAML=<<-YAML
4
+ - regex: "class\\s+(\\w+)"
5
+ capture: 1
6
+ type: id
7
+ - regex: "interface\\s+(\\w+)"
8
+ capture: 1
9
+ type: id
10
+ - regex: "(public|private).*\\s+(\\w+)\s*\\("
11
+ capture: 2
12
+ type: id
13
+ YAML
14
+
15
+ RUBY_YAML=<<-YAML
16
+ - regex: "^[^#]*(class|module)\\s+(?:\\w*::)*(\\w+)(?:$|\\s|<)"
17
+ capture: 2
18
+ type: id
19
+ - regex: "^[^#]*def (self\\.)?(\\w+)"
20
+ capture: 2
21
+ type: id
22
+ - regex: "^[^#]*attr(_reader|_accessor|_writer)(.*)$"
23
+ capture: 2
24
+ type: id-list
25
+ - regex: "^[^#]*alias\s+:(\\w+)"
26
+ capture: 1
27
+ type: id
28
+ - regex: "^[^#]*alias_method\s+:(\\w+)"
29
+ capture: 1
30
+ type: id
31
+ - regex: "^\\s*([A-Z]\\w*)\\s*="
32
+ capture: 1
33
+ type: id
34
+ YAML
35
+
36
+ class Declarations
37
+ class Parser
38
+ DEFINITIONS = {
39
+ /\.rb$/ => YAML.load(RUBY_YAML),
40
+ /\.java$/ => YAML.load(JAVA_YAML)
41
+ }
42
+
43
+ attr_reader :tags
44
+
45
+ def initialize
46
+ @tags = []
47
+ end
48
+
49
+ def parse(files)
50
+ files.each do |path|
51
+ @tags += match_in_file(path)
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def decls_for_file(path)
58
+ DEFINITIONS.each do |fn_re, decls|
59
+ if path =~ fn_re
60
+ return decls
61
+ end
62
+ end
63
+ nil
64
+ end
65
+
66
+ def match_in_file(path)
67
+ tags = []
68
+ begin
69
+ file = ::File.read(path)
70
+ if decls = decls_for_file(path)
71
+ decls.each do |decl|
72
+ file.each_line do |line|
73
+ if md = line.match(Regexp.new(decl["regex"]))
74
+ capture = md[decl["capture"]]
75
+ case decl["type"]
76
+ when "id"
77
+ tags << [capture, path, md[0]]
78
+ when "id-list"
79
+ tags += capture.scan(/\w+/).map {|id| [id, path, md[0]] }
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ tags
86
+ rescue
87
+ []
88
+ end
89
+ end
90
+
91
+ end
92
+ end
93
+ end
94
+
@@ -0,0 +1,44 @@
1
+ module Redcar
2
+ class Declarations
3
+ class SelectTagDialog < FilterListDialog
4
+
5
+ def initialize(matches)
6
+ super()
7
+ @matches = matches
8
+ end
9
+
10
+ def close
11
+ super
12
+ end
13
+
14
+ def update_list(filter)
15
+ @last_list = @matches
16
+ filtered_list = @last_list
17
+ if filter.length >= 1
18
+ filtered_list = filter_and_rank_by(filtered_list, filter, filtered_list.length) do |match|
19
+ match[:file].split(::File::SEPARATOR).last
20
+ end
21
+ end
22
+ align_matches_for_display(filtered_list)
23
+ end
24
+
25
+ def selected(text, ix, closing=false)
26
+ if @last_list
27
+ close
28
+ Redcar::Declarations.go_to_definition(@last_list[ix])
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def align_matches_for_display(filtered_list)
35
+ filtered_list.collect do |match|
36
+ file_path = match[:file]
37
+ file = file_path.split(::File::SEPARATOR).last
38
+ relative_path = file_path.gsub(Regexp.compile(Project::Manager.focussed_project.path + '/'), '')
39
+ "%s (%s)" % [file, relative_path]
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,7 @@
1
+ Plugin.define do
2
+ name "declarations"
3
+ version "0.1.0"
4
+ file "lib", "declarations"
5
+ object "Redcar::Declarations"
6
+ dependencies "project", ">0"
7
+ end
@@ -0,0 +1,62 @@
1
+
2
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
3
+
4
+ module Redcar
5
+ describe Declarations::File do
6
+ before do
7
+ @tags_file = File.join(File.dirname(__FILE__), "..", "tags")
8
+ end
9
+
10
+ after do
11
+ FileUtils.rm_f(@tags_file)
12
+ end
13
+
14
+ describe "dump and load from file" do
15
+ describe "with no existing tags file" do
16
+ before do
17
+ @file = Declarations::File.new(@tags_file)
18
+ end
19
+
20
+ it "should have no tags" do
21
+ @file.tags.should be_empty
22
+ end
23
+
24
+ it "should add new tags" do
25
+ @file.add_tags([%w"Abc /foo class:Abc"])
26
+ @file.tags.length.should == 1
27
+ end
28
+
29
+ describe "with tags added" do
30
+ before do
31
+ @file.add_tags([%w"Abc /foo class:Abc"])
32
+ end
33
+
34
+ it "should dump a tags file" do
35
+ @file.dump
36
+ File.exist?(@tags_file).should be_true
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "with existing tags file" do
42
+ before do
43
+ file = Declarations::File.new(@tags_file)
44
+ file.add_tags([%w"Abc /foo class:Abc"])
45
+ file.last_updated = Time.now
46
+ @last_updated = Time.now
47
+ file.dump
48
+ @file = Declarations::File.new(@tags_file)
49
+ end
50
+
51
+ it "should load up the tags" do
52
+ @file.tags.should == [%w"Abc /foo class:Abc"]
53
+ end
54
+
55
+ it "should know the timestamp of when it was last updated" do
56
+ @file.last_updated.to_s.should == @last_updated.to_s
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,15 @@
1
+
2
+ class James
3
+ def madison
4
+ end
5
+
6
+ def self.alexander
7
+ end
8
+
9
+ module Hamilton
10
+ end
11
+ end
12
+
13
+ module James::Hamilton
14
+ attr_accessor :john, :jay
15
+ end
@@ -0,0 +1,4 @@
1
+ $:.push File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')
2
+
3
+ require 'redcar'
4
+ Redcar.load
@@ -0,0 +1,40 @@
1
+ Feature: Indentation commands
2
+
3
+ Scenario: Increase indent, soft tabs, width 2
4
+ When I open a new edit tab
5
+ And tabs are soft, 2 spaces
6
+ And I run the command Redcar::Top::IncreaseIndentCommand
7
+ Then the contents should be " "
8
+
9
+ Scenario: Decrease indent, soft tabs, width 2
10
+ When I open a new edit tab
11
+ And tabs are soft, 2 spaces
12
+ And I replace the contents with "<c> "
13
+ And I run the command Redcar::Top::DecreaseIndentCommand
14
+ Then the contents should be " "
15
+
16
+ Scenario: Increase indent, soft tabs, width 3
17
+ When I open a new edit tab
18
+ And tabs are soft, 3 spaces
19
+ And I run the command Redcar::Top::IncreaseIndentCommand
20
+ Then the contents should be " "
21
+
22
+ Scenario: Decrease indent, soft tabs, width 3
23
+ When I open a new edit tab
24
+ And tabs are soft, 3 spaces
25
+ And I replace the contents with "<c> "
26
+ And I run the command Redcar::Top::DecreaseIndentCommand
27
+ Then the contents should be " "
28
+
29
+ Scenario: Increase indent, hard tabs, width 2
30
+ When I open a new edit tab
31
+ And tabs are hard
32
+ And I run the command Redcar::Top::IncreaseIndentCommand
33
+ Then the contents should be "\t"
34
+
35
+ Scenario: Decrease indent, hard tabs, width 2
36
+ When I open a new edit tab
37
+ And tabs are hard
38
+ And I replace the contents with "<c>\t\t"
39
+ And I run the command Redcar::Top::DecreaseIndentCommand
40
+ Then the contents should be "\t"
@@ -0,0 +1,40 @@
1
+ Feature: Line delimiter
2
+
3
+ Scenario: Chooses line delimiter by text put in the tab (Windows)
4
+ When I open a new edit tab
5
+ And I replace the contents with "foo\r\nbar\r\nbaz\r\n"
6
+ Then the line delimiter should be "\r\n"
7
+
8
+ Scenario: Delete at end of line deletes delimiter (Windows)
9
+ When I open a new edit tab
10
+ And I replace the contents with "foo\r\nbar\r\nbaz\r\n"
11
+ And I move the cursor to 3
12
+ And I press the Delete key in the edit tab
13
+ Then the contents should be "foobar\r\nbaz\r\n"
14
+
15
+ Scenario: Backspace at start of line deletes delimiter (Windows)
16
+ When I open a new edit tab
17
+ And I replace the contents with "foo\r\nbar\r\nbaz\r\n"
18
+ And I move the cursor to 5
19
+ And I press the Backspace key in the edit tab
20
+ Then the contents should be "foobar\r\nbaz\r\n"
21
+
22
+ Scenario: Chooses line delimiter by text put in the tab (Unix)
23
+ When I open a new edit tab
24
+ And I replace the contents with "foo\nbar\nbaz\n"
25
+ Then the line delimiter should be "\n"
26
+
27
+ Scenario: Delete at end of line deletes delimiter (Unix)
28
+ When I open a new edit tab
29
+ And I replace the contents with "foo\nbar\nbaz\n"
30
+ And I move the cursor to 3
31
+ And I press the Delete key in the edit tab
32
+ Then the contents should be "foobar\nbaz\n"
33
+
34
+ Scenario: Backspace at start of line deletes delimiter (Windows)
35
+ When I open a new edit tab
36
+ And I replace the contents with "foo\nbar\nbaz\n"
37
+ And I move the cursor to 4
38
+ And I press the Backspace key in the edit tab
39
+ Then the contents should be "foobar\nbaz\n"
40
+
@@ -1,6 +1,6 @@
1
1
 
2
2
  def unescape_text(text)
3
- text.gsub("\\t", "\t").gsub("\\n", "\n").gsub("\\\"", "\"")
3
+ text.gsub("\\t", "\t").gsub("\\n", "\n").gsub("\\r", "\r").gsub("\\\"", "\"")
4
4
  end
5
5
 
6
6
  When /^I undo$/ do
@@ -133,7 +133,19 @@ Then /^the selection range should be from (\d+) to (\d+)$/ do |from_str, to_str|
133
133
  r.end.should == to_str.to_i
134
134
  end
135
135
 
136
-
137
-
138
-
136
+ Then /the line delimiter should be "(.*)"/ do |delim|
137
+ doc = Redcar::EditView.focussed_edit_view_document
138
+ doc.delim.should == unescape_text(delim)
139
+ end
140
+
141
+ When /^I move to line (\d+)$/ do |num|
142
+ doc = Redcar::EditView.focussed_edit_view_document
143
+ doc.cursor_offset = doc.offset_at_line(num.to_i)
144
+ end
145
+
146
+ Then /^the cursor should be on line (\d+)$/ do |num|
147
+ doc = Redcar::EditView.focussed_edit_view_document
148
+ doc.cursor_line.should == num.to_i
149
+ end
150
+
139
151
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  module NotebookSwtHelper
3
3
  def sash
4
- sash = first_shell.children.to_a.first
4
+ sash = active_shell.children.to_a.first
5
5
  end
6
6
 
7
7
  def ctab_folders
@@ -19,7 +19,7 @@ When /^I close the focussed tab$/ do
19
19
  end
20
20
 
21
21
  When /^I replace the contents with "([^\"]*)"$/ do |contents|
22
- contents = contents.gsub("\\n", "\n").gsub("\\t", "\t")
22
+ contents = unescape_text(contents)
23
23
  win = Redcar.app.windows.first
24
24
  tab = win.focussed_notebook.focussed_tab
25
25
  cursor_offset = (contents =~ /<c>/)
@@ -14,7 +14,11 @@ Then /^there should be (no|one|\d+) windows?$/ do |num|
14
14
  # in the gui
15
15
  display = Swt::Widgets::Display.get_current
16
16
  shells = display.get_shells.to_a
17
- shells.length.should == num
17
+
18
+ # on OSX there is always an invisible window
19
+ diff = Redcar.platform == :osx ? 1 : 0
20
+
21
+ shells.length.should == num + diff
18
22
  end
19
23
 
20
24
  When /I open a new window(?: with title "(.*)")?/ do |title|
@@ -3,8 +3,7 @@ RequireSupportFiles File.dirname(__FILE__) + "/../../../application/features/"
3
3
  module SwtTabHelpers
4
4
  def get_tab_folder
5
5
  display = Redcar::ApplicationSWT.display
6
- shell = display.get_shells.to_a.first
7
- sash_form = shell.children.to_a.first
6
+ sash_form = active_shell.children.to_a.first
8
7
  tab_folders = sash_form.children.to_a[1].children.to_a[0].children.to_a
9
8
  tab_folders.length.should == 1
10
9
  tab_folders.first
@@ -16,13 +15,12 @@ module SwtTabHelpers
16
15
  end
17
16
 
18
17
  def focussed_tab
19
- Redcar.app.windows.first.focussed_notebook.focussed_tab
18
+ Redcar.app.focussed_window.focussed_notebook.focussed_tab
20
19
  end
21
20
 
22
21
  def get_tabs
23
22
  display = Redcar::ApplicationSWT.display
24
- shell = display.get_shells.to_a.first
25
- sash_form = shell.children.to_a.first
23
+ sash_form = active_shell.children.to_a.first
26
24
  tab_folders = sash_form.children.to_a[1].children.to_a[0].children.to_a.select{|c| c.is_a? Swt::Custom::CTabFolder}
27
25
  items = tab_folders.map{|f| f.getItems.to_a}.flatten
28
26
  items.map {|i| model_tab_for_item(i)}
@@ -49,4 +49,25 @@ Feature: Undo and Redo
49
49
  And I redo
50
50
  Then the menu item "Edit|Undo" should be active
51
51
  And the menu item "Edit|Redo" should be inactive
52
+
53
+ Scenario: Compound undo steps work
54
+ When I open a new edit tab
55
+ And tabs are hard
56
+ And I replace the contents with "Bolzano\nWeierstrass"
57
+ And I select from 0 to 19
58
+ And tabs are hard
59
+ And I run the command Redcar::Top::IncreaseIndentCommand
60
+ Then the contents should be "\tBolzano\n\tWeierstrass"
61
+ And I undo
62
+ Then the contents should be "Bolzano\nWeierstrass"
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
52
73
 
@@ -7,8 +7,10 @@ require "edit_view/command"
7
7
  require "edit_view/document"
8
8
  require "edit_view/document/command"
9
9
  require "edit_view/document/controller"
10
+ require "edit_view/document/indentation"
10
11
  require "edit_view/document/mirror"
11
12
  require "edit_view/edit_tab"
13
+ require "edit_view/modified_tabs_checker"
12
14
  require "edit_view/tab_settings"
13
15
  require "edit_view/info_speedbar"
14
16
 
@@ -43,10 +45,9 @@ module Redcar
43
45
 
44
46
  def self.all_handlers(type)
45
47
  result = []
46
- Redcar.plugin_manager.loaded_plugins.each do |plugin|
47
- if plugin.object.respond_to?(:"#{type}_handlers")
48
- result += plugin.object.send(:"#{type}_handlers")
49
- end
48
+ method_name = :"#{type}_handlers"
49
+ Redcar.plugin_manager.objects_implementing(method_name).each do |object|
50
+ result += object.send(method_name)
50
51
  end
51
52
  result.each {|h| Handler.verify_interface!(h) }
52
53
  end
@@ -139,6 +140,7 @@ module Redcar
139
140
  # loses focus. Sends :focussed_edit_view event.
140
141
  def self.focussed_edit_view=(edit_view)
141
142
  @focussed_edit_view = edit_view
143
+ edit_view.check_for_updated_document if edit_view
142
144
  notify_listeners(:focussed_edit_view, edit_view)
143
145
  end
144
146
 
@@ -211,6 +213,10 @@ module Redcar
211
213
  focussed_edit_view_document.mirror if focussed_edit_view_document
212
214
  end
213
215
 
216
+ def self.all_edit_views
217
+ Redcar.app.windows.map {|w| w.notebooks.map {|n| n.tabs}.flatten }.flatten.select {|t| t.is_a?(EditTab)}.map {|t| t.edit_view}
218
+ end
219
+
214
220
  attr_reader :document
215
221
 
216
222
  def initialize
@@ -242,6 +248,7 @@ module Redcar
242
248
  @grammar = name
243
249
  self.tab_width = EditView.tab_settings.width_for(name)
244
250
  self.soft_tabs = EditView.tab_settings.softness_for(name)
251
+ refresh_show_invisibles
245
252
  end
246
253
 
247
254
  def focus
@@ -271,6 +278,24 @@ module Redcar
271
278
  EditView.tab_settings.set_softness_for(grammar, bool)
272
279
  notify_listeners(:softness_changed, bool)
273
280
  end
281
+
282
+ def show_invisibles?
283
+ @show_invisibles
284
+ end
285
+
286
+ def self.show_invisibles?
287
+ EditView.tab_settings.show_invisibles?
288
+ end
289
+
290
+ def self.show_invisibles=(bool)
291
+ EditView.tab_settings.set_show_invisibles(bool)
292
+ all_edit_views.each {|ev| ev.refresh_show_invisibles }
293
+ end
294
+
295
+ def refresh_show_invisibles
296
+ @show_invisibles = EditView.tab_settings.show_invisibles?
297
+ notify_listeners(:invisibles_changed, @show_invisibles)
298
+ end
274
299
 
275
300
  def title=(title)
276
301
  notify_listeners(:title_changed, title)
@@ -291,6 +316,34 @@ module Redcar
291
316
  def delay_parsing
292
317
  controller.delay_parsing { yield }
293
318
  end
319
+
320
+ def reset_last_checked
321
+ @last_checked = Time.now
322
+ end
323
+
324
+ def check_for_updated_document
325
+ # awful forward dependency on the Project plugin here....
326
+ if document and
327
+ document.mirror and
328
+ document.mirror.is_a?(Project::FileMirror) and
329
+ document.mirror.changed_since?(@last_checked)
330
+ if document.modified?
331
+ result = Application::Dialog.message_box(
332
+ "This file has been changed on disc, and you have unsaved changes in Redcar.\n\n" +
333
+ "Revert to version on disc (and lose your changes)?",
334
+ :buttons => :yes_no
335
+ )
336
+ case result
337
+ when :yes
338
+ document.update_from_mirror
339
+ end
340
+ else
341
+ puts "updating document as has changed since #{@last_checked}"
342
+ document.update_from_mirror
343
+ end
344
+ end
345
+ @last_checked = Time.now
346
+ end
294
347
  end
295
348
  end
296
349