redcar 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/CHANGES +42 -0
  2. data/README.md +5 -3
  3. data/Rakefile +39 -81
  4. data/bin/redcar +1 -1
  5. data/lib/redcar.rb +9 -6
  6. data/lib/redcar/installer.rb +1 -1
  7. data/lib/redcar/ruby_extensions.rb +19 -0
  8. data/lib/redcar/runner.rb +1 -1
  9. data/lib/redcar/usage.rb +3 -0
  10. data/lib/redcar_quick_start.rb +11 -11
  11. data/plugins/application/features/step_definitions/tree_steps.rb +22 -5
  12. data/plugins/application/features/step_definitions/window_steps.rb +9 -1
  13. data/plugins/application/features/support/env.rb +5 -2
  14. data/plugins/application/lib/application.rb +51 -46
  15. data/plugins/application/lib/application/window.rb +60 -30
  16. data/plugins/application_swt/lib/application_swt.rb +16 -16
  17. data/plugins/application_swt/lib/application_swt/window.rb +35 -7
  18. data/plugins/auto_completer/features/support/env.rb +0 -2
  19. data/plugins/auto_indenter/features/support/env.rb +0 -1
  20. data/plugins/auto_pairer/features/auto_pairer.feature +50 -45
  21. data/plugins/auto_pairer/features/support/env.rb +0 -1
  22. data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +11 -6
  23. data/plugins/clipboard-viewer/Screenshot.png +0 -0
  24. data/plugins/clipboard-viewer/lib/clipboard_viewer.rb +50 -0
  25. data/plugins/clipboard-viewer/lib/clipboard_viewer/browser_controller.rb +27 -0
  26. data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +67 -0
  27. data/plugins/clipboard-viewer/plugin.rb +9 -0
  28. data/plugins/clipboard-viewer/views/clipboard.html.erb +15 -0
  29. data/plugins/clipboard-viewer/views/default.css +43 -0
  30. data/plugins/clipboard-viewer/views/redcar_small_icon.png +0 -0
  31. data/plugins/comment/features/line_comment.feature +137 -0
  32. data/plugins/comment/features/selection_comment.feature +21 -0
  33. data/plugins/comment/features/step_definitions/comment_steps.rb +7 -0
  34. data/plugins/comment/lib/comment.rb +266 -0
  35. data/plugins/comment/plugin.rb +7 -0
  36. data/plugins/comment/vendor/comment_lib.json +47 -0
  37. data/plugins/declarations/lib/declarations.rb +1 -1
  38. data/plugins/document_search/features/replace.feature +10 -2
  39. data/plugins/document_search/features/support/env.rb +0 -1
  40. data/plugins/document_search/lib/document_search.rb +4 -1
  41. data/plugins/document_search/lib/document_search/replace.rb +11 -3
  42. data/plugins/document_search/lib/document_search/search_and_replace.rb +5 -2
  43. data/plugins/edit_view/features/case_change.feature +9 -9
  44. data/plugins/edit_view/features/cursor_navigation.feature +36 -0
  45. data/plugins/edit_view/features/step_definitions/editing_steps.rb +63 -8
  46. data/plugins/edit_view/features/step_definitions/notebook_steps.rb +2 -0
  47. data/plugins/edit_view/features/step_definitions/tab_steps.rb +8 -5
  48. data/plugins/edit_view/features/support/env.rb +8 -2
  49. data/plugins/edit_view/lib/edit_view.rb +16 -1
  50. data/plugins/edit_view/lib/edit_view/actions/cmd_enter.rb +11 -0
  51. data/plugins/edit_view/lib/edit_view/document.rb +27 -10
  52. data/plugins/edit_view/lib/edit_view/edit_tab.rb +17 -4
  53. data/plugins/edit_view/spec/edit_view/document_spec.rb +3 -0
  54. data/plugins/edit_view_swt/lib/edit_view_swt.rb +42 -3
  55. data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +17 -15
  56. data/plugins/help/lib/help.rb +40 -0
  57. data/plugins/help/plugin.rb +8 -0
  58. data/plugins/html_view/features/step_definitions/html_view_steps.rb +6 -4
  59. data/plugins/line_tools/features/support/env.rb +0 -1
  60. data/plugins/macros/features/step_definitions/macro_steps.rb +0 -55
  61. data/plugins/macros/features/support/env.rb +0 -2
  62. data/plugins/open_default_app/lib/open_default_app.rb +35 -0
  63. data/plugins/open_default_app/plugin.rb +8 -0
  64. data/plugins/open_default_app/screenshot.png +0 -0
  65. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +17 -3
  66. data/plugins/project/features/find_file.feature +3 -2
  67. data/plugins/project/features/highlight_focussed_tab.feature +8 -0
  68. data/plugins/project/features/move_and_rename_files.feature +25 -0
  69. data/plugins/project/features/open_and_save_files.feature +10 -1
  70. data/plugins/project/features/open_directory_tree.feature +32 -2
  71. data/plugins/project/features/step_definitions/directory_steps.rb +17 -0
  72. data/plugins/project/features/step_definitions/project_tree_steps.rb +3 -0
  73. data/plugins/project/features/sub_project.feature +14 -0
  74. data/plugins/project/features/support/env.rb +22 -3
  75. data/plugins/project/features/watch_for_modified_files.feature +32 -9
  76. data/plugins/project/lib/project.rb +53 -21
  77. data/plugins/project/lib/project/adapters/local.rb +21 -16
  78. data/plugins/project/lib/project/adapters/remote.rb +15 -13
  79. data/plugins/project/lib/project/commands.rb +37 -16
  80. data/plugins/project/lib/project/dir_controller.rb +41 -42
  81. data/plugins/project/lib/project/drb_service.rb +35 -21
  82. data/plugins/project/lib/project/file_list.rb +7 -1
  83. data/plugins/project/lib/project/manager.rb +28 -3
  84. data/plugins/project/lib/project/sub_project.rb +17 -0
  85. data/plugins/project/lib/project/support/recycle.js +2 -0
  86. data/plugins/project/lib/project/support/trash.rb +72 -0
  87. data/plugins/project/spec/fixtures/multi-byte-files/a/341/204/200/341/205/247/341/206/274/341/204/205/341/205/251/foo +1 -0
  88. data/plugins/project/spec/fixtures/multi-byte-files//341/204/220/341/205/246/341/204/211/341/205/263/341/204/220/341/205/263.py +1 -0
  89. data/plugins/project/spec/project/file_list_spec.rb +4 -0
  90. data/plugins/redcar/features/goto_line_command.feature +20 -0
  91. data/plugins/redcar/redcar.rb +107 -47
  92. data/plugins/repl/lib/repl.rb +20 -20
  93. data/plugins/repl/lib/repl/clojure_mirror.rb +50 -58
  94. data/plugins/repl/lib/repl/groovy_mirror.rb +22 -41
  95. data/plugins/repl/lib/repl/repl_mirror.rb +85 -14
  96. data/plugins/repl/lib/repl/ruby_mirror.rb +12 -39
  97. data/plugins/repl/spec/repl/groovy_mirror_spec.rb +1 -1
  98. data/plugins/repl/spec/repl/ruby_mirror_spec.rb +12 -12
  99. data/plugins/ruby/README +6 -0
  100. data/plugins/ruby/lib/syntax_check/ruby.rb +28 -0
  101. data/plugins/ruby/plugin.rb +7 -0
  102. data/plugins/runnables/features/command_tree.feature +9 -0
  103. data/plugins/runnables/features/file_runner_input.feature +20 -0
  104. data/plugins/runnables/features/run_alternate_command.feature +14 -0
  105. data/plugins/runnables/features/support/env.rb +42 -5
  106. data/plugins/runnables/lib/runnables.rb +67 -21
  107. data/plugins/runnables/lib/runnables/commands.rb +35 -18
  108. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +23 -37
  109. data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +16 -18
  110. data/plugins/scm_svn/features/support/env.rb +0 -3
  111. data/plugins/snippets/features/snippets.feature +17 -2
  112. data/plugins/snippets/features/support/env.rb +0 -1
  113. data/plugins/snippets/lib/snippets/tab_handler.rb +51 -18
  114. data/plugins/swt/lib/swt/cucumber_patches.rb +13 -68
  115. data/plugins/swt/lib/swt/cucumber_runner.rb +2 -3
  116. data/plugins/syntax_check/README +6 -0
  117. data/plugins/syntax_check/lib/syntax_check.rb +16 -0
  118. data/plugins/syntax_check/lib/syntax_check/checker.rb +47 -0
  119. data/plugins/syntax_check/lib/syntax_check/error.rb +23 -0
  120. data/plugins/syntax_check/plugin.rb +7 -0
  121. data/plugins/tree_view_swt/lib/tree_view_swt.rb +6 -0
  122. data/plugins/web_bookmarks/Screenshot.png +0 -0
  123. data/plugins/web_bookmarks/lib/web_bookmarks.rb +42 -0
  124. data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +43 -0
  125. data/plugins/web_bookmarks/lib/web_bookmarks/browser_bar.rb +70 -0
  126. data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +111 -0
  127. data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +67 -0
  128. data/plugins/web_bookmarks/lib/web_bookmarks/view_controller.rb +22 -0
  129. data/plugins/web_bookmarks/plugin.rb +11 -0
  130. data/plugins/web_bookmarks/views/index.html.erb +5 -0
  131. metadata +60 -10
@@ -9,26 +9,10 @@ module Redcar
9
9
  puts 'warning--not starting listener (perhaps theres another Redcar already open?)' + e + ' ' + address
10
10
  end
11
11
  end
12
-
13
- def open_item_untitled(path)
12
+
13
+ def open_item_drb(full_path, untitled = false)
14
14
  begin
15
- puts 'drb opening untitled ' + full_path if $VERBOSE
16
- if File.file?(path)
17
- Swt.sync_exec do
18
- Project::Manager.open_untitled_path(path)
19
- Redcar.app.focussed_window.controller.bring_to_front
20
- end
21
- end
22
- 'ok'
23
- rescue Exception => e
24
- puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
25
- raise e
26
- end
27
- end
28
-
29
- def open_item_drb(full_path)
30
- begin
31
- puts 'drb opening ' + full_path if $VERBOSE
15
+ puts %{drb opening #{"untitled" if untitled} #{full_path}} if $VERBOSE
32
16
  if File.directory? full_path
33
17
  Swt.sync_exec do
34
18
  if Redcar.app.windows.length == 0 and Application.storage['last_open_dir'] == full_path
@@ -60,7 +44,11 @@ module Redcar
60
44
  if Redcar.app.windows.length == 0
61
45
  Project::Manager.restore_last_session
62
46
  end
63
- Project::Manager.open_file(full_path)
47
+ if untitled
48
+ Project::Manager.open_untitled_path(full_path)
49
+ else
50
+ Project::Manager.open_file(full_path)
51
+ end
64
52
  Redcar.app.focussed_window.controller.bring_to_front
65
53
  end
66
54
  'ok'
@@ -68,7 +56,33 @@ module Redcar
68
56
  rescue Exception => e
69
57
  puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
70
58
  raise e
71
- end
59
+ end
60
+ end
61
+
62
+ def open_file_and_wait(file, untitled = false)
63
+ semaphore = Mutex.new
64
+ handler = nil
65
+ tab = nil
66
+ Swt.sync_exec do
67
+ semaphore.lock
68
+ Project::Manager.restore_last_session if Redcar.app.windows.empty?
69
+ if untitled
70
+ Project::Manager.open_untitled_path(file)
71
+ else
72
+ Project::Manager.open_file(file)
73
+ end
74
+ window = Redcar.app.focussed_window
75
+ window.controller.bring_to_front
76
+ tab = window.focussed_notebook_tab
77
+ handler = tab.add_listener(:close) { semaphore.unlock }
78
+ end
79
+ Thread.new(tab, handler) do
80
+ semaphore.synchronize { tab.remove_listener(handler) }
81
+ end.join # Wait until the tab's close event was fired
82
+ 'ok'
83
+ rescue Exception => e
84
+ puts 'drb got exception:' + e.class + " " + e.message, e.backtrace
85
+ raise e
72
86
  end
73
87
 
74
88
  end
@@ -41,7 +41,13 @@ module Redcar
41
41
  paths.collect!{|d| d.dup}
42
42
  while file = paths.shift
43
43
  begin
44
- stat = File.lstat(file)
44
+ if File.symlink? file
45
+ real_file = File.expand_path(File.join("..", File.readlink(file)), file)
46
+ real_file = File.expand_path(File.join("..", File.readlink(real_file)), real_file) while File.symlink? real_file
47
+ stat = File.lstat(real_file)
48
+ else
49
+ stat = File.lstat(file)
50
+ end
45
51
  unless file =~ /\.git|\.yardoc|\.svn/
46
52
  unless stat.directory?
47
53
  files[file.dup] = stat.mtime
@@ -143,7 +143,9 @@ module Redcar
143
143
  end
144
144
 
145
145
  def self.find_projects_containing_path(path)
146
- open_projects.select {|project| project.contains_path?(path) }
146
+ open_projects.select {|p|
147
+ p.contains_path?(path)
148
+ }.sort_by {|p| path.split(//).length-p.path.split(//).length}
147
149
  end
148
150
 
149
151
  def self.open_file(path, adapter=Adapters::Local.new)
@@ -180,6 +182,18 @@ module Redcar
180
182
  end
181
183
  end
182
184
 
185
+ # Opens a subproject in a new window
186
+ # @param [String] project_path the project path to fork
187
+ # @param [String] path the path of the directory to view
188
+ def self.open_subproject(project_path,path)
189
+ win = Redcar.app.focussed_window
190
+ win = Redcar.app.new_window if !win or Manager.in_window(win)
191
+ project = Redcar::Project::SubProject.new(project_path,path).tap do |p|
192
+ p.open(win) if p.ready?
193
+ win.title = "Subproject: #{File.basename(path)} in #{File.basename(project_path)}"
194
+ end
195
+ end
196
+
183
197
  # The currently focussed Project, or nil if none.
184
198
  #
185
199
  # @return [Project]
@@ -222,6 +236,17 @@ module Redcar
222
236
  found_path_args
223
237
  end
224
238
 
239
+ def self.update_tab_for_path(path,new_path=nil)
240
+ if tab = Manager.find_open_file_tab(path)
241
+ if new_path
242
+ mirror = Project::FileMirror.new(new_path)
243
+ tab.edit_view.document.mirror = mirror
244
+ else
245
+ tab.update_for_file_changes
246
+ end
247
+ end
248
+ end
249
+
225
250
  def self.open_untitled_path(path)
226
251
  begin
227
252
  if File.file?(path) and contents = File.read(path)
@@ -297,7 +322,6 @@ module Redcar
297
322
 
298
323
  group(:priority => 11) do
299
324
  item "Close Directory", Project::DirectoryCloseCommand
300
- item "Reveal in Project", Project::RevealInProjectCommand
301
325
  end
302
326
  end
303
327
  sub_menu "Project", :priority => 15 do
@@ -332,7 +356,8 @@ module Redcar
332
356
  item("in File Browser") { Project::OpenDirectoryInExplorerCommand.new(enclosing_dir).run }
333
357
  item("in Command Line") { Project::OpenDirectoryInCommandLineCommand.new(enclosing_dir).run }
334
358
  unless enclosing_dir == tree.tree_mirror.path
335
- item("as new Project") { Manager.open_project_for_path(enclosing_dir) }
359
+ item("as new Project") { Manager.open_project_for_path(enclosing_dir) }
360
+ item("as Subproject") { Manager.open_subproject(tree.tree_mirror.path,enclosing_dir) }
336
361
  end
337
362
  end
338
363
  end
@@ -0,0 +1,17 @@
1
+
2
+ module Redcar
3
+ class Project
4
+ class SubProject < Project
5
+
6
+ def initialize(project_path, path, adapter=Adapters::Local.new)
7
+ super(path,adapter)
8
+ @project=project_path
9
+ end
10
+
11
+ def config_files(glob)
12
+ file_glob = File.join("#{@project}/.redcar", glob)
13
+ super + Dir[file_glob]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,2 @@
1
+ var Path = WScript.Arguments(0);
2
+ WScript.CreateObject("Shell.Application").Namespace(0).ParseName(Path).InvokeVerb("delete");
@@ -0,0 +1,72 @@
1
+ module Redcar
2
+ class Project
3
+ module Trash
4
+ WINDOWS_SUPPORT_JS = File.expand_path("../recycle.js", __FILE__)
5
+
6
+ class << self
7
+ def recycle(file)
8
+ file = File.expand_path(file)
9
+ case Redcar.platform
10
+ when :windows then windows(file)
11
+ when :osx then osx(file)
12
+ when :linux then linux(file)
13
+ end
14
+ end
15
+
16
+ def osx(file)
17
+ system %{ osascript -e "tell application \\"Finder\\"
18
+ move (POSIX file \\"#{file}\\") to the trash
19
+ end tell" }
20
+ end
21
+
22
+ def windows(file)
23
+ system %{ cscript //nologo #{WINDOWS_SUPPORT_JS} "#{file}" }
24
+ end
25
+
26
+ # Move paths to FreeDesktop Trash can
27
+ # See <http://www.ramendik.ru/docs/trashspec.html>
28
+ def linux(file)
29
+ trashdir = File.expand_path("#{(ENV['XDG_DATA_HOME'] || '~/.local/share')}/Trash")
30
+ FileUtils.mkdir_p("#{trashdir}/files")
31
+ FileUtils.mkdir_p("#{trashdir}/info")
32
+
33
+ # Create unique filename
34
+ deleted_path = "#{trashdir}/files/#{File.basename(file)}"
35
+ while File.exist?(deleted_path)
36
+ deleted_path = "#{trashdir}/files/#{File.basename(file)}-#{Time.now.to_i}"
37
+ end
38
+
39
+ # Write trashinfo
40
+ trashinfo = "#{trashdir}/info/#{File.basename(deleted_path)}.trashinfo"
41
+ File.open(trashinfo, 'w') do |f|
42
+ f << "[Trash Info]\n"
43
+ f << "Path=#{file}\n"
44
+ f << "DeletionDate=#{DateTime.now.strftime('%Y%m%dT%H:%M:%S')}\n"
45
+ end
46
+
47
+ begin
48
+ FileUtils.mv(file, deleted_path)
49
+ rescue SystemCallError
50
+ # We cannot move - this usually happens if the file is on another partition
51
+ # The proper way to go would be to check for a partition-topdir .Trash directory
52
+ # We do not support this right now - the spec allows us to copy-and-remove in this case
53
+ if File.directory? file
54
+ # FileUtils.cp_r copies src-dir always _into_ dest-dir
55
+ # But we want src-dir's contents to be the contents of dest-dir
56
+ FileUtils.mkdir_p deleted_path
57
+ FileUtils.cp_r("#{file}/.", deleted_path)
58
+ else
59
+ FileUtils.cp(file, deleted_path)
60
+ end
61
+ FileUtils.rm_rf(file)
62
+ end
63
+
64
+ return true
65
+ rescue SystemCallError
66
+ FileUtils.rm(trashinfo) if File.exist? trashinfo
67
+ return false
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -30,6 +30,10 @@ describe FileList do
30
30
  @file_list.all_files.include?(relative_path("README")).should be_true
31
31
  @file_list.all_files.include?(relative_path("lib", "foo_lib.rb")).should be_true
32
32
  end
33
+
34
+ it "should return a list of files in a symlinked directory" do
35
+ @file_list.all_files.include?(relative_path("lib_symlink", "foo_lib.rb")).should be_true
36
+ end
33
37
  end
34
38
 
35
39
  describe "update information" do
@@ -0,0 +1,20 @@
1
+
2
+ @speedbar
3
+ Feature: Goto line command
4
+
5
+ Background:
6
+ Given I open a new edit tab
7
+
8
+ Scenario: Open goto line speedbar
9
+ When I replace the contents with "Foo\nBar\nBaz"
10
+ And I move the cursor to 0
11
+ And I run the command Redcar::Top::GotoLineCommand
12
+ Then the Redcar::Top::GotoLineCommand::Speedbar speedbar should be open
13
+
14
+ Scenario: Search for a word should select next occurrence
15
+ When I replace the contents with "Foo\nBar\nBaz"
16
+ And I move the cursor to 0
17
+ And I run the command Redcar::Top::GotoLineCommand
18
+ And I type "2" into the "line" field in the speedbar
19
+ And I press "Go" in the speedbar
20
+ Then the cursor should be on line 1
@@ -82,7 +82,12 @@ module Redcar
82
82
  class NewCommand < Command
83
83
 
84
84
  def execute
85
- tab = win.new_tab(Redcar::EditTab)
85
+ unless win.nil?
86
+ tab = win.new_tab(Redcar::EditTab)
87
+ else
88
+ window = Redcar.app.new_window
89
+ tab = window.new_tab(Redcar::EditTab)
90
+ end
86
91
  tab.title = "untitled"
87
92
  tab.focus
88
93
  tab
@@ -216,9 +221,31 @@ module Redcar
216
221
 
217
222
  class CloseTreeCommand < Command
218
223
  def execute
219
- treebook = Redcar.app.focussed_window.treebook
220
- tree = treebook.focussed_tree
221
- treebook.remove_tree(tree)
224
+ win = Redcar.app.focussed_window
225
+ if win and treebook = win.treebook
226
+ if tree = treebook.focussed_tree
227
+ if tree.tree_mirror.is_a?(Project::DirMirror)
228
+ Redcar::Application::Dialog.message_box(
229
+ "Use the \"Close Directory\" command to close this project"
230
+ )
231
+ else
232
+ treebook.remove_tree(tree)
233
+ end
234
+ end
235
+ end
236
+ end
237
+ end
238
+
239
+ class ToggleTreesCommand < Command
240
+ def execute
241
+ win = Redcar.app.focussed_window
242
+ if win and treebook = win.treebook
243
+ if win.trees_visible?
244
+ win.set_trees_visible(false)
245
+ else
246
+ win.set_trees_visible(true)
247
+ end
248
+ end
222
249
  end
223
250
  end
224
251
 
@@ -407,8 +434,22 @@ Redcar.environment: #{Redcar.environment}
407
434
  end
408
435
  end
409
436
 
410
- class MoveBottomCommand < DocumentCommand
437
+ class MoveNextLineCommand < DocumentCommand
438
+ def execute
439
+ doc = tab.edit_view.document
440
+ line_ix = doc.line_at_offset(doc.cursor_offset)
441
+ if line_ix == doc.line_count - 1
442
+ doc.cursor_offset = doc.length
443
+ else
444
+ doc.cursor_offset = doc.offset_at_line(line_ix + 1) - doc.delim.length
445
+ end
446
+ doc.ensure_visible(doc.cursor_offset)
447
+ doc.insert(doc.cursor_offset, "\n")
448
+
449
+ end
450
+ end
411
451
 
452
+ class MoveBottomCommand < DocumentCommand
412
453
  def execute
413
454
  doc.cursor_offset = doc.length
414
455
  doc.ensure_visible(doc.length)
@@ -550,30 +591,34 @@ Redcar.environment: #{Redcar.environment}
550
591
  cursor_line = doc.cursor_line
551
592
  cursor_line_offset = doc.cursor_line_offset
552
593
  diff = 0
553
- doc.controllers(AutoIndenter::DocumentController).first.disable do
554
- doc.selection_ranges.each do |range|
555
- doc.delete(range.begin - diff, range.count)
556
- diff += range.count
557
- end
558
- texts = Redcar.app.clipboard.last.dup
559
- texts.each_with_index do |text, i|
560
- line_ix = start_line + i
561
- if line_ix == doc.line_count
562
- doc.insert(doc.length, "\n" + " "*line_offset)
563
- else
564
- line = doc.get_line(line_ix).chomp
565
- if line.length < line_offset
566
- doc.insert(
567
- doc.offset_at_inner_end_of_line(line_ix),
568
- " "*(line_offset - line.length)
569
- )
594
+ doc.controllers(AutoPairer::DocumentController).first.disable do
595
+ doc.controllers(AutoIndenter::DocumentController).first.disable do
596
+ doc.controllers(AutoCompleter::DocumentController).first.start_modification
597
+ doc.selection_ranges.each do |range|
598
+ doc.delete(range.begin - diff, range.count)
599
+ diff += range.count
600
+ end
601
+ texts = Redcar.app.clipboard.last.dup
602
+ texts.each_with_index do |text, i|
603
+ line_ix = start_line + i
604
+ if line_ix == doc.line_count
605
+ doc.insert(doc.length, "\n" + " "*line_offset)
606
+ else
607
+ line = doc.get_line(line_ix).chomp
608
+ if line.length < line_offset
609
+ doc.insert(
610
+ doc.offset_at_inner_end_of_line(line_ix),
611
+ " "*(line_offset - line.length)
612
+ )
613
+ end
570
614
  end
615
+ doc.insert(
616
+ doc.offset_at_line(line_ix) + line_offset,
617
+ text
618
+ )
619
+ doc.cursor_offset = doc.offset_at_line(line_ix) + line_offset + text.length
571
620
  end
572
- doc.insert(
573
- doc.offset_at_line(line_ix) + line_offset,
574
- text
575
- )
576
- doc.cursor_offset = doc.offset_at_line(line_ix) + line_offset + text.length
621
+ doc.controllers(AutoCompleter::DocumentController).first.end_modification
577
622
  end
578
623
  end
579
624
  end
@@ -607,15 +652,15 @@ Redcar.environment: #{Redcar.environment}
607
652
  cursor_ix = doc.cursor_offset
608
653
  if doc.selection?
609
654
  start_ix = doc.selection_range.begin
610
- text = doc.selected_text
611
-
655
+ text = doc.selected_text
656
+
612
657
  sorted_text = text.split("\n").sort().join("\n")
613
658
  doc.replace_selection(sorted_text)
614
659
  doc.cursor_offset = cursor_ix
615
660
  end
616
661
  end
617
662
  end
618
-
663
+
619
664
  class DialogExample < Redcar::Command
620
665
  def execute
621
666
  builder = Menu::Builder.new do
@@ -641,23 +686,22 @@ Redcar.environment: #{Redcar.environment}
641
686
 
642
687
  button :go, "Go", "Return" do
643
688
  new_line_ix = line.value.to_i - 1
644
- if new_line_ix < doc.line_count and new_line_ix >= 0
645
- doc.cursor_offset = doc.offset_at_line(new_line_ix)
646
- doc.scroll_to_line(new_line_ix)
647
- win.close_speedbar
689
+ if new_line_ix < @doc.line_count and new_line_ix >= 0
690
+ @doc.cursor_offset = @doc.offset_at_line(new_line_ix)
691
+ @doc.scroll_to_line(new_line_ix)
692
+ @win.close_speedbar
648
693
  end
649
694
  end
650
695
 
651
- def initialize(command)
696
+ def initialize(command, win)
652
697
  @command = command
698
+ @doc = command.doc
699
+ @win = win
653
700
  end
654
-
655
- def doc; @command.doc; end
656
- def win; @command.send(:win); end
657
701
  end
658
702
 
659
703
  def execute
660
- @speedbar = GotoLineCommand::Speedbar.new(self)
704
+ @speedbar = GotoLineCommand::Speedbar.new(self, win)
661
705
  win.open_speedbar(@speedbar)
662
706
  end
663
707
  end
@@ -681,6 +725,12 @@ Redcar.environment: #{Redcar.environment}
681
725
  end
682
726
  end
683
727
 
728
+ class ToggleFullscreen < Command
729
+ def execute
730
+ Redcar.app.focussed_window.fullscreen = !Redcar.app.focussed_window.fullscreen
731
+ end
732
+ end
733
+
684
734
  class ToggleInvisibles < Redcar::EditTabCommand
685
735
  def execute
686
736
  EditView.show_invisibles = !EditView.show_invisibles?
@@ -743,11 +793,12 @@ Redcar.environment: #{Redcar.environment}
743
793
  #link "Cmd+Ctrl+O", Project::OpenRemoteCommand
744
794
  link "Cmd+S", Project::FileSaveCommand
745
795
  link "Cmd+Shift+S", Project::FileSaveAsCommand
746
- link "Cmd+Ctrl+R", Project::RevealInProjectCommand
747
796
  link "Cmd+W", CloseTabCommand
748
797
  link "Cmd+Shift+W", CloseWindowCommand
749
798
  link "Cmd+Q", QuitCommand
750
799
 
800
+ #link "Cmd+Return", MoveNextLineCommand
801
+
751
802
  link "Cmd+Shift+E", EditView::InfoSpeedbarCommand
752
803
  link "Cmd+Z", UndoCommand
753
804
  link "Cmd+Shift+Z", RedoCommand
@@ -766,6 +817,7 @@ Redcar.environment: #{Redcar.environment}
766
817
  link "Cmd+Shift+I", AutoIndenter::IndentCommand
767
818
  link "Cmd+L", GotoLineCommand
768
819
  link "Cmd+F", DocumentSearch::SearchForwardCommand
820
+ link "Cmd+H", DocumentSearch::SearchAndReplaceCommand
769
821
  #link "Cmd+Shift+F", DocumentSearch::RepeatPreviousSearchForwardCommand
770
822
  link "Cmd+Ctrl+F", DocumentSearch::SearchAndReplaceCommand
771
823
  link "Cmd+Shift+F", Redcar::FindInProject::OpenSearch
@@ -789,11 +841,13 @@ Redcar.environment: #{Redcar.environment}
789
841
  link "Cmd+Shift+]", SwitchTabUpCommand
790
842
  link "Ctrl+Shift+[", MoveTabDownCommand
791
843
  link "Ctrl+Shift+]", MoveTabUpCommand
844
+ link "F11", ToggleFullscreen
792
845
  link "Cmd+Alt+I", ToggleInvisibles
793
846
  link "Ctrl+R", Runnables::RunEditTabCommand
794
847
  link "Cmd+I", OutlineView::OpenOutlineViewCommand
795
848
 
796
849
  link "Ctrl+Shift+P", PrintScopeCommand
850
+ link "Cmd+Shift+H", ToggleTreesCommand
797
851
 
798
852
  link "Cmd+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
799
853
 
@@ -816,11 +870,12 @@ Redcar.environment: #{Redcar.environment}
816
870
  #link "Alt+Shift+O", Project::OpenRemoteCommand
817
871
  link "Ctrl+S", Project::FileSaveCommand
818
872
  link "Ctrl+Shift+S", Project::FileSaveAsCommand
819
- link "Ctrl+Shift+R", Project::RevealInProjectCommand
820
873
  link "Ctrl+W", CloseTabCommand
821
874
  link "Ctrl+Shift+W", CloseWindowCommand
822
875
  link "Ctrl+Q", QuitCommand
823
876
 
877
+ link "Ctrl+Enter", MoveNextLineCommand
878
+
824
879
  link "Ctrl+Shift+E", EditView::InfoSpeedbarCommand
825
880
  link "Ctrl+Z", UndoCommand
826
881
  link "Ctrl+Y", RedoCommand
@@ -839,6 +894,7 @@ Redcar.environment: #{Redcar.environment}
839
894
  link "Ctrl+Shift+[", AutoIndenter::IndentCommand
840
895
  link "Ctrl+L", GotoLineCommand
841
896
  link "Ctrl+F", DocumentSearch::SearchForwardCommand
897
+ link "Ctrl+H", DocumentSearch::SearchAndReplaceCommand
842
898
  link "F3", DocumentSearch::RepeatPreviousSearchForwardCommand
843
899
  link "Ctrl+Shift+F", Redcar::FindInProject::OpenSearch
844
900
  link "Ctrl+A", SelectAllCommand
@@ -862,16 +918,18 @@ Redcar.environment: #{Redcar.environment}
862
918
  link "Ctrl+Shift+P", PrintScopeCommand
863
919
 
864
920
  link "Ctrl+Alt+O", SwitchNotebookCommand
865
-
921
+ link "Ctrl+Shift+H", ToggleTreesCommand
866
922
  link "Ctrl+Page Up", SwitchTabDownCommand
867
923
  link "Ctrl+Page Down", SwitchTabUpCommand
868
924
  link "Ctrl+Shift+Page Up", MoveTabDownCommand
869
925
  link "Ctrl+Shift+Page Down", MoveTabUpCommand
870
926
  link "Ctrl+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
927
+ link "F11", ToggleFullscreen
871
928
  link "Ctrl+Alt+I", ToggleInvisibles
872
929
  link "Ctrl+I", OutlineView::OpenOutlineViewCommand
873
930
 
874
931
  link "Ctrl+Alt+S", Snippets::OpenSnippetExplorer
932
+
875
933
  #Textmate.attach_keybindings(self, :linux)
876
934
 
877
935
  # map SelectTab<number>Command
@@ -896,10 +954,9 @@ Redcar.environment: #{Redcar.environment}
896
954
  item "New Notebook", :command => NewNotebookCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "book--plus.png"), :barname => :edit
897
955
  item "Close Notebook", :command => CloseNotebookCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "book--minus.png"), :barname => :edit
898
956
  end
899
-
900
957
  end
901
958
 
902
- def self.menus
959
+ def self.menus(window)
903
960
  Menu::Builder.build do
904
961
  sub_menu "File", :priority => :first do
905
962
  group(:priority => :first) do
@@ -949,7 +1006,7 @@ Redcar.environment: #{Redcar.environment}
949
1006
  item "Toggle Block Selection", ToggleBlockSelectionCommand
950
1007
  end
951
1008
  end
952
-
1009
+
953
1010
  group(:priority => 40) do
954
1011
  sub_menu "Document Navigation" do
955
1012
  item "Goto Line", GotoLineCommand
@@ -982,6 +1039,8 @@ Redcar.environment: #{Redcar.environment}
982
1039
  item "Font Size", SelectFontSize
983
1040
  item "Theme", SelectTheme
984
1041
  end
1042
+ item "Toggle Tree Visibility", :command => ToggleTreesCommand
1043
+ item "Toggle Fullscreen", :command => ToggleFullscreen, :type => :check, :active => window ? window.fullscreen : false
985
1044
  separator
986
1045
  item "New Notebook", NewNotebookCommand
987
1046
  item "Close Notebook", CloseNotebookCommand
@@ -1015,7 +1074,7 @@ Redcar.environment: #{Redcar.environment}
1015
1074
  end
1016
1075
  end
1017
1076
  sub_menu "Help", :priority => :last do
1018
- group(:priority => :first) do
1077
+ group(:priority => :last) do
1019
1078
  item "About", AboutCommand
1020
1079
  item "New In This Version", ChangelogCommand
1021
1080
  end
@@ -1070,7 +1129,8 @@ Redcar.environment: #{Redcar.environment}
1070
1129
  s = Time.now
1071
1130
  Redcar::Project::Manager.start(args)
1072
1131
  puts "project start took #{Time.now - s}s"
1073
- Redcar.app.make_sure_at_least_one_window_open
1132
+ win = Redcar.app.make_sure_at_least_one_window_open
1133
+ win.close if win and args.include?("--no-window")
1074
1134
  end
1075
1135
  Redcar.update_gui do
1076
1136
  Swt.splash_screen.close if Swt.splash_screen