redcar 0.11.0dev → 0.11

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 (139) hide show
  1. data/CHANGES +14 -1
  2. data/README.md +28 -8
  3. data/Rakefile +23 -18
  4. data/bin/redcar +9 -4
  5. data/lib/redcar.rb +42 -4
  6. data/lib/redcar/installer.rb +7 -2
  7. data/lib/redcar/logger.rb +64 -0
  8. data/lib/redcar/runner.rb +17 -8
  9. data/lib/redcar/usage.rb +2 -0
  10. data/plugins/application/features/step_definitions/tree_steps.rb +4 -4
  11. data/plugins/application/features/support/env.rb +6 -6
  12. data/plugins/application/lib/application.rb +31 -3
  13. data/plugins/application/lib/application/command.rb +6 -0
  14. data/plugins/application/lib/application/command/executor.rb +0 -1
  15. data/plugins/application/lib/application/commands/application_commands.rb +21 -0
  16. data/plugins/application/lib/application/commands/notebook_commands.rb +73 -0
  17. data/plugins/application/lib/application/commands/tab_commands.rb +105 -0
  18. data/plugins/application/lib/application/commands/treebook_commands.rb +117 -0
  19. data/plugins/application/lib/application/commands/window_commands.rb +68 -0
  20. data/plugins/{tree/lib → application/lib/application}/tree.rb +0 -4
  21. data/plugins/{tree/lib → application/lib/application}/tree/command.rb +0 -0
  22. data/plugins/{tree/lib → application/lib/application}/tree/controller.rb +0 -0
  23. data/plugins/{tree/lib → application/lib/application}/tree/mirror.rb +0 -0
  24. data/plugins/application/spec/application/keymap/builder_spec.rb +1 -1
  25. data/plugins/application/spec/application/menu/builder_spec.rb +2 -2
  26. data/plugins/application_swt/lib/application_swt.rb +4 -2
  27. data/plugins/application_swt/lib/swt/vtab_label.rb +6 -3
  28. data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +6 -3
  29. data/plugins/clojure/lib/clojure.rb +2 -2
  30. data/plugins/core/lib/core.rb +0 -4
  31. data/plugins/core/lib/core/gui.rb +2 -4
  32. data/plugins/core/lib/core/plugin/storage.rb +68 -21
  33. data/plugins/core/spec/core/base_storage_spec.rb +81 -0
  34. data/plugins/core/spec/core/shared_storage_spec.rb +49 -0
  35. data/plugins/core/spec/core/storage_spec.rb +13 -63
  36. data/plugins/declarations/lib/declarations.rb +3 -1
  37. data/plugins/document_search/features/replace.feature +29 -20
  38. data/plugins/document_search/lib/document_search/find_speedbar.rb +4 -1
  39. data/plugins/edit_view/features/indentation_commands.feature +6 -5
  40. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +4 -4
  41. data/plugins/edit_view/features/step_definitions/tab_steps.rb +7 -7
  42. data/plugins/edit_view/features/step_definitions/window_steps.rb +2 -2
  43. data/plugins/edit_view/lib/edit_view.rb +15 -1
  44. data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +7 -7
  45. data/plugins/edit_view_swt/lib/edit_view_swt.rb +7 -6
  46. data/plugins/execute_current_tab/lib/execute_current_tab.rb +1 -1
  47. data/plugins/groovy/lib/groovy.rb +3 -3
  48. data/plugins/groovy/lib/groovy/commands.rb +1 -1
  49. data/plugins/help/lib/help/view_controller.rb +5 -0
  50. data/plugins/help/views/index.html.erb +10 -1
  51. data/plugins/html_view/features/step_definitions/html_view_steps.rb +1 -1
  52. data/plugins/html_view/features/support/env.rb +0 -15
  53. data/plugins/html_view/lib/html_view.rb +3 -4
  54. data/plugins/html_view/lib/html_view/commands.rb +1 -1
  55. data/plugins/key_bindings/lib/key_bindings.rb +34 -0
  56. data/plugins/key_bindings/plugin.rb +8 -0
  57. data/plugins/{tree → key_bindings}/spec/spec_helper.rb +0 -0
  58. data/plugins/line_tools/features/lower_text.feature +3 -4
  59. data/plugins/line_tools/lib/line_tools.rb +6 -5
  60. data/plugins/mirah/lib/mirah.rb +2 -2
  61. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +5 -3
  62. data/plugins/project/features/open_directory_tree.feature +1 -1
  63. data/plugins/project/features/step_definitions/file_steps.rb +5 -5
  64. data/plugins/project/features/step_definitions/find_file_steps.rb +2 -3
  65. data/plugins/project/features/support/env.rb +4 -0
  66. data/plugins/project/lib/project.rb +15 -9
  67. data/plugins/project/lib/project/commands.rb +46 -16
  68. data/plugins/project/lib/project/dir_controller.rb +1 -1
  69. data/plugins/project/lib/project/dir_mirror.rb +3 -2
  70. data/plugins/project/lib/project/drb_service.rb +3 -1
  71. data/plugins/project/lib/project/file_list.rb +99 -21
  72. data/plugins/project/lib/project/find_file_dialog.rb +8 -24
  73. data/plugins/project/lib/project/manager.rb +68 -12
  74. data/plugins/project/lib/project/project_tree_controller.rb +1 -1
  75. data/plugins/project/plugin.rb +1 -2
  76. data/plugins/project_search/features/word_search.feature +1 -1
  77. data/plugins/project_search/lib/project_search.rb +16 -6
  78. data/plugins/project_search/lib/project_search/commands.rb +15 -28
  79. data/plugins/project_search/lib/project_search/hit.rb +4 -0
  80. data/plugins/project_search/lib/project_search/lucene_index.rb +14 -4
  81. data/plugins/project_search/lib/project_search/views/_file.html.erb +11 -11
  82. data/plugins/project_search/lib/project_search/word_search.rb +22 -4
  83. data/plugins/project_search/spec/project_search/word_search_spec.rb +2 -2
  84. data/plugins/redcar/redcar.rb +140 -588
  85. data/plugins/repl/features/step_definitions/repl_steps.rb +3 -3
  86. data/plugins/repl/features/support/fake_repl.rb +1 -1
  87. data/plugins/ruby/lib/ruby.rb +4 -4
  88. data/plugins/runnables/features/fixtures/alternate.ruby +1 -0
  89. data/plugins/runnables/features/fixtures/line_app.rb +1 -0
  90. data/plugins/runnables/features/fixtures/name_app.rb +1 -0
  91. data/plugins/runnables/features/fixtures/params_app.rb +1 -0
  92. data/plugins/runnables/features/fixtures/runnable_app.rb +1 -0
  93. data/plugins/runnables/lib/runnables.rb +21 -0
  94. data/plugins/runnables/lib/runnables/command_output_controller.rb +14 -9
  95. data/plugins/runnables/lib/runnables/output_processor.rb +4 -4
  96. data/plugins/runnables/lib/runnables/running_process_checker.rb +6 -6
  97. data/plugins/runnables/plugin.rb +1 -2
  98. data/plugins/scm/lib/scm.rb +18 -18
  99. data/plugins/scm/lib/scm/commit_mirror.rb +2 -2
  100. data/plugins/scm/lib/scm/scm_changes_controller.rb +1 -1
  101. data/plugins/scm_hg/lib/scm_hg.rb +1 -1
  102. data/plugins/snippets/lib/snippets/document_controller.rb +46 -40
  103. data/plugins/swt/lib/swt.rb +2 -0
  104. data/plugins/test_runner/lib/test_runner.rb +1 -0
  105. data/plugins/test_runner/lib/test_runner/jasmine_test_runner.rb +15 -0
  106. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +21 -5
  107. data/plugins/textmate/lib/textmate.rb +5 -1
  108. data/plugins/textmate/lib/textmate/preference.rb +4 -0
  109. data/plugins/textmate/lib/textmate/snippet.rb +0 -2
  110. data/plugins/textmate/lib/textmate/tree_mirror.rb +6 -5
  111. data/plugins/textmate/plugin.rb +1 -1
  112. data/plugins/textmate/vendor/redcar-bundles/Bundles/C.tmbundle/Syntaxes/C.plist +2 -2
  113. data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/info.plist +2 -0
  114. data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Plain_Text_Feature.tmLanguage +0 -4
  115. data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/info.plist +2 -0
  116. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +3 -1
  117. data/plugins/textmate/vendor/redcar-bundles/Bundles/Palm-WebOS-Development.tmbundle/info.plist +2 -0
  118. data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +2 -0
  119. data/plugins/textmate/vendor/redcar-bundles/Bundles/SQL.tmbundle/info.plist +2 -0
  120. data/plugins/textmate/vendor/redcar-bundles/Bundles/Scala.tmbundle/info.plist +2 -0
  121. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/GNU_Smalltalk.tmPreferences +1 -1
  122. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/MIST_Smalltalk_Format.tmPreferences +1 -1
  123. data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/info.plist +2 -0
  124. data/plugins/textmate/vendor/redcar-bundles/Bundles/Vala.tmbundle/info.plist +4 -2
  125. data/plugins/textmate/vendor/redcar-bundles/Bundles/Webrat.tmbundle/info.plist +2 -0
  126. data/plugins/textmate/vendor/redcar-bundles/Bundles/YAML.tmbundle/Syntaxes/YAML.plist +1 -0
  127. data/plugins/textmate/vendor/redcar-bundles/Bundles/groovy.tmbundle/info.plist +2 -0
  128. data/plugins/textmate/vendor/redcar-bundles/Themes/Twilight.tmTheme +0 -2
  129. data/plugins/todo_list/lib/todo_list.rb +3 -3
  130. data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
  131. data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +1 -1
  132. data/plugins/web_bookmarks/lib/web_bookmarks.rb +11 -4
  133. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -1
  134. data/plugins/web_bookmarks/plugin.rb +1 -2
  135. metadata +29 -20
  136. data/plugins/core/lib/core/logger.rb +0 -28
  137. data/plugins/file_parser/lib/file_parser.rb +0 -125
  138. data/plugins/file_parser/plugin.rb +0 -7
  139. data/plugins/tree/plugin.rb +0 -9
@@ -1,9 +1,9 @@
1
1
  When /^I open a "([^"]*)" repl$/ do |repl|
2
- Redcar.const_get(repl.camelize).const_get(repl.camelize + "OpenREPL").new.run
2
+ Redcar.const_get(repl.camelize).const_get("Open" + repl.camelize + "REPL").new.run
3
3
  end
4
4
 
5
5
  When /^I open a new repl$/ do
6
- Redcar::REPL::FakeOpenREPL.new.run
6
+ Redcar::REPL::OpenFakeREPL.new.run
7
7
  end
8
8
 
9
9
  Then /^the REPL output should be "([^"]*)"$/ do |output|
@@ -16,4 +16,4 @@ end
16
16
 
17
17
  Then /^the current command should be blank$/ do
18
18
  current_tab.current_command.should == nil
19
- end
19
+ end
@@ -7,7 +7,7 @@ module Redcar
7
7
  end
8
8
  end
9
9
 
10
- class FakeOpenREPL < OpenREPL
10
+ class OpenFakeREPL < OpenREPL
11
11
  def execute
12
12
  open_repl(ReplMirror.new)
13
13
  end
@@ -8,7 +8,7 @@ module Redcar
8
8
  Menu::Builder.build do
9
9
  sub_menu "Plugins" do
10
10
  sub_menu "REPL" do
11
- item "Open Ruby REPL", RubyOpenREPL
11
+ item "Open Ruby REPL", OpenRubyREPL
12
12
  end
13
13
  end
14
14
  end
@@ -16,17 +16,17 @@ module Redcar
16
16
 
17
17
  def self.keymaps
18
18
  osx = Keymap.build("main", :osx) do
19
- link "Cmd+Shift+R", RubyOpenREPL
19
+ link "Cmd+Shift+R", OpenRubyREPL
20
20
  end
21
21
 
22
22
  linwin = Keymap.build("main", [:linux, :windows]) do
23
- link "Ctrl+Shift+R", RubyOpenREPL
23
+ link "Ctrl+Shift+R", OpenRubyREPL
24
24
  end
25
25
 
26
26
  [linwin, osx]
27
27
  end
28
28
 
29
- class RubyOpenREPL < Redcar::REPL::OpenREPL
29
+ class OpenRubyREPL < Redcar::REPL::OpenREPL
30
30
  def execute
31
31
  open_repl(ReplMirror.new)
32
32
  end
@@ -0,0 +1 @@
1
+ ARGV.each { |it| print it+' '}
@@ -0,0 +1 @@
1
+ ARGV.each { |it| println it}
@@ -0,0 +1 @@
1
+ ARGV.each { |it| println it}
@@ -0,0 +1 @@
1
+ ARGV.each { |it| print it+' '}
@@ -0,0 +1 @@
1
+ puts "hello world"
@@ -155,5 +155,26 @@ module Redcar
155
155
  storage
156
156
  end
157
157
  end
158
+
159
+ def self.quit_guard
160
+ Runnables::RunningProcessChecker.new(
161
+ Redcar.app.all_tabs.select {|t| t.is_a?(HtmlTab)},
162
+ "Kill all and quit?"
163
+ ).check
164
+ end
165
+
166
+ def self.close_window_guard(win)
167
+ Runnables::RunningProcessChecker.new(
168
+ win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(HtmlTab)},
169
+ "Kill them and close the window?"
170
+ ).check
171
+ end
172
+
173
+ def self.project_closed(project,window)
174
+ rtree = window.treebook.trees.detect { |t|
175
+ t.tree_mirror.is_a? Runnables::TreeMirror
176
+ }
177
+ rtree.close if rtree
178
+ end
158
179
  end
159
180
  end
@@ -18,14 +18,14 @@ module Redcar
18
18
  end
19
19
 
20
20
  def ask_before_closing
21
- if @shell
21
+ if @pid
22
22
  "This tab contains an unfinished process. \n\nKill the process and close?"
23
23
  end
24
24
  end
25
25
 
26
26
  def close
27
- if @shell
28
- Process.kill(9, @shell.pid.to_i + 1)
27
+ if @pid
28
+ Process.kill(9, @pid.to_i + 1)
29
29
  end
30
30
  end
31
31
 
@@ -82,21 +82,26 @@ module Redcar
82
82
  # TODO: Find browser's onload rather than sleeping
83
83
  sleep 1
84
84
  start_output_block
85
- Redcar.logger.info "Running: #{cmd}"
85
+ Redcar.log.info "Running: #{cmd}"
86
86
 
87
87
  # JRuby-specific
88
- pid, input, output, error = IO.popen4(cmd)
88
+ @pid, input, output, error = IO.popen4(cmd)
89
89
  @stdout_thread = output_thread(:stdout, output)
90
90
  @stderr_thread = output_thread(:stderr, error)
91
91
 
92
92
  Thread.new do
93
- sleep 0.1 until @stdout_thread_started && @stderr_thread_started &&
94
- !@stdout_thread.alive? && !@stderr_thread.alive?
93
+ sleep 0.1 until finished?
94
+ @pid = nil
95
95
  end_output_block
96
96
  end
97
97
  end
98
98
  end
99
99
 
100
+ def finished?
101
+ @stdout_thread_started && @stderr_thread_started &&
102
+ !@stdout_thread.alive? && !@stderr_thread.alive?
103
+ end
104
+
100
105
  def format_time(time)
101
106
  time.strftime("%I:%M:%S %p").downcase
102
107
  end
@@ -163,8 +168,8 @@ module Redcar
163
168
  end
164
169
 
165
170
  def open_file(file, line)
166
- puts "i got called: #{file}"
167
- Project::Manager.open_file(file)
171
+ Project::Manager.open_file(File.join(Project::Manager.focussed_project.path, file))
172
+ Redcar.app.focussed_window.focussed_notebook_tab.edit_view.document.scroll_to_line(line.to_i)
168
173
  end
169
174
 
170
175
  def index
@@ -18,9 +18,9 @@ module Redcar
18
18
  end
19
19
 
20
20
  def process_file_line_numbers(str)
21
- file_number_regex = /(\/\S+)\:(\d+)/
21
+ file_number_regex = /(\S+)\:(\d+)/
22
22
  if str =~ file_number_regex
23
- str.gsub(file_number_regex,
23
+ str.gsub(file_number_regex,
24
24
  %{<a class="file_line_link" href="javascript:Controller.openFile('#{$1}', '#{$2}');">#{$1}:#{$2}</a>})
25
25
  else
26
26
  str
@@ -29,7 +29,7 @@ module Redcar
29
29
 
30
30
  def initialize
31
31
  @ansi_stack = []
32
- @ansi_colors = %w(black red green yellow blue purple cyan gray)
32
+ @ansi_colors = %w(black red green yellow blue purple cyan gray)
33
33
  end
34
34
 
35
35
  def color(num)
@@ -58,7 +58,7 @@ module Redcar
58
58
  if match[2] == "0" && match[4].nil?
59
59
  close_ansi_spans(:clear)
60
60
  else
61
- style = ""
61
+ style = ""
62
62
  style << "ansi-regular " if match[2] == "0"
63
63
  style << "ansi-bold " if match[2] == "1"
64
64
  style << "ansi-light " if match[4] == "9"
@@ -1,8 +1,8 @@
1
1
  module Redcar
2
2
  class Runnables
3
3
  class RunningProcessChecker
4
- def initialize(tabs, message, options)
5
- @tabs, @message, @options = tabs, message, options
4
+ def initialize(tabs, message)
5
+ @tabs, @message = tabs, message
6
6
  end
7
7
 
8
8
  def check
@@ -19,14 +19,14 @@ module Redcar
19
19
  t.focus
20
20
  t.close
21
21
  end
22
- @options[:continue] ? @options[:continue].call : nil
22
+ true
23
23
  when :no
24
- @options[:continue] ? @options[:continue].call : nil
24
+ true
25
25
  when :cancel
26
- @options[:cancel] ? @options[:cancel].call : nil
26
+ false
27
27
  end
28
28
  else
29
- @options[:none] ? @options[:none].call : nil
29
+ true
30
30
  end
31
31
  end
32
32
  end
@@ -4,7 +4,6 @@ Plugin.define do
4
4
  version "1.0"
5
5
  file "lib", "runnables"
6
6
  object "Redcar::Runnables"
7
- dependencies "tree", ">0",
8
- "application", ">=1.1",
7
+ dependencies "application", ">=1.1",
9
8
  "HTML View", ">0"
10
9
  end
@@ -42,12 +42,12 @@ module Redcar
42
42
 
43
43
  def self.keymaps
44
44
  osx = Keymap.build("main", :osx) do
45
- link "Cmd+Shift+C", Scm::CommitMirror::SaveCommand
46
- link "Cmd+Shift+.", :command => Scm::CommitMirror::SaveCommand, :value => [:commit, [Scm::ScmChangesMirror, Scm::ScmChangesController]]
45
+ link "Cmd+Shift+C", Scm::CommitMirror::CommitChangesCommand
46
+ link "Cmd+Shift+.", :command => Scm::CommitMirror::CommitChangesCommand, :value => [:commit, [Scm::ScmChangesMirror, Scm::ScmChangesController]]
47
47
  end
48
48
 
49
49
  linwin = Keymap.build("main", [:linux, :windows]) do
50
- link "Ctrl+Shift+C", Scm::CommitMirror::SaveCommand
50
+ link "Ctrl+Shift+C", Scm::CommitMirror::CommitChangesCommand
51
51
  end
52
52
 
53
53
  [linwin, osx]
@@ -66,8 +66,8 @@ module Redcar
66
66
  item "Toggle Changes Tree", :command => Scm::ToggleScmTreeCommand, :value => [:commit, [Scm::ScmChangesMirror, Scm::ScmChangesController]]
67
67
  item "Toggle Commits Tree", :command => Scm::ToggleScmTreeCommand, :value => [:push, [Scm::ScmCommitsMirror, Scm::ScmCommitsController]]
68
68
  separator
69
- item "Create Commit", :command => Scm::CommitMirror::OpenCommand
70
- item "Save Commit", :command => Scm::CommitMirror::SaveCommand
69
+ item "Create Commit", :command => Scm::CommitMirror::CreateCommitCommand
70
+ item "Save Commit", :command => Scm::CommitMirror::CommitChangesCommand
71
71
  end
72
72
  end
73
73
  end
@@ -86,16 +86,16 @@ module Redcar
86
86
  def self.modules
87
87
  @modules ||= begin
88
88
  mods = []
89
- puts "Loading Redcar SCM modules..." if debug
89
+ Redcar.log.debug "SCM Loading Redcar SCM modules..."
90
90
 
91
91
  Redcar.plugin_manager.objects_implementing(:scm_module).each do |i|
92
- puts " Found #{i.name}." if debug
92
+ Redcar.log.debug "SCM Found #{i.name}."
93
93
  object = i.scm_module
94
94
 
95
95
  if object.supported?
96
96
  mods.push(object)
97
97
  elsif debug
98
- puts " but discarding because it isn't supported on the current system."
98
+ Redcar.log.debug "SCM but discarding because it isn't supported on the current system."
99
99
  end
100
100
  end
101
101
 
@@ -111,7 +111,7 @@ module Redcar
111
111
  begin
112
112
  assert_interface(mod, Redcar::Scm::Model)
113
113
  rescue RuntimeError => e
114
- puts "Skipping SCM module #{m.name} because it has an invalid interface." if debug
114
+ Redcar.log.debug "SCM Skipping SCM module #{m.name} because it has an invalid interface."
115
115
  nil
116
116
  else
117
117
  mod
@@ -131,17 +131,17 @@ module Redcar
131
131
  # for now we only want to attempt to handle the local case
132
132
  return if project.remote?
133
133
 
134
- puts "#{modules.count} SCM modules loaded." if debug
134
+ Redcar.log.debug "SCM #{modules.count} SCM modules loaded."
135
135
 
136
136
  repo = modules_instance.find do |m|
137
- puts "Checking if #{project.path} is a #{m.repository_type} repository..." if debug
137
+ Redcar.log.debug "SCM Checking if #{project.path} is a #{m.repository_type} repository..."
138
138
  m.repository?(project.path)
139
139
  end
140
140
 
141
141
  # quit if we can't find something to handle this project
142
142
  return if repo.nil?
143
143
 
144
- puts " Yes it is!" if debug
144
+ Redcar.log.debug "SCM Yes it is!"
145
145
 
146
146
  prepare(project, repo)
147
147
  end
@@ -156,7 +156,7 @@ module Redcar
156
156
  repo.load(project.path)
157
157
  adapter = repo.adapter(project.adapter)
158
158
  if not adapter.nil?
159
- puts "Attaching a custom adapter to the project." if debug
159
+ Redcar.log.debug "SCM Attaching a custom adapter to the project."
160
160
  project.adapter = adapter
161
161
  end
162
162
 
@@ -165,19 +165,19 @@ module Redcar
165
165
  # cleanup
166
166
  info = project_repositories.delete project
167
167
 
168
- puts "*** Error loading SCM: " + $!.message
168
+ Redcar.log.error "*** Error loading SCM: " + $!.message
169
169
  puts $!.backtrace
170
170
  end
171
171
 
172
- puts "scm start took #{Time.now - start}s (included in project start time)" if debug
172
+ Redcar.log.debug "SCM start took #{Time.now - start}s"
173
173
  end
174
174
 
175
- def self.project_closed(project)
175
+ def self.project_closed(project,window)
176
176
  # disassociate this project with any repositories
177
177
  info = project_repositories.delete project
178
178
  return if info.nil?
179
179
 
180
- info['trees'].each {|t| project.window.treebook.remove_tree(t)}
180
+ info['trees'].each {|t| window.treebook.remove_tree(t)}
181
181
  end
182
182
 
183
183
  def self.refresh_trees
@@ -191,7 +191,7 @@ module Redcar
191
191
  # Search for the current project
192
192
  project = Project::Manager.in_window(Redcar.app.focussed_window)
193
193
  if project.nil?
194
- puts "Couldn't detect the project in the current window."
194
+ Redcar.log.debug "SCM Couldn't detect the project in the current window."
195
195
  end
196
196
  repo_info = project_repositories[project]
197
197
  init_modules = Redcar::Scm::Manager.modules_with_init
@@ -43,7 +43,7 @@ module Redcar
43
43
  notify_listeners(:change)
44
44
  end
45
45
 
46
- class SaveCommand < Command
46
+ class CommitChangesCommand < Command
47
47
  sensitize :open_commit_tab
48
48
 
49
49
  def execute
@@ -57,7 +57,7 @@ module Redcar
57
57
  end
58
58
  end
59
59
 
60
- class OpenCommand < Command
60
+ class CreateCommitCommand < Command
61
61
  sensitize :open_scm
62
62
 
63
63
  def execute
@@ -21,7 +21,7 @@ module Redcar
21
21
 
22
22
  def activated(tree, node)
23
23
  if node.respond_to?(:status) and node.status == [:unmerged]
24
- Project::FileOpenCommand.new(node.path).run
24
+ Project::FileCreateCommitCommand.new(node.path).run
25
25
  elsif node.respond_to?(:diff)
26
26
  diff = node.diff
27
27
  if diff
@@ -11,7 +11,7 @@ module Redcar
11
11
 
12
12
  def self.supported?
13
13
  # not implemented, and hence never supported
14
- puts " Mercurial support is currently unimplemented" if debug
14
+ Redcar.log.debug "SCM Mercurial support is currently unimplemented"
15
15
  false
16
16
  end
17
17
 
@@ -16,7 +16,7 @@ module Redcar
16
16
  @text = text
17
17
  end
18
18
  end
19
-
19
+
20
20
  def after_modify
21
21
  if in_snippet? and @start_offset and !@constructing
22
22
  left_marks = marks_at_offset(@start_offset)
@@ -53,25 +53,31 @@ module Redcar
53
53
  end
54
54
  end
55
55
  end
56
- if in_snippet? and @end_offset > @start_offset and !@ignore
57
- update_after_delete(@start_offset, @end_offset)
58
- end
59
- if in_snippet? and !@ignore and @start_offset
60
- document.controllers(AutoPairer::DocumentController).first.ignore do
61
- update_after_insert(@start_offset, @text.length)
56
+ if in_snippet?
57
+ if @end_offset
58
+ if @end_offset > @start_offset and !@ignore
59
+ update_after_delete(@start_offset, @end_offset)
60
+ end
61
+ if !@ignore and @start_offset
62
+ document.controllers(AutoPairer::DocumentController).first.ignore do
63
+ update_after_insert(@start_offset, @text.length)
64
+ end
65
+ @start_offset, @end_offset, @text = nil, nil, nil
66
+ end
67
+ else
68
+ clear_snippet
62
69
  end
63
- @start_offset, @end_offset, @text = nil, nil, nil
64
70
  end
65
71
 
66
72
  false
67
73
  end
68
-
74
+
69
75
  def cursor_moved(new_offset)
70
76
  if @current_snippet and !@ignore
71
77
  check_in_snippet
72
78
  end
73
79
  end
74
-
80
+
75
81
  def start_snippet!(snippet)
76
82
  @current_snippet = snippet
77
83
  document.controllers(AutoPairer::DocumentController).first.ignore do
@@ -80,17 +86,17 @@ module Redcar
80
86
  end
81
87
  end
82
88
  end
83
-
89
+
84
90
  def in_snippet?
85
91
  !!current_snippet
86
92
  end
87
-
93
+
88
94
  SnippetMark ||= Struct.new(:mark, :order_id, :stop_id)
89
-
95
+
90
96
  class SnippetMark
91
97
  attr_accessor :name
92
98
  end
93
-
99
+
94
100
  def insert_snippet(snippet)
95
101
  @content = snippet.content
96
102
  @insert_line_num = document.cursor_line
@@ -102,7 +108,7 @@ module Redcar
102
108
  @marks = []
103
109
  @order_id = 0
104
110
  @stop_id = 0
105
-
111
+
106
112
  @env = Textmate::Environment.new
107
113
  fix_line_endings
108
114
  # Not sure what to do about backticks. Currently they don't work in Redcar.
@@ -125,17 +131,17 @@ module Redcar
125
131
  select_tab_stop(@tab_stops.keys.sort.first)
126
132
  end
127
133
  end
128
-
134
+
129
135
  def leading_whitespace(line)
130
136
  line[/^(\s*)([^\s]|$)/, 1].chomp
131
137
  end
132
-
138
+
133
139
  def fix_line_endings
134
140
  if document.delim != "\n" # textmate uses "\n" everywhere
135
141
  @content = @content.gsub("\n", document.delim)
136
142
  end
137
143
  end
138
-
144
+
139
145
  def compute_tab_stop(line, tab_width, soft_tabs)
140
146
  re = / {0,#{tab_width - 1}}\t|#{" "*tab_width}/
141
147
  sc = StringScanner.new(leading_whitespace(line))
@@ -143,7 +149,7 @@ module Redcar
143
149
  tab_stop += 1 while sc.skip(re)
144
150
  tab_stop
145
151
  end
146
-
152
+
147
153
  def fix_indent
148
154
  tab_width = document.edit_view.tab_width
149
155
  soft_tabs = document.edit_view.soft_tabs?
@@ -163,7 +169,7 @@ module Redcar
163
169
  document.delete(document.offset_at_line(line_ix) + new_indent.length, pre.length)
164
170
  end
165
171
  end
166
-
172
+
167
173
  def unescape(text)
168
174
  text.gsub("\\$", "$").gsub("\\\\", "\\").gsub("\\}", "}").gsub("\\`", "`")
169
175
  end
@@ -172,7 +178,7 @@ module Redcar
172
178
  document.insert_at_cursor(text)
173
179
  document.cursor_offset += text.length
174
180
  end
175
-
181
+
176
182
  def check_in_snippet
177
183
  clear_snippet unless find_current_tab_stop
178
184
  end
@@ -184,7 +190,7 @@ module Redcar
184
190
  while remaining_content.length > 0
185
191
  i += 1
186
192
  raise "Snippet failed to parse: #{text.inspect}" if i > 100
187
-
193
+
188
194
  if md = Regexp.new("(?<!\\\\)\\$").match(remaining_content)
189
195
  insert_at_cursor_with_gravity(unescape(md.pre_match))
190
196
  @stop_id += 1
@@ -290,11 +296,11 @@ module Redcar
290
296
  end
291
297
  @end_line_num = document.cursor_line
292
298
  end
293
-
299
+
294
300
  def onig_split(string, re)
295
301
  line = string.dup
296
302
  bits = []
297
- while line.length > 0 and
303
+ while line.length > 0 and
298
304
  md = re.match(line)
299
305
  line = md.post_match
300
306
  bits << md.pre_match
@@ -328,26 +334,26 @@ module Redcar
328
334
  @marks << snippet_mark
329
335
  snippet_mark
330
336
  end
331
-
337
+
332
338
  def marks_at_cursor
333
339
  marks_at_offset(document.cursor_offset)
334
340
  end
335
-
341
+
336
342
  def marks_at_offset(offset)
337
343
  marks.select {|m| m.mark.get_offset == offset }
338
344
  end
339
-
345
+
340
346
  def marks
341
347
  @marks
342
348
  end
343
-
349
+
344
350
  def update_after_insert(offset, length)
345
351
  #@buf.parser.stop_parsing
346
352
  update_mirrors(offset, offset+length)
347
353
  update_transformations(offset, offset+length)
348
354
  #@buf.parser.start_parsing
349
355
  end
350
-
356
+
351
357
  def update_after_delete(offset1, offset2)
352
358
  #@buf.parser.stop_parsing
353
359
  delete_any_mirrors(offset1, offset2)
@@ -355,7 +361,7 @@ module Redcar
355
361
  update_transformations(offset1, offset2)
356
362
  #@buf.parser.start_parsing
357
363
  end
358
-
364
+
359
365
  def delete_any_mirrors(offset1, offset2)
360
366
  @mirrors.each do |num, mirrors|
361
367
  (mirrors||[]).reject! do |mirror|
@@ -404,7 +410,7 @@ module Redcar
404
410
  end
405
411
  end
406
412
  end
407
-
413
+
408
414
  def set_names
409
415
  @tab_stops.each do |i, h|
410
416
  h[:leftmark].name = "$#{i}l"
@@ -423,12 +429,12 @@ module Redcar
423
429
  end
424
430
  end
425
431
  end
426
-
432
+
427
433
  def select_tab_stop(n)
428
- document.set_selection_range(@tab_stops[n][:rightmark].mark.get_offset,
434
+ document.set_selection_range(@tab_stops[n][:rightmark].mark.get_offset,
429
435
  @tab_stops[n][:leftmark].mark.get_offset)
430
436
  end
431
-
437
+
432
438
  def move_forward_tab_stop
433
439
  current = find_current_tab_stop
434
440
  raise "unexpectedly outside snippet" unless current
@@ -462,7 +468,7 @@ module Redcar
462
468
  select_tab_stop(current-1)
463
469
  end
464
470
  end
465
-
471
+
466
472
  def clear_snippet
467
473
  @current_snippet = false
468
474
  @word = nil
@@ -476,7 +482,7 @@ module Redcar
476
482
  document.delete_mark(mark.mark)
477
483
  end
478
484
  end
479
-
485
+
480
486
  def find_current_tab_stop
481
487
  candidates = []
482
488
  @tab_stops.each do |num, hash|
@@ -495,13 +501,13 @@ module Redcar
495
501
  candidates.sort.first[1]
496
502
  end
497
503
  end
498
-
504
+
499
505
  def get_tab_stop_range(num)
500
506
  off1 = @tab_stops[num][:leftmark].mark.get_offset
501
507
  off2 = @tab_stops[num][:rightmark].mark.get_offset
502
508
  off1..off2
503
509
  end
504
-
510
+
505
511
  def get_tab_stop_text(num)
506
512
  i1 = @tab_stops[num][:leftmark].mark.get_offset
507
513
  i2 = @tab_stops[num][:rightmark].mark.get_offset
@@ -512,7 +518,7 @@ module Redcar
512
518
  update_mirrors
513
519
  update_transformations
514
520
  end
515
-
521
+
516
522
  def update_mirrors(start=nil, stop=nil)
517
523
  @mirrors.each do |num, mirrors|
518
524
  next unless mirrors
@@ -541,7 +547,7 @@ module Redcar
541
547
  end
542
548
  @editing_stop_id = nil
543
549
  end
544
-
550
+
545
551
  def update_transformations(start=nil, stop=nil)
546
552
  @transformations.each do |num, transformations|
547
553
  r = get_tab_stop_range(num)