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
@@ -1,25 +1,150 @@
|
|
1
|
+
|
1
2
|
module Redcar
|
2
3
|
class REPL
|
3
|
-
class
|
4
|
-
|
4
|
+
class Tab < Redcar::EditTab
|
5
|
+
|
5
6
|
DEFAULT_ICON = :application_terminal
|
6
|
-
|
7
|
+
|
7
8
|
def initialize(*args, &block)
|
8
9
|
super(*args,&block)
|
9
10
|
end
|
10
|
-
|
11
|
+
|
11
12
|
def icon
|
12
13
|
DEFAULT_ICON
|
13
14
|
end
|
14
|
-
|
15
|
+
|
16
|
+
def close
|
17
|
+
history = REPL.storage['command_history']
|
18
|
+
history[repl_mirror.title] = repl_mirror.command_history
|
19
|
+
REPL.storage['command_history'] = history
|
20
|
+
notify_listeners(:close)
|
21
|
+
end
|
22
|
+
|
23
|
+
def repl_mirror
|
24
|
+
edit_view.document.mirror
|
25
|
+
end
|
26
|
+
|
15
27
|
def repl_mirror=(mirror)
|
16
28
|
edit_view.document.mirror = mirror
|
17
29
|
edit_view.cursor_offset = edit_view.document.length
|
18
30
|
edit_view.grammar = mirror.grammar_name
|
19
|
-
|
31
|
+
indenters = edit_view.document.controllers(Redcar::AutoIndenter::DocumentController)
|
32
|
+
indenters.first.increase_ignore
|
33
|
+
update_cursor_size
|
34
|
+
attach_listeners
|
35
|
+
end
|
36
|
+
|
37
|
+
def attach_listeners
|
38
|
+
control = edit_view.controller.mate_text.get_control
|
39
|
+
control.add_verify_key_listener(Redcar::ReplSWT::KeyListener.new(self))
|
40
|
+
control.remove_key_listener(edit_view.controller.key_listener)
|
41
|
+
control.remove_verify_key_listener(edit_view.controller.verify_key_listener)
|
42
|
+
repl_mirror.add_listener(:change) do
|
20
43
|
edit_view.cursor_offset = edit_view.document.length
|
21
44
|
edit_view.scroll_to_line(edit_view.document.line_count)
|
22
45
|
end
|
46
|
+
edit_view.add_listener(:font_changed) do
|
47
|
+
update_cursor_size
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def current_command
|
52
|
+
offset = repl_mirror.current_offset.to_i
|
53
|
+
end_offset = edit_view.document.length
|
54
|
+
length = end_offset.to_i - offset.to_i
|
55
|
+
edit_view.document.get_range(offset,length) if length > 0
|
56
|
+
end
|
57
|
+
|
58
|
+
def cached_command
|
59
|
+
@cached_command
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_command(text)
|
63
|
+
offset = repl_mirror.current_offset.to_i
|
64
|
+
length = 0
|
65
|
+
length = current_command.split(//).length if current_command
|
66
|
+
if length > 0
|
67
|
+
edit_view.document.replace(offset,length,text.to_s)
|
68
|
+
else
|
69
|
+
edit_view.document.cursor_offset = offset
|
70
|
+
edit_view.document.insert_at_cursor(text.to_s)
|
71
|
+
edit_view.document.cursor_offset = edit_view.document.length
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def go_to_previous_command
|
76
|
+
if repl_mirror.command_index == repl_mirror.command_history.size
|
77
|
+
@cached_command = current_command
|
78
|
+
end
|
79
|
+
command = repl_mirror.previous_command
|
80
|
+
set_command(command) if command
|
81
|
+
end
|
82
|
+
|
83
|
+
def go_to_next_command
|
84
|
+
command = repl_mirror.next_command || cached_command
|
85
|
+
command = "" if current_command and !command
|
86
|
+
set_command(command) if command
|
87
|
+
end
|
88
|
+
|
89
|
+
def go_to_home?
|
90
|
+
cursor_line = edit_view.document.cursor_line
|
91
|
+
prompt_line = edit_view.document.line_at_offset(repl_mirror.current_offset.to_i)
|
92
|
+
if cursor_line == prompt_line
|
93
|
+
edit_view.document.cursor_offset = repl_mirror.current_offset.to_i
|
94
|
+
false
|
95
|
+
else
|
96
|
+
true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def commit_changes
|
101
|
+
@cached_command = nil
|
102
|
+
edit_view.document.save!
|
103
|
+
end
|
104
|
+
|
105
|
+
# Check (and move, if necessary) the cursor position before inserting text
|
106
|
+
def check_cursor_location
|
107
|
+
offset = repl_mirror.current_offset
|
108
|
+
current_offset = edit_view.document.cursor_offset
|
109
|
+
end_offset = edit_view.document.selection_offset
|
110
|
+
if end_offset and end_offset < current_offset
|
111
|
+
current_offset = end_offset
|
112
|
+
end_offset = edit_view.document.cursor_offset
|
113
|
+
end
|
114
|
+
unless current_offset.to_i >= offset
|
115
|
+
if edit_view.document.selection? and end_offset > offset
|
116
|
+
edit_view.document.set_selection_range(offset,end_offset)
|
117
|
+
else
|
118
|
+
edit_view.document.cursor_offset = edit_view.document.length
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def backspace_possible?
|
124
|
+
check_cursor_location
|
125
|
+
length = 0
|
126
|
+
length = current_command.split(//).length if current_command
|
127
|
+
length > 0
|
128
|
+
end
|
129
|
+
|
130
|
+
def delete_possible?
|
131
|
+
check_cursor_location
|
132
|
+
offset = edit_view.document.cursor_offset
|
133
|
+
edit_view.document.length - offset > 0
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
def update_cursor_size
|
139
|
+
if widget = edit_view.controller.mate_text.get_text_widget
|
140
|
+
caret = Swt::Widgets::Caret.new(widget, Swt::SWT::NONE)
|
141
|
+
caret.set_image(nil)
|
142
|
+
widget.set_caret(caret)
|
143
|
+
height = widget.get_line_height
|
144
|
+
width = edit_view.controller.char_width
|
145
|
+
caret.set_size(width,height)
|
146
|
+
caret.set_visible(true)
|
147
|
+
end
|
23
148
|
end
|
24
149
|
end
|
25
150
|
end
|
data/plugins/repl/plugin.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
class Redcar::REPL
|
4
|
+
describe ReplMirror do
|
5
|
+
before do
|
6
|
+
@mirror = ReplMirror.new
|
7
|
+
@changed_event = false
|
8
|
+
@mirror.add_listener(:change) { @changed_event = true }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "has special commands" do
|
12
|
+
it "gives usage assistance" do
|
13
|
+
@mirror.evaluate('help')
|
14
|
+
@mirror.history.include?(@mirror.help).should == true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "clears command output" do
|
18
|
+
['1','2','3'].each {|cmd| @mirror.add_command(cmd)}
|
19
|
+
@mirror.evaluate('clear')
|
20
|
+
@mirror.history.should == @mirror.prompt + " "
|
21
|
+
end
|
22
|
+
|
23
|
+
it "resets command history" do
|
24
|
+
['1','2','3'].each {|cmd| @mirror.add_command(cmd)}
|
25
|
+
@mirror.evaluate('reset')
|
26
|
+
@mirror.command_history.should == []
|
27
|
+
@mirror.history.should == @mirror.initial_preamble
|
28
|
+
Redcar::REPL.storage['command_history'][@mirror.title].should == []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "has command history" do
|
33
|
+
it "should be empty initially" do
|
34
|
+
@mirror.command_history.should == []
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "adding and navigating command history" do
|
38
|
+
before(:each) do
|
39
|
+
Redcar::REPL.storage['command_history'][@mirror.title] = []
|
40
|
+
['1','2','3'].each {|cmd| @mirror.add_command(cmd)}
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should add new commands" do
|
44
|
+
@mirror.command_history.size.should == 3
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should retrieve previous commands in order" do
|
48
|
+
@mirror.previous_command.should == "3"
|
49
|
+
@mirror.previous_command.should == "2"
|
50
|
+
@mirror.previous_command.should == "1"
|
51
|
+
@mirror.previous_command.should == nil
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should retrieve next commands in order" do
|
55
|
+
@mirror.previous_command.should == "3"
|
56
|
+
@mirror.previous_command.should == "2"
|
57
|
+
@mirror.previous_command.should == "1"
|
58
|
+
@mirror.next_command.should == "2"
|
59
|
+
@mirror.next_command.should == "3"
|
60
|
+
@mirror.next_command.should == nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have a maximum size" do
|
64
|
+
@mirror.set_buffer_size 3
|
65
|
+
['4','5'].each {|cmd| @mirror.add_command(cmd)}
|
66
|
+
@mirror.command_history.size.should == 3
|
67
|
+
@mirror.command_history.should == ['3','4','5']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class ReplSWT
|
4
|
+
class KeyListener
|
5
|
+
def initialize(controller)
|
6
|
+
@controller = controller
|
7
|
+
end
|
8
|
+
|
9
|
+
def key_pressed(e)
|
10
|
+
end
|
11
|
+
|
12
|
+
def key_released(e)
|
13
|
+
end
|
14
|
+
|
15
|
+
def verify_key(e)
|
16
|
+
e.doit = false
|
17
|
+
case e.keyCode
|
18
|
+
when Swt::SWT::ARROW_UP
|
19
|
+
@controller.go_to_previous_command
|
20
|
+
when Swt::SWT::ARROW_DOWN
|
21
|
+
@controller.go_to_next_command
|
22
|
+
when Swt::SWT::ARROW_LEFT
|
23
|
+
e.doit = @controller.backspace_possible?
|
24
|
+
when Swt::SWT::CR
|
25
|
+
if e.stateMask == Swt::SWT::SHIFT
|
26
|
+
e.doit = true
|
27
|
+
else
|
28
|
+
@controller.commit_changes
|
29
|
+
end
|
30
|
+
when Swt::SWT::HOME
|
31
|
+
e.doit = @controller.go_to_home?
|
32
|
+
when Swt::SWT::DEL
|
33
|
+
e.doit = @controller.delete_possible?
|
34
|
+
when Swt::SWT::BS
|
35
|
+
e.doit = @controller.backspace_possible?
|
36
|
+
else
|
37
|
+
@controller.check_cursor_location
|
38
|
+
e.doit = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ruby/syntax_checker'
|
2
|
+
require 'ruby/repl_mirror'
|
3
|
+
|
4
|
+
module Redcar
|
5
|
+
class Ruby
|
6
|
+
|
7
|
+
def self.menus
|
8
|
+
Menu::Builder.build do
|
9
|
+
sub_menu "Plugins" do
|
10
|
+
sub_menu "REPL" do
|
11
|
+
item "Open Ruby REPL", RubyOpenREPL
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.keymaps
|
18
|
+
osx = Keymap.build("main", :osx) do
|
19
|
+
link "Cmd+Shift+R", RubyOpenREPL
|
20
|
+
end
|
21
|
+
|
22
|
+
linwin = Keymap.build("main", [:linux, :windows]) do
|
23
|
+
link "Ctrl+Shift+R", RubyOpenREPL
|
24
|
+
end
|
25
|
+
|
26
|
+
[linwin, osx]
|
27
|
+
end
|
28
|
+
|
29
|
+
class RubyOpenREPL < Redcar::REPL::OpenREPL
|
30
|
+
def execute
|
31
|
+
open_repl(ReplMirror.new)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
1
|
|
2
2
|
module Redcar
|
3
|
-
class
|
4
|
-
class
|
5
|
-
|
3
|
+
class Ruby
|
4
|
+
class ReplMirror < Redcar::REPL::ReplMirror
|
5
|
+
|
6
6
|
def title
|
7
7
|
"Ruby REPL"
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def grammar_name
|
11
11
|
"Ruby REPL"
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def prompt
|
15
15
|
">>"
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def format_error(e)
|
19
|
-
backtrace = e.backtrace.reject{|l| l =~ /
|
19
|
+
backtrace = e.backtrace.reject{|l| l =~ /repl_mirror/}
|
20
20
|
backtrace.unshift("(repl):1")
|
21
21
|
"#{e.class}: #{e.message}\n #{backtrace.join("\n ")}"
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def evaluator
|
25
|
-
@evaluator ||=
|
25
|
+
@evaluator ||= ReplMirror::Evaluator.new
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
class Evaluator
|
29
29
|
attr_reader :output
|
30
|
-
|
30
|
+
|
31
31
|
def initialize
|
32
32
|
@binding = binding
|
33
33
|
@output = nil
|
@@ -36,7 +36,7 @@ module Redcar
|
|
36
36
|
def inspect
|
37
37
|
"main"
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def execute(command)
|
41
41
|
eval(command, @binding).inspect
|
42
42
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'java'
|
2
2
|
|
3
3
|
module Redcar
|
4
|
-
|
5
|
-
class
|
4
|
+
class Ruby
|
5
|
+
class SyntaxChecker < Redcar::SyntaxCheck::Checker
|
6
6
|
supported_grammars "Ruby", "Ruby on Rails"
|
7
7
|
|
8
8
|
def check(*args)
|
@@ -21,7 +21,7 @@ module Redcar
|
|
21
21
|
message =~ /#{Regexp.escape(file)}:(\d+):(.*)/
|
22
22
|
line = $1.to_i - 1
|
23
23
|
message = $2
|
24
|
-
SyntaxCheck::Error.new(doc, line, message)
|
24
|
+
Redcar::SyntaxCheck::Error.new(doc, line, message)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/plugins/ruby/plugin.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Plugin.define do
|
2
2
|
name "ruby"
|
3
|
-
version "0.
|
4
|
-
file "lib", "
|
5
|
-
object "Redcar::
|
6
|
-
dependencies "syntax_check", ">0"
|
3
|
+
version "0.2"
|
4
|
+
file "lib", "ruby"
|
5
|
+
object "Redcar::Ruby"
|
6
|
+
dependencies "syntax_check", ">0",
|
7
|
+
"repl", ">0"
|
7
8
|
end
|
@@ -1,25 +1,27 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
2
|
|
3
|
-
class Redcar::
|
4
|
-
describe
|
3
|
+
class Redcar::Ruby
|
4
|
+
describe ReplMirror do
|
5
5
|
before do
|
6
|
-
@mirror =
|
6
|
+
@mirror = ReplMirror.new
|
7
7
|
@changed_event = false
|
8
8
|
@mirror.add_listener(:change) { @changed_event = true }
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def commit_test_text1
|
12
12
|
text = <<-RUBY
|
13
13
|
# Ruby REPL
|
14
|
+
# type 'help' for help
|
14
15
|
|
15
16
|
>> $internal_repl_test = 707
|
16
17
|
RUBY
|
17
18
|
@mirror.commit(text.chomp)
|
18
19
|
end
|
19
|
-
|
20
|
+
|
20
21
|
def result_test_text1
|
21
22
|
(<<-RUBY).chomp
|
22
23
|
# Ruby REPL
|
24
|
+
# type 'help' for help
|
23
25
|
|
24
26
|
>> $internal_repl_test = 707
|
25
27
|
=> 707
|
@@ -30,6 +32,7 @@ RUBY
|
|
30
32
|
def commit_test_text2
|
31
33
|
text = <<-RUBY
|
32
34
|
# Ruby REPL
|
35
|
+
# type 'help' for help
|
33
36
|
|
34
37
|
>> $internal_repl_test = 707
|
35
38
|
=> 707
|
@@ -38,10 +41,11 @@ RUBY
|
|
38
41
|
@mirror.commit(text.chomp)
|
39
42
|
text.chomp
|
40
43
|
end
|
41
|
-
|
44
|
+
|
42
45
|
def result_test_text2
|
43
46
|
(<<-RUBY).chomp
|
44
47
|
# Ruby REPL
|
48
|
+
# type 'help' for help
|
45
49
|
|
46
50
|
>> $internal_repl_test = 707
|
47
51
|
=> 707
|
@@ -50,59 +54,61 @@ RUBY
|
|
50
54
|
>>
|
51
55
|
RUBY
|
52
56
|
end
|
53
|
-
|
54
|
-
|
57
|
+
|
58
|
+
|
55
59
|
def commit_no_input
|
56
60
|
text = <<-RUBY
|
57
61
|
# Ruby REPL
|
62
|
+
# type 'help' for help
|
58
63
|
|
59
64
|
>>
|
60
65
|
RUBY
|
61
66
|
@mirror.commit(text)
|
62
67
|
end
|
63
|
-
|
64
|
-
def prompt
|
68
|
+
|
69
|
+
def prompt
|
65
70
|
"# Ruby REPL\n\n"
|
66
71
|
end
|
67
|
-
|
72
|
+
|
68
73
|
describe "with no history" do
|
69
74
|
it "should exist" do
|
70
75
|
@mirror.should be_exist
|
71
76
|
end
|
72
|
-
|
77
|
+
|
73
78
|
it "should have a message and a prompt" do
|
74
79
|
@mirror.read.should == (<<-RUBY).chomp
|
75
80
|
# Ruby REPL
|
81
|
+
# type 'help' for help
|
76
82
|
|
77
83
|
>>
|
78
84
|
RUBY
|
79
85
|
end
|
80
|
-
|
86
|
+
|
81
87
|
it "should have a title" do
|
82
88
|
@mirror.title.should == "Ruby REPL"
|
83
89
|
end
|
84
|
-
|
90
|
+
|
85
91
|
it "should not be changed" do
|
86
92
|
@mirror.should_not be_changed
|
87
93
|
end
|
88
|
-
|
94
|
+
|
89
95
|
describe "when executing" do
|
90
96
|
it "should execute committed text" do
|
91
97
|
commit_test_text1
|
92
98
|
$internal_repl_test.should == 707
|
93
99
|
end
|
94
|
-
|
100
|
+
|
95
101
|
it "should allow committing nothing as the first command" do
|
96
102
|
commit_no_input
|
97
|
-
@mirror.read.should == "# Ruby REPL\n\n>> \n=> nil\n>> "
|
103
|
+
@mirror.read.should == "# Ruby REPL\n# type 'help' for help\n\n>> \n=> nil\n>> "
|
98
104
|
end
|
99
|
-
|
105
|
+
|
100
106
|
it "should allow committing nothing as an xth command" do
|
101
107
|
committed = commit_test_text2
|
102
108
|
@mirror.commit committed + "\n>> "
|
103
|
-
@mirror.read.should == "# Ruby REPL\n\n>> $internal_repl_test = 909\n=> 909\n>> \n=> nil\n>> "
|
109
|
+
@mirror.read.should == "# Ruby REPL\n# type 'help' for help\n\n>> $internal_repl_test = 909\n=> 909\n>> \n=> nil\n>> "
|
104
110
|
end
|
105
|
-
|
111
|
+
|
106
112
|
it "should emit changed event when text is executed" do
|
107
113
|
commit_test_text1
|
108
114
|
@changed_event.should be_true
|
@@ -112,11 +118,12 @@ RUBY
|
|
112
118
|
commit_test_text1
|
113
119
|
@mirror.read.should == result_test_text1
|
114
120
|
end
|
115
|
-
|
121
|
+
|
116
122
|
it "should display errors" do
|
117
123
|
@mirror.commit(prompt + ">> nil.foo")
|
118
124
|
@mirror.read.should == (<<-RUBY).chomp
|
119
125
|
# Ruby REPL
|
126
|
+
# type 'help' for help
|
120
127
|
|
121
128
|
>> nil.foo
|
122
129
|
x> NoMethodError: undefined method `foo' for nil:NilClass
|
@@ -127,44 +134,45 @@ RUBY
|
|
127
134
|
end
|
128
135
|
end
|
129
136
|
end
|
130
|
-
|
137
|
+
|
131
138
|
describe "with a history" do
|
132
139
|
before do
|
133
140
|
commit_test_text1
|
134
141
|
end
|
135
|
-
|
142
|
+
|
136
143
|
it "should not have changed" do
|
137
144
|
@mirror.changed?.should be_false
|
138
145
|
end
|
139
|
-
|
146
|
+
|
140
147
|
it "should display the history and prompt correctly" do
|
141
148
|
@mirror.read.should == result_test_text1
|
142
149
|
end
|
143
|
-
|
150
|
+
|
144
151
|
describe "when executing" do
|
145
152
|
it "should execute committed text" do
|
146
153
|
commit_test_text2
|
147
154
|
$internal_repl_test.should == 909
|
148
155
|
end
|
149
|
-
|
156
|
+
|
150
157
|
it "should show the correct history" do
|
151
158
|
commit_test_text2
|
152
159
|
@mirror.read.should == result_test_text2
|
153
160
|
end
|
154
|
-
|
161
|
+
|
155
162
|
it "should allow the history to be cleared" do
|
156
163
|
@mirror.clear_history
|
157
164
|
@mirror.read.should == ">> "
|
158
165
|
end
|
159
|
-
|
166
|
+
|
160
167
|
end
|
161
168
|
end
|
162
|
-
|
169
|
+
|
163
170
|
describe "when executing" do
|
164
171
|
it "should execute inside a main object" do
|
165
172
|
@mirror.commit(prompt + ">> self")
|
166
173
|
@mirror.read.should == (<<-RUBY).chomp
|
167
174
|
# Ruby REPL
|
175
|
+
# type 'help' for help
|
168
176
|
|
169
177
|
>> self
|
170
178
|
=> main
|
@@ -178,6 +186,7 @@ RUBY
|
|
178
186
|
@mirror.commit(sent + "\n>> a")
|
179
187
|
@mirror.read.should == (<<-RUBY).chomp
|
180
188
|
# Ruby REPL
|
189
|
+
# type 'help' for help
|
181
190
|
|
182
191
|
>> a = 13
|
183
192
|
=> 13
|