redcar 0.11.0dev → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +14 -1
- data/README.md +28 -8
- data/Rakefile +23 -18
- data/bin/redcar +9 -4
- data/lib/redcar.rb +42 -4
- data/lib/redcar/installer.rb +7 -2
- data/lib/redcar/logger.rb +64 -0
- data/lib/redcar/runner.rb +17 -8
- data/lib/redcar/usage.rb +2 -0
- data/plugins/application/features/step_definitions/tree_steps.rb +4 -4
- data/plugins/application/features/support/env.rb +6 -6
- data/plugins/application/lib/application.rb +31 -3
- data/plugins/application/lib/application/command.rb +6 -0
- data/plugins/application/lib/application/command/executor.rb +0 -1
- data/plugins/application/lib/application/commands/application_commands.rb +21 -0
- data/plugins/application/lib/application/commands/notebook_commands.rb +73 -0
- data/plugins/application/lib/application/commands/tab_commands.rb +105 -0
- data/plugins/application/lib/application/commands/treebook_commands.rb +117 -0
- data/plugins/application/lib/application/commands/window_commands.rb +68 -0
- data/plugins/{tree/lib → application/lib/application}/tree.rb +0 -4
- data/plugins/{tree/lib → application/lib/application}/tree/command.rb +0 -0
- data/plugins/{tree/lib → application/lib/application}/tree/controller.rb +0 -0
- data/plugins/{tree/lib → application/lib/application}/tree/mirror.rb +0 -0
- data/plugins/application/spec/application/keymap/builder_spec.rb +1 -1
- data/plugins/application/spec/application/menu/builder_spec.rb +2 -2
- data/plugins/application_swt/lib/application_swt.rb +4 -2
- data/plugins/application_swt/lib/swt/vtab_label.rb +6 -3
- data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +6 -3
- data/plugins/clojure/lib/clojure.rb +2 -2
- data/plugins/core/lib/core.rb +0 -4
- data/plugins/core/lib/core/gui.rb +2 -4
- data/plugins/core/lib/core/plugin/storage.rb +68 -21
- data/plugins/core/spec/core/base_storage_spec.rb +81 -0
- data/plugins/core/spec/core/shared_storage_spec.rb +49 -0
- data/plugins/core/spec/core/storage_spec.rb +13 -63
- data/plugins/declarations/lib/declarations.rb +3 -1
- data/plugins/document_search/features/replace.feature +29 -20
- data/plugins/document_search/lib/document_search/find_speedbar.rb +4 -1
- data/plugins/edit_view/features/indentation_commands.feature +6 -5
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +4 -4
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +7 -7
- data/plugins/edit_view/features/step_definitions/window_steps.rb +2 -2
- data/plugins/edit_view/lib/edit_view.rb +15 -1
- data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +7 -7
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +7 -6
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +1 -1
- data/plugins/groovy/lib/groovy.rb +3 -3
- data/plugins/groovy/lib/groovy/commands.rb +1 -1
- data/plugins/help/lib/help/view_controller.rb +5 -0
- data/plugins/help/views/index.html.erb +10 -1
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +1 -1
- data/plugins/html_view/features/support/env.rb +0 -15
- data/plugins/html_view/lib/html_view.rb +3 -4
- data/plugins/html_view/lib/html_view/commands.rb +1 -1
- data/plugins/key_bindings/lib/key_bindings.rb +34 -0
- data/plugins/key_bindings/plugin.rb +8 -0
- data/plugins/{tree → key_bindings}/spec/spec_helper.rb +0 -0
- data/plugins/line_tools/features/lower_text.feature +3 -4
- data/plugins/line_tools/lib/line_tools.rb +6 -5
- data/plugins/mirah/lib/mirah.rb +2 -2
- data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +5 -3
- data/plugins/project/features/open_directory_tree.feature +1 -1
- data/plugins/project/features/step_definitions/file_steps.rb +5 -5
- data/plugins/project/features/step_definitions/find_file_steps.rb +2 -3
- data/plugins/project/features/support/env.rb +4 -0
- data/plugins/project/lib/project.rb +15 -9
- data/plugins/project/lib/project/commands.rb +46 -16
- data/plugins/project/lib/project/dir_controller.rb +1 -1
- data/plugins/project/lib/project/dir_mirror.rb +3 -2
- data/plugins/project/lib/project/drb_service.rb +3 -1
- data/plugins/project/lib/project/file_list.rb +99 -21
- data/plugins/project/lib/project/find_file_dialog.rb +8 -24
- data/plugins/project/lib/project/manager.rb +68 -12
- data/plugins/project/lib/project/project_tree_controller.rb +1 -1
- data/plugins/project/plugin.rb +1 -2
- data/plugins/project_search/features/word_search.feature +1 -1
- data/plugins/project_search/lib/project_search.rb +16 -6
- data/plugins/project_search/lib/project_search/commands.rb +15 -28
- data/plugins/project_search/lib/project_search/hit.rb +4 -0
- data/plugins/project_search/lib/project_search/lucene_index.rb +14 -4
- data/plugins/project_search/lib/project_search/views/_file.html.erb +11 -11
- data/plugins/project_search/lib/project_search/word_search.rb +22 -4
- data/plugins/project_search/spec/project_search/word_search_spec.rb +2 -2
- data/plugins/redcar/redcar.rb +140 -588
- data/plugins/repl/features/step_definitions/repl_steps.rb +3 -3
- data/plugins/repl/features/support/fake_repl.rb +1 -1
- data/plugins/ruby/lib/ruby.rb +4 -4
- data/plugins/runnables/features/fixtures/alternate.ruby +1 -0
- data/plugins/runnables/features/fixtures/line_app.rb +1 -0
- data/plugins/runnables/features/fixtures/name_app.rb +1 -0
- data/plugins/runnables/features/fixtures/params_app.rb +1 -0
- data/plugins/runnables/features/fixtures/runnable_app.rb +1 -0
- data/plugins/runnables/lib/runnables.rb +21 -0
- data/plugins/runnables/lib/runnables/command_output_controller.rb +14 -9
- data/plugins/runnables/lib/runnables/output_processor.rb +4 -4
- data/plugins/runnables/lib/runnables/running_process_checker.rb +6 -6
- data/plugins/runnables/plugin.rb +1 -2
- data/plugins/scm/lib/scm.rb +18 -18
- data/plugins/scm/lib/scm/commit_mirror.rb +2 -2
- data/plugins/scm/lib/scm/scm_changes_controller.rb +1 -1
- data/plugins/scm_hg/lib/scm_hg.rb +1 -1
- data/plugins/snippets/lib/snippets/document_controller.rb +46 -40
- data/plugins/swt/lib/swt.rb +2 -0
- data/plugins/test_runner/lib/test_runner.rb +1 -0
- data/plugins/test_runner/lib/test_runner/jasmine_test_runner.rb +15 -0
- data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +21 -5
- data/plugins/textmate/lib/textmate.rb +5 -1
- data/plugins/textmate/lib/textmate/preference.rb +4 -0
- data/plugins/textmate/lib/textmate/snippet.rb +0 -2
- data/plugins/textmate/lib/textmate/tree_mirror.rb +6 -5
- data/plugins/textmate/plugin.rb +1 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/C.tmbundle/Syntaxes/C.plist +2 -2
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/Syntaxes/Cucumber_Plain_Text_Feature.tmLanguage +0 -4
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Cucumber.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +3 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Palm-WebOS-Development.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/SQL.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Scala.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/GNU_Smalltalk.tmPreferences +1 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/Preferences/MIST_Smalltalk_Format.tmPreferences +1 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Smalltalk.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Vala.tmbundle/info.plist +4 -2
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Webrat.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/YAML.tmbundle/Syntaxes/YAML.plist +1 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/groovy.tmbundle/info.plist +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Themes/Twilight.tmTheme +0 -2
- data/plugins/todo_list/lib/todo_list.rb +3 -3
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
- data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +1 -1
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +11 -4
- data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -1
- data/plugins/web_bookmarks/plugin.rb +1 -2
- metadata +29 -20
- data/plugins/core/lib/core/logger.rb +0 -28
- data/plugins/file_parser/lib/file_parser.rb +0 -125
- data/plugins/file_parser/plugin.rb +0 -7
- data/plugins/tree/plugin.rb +0 -9
data/plugins/project/plugin.rb
CHANGED
@@ -5,7 +5,7 @@ Feature: Word search
|
|
5
5
|
Background:
|
6
6
|
Given I will choose "plugins/project_search/spec/fixtures/project" from the "open_directory" dialog
|
7
7
|
And I open a directory
|
8
|
-
When I open the "
|
8
|
+
When I open the "Search" from the "Project" menu
|
9
9
|
And I wait "3" seconds
|
10
10
|
|
11
11
|
Scenario: See the search interface
|
@@ -15,7 +15,10 @@ class ProjectSearch
|
|
15
15
|
Redcar::Menu::Builder.build do
|
16
16
|
sub_menu "Project" do
|
17
17
|
group :priority => 1 do
|
18
|
-
item "Search", :command => ProjectSearch::WordSearchCommand
|
18
|
+
item "Word Search", :command => ProjectSearch::WordSearchCommand
|
19
|
+
end
|
20
|
+
sub_menu "Refresh", :priority => 31 do
|
21
|
+
item "Search index", :command => ProjectSearch::RefreshIndex
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -33,8 +36,8 @@ class ProjectSearch
|
|
33
36
|
|
34
37
|
def self.toolbars
|
35
38
|
Redcar::ToolBar::Builder.build do
|
36
|
-
item "Search", :command => WordSearchCommand,
|
37
|
-
:icon => File.join(Redcar::ICONS_DIRECTORY, "application-search-result.png"),
|
39
|
+
item "Word Search", :command => WordSearchCommand,
|
40
|
+
:icon => File.join(Redcar::ICONS_DIRECTORY, "application-search-result.png"),
|
38
41
|
:barname => :project
|
39
42
|
end
|
40
43
|
end
|
@@ -54,13 +57,20 @@ class ProjectSearch
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
57
|
-
|
58
|
-
|
60
|
+
def self.shared_storage
|
61
|
+
@shared_storage ||= begin
|
62
|
+
storage = Redcar::Plugin::SharedStorage.new('shared__ignored_files')
|
63
|
+
storage.set_or_update_default('ignored_file_patterns', [/tags$/, /\.log$/])
|
64
|
+
storage.save
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Lucene::Config.use do |config|
|
69
|
+
config[:store_on_file] = true
|
59
70
|
config[:storage_path] = ""
|
60
71
|
config[:id_field] = :id
|
61
72
|
end
|
62
73
|
|
63
|
-
|
64
74
|
def self.project_refresh_task_type
|
65
75
|
LuceneRefresh
|
66
76
|
end
|
@@ -1,5 +1,18 @@
|
|
1
1
|
|
2
2
|
class ProjectSearch
|
3
|
+
class RefreshIndex < Redcar::Command
|
4
|
+
sensitize :open_project
|
5
|
+
|
6
|
+
def execute
|
7
|
+
if project = Redcar::Project::Manager.focussed_project
|
8
|
+
if index = ProjectSearch.indexes[project.path]
|
9
|
+
index.delete
|
10
|
+
project.refresh
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
3
16
|
class WordSearchCommand < Redcar::Command
|
4
17
|
sensitize :open_project
|
5
18
|
|
@@ -12,7 +25,7 @@ class ProjectSearch
|
|
12
25
|
|
13
26
|
def execute
|
14
27
|
if project = Redcar::Project::Manager.focussed_project
|
15
|
-
if
|
28
|
+
if tab = find_open_instance
|
16
29
|
tab.html_view.refresh
|
17
30
|
tab.focus
|
18
31
|
else
|
@@ -31,32 +44,6 @@ class ProjectSearch
|
|
31
44
|
return
|
32
45
|
end
|
33
46
|
end
|
34
|
-
|
35
|
-
class RegexSearchCommand < Redcar::Command
|
36
|
-
sensitize :open_project
|
37
|
-
|
38
|
-
def execute
|
39
|
-
if Redcar::Project::Manager.focussed_project
|
40
|
-
if (tab = find_open_instance)
|
41
|
-
tab.html_view.controller = tab.html_view.controller # refresh
|
42
|
-
else
|
43
|
-
tab = win.new_tab(Redcar::HtmlTab)
|
44
|
-
tab.html_view.controller = ProjectSearch::RegexSearchController.new
|
45
|
-
end
|
46
|
-
tab.focus
|
47
|
-
else
|
48
|
-
# warning
|
49
|
-
Redcar::Application::Dialog.message_box("You need an open project to be able to use Find In Project!", :type => :error)
|
50
|
-
end
|
51
|
-
end
|
47
|
+
end
|
52
48
|
|
53
|
-
private
|
54
49
|
|
55
|
-
def find_open_instance
|
56
|
-
all_tabs = Redcar.app.focussed_window.notebooks.map { |nb| nb.tabs }.flatten
|
57
|
-
all_tabs.find do |t|
|
58
|
-
t.is_a?(Redcar::HtmlTab) && t.title == ProjectSearch::RegexSearchController.new.title
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -13,6 +13,16 @@ class ProjectSearch
|
|
13
13
|
File.join(@project.config_dir, 'lucene_last_updated')
|
14
14
|
end
|
15
15
|
|
16
|
+
def lucene_index_dir
|
17
|
+
File.join(@project.config_dir, "lucene")
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete
|
21
|
+
FileUtils.rm(timestamp_file_path)
|
22
|
+
FileUtils.rm_r(lucene_index_dir)
|
23
|
+
load
|
24
|
+
end
|
25
|
+
|
16
26
|
def load
|
17
27
|
@last_updated = Time.at(0)
|
18
28
|
if File.exist?(timestamp_file_path)
|
@@ -35,12 +45,12 @@ class ProjectSearch
|
|
35
45
|
changed_files = @project.file_list.changed_since(last_updated)
|
36
46
|
@last_updated = Time.now
|
37
47
|
changed_files.reject! do |fn, ts|
|
38
|
-
fn.index(@project.config_dir)
|
48
|
+
fn.index(@project.config_dir) or Redcar::Project::FileList.hide_file_path?(fn)
|
39
49
|
end
|
40
|
-
Lucene::Transaction.run do
|
41
|
-
@lucene_index ||= Lucene::Index.new(
|
50
|
+
Lucene::Transaction.run do
|
51
|
+
@lucene_index ||= Lucene::Index.new(lucene_index_dir)
|
42
52
|
begin
|
43
|
-
@lucene_index.field_infos[:contents][:store] = true
|
53
|
+
@lucene_index.field_infos[:contents][:store] = true
|
44
54
|
@lucene_index.field_infos[:contents][:tokenized] = true
|
45
55
|
changed_files.each do |fn, ts|
|
46
56
|
unless File.basename(fn)[0..0] == "." or fn.include?(".git")
|
47
57
|
contents = File.read(fn)
|
@@ -15,16 +15,16 @@
|
|
15
15
|
<% hits.each_with_index do |hit, i| %>
|
16
16
|
<% next_hit = hits[i + 1] %>
|
17
17
|
<% next_hit_line_num = next_hit ? next_hit.line_num : 100_000_000 %>
|
18
|
-
|
19
|
-
<% if @word_search.context? and last_matching_line_num and (
|
18
|
+
<% display_line_num = hit.line_num + 1%>
|
19
|
+
<% if @word_search.context? and last_matching_line_num and (display_line_num - last_matching_line_num) > (@word_search.context_size * 2) %>
|
20
20
|
<tr class="divider file_<%= file_num %>">
|
21
21
|
<td class="line_num">. . .</td>
|
22
22
|
<td class="text"> </td> <!-- extra space to ensure line-height is respected -->
|
23
23
|
</tr>
|
24
24
|
<% end %>
|
25
|
-
|
25
|
+
|
26
26
|
<% hit.pre_context.each_with_index do |context_line, i| %>
|
27
|
-
<% this_line_num =
|
27
|
+
<% this_line_num = display_line_num - @word_search.context_size + i %>
|
28
28
|
<% unless this_line_num <= last_displayed_line_num %>
|
29
29
|
<% line_index += 1 %>
|
30
30
|
<tr class="result file_<%= file_num %> line_<%= this_line_num %> <%= (line_index % 2 == 0 ? 'even' : 'odd') %>" data-href='<%= CGI::escapeHTML(file) %>' data-line_num='<%= this_line_num %>'>
|
@@ -34,17 +34,17 @@
|
|
34
34
|
</tr>
|
35
35
|
<% end %>
|
36
36
|
<% end %>
|
37
|
-
|
37
|
+
|
38
38
|
<% line_index += 1 %>
|
39
|
-
<% last_displayed_line_num =
|
40
|
-
<tr class="result file_<%= file_num %> line_<%=
|
41
|
-
<td class='line_num'><%=
|
39
|
+
<% last_displayed_line_num = display_line_num %>
|
40
|
+
<tr class="result file_<%= file_num %> line_<%= display_line_num %> <%= (line_index % 2 == 0 ? 'even' : 'odd') %>" data-href='<%= CGI::escapeHTML(file) %>' data-line_num='<%= display_line_num %>'>
|
41
|
+
<td class='line_num'><%= display_line_num %></td>
|
42
42
|
<% text = CGI.escapeHTML(hit.line).gsub(@word_search.regex) { "<span>#{$&}</span>" } %>
|
43
43
|
<td class='text'><pre><%= text.chomp + " " %></pre></td> <!-- extra space to ensure line-height is respected -->
|
44
44
|
</tr>
|
45
45
|
|
46
46
|
<% hit.post_context.each_with_index do |context_line, i| %>
|
47
|
-
<% this_line_num =
|
47
|
+
<% this_line_num = display_line_num + i + 1%>
|
48
48
|
<% unless this_line_num >= next_hit_line_num %>
|
49
49
|
<% last_displayed_line_num = this_line_num %>
|
50
50
|
<% line_index += 1 %>
|
@@ -55,6 +55,6 @@
|
|
55
55
|
</tr>
|
56
56
|
<% end %>
|
57
57
|
<% end %>
|
58
|
-
|
59
|
-
<% last_matching_line_num =
|
58
|
+
|
59
|
+
<% last_matching_line_num = display_line_num %>
|
60
60
|
<% end %>
|
@@ -49,6 +49,7 @@ class ProjectSearch
|
|
49
49
|
remove_hits << hit
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
52
53
|
hits_needing_post_context -= remove_hits
|
53
54
|
|
54
55
|
if matching_line?(line)
|
@@ -59,11 +60,10 @@ class ProjectSearch
|
|
59
60
|
hits_needing_post_context << hit
|
60
61
|
end
|
61
62
|
end
|
62
|
-
|
63
|
-
if pre_context.length
|
63
|
+
pre_context << line
|
64
|
+
if pre_context.length > context_size
|
64
65
|
pre_context.shift
|
65
66
|
end
|
66
|
-
pre_context << line
|
67
67
|
end
|
68
68
|
send_file_results(file_hits)
|
69
69
|
end
|
@@ -97,7 +97,25 @@ class ProjectSearch
|
|
97
97
|
new_doc_ids = index.find(:contents => bit.downcase).map {|doc| doc.id }
|
98
98
|
doc_ids = doc_ids ? (doc_ids & new_doc_ids) : new_doc_ids
|
99
99
|
end
|
100
|
-
doc_ids
|
100
|
+
doc_ids.reject {|doc_id| Redcar::Project::FileList.hide_file_path?(doc_id) }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def ignore_regexes
|
105
|
+
self.class.shared_storage['ignored_file_patterns']
|
106
|
+
end
|
107
|
+
|
108
|
+
def ignore_file?(filename)
|
109
|
+
if self.class.storage['ignore_file_patterns']
|
110
|
+
ignore_regexes.any? {|re| re =~ filename }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def inspect
|
115
|
+
if @results
|
116
|
+
"<ProjectSearch::WordSearch #{project.path} \"#{query_string}\" #{@results.length} hits>"
|
117
|
+
else
|
118
|
+
"<ProjectSearch::WordSearch #{project.path} \"#{query_string}\" ...>"
|
101
119
|
end
|
102
120
|
end
|
103
121
|
end
|
@@ -37,7 +37,7 @@ describe ProjectSearch::WordSearch do
|
|
37
37
|
results.length.should == 1
|
38
38
|
result = results.first
|
39
39
|
result.should be_an_instance_of(ProjectSearch::Hit)
|
40
|
-
result.file.should == project_search_fixture_dir + "/foo.txt"
|
40
|
+
File.expand_path(result.file).should == File.expand_path(project_search_fixture_dir + "/foo.txt")
|
41
41
|
result.line_num.should == 0
|
42
42
|
result.line("<b>", "</b>").should == "<b>Foo</b> Bar Baz"
|
43
43
|
end
|
@@ -68,7 +68,7 @@ describe ProjectSearch::WordSearch do
|
|
68
68
|
results.length.should == 1
|
69
69
|
result = results.first
|
70
70
|
result.should be_an_instance_of(ProjectSearch::Hit)
|
71
|
-
result.file.should == project_search_fixture_dir + "/foo.txt"
|
71
|
+
File.expand_path(result.file).should == File.expand_path(project_search_fixture_dir + "/foo.txt")
|
72
72
|
result.line_num.should == 2
|
73
73
|
result.line("<b>", "</b>").should == "<b>Corge</b> <b>Corge</b> <b>Corge</b>"
|
74
74
|
end
|
data/plugins/redcar/redcar.rb
CHANGED
@@ -52,41 +52,7 @@ module Redcar
|
|
52
52
|
end
|
53
53
|
|
54
54
|
module Top
|
55
|
-
class
|
56
|
-
|
57
|
-
def execute
|
58
|
-
check_for_modified_tabs_and_quit
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
def check_for_modified_tabs_and_quit
|
64
|
-
EditView::ModifiedTabsChecker.new(
|
65
|
-
Redcar.app.all_tabs.select {|t| t.is_a?(EditTab)},
|
66
|
-
"Save all before quitting?",
|
67
|
-
:none => lambda { check_for_running_processes_and_quit },
|
68
|
-
:continue => lambda { check_for_running_processes_and_quit },
|
69
|
-
:cancel => nil
|
70
|
-
).check
|
71
|
-
end
|
72
|
-
|
73
|
-
def check_for_running_processes_and_quit
|
74
|
-
Runnables::RunningProcessChecker.new(
|
75
|
-
Redcar.app.all_tabs.select {|t| t.is_a?(HtmlTab)},
|
76
|
-
"Kill all and quit?",
|
77
|
-
:none => lambda { quit },
|
78
|
-
:continue => lambda { quit },
|
79
|
-
:cancel => nil
|
80
|
-
).check
|
81
|
-
end
|
82
|
-
|
83
|
-
def quit
|
84
|
-
Project::Manager.open_projects.each {|pr| pr.close }
|
85
|
-
Redcar.app.quit
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class NewCommand < Command
|
55
|
+
class OpenNewEditTabCommand < Command
|
90
56
|
|
91
57
|
def execute
|
92
58
|
unless win.nil?
|
@@ -101,76 +67,6 @@ module Redcar
|
|
101
67
|
end
|
102
68
|
end
|
103
69
|
|
104
|
-
class NewNotebookCommand < Command
|
105
|
-
# sensitize :single_notebook
|
106
|
-
|
107
|
-
def execute
|
108
|
-
#unless win.notebooks.length > 1
|
109
|
-
win.create_notebook
|
110
|
-
# end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class NewWindowCommand < Command
|
115
|
-
|
116
|
-
def initialize(title=nil)
|
117
|
-
@title = title
|
118
|
-
end
|
119
|
-
|
120
|
-
def execute
|
121
|
-
window = Redcar.app.new_window
|
122
|
-
window.title = @title if @title
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
class CloseWindowCommand < Command
|
127
|
-
def initialize(window=nil)
|
128
|
-
@window = window
|
129
|
-
end
|
130
|
-
|
131
|
-
def execute
|
132
|
-
check_for_modified_tabs_and_close_window
|
133
|
-
quit_if_no_windows if [:linux, :windows].include?(Redcar.platform)
|
134
|
-
@window = nil
|
135
|
-
end
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def quit_if_no_windows
|
140
|
-
if Redcar.app.windows.length == 0
|
141
|
-
if Application.storage['stay_resident_after_last_window_closed'] && !(ARGV.include?("--multiple-instance"))
|
142
|
-
puts 'continuing to run to wait for incoming drb connections later'
|
143
|
-
else
|
144
|
-
QuitCommand.new.run
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def check_for_modified_tabs_and_close_window
|
150
|
-
EditView::ModifiedTabsChecker.new(
|
151
|
-
win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(EditTab)},
|
152
|
-
"Save all before closing the window?",
|
153
|
-
:none => lambda { check_for_running_processes_and_close_window },
|
154
|
-
:continue => lambda { check_for_running_processes_and_close_window },
|
155
|
-
:cancel => nil
|
156
|
-
).check
|
157
|
-
end
|
158
|
-
|
159
|
-
def check_for_running_processes_and_close_window
|
160
|
-
Runnables::RunningProcessChecker.new(
|
161
|
-
win.notebooks.map(&:tabs).flatten.select {|t| t.is_a?(HtmlTab)},
|
162
|
-
"Kill them and close the window?",
|
163
|
-
:none => lambda { win.close },
|
164
|
-
:continue => lambda { win.close },
|
165
|
-
:cancel => nil
|
166
|
-
).check
|
167
|
-
end
|
168
|
-
|
169
|
-
def win
|
170
|
-
@window || super
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
70
|
class GenerateWindowsMenu < Command
|
175
71
|
def initialize(builder)
|
176
72
|
@builder = builder
|
@@ -205,9 +101,15 @@ module Redcar
|
|
205
101
|
book.tabs.each_with_index do |tab,i|
|
206
102
|
num = i + 1
|
207
103
|
if num < 10
|
208
|
-
@builder.item
|
104
|
+
@builder.item("Tab #{num}: #{trim(tab.title)}",
|
105
|
+
:type => :radio,
|
106
|
+
:active => (tab == focussed_tab),
|
107
|
+
:command => Redcar::Application.const_get("SelectTab#{num}Command")
|
108
|
+
)
|
209
109
|
else
|
210
|
-
@builder.item("Tab #{num}: #{trim(tab.title)}",
|
110
|
+
@builder.item("Tab #{num}: #{trim(tab.title)}",
|
111
|
+
:type => :radio,
|
112
|
+
:active => (tab == focussed_tab)) { tab.focus }
|
211
113
|
end
|
212
114
|
end
|
213
115
|
if book = win.nonfocussed_notebook and book.tabs.any?
|
@@ -221,133 +123,9 @@ module Redcar
|
|
221
123
|
end
|
222
124
|
end
|
223
125
|
|
224
|
-
class FocusWindowCommand < Command
|
225
|
-
def initialize(window=nil)
|
226
|
-
@window = window
|
227
|
-
end
|
228
|
-
|
229
|
-
def execute
|
230
|
-
win.focus
|
231
|
-
@window = nil
|
232
|
-
end
|
233
|
-
|
234
|
-
def win
|
235
|
-
@window || super
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
class RotateNotebooksCommand < Command
|
240
|
-
sensitize :multiple_notebooks
|
241
|
-
|
242
|
-
def execute
|
243
|
-
win.rotate_notebooks
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
class CloseNotebookCommand < Command
|
248
|
-
sensitize :multiple_notebooks
|
249
|
-
|
250
|
-
def execute
|
251
|
-
unless win.notebooks.length == 1
|
252
|
-
win.close_notebook
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
class SwitchNotebookCommand < Command
|
258
|
-
sensitize :multiple_notebooks, :other_notebook_has_tab
|
259
|
-
|
260
|
-
def execute
|
261
|
-
new_notebook = win.nonfocussed_notebook
|
262
|
-
if new_notebook.focussed_tab
|
263
|
-
new_notebook.focussed_tab.focus
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
class MoveTabToOtherNotebookCommand < Command
|
269
|
-
sensitize :multiple_notebooks, :open_tab
|
270
|
-
|
271
|
-
def execute
|
272
|
-
current_notebook = tab.notebook
|
273
|
-
i = win.notebooks.index current_notebook
|
274
|
-
|
275
|
-
target_notebook = win.notebooks[ (i + 1) % win.notebooks.length ]
|
276
|
-
target_notebook.grab_tab_from(current_notebook, tab)
|
277
|
-
tab.focus
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
class OpenTreeFinderCommand < TreeCommand
|
282
|
-
|
283
|
-
def execute
|
284
|
-
if win = Redcar.app.focussed_window
|
285
|
-
if trees = win.treebook.trees and trees.any?
|
286
|
-
titles = []
|
287
|
-
trees.each {|t| titles << t.tree_mirror.title}
|
288
|
-
dialog = TreeFuzzyFilter.new(win,titles)
|
289
|
-
dialog.open
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
class TreeFuzzyFilter < FilterListDialog
|
295
|
-
|
296
|
-
def initialize(win,titles)
|
297
|
-
super()
|
298
|
-
@win = win
|
299
|
-
@titles = titles
|
300
|
-
end
|
301
|
-
|
302
|
-
def selected(text,ix)
|
303
|
-
if tree = @win.treebook.trees.detect do |tree|
|
304
|
-
tree.tree_mirror.title == text
|
305
|
-
end
|
306
|
-
if @win.treebook.focussed_tree == tree
|
307
|
-
@win.set_trees_visible(true) if not @win.trees_visible?
|
308
|
-
else
|
309
|
-
@win.treebook.focus_tree(tree)
|
310
|
-
end
|
311
|
-
tree.focus
|
312
|
-
close
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
def update_list(filter)
|
317
|
-
@titles.select do |t|
|
318
|
-
t.downcase.include?(filter.downcase)
|
319
|
-
end
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
class CloseTreeCommand < TreeCommand
|
325
|
-
def execute
|
326
|
-
win = Redcar.app.focussed_window
|
327
|
-
if win and treebook = win.treebook
|
328
|
-
if tree = treebook.focussed_tree
|
329
|
-
treebook.remove_tree(tree)
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
class ToggleTreesCommand < TreeCommand
|
336
|
-
def execute
|
337
|
-
win = Redcar.app.focussed_window
|
338
|
-
if win and treebook = win.treebook
|
339
|
-
if win.trees_visible?
|
340
|
-
win.set_trees_visible(false)
|
341
|
-
else
|
342
|
-
win.set_trees_visible(true)
|
343
|
-
end
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
126
|
class AboutCommand < Command
|
349
127
|
def execute
|
350
|
-
new_tab = Top::
|
128
|
+
new_tab = Top::OpenNewEditTabCommand.new.run
|
351
129
|
new_tab.document.text = <<-TXT
|
352
130
|
About: Redcar\nVersion: #{Redcar::VERSION}
|
353
131
|
Ruby Version: #{RUBY_VERSION}
|
@@ -362,7 +140,7 @@ Redcar.environment: #{Redcar.environment}
|
|
362
140
|
|
363
141
|
class ChangelogCommand < Command
|
364
142
|
def execute
|
365
|
-
new_tab = Top::
|
143
|
+
new_tab = Top::OpenNewEditTabCommand.new.run
|
366
144
|
new_tab.document.text = File.read(File.join(File.dirname(__FILE__), "..", "..", "CHANGES"))
|
367
145
|
new_tab.edit_view.reset_undo
|
368
146
|
new_tab.edit_view.document.set_modified(false)
|
@@ -382,135 +160,6 @@ Redcar.environment: #{Redcar.environment}
|
|
382
160
|
end
|
383
161
|
end
|
384
162
|
|
385
|
-
class CloseTabCommand < TabCommand
|
386
|
-
def initialize(tab=nil)
|
387
|
-
@tab = tab
|
388
|
-
end
|
389
|
-
|
390
|
-
def tab
|
391
|
-
@tab || super
|
392
|
-
end
|
393
|
-
|
394
|
-
def execute
|
395
|
-
if tab.is_a?(EditTab)
|
396
|
-
if tab.edit_view.document.modified?
|
397
|
-
tab.focus
|
398
|
-
result = Application::Dialog.message_box(
|
399
|
-
"This tab has unsaved changes. \n\nSave before closing?",
|
400
|
-
:buttons => :yes_no_cancel
|
401
|
-
)
|
402
|
-
case result
|
403
|
-
when :yes
|
404
|
-
tab.edit_view.document.save!
|
405
|
-
close_tab
|
406
|
-
when :no
|
407
|
-
close_tab
|
408
|
-
when :cancel
|
409
|
-
end
|
410
|
-
else
|
411
|
-
close_tab
|
412
|
-
end
|
413
|
-
elsif tab.is_a?(HtmlTab)
|
414
|
-
if tab.html_view.controller and message = tab.html_view.controller.ask_before_closing
|
415
|
-
tab.focus
|
416
|
-
result = Application::Dialog.message_box(
|
417
|
-
message,
|
418
|
-
:buttons => :yes_no_cancel
|
419
|
-
)
|
420
|
-
case result
|
421
|
-
when :yes
|
422
|
-
close_tab
|
423
|
-
when :no
|
424
|
-
close_tab
|
425
|
-
when :cancel
|
426
|
-
end
|
427
|
-
else
|
428
|
-
close_tab
|
429
|
-
end
|
430
|
-
else
|
431
|
-
close_tab
|
432
|
-
end
|
433
|
-
@tab = nil
|
434
|
-
end
|
435
|
-
|
436
|
-
private
|
437
|
-
|
438
|
-
def close_tab
|
439
|
-
win = tab.notebook.window
|
440
|
-
tab.close
|
441
|
-
# this will break a lot of features:
|
442
|
-
#if win.all_tabs.empty? and not Project::Manager.in_window(win)
|
443
|
-
# win.close
|
444
|
-
#end
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
class CloseAll < Redcar::Command
|
449
|
-
def execute
|
450
|
-
window = Redcar.app.focussed_window
|
451
|
-
tabs = window.all_tabs
|
452
|
-
tabs.each do |t|
|
453
|
-
Redcar::Top::CloseTabCommand.new(t).run
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|
457
|
-
|
458
|
-
class CloseOthers < Redcar::Command
|
459
|
-
def execute
|
460
|
-
window = Redcar.app.focussed_window
|
461
|
-
current_tab = Redcar.app.focussed_notebook_tab
|
462
|
-
tabs = window.all_tabs
|
463
|
-
tabs.each do |t|
|
464
|
-
unless t == current_tab
|
465
|
-
Redcar::Top::CloseTabCommand.new(t).run
|
466
|
-
end
|
467
|
-
end
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
class SwitchTreeDownCommand < TreeCommand
|
472
|
-
|
473
|
-
def execute
|
474
|
-
win = Redcar.app.focussed_window
|
475
|
-
win.treebook.switch_down
|
476
|
-
end
|
477
|
-
end
|
478
|
-
|
479
|
-
class SwitchTreeUpCommand < TreeCommand
|
480
|
-
|
481
|
-
def execute
|
482
|
-
win = Redcar.app.focussed_window
|
483
|
-
win.treebook.switch_up
|
484
|
-
end
|
485
|
-
end
|
486
|
-
|
487
|
-
class SwitchTabDownCommand < TabCommand
|
488
|
-
|
489
|
-
def execute
|
490
|
-
win.focussed_notebook.switch_down
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
class SwitchTabUpCommand < TabCommand
|
495
|
-
|
496
|
-
def execute
|
497
|
-
win.focussed_notebook.switch_up
|
498
|
-
end
|
499
|
-
end
|
500
|
-
|
501
|
-
class MoveTabUpCommand < TabCommand
|
502
|
-
|
503
|
-
def execute
|
504
|
-
win.focussed_notebook.move_up
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
class MoveTabDownCommand < TabCommand
|
509
|
-
|
510
|
-
def execute
|
511
|
-
win.focussed_notebook.move_down
|
512
|
-
end
|
513
|
-
end
|
514
163
|
|
515
164
|
class UndoCommand < EditTabCommand
|
516
165
|
sensitize :undoable
|
@@ -802,22 +451,6 @@ Redcar.environment: #{Redcar.environment}
|
|
802
451
|
end
|
803
452
|
end
|
804
453
|
|
805
|
-
class DialogExample < Redcar::Command
|
806
|
-
def execute
|
807
|
-
builder = Menu::Builder.new do
|
808
|
-
item("Foo") { p :foo }
|
809
|
-
item("Bar") { p :bar }
|
810
|
-
separator
|
811
|
-
sub_menu "Baz" do
|
812
|
-
item("Qux") { p :qx }
|
813
|
-
item("Quux") { p :quux }
|
814
|
-
item("Corge") { p :corge }
|
815
|
-
end
|
816
|
-
end
|
817
|
-
win.popup_menu(builder.menu)
|
818
|
-
end
|
819
|
-
end
|
820
|
-
|
821
454
|
class GotoLineCommand < Redcar::EditTabCommand
|
822
455
|
|
823
456
|
class Speedbar < Redcar::Speedbar
|
@@ -856,79 +489,6 @@ Redcar.environment: #{Redcar.environment}
|
|
856
489
|
end
|
857
490
|
end
|
858
491
|
|
859
|
-
class TreebookWidthCommand < Command
|
860
|
-
sensitize :open_trees
|
861
|
-
|
862
|
-
def increment
|
863
|
-
raise "Please implement me!"
|
864
|
-
end
|
865
|
-
|
866
|
-
def execute
|
867
|
-
if win = Redcar.app.focussed_window
|
868
|
-
if increment > 0
|
869
|
-
win.adjust_treebook_width(true)
|
870
|
-
else
|
871
|
-
win.adjust_treebook_width(false)
|
872
|
-
end
|
873
|
-
end
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
|
-
["In","De"].each do |prefix|
|
878
|
-
const_set("#{prefix}creaseTreebookWidthCommand", Class.new(TreebookWidthCommand)).class_eval do
|
879
|
-
define_method :increment do
|
880
|
-
prefix == "In" ? 1 : -1
|
881
|
-
end
|
882
|
-
end
|
883
|
-
end
|
884
|
-
|
885
|
-
class EnlargeNotebookCommand < Command
|
886
|
-
sensitize :multiple_notebooks
|
887
|
-
def index
|
888
|
-
raise "Please define me!"
|
889
|
-
end
|
890
|
-
|
891
|
-
def execute
|
892
|
-
if win = Redcar.app.focussed_window
|
893
|
-
win.enlarge_notebook(index)
|
894
|
-
end
|
895
|
-
end
|
896
|
-
end
|
897
|
-
|
898
|
-
["First","Second"].each do |book|
|
899
|
-
const_set("Enlarge#{book}NotebookCommand", Class.new(EnlargeNotebookCommand)).class_eval do
|
900
|
-
define_method :index do
|
901
|
-
book == "First" ? 0 : 1
|
902
|
-
end
|
903
|
-
end
|
904
|
-
end
|
905
|
-
|
906
|
-
# define commands from SelectTab1Command to SelectTab9Command
|
907
|
-
(1..9).each do |tab_num|
|
908
|
-
const_set("SelectTab#{tab_num}Command", Class.new(Redcar::TabCommand)).class_eval do
|
909
|
-
define_method :execute do
|
910
|
-
notebook = Redcar.app.focussed_window_notebook
|
911
|
-
notebook.tabs[tab_num-1].focus if notebook.tabs[tab_num-1]
|
912
|
-
end
|
913
|
-
end
|
914
|
-
end
|
915
|
-
|
916
|
-
class ResetNotebookWidthsCommand < Command
|
917
|
-
sensitize :multiple_notebooks
|
918
|
-
|
919
|
-
def execute
|
920
|
-
if win = Redcar.app.focussed_window
|
921
|
-
win.reset_notebook_widths
|
922
|
-
end
|
923
|
-
end
|
924
|
-
end
|
925
|
-
|
926
|
-
class ToggleFullscreen < Command
|
927
|
-
def execute
|
928
|
-
Redcar.app.focussed_window.fullscreen = !Redcar.app.focussed_window.fullscreen
|
929
|
-
end
|
930
|
-
end
|
931
|
-
|
932
492
|
class ToggleInvisibles < Redcar::EditTabCommand
|
933
493
|
def execute
|
934
494
|
EditView.show_invisibles = !EditView.show_invisibles?
|
@@ -941,14 +501,6 @@ Redcar.environment: #{Redcar.environment}
|
|
941
501
|
end
|
942
502
|
end
|
943
503
|
|
944
|
-
class ToggleToolbar < Command
|
945
|
-
|
946
|
-
def execute
|
947
|
-
Redcar.app.toggle_show_toolbar
|
948
|
-
Redcar.app.refresh_toolbar!
|
949
|
-
end
|
950
|
-
end
|
951
|
-
|
952
504
|
class SelectNewFont < EditTabCommand
|
953
505
|
def execute
|
954
506
|
Redcar::EditView::SelectFontDialog.new.open
|
@@ -1010,20 +562,20 @@ Redcar.environment: #{Redcar.environment}
|
|
1010
562
|
|
1011
563
|
def self.keymaps
|
1012
564
|
osx = Redcar::Keymap.build("main", :osx) do
|
1013
|
-
link "Cmd+N",
|
1014
|
-
link "Cmd+Shift+N",
|
1015
|
-
link "Cmd+Alt+N",
|
1016
|
-
link "Cmd+O", Project::
|
565
|
+
link "Cmd+N", OpenNewEditTabCommand
|
566
|
+
link "Cmd+Shift+N", Application::OpenNewNotebookCommand
|
567
|
+
link "Cmd+Alt+N", Application::OpenNewWindowCommand
|
568
|
+
link "Cmd+O", Project::OpenFileCommand
|
1017
569
|
link "Cmd+U", Project::FileReloadCommand
|
1018
570
|
link "Cmd+Shift+O", Project::DirectoryOpenCommand
|
1019
571
|
link "Cmd+Alt+Ctrl+P", Project::FindRecentCommand
|
1020
572
|
#link "Cmd+Ctrl+O", Project::OpenRemoteCommand
|
1021
|
-
link "Cmd+S", Project::
|
1022
|
-
link "Cmd+Shift+S", Project::
|
1023
|
-
link "Cmd+W", CloseTabCommand
|
1024
|
-
link "Cmd+Shift+W", CloseWindowCommand
|
1025
|
-
link "Alt+Shift+W", CloseTreeCommand
|
1026
|
-
link "Cmd+Q", QuitCommand
|
573
|
+
link "Cmd+S", Project::SaveFileCommand
|
574
|
+
link "Cmd+Shift+S", Project::SaveFileAsCommand
|
575
|
+
link "Cmd+W", Application::CloseTabCommand
|
576
|
+
link "Cmd+Shift+W", Application::CloseWindowCommand
|
577
|
+
link "Alt+Shift+W", Application::CloseTreeCommand
|
578
|
+
link "Cmd+Q", Application::QuitCommand
|
1027
579
|
|
1028
580
|
#link "Cmd+Return", MoveNextLineCommand
|
1029
581
|
|
@@ -1062,29 +614,28 @@ Redcar.environment: #{Redcar.environment}
|
|
1062
614
|
link "Ctrl+Shift+^", SortLinesCommand
|
1063
615
|
|
1064
616
|
link "Cmd+T", Project::FindFileCommand
|
1065
|
-
link "Cmd+Shift+Alt+O", MoveTabToOtherNotebookCommand
|
1066
|
-
link "Cmd+Alt+O", SwitchNotebookCommand
|
1067
|
-
link "Alt+Shift+[", SwitchTreeUpCommand
|
1068
|
-
link "Alt+Shift+]", SwitchTreeDownCommand
|
1069
|
-
link "Cmd+Shift+[", SwitchTabDownCommand
|
1070
|
-
link "Cmd+Shift+]", SwitchTabUpCommand
|
1071
|
-
link "Ctrl+Shift+[", MoveTabDownCommand
|
1072
|
-
link "Ctrl+Shift+]", MoveTabUpCommand
|
1073
|
-
link "Cmd+Shift++", ToggleFullscreen
|
1074
|
-
link "Cmd+Shift+T", OpenTreeFinderCommand
|
1075
|
-
link "Alt+Shift+J", IncreaseTreebookWidthCommand
|
1076
|
-
link "Alt+Shift+H", DecreaseTreebookWidthCommand
|
1077
|
-
link "Cmd+Shift+>",
|
1078
|
-
link "Cmd+Shift
|
1079
|
-
link "Cmd+Shift
|
1080
|
-
link "
|
1081
|
-
link "Alt+Shift+N", CloseNotebookCommand
|
617
|
+
link "Cmd+Shift+Alt+O", Application::MoveTabToOtherNotebookCommand
|
618
|
+
link "Cmd+Alt+O", Application::SwitchNotebookCommand
|
619
|
+
link "Alt+Shift+[", Application::SwitchTreeUpCommand
|
620
|
+
link "Alt+Shift+]", Application::SwitchTreeDownCommand
|
621
|
+
link "Cmd+Shift+[", Application::SwitchTabDownCommand
|
622
|
+
link "Cmd+Shift+]", Application::SwitchTabUpCommand
|
623
|
+
link "Ctrl+Shift+[", Application::MoveTabDownCommand
|
624
|
+
link "Ctrl+Shift+]", Application::MoveTabUpCommand
|
625
|
+
link "Cmd+Shift++", Application::ToggleFullscreen
|
626
|
+
link "Cmd+Shift+T", Application::OpenTreeFinderCommand
|
627
|
+
link "Alt+Shift+J", Application::IncreaseTreebookWidthCommand
|
628
|
+
link "Alt+Shift+H", Application::DecreaseTreebookWidthCommand
|
629
|
+
link "Cmd+Shift+>", Application::EnlargeNotebookCommand
|
630
|
+
link "Cmd+Shift+L", Application::ResetNotebookWidthsCommand
|
631
|
+
link "Cmd+Shift+:", Application::RotateNotebooksCommand
|
632
|
+
link "Alt+Shift+N", Application::CloseNotebookCommand
|
1082
633
|
link "Cmd+Alt+I", ToggleInvisibles
|
1083
634
|
link "Cmd++", IncreaseFontSize
|
1084
635
|
link "Cmd+-", DecreaseFontSize
|
1085
636
|
|
1086
637
|
link "Ctrl+Shift+P", PrintScopeCommand
|
1087
|
-
link "Cmd+Shift+H", ToggleTreesCommand
|
638
|
+
link "Cmd+Shift+H", Application::ToggleTreesCommand
|
1088
639
|
|
1089
640
|
# link "Cmd+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
|
1090
641
|
|
@@ -1093,25 +644,25 @@ Redcar.environment: #{Redcar.environment}
|
|
1093
644
|
|
1094
645
|
# map SelectTab<number>Command
|
1095
646
|
(1..9).each do |tab_num|
|
1096
|
-
link "Cmd+#{tab_num}",
|
647
|
+
link "Cmd+#{tab_num}", Application.const_get("SelectTab#{tab_num}Command")
|
1097
648
|
end
|
1098
649
|
|
1099
650
|
end
|
1100
651
|
|
1101
652
|
linwin = Redcar::Keymap.build("main", [:linux, :windows]) do
|
1102
|
-
link "Ctrl+N",
|
1103
|
-
link "Ctrl+Shift+N",
|
1104
|
-
link "Ctrl+Alt+N",
|
1105
|
-
link "Ctrl+O", Project::
|
653
|
+
link "Ctrl+N", OpenNewEditTabCommand
|
654
|
+
link "Ctrl+Shift+N", Application::OpenNewNotebookCommand
|
655
|
+
link "Ctrl+Alt+N", Application::OpenNewWindowCommand
|
656
|
+
link "Ctrl+O", Project::OpenFileCommand
|
1106
657
|
link "Ctrl+Shift+O", Project::DirectoryOpenCommand
|
1107
658
|
link "Ctrl+Alt+Shift+P", Project::FindRecentCommand
|
1108
659
|
#link "Alt+Shift+O", Project::OpenRemoteCommand
|
1109
|
-
link "Ctrl+S", Project::
|
1110
|
-
link "Ctrl+Shift+S", Project::
|
1111
|
-
link "Ctrl+W", CloseTabCommand
|
1112
|
-
link "Ctrl+Shift+W", CloseWindowCommand
|
1113
|
-
link "Alt+Shift+W", CloseTreeCommand
|
1114
|
-
link "Ctrl+Q", QuitCommand
|
660
|
+
link "Ctrl+S", Project::SaveFileCommand
|
661
|
+
link "Ctrl+Shift+S", Project::SaveFileAsCommand
|
662
|
+
link "Ctrl+W", Application::CloseTabCommand
|
663
|
+
link "Ctrl+Shift+W", Application::CloseWindowCommand
|
664
|
+
link "Alt+Shift+W", Application::CloseTreeCommand
|
665
|
+
link "Ctrl+Q", Application::QuitCommand
|
1115
666
|
|
1116
667
|
link "Ctrl+Enter", MoveNextLineCommand
|
1117
668
|
|
@@ -1141,7 +692,7 @@ Redcar.environment: #{Redcar.environment}
|
|
1141
692
|
link "Escape", AutoCompleter::AutoCompleteCommand
|
1142
693
|
link "Ctrl+Escape", AutoCompleter::MenuAutoCompleterCommand
|
1143
694
|
link "Ctrl+Space", AutoCompleter::AutoCompleteCommand
|
1144
|
-
|
695
|
+
|
1145
696
|
link "Ctrl+Shift+Space", AutoCompleter::MenuAutoCompleterCommand
|
1146
697
|
|
1147
698
|
link "Ctrl+U", EditView::UpcaseTextCommand
|
@@ -1153,28 +704,26 @@ Redcar.environment: #{Redcar.environment}
|
|
1153
704
|
link "Ctrl+Shift+^", SortLinesCommand
|
1154
705
|
|
1155
706
|
link "Ctrl+T", Project::FindFileCommand
|
1156
|
-
link "Ctrl+Shift+Alt+O", MoveTabToOtherNotebookCommand
|
707
|
+
link "Ctrl+Shift+Alt+O", Application::MoveTabToOtherNotebookCommand
|
1157
708
|
|
1158
709
|
link "Ctrl+Shift+P", PrintScopeCommand
|
1159
710
|
|
1160
|
-
link "Ctrl+Alt+O", SwitchNotebookCommand
|
1161
|
-
link "Ctrl+Shift+H", ToggleTreesCommand
|
1162
|
-
link "Alt+Page Up", SwitchTreeUpCommand
|
1163
|
-
link "Alt+Page Down", SwitchTreeDownCommand
|
1164
|
-
link "Ctrl+Page Up", SwitchTabDownCommand
|
1165
|
-
link "Ctrl+Page Down", SwitchTabUpCommand
|
1166
|
-
link "Ctrl+Shift+Page Up", MoveTabDownCommand
|
1167
|
-
link "Ctrl+Shift+Page Down", MoveTabUpCommand
|
1168
|
-
link "Ctrl+Shift+T", OpenTreeFinderCommand
|
1169
|
-
link "Alt+Shift+J", IncreaseTreebookWidthCommand
|
1170
|
-
link "Alt+Shift+H", DecreaseTreebookWidthCommand
|
1171
|
-
link "Ctrl+Shift+>",
|
1172
|
-
link "Ctrl+Shift
|
1173
|
-
link "Ctrl+Shift
|
1174
|
-
link "
|
1175
|
-
link "
|
1176
|
-
# link "Ctrl+Shift+R", PluginManagerUi::ReloadLastReloadedCommand
|
1177
|
-
link "F11", ToggleFullscreen
|
711
|
+
link "Ctrl+Alt+O", Application::SwitchNotebookCommand
|
712
|
+
link "Ctrl+Shift+H", Application::ToggleTreesCommand
|
713
|
+
link "Alt+Page Up", Application::SwitchTreeUpCommand
|
714
|
+
link "Alt+Page Down", Application::SwitchTreeDownCommand
|
715
|
+
link "Ctrl+Page Up", Application::SwitchTabDownCommand
|
716
|
+
link "Ctrl+Page Down", Application::SwitchTabUpCommand
|
717
|
+
link "Ctrl+Shift+Page Up", Application::MoveTabDownCommand
|
718
|
+
link "Ctrl+Shift+Page Down", Application::MoveTabUpCommand
|
719
|
+
link "Ctrl+Shift+T", Application::OpenTreeFinderCommand
|
720
|
+
link "Alt+Shift+J", Application::IncreaseTreebookWidthCommand
|
721
|
+
link "Alt+Shift+H", Application::DecreaseTreebookWidthCommand
|
722
|
+
link "Ctrl+Shift+>", Application::EnlargeNotebookCommand
|
723
|
+
link "Ctrl+Shift+L", Application::ResetNotebookWidthsCommand
|
724
|
+
link "Ctrl+Shift+:", Application::RotateNotebooksCommand
|
725
|
+
link "Alt+Shift+N", Application::CloseNotebookCommand
|
726
|
+
link "F11", Application::ToggleFullscreen
|
1178
727
|
link "Ctrl+Alt+I", ToggleInvisibles
|
1179
728
|
link "Ctrl++", IncreaseFontSize
|
1180
729
|
link "Ctrl+-", DecreaseFontSize
|
@@ -1185,7 +734,7 @@ Redcar.environment: #{Redcar.environment}
|
|
1185
734
|
|
1186
735
|
# map SelectTab<number>Command
|
1187
736
|
(1..9).each do |tab_num|
|
1188
|
-
link "Alt+#{tab_num}",
|
737
|
+
link "Alt+#{tab_num}", Application.const_get("SelectTab#{tab_num}Command")
|
1189
738
|
end
|
1190
739
|
|
1191
740
|
end
|
@@ -1195,15 +744,15 @@ Redcar.environment: #{Redcar.environment}
|
|
1195
744
|
|
1196
745
|
def self.toolbars
|
1197
746
|
ToolBar::Builder.build do
|
1198
|
-
item "New File", :command =>
|
1199
|
-
item "Open File", :command => Project::
|
747
|
+
item "New File", :command => OpenNewEditTabCommand, :icon => :new, :barname => :core
|
748
|
+
item "Open File", :command => Project::OpenFileCommand, :icon => :open, :barname => :core
|
1200
749
|
item "Open Directory", :command => Project::DirectoryOpenCommand, :icon => :open_dir, :barname => :core
|
1201
|
-
item "Save File", :command => Project::
|
1202
|
-
item "Save File As", :command => Project::
|
750
|
+
item "Save File", :command => Project::SaveFileCommand, :icon => :save, :barname => :core
|
751
|
+
item "Save File As", :command => Project::SaveFileAsCommand, :icon => :save_as, :barname => :core
|
1203
752
|
item "Undo", :command => UndoCommand, :icon => :undo, :barname => :core
|
1204
753
|
item "Redo", :command => RedoCommand, :icon => :redo, :barname => :core
|
1205
|
-
item "New Notebook", :command =>
|
1206
|
-
item "Close Notebook", :command => CloseNotebookCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "book--minus.png"), :barname => :edit
|
754
|
+
item "New Notebook", :command => Application::OpenNewNotebookCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "book--plus.png"), :barname => :edit
|
755
|
+
item "Close Notebook", :command => Application::CloseNotebookCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "book--minus.png"), :barname => :edit
|
1207
756
|
end
|
1208
757
|
end
|
1209
758
|
|
@@ -1211,22 +760,22 @@ Redcar.environment: #{Redcar.environment}
|
|
1211
760
|
Menu::Builder.build do
|
1212
761
|
sub_menu "File", :priority => :first do
|
1213
762
|
group(:priority => :first) do
|
1214
|
-
item "New",
|
1215
|
-
item "New Window",
|
763
|
+
item "New", OpenNewEditTabCommand
|
764
|
+
item "New Window", Application::OpenNewWindowCommand
|
1216
765
|
end
|
1217
766
|
|
1218
767
|
group(:priority => 10) do
|
1219
768
|
separator
|
1220
|
-
item "Close Tab", CloseTabCommand
|
1221
|
-
item "Close Tree", CloseTreeCommand
|
1222
|
-
item "Close Window", CloseWindowCommand
|
1223
|
-
item "Close Others", CloseOthers
|
1224
|
-
item "Close All", CloseAll
|
769
|
+
item "Close Tab", Application::CloseTabCommand
|
770
|
+
item "Close Tree", Application::CloseTreeCommand
|
771
|
+
item "Close Window", Application::CloseWindowCommand
|
772
|
+
item "Close Others", Application::CloseOthers
|
773
|
+
item "Close All", Application::CloseAll
|
1225
774
|
end
|
1226
775
|
|
1227
776
|
group(:priority => :last) do
|
1228
777
|
separator
|
1229
|
-
item "Quit", QuitCommand
|
778
|
+
item "Quit", Application::QuitCommand
|
1230
779
|
end
|
1231
780
|
end
|
1232
781
|
sub_menu "Edit", :priority => 5 do
|
@@ -1282,7 +831,7 @@ Redcar.environment: #{Redcar.environment}
|
|
1282
831
|
group(:priority => 10) do
|
1283
832
|
item "Task Manager", TaskManager::OpenCommand
|
1284
833
|
separator
|
1285
|
-
|
834
|
+
item "Print Scope Tree", PrintScopeTreeCommand
|
1286
835
|
item "Print Scope at Cursor", PrintScopeCommand
|
1287
836
|
end
|
1288
837
|
end
|
@@ -1297,49 +846,48 @@ Redcar.environment: #{Redcar.environment}
|
|
1297
846
|
end
|
1298
847
|
group(:priority => 10) do
|
1299
848
|
separator
|
1300
|
-
item "Toggle Fullscreen", :command => ToggleFullscreen, :type => :check, :active => window ? window.fullscreen : false
|
849
|
+
item "Toggle Fullscreen", :command => Application::ToggleFullscreen, :type => :check, :active => window ? window.fullscreen : false
|
1301
850
|
end
|
1302
851
|
group(:priority => 15) do
|
1303
852
|
separator
|
1304
853
|
sub_menu "Trees" do
|
1305
|
-
item "Open Tree Finder", OpenTreeFinderCommand
|
1306
|
-
item "Toggle Tree Visibility", ToggleTreesCommand
|
1307
|
-
item "Increase Tree Width", IncreaseTreebookWidthCommand
|
1308
|
-
item "Decrease Tree Width", DecreaseTreebookWidthCommand
|
854
|
+
item "Open Tree Finder", Application::OpenTreeFinderCommand
|
855
|
+
item "Toggle Tree Visibility", Application::ToggleTreesCommand
|
856
|
+
item "Increase Tree Width", Application::IncreaseTreebookWidthCommand
|
857
|
+
item "Decrease Tree Width", Application::DecreaseTreebookWidthCommand
|
1309
858
|
separator
|
1310
|
-
item "Previous Tree", SwitchTreeUpCommand
|
1311
|
-
item "Next Tree", SwitchTreeDownCommand
|
859
|
+
item "Previous Tree", Application::SwitchTreeUpCommand
|
860
|
+
item "Next Tree", Application::SwitchTreeDownCommand
|
1312
861
|
end
|
1313
862
|
lazy_sub_menu "Windows" do
|
1314
863
|
GenerateWindowsMenu.new(self).run
|
1315
864
|
end
|
1316
865
|
sub_menu "Notebooks" do
|
1317
|
-
item "New Notebook",
|
1318
|
-
item "Close Notebook", CloseNotebookCommand
|
1319
|
-
item "Rotate Notebooks", RotateNotebooksCommand
|
1320
|
-
item "Move Tab To Other Notebook", MoveTabToOtherNotebookCommand
|
1321
|
-
item "Switch Notebooks", SwitchNotebookCommand
|
866
|
+
item "New Notebook", Application::OpenNewNotebookCommand
|
867
|
+
item "Close Notebook", Application::CloseNotebookCommand
|
868
|
+
item "Rotate Notebooks", Application::RotateNotebooksCommand
|
869
|
+
item "Move Tab To Other Notebook", Application::MoveTabToOtherNotebookCommand
|
870
|
+
item "Switch Notebooks", Application::SwitchNotebookCommand
|
1322
871
|
separator
|
1323
|
-
item "Enlarge First Notebook",
|
1324
|
-
item "
|
1325
|
-
item "Reset Notebook Widths", ResetNotebookWidthsCommand
|
872
|
+
item "Enlarge First Notebook", Application::EnlargeNotebookCommand
|
873
|
+
item "Reset Notebook Widths", Application::ResetNotebookWidthsCommand
|
1326
874
|
end
|
1327
875
|
sub_menu "Tabs" do
|
1328
|
-
item "Previous Tab",
|
1329
|
-
item "Next Tab",
|
1330
|
-
item "Move Tab Left",
|
1331
|
-
item "Move Tab Right", MoveTabUpCommand
|
876
|
+
item "Previous Tab", Application::SwitchTabDownCommand
|
877
|
+
item "Next Tab", Application::SwitchTabUpCommand
|
878
|
+
item "Move Tab Left", Application::MoveTabDownCommand
|
879
|
+
item "Move Tab Right", Application::MoveTabUpCommand
|
1332
880
|
separator
|
1333
881
|
# GenerateTabsMenu.new(self).run # TODO: find a way to maintain keybindings with lazy menus
|
1334
882
|
item "Focussed Notebook", ShowTitle
|
1335
883
|
(1..9).each do |num|
|
1336
|
-
item "Tab #{num}",
|
884
|
+
item "Tab #{num}", Application.const_get("SelectTab#{num}Command")
|
1337
885
|
end
|
1338
886
|
end
|
1339
887
|
end
|
1340
888
|
group(:priority => :last) do
|
1341
889
|
separator
|
1342
|
-
item "Show Toolbar", :command => ToggleToolbar, :type => :check, :active => Redcar.app.show_toolbar?
|
890
|
+
item "Show Toolbar", :command => Application::ToggleToolbar, :type => :check, :active => Redcar.app.show_toolbar?
|
1343
891
|
item "Show Invisibles", :command => ToggleInvisibles, :type => :check, :active => EditView.show_invisibles?
|
1344
892
|
item "Show Line Numbers", :command => ToggleLineNumbers, :type => :check, :active => EditView.show_line_numbers?
|
1345
893
|
end
|
@@ -1370,19 +918,19 @@ Redcar.environment: #{Redcar.environment}
|
|
1370
918
|
end
|
1371
919
|
|
1372
920
|
def tab_close(tab)
|
1373
|
-
CloseTabCommand.new(tab).run
|
921
|
+
Application::CloseTabCommand.new(tab).run
|
1374
922
|
end
|
1375
923
|
|
1376
924
|
def window_close(win)
|
1377
|
-
CloseWindowCommand.new(win).run
|
925
|
+
Application::CloseWindowCommand.new(win).run
|
1378
926
|
end
|
1379
927
|
|
1380
928
|
def application_close(app)
|
1381
|
-
QuitCommand.new.run
|
929
|
+
Application::QuitCommand.new.run
|
1382
930
|
end
|
1383
931
|
|
1384
932
|
def window_focus(win)
|
1385
|
-
FocusWindowCommand.new(win).run
|
933
|
+
Application::FocusWindowCommand.new(win).run
|
1386
934
|
end
|
1387
935
|
end
|
1388
936
|
|
@@ -1391,36 +939,40 @@ Redcar.environment: #{Redcar.environment}
|
|
1391
939
|
end
|
1392
940
|
|
1393
941
|
def self.start(args=[])
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
942
|
+
begin
|
943
|
+
Redcar.log.info("startup milestone: loading plugins took #{Time.now - Redcar.process_start_time}")
|
944
|
+
Redcar.update_gui do
|
945
|
+
Application.start
|
946
|
+
ApplicationSWT.start
|
947
|
+
EditViewSWT.start
|
948
|
+
Swt.splash_screen.inc(1) if Swt.splash_screen
|
949
|
+
s = Time.now
|
950
|
+
if Redcar.gui
|
951
|
+
Redcar.app.controller = ApplicationSWT.new(Redcar.app)
|
952
|
+
end
|
953
|
+
Redcar.app.refresh_menu!
|
954
|
+
Redcar.app.load_sensitivities
|
955
|
+
Redcar.log.info("initializing gui took #{Time.now - s}s")
|
956
|
+
end
|
957
|
+
Redcar.update_gui do
|
958
|
+
Swt.splash_screen.close if Swt.splash_screen
|
959
|
+
win = Redcar.app.make_sure_at_least_one_window_open
|
960
|
+
win.close if win and args.include?("--no-window")
|
961
|
+
Redcar.log.info("startup milestone: window open #{Time.now - Redcar.process_start_time}")
|
962
|
+
Redcar::Project::Manager.start(args)
|
963
|
+
Redcar.log.info("startup milestone: project open #{Time.now - Redcar.process_start_time}")
|
964
|
+
end
|
965
|
+
Redcar.load_useful_libraries
|
966
|
+
Redcar.log.info("startup milestone: complete: #{Time.now - Redcar.process_start_time}")
|
967
|
+
if args.include?("--compute-textmate-cache-and-quit")
|
968
|
+
Redcar::Textmate.all_bundles
|
969
|
+
exit
|
970
|
+
end
|
971
|
+
rescue => e
|
972
|
+
Redcar.log.error("error in startup: #{e.inspect}")
|
973
|
+
e.backtrace.each do |line|
|
974
|
+
Redcar.log.error(line)
|
1404
975
|
end
|
1405
|
-
Redcar.app.refresh_menu!
|
1406
|
-
Redcar.app.load_sensitivities
|
1407
|
-
puts "initializing gui took #{Time.now - s}s"
|
1408
|
-
end
|
1409
|
-
Redcar.update_gui do
|
1410
|
-
Swt.splash_screen.inc(2) if Swt.splash_screen
|
1411
|
-
s = Time.now
|
1412
|
-
Redcar::Project::Manager.start(args)
|
1413
|
-
puts "project start took #{Time.now - s}s"
|
1414
|
-
win = Redcar.app.make_sure_at_least_one_window_open
|
1415
|
-
win.close if win and args.include?("--no-window")
|
1416
|
-
end
|
1417
|
-
Redcar.update_gui do
|
1418
|
-
Swt.splash_screen.close if Swt.splash_screen
|
1419
|
-
end
|
1420
|
-
puts "start time: #{Time.now - $redcar_process_start_time}"
|
1421
|
-
if args.include?("--compute-textmate-cache-and-quit")
|
1422
|
-
Redcar::Textmate.all_bundles
|
1423
|
-
exit
|
1424
976
|
end
|
1425
977
|
end
|
1426
978
|
end
|