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,55 @@
|
|
1
|
+
Feature: Navigation and editing keys have special behaviour in a REPL
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I open a new repl
|
5
|
+
And I insert "clear" at the cursor
|
6
|
+
And I press the return key
|
7
|
+
And I insert "x = 4" at the cursor
|
8
|
+
When I move the cursor to the end of the document
|
9
|
+
|
10
|
+
Scenario: Backspace does not erase the prompt
|
11
|
+
And I press the backspace key
|
12
|
+
Then the current command should be "x = "
|
13
|
+
When I press the backspace key
|
14
|
+
Then the current command should be "x ="
|
15
|
+
When I press the backspace key
|
16
|
+
Then the current command should be "x "
|
17
|
+
When I press the backspace key
|
18
|
+
Then the current command should be "x"
|
19
|
+
When I press the backspace key
|
20
|
+
Then the current command should be blank
|
21
|
+
When I press the backspace key
|
22
|
+
Then the current command should be blank
|
23
|
+
And I should see ">> " in the edit tab
|
24
|
+
|
25
|
+
Scenario: Delete does not erase the prompt
|
26
|
+
When I move the cursor to 0
|
27
|
+
And I press the delete key
|
28
|
+
Then the current command should be "x = 4"
|
29
|
+
And I should see ">> " in the edit tab
|
30
|
+
|
31
|
+
Scenario: The home key sets the cursor at the start of the line and after the prompt
|
32
|
+
When I press the home key
|
33
|
+
Then the cursor should be at 3
|
34
|
+
When I replace 3 to 8 with "x = 4\ny = 9"
|
35
|
+
And I move the cursor to 11
|
36
|
+
And I press the home key
|
37
|
+
Then the cursor should be at 9
|
38
|
+
|
39
|
+
Scenario: Left and right arrow keys can be used to navigate the current command
|
40
|
+
When I press the left arrow key
|
41
|
+
Then the cursor should be at 7
|
42
|
+
When I press the left arrow key
|
43
|
+
Then the cursor should be at 6
|
44
|
+
When I press the left arrow key
|
45
|
+
Then the cursor should be at 5
|
46
|
+
When I press the right arrow key
|
47
|
+
Then the cursor should be at 6
|
48
|
+
|
49
|
+
Scenario: The left arrow key should not go beyond the prompt
|
50
|
+
When I press the return key
|
51
|
+
And I insert "clear" at the cursor
|
52
|
+
And I press the return key
|
53
|
+
Then the cursor should be at 3
|
54
|
+
When I press the left arrow key
|
55
|
+
Then the cursor should be at 3
|
@@ -0,0 +1,75 @@
|
|
1
|
+
Feature: Command history
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I open a new repl
|
5
|
+
And I insert "x = 4" at the cursor
|
6
|
+
And I press the return key
|
7
|
+
Then the current command should be blank
|
8
|
+
When I insert "y = 5" at the cursor
|
9
|
+
And I press the return key
|
10
|
+
|
11
|
+
Scenario: Command History can be browsed using the arrow keys
|
12
|
+
When I press the up arrow key
|
13
|
+
Then the current command should be "y = 5"
|
14
|
+
When I press the up arrow key
|
15
|
+
Then the current command should be "x = 4"
|
16
|
+
When I press the up arrow key
|
17
|
+
Then the current command should be "x = 4"
|
18
|
+
When I press the down arrow key
|
19
|
+
Then the current command should be "y = 5"
|
20
|
+
When I press the down arrow key
|
21
|
+
Then the current command should be blank
|
22
|
+
|
23
|
+
Scenario: Command history can be cleared from the screen but retained in the buffer
|
24
|
+
When I insert "clear" at the cursor
|
25
|
+
And I press the return key
|
26
|
+
And I press the up arrow key
|
27
|
+
Then the current command should be "clear"
|
28
|
+
When I press the up arrow key
|
29
|
+
Then the current command should be "y = 5"
|
30
|
+
When I press the up arrow key
|
31
|
+
Then the current command should be "x = 4"
|
32
|
+
|
33
|
+
Scenario: Command history can be reset
|
34
|
+
When I insert "reset" at the cursor
|
35
|
+
And I press the return key
|
36
|
+
And I press the up arrow key
|
37
|
+
Then the current command should be blank
|
38
|
+
And I press the up arrow key
|
39
|
+
Then the current command should be blank
|
40
|
+
And I press the down arrow key
|
41
|
+
Then the current command should be blank
|
42
|
+
|
43
|
+
Scenario: Command history is saved between REPL sessions
|
44
|
+
When I close the focussed tab
|
45
|
+
And I open a new repl
|
46
|
+
When I press the up arrow key
|
47
|
+
Then the current command should be "y = 5"
|
48
|
+
When I press the up arrow key
|
49
|
+
Then the current command should be "x = 4"
|
50
|
+
|
51
|
+
Scenario: Uncommitted command is saved when navigating history
|
52
|
+
When I insert "x - y" at the cursor
|
53
|
+
And I press the up arrow key
|
54
|
+
Then the current command should be "y = 5"
|
55
|
+
When I press the down arrow key
|
56
|
+
Then the current command should be "x - y"
|
57
|
+
|
58
|
+
Scenario: Command history buffer size can be set
|
59
|
+
When I insert "x * y" at the cursor
|
60
|
+
And I press the return key
|
61
|
+
When I insert "buffer 2" at the cursor
|
62
|
+
And I press the return key
|
63
|
+
Then the REPL output should be "Buffer size set to 2"
|
64
|
+
When I press the up arrow key
|
65
|
+
Then the current command should be "buffer 2"
|
66
|
+
And I press the up arrow key
|
67
|
+
Then the current command should be "x * y"
|
68
|
+
And I press the up arrow key
|
69
|
+
Then the current command should be "x * y"
|
70
|
+
When I press the return key
|
71
|
+
And I close the focussed tab
|
72
|
+
And I open a new repl
|
73
|
+
And I insert "buffer" at the cursor
|
74
|
+
And I press the return key
|
75
|
+
Then the REPL output should be "Current buffer size is 2"
|
@@ -1,3 +1,19 @@
|
|
1
1
|
When /^I open a "([^"]*)" repl$/ do |repl|
|
2
|
-
Redcar
|
2
|
+
Redcar.const_get(repl.camelize).const_get(repl.camelize + "OpenREPL").new.run
|
3
3
|
end
|
4
|
+
|
5
|
+
When /^I open a new repl$/ do
|
6
|
+
Redcar::REPL::FakeOpenREPL.new.run
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^the REPL output should be "([^"]*)"$/ do |output|
|
10
|
+
current_tab.edit_view.document.mirror.last_output.should == output
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^the current command should be "([^"]*)"$/ do |cmd|
|
14
|
+
current_tab.current_command.should == cmd
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^the current command should be blank$/ do
|
18
|
+
current_tab.current_command.should == nil
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
require File.join File.dirname(__FILE__), 'fake_repl'
|
3
|
+
|
4
|
+
Redcar::REPL::ReplMirror.class_eval do
|
5
|
+
def evaluator
|
6
|
+
@eval ||= Redcar::REPL::FakeEvaluator.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def grammar_name
|
10
|
+
"Plain Text"
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_error(e)
|
14
|
+
"An error was thrown: #{e}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Before do
|
19
|
+
Redcar::REPL.storage['command_history'] = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
def current_tab
|
23
|
+
Redcar.app.focussed_window.focussed_notebook_tab
|
24
|
+
end
|
data/plugins/repl/lib/repl.rb
CHANGED
@@ -1,97 +1,40 @@
|
|
1
|
+
|
1
2
|
require 'repl/repl_mirror'
|
2
|
-
require 'repl/ruby_mirror'
|
3
|
-
require 'repl/clojure_mirror'
|
4
|
-
require 'repl/groovy_mirror'
|
5
3
|
require 'repl/repl_tab'
|
4
|
+
require 'repl/repl_command'
|
6
5
|
|
7
6
|
module Redcar
|
8
7
|
class REPL
|
9
|
-
def self.menus
|
10
|
-
Menu::Builder.build do
|
11
|
-
sub_menu "Plugins" do
|
12
|
-
sub_menu "REPL", :priority => 180 do
|
13
|
-
item "Open Ruby REPL", REPL::RubyOpenREPL
|
14
|
-
item "Open Clojure REPL", REPL::ClojureOpenREPL
|
15
|
-
item "Open Groovy REPL", REPL::GroovyOpenREPL
|
16
|
-
item "Execute", REPL::CommitREPL
|
17
|
-
item "Clear History", REPL::ClearHistoryREPL
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
8
|
|
23
|
-
|
24
|
-
osx = Keymap.build("main", :osx) do
|
25
|
-
link "Cmd+Shift+R", REPL::RubyOpenREPL
|
26
|
-
link "Cmd+M", REPL::CommitREPL
|
27
|
-
end
|
28
|
-
|
29
|
-
linwin = Keymap.build("main", [:linux, :windows]) do
|
30
|
-
link "Ctrl+Shift+R", REPL::RubyOpenREPL
|
31
|
-
link "Ctrl+M", REPL::CommitREPL
|
32
|
-
end
|
33
|
-
|
34
|
-
[linwin, osx]
|
35
|
-
end
|
9
|
+
DEFAULT_BUFFER_SIZE = 15
|
36
10
|
|
37
11
|
def self.sensitivities
|
38
12
|
[
|
39
13
|
Sensitivity.new(:open_repl_tab, Redcar.app, false, [:tab_focussed]) do |tab|
|
40
14
|
tab and
|
41
|
-
tab.is_a?(REPL::
|
15
|
+
tab.is_a?(REPL::Tab) and
|
42
16
|
tab.edit_view.document.mirror.is_a?(REPL::ReplMirror)
|
43
17
|
end
|
44
18
|
]
|
45
19
|
end
|
46
20
|
|
47
|
-
|
21
|
+
def self.storage
|
22
|
+
@storage ||= begin
|
23
|
+
storage = Plugin::Storage.new('repl')
|
24
|
+
storage.set_default(
|
25
|
+
'command_history_buffer_size',
|
26
|
+
DEFAULT_BUFFER_SIZE)
|
27
|
+
storage.set_default('command_history', {})
|
28
|
+
storage
|
29
|
+
end
|
30
|
+
end
|
48
31
|
|
32
|
+
class OpenREPL < Command
|
49
33
|
def open_repl(mirror)
|
50
|
-
tab = win.new_tab(REPL::
|
34
|
+
tab = win.new_tab(Redcar::REPL::Tab)
|
51
35
|
tab.repl_mirror = mirror
|
52
36
|
tab.focus
|
53
37
|
end
|
54
38
|
end
|
55
|
-
|
56
|
-
class RubyOpenREPL < OpenREPL
|
57
|
-
def execute
|
58
|
-
open_repl(RubyMirror.new)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class ClojureOpenREPL < OpenREPL
|
63
|
-
def execute
|
64
|
-
open_repl(ClojureMirror.new)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class GroovyOpenREPL < OpenREPL
|
69
|
-
def execute
|
70
|
-
open_repl(GroovyMirror.new)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class ReplCommand < Command
|
75
|
-
sensitize :open_repl_tab
|
76
|
-
end
|
77
|
-
|
78
|
-
class CommitREPL < ReplCommand
|
79
|
-
|
80
|
-
def execute
|
81
|
-
edit_view = win.focussed_notebook.focussed_tab.edit_view
|
82
|
-
edit_view.document.save!
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
class ClearHistoryREPL < ReplCommand
|
87
|
-
|
88
|
-
def execute
|
89
|
-
mirror = win.focussed_notebook.focussed_tab.edit_view.document.mirror
|
90
|
-
mirror.clear_history
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
39
|
end
|
95
|
-
end
|
96
|
-
|
97
|
-
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class REPL
|
4
|
+
class ReplCommand
|
5
|
+
|
6
|
+
attr_reader :title,:description,:regex
|
7
|
+
|
8
|
+
def initialize(title,regex,description,&block)
|
9
|
+
@title = title
|
10
|
+
@regex = regex
|
11
|
+
@description = description
|
12
|
+
@block = block
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(match_data)
|
16
|
+
@block.call match_data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,31 +1,78 @@
|
|
1
1
|
module Redcar
|
2
2
|
class REPL
|
3
3
|
class ReplMirror
|
4
|
-
attr_reader :history
|
5
|
-
|
4
|
+
attr_reader :history , :command_history,
|
5
|
+
:command_index, :current_offset ,
|
6
|
+
:last_output
|
7
|
+
|
6
8
|
# A ReplMirror is a type of Document::Mirror
|
7
9
|
include Redcar::Document::Mirror
|
8
10
|
|
9
11
|
def initialize
|
10
12
|
@history = initial_preamble
|
11
13
|
@mutex = Mutex.new
|
14
|
+
initialize_command_history
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize_command_history
|
18
|
+
@command_history = REPL.storage['command_history'][title] || []
|
19
|
+
@command_history_buffer_size = REPL.storage['command_history_buffer_size']
|
20
|
+
@command_index = @command_history.size
|
21
|
+
set_current_offset
|
12
22
|
end
|
13
|
-
|
23
|
+
|
14
24
|
# What to display when the REPL is opened. Defaults to the title followed
|
15
25
|
# by a prompt
|
16
26
|
#
|
17
27
|
# @return [String]
|
18
28
|
def initial_preamble
|
19
|
-
"# #{title}\n\n#{prompt} "
|
29
|
+
"# #{title}\n# type 'help' for help\n\n#{prompt} "
|
20
30
|
end
|
21
|
-
|
31
|
+
|
32
|
+
# What to display when the help command is run
|
33
|
+
#
|
34
|
+
# @return [String]
|
35
|
+
def help
|
36
|
+
help = "Hello! I am a #{title}. I am here to assist you in exploring language APIs.\n\nCommands:\n"
|
37
|
+
special_commands.each do |cmd|
|
38
|
+
help << "#{cmd.title} : #{cmd.description}\n"
|
39
|
+
end
|
40
|
+
help
|
41
|
+
end
|
42
|
+
|
43
|
+
# The special commands supported by the REPL outside of the
|
44
|
+
# standard REPL syntax. Each entry is a command and description.
|
45
|
+
#
|
46
|
+
# @return [Hash]
|
47
|
+
def special_commands
|
48
|
+
[
|
49
|
+
ReplCommand.new('clear', /^clear$/,'Clear command output') do |last|
|
50
|
+
clear_history
|
51
|
+
end,
|
52
|
+
ReplCommand.new('reset', /^reset$/,
|
53
|
+
'Reset REPL to initial state and clear all command history') do |last|
|
54
|
+
reset_history
|
55
|
+
end,
|
56
|
+
ReplCommand.new('help',/^help$/,'Display this help text') do |last|
|
57
|
+
append_to_history help
|
58
|
+
end,
|
59
|
+
ReplCommand.new('buffer',/^buffer$/,'Displays command history buffer size') do |last|
|
60
|
+
append_to_history "Current buffer size is #{command_history_buffer_size}"
|
61
|
+
end,
|
62
|
+
ReplCommand.new('buffer [int]',/buffer (\d+)$/, 'Sets command history buffer size') do |last|
|
63
|
+
set_buffer_size last.captures.first.to_i
|
64
|
+
append_to_history "Buffer size set to #{command_history_buffer_size}"
|
65
|
+
end
|
66
|
+
]
|
67
|
+
end
|
68
|
+
|
22
69
|
# The name of the textmate grammar to apply to the repl history.
|
23
70
|
#
|
24
71
|
# @return [String]
|
25
72
|
def grammar_name
|
26
73
|
raise "implement the grammar_name method on your REPL"
|
27
74
|
end
|
28
|
-
|
75
|
+
|
29
76
|
# The prompt to display when the REPL is ready to accept input.
|
30
77
|
# Default: ">>"
|
31
78
|
#
|
@@ -33,21 +80,29 @@ module Redcar
|
|
33
80
|
def prompt
|
34
81
|
">>"
|
35
82
|
end
|
36
|
-
|
83
|
+
|
84
|
+
# The tab title and preamble to display
|
85
|
+
# Default: "REPL"
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
def title
|
89
|
+
"REPL"
|
90
|
+
end
|
91
|
+
|
37
92
|
# This returns an object that implements:
|
38
93
|
# execute(str:String): String
|
39
94
|
def evaluator
|
40
95
|
raise "implement evaluator on your REPL"
|
41
96
|
end
|
42
|
-
|
97
|
+
|
43
98
|
# Format the language specific exception to be displayed in the Repl
|
44
|
-
#
|
45
|
-
# @param [Exception]
|
99
|
+
#
|
100
|
+
# @param [Exception]
|
46
101
|
# @return [String]
|
47
102
|
def format_error(exception)
|
48
103
|
raise "implement format_error on your REPL"
|
49
104
|
end
|
50
|
-
|
105
|
+
|
51
106
|
# Execute a new statement. Accepts the entire pretty formatted history,
|
52
107
|
# within which it looks for the last statement and executes it.
|
53
108
|
#
|
@@ -58,7 +113,7 @@ module Redcar
|
|
58
113
|
command = entered_expression(contents)
|
59
114
|
evaluate(command)
|
60
115
|
end
|
61
|
-
|
116
|
+
|
62
117
|
# What did the user just enter?
|
63
118
|
#
|
64
119
|
# @return [String]
|
@@ -66,20 +121,78 @@ module Redcar
|
|
66
121
|
if contents.split("\n").last =~ /#{prompt}\s+$/
|
67
122
|
""
|
68
123
|
else
|
69
|
-
contents.split(prompt).last
|
124
|
+
last = contents.split(prompt).last
|
125
|
+
if last
|
126
|
+
last.strip
|
127
|
+
else
|
128
|
+
""
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# How many commands will be stored in command history
|
134
|
+
#
|
135
|
+
# @return [Integer]
|
136
|
+
def command_history_buffer_size
|
137
|
+
@command_history_buffer_size
|
138
|
+
end
|
139
|
+
|
140
|
+
def set_buffer_size(size)
|
141
|
+
@command_history_buffer_size = size
|
142
|
+
if @command_history.size > size
|
143
|
+
@command_history.shift(@command_history.size - size)
|
144
|
+
end
|
145
|
+
@command_index = @command_history.size
|
146
|
+
REPL.storage['command_history_buffer_size'] = size
|
147
|
+
end
|
148
|
+
|
149
|
+
# The previous command to the command currently displayed,
|
150
|
+
# or the last one executed, if none.
|
151
|
+
#
|
152
|
+
# @return [String]
|
153
|
+
def previous_command
|
154
|
+
if current = @command_index
|
155
|
+
if @command_history.size > 0 and current > 0
|
156
|
+
@command_index = current - 1
|
157
|
+
command = @command_history[@command_index]
|
158
|
+
end
|
159
|
+
end
|
160
|
+
command
|
161
|
+
end
|
162
|
+
|
163
|
+
# The next command to the command currently displayed,
|
164
|
+
# or blank, if none.
|
165
|
+
#
|
166
|
+
# @return [String]
|
167
|
+
def next_command
|
168
|
+
if @command_index and @command_history.size > @command_index + 1
|
169
|
+
@command_index = @command_index + 1
|
170
|
+
command = @command_history[@command_index]
|
171
|
+
else
|
172
|
+
@command_index = @command_history.size
|
70
173
|
end
|
174
|
+
command
|
71
175
|
end
|
72
176
|
|
73
177
|
# Evaluate an expression. Calls execute on the return value of evaluator
|
74
178
|
def evaluate(expr)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
179
|
+
add_command(expr)
|
180
|
+
special = special_commands.select {|cmd| expr =~ cmd.regex}
|
181
|
+
if special.size > 0
|
182
|
+
cmd = special.first
|
183
|
+
expr =~ cmd.regex
|
184
|
+
cmd.call Regexp.last_match
|
185
|
+
else
|
186
|
+
begin
|
187
|
+
@last_output = evaluator.execute(expr)
|
188
|
+
@history += "=> " + @last_output
|
189
|
+
rescue Object => e
|
190
|
+
@history += "x> " + format_error(e)
|
191
|
+
end
|
192
|
+
@history += "\n" + prompt + " "
|
193
|
+
set_current_offset
|
194
|
+
notify_listeners(:change)
|
80
195
|
end
|
81
|
-
@history += "\n" + prompt + " "
|
82
|
-
notify_listeners(:change)
|
83
196
|
end
|
84
197
|
|
85
198
|
# Get the complete history as a pretty formatted string.
|
@@ -88,9 +201,27 @@ module Redcar
|
|
88
201
|
def read
|
89
202
|
@history
|
90
203
|
end
|
91
|
-
|
204
|
+
|
205
|
+
def append_to_history(text)
|
206
|
+
@last_output = text
|
207
|
+
@history += "=> " + text
|
208
|
+
@history += "\n" + prompt + " "
|
209
|
+
set_current_offset
|
210
|
+
notify_listeners(:change)
|
211
|
+
end
|
212
|
+
|
92
213
|
def clear_history
|
93
|
-
@history =
|
214
|
+
@history = prompt + " "
|
215
|
+
set_current_offset
|
216
|
+
notify_listeners(:change)
|
217
|
+
end
|
218
|
+
|
219
|
+
def reset_history
|
220
|
+
@history = initial_preamble
|
221
|
+
history = REPL.storage['command_history']
|
222
|
+
history[title] = []
|
223
|
+
REPL.storage['command_history'] = history
|
224
|
+
initialize_command_history
|
94
225
|
notify_listeners(:change)
|
95
226
|
end
|
96
227
|
|
@@ -104,6 +235,21 @@ module Redcar
|
|
104
235
|
def changed?
|
105
236
|
false
|
106
237
|
end
|
238
|
+
|
239
|
+
# Appends a command to history
|
240
|
+
def add_command(expr)
|
241
|
+
@history += expr + "\n"
|
242
|
+
@command_history.push expr
|
243
|
+
size = @command_history.size
|
244
|
+
buffer_size = @command_history_buffer_size
|
245
|
+
@command_history.shift(size - buffer_size) if size > buffer_size
|
246
|
+
@command_index = @command_history.size
|
247
|
+
end
|
248
|
+
|
249
|
+
# Set the position at which a command can begin
|
250
|
+
def set_current_offset
|
251
|
+
@current_offset = @history.split(//).length
|
252
|
+
end
|
107
253
|
end
|
108
254
|
end
|
109
255
|
end
|