redcar 0.9.2 → 0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +34 -4
- data/Rakefile +2 -1
- data/lib/redcar.rb +3 -3
- data/lib/redcar/installer.rb +2 -3
- data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
- data/plugins/application/features/step_definitions/key_steps.rb +18 -0
- data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
- data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
- data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
- data/plugins/application/features/support/env.rb +39 -5
- data/plugins/application/features/support/fake_event.rb +12 -0
- data/plugins/application/lib/application.rb +5 -6
- data/plugins/application/lib/application/dialog.rb +53 -10
- data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
- data/plugins/application/lib/application/keymap.rb +10 -8
- data/plugins/application/lib/application/menu.rb +38 -16
- data/plugins/application/lib/application/treebook.rb +30 -0
- data/plugins/application/lib/application/window.rb +20 -2
- data/plugins/application/spec/application/command/executor_spec.rb +1 -0
- data/plugins/application/spec/application/menu_spec.rb +26 -26
- data/plugins/application/spec/application/treebook_spec.rb +6 -6
- data/plugins/application/spec/spec_helper.rb +10 -1
- data/plugins/application_swt/lib/application_swt.rb +25 -3
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
- data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
- data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
- data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
- data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
- data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
- data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
- data/plugins/application_swt/lib/application_swt/window.rb +85 -57
- data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
- data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
- data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
- data/plugins/auto_completer/lib/auto_completer.rb +10 -42
- data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
- data/plugins/clojure/lib/clojure.rb +33 -0
- data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
- data/plugins/clojure/plugin.rb +9 -0
- data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
- data/plugins/clojure/spec/spec_helper.rb +5 -0
- data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
- data/plugins/{repl → clojure}/vendor/dummy +0 -0
- data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
- data/plugins/connection_manager/lib/connection_manager.rb +13 -13
- data/plugins/declarations/lib/declarations.rb +17 -6
- data/plugins/document_search/features/find.feature +389 -0
- data/plugins/document_search/features/find_and_replace.feature +723 -0
- data/plugins/document_search/features/replace.feature +69 -62
- data/plugins/document_search/lib/document_search.rb +81 -64
- data/plugins/document_search/lib/document_search/commands.rb +258 -0
- data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
- data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
- data/plugins/document_search/lib/document_search/query_options.rb +45 -0
- data/plugins/edit_view/features/case_change.feature +9 -5
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
- data/plugins/edit_view/lib/edit_view.rb +15 -12
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
- data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
- data/plugins/edit_view/lib/edit_view/document.rb +129 -99
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
- data/plugins/encryption/encryption.rb +2 -0
- data/plugins/find-in-project/lib/find_in_project.rb +3 -5
- data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
- data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
- data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
- data/plugins/groovy/lib/groovy.rb +38 -0
- data/plugins/groovy/lib/groovy/commands.rb +10 -0
- data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
- data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
- data/plugins/groovy/plugin.rb +5 -4
- data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
- data/plugins/groovy/spec/spec_helper.rb +5 -0
- data/plugins/html_view/assets/json2.js +476 -0
- data/plugins/html_view/lib/html_view.rb +1 -0
- data/plugins/java/features/fixtures/test.java +0 -0
- data/plugins/java/features/support/env.rb +27 -0
- data/plugins/java/features/syntax_check_java.feature +86 -0
- data/plugins/java/lib/syntax_check/java.rb +86 -0
- data/plugins/java/plugin.rb +7 -0
- data/plugins/javascript/features/fixtures/test2.js +5 -0
- data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
- data/plugins/javascript/features/support/env.rb +14 -0
- data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
- data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
- data/plugins/line_tools/features/trim_line.feature +49 -0
- data/plugins/line_tools/lib/line_tools.rb +5 -1
- data/plugins/mirah/README +7 -0
- data/plugins/mirah/features/fixtures/test.mirah +2 -0
- data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
- data/plugins/mirah/lib/mirah.rb +43 -0
- data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
- data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
- data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
- data/plugins/mirah/plugin.rb +8 -0
- data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
- data/plugins/mirah/spec/spec_helper.rb +5 -0
- data/plugins/mirah/vendor/mirah-parser.jar +0 -0
- data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
- data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
- data/plugins/project/features/find_file.feature +40 -16
- data/plugins/project/features/highlight_focussed_tab.feature +16 -10
- data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
- data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
- data/plugins/project/features/support/env.rb +5 -0
- data/plugins/project/lib/project/commands.rb +8 -1
- data/plugins/project/lib/project/dir_controller.rb +4 -1
- data/plugins/project/lib/project/find_file_dialog.rb +16 -12
- data/plugins/project/lib/project/manager.rb +30 -1
- data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
- data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
- data/plugins/project_search/vendor/lucene/Gemfile +9 -0
- data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
- data/plugins/project_search/vendor/lucene/LICENSE +19 -0
- data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
- data/plugins/project_search/vendor/lucene/Rakefile +35 -0
- data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
- data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
- data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
- data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
- data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
- data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
- data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
- data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
- data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
- data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
- data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
- data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
- data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
- data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
- data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
- data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
- data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
- data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
- data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
- data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
- data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
- data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
- data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
- data/plugins/redcar/features/alter_font_size.feature +25 -0
- data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
- data/plugins/redcar/redcar.rb +256 -43
- data/plugins/repl/features/command_editing.feature +55 -0
- data/plugins/repl/features/command_history.feature +75 -0
- data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
- data/plugins/repl/features/support/env.rb +24 -0
- data/plugins/repl/features/support/fake_repl.rb +16 -0
- data/plugins/repl/lib/repl.rb +17 -74
- data/plugins/repl/lib/repl/repl_command.rb +20 -0
- data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
- data/plugins/repl/lib/repl/repl_tab.rb +131 -6
- data/plugins/repl/plugin.rb +1 -1
- data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
- data/plugins/repl/spec/spec_helper.rb +1 -1
- data/plugins/repl_swt/lib/repl_swt.rb +7 -0
- data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
- data/plugins/repl_swt/plugin.rb +8 -0
- data/plugins/ruby/lib/ruby.rb +35 -0
- data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
- data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
- data/plugins/ruby/plugin.rb +5 -4
- data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
- data/plugins/ruby/spec/spec_helper.rb +5 -0
- data/plugins/runnables/lib/runnables.rb +2 -0
- data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
- data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
- data/plugins/runnables/views/command_output.html.erb +3 -2
- data/plugins/scm/lib/scm.rb +4 -2
- data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
- data/plugins/scm_git/lib/scm_git.rb +136 -107
- data/plugins/scm_git/lib/scm_git/change.rb +28 -19
- data/plugins/snippets/lib/snippets/explorer.rb +2 -2
- data/plugins/swt/lib/swt/full_swt.rb +1 -0
- data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
- data/plugins/syntax_check/features/support/env.rb +3 -0
- data/plugins/syntax_check/lib/syntax_check.rb +71 -5
- data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
- data/plugins/test_runner/lib/test_runner.rb +39 -0
- data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
- data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
- data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
- data/plugins/test_runner/plugin.rb +8 -0
- data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
- data/plugins/test_runner/spec/spec_helper.rb +5 -0
- data/plugins/textmate/lib/textmate.rb +12 -2
- data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
- data/plugins/todo_list/lib/todo_list.rb +7 -0
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
- data/plugins/tree/lib/tree.rb +4 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
- metadata +137 -22
- data/plugins/document_search/features/search.feature +0 -163
- data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
- data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
- data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
- data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
- data/plugins/ruby/README +0 -6
@@ -0,0 +1,85 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
# A type of dialog for displaying a list inside a tab. Example uses include
|
4
|
+
# selection dialogs for code completion or dynamically opening files based on
|
5
|
+
# tab content.
|
6
|
+
# Modeless List dialogs can also add sub-lists, by implementing the 'previous_list'
|
7
|
+
# and/or 'next_list' methods, which are called when a ARROW_LEFT or ARROW_RIGHT
|
8
|
+
# key event is generated.
|
9
|
+
#
|
10
|
+
# Subclasses should implement the 'selected' method,
|
11
|
+
# and optionally 'previous_list' and 'next_list' if applicable.
|
12
|
+
class ModelessListDialog
|
13
|
+
include Redcar::Model
|
14
|
+
include Redcar::Observable
|
15
|
+
|
16
|
+
def initialize(close_on_lost_focus=true)
|
17
|
+
@close_on_lost_focus = close_on_lost_focus
|
18
|
+
self.controller = Redcar.gui.controller_for(self).new(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Set the size of the list dialog. The width is measured in pixels
|
22
|
+
# and the height in rows of text
|
23
|
+
def set_size(width,height)
|
24
|
+
notify_listeners(:set_size, width,height)
|
25
|
+
end
|
26
|
+
# Set the location of the list dialog relative to an offset in a tab
|
27
|
+
def set_location(offset)
|
28
|
+
notify_listeners(:set_location,offset)
|
29
|
+
end
|
30
|
+
|
31
|
+
def open
|
32
|
+
notify_listeners(:open)
|
33
|
+
end
|
34
|
+
|
35
|
+
def close
|
36
|
+
notify_listeners(:close)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Whether to close the list dialog when focus is lost
|
40
|
+
def close_on_lost_focus
|
41
|
+
@close_on_lost_focus
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get a 'previous' list, where applicable, based on the
|
45
|
+
# currently selected item in the list
|
46
|
+
#
|
47
|
+
# @return [Array<String>] list items
|
48
|
+
def previous_list
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get a 'next' list, where applicable, based on the
|
52
|
+
# currently selected item in the list
|
53
|
+
#
|
54
|
+
# @return [Array<String>] list items
|
55
|
+
def next_list
|
56
|
+
end
|
57
|
+
|
58
|
+
# Update the items in the dialog list
|
59
|
+
#
|
60
|
+
# @param [Array<String>] items
|
61
|
+
def update_list(items)
|
62
|
+
notify_listeners :update_list, items
|
63
|
+
end
|
64
|
+
|
65
|
+
# Do an action, based on the index of the selected item
|
66
|
+
def selected(index)
|
67
|
+
p "'#{select(index)}' (at index #{index}) was selected!"
|
68
|
+
close
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get the text of an item at an index
|
72
|
+
#
|
73
|
+
# @return [String]
|
74
|
+
def select(index)
|
75
|
+
self.controller.select index
|
76
|
+
end
|
77
|
+
|
78
|
+
# The index of the currently selected text
|
79
|
+
#
|
80
|
+
# @return [Integer]
|
81
|
+
def selection_index
|
82
|
+
self.controller.selection_index
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -4,36 +4,38 @@ module Redcar
|
|
4
4
|
def self.build(name, platform, &block)
|
5
5
|
Builder.new(name, platform, &block).keymap
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
attr_reader :name, :platforms
|
9
9
|
attr_accessor :map
|
10
|
-
|
10
|
+
|
11
11
|
def initialize(name, platforms)
|
12
12
|
@name, @platforms = name, [*platforms]
|
13
13
|
@map = {}
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def link(key_string, command)
|
17
17
|
@map[key_string] = command
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def command(key_string)
|
21
21
|
@map[key_string]
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def command_to_key(command)
|
25
25
|
@map.invert[command]
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def length
|
29
29
|
@map.length
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def merge(other)
|
33
33
|
keymap = Keymap.new(@name, @platforms)
|
34
|
+
(@map.keys & other.map.keys).each do |key|
|
35
|
+
puts "conflicting keybinding #{key}: #{@map[key].inspect} is being overwritten by #{other.map[key].inspect}"
|
36
|
+
end
|
34
37
|
keymap.map = @map.merge(other.map)
|
35
38
|
keymap
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
39
|
-
|
@@ -3,43 +3,55 @@ module Redcar
|
|
3
3
|
class Menu
|
4
4
|
include Enumerable
|
5
5
|
include Redcar::Model
|
6
|
-
|
6
|
+
|
7
7
|
# Default priority for all menu's and items if they aren't explicitly provided
|
8
8
|
DEFAULT_PRIORITY = 50
|
9
|
-
|
9
|
+
|
10
|
+
# Default mnemonic values for primary menus
|
11
|
+
MNEMONICS = {
|
12
|
+
"File" => "&File",
|
13
|
+
"Edit" => "&Edit",
|
14
|
+
"Project" => "&Project",
|
15
|
+
"Debug" => "&Debug",
|
16
|
+
"View" => "&View",
|
17
|
+
"Plugins" => "P&lugins",
|
18
|
+
"Bundles" => "&Bundles",
|
19
|
+
"Help" => "&Help"
|
20
|
+
}
|
21
|
+
|
10
22
|
attr_reader :text, :entries, :priority
|
11
|
-
|
23
|
+
|
12
24
|
# A Menu will initially have nothing in it.
|
13
25
|
def initialize(text=nil, options={})
|
14
|
-
@text, @entries, @priority = text
|
26
|
+
@text, @entries, @priority = Menu.parse(text), [], options[:priority]
|
15
27
|
end
|
16
|
-
|
28
|
+
|
17
29
|
# Iterate over each entry, sorted by priority
|
18
30
|
def each
|
19
31
|
sorted = {:first => [], :last => []}
|
20
32
|
entries.each {|e| (sorted[e.priority || Menu::DEFAULT_PRIORITY] ||= []) << e}
|
21
|
-
|
33
|
+
|
22
34
|
# Get the nasty Symbols out of the hash so we can sort it
|
23
35
|
first = sorted.delete(:first)
|
24
36
|
last = sorted.delete(:last)
|
25
|
-
|
37
|
+
|
26
38
|
# Yield up the results
|
27
39
|
first.each {|val| yield val }
|
28
40
|
sorted.keys.sort.each {|i| sorted[i].each {|val| yield val }}
|
29
41
|
last.each {|val| yield val }
|
30
42
|
end
|
31
|
-
|
43
|
+
|
32
44
|
# Add a Redcar::MenuItem or a Redcar::Menu
|
33
45
|
def <<(entry)
|
34
46
|
entries << entry
|
35
47
|
self
|
36
48
|
end
|
37
|
-
|
49
|
+
|
38
50
|
# Number of entries in the menu
|
39
51
|
def length
|
40
52
|
entries.length
|
41
53
|
end
|
42
|
-
|
54
|
+
|
43
55
|
# Fetch the sub_menu with the given name
|
44
56
|
#
|
45
57
|
# @param [String]
|
@@ -47,16 +59,16 @@ module Redcar
|
|
47
59
|
def sub_menu(text)
|
48
60
|
detect {|e| e.text == text and e.is_a?(Menu) }
|
49
61
|
end
|
50
|
-
|
62
|
+
|
51
63
|
def entry(text)
|
52
64
|
detect {|e| e.text == text }
|
53
65
|
end
|
54
|
-
|
66
|
+
|
55
67
|
# Append items and sub_menus using the same syntax as Menu::Builder
|
56
68
|
def build(&block)
|
57
69
|
Menu::Builder.new(self, &block)
|
58
70
|
end
|
59
|
-
|
71
|
+
|
60
72
|
def ==(other)
|
61
73
|
return false unless length == other.length
|
62
74
|
return false unless text == other.text
|
@@ -65,15 +77,15 @@ module Redcar
|
|
65
77
|
end
|
66
78
|
true
|
67
79
|
end
|
68
|
-
|
80
|
+
|
69
81
|
def is_unique?
|
70
82
|
false
|
71
83
|
end
|
72
|
-
|
84
|
+
|
73
85
|
def lazy_text?
|
74
86
|
false
|
75
87
|
end
|
76
|
-
|
88
|
+
|
77
89
|
# Merge two Menu trees together. Modifies this Menu.
|
78
90
|
#
|
79
91
|
# @param [Menu] another Menu
|
@@ -91,5 +103,15 @@ module Redcar
|
|
91
103
|
end
|
92
104
|
end
|
93
105
|
end
|
106
|
+
|
107
|
+
# Get menu text from a string, adding mnemonics where applicable
|
108
|
+
def self.parse(menu_text)
|
109
|
+
menu_text = "" unless menu_text
|
110
|
+
if Redcar.platform != :osx and mnemonic = MNEMONICS[menu_text]
|
111
|
+
mnemonic
|
112
|
+
else
|
113
|
+
menu_text
|
114
|
+
end
|
115
|
+
end
|
94
116
|
end
|
95
117
|
end
|
@@ -17,6 +17,7 @@ module Redcar
|
|
17
17
|
@trees << tree
|
18
18
|
@focussed_tree = tree
|
19
19
|
notify_listeners(:tree_added, tree)
|
20
|
+
tree.focus
|
20
21
|
Redcar.app.repeat_event(:tree_added) if Redcar.app
|
21
22
|
end
|
22
23
|
|
@@ -27,6 +28,7 @@ module Redcar
|
|
27
28
|
return if @focussed_tree == tree
|
28
29
|
@focussed_tree = tree
|
29
30
|
notify_listeners(:tree_focussed, tree)
|
31
|
+
tree.focus
|
30
32
|
end
|
31
33
|
|
32
34
|
# Remove a tree from this treebook
|
@@ -43,6 +45,34 @@ module Redcar
|
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
48
|
+
def switch_down
|
49
|
+
if @trees.any?
|
50
|
+
if @focussed_tree
|
51
|
+
index = @trees.index @focussed_tree
|
52
|
+
else
|
53
|
+
index = -1
|
54
|
+
end
|
55
|
+
new_tree_index = index + 1
|
56
|
+
new_tree_index = 0 if new_tree_index < 0 or new_tree_index >= @trees.size
|
57
|
+
tree = @trees[new_tree_index]
|
58
|
+
focus_tree(tree) if tree
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def switch_up
|
63
|
+
if @trees.any?
|
64
|
+
if @focussed_tree
|
65
|
+
index = @trees.index @focussed_tree
|
66
|
+
else
|
67
|
+
index = 1
|
68
|
+
end
|
69
|
+
new_tree_index = index - 1
|
70
|
+
new_tree_index = @trees.size - 1 if new_tree_index < 0 or new_tree_index >= @trees.size
|
71
|
+
tree = @trees[new_tree_index]
|
72
|
+
focus_tree(tree) if tree
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
46
76
|
private
|
47
77
|
|
48
78
|
# Tell the Treebook that this tree has been focussed in the GUI.
|
@@ -68,7 +68,7 @@ module Redcar
|
|
68
68
|
#
|
69
69
|
# @events [(:new_notebook, notebook)]
|
70
70
|
def create_notebook
|
71
|
-
|
71
|
+
# return if @notebooks.length == 2
|
72
72
|
notebook = Redcar::Notebook.new(self)
|
73
73
|
@notebooks << notebook
|
74
74
|
if @notebooks.length == 1
|
@@ -78,6 +78,22 @@ module Redcar
|
|
78
78
|
notify_listeners(:new_notebook, notebook)
|
79
79
|
end
|
80
80
|
|
81
|
+
def enlarge_notebook(index)
|
82
|
+
notify_listeners(:enlarge_notebook,index)
|
83
|
+
end
|
84
|
+
|
85
|
+
def adjust_treebook_width(more=true)
|
86
|
+
if more
|
87
|
+
notify_listeners(:increase_treebook_width)
|
88
|
+
else
|
89
|
+
notify_listeners(:decrease_treebook_width)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def reset_notebook_widths
|
94
|
+
notify_listeners(:reset_notebook_widths)
|
95
|
+
end
|
96
|
+
|
81
97
|
def attach_notebook_listeners(notebook)
|
82
98
|
notebook.add_listener(:tab_focussed) do |tab|
|
83
99
|
notify_listeners(:tab_focussed, tab)
|
@@ -143,7 +159,9 @@ module Redcar
|
|
143
159
|
end
|
144
160
|
|
145
161
|
def nonfocussed_notebook
|
146
|
-
|
162
|
+
i = @notebooks.index @focussed_notebook
|
163
|
+
@notebooks[(i + 1) % @notebooks.length]
|
164
|
+
#@notebooks.find {|nb| nb != @focussed_notebook }
|
147
165
|
end
|
148
166
|
|
149
167
|
# Sets the orientation of the notebooks.
|
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
|
2
2
|
|
3
3
|
describe Redcar::Menu do
|
4
4
|
class DummyCommand; end
|
5
|
-
|
5
|
+
|
6
6
|
describe "with no entries and no text" do
|
7
7
|
before do
|
8
8
|
@menu = Redcar::Menu.new
|
@@ -15,8 +15,8 @@ describe Redcar::Menu do
|
|
15
15
|
it "reports length" do
|
16
16
|
@menu.length.should == 0
|
17
17
|
end
|
18
|
-
end
|
19
|
-
|
18
|
+
end
|
19
|
+
|
20
20
|
describe "with entries in it and text" do
|
21
21
|
before do
|
22
22
|
@menu = Redcar::Menu.new("Edit") \
|
@@ -28,17 +28,17 @@ describe Redcar::Menu do
|
|
28
28
|
it "reports length" do
|
29
29
|
@menu.length.should == 3
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "has text" do
|
33
|
-
@menu.text.should == "Edit"
|
33
|
+
@menu.text.should == Redcar::Menu.parse("Edit")
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
describe "building entries" do
|
38
38
|
before do
|
39
39
|
@menu = Redcar::Menu.new
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should let you add items by building" do
|
43
43
|
@menu.build do
|
44
44
|
item "Cut", DummyCommand
|
@@ -47,24 +47,24 @@ describe Redcar::Menu do
|
|
47
47
|
@menu.entries.first.text.should == "Cut"
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def build(name=nil, &block)
|
52
52
|
Redcar::Menu::Builder.build(name, &block)
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
describe "merging Menus" do
|
56
56
|
it "adds items" do
|
57
57
|
menu = build "Plugins" do
|
58
58
|
item "Foo", 1
|
59
59
|
item "Bar", 2
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
menu2 = build "Plugins" do
|
63
63
|
item "Bar", 3
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
menu.merge(menu2)
|
67
|
-
|
67
|
+
|
68
68
|
menu.should == build("Plugins") do
|
69
69
|
item "Foo", 1
|
70
70
|
item "Bar", 3
|
@@ -76,45 +76,45 @@ describe Redcar::Menu do
|
|
76
76
|
sub_menu "REPL" do
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
menu2 = build "Plugins" do
|
81
81
|
sub_menu "My Plugin" do
|
82
82
|
end
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
menu.merge(menu2)
|
86
|
-
|
86
|
+
|
87
87
|
menu.should == build("Plugins") do
|
88
88
|
sub_menu "REPL" do
|
89
89
|
end
|
90
90
|
sub_menu "My Plugin" do
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
it "replaces a menu with an item and vice versa" do
|
97
97
|
menu = build "Plugins" do
|
98
98
|
item "My Plugin", 201
|
99
99
|
sub_menu "REPL" do
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
menu2 = build "Plugins" do
|
104
104
|
item "REPL", 101
|
105
105
|
sub_menu "My Plugin" do
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
menu.merge(menu2)
|
110
|
-
|
110
|
+
|
111
111
|
menu.should == build("Plugins") do
|
112
112
|
sub_menu "My Plugin" do
|
113
113
|
end
|
114
114
|
item "REPL", 101
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
it "puts newer ones on the end" do
|
119
119
|
menu = build "Plugins" do
|
120
120
|
sub_menu "REPL" do
|
@@ -130,9 +130,9 @@ describe Redcar::Menu do
|
|
130
130
|
item "Open", 101
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
menu.merge(menu2)
|
135
|
-
|
135
|
+
|
136
136
|
menu.should == build("Plugins") do
|
137
137
|
sub_menu "REPL" do
|
138
138
|
end
|
@@ -144,7 +144,7 @@ describe Redcar::Menu do
|
|
144
144
|
end
|
145
145
|
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
it "uses the priority of whichever menu has one" do
|
149
149
|
menu = build("Main"){ sub_menu("Project"){} }
|
150
150
|
menu2 = build("Main"){ sub_menu("Project", :priority => 10){} }
|
@@ -156,12 +156,12 @@ describe Redcar::Menu do
|
|
156
156
|
menu.merge(menu2)
|
157
157
|
menu.entries.first.priority.should == 10
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "preserves own priority when merging" do
|
161
161
|
menu = build("Main"){ sub_menu("Project", :priority => 10){} }
|
162
162
|
menu2 = build("Main"){ sub_menu("Project", :priority => 5){} }
|
163
163
|
menu.merge(menu2)
|
164
|
-
menu.entries.first.priority.should == 10
|
164
|
+
menu.entries.first.priority.should == 10
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|