redcar 0.3.4.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +45 -0
- data/README.md +2 -1
- data/ROADMAP.md +0 -1
- data/Rakefile +10 -4
- data/bin/redcar +2 -2
- data/lib/openssl/build.properties +7 -0
- data/lib/plugin_manager/lib/plugin_manager.rb +10 -0
- data/lib/plugin_manager/lib/plugin_manager/plugin_definition.rb +1 -13
- data/lib/redcar.rb +12 -8
- data/lib/redcar/installer.rb +16 -15
- data/lib/redcar/ruby_extensions.rb +146 -1
- data/lib/redcar/runner.rb +16 -7
- data/lib/redcar/usage.rb +4 -7
- data/lib/redcar_quick_start.rb +5 -5
- data/lib/regex_replace.rb +0 -7
- data/plugins/application/features/step_definitions/command_steps.rb +5 -0
- data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
- data/plugins/application/features/step_definitions/filter_list_dialog_steps.rb +38 -0
- data/plugins/application/features/step_definitions/window_steps.rb +1 -1
- data/plugins/application/features/support/env.rb +44 -8
- data/plugins/application/lib/application.rb +32 -33
- data/plugins/application/lib/application/command.rb +32 -2
- data/plugins/application/lib/application/command/executor.rb +2 -12
- data/plugins/application/lib/application/dialog.rb +14 -14
- data/plugins/application/lib/application/event_spewer.rb +32 -0
- data/plugins/application/lib/application/menu.rb +5 -5
- data/plugins/application/lib/application/menu/builder.rb +5 -0
- data/plugins/application/lib/application/menu/lazy_menu.rb +24 -0
- data/plugins/application/lib/application/notebook.rb +4 -3
- data/plugins/application/lib/application/tab.rb +6 -2
- data/plugins/application/lib/application/window.rb +8 -4
- data/plugins/application/spec/application/menu/builder_spec.rb +17 -1
- data/plugins/application/spec/application/notebook_spec.rb +1 -1
- data/plugins/application_swt/build.xml +74 -0
- data/plugins/application_swt/lib/application_swt.rb +79 -0
- data/plugins/application_swt/lib/application_swt/cucumber_patches.rb +6 -1
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +25 -17
- data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +50 -12
- data/plugins/application_swt/lib/application_swt/html_tab.rb +20 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +26 -2
- data/plugins/application_swt/lib/application_swt/notebook.rb +10 -12
- data/plugins/application_swt/lib/application_swt/window.rb +11 -11
- data/plugins/application_swt/src/com/redcareditor/application_swt/CocoaUIEnhancer.java +313 -0
- data/plugins/auto_completer/lib/auto_completer.rb +74 -67
- data/plugins/auto_completer/lib/auto_completer/current_document_completion_source.rb +19 -0
- data/plugins/auto_completer/lib/auto_completer/document_controller.rb +2 -2
- data/plugins/auto_completer/lib/auto_completer/word_list.rb +8 -1
- data/plugins/auto_indenter/features/ruby_style_indentation.feature +24 -0
- data/plugins/auto_indenter/features/step_definitions/indentation_steps.rb +6 -0
- data/plugins/auto_indenter/features/support/env.rb +2 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +86 -0
- data/plugins/auto_indenter/lib/auto_indenter/analyzer.rb +91 -0
- data/plugins/auto_indenter/lib/auto_indenter/commands.rb +34 -0
- data/plugins/auto_indenter/lib/auto_indenter/document_controller.rb +67 -12
- data/plugins/auto_indenter/lib/auto_indenter/rules.rb +41 -0
- data/plugins/auto_indenter/spec/auto_indenter/analyzer_spec.rb +151 -0
- data/plugins/auto_indenter/spec/spec_helper.rb +5 -0
- data/plugins/auto_pairer/lib/auto_pairer.rb +1 -0
- data/plugins/auto_pairer/lib/auto_pairer/document_controller.rb +43 -42
- data/plugins/auto_pairer/lib/auto_pairer/pairs_for_scope.rb +1 -5
- data/plugins/core/lib/core.rb +12 -1
- data/plugins/core/lib/core/observable.rb +7 -7
- data/plugins/core/lib/core/persistent_cache.rb +14 -2
- data/plugins/core/lib/core/plugin.rb +7 -0
- data/plugins/core/lib/core/resource.rb +78 -0
- data/plugins/core/lib/core/task.rb +62 -0
- data/plugins/core/lib/core/task_queue.rb +72 -0
- data/plugins/core/spec/core/resource_spec.rb +124 -0
- data/plugins/core/spec/core/task_queue_spec.rb +202 -0
- data/plugins/core/spec/spec_helper.rb +23 -1
- data/plugins/declarations/TODO +3 -0
- data/plugins/declarations/lib/declarations.rb +144 -0
- data/plugins/declarations/lib/declarations/completion_source.rb +22 -0
- data/plugins/declarations/lib/declarations/file.rb +68 -0
- data/plugins/declarations/lib/declarations/parser.rb +94 -0
- data/plugins/declarations/lib/declarations/select_tag_dialog.rb +44 -0
- data/plugins/declarations/plugin.rb +7 -0
- data/plugins/declarations/spec/declarations/file_spec.rb +62 -0
- data/plugins/declarations/spec/fixtures/federalist.rb +15 -0
- data/plugins/declarations/spec/spec_helper.rb +4 -0
- data/plugins/edit_view/features/indentation_commands.feature +40 -0
- data/plugins/edit_view/features/line_delimiter.feature +40 -0
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +16 -4
- data/plugins/edit_view/features/step_definitions/notebook_steps.rb +1 -1
- data/plugins/edit_view/features/step_definitions/tab_steps.rb +1 -1
- data/plugins/edit_view/features/step_definitions/window_steps.rb +5 -1
- data/plugins/edit_view/features/support/env.rb +3 -5
- data/plugins/edit_view/features/undo_and_redo.feature +21 -0
- data/plugins/edit_view/lib/edit_view.rb +57 -4
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +19 -3
- data/plugins/edit_view/lib/edit_view/document.rb +46 -11
- data/plugins/edit_view/lib/edit_view/document/indentation.rb +35 -0
- data/plugins/edit_view/lib/edit_view/modified_tabs_checker.rb +35 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +13 -3
- data/plugins/edit_view/spec/edit_view/document/indentation_spec.rb +112 -0
- data/plugins/edit_view/spec/edit_view/document_spec.rb +22 -0
- data/plugins/edit_view/spec/spec_helper.rb +1 -0
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +59 -7
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +3 -3
- data/plugins/edit_view_swt/lib/edit_view_swt/word_movement.rb +2 -2
- data/plugins/edit_view_swt/vendor/java-mateview.rb +3 -2
- data/plugins/encryption/encryption.rb +13 -6
- data/plugins/execute_current_tab/lib/execute_current_tab.rb +25 -15
- data/plugins/html_view/assets/redcar.css +32 -1
- data/plugins/html_view/lib/html_view.rb +23 -3
- data/plugins/html_view/lib/html_view/html_tab.rb +4 -0
- data/plugins/my_plugin/lib/my_plugin.rb +4 -12
- data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +1 -0
- data/plugins/plugin_manager_ui/views/index.html.erb +30 -37
- data/plugins/project/features/find_file.feature +75 -0
- data/plugins/project/features/open_and_save_files.feature +7 -7
- data/plugins/project/features/open_directory_tree.feature +11 -3
- data/plugins/project/features/refresh_directory_tree.feature +7 -1
- data/plugins/project/features/step_definitions/directory_steps.rb +11 -1
- data/plugins/project/features/step_definitions/file_steps.rb +10 -0
- data/plugins/project/features/support/env.rb +6 -1
- data/plugins/project/features/watch_for_modified_files.feature +79 -0
- data/plugins/project/lib/project.rb +72 -306
- data/plugins/project/lib/project/commands.rb +128 -0
- data/plugins/project/lib/project/dir_mirror.rb +5 -1
- data/plugins/project/lib/project/drb_service.rb +21 -31
- data/plugins/project/lib/project/file_list.rb +76 -0
- data/plugins/project/lib/project/file_mirror.rb +13 -1
- data/plugins/project/lib/project/find_file_dialog.rb +22 -52
- data/plugins/project/lib/project/manager.rb +210 -0
- data/plugins/project/lib/project/recent_directories.rb +16 -3
- data/plugins/project/plugin.rb +1 -1
- data/plugins/project/spec/fixtures/myproject/README +2 -0
- data/plugins/project/spec/fixtures/myproject/lib/foo_lib.rb +1 -0
- data/plugins/project/spec/fixtures/myproject/spec/foo_spec.rb +1 -0
- data/plugins/project/{features → spec}/fixtures/winter.txt +0 -0
- data/plugins/project/spec/project/dir_mirror_spec.rb +1 -12
- data/plugins/project/spec/project/file_list_spec.rb +140 -0
- data/plugins/project/spec/spec_helper.rb +20 -0
- data/plugins/redcar/plugin.rb +1 -0
- data/plugins/redcar/redcar.rb +254 -84
- data/plugins/redcar_debug/lib/redcar_debug.rb +58 -11
- data/plugins/redcar_debug/vendor/jruby-prof/README +46 -0
- data/plugins/redcar_debug/vendor/jruby-prof/Rakefile +36 -0
- data/plugins/redcar_debug/vendor/jruby-prof/build.xml +31 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.html +22677 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/call_tree.txt +589 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/flat.txt +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/graph.html +1670 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/graph.txt +125 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/pidigits.rb +92 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test.rb +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test2.rb +29 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test_exception.rb +28 -0
- data/plugins/redcar_debug/vendor/jruby-prof/example/test_overhead.rb +43 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof.rb +66 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/abstract_printer.rb +21 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/flat_text_printer.rb +35 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_html_printer.rb +123 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/graph_text_printer.rb +45 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/invocation_set.rb +34 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/method.rb +107 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/profile_invocation.rb +43 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/simple_tree_printer.rb +27 -0
- data/plugins/redcar_debug/vendor/jruby-prof/lib/jruby-prof/tree_html_printer.rb +144 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/Invocation.java +14 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/JRubyProf.java +94 -0
- data/plugins/redcar_debug/vendor/jruby-prof/src/org/jruby/prof/ProfEventHook.java +49 -0
- data/plugins/redcar_debug/vendor/jruby-prof/templates/graph_row.html.erb +18 -0
- data/plugins/redcar_debug/vendor/jruby-prof/test/basic_test.rb +291 -0
- data/plugins/redcar_debug/views/history.html.erb +33 -0
- data/plugins/redcar_debug/views/index.html.erb +33 -0
- data/plugins/repl/lib/repl/internal_mirror.rb +3 -15
- data/plugins/repl/spec/repl/internal_mirror_spec.rb +2 -2
- data/plugins/snippets/lib/snippets.rb +0 -1
- data/plugins/snippets/lib/snippets/document_controller.rb +7 -1
- data/plugins/task_manager/lib/task_manager.rb +28 -0
- data/plugins/task_manager/plugin.rb +11 -0
- data/plugins/task_manager/views/index.html.erb +67 -0
- data/plugins/textmate/lib/textmate.rb +17 -21
- data/plugins/textmate/lib/textmate/plist.rb +1 -2
- data/plugins/textmate/lib/textmate/preference.rb +5 -1
- data/plugins/textmate/lib/textmate/snippet.rb +6 -1
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +0 -6
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/Comments.tmPreferences +1 -1
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Cucumber_Plain_Text_Feature_Completions.tmPreferences +30 -0
- data/textmate/Bundles/Cucumber.tmbundle/Preferences/next_Symbol_list___Scenario.tmPreferences +19 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Plain_Text_Feature.tmLanguage +221 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/next_Cucumber_Steps.tmLanguage +424 -0
- data/textmate/Bundles/Cucumber.tmbundle/Syntaxes/plaintext_template.erb +19 -77
- data/textmate/Bundles/Cucumber.tmbundle/info.plist +1 -20
- data/textmate/Bundles/Perl.tmbundle/Syntaxes/Perl.plist +1 -1
- data/textmate/Themes/Emacs Strict.tmTheme +241 -0
- data/textmate/Themes/IR_White.tmTheme +792 -0
- data/textmate/Themes/Monokai.tmTheme +291 -0
- data/textmate/Themes/WhysPoignant.tmTheme +191 -0
- metadata +92 -7
- data/plugins/application/features/main_window.feature +0 -8
- data/plugins/project/lib/project/project_command.rb +0 -5
- data/textmate/Bundles/Cucumber.tmbundle/Snippets/Scenario.tmSnippet +0 -22
- data/textmate/Bundles/Cucumber.tmbundle/Snippets/Story.tmSnippet +0 -25
|
@@ -27,6 +27,10 @@ module Redcar
|
|
|
27
27
|
end
|
|
28
28
|
real_ix + offset - imaginary_ix
|
|
29
29
|
end
|
|
30
|
+
|
|
31
|
+
def self.ensure_cursor_in_view(edit_view)
|
|
32
|
+
edit_view.document.ensure_visible(edit_view.document.cursor_offset)
|
|
33
|
+
end
|
|
30
34
|
end
|
|
31
35
|
|
|
32
36
|
class ArrowLeftHandler < ArrowHandler
|
|
@@ -40,6 +44,8 @@ module Redcar
|
|
|
40
44
|
else
|
|
41
45
|
doc.cursor_offset = move_left_offset(edit_view)
|
|
42
46
|
end
|
|
47
|
+
ArrowHandler.ensure_cursor_in_view(edit_view)
|
|
48
|
+
true
|
|
43
49
|
end
|
|
44
50
|
|
|
45
51
|
def self.move_left_offset(edit_view)
|
|
@@ -85,6 +91,8 @@ module Redcar
|
|
|
85
91
|
else
|
|
86
92
|
doc.cursor_offset = move_right_offset(edit_view)
|
|
87
93
|
end
|
|
94
|
+
ArrowHandler.ensure_cursor_in_view(edit_view)
|
|
95
|
+
true
|
|
88
96
|
end
|
|
89
97
|
|
|
90
98
|
def self.move_right_offset(edit_view)
|
|
@@ -95,6 +103,10 @@ module Redcar
|
|
|
95
103
|
def self.move_right_offset1(edit_view)
|
|
96
104
|
doc = edit_view.document
|
|
97
105
|
return doc.length if doc.cursor_offset == doc.length - 1
|
|
106
|
+
if doc.length >= doc.cursor_offset + doc.delim.length and
|
|
107
|
+
doc.get_range(doc.cursor_offset, doc.delim.length) == doc.delim
|
|
108
|
+
return doc.cursor_offset + doc.delim.length
|
|
109
|
+
end
|
|
98
110
|
if edit_view.soft_tabs?
|
|
99
111
|
line = doc.get_line(doc.cursor_line)
|
|
100
112
|
width = edit_view.tab_width
|
|
@@ -106,15 +118,19 @@ module Redcar
|
|
|
106
118
|
if match = after_line.match(/^\s+/)
|
|
107
119
|
doc.cursor_offset + match[0].length
|
|
108
120
|
else
|
|
109
|
-
doc
|
|
121
|
+
incremented_offset(doc)
|
|
110
122
|
end
|
|
111
123
|
else
|
|
112
|
-
doc
|
|
124
|
+
incremented_offset(doc)
|
|
113
125
|
end
|
|
114
126
|
else
|
|
115
|
-
doc
|
|
127
|
+
incremented_offset(doc)
|
|
116
128
|
end
|
|
117
129
|
end
|
|
130
|
+
|
|
131
|
+
def self.incremented_offset(doc)
|
|
132
|
+
doc.cursor_offset + 1
|
|
133
|
+
end
|
|
118
134
|
end
|
|
119
135
|
end
|
|
120
136
|
end
|
|
@@ -10,10 +10,8 @@ module Redcar
|
|
|
10
10
|
|
|
11
11
|
def self.all_document_controller_types
|
|
12
12
|
result = []
|
|
13
|
-
Redcar.plugin_manager.
|
|
14
|
-
|
|
15
|
-
result += plugin.object.document_controller_types
|
|
16
|
-
end
|
|
13
|
+
Redcar.plugin_manager.objects_implementing(:document_controller_types).each do |object|
|
|
14
|
+
result += object.document_controller_types
|
|
17
15
|
end
|
|
18
16
|
result
|
|
19
17
|
end
|
|
@@ -52,9 +50,14 @@ module Redcar
|
|
|
52
50
|
|
|
53
51
|
def save!
|
|
54
52
|
@mirror.commit(to_s)
|
|
53
|
+
@edit_view.reset_last_checked
|
|
55
54
|
set_modified(false)
|
|
56
55
|
end
|
|
57
56
|
|
|
57
|
+
def modified?
|
|
58
|
+
@modified
|
|
59
|
+
end
|
|
60
|
+
|
|
58
61
|
def title
|
|
59
62
|
@mirror ? @mirror.title : nil
|
|
60
63
|
end
|
|
@@ -77,6 +80,10 @@ module Redcar
|
|
|
77
80
|
update_from_mirror
|
|
78
81
|
end
|
|
79
82
|
end
|
|
83
|
+
|
|
84
|
+
def mirror_changed?
|
|
85
|
+
mirror and mirror.changed?
|
|
86
|
+
end
|
|
80
87
|
|
|
81
88
|
def verify_text(start_offset, end_offset, text)
|
|
82
89
|
@change = [start_offset, end_offset, text]
|
|
@@ -289,6 +296,10 @@ module Redcar
|
|
|
289
296
|
controller.selection_offset
|
|
290
297
|
end
|
|
291
298
|
|
|
299
|
+
def selection_line
|
|
300
|
+
line_at_offset(selection_offset)
|
|
301
|
+
end
|
|
302
|
+
|
|
292
303
|
# Set the range of text selected by the user.
|
|
293
304
|
#
|
|
294
305
|
# @param [Integer] cursor_offset
|
|
@@ -418,6 +429,10 @@ module Redcar
|
|
|
418
429
|
@edit_view.controller.biggest_visible_line
|
|
419
430
|
end
|
|
420
431
|
|
|
432
|
+
def ensure_visible(offset)
|
|
433
|
+
@edit_view.controller.ensure_visible(offset)
|
|
434
|
+
end
|
|
435
|
+
|
|
421
436
|
def num_lines_visible
|
|
422
437
|
biggest_visible_line - smallest_visible_line
|
|
423
438
|
end
|
|
@@ -436,20 +451,40 @@ module Redcar
|
|
|
436
451
|
def delete_mark(mark)
|
|
437
452
|
controller.delete_mark(mark)
|
|
438
453
|
end
|
|
439
|
-
|
|
440
|
-
private
|
|
441
454
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
455
|
+
# Everything within the block will be treated as a single action
|
|
456
|
+
# for the purposes of Undo.
|
|
457
|
+
#
|
|
458
|
+
# doc.compound { first_thing; second_thing }
|
|
459
|
+
def compound
|
|
460
|
+
@edit_view.controller.compound { yield }
|
|
446
461
|
end
|
|
447
462
|
|
|
463
|
+
def update_from_mirror
|
|
464
|
+
previous_line = cursor_line
|
|
465
|
+
top_line = smallest_visible_line
|
|
466
|
+
|
|
467
|
+
self.text = mirror.read
|
|
468
|
+
|
|
469
|
+
@modified = false
|
|
470
|
+
@edit_view.title = title_with_star
|
|
471
|
+
if line_count > previous_line
|
|
472
|
+
self.cursor_offset = offset_at_line(previous_line)
|
|
473
|
+
scroll_to_line_at_top(top_line)
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
|
|
448
477
|
def set_modified(boolean)
|
|
449
478
|
@modified = boolean
|
|
450
479
|
@edit_view.title = title_with_star
|
|
451
480
|
end
|
|
452
|
-
|
|
481
|
+
|
|
482
|
+
def indentation
|
|
483
|
+
Document::Indentation.new(self, @edit_view.tab_width, @edit_view.soft_tabs?)
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
private
|
|
487
|
+
|
|
453
488
|
def title_with_star
|
|
454
489
|
if mirror
|
|
455
490
|
if @modified
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
module Redcar
|
|
3
|
+
class Document
|
|
4
|
+
class Indentation
|
|
5
|
+
def initialize(doc, tab_width, soft_tabs)
|
|
6
|
+
@doc, @tab_width, @soft_tabs = doc, tab_width, soft_tabs
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def get_level(ix)
|
|
10
|
+
whitespace_prefix(ix).scan(indent_consuming_regex).length
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def whitespace_prefix(ix)
|
|
14
|
+
line = @doc.get_line(ix)
|
|
15
|
+
line.match(/^(\s*)([^\s]|$)/)[1].chomp
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_level(ix, level)
|
|
19
|
+
offset = @doc.offset_at_line(ix)
|
|
20
|
+
prefix = whitespace_prefix(ix)
|
|
21
|
+
if @soft_tabs
|
|
22
|
+
@doc.replace(offset, prefix.length, " "*@tab_width*level)
|
|
23
|
+
else
|
|
24
|
+
@doc.replace(offset, prefix.length, "\t"*level)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def indent_consuming_regex
|
|
31
|
+
/( {0,#{@tab_width - 1}}\t| {#{@tab_width}})/
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Redcar
|
|
2
|
+
class EditView
|
|
3
|
+
class ModifiedTabsChecker
|
|
4
|
+
def initialize(tabs, message, options)
|
|
5
|
+
@tabs, @message, @options = tabs, message, options
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def check
|
|
9
|
+
modified_edit_tabs = @tabs.select {|t| t.edit_view.document.modified? }
|
|
10
|
+
if modified_edit_tabs.any?
|
|
11
|
+
result = Application::Dialog.message_box(
|
|
12
|
+
"You have #{modified_edit_tabs.length} modified tabs.\n\n" +
|
|
13
|
+
@message,
|
|
14
|
+
:buttons => :yes_no_cancel
|
|
15
|
+
)
|
|
16
|
+
case result
|
|
17
|
+
when :yes
|
|
18
|
+
modified_edit_tabs.each do |t|
|
|
19
|
+
t.focus
|
|
20
|
+
Project::FileSaveCommand.new(t).run
|
|
21
|
+
end
|
|
22
|
+
@options[:continue] ? @options[:continue].call : nil
|
|
23
|
+
when :no
|
|
24
|
+
@options[:continue] ? @options[:continue].call : nil
|
|
25
|
+
when :cancel
|
|
26
|
+
@options[:cancel] ? @options[:cancel].call : nil
|
|
27
|
+
end
|
|
28
|
+
else
|
|
29
|
+
@options[:none] ? @options[:none].call : nil
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
@@ -5,11 +5,12 @@ module Redcar
|
|
|
5
5
|
DEFAULT_TAB_WIDTH = 2
|
|
6
6
|
TAB_WIDTHS = %w(2 3 4 5 6 8)
|
|
7
7
|
|
|
8
|
-
attr_reader :tab_widths, :softnesses
|
|
8
|
+
attr_reader :tab_widths, :softnesses, :show_invisibles
|
|
9
9
|
|
|
10
10
|
def initialize
|
|
11
|
-
@tab_widths
|
|
12
|
-
@softnesses
|
|
11
|
+
@tab_widths = EditView.storage['tab_widths'] || {}
|
|
12
|
+
@softnesses = EditView.storage['softnesses'] || {}
|
|
13
|
+
@show_invisibles = !!EditView.storage['show_invisibles']
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def width_for(grammar_name)
|
|
@@ -35,6 +36,15 @@ module Redcar
|
|
|
35
36
|
EditView.storage['softnesses'] = softnesses
|
|
36
37
|
end
|
|
37
38
|
end
|
|
39
|
+
|
|
40
|
+
def show_invisibles?
|
|
41
|
+
show_invisibles
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def set_show_invisibles(bool)
|
|
45
|
+
@show_invisibles = bool
|
|
46
|
+
EditView.storage['show_invisibles'] = bool
|
|
47
|
+
end
|
|
38
48
|
end
|
|
39
49
|
end
|
|
40
50
|
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
require File.join(File.dirname(__FILE__), %w".. .. spec_helper")
|
|
3
|
+
|
|
4
|
+
describe Redcar::Document::Indentation do
|
|
5
|
+
class MockDoc
|
|
6
|
+
def initialize(string)
|
|
7
|
+
@string = string
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_line(ix)
|
|
11
|
+
lines[ix] + "\n"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def offset_at_line(ix)
|
|
15
|
+
return 0 if ix == 0
|
|
16
|
+
lines[0..(ix - 1)].join("\n").length + 1
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def delim
|
|
20
|
+
"\n"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def lines
|
|
26
|
+
@string.split("\n")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "#get_level" do
|
|
31
|
+
it "should report indent correctly" do
|
|
32
|
+
ind = Redcar::Document::Indentation.new(MockDoc.new(<<RUBY), 4, false)
|
|
33
|
+
def foo
|
|
34
|
+
p :foo
|
|
35
|
+
p :bar
|
|
36
|
+
p :baz
|
|
37
|
+
p :qux
|
|
38
|
+
p :qux
|
|
39
|
+
|
|
40
|
+
RUBY
|
|
41
|
+
ind.get_level(0).should == 0
|
|
42
|
+
ind.get_level(1).should == 1
|
|
43
|
+
ind.get_level(2).should == 1
|
|
44
|
+
ind.get_level(3).should == 1
|
|
45
|
+
ind.get_level(4).should == 2
|
|
46
|
+
ind.get_level(5).should == 2
|
|
47
|
+
ind.get_level(6).should == 1
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "#set_level" do
|
|
52
|
+
describe "with soft tabs" do
|
|
53
|
+
it "should set indent correctly from no indent" do
|
|
54
|
+
@doc = MockDoc.new(<<RUBY)
|
|
55
|
+
def foo
|
|
56
|
+
RUBY
|
|
57
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, true)
|
|
58
|
+
@doc.should_receive(:replace).with(0, 0, " ")
|
|
59
|
+
ind.set_level(0, 1)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should set indent correctly from no indent (2)" do
|
|
63
|
+
@doc = MockDoc.new(<<RUBY)
|
|
64
|
+
def foo
|
|
65
|
+
RUBY
|
|
66
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, true)
|
|
67
|
+
@doc.should_receive(:replace).with(0, 0, " ")
|
|
68
|
+
ind.set_level(0, 2)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should set indent correctly resetting previous indent" do
|
|
72
|
+
@doc = MockDoc.new(<<RUBY)
|
|
73
|
+
def foo
|
|
74
|
+
RUBY
|
|
75
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, true)
|
|
76
|
+
@doc.should_receive(:replace).with(0, 8, " ")
|
|
77
|
+
ind.set_level(0, 1)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
describe "with hard tabs" do
|
|
82
|
+
it "should set indent correctly from no indent" do
|
|
83
|
+
@doc = MockDoc.new(<<RUBY)
|
|
84
|
+
def foo
|
|
85
|
+
RUBY
|
|
86
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, false)
|
|
87
|
+
@doc.should_receive(:replace).with(0, 0, "\t")
|
|
88
|
+
ind.set_level(0, 1)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should set indent correctly resetting previous indent" do
|
|
92
|
+
@doc = MockDoc.new(<<RUBY)
|
|
93
|
+
def foo
|
|
94
|
+
RUBY
|
|
95
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, false)
|
|
96
|
+
@doc.should_receive(:replace).with(0, 2, "\t")
|
|
97
|
+
ind.set_level(0, 1)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should set indent correctly (2) from no indent" do
|
|
101
|
+
@doc = MockDoc.new(<<RUBY)
|
|
102
|
+
def foo
|
|
103
|
+
RUBY
|
|
104
|
+
ind = Redcar::Document::Indentation.new(@doc, 4, false)
|
|
105
|
+
@doc.should_receive(:replace).with(0, 0, "\t\t")
|
|
106
|
+
ind.set_level(0, 2)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
@@ -3,6 +3,16 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
|
|
3
3
|
describe Redcar::Document do
|
|
4
4
|
class TestEditView
|
|
5
5
|
attr_accessor :title
|
|
6
|
+
|
|
7
|
+
def reset_last_checked
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def controller
|
|
11
|
+
o = Object.new
|
|
12
|
+
def o.method_missing(*_)
|
|
13
|
+
end
|
|
14
|
+
o
|
|
15
|
+
end
|
|
6
16
|
end
|
|
7
17
|
|
|
8
18
|
class TestDocumentController
|
|
@@ -21,6 +31,18 @@ describe Redcar::Document do
|
|
|
21
31
|
def get_range(from_here, to_here)
|
|
22
32
|
@text[from_here, to_here]
|
|
23
33
|
end
|
|
34
|
+
|
|
35
|
+
def cursor_offset
|
|
36
|
+
0
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def line_at_offset(_)
|
|
40
|
+
0
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def line_count
|
|
44
|
+
0
|
|
45
|
+
end
|
|
24
46
|
end
|
|
25
47
|
|
|
26
48
|
class TestMirror
|
|
@@ -25,7 +25,7 @@ module Redcar
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
attr_reader :mate_text, :widget, :model
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
def initialize(model, parent, options={})
|
|
30
30
|
@options = options
|
|
31
31
|
@model = model
|
|
@@ -81,6 +81,20 @@ module Redcar
|
|
|
81
81
|
@undo_manager.reset
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
def compound
|
|
85
|
+
begin_compound
|
|
86
|
+
yield
|
|
87
|
+
end_compound
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def begin_compound
|
|
91
|
+
@undo_manager.begin_compound_change
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def end_compound
|
|
95
|
+
@undo_manager.end_compound_change
|
|
96
|
+
end
|
|
97
|
+
|
|
84
98
|
def create_document
|
|
85
99
|
@document = EditViewSWT::Document.new(@model.document, @mate_text.mate_document)
|
|
86
100
|
@model.document.controller = @document
|
|
@@ -91,11 +105,15 @@ module Redcar
|
|
|
91
105
|
h4 = @model.add_listener(:tab_width_changed) do |new_tab_width|
|
|
92
106
|
@mate_text.get_control.set_tabs(new_tab_width)
|
|
93
107
|
end
|
|
108
|
+
h5 = @model.add_listener(:invisibles_changed) do |new_bool|
|
|
109
|
+
@mate_text.showInvisibles(new_bool)
|
|
110
|
+
end
|
|
94
111
|
@mate_text.getTextWidget.addFocusListener(FocusListener.new(self))
|
|
95
112
|
@mate_text.getTextWidget.addVerifyListener(VerifyListener.new(@model.document, self))
|
|
96
113
|
@mate_text.getTextWidget.addModifyListener(ModifyListener.new(@model.document, self))
|
|
97
114
|
@mate_text.get_control.add_verify_key_listener(VerifyKeyListener.new(self))
|
|
98
|
-
@
|
|
115
|
+
@mate_text.get_control.add_key_listener(KeyListener.new(self))
|
|
116
|
+
@handlers << [@model.document, h1] << [@model, h2] << [@model, h3] << [@model, h4] << [@model, h5]
|
|
99
117
|
end
|
|
100
118
|
|
|
101
119
|
class VerifyKeyListener
|
|
@@ -104,6 +122,9 @@ module Redcar
|
|
|
104
122
|
end
|
|
105
123
|
|
|
106
124
|
def verify_key(key_event)
|
|
125
|
+
if @edit_view_swt.model.document.block_selection_mode?
|
|
126
|
+
@edit_view_swt.begin_compound
|
|
127
|
+
end
|
|
107
128
|
if key_event.character == Swt::SWT::TAB
|
|
108
129
|
key_event.doit = !@edit_view_swt.model.tab_pressed(ApplicationSWT::Menu::BindingTranslator.modifiers(key_event))
|
|
109
130
|
elsif key_event.character == Swt::SWT::ESC
|
|
@@ -120,6 +141,22 @@ module Redcar
|
|
|
120
141
|
end
|
|
121
142
|
end
|
|
122
143
|
|
|
144
|
+
class KeyListener
|
|
145
|
+
def initialize(edit_view_swt)
|
|
146
|
+
@edit_view_swt = edit_view_swt
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def key_pressed(_)
|
|
150
|
+
@was_in_block_selection = @edit_view_swt.model.document.block_selection_mode?
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def key_released(_)
|
|
154
|
+
if @was_in_block_selection
|
|
155
|
+
@edit_view_swt.end_compound
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
123
160
|
def delay_parsing
|
|
124
161
|
mate_text.delay_parsing { yield }
|
|
125
162
|
end
|
|
@@ -161,7 +198,7 @@ module Redcar
|
|
|
161
198
|
end
|
|
162
199
|
|
|
163
200
|
def scroll_to_line(line_index)
|
|
164
|
-
@mate_text.parser.last_visible_line_changed(line_index + 100)
|
|
201
|
+
@mate_text.parser.parserScheduler.last_visible_line_changed(line_index + 100)
|
|
165
202
|
@mate_text.viewer.set_top_index(line_index)
|
|
166
203
|
end
|
|
167
204
|
|
|
@@ -177,14 +214,29 @@ module Redcar
|
|
|
177
214
|
@mate_text.viewer.get_bottom_index
|
|
178
215
|
end
|
|
179
216
|
|
|
217
|
+
def ensure_visible(offset)
|
|
218
|
+
line = @document.line_at_offset(offset)
|
|
219
|
+
line_start_offset = @document.offset_at_line(line)
|
|
220
|
+
if offset == line_start_offset
|
|
221
|
+
# This doesn't work. Bug in JFace.SourceViewer?
|
|
222
|
+
@mate_text.viewer.reveal_range(offset, 1)
|
|
223
|
+
# so we do this too:
|
|
224
|
+
@mate_text.get_control.set_horizontal_pixel(0)
|
|
225
|
+
else
|
|
226
|
+
@mate_text.viewer.reveal_range(offset, 1)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
180
230
|
def update_grammar(new_mirror)
|
|
181
231
|
title = new_mirror.title
|
|
182
|
-
return if @mate_text.set_grammar_by_filename(title)
|
|
183
232
|
contents = new_mirror.read
|
|
184
233
|
first_line = contents.to_s.split("\n").first
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
234
|
+
grammar_name = @mate_text.set_grammar_by_first_line(first_line) if first_line
|
|
235
|
+
unless grammar_name
|
|
236
|
+
grammar_name = @mate_text.set_grammar_by_filename(title)
|
|
237
|
+
end
|
|
238
|
+
grammar_name ||= "Plain Text"
|
|
239
|
+
@model.set_grammar(grammar_name)
|
|
188
240
|
end
|
|
189
241
|
|
|
190
242
|
STRIP_KEYS = {
|