redcar 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +41 -1
- data/README.md +1 -1
- data/Rakefile +5 -6
- data/lib/plugin_manager/lib/plugin_manager.rb +1 -2
- data/lib/redcar.rb +19 -14
- data/lib/redcar/installer.rb +21 -17
- data/lib/redcar/runner.rb +10 -7
- data/lib/redcar/usage.rb +1 -0
- data/lib/redcar_quick_start.rb +8 -12
- data/lib/regex_replace.rb +3 -3
- data/plugins/application/features/step_definitions/menu_steps.rb +10 -0
- data/plugins/application/features/step_definitions/speedbar_steps.rb +8 -2
- data/plugins/application/features/step_definitions/tree_steps.rb +48 -6
- data/plugins/application/features/step_definitions/window_steps.rb +9 -4
- data/plugins/application/features/support/env.rb +20 -1
- data/plugins/application/features/support/fake_event.rb +14 -0
- data/plugins/application/lib/application.rb +29 -12
- data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +19 -0
- data/plugins/application/lib/application/speedbar.rb +23 -17
- data/plugins/application/lib/application/tab.rb +20 -15
- data/plugins/application/lib/application/treebook.rb +10 -7
- data/plugins/application/lib/application/window.rb +1 -1
- data/plugins/application/plugin.rb +1 -1
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -4
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +15 -4
- data/plugins/application_swt/lib/application_swt/icon.rb +3 -5
- data/plugins/application_swt/lib/application_swt/notebook/tab_drag_and_drop_listener.rb +4 -4
- data/plugins/application_swt/lib/application_swt/notebook/tab_transfer.rb +5 -5
- data/plugins/application_swt/lib/application_swt/speedbar.rb +34 -120
- data/plugins/application_swt/lib/application_swt/speedbar/button_item.rb +20 -0
- data/plugins/application_swt/lib/application_swt/speedbar/combo_item.rb +38 -0
- data/plugins/application_swt/lib/application_swt/speedbar/label_item.rb +15 -0
- data/plugins/application_swt/lib/application_swt/speedbar/slider_item.rb +32 -0
- data/plugins/application_swt/lib/application_swt/speedbar/text_box_item.rb +36 -0
- data/plugins/application_swt/lib/application_swt/speedbar/toggle_item.rb +29 -0
- data/plugins/application_swt/lib/application_swt/tab.rb +1 -3
- data/plugins/application_swt/lib/application_swt/toolbar.rb +19 -20
- data/plugins/application_swt/lib/application_swt/treebook.rb +24 -9
- data/plugins/application_swt/lib/application_swt/window.rb +110 -98
- data/plugins/application_swt/lib/swt/vtab_folder.rb +77 -32
- data/plugins/application_swt/lib/swt/vtab_item.rb +9 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +63 -23
- data/plugins/application_swt/plugin.rb +1 -1
- data/plugins/clipboard-viewer/lib/clipboard_viewer/clipboard_bar.rb +2 -2
- data/plugins/comment/features/line_comment.feature +116 -4
- data/plugins/comment/lib/comment.rb +18 -16
- data/plugins/connection_manager/lib/connection_manager/commands.rb +1 -1
- data/plugins/connection_manager/lib/connection_manager/private_key_store.rb +5 -3
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/declarations/lib/declarations/parser.rb +68 -20
- data/plugins/document_search/features/replace.feature +18 -0
- data/plugins/document_search/lib/document_search.rb +37 -54
- data/plugins/document_search/lib/document_search/replace_all_command.rb +27 -0
- data/plugins/document_search/lib/document_search/replace_command.rb +38 -0
- data/plugins/document_search/lib/document_search/replace_next_command.rb +27 -0
- data/plugins/document_search/lib/document_search/search_and_replace.rb +17 -24
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +4 -4
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +9 -0
- data/plugins/edit_view/features/step_definitions/window_steps.rb +0 -12
- data/plugins/edit_view/lib/edit_view/document.rb +2 -0
- data/plugins/edit_view/lib/edit_view/document/command.rb +8 -8
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +21 -7
- data/plugins/edit_view/lib/edit_view/select_font_dialog.rb +6 -0
- data/plugins/edit_view/lib/edit_view/select_theme_dialog.rb +6 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +92 -43
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +17 -4
- data/plugins/find-in-project/lib/find_in_project.rb +1 -4
- data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -14
- data/plugins/find-in-project/lib/find_in_project/controllers.rb +12 -0
- data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +5 -0
- data/plugins/groovy/features/fixtures/test.groovy +0 -0
- data/plugins/groovy/features/step_definitions/groovy_steps.rb +27 -0
- data/plugins/groovy/features/support/env.rb +27 -0
- data/plugins/groovy/features/syntax_check_groovy.feature +72 -0
- data/plugins/groovy/lib/syntax_check/groovy.rb +76 -0
- data/plugins/groovy/plugin.rb +7 -0
- data/plugins/help/lib/help.rb +28 -4
- data/plugins/help/lib/help/help_tab.rb +11 -0
- data/plugins/help/lib/help/view_controller.rb +25 -0
- data/plugins/help/plugin.rb +2 -1
- data/plugins/{view_shortcuts → help}/views/default.css +0 -0
- data/plugins/{view_shortcuts → help}/views/index.html.erb +1 -1
- data/plugins/{view_shortcuts → help}/views/redcar_small_icon.png +0 -0
- data/plugins/html_view/features/browser_bar.feature +47 -0
- data/plugins/html_view/features/fixtures/other.html +1 -0
- data/plugins/html_view/features/fixtures/sample.html +1 -0
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +45 -5
- data/plugins/html_view/features/support/env.rb +26 -0
- data/plugins/html_view/features/web_preview.feature +21 -0
- data/plugins/html_view/lib/html_controller.rb +5 -5
- data/plugins/html_view/lib/html_view.rb +62 -10
- data/plugins/{web_bookmarks/lib/web_bookmarks → html_view/lib/html_view}/browser_bar.rb +32 -20
- data/plugins/html_view/lib/html_view/commands.rb +64 -0
- data/plugins/{web_bookmarks/lib/web_bookmarks/view_controller.rb → html_view/lib/html_view/default_controller.rb} +7 -6
- data/plugins/html_view/lib/html_view/html_tab.rb +17 -6
- data/plugins/html_view/plugin.rb +3 -3
- data/plugins/{web_bookmarks → html_view}/views/index.html.erb +0 -0
- data/plugins/javascript/features/fixtures/test.js +0 -0
- data/plugins/javascript/features/support/env.rb +4 -0
- data/plugins/javascript/features/syntax_check_javascript.feature +27 -0
- data/plugins/javascript/lib/syntax_check/javascript.rb +52 -0
- data/plugins/javascript/plugin.rb +7 -0
- data/plugins/javascript/vendor/jslint.js +539 -0
- data/plugins/macros/lib/macros/commands.rb +3 -3
- data/plugins/open_default_app/lib/open_default_app.rb +29 -3
- data/plugins/open_default_app/plugin.rb +1 -1
- data/plugins/outline_view/features/outline_view.feature +79 -0
- data/plugins/outline_view/features/step_definitions/outline_steps.rb +45 -0
- data/plugins/outline_view/lib/outline_view.rb +1 -1
- data/plugins/outline_view/spec/fixtures/some_project/javascript.js +10 -0
- data/plugins/outline_view/spec/fixtures/some_project/nothing_to_see.rb +0 -0
- data/plugins/outline_view/spec/fixtures/some_project/one_lonely_class.rb +2 -0
- data/plugins/outline_view/spec/fixtures/some_project/similar_names.rb +18 -0
- data/plugins/outline_view/spec/fixtures/some_project/something_fancy.rb +736 -0
- data/plugins/outline_view/spec/fixtures/some_project/trailing_space.rb +5 -0
- data/plugins/outline_view_swt/lib/outline_view_swt.rb +17 -19
- data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +1 -4
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +12 -3
- data/plugins/project/features/close_directory_tree.feature +27 -0
- data/plugins/project/features/highlight_focussed_tab.feature +45 -1
- data/plugins/project/features/open_and_save_files.feature +33 -0
- data/plugins/project/features/open_directory_tree.feature +37 -11
- data/plugins/project/features/step_definitions/directory_steps.rb +1 -1
- data/plugins/project/features/step_definitions/drb_steps.rb +40 -0
- data/plugins/project/features/support/env.rb +17 -0
- data/plugins/project/lib/project.rb +12 -2
- data/plugins/project/lib/project/commands.rb +101 -99
- data/plugins/project/lib/project/drb_service.rb +55 -65
- data/plugins/project/lib/project/manager.rb +29 -4
- data/plugins/project/lib/project/project_tree_controller.rb +24 -0
- data/plugins/project/lib/project/support/trash.rb +1 -0
- data/plugins/redcar/redcar.rb +100 -37
- data/plugins/redcar_debug/lib/redcar_debug.rb +3 -3
- data/plugins/repl/features/step_definitions/repl_steps.rb +3 -0
- data/plugins/repl/lib/repl.rb +4 -11
- data/plugins/repl/lib/repl/repl_tab.rb +26 -0
- data/plugins/ruby/features/fixtures/test.rb +0 -0
- data/plugins/ruby/features/support/env.rb +4 -0
- data/plugins/ruby/features/syntax_check_ruby.feature +25 -0
- data/plugins/runnables/features/command_tree.feature +28 -0
- data/plugins/runnables/lib/runnables.rb +1 -0
- data/plugins/runnables/lib/runnables/commands.rb +4 -4
- data/plugins/runnables/lib/runnables/output_processor.rb +5 -5
- data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +2 -7
- data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +13 -8
- data/plugins/scm_git/lib/scm_git/change.rb +5 -5
- data/plugins/strip_trailing_spaces/features/fixtures/test.txt +3 -0
- data/plugins/strip_trailing_spaces/features/strip_trailing_spaces.feature +34 -0
- data/plugins/strip_trailing_spaces/lib/strip_trailing_spaces.rb +3 -38
- data/plugins/swt/lib/swt.rb +5 -13
- data/plugins/swt/lib/swt/full_swt.rb +15 -13
- data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +7 -0
- data/plugins/syntax_check/lib/syntax_check.rb +21 -3
- data/plugins/syntax_check/lib/syntax_check/error.rb +4 -3
- data/plugins/task_manager/lib/task_manager.rb +1 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Autocompletions.tmPreferences +345 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Preferences/Symbol List Target.tmPreferences +22 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Snippets/Doc Banner.tmSnippet +20 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/Syntaxes/Ant.tmLanguage +247 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ant.tmbundle/info.plist +55 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/Syntaxes/GroovyRepl.plist +40 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/RedcarRepl.tmbundle/info.plist +1 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Haml.tmbundle/Syntaxes/Ruby_Haml.tmLanguage +0 -1
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/Syntaxes/Ruby Sass.tmLanguage +626 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby Sass.tmbundle/info.plist +16 -0
- data/plugins/todo_list/features/support/env.rb +8 -0
- data/plugins/todo_list/features/todo_list.feature +26 -0
- data/plugins/todo_list/lib/todo_list.rb +1 -0
- data/plugins/todo_list/lib/todo_list/file_parser.rb +23 -19
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +60 -100
- data/plugins/todo_list/spec/fixtures/project/FIXME.file +3 -0
- data/plugins/todo_list/spec/fixtures/project/NOTE.ignored.file +1 -0
- data/plugins/todo_list/spec/fixtures/project/OPTIMIZE_colon.file +1 -0
- data/plugins/todo_list/spec/fixtures/project/XXX.ignored +1 -0
- data/plugins/todo_list/spec/fixtures/project/ignored_directory/TODO.file +2 -0
- data/plugins/todo_list/spec/fixtures/settings.rb +11 -0
- data/plugins/todo_list/spec/spec_helper.rb +6 -0
- data/plugins/todo_list/spec/todo_list/file_parser_spec.rb +35 -0
- data/plugins/tree/lib/tree.rb +1 -0
- data/plugins/tree/lib/tree/command.rb +5 -0
- data/plugins/web_bookmarks/features/bookmark.feature +37 -0
- data/plugins/web_bookmarks/features/fixtures/other.html +1 -0
- data/plugins/web_bookmarks/features/fixtures/sample.html +1 -0
- data/plugins/web_bookmarks/features/step_definitions/web_steps.rb +4 -0
- data/plugins/web_bookmarks/features/support/env.rb +26 -0
- data/plugins/web_bookmarks/lib/web_bookmarks.rb +0 -10
- data/plugins/web_bookmarks/lib/web_bookmarks/bookmark.rb +10 -1
- data/plugins/web_bookmarks/lib/web_bookmarks/commands.rb +1 -47
- data/plugins/web_bookmarks/lib/web_bookmarks/tree.rb +21 -14
- data/{plugins/application → share}/icons/close.png +0 -0
- data/{plugins/application → share}/icons/darwin-file.png +0 -0
- data/{plugins/application → share}/icons/darwin-folder.png +0 -0
- data/share/icons/open-source-flipped.png +0 -0
- data/{plugins/application/icons/redcar_icon_beta_dev.png → share/icons/redcar-icon-beta-dev.png} +0 -0
- data/{plugins/application/icons/redcar_icon_beta.png → share/icons/redcar-icon-beta.png} +0 -0
- data/{plugins/application → share}/icons/redcar-splash.png +0 -0
- metadata +90 -30
- data/lib/redcar/jvm_options_probe.rb +0 -33
- data/plugins/document_search/lib/document_search/replace.rb +0 -113
- data/plugins/document_search/lib/document_search/search.rb +0 -45
- data/plugins/outline_view_swt/lib/icons/alias.png +0 -0
- data/plugins/outline_view_swt/lib/icons/assignment.png +0 -0
- data/plugins/outline_view_swt/lib/icons/attribute.png +0 -0
- data/plugins/outline_view_swt/lib/icons/class.png +0 -0
- data/plugins/outline_view_swt/lib/icons/interface.png +0 -0
- data/plugins/outline_view_swt/lib/icons/method.png +0 -0
- data/plugins/strip_trailing_spaces/CHANGELOG +0 -12
- data/plugins/strip_trailing_spaces/README.md +0 -32
- data/plugins/view_shortcuts/lib/view_shortcuts.rb +0 -52
- data/plugins/view_shortcuts/plugin.rb +0 -11
@@ -0,0 +1,27 @@
|
|
1
|
+
module DocumentSearch
|
2
|
+
class ReplaceAllCommand < ReplaceCommand
|
3
|
+
def execute
|
4
|
+
startoff, endoff = nil
|
5
|
+
text = doc.get_all_text
|
6
|
+
count = 0
|
7
|
+
sc = StringScanner.new(text)
|
8
|
+
while sc.scan_until(query)
|
9
|
+
count += 1
|
10
|
+
|
11
|
+
startoff = sc.pos - sc.matched_size
|
12
|
+
replacement_text = text.slice(startoff, sc.matched_size).gsub(query, replace)
|
13
|
+
endoff = startoff + replacement_text.length
|
14
|
+
|
15
|
+
text[startoff...sc.pos] = replacement_text
|
16
|
+
sc.string = text
|
17
|
+
sc.pos = startoff + replacement_text.length
|
18
|
+
end
|
19
|
+
if count > 0
|
20
|
+
doc.text = text
|
21
|
+
doc.set_selection_range(startoff + replacement_text.length, startoff)
|
22
|
+
doc.scroll_to_line(doc.line_at_offset(startoff))
|
23
|
+
end
|
24
|
+
count
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DocumentSearch
|
2
|
+
class ReplaceCommand < Redcar::DocumentCommand
|
3
|
+
attr_reader :query, :replace
|
4
|
+
|
5
|
+
def initialize(query, replace, search_method)
|
6
|
+
@replace = replace
|
7
|
+
@query = send(search_method, query)
|
8
|
+
end
|
9
|
+
|
10
|
+
# An instance of a search type method: Regular expression
|
11
|
+
def regex_search_query(query)
|
12
|
+
/#{query}/
|
13
|
+
end
|
14
|
+
|
15
|
+
# An instance of a search type method: Plain text search
|
16
|
+
def plain_search_query(query)
|
17
|
+
regex_search_query(Regexp.escape(query))
|
18
|
+
end
|
19
|
+
|
20
|
+
# An instance of a search type method: Glob text search
|
21
|
+
# Converts a glob pattern (* or ?) into a regex pattern
|
22
|
+
def glob_search_query(query)
|
23
|
+
# convert the glob pattern to a regex pattern
|
24
|
+
new_query = ""
|
25
|
+
query.each_char do |c|
|
26
|
+
case c
|
27
|
+
when "*"
|
28
|
+
new_query << ".*"
|
29
|
+
when "?"
|
30
|
+
new_query << "."
|
31
|
+
else
|
32
|
+
new_query << Regexp.escape(c)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
regex_search_query(new_query)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module DocumentSearch
|
2
|
+
class ReplaceNextCommand < ReplaceCommand
|
3
|
+
# The current selection is usually not used for the next replacement, unless
|
4
|
+
# it matches the query string, in which case we assume that the user meant replace it, too
|
5
|
+
def start_position
|
6
|
+
offsets = [doc.cursor_offset, doc.selection_offset]
|
7
|
+
return offsets.min if query == doc.selected_text
|
8
|
+
offsets.max
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
sc = StringScanner.new(doc.get_all_text)
|
13
|
+
sc.pos = start_position
|
14
|
+
sc.scan_until(query) || sc.reset && sc.scan_until(query)
|
15
|
+
|
16
|
+
return 0 unless sc.matched?
|
17
|
+
startoff = sc.pos - sc.matched_size
|
18
|
+
|
19
|
+
text = doc.get_range(startoff, sc.matched_size)
|
20
|
+
replacement_text = text.gsub(query, replace)
|
21
|
+
doc.replace(sc.pos - sc.matched_size, sc.matched_size, replacement_text)
|
22
|
+
doc.set_selection_range(startoff + replacement_text.length, startoff)
|
23
|
+
doc.scroll_to_line(doc.line_at_offset(startoff))
|
24
|
+
1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -16,44 +16,47 @@ module DocumentSearch
|
|
16
16
|
self.search_type.value = SearchAndReplaceSpeedbar.previous_search_type
|
17
17
|
self.query.edit_view.document.select_all
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
label :label_search, "Search:"
|
21
21
|
textbox :query
|
22
|
-
|
22
|
+
|
23
23
|
label :label_replace, "Replace:"
|
24
24
|
textbox :replace
|
25
|
-
|
25
|
+
|
26
26
|
combo :search_type, ["Regex", "Plain", "Glob"], "RegEx" do |v|
|
27
27
|
SearchAndReplaceSpeedbar.previous_search_type = v
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
button :single_replace, "Replace", "Return" do
|
31
31
|
SearchAndReplaceSpeedbar.previous_query = query.value
|
32
32
|
SearchAndReplaceSpeedbar.previous_replace = replace.value
|
33
33
|
SearchAndReplaceSpeedbar.previous_search_type = search_type.value || "Regex" # Hack to work around fact that default value not being picked up
|
34
34
|
success = SearchAndReplaceSpeedbar.search_replace
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
button :all_replace, "Replace All", nil do
|
38
38
|
SearchAndReplaceSpeedbar.previous_query = query.value
|
39
39
|
SearchAndReplaceSpeedbar.previous_replace = replace.value
|
40
40
|
SearchAndReplaceSpeedbar.previous_search_type = search_type.value || "Regex" # Hack to work around fact that default value not being picked up
|
41
41
|
success = SearchAndReplaceSpeedbar.search_replace_all
|
42
42
|
end
|
43
|
-
|
44
|
-
def self.
|
45
|
-
current_query = @previous_query
|
46
|
-
current_replace = @previous_replace
|
43
|
+
|
44
|
+
def self.search_method
|
47
45
|
case @previous_search_type
|
48
46
|
when "Regex"
|
49
|
-
search_method = :
|
47
|
+
search_method = :regex_search_query
|
50
48
|
when "Plain"
|
51
|
-
search_method = :
|
49
|
+
search_method = :plain_search_query
|
52
50
|
when "Glob"
|
53
|
-
search_method = :
|
51
|
+
search_method = :glob_search_query
|
54
52
|
else
|
55
|
-
search_method = :
|
53
|
+
search_method = :regex_search_query
|
56
54
|
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.search_replace
|
58
|
+
current_query = @previous_query
|
59
|
+
current_replace = @previous_replace
|
57
60
|
adoc = Redcar.app.focussed_notebook_tab.document
|
58
61
|
cmd = ReplaceNextCommand.new(current_query, current_replace, search_method)
|
59
62
|
count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
|
@@ -61,20 +64,10 @@ module DocumentSearch
|
|
61
64
|
Redcar::Application::Dialog.message_box("No instance of the search string were found", {:type => :info, :buttons => :ok})
|
62
65
|
end
|
63
66
|
end
|
64
|
-
|
67
|
+
|
65
68
|
def self.search_replace_all
|
66
69
|
current_query = @previous_query
|
67
70
|
current_replace = @previous_replace
|
68
|
-
case @previous_search_type
|
69
|
-
when "Regex"
|
70
|
-
search_method = :regex_search_method
|
71
|
-
when "Plain"
|
72
|
-
search_method = :plain_search_method
|
73
|
-
when "Glob"
|
74
|
-
search_method = :glob_search_method
|
75
|
-
else
|
76
|
-
search_method = :regex_search_method
|
77
|
-
end
|
78
71
|
cmd = ReplaceAllCommand.new(current_query, current_replace, search_method)
|
79
72
|
count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
|
80
73
|
if count == 0 or count > 1
|
@@ -143,7 +143,7 @@ Then /^the selection should be on line (.*)$/ do |line_num|
|
|
143
143
|
doc.line_at_offset(r.begin).should == line_num
|
144
144
|
doc.line_at_offset(r.end).should == line_num
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
Then /^there should not be any text selected$/ do
|
148
148
|
doc = Redcar::EditView.focussed_edit_view_document
|
149
149
|
doc.selected_text.should == ""
|
@@ -151,7 +151,7 @@ end
|
|
151
151
|
|
152
152
|
Then /^the selected text should be "([^"]*)"$/ do |selected_text|
|
153
153
|
doc = Redcar::EditView.focussed_edit_view_document
|
154
|
-
doc.selected_text.should == selected_text
|
154
|
+
doc.selected_text.should == unescape_text(selected_text)
|
155
155
|
end
|
156
156
|
|
157
157
|
Then /the line delimiter should be "(.*)"/ do |delim|
|
@@ -234,8 +234,8 @@ Given /^the contents? is:$/ do |string|
|
|
234
234
|
selection_index = string.index('<s>')
|
235
235
|
string = string.gsub('<s>', '').gsub('<c>', '')
|
236
236
|
When %{I replace the contents with "#{string}"}
|
237
|
-
|
238
|
-
if cursor_index and selection_index
|
237
|
+
|
238
|
+
if cursor_index and selection_index
|
239
239
|
if cursor_index < selection_index
|
240
240
|
selection_index -= 3
|
241
241
|
else
|
@@ -93,3 +93,12 @@ Then /^my active tab should have an "([^"]*)" icon$/ do |arg1|
|
|
93
93
|
focussed_tab.icon.should == :"#{arg1}"
|
94
94
|
end
|
95
95
|
|
96
|
+
Then /^the tab should (not )?have annotations$/ do |negated|
|
97
|
+
annotations = focussed_tab.controller.edit_view.annotations
|
98
|
+
negated ? (annotations.should be_empty) : (annotations.should_not be_empty)
|
99
|
+
end
|
100
|
+
|
101
|
+
Then /^the tab should (not )?have an annotation on line (\d+)$/ do |negated, num|
|
102
|
+
annotations = focussed_tab.controller.edit_view.annotations(:line => num.to_i)
|
103
|
+
negated ? (annotations.should be_empty) : (annotations.should_not be_empty)
|
104
|
+
end
|
@@ -25,18 +25,6 @@ When /I open a new window(?: with title "(.*)")?/ do |title|
|
|
25
25
|
Redcar::Top::NewWindowCommand.new(title).run
|
26
26
|
end
|
27
27
|
|
28
|
-
class FakeEvent
|
29
|
-
def initialize(event_type, widget)
|
30
|
-
untyped_event = Swt::Widgets::Event.new.tap do |e|
|
31
|
-
e.display = Swt.display
|
32
|
-
e.widget = widget
|
33
|
-
e.x = 0
|
34
|
-
e.y = 0
|
35
|
-
end
|
36
|
-
widget.notify_listeners(event_type, untyped_event)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
28
|
When /^I maximize the window size$/ do
|
41
29
|
Redcar.app.focussed_window.controller.shell.maximized = true
|
42
30
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
module Redcar
|
2
|
-
class DocumentCommand <
|
2
|
+
class DocumentCommand < TabCommand
|
3
3
|
sensitize :edit_view_focussed
|
4
|
-
|
4
|
+
|
5
5
|
def _finished
|
6
|
-
edit_view.history.record(self)
|
6
|
+
edit_view.history.record(self) if edit_view
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def run_in_focussed_tab_edit_view
|
10
10
|
if edit_view = Redcar::EditView.focussed_tab_edit_view
|
11
11
|
run(:env => {:edit_view => edit_view})
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
private
|
16
|
-
|
16
|
+
|
17
17
|
def edit_view
|
18
18
|
env[:edit_view] || EditView.focussed_edit_view
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def doc
|
22
22
|
edit_view.document
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -8,17 +8,31 @@ module Redcar
|
|
8
8
|
create_edit_view
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def icon
|
12
|
+
i = DEFAULT_ICON
|
13
13
|
doc = @edit_view.document
|
14
14
|
if doc and doc.path
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
unless doc.mirror.adapter.is_a?(Redcar::Project::Adapters::Remote)
|
16
|
+
if File.exists?(doc.path)
|
17
|
+
if File.writable?(doc.path)
|
18
|
+
i = DEFAULT_ICON
|
19
|
+
else
|
20
|
+
i = NO_WRITE_ICON
|
21
|
+
end
|
22
|
+
else
|
23
|
+
i = MISSING_ICON
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
|
-
|
27
|
+
i
|
28
|
+
end
|
29
|
+
|
30
|
+
def update_for_file_changes
|
31
|
+
new_icon = icon
|
32
|
+
if new_icon and new_icon != @icon
|
33
|
+
@icon = new_icon
|
34
|
+
notify_listeners(:changed_icon, @icon)
|
35
|
+
end
|
22
36
|
end
|
23
37
|
|
24
38
|
def create_edit_view
|
@@ -28,7 +28,7 @@ module Redcar
|
|
28
28
|
:WINDOW_START => 17039365,
|
29
29
|
:WINDOW_END => 17039366
|
30
30
|
}
|
31
|
-
|
31
|
+
|
32
32
|
SELECTION_COMMANDS = {
|
33
33
|
:SELECT_ALL => 262209,
|
34
34
|
:SELECT_LINE_UP => 16908289,
|
@@ -46,7 +46,7 @@ module Redcar
|
|
46
46
|
:SELECT_WINDOW_START => 17170437,
|
47
47
|
:SELECT_WINDOW_END => 17170438
|
48
48
|
}
|
49
|
-
|
49
|
+
|
50
50
|
MODIFICATION_COMMANDS = {
|
51
51
|
:CUT => 131199,
|
52
52
|
:COPY => 17039369,
|
@@ -56,7 +56,7 @@ module Redcar
|
|
56
56
|
:DELETE_WORD_PREVIOUS => 262152,
|
57
57
|
:DELETE_WORD_NEXT => 262271
|
58
58
|
}
|
59
|
-
|
59
|
+
|
60
60
|
ALL_ACTIONS = NAVIGATION_COMMANDS.merge(SELECTION_COMMANDS).merge(MODIFICATION_COMMANDS)
|
61
61
|
|
62
62
|
include Redcar::Observable
|
@@ -107,42 +107,42 @@ module Redcar
|
|
107
107
|
mate_text.add_grammar_listener do |new_grammar|
|
108
108
|
@model.set_grammar(new_grammar)
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
create_model_listeners
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
def create_mate_text
|
115
115
|
@mate_text = JavaMateView::MateText.new(@parent, !!@options[:single_line])
|
116
116
|
@mate_text.set_font(EditView.font, EditView.font_size)
|
117
117
|
|
118
118
|
@model.controller = self
|
119
|
-
|
119
|
+
|
120
120
|
add_styled_text_command_key_listeners
|
121
121
|
end
|
122
|
-
|
122
|
+
|
123
123
|
class CommandKeyListener
|
124
|
-
|
124
|
+
|
125
125
|
attr_reader :st
|
126
|
-
|
126
|
+
|
127
127
|
def initialize(styled_text, edit_view)
|
128
128
|
@edit_view = edit_view
|
129
129
|
@st = styled_text
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def key_pressed(event)
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
def key_released(event)
|
136
136
|
record_action(event)
|
137
137
|
end
|
138
|
-
|
138
|
+
|
139
139
|
# This pile of crap is copied from StyledText#handleKey. Wouldn't
|
140
140
|
# it be great if this logic was accessible on StyledText somehow?
|
141
141
|
def record_action(event)
|
142
142
|
if (event.keyCode != 0)
|
143
143
|
# special key pressed (e.g., F1)
|
144
144
|
action = st.getKeyBinding(event.keyCode | event.stateMask)
|
145
|
-
else
|
145
|
+
else
|
146
146
|
# character key pressed
|
147
147
|
action = st.getKeyBinding(event.character | event.stateMask)
|
148
148
|
if (action == Swt::SWT::NULL)
|
@@ -155,31 +155,31 @@ module Redcar
|
|
155
155
|
end
|
156
156
|
end
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
if (action == Swt::SWT::NULL)
|
160
160
|
ignore = false
|
161
|
-
|
161
|
+
|
162
162
|
if (Redcar.platform == :osx)
|
163
|
-
# Ignore accelerator key combinations (we do not want to
|
164
|
-
# insert a character in the text in this instance). Do not
|
163
|
+
# Ignore accelerator key combinations (we do not want to
|
164
|
+
# insert a character in the text in this instance). Do not
|
165
165
|
# ignore COMMAND+ALT combinations since that key sequence
|
166
166
|
# produces characters on the mac.
|
167
167
|
ignore = (event.stateMask & Swt::SWT::COMMAND) != 0 ||
|
168
168
|
(event.stateMask & Swt::SWT::CTRL) != 0
|
169
169
|
else
|
170
|
-
# Ignore accelerator key combinations (we do not want to
|
171
|
-
# insert a character in the text in this instance). Don't
|
172
|
-
# ignore CTRL+ALT combinations since that is the Alt Gr
|
173
|
-
# key on some keyboards. See bug 20953.
|
174
|
-
ignore = (event.stateMask ^ Swt::SWT::ALT) == 0 ||
|
170
|
+
# Ignore accelerator key combinations (we do not want to
|
171
|
+
# insert a character in the text in this instance). Don't
|
172
|
+
# ignore CTRL+ALT combinations since that is the Alt Gr
|
173
|
+
# key on some keyboards. See bug 20953.
|
174
|
+
ignore = (event.stateMask ^ Swt::SWT::ALT) == 0 ||
|
175
175
|
(event.stateMask ^ Swt::SWT::CTRL) == 0 ||
|
176
176
|
(event.stateMask ^ (Swt::SWT::ALT | Swt::SWT::SHIFT)) == 0 ||
|
177
177
|
(event.stateMask ^ (Swt::SWT::CTRL | Swt::SWT::SHIFT)) == 0
|
178
178
|
end
|
179
179
|
# -ignore anything below SPACE except for line delimiter keys and tab.
|
180
|
-
# -ignore DEL
|
181
|
-
if (!ignore && event.character > 31 && event.character != Swt::SWT::DEL ||
|
182
|
-
event.character == Swt::SWT::CR || event.character == Swt::SWT::LF ||
|
180
|
+
# -ignore DEL
|
181
|
+
if (!ignore && event.character > 31 && event.character != Swt::SWT::DEL ||
|
182
|
+
event.character == Swt::SWT::CR || event.character == Swt::SWT::LF ||
|
183
183
|
event.character == Swt::SWT::TAB)
|
184
184
|
@edit_view.history.record(event.character)
|
185
185
|
end
|
@@ -188,7 +188,7 @@ module Redcar
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
def add_styled_text_command_key_listeners
|
193
193
|
st = @mate_text.get_text_widget
|
194
194
|
st.add_key_listener(CommandKeyListener.new(st, @model))
|
@@ -210,7 +210,7 @@ module Redcar
|
|
210
210
|
|
211
211
|
def undoable?
|
212
212
|
# The override malarky is because the JFace::TextViewerUndoManager doesn't
|
213
|
-
# recognize that typing while in Block Selection mode makes the edit view
|
213
|
+
# recognize that typing while in Block Selection mode makes the edit view
|
214
214
|
# undoable. (Even though it faithfully records the actions, and responds
|
215
215
|
# correctly to "undo".) So we override the undo manager for this case.
|
216
216
|
@undoable_override || @undo_manager.undoable
|
@@ -248,7 +248,7 @@ module Redcar
|
|
248
248
|
def annotations(options = nil)
|
249
249
|
return @mate_text.annotations unless options
|
250
250
|
if options[:line]
|
251
|
-
@mate_text.annotationsOnLine(line
|
251
|
+
@mate_text.annotationsOnLine(options[:line] - 1)
|
252
252
|
elsif options[:type]
|
253
253
|
annotations_of_type(options[:type])
|
254
254
|
end
|
@@ -278,6 +278,32 @@ module Redcar
|
|
278
278
|
end
|
279
279
|
end
|
280
280
|
|
281
|
+
def reset_right_margin
|
282
|
+
return if @options[:single_line]
|
283
|
+
if @model.word_wrap?
|
284
|
+
size = @mate_text.get_text_widget.get_size
|
285
|
+
width = size.x
|
286
|
+
@mate_text.get_text_widget.right_margin = width - char_width*(@model.margin_column||0) - 3*char_width
|
287
|
+
else
|
288
|
+
@mate_text.get_text_widget.right_margin = 0
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def char_width
|
293
|
+
return 0 if !!@options[:single_line]
|
294
|
+
@char_width ||= begin
|
295
|
+
gc = Swt::Graphics::GC.new(@mate_text.get_text_widget)
|
296
|
+
fm = gc.getFontMetrics
|
297
|
+
width = fm.getAverageCharWidth
|
298
|
+
gc.dispose
|
299
|
+
width
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def clear_char_width
|
304
|
+
@char_width = nil
|
305
|
+
end
|
306
|
+
|
281
307
|
def create_document
|
282
308
|
@document = EditViewSWT::Document.new(@model.document, @mate_text.mate_document)
|
283
309
|
@model.document.controller = @document
|
@@ -291,21 +317,17 @@ module Redcar
|
|
291
317
|
h5 = @model.add_listener(:invisibles_changed) do |new_bool|
|
292
318
|
@mate_text.showInvisibles(new_bool)
|
293
319
|
end
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
@mate_text.set_font(EditView.font, EditView.font_size)
|
299
|
-
end
|
300
|
-
h8 = @model.add_listener(:theme_changed) do
|
301
|
-
@mate_text.set_theme_by_name(EditView.theme)
|
302
|
-
end
|
303
|
-
h9 = @model.add_listener(:line_number_visibility_changed) do |new_bool|
|
304
|
-
@mate_text.set_line_numbers_visible(new_bool)
|
320
|
+
|
321
|
+
h6 = @model.add_listener(:word_wrap_changed) do |should_word_wrap|
|
322
|
+
@mate_text.set_word_wrap(should_word_wrap)
|
323
|
+
reset_right_margin
|
305
324
|
end
|
325
|
+
|
306
326
|
h11 = @model.add_listener(:margin_column_changed) do |new_column|
|
307
327
|
@mate_text.set_margin_column(new_column)
|
328
|
+
reset_right_margin
|
308
329
|
end
|
330
|
+
|
309
331
|
h12 = @model.add_listener(:show_margin_changed) do |new_bool|
|
310
332
|
if new_bool
|
311
333
|
@mate_text.set_margin_column(@model.margin_column)
|
@@ -313,6 +335,19 @@ module Redcar
|
|
313
335
|
@mate_text.set_margin_column(-1)
|
314
336
|
end
|
315
337
|
end
|
338
|
+
|
339
|
+
h7 = @model.add_listener(:font_changed) do
|
340
|
+
@mate_text.set_font(EditView.font, EditView.font_size)
|
341
|
+
clear_char_width
|
342
|
+
reset_right_margin
|
343
|
+
end
|
344
|
+
|
345
|
+
h8 = @model.add_listener(:theme_changed) do
|
346
|
+
@mate_text.set_theme_by_name(EditView.theme)
|
347
|
+
end
|
348
|
+
h9 = @model.add_listener(:line_number_visibility_changed) do |new_bool|
|
349
|
+
@mate_text.set_line_numbers_visible(new_bool)
|
350
|
+
end
|
316
351
|
h13 = @model.document.add_listener(:changed) do
|
317
352
|
@undoable_override = true
|
318
353
|
end
|
@@ -336,19 +371,19 @@ module Redcar
|
|
336
371
|
end
|
337
372
|
end
|
338
373
|
end
|
339
|
-
|
374
|
+
|
340
375
|
def type_character(character)
|
341
376
|
mate_text.get_text_widget.doContent(character)
|
342
377
|
mate_text.get_text_widget.update
|
343
378
|
end
|
344
|
-
|
379
|
+
|
345
380
|
model_listener :type_character
|
346
|
-
|
381
|
+
|
347
382
|
def invoke_action(action_symbol)
|
348
383
|
const = EditViewSWT::ALL_ACTIONS[action_symbol]
|
349
384
|
mate_text.get_text_widget.invokeAction(const)
|
350
385
|
end
|
351
|
-
|
386
|
+
|
352
387
|
model_listener :invoke_action
|
353
388
|
|
354
389
|
class VerifyKeyListener
|
@@ -430,6 +465,20 @@ module Redcar
|
|
430
465
|
# h = @document.add_listener(:set_text, &method(:reparse))
|
431
466
|
# @handlers << [@document, h]
|
432
467
|
@mate_text.get_text_widget.add_word_movement_listener(WordMoveListener.new(self))
|
468
|
+
@mate_text.get_text_widget.add_control_listener(ControlListener.new(self))
|
469
|
+
end
|
470
|
+
|
471
|
+
class ControlListener
|
472
|
+
def initialize(edit_view_swt)
|
473
|
+
@edit_view_swt = edit_view_swt
|
474
|
+
end
|
475
|
+
|
476
|
+
def controlMoved(*_)
|
477
|
+
end
|
478
|
+
|
479
|
+
def controlResized(e)
|
480
|
+
@edit_view_swt.reset_right_margin
|
481
|
+
end
|
433
482
|
end
|
434
483
|
|
435
484
|
def reparse
|