redcar 0.6.1 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +26 -0
- data/README.md +17 -31
- data/Rakefile +1 -1
- data/bin/redcar +1 -1
- data/lib/redcar.rb +8 -4
- data/lib/redcar/installer.rb +2 -1
- data/plugins/application/features/step_definitions/dialog_steps.rb +5 -0
- data/plugins/application/features/step_definitions/tree_steps.rb +1 -1
- data/plugins/application/features/support/env.rb +38 -17
- data/plugins/application/lib/application.rb +4 -0
- data/plugins/application/lib/application/command.rb +8 -2
- data/plugins/application/lib/application/command/executor.rb +37 -8
- data/plugins/application/lib/application/command/history.rb +3 -3
- data/plugins/application/lib/application/menu.rb +4 -0
- data/plugins/application/lib/application/menu/item.rb +9 -1
- data/plugins/application/lib/application/tab.rb +11 -0
- data/plugins/application/spec/application/command/executor_spec.rb +3 -3
- data/plugins/application/spec/application/command_spec.rb +24 -0
- data/plugins/application/spec/spec_helper.rb +1 -0
- data/plugins/application_swt/lib/application_swt.rb +27 -24
- data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +4 -33
- data/plugins/application_swt/lib/application_swt/dialogs/input_dialog.rb +46 -0
- data/plugins/application_swt/lib/application_swt/dialogs/text_and_file_dialog.rb +118 -0
- data/plugins/application_swt/lib/application_swt/icon.rb +37 -0
- data/plugins/application_swt/lib/application_swt/menu.rb +8 -3
- data/plugins/application_swt/lib/application_swt/tab.rb +6 -3
- data/plugins/application_swt/lib/application_swt/treebook.rb +29 -31
- data/plugins/application_swt/lib/swt/graphics_utils.rb +170 -0
- data/plugins/application_swt/lib/swt/vtab_folder.rb +125 -0
- data/plugins/application_swt/lib/swt/vtab_item.rb +69 -0
- data/plugins/application_swt/lib/swt/vtab_label.rb +84 -0
- data/plugins/auto_indenter/lib/auto_indenter.rb +4 -2
- data/plugins/core/lib/core/controller.rb +18 -0
- data/plugins/declarations/lib/declarations.rb +1 -1
- data/plugins/document_search/lib/document_search.rb +8 -6
- data/plugins/document_search/lib/document_search/replace.rb +51 -31
- data/plugins/document_search/lib/document_search/search_and_replace.rb +12 -11
- data/plugins/edit_view/features/step_definitions/editing_steps.rb +33 -17
- data/plugins/edit_view/lib/edit_view.rb +100 -21
- data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +34 -11
- data/plugins/edit_view/lib/edit_view/actions/deletion.rb +10 -0
- data/plugins/edit_view/lib/edit_view/command.rb +5 -1
- data/plugins/edit_view/lib/edit_view/document.rb +8 -3
- data/plugins/edit_view/lib/edit_view/document/command.rb +15 -1
- data/plugins/edit_view/lib/edit_view/document/controller.rb +9 -0
- data/plugins/edit_view/lib/edit_view/document/history.rb +41 -0
- data/plugins/edit_view/lib/edit_view/tab_settings.rb +1 -11
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +150 -4
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +1 -1
- data/plugins/edit_view_swt/vendor/java-mateview.rb +1 -1
- data/plugins/find-in-project/lib/find_in_project.rb +7 -5
- data/plugins/html_view/features/step_definitions/html_view_steps.rb +2 -2
- data/plugins/line_tools/features/step_definitions/line_tools_steps.rb +0 -1
- data/plugins/line_tools/lib/line_tools.rb +7 -9
- data/plugins/macros/features/block_selection_in_macros.feature +48 -0
- data/plugins/macros/features/predictive_macros.feature +79 -0
- data/plugins/macros/features/record_and_run_macro.feature +87 -0
- data/plugins/macros/features/step_definitions/macro_steps.rb +66 -0
- data/plugins/macros/features/step_definitions/prediction_steps.rb +8 -0
- data/plugins/macros/features/support/env.rb +2 -0
- data/plugins/macros/lib/macros.rb +167 -0
- data/plugins/macros/lib/macros/action_sequence.rb +30 -0
- data/plugins/macros/lib/macros/commands.rb +108 -0
- data/plugins/macros/lib/macros/macro.rb +37 -0
- data/plugins/macros/lib/macros/manager_controller.rb +67 -0
- data/plugins/macros/lib/macros/predictive/document_controller.rb +69 -0
- data/plugins/macros/lib/macros/predictive/sequence_finder.rb +112 -0
- data/plugins/macros/plugin.rb +9 -0
- data/plugins/macros/spec/macros/predictive/sequence_finder_spec.rb +142 -0
- data/plugins/macros/spec/spec_helper.rb +6 -0
- data/plugins/macros/views/macro_manager.html.erb +86 -0
- data/plugins/outline_view/lib/outline_view.rb +1 -1
- data/plugins/project/lib/project/commands.rb +2 -2
- data/plugins/redcar/redcar.rb +37 -46
- data/plugins/repl/lib/repl.rb +4 -4
- data/plugins/runnables/features/command_tree.feature +1 -1
- data/plugins/runnables/features/parameter_input.feature +42 -0
- data/plugins/runnables/features/step_definitions/runnable_steps.rb +6 -0
- data/plugins/runnables/features/support/env.rb +28 -8
- data/plugins/runnables/lib/runnables.rb +35 -206
- data/plugins/runnables/lib/runnables/commands.rb +65 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable.rb +62 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_group.rb +59 -0
- data/plugins/runnables/lib/runnables/tree_mirror/nodes/runnable_type_group.rb +32 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_controller.rb +41 -0
- data/plugins/runnables/lib/runnables/tree_mirror/tree_mirror.rb +61 -0
- data/plugins/scm/lib/scm.rb +78 -45
- data/plugins/scm/lib/scm/commands.rb +18 -4
- data/plugins/scm/lib/scm/model.rb +54 -41
- data/plugins/scm_svn/LICENSE +48 -0
- data/plugins/scm_svn/features/add_and_commit.feature +18 -0
- data/plugins/scm_svn/features/checkout.feature +5 -0
- data/plugins/scm_svn/features/edit_and_index.feature +12 -0
- data/plugins/scm_svn/features/ignore_files.feature +14 -0
- data/plugins/scm_svn/features/merge.feature +34 -0
- data/plugins/scm_svn/features/resolve_conflict.feature +23 -0
- data/plugins/scm_svn/features/revert_and_delete.feature +21 -0
- data/plugins/scm_svn/features/step_definitions/branch_and_merge_steps.rb +27 -0
- data/plugins/scm_svn/features/step_definitions/checkout_steps.rb +25 -0
- data/plugins/scm_svn/features/step_definitions/edit_and_index_steps.rb +50 -0
- data/plugins/scm_svn/features/step_definitions/scm_svn_steps.rb +57 -0
- data/plugins/scm_svn/features/support/env.rb +74 -0
- data/plugins/scm_svn/features/switch_branches.feature +53 -0
- data/plugins/scm_svn/features/update.feature +16 -0
- data/plugins/scm_svn/lib/scm_svn.rb +423 -9
- data/plugins/scm_svn/lib/scm_svn/change.rb +116 -0
- data/plugins/swt/lib/swt.rb +0 -15
- data/plugins/swt/lib/swt/cucumber_patches.rb +2 -37
- data/plugins/swt/lib/swt/cucumber_runner.rb +1 -0
- data/plugins/swt/lib/swt/full_swt.rb +2 -0
- data/plugins/textmate/vendor/redcar-bundles/Bundles/Clojure.tmbundle/Syntaxes/Clojure.tmLanguage +14 -2
- data/plugins/todo_list/lib/todo_list/todo_controller.rb +1 -1
- data/plugins/todo_list/views/default.css +50 -0
- data/plugins/todo_list/views/index.html.erb +5 -16
- data/plugins/todo_list/views/redcar_small_icon.png +0 -0
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +14 -33
- data/plugins/view_shortcuts/views/default.css +31 -0
- data/plugins/view_shortcuts/views/index.html.erb +26 -16
- data/plugins/view_shortcuts/views/redcar_small_icon.png +0 -0
- data/{plugins/runnables → share}/icons/cog.png +0 -0
- data/share/icons/folder-gear-emblem.png +0 -0
- data/share/icons/folder-gear.png +0 -0
- data/share/icons/folder-open-small-gears.png +0 -0
- metadata +59 -5
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path("../vtab_label", __FILE__)
|
2
|
+
|
3
|
+
module Swt
|
4
|
+
module Widgets
|
5
|
+
class VTabItem
|
6
|
+
attr_accessor :text, :control
|
7
|
+
|
8
|
+
def initialize(parent, style)
|
9
|
+
@parent = parent
|
10
|
+
@parent.add_item(self)
|
11
|
+
end
|
12
|
+
|
13
|
+
def text= title
|
14
|
+
@text = title
|
15
|
+
@label.title = title
|
16
|
+
end
|
17
|
+
|
18
|
+
def control= control
|
19
|
+
@control = control
|
20
|
+
@control.visible = active?
|
21
|
+
@control.layout_data = Swt::Layout::GridData.new.tap do |l|
|
22
|
+
l.horizontalAlignment = Swt::Layout::GridData::FILL
|
23
|
+
l.verticalAlignment = Swt::Layout::GridData::FILL
|
24
|
+
l.grabExcessHorizontalSpace = true
|
25
|
+
l.grabExcessVerticalSpace = true
|
26
|
+
l.exclude = active?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def draw_label(tab_area)
|
31
|
+
@label = VTabLabel.new(self, tab_area, Swt::SWT::NONE)
|
32
|
+
end
|
33
|
+
|
34
|
+
# This way up to the parent
|
35
|
+
def activate
|
36
|
+
@parent.selection = self
|
37
|
+
end
|
38
|
+
|
39
|
+
def active= boolean
|
40
|
+
@label.active = boolean
|
41
|
+
if @control
|
42
|
+
@control.visible = boolean
|
43
|
+
@control.layout_data.exclude = !boolean
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def active?
|
48
|
+
@label.active
|
49
|
+
end
|
50
|
+
|
51
|
+
def selection_color_options
|
52
|
+
@parent.selection_color_options
|
53
|
+
end
|
54
|
+
|
55
|
+
def font= swt_font
|
56
|
+
@label.font = swt_font
|
57
|
+
end
|
58
|
+
|
59
|
+
def font
|
60
|
+
@label.font
|
61
|
+
end
|
62
|
+
|
63
|
+
def dispose
|
64
|
+
@control.dispose
|
65
|
+
@label.dispose
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require File.expand_path("../graphics_utils", __FILE__)
|
2
|
+
|
3
|
+
module Swt
|
4
|
+
module Widgets
|
5
|
+
class VTabLabel
|
6
|
+
attr_reader :active, :title
|
7
|
+
attr_accessor :font
|
8
|
+
|
9
|
+
include Swt::Events::MouseListener
|
10
|
+
|
11
|
+
def initialize(tab, parent, style)
|
12
|
+
@label = Swt::Widgets::Label.new(parent, style)
|
13
|
+
@active = false
|
14
|
+
@tab = tab
|
15
|
+
@parent = parent
|
16
|
+
@title = ""
|
17
|
+
|
18
|
+
@label.image = label_image
|
19
|
+
@label.add_paint_listener { |event| event.gc.draw_image(label_image, 0, 0) }
|
20
|
+
@label.add_mouse_listener(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def label_image
|
24
|
+
display = Swt::Widgets::Display.current
|
25
|
+
@img = nil if @dirty
|
26
|
+
@img ||= GraphicsUtils.create_rotated_text(@title, @font, @parent.foreground, @parent.background, Swt::SWT::UP) do |gc, extent|
|
27
|
+
fg, bg = gc.foreground, gc.background
|
28
|
+
if @active
|
29
|
+
options = @tab.selection_color_options
|
30
|
+
options[:percents].each_with_index do |p, idx|
|
31
|
+
gc.foreground = options[:colors][idx]
|
32
|
+
gc.background = options[:colors][idx + 1]
|
33
|
+
if options[:vertical]
|
34
|
+
h = idx > 0 ? extent.height * options[:percents][idx - 1] : 0
|
35
|
+
gc.fill_gradient_rectangle(0, h, extent.width, extent.height * p, true)
|
36
|
+
else
|
37
|
+
h = idx > 0 ? extent.width * options[:percents][idx - 1] : 0
|
38
|
+
gc.fill_gradient_rectangle(w, 0, extent.width * p, extent.height, false)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
gc.fill_rectangle(0, 0, extent.width, extent.height)
|
43
|
+
end
|
44
|
+
gc.foreground = display.get_system_color(Swt::SWT::COLOR_WIDGET_NORMAL_SHADOW)
|
45
|
+
gc.draw_rectangle(0, 0, extent.width - 1, extent.height - 1)
|
46
|
+
gc.foreground, gc.background = fg, bg
|
47
|
+
end
|
48
|
+
@dirty = false
|
49
|
+
@img
|
50
|
+
end
|
51
|
+
|
52
|
+
def activate
|
53
|
+
@tab.activate
|
54
|
+
end
|
55
|
+
|
56
|
+
def active= boolean
|
57
|
+
@active = boolean
|
58
|
+
redraw
|
59
|
+
end
|
60
|
+
|
61
|
+
def title= (str)
|
62
|
+
@title = str
|
63
|
+
redraw
|
64
|
+
end
|
65
|
+
|
66
|
+
def redraw
|
67
|
+
@dirty = true
|
68
|
+
@label.image = label_image
|
69
|
+
end
|
70
|
+
|
71
|
+
def dispose
|
72
|
+
@label.dispose
|
73
|
+
end
|
74
|
+
|
75
|
+
def mouseUp(e)
|
76
|
+
activate
|
77
|
+
end
|
78
|
+
|
79
|
+
# Unused
|
80
|
+
def mouseDown(e); end
|
81
|
+
def mouseDoubleClick(e); end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -22,8 +22,10 @@ module Redcar
|
|
22
22
|
def self.menus
|
23
23
|
Menu::Builder.build do
|
24
24
|
sub_menu "Edit" do
|
25
|
-
|
26
|
-
|
25
|
+
sub_menu "Formatting" do
|
26
|
+
item "Indent", :command => AutoIndenter::IndentCommand, :priority => 63
|
27
|
+
item "Tidy File", :command => AutoIndenter::TidyCommand, :priority => 64
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,5 +1,23 @@
|
|
1
1
|
module Redcar
|
2
2
|
module Controller
|
3
3
|
attr_accessor :model
|
4
|
+
|
5
|
+
def self.included(klass)
|
6
|
+
klass.class_eval <<-RUBY
|
7
|
+
def self.model_listeners
|
8
|
+
@model_listeners ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.model_listener(name)
|
12
|
+
model_listeners << name
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_model_listeners
|
16
|
+
self.class.model_listeners.each do |name|
|
17
|
+
@model.add_listener(name, &method(name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
RUBY
|
21
|
+
end
|
4
22
|
end
|
5
23
|
end
|
@@ -88,7 +88,7 @@ module Redcar
|
|
88
88
|
path = match[:file]
|
89
89
|
Project::Manager.open_file(path)
|
90
90
|
regexp = Regexp.new(Regexp.escape(match[:match]))
|
91
|
-
DocumentSearch::FindNextRegex.new(regexp, true).
|
91
|
+
DocumentSearch::FindNextRegex.new(regexp, true).run_in_focussed_tab_edit_view
|
92
92
|
end
|
93
93
|
|
94
94
|
class GoToTagCommand < EditTabCommand
|
@@ -6,19 +6,20 @@ module DocumentSearch
|
|
6
6
|
def self.menus
|
7
7
|
Redcar::Menu::Builder.build do
|
8
8
|
sub_menu "Edit" do
|
9
|
-
|
10
|
-
item "
|
9
|
+
sub_menu "Search", :priority => 50 do
|
10
|
+
item "Document Search", SearchForwardCommand
|
11
11
|
item "Repeat Last Search", RepeatPreviousSearchForwardCommand
|
12
12
|
item "Search and Replace", SearchAndReplaceCommand
|
13
13
|
end
|
14
|
+
separator
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.toolbars
|
19
20
|
Redcar::ToolBar::Builder.build do
|
20
|
-
item "Search Document", :command => DocumentSearch::SearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier.png"), :barname => :
|
21
|
-
item "Repeat Last Search", :command => DocumentSearch::RepeatPreviousSearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier--arrow.png"), :barname => :
|
21
|
+
item "Search Document", :command => DocumentSearch::SearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier.png"), :barname => :edit
|
22
|
+
item "Repeat Last Search", :command => DocumentSearch::RepeatPreviousSearchForwardCommand, :icon => File.join(Redcar::ICONS_DIRECTORY, "magnifier--arrow.png"), :barname => :edit
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
@@ -63,7 +64,8 @@ module DocumentSearch
|
|
63
64
|
if !@previous_is_regex
|
64
65
|
current_query = Regexp.escape(current_query)
|
65
66
|
end
|
66
|
-
FindNextRegex.new(Regexp.new(current_query, !@previous_match_case), true)
|
67
|
+
cmd = FindNextRegex.new(Regexp.new(current_query, !@previous_match_case), true)
|
68
|
+
cmd.run_in_focussed_tab_edit_view
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -91,7 +93,7 @@ module DocumentSearch
|
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
94
|
-
class FindNextRegex < Redcar::
|
96
|
+
class FindNextRegex < Redcar::DocumentCommand
|
95
97
|
def initialize(re, wrap=nil)
|
96
98
|
@re = re
|
97
99
|
@wrap = wrap
|
@@ -1,15 +1,22 @@
|
|
1
1
|
module DocumentSearch
|
2
|
-
class
|
3
|
-
|
4
|
-
|
2
|
+
class ReplaceNextCommand < Redcar::DocumentCommand
|
3
|
+
|
4
|
+
attr_reader :query, :replace, :search_method
|
5
|
+
|
6
|
+
def initialize(query, replace, search_method)
|
7
|
+
@query, @replace, @search_method = query, replace, search_method
|
5
8
|
end
|
6
9
|
|
7
|
-
def
|
10
|
+
def body
|
11
|
+
Search.method(search_method)
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
8
15
|
# Get the current line and then get the line segment from the cursor or selection to the end of the line
|
9
|
-
latest_point = [
|
10
|
-
curr_line_number =
|
11
|
-
cursor_line_offset = latest_point -
|
12
|
-
curr_line =
|
16
|
+
latest_point = [doc.cursor_offset, doc.selection_offset].max
|
17
|
+
curr_line_number = doc.line_at_offset(latest_point)
|
18
|
+
cursor_line_offset = latest_point - doc.offset_at_line(curr_line_number)
|
19
|
+
curr_line = doc.get_line(curr_line_number)
|
13
20
|
line_seg = curr_line[cursor_line_offset..-1]
|
14
21
|
|
15
22
|
# Call the search method passed by the caller
|
@@ -19,63 +26,76 @@ module DocumentSearch
|
|
19
26
|
if new_line
|
20
27
|
# Add the replacment to the end of the line, and then replace in the document
|
21
28
|
curr_line[cursor_line_offset..-1] = new_line
|
22
|
-
|
23
|
-
line_offset =
|
24
|
-
|
29
|
+
doc.replace_line(doc.cursor_line, curr_line.chomp)
|
30
|
+
line_offset = doc.offset_at_line(doc.cursor_line)
|
31
|
+
doc.set_selection_range(cursor_line_offset + line_offset + startoff, cursor_line_offset + line_offset + endoff)
|
25
32
|
return 1
|
26
33
|
end
|
27
34
|
|
28
35
|
#Look at the rest of the lines starting at the next line
|
29
|
-
start_line =
|
30
|
-
(start_line+1
|
31
|
-
new_line, startoff, endoff = body.call(
|
36
|
+
start_line = doc.cursor_line
|
37
|
+
(start_line+1..doc.line_count-1).each do |i|
|
38
|
+
new_line, startoff, endoff = body.call(doc.get_line(i), query, replace)
|
32
39
|
if new_line
|
33
|
-
|
34
|
-
line_offset =
|
35
|
-
|
36
|
-
|
40
|
+
doc.replace_line(i, new_line.chomp)
|
41
|
+
line_offset = doc.offset_at_line(i)
|
42
|
+
doc.set_selection_range(line_offset + startoff, line_offset + endoff)
|
43
|
+
doc.ensure_visible(doc.offset_at_line(i))
|
37
44
|
return 1
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
41
48
|
#Look at the rest of the lines starting at the beginning
|
42
|
-
start_line =
|
49
|
+
start_line = doc.cursor_line
|
43
50
|
(0..start_line-1).each do |i|
|
44
|
-
new_line, startoff, endoff = body.call(
|
51
|
+
new_line, startoff, endoff = body.call(doc.get_line(i), query, replace)
|
45
52
|
|
46
53
|
if new_line
|
47
|
-
|
48
|
-
line_offset =
|
49
|
-
|
50
|
-
|
54
|
+
doc.replace_line(i, new_line.chomp)
|
55
|
+
line_offset = doc.offset_at_line(i)
|
56
|
+
doc.set_selection_range(line_offset + startoff, line_offset + endoff)
|
57
|
+
doc.ensure_visible(doc.offset_at_line(i))
|
51
58
|
return 1
|
52
59
|
end
|
53
60
|
end
|
54
61
|
0
|
55
62
|
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class ReplaceAllCommand < Redcar::DocumentCommand
|
66
|
+
|
67
|
+
attr_reader :query, :replace, :search_method
|
56
68
|
|
57
69
|
# Replace All starts at the begnning of the doc and iterates over all of the lines.
|
58
|
-
def
|
70
|
+
def initialize(query, replace, search_method)
|
71
|
+
@query, @replace, @search_method = query, replace, search_method
|
72
|
+
end
|
73
|
+
|
74
|
+
def body
|
75
|
+
Search.method(search_method)
|
76
|
+
end
|
77
|
+
|
78
|
+
def execute
|
59
79
|
count = 0
|
60
80
|
last_match_line = nil
|
61
81
|
startoff = nil
|
62
82
|
endoff = nil
|
63
|
-
(0..(
|
83
|
+
(0..(doc.line_count-1)).each do |i|
|
64
84
|
begin
|
65
|
-
line, a, b = body.call(
|
85
|
+
line, a, b = body.call(doc.get_line(i), query, replace)
|
66
86
|
if line
|
67
87
|
startoff = a
|
68
88
|
endoff = b
|
69
89
|
last_match_line = i
|
70
|
-
|
90
|
+
doc.replace_line(i, line.chomp)
|
71
91
|
count += 1
|
72
92
|
end
|
73
93
|
end while line != nil
|
74
94
|
end
|
75
95
|
if last_match_line
|
76
|
-
line_offset =
|
77
|
-
|
78
|
-
|
96
|
+
line_offset = doc.offset_at_line(last_match_line)
|
97
|
+
doc.set_selection_range(line_offset + startoff, line_offset + endoff)
|
98
|
+
doc.ensure_visible(doc.offset_at_line(last_match_line))
|
79
99
|
end
|
80
100
|
count
|
81
101
|
end
|
@@ -43,16 +43,17 @@ module DocumentSearch
|
|
43
43
|
current_replace = @previous_replace
|
44
44
|
case @previous_search_type
|
45
45
|
when "Regex"
|
46
|
-
search_method =
|
46
|
+
search_method = :regex_search_method
|
47
47
|
when "Plain"
|
48
|
-
search_method =
|
48
|
+
search_method = :plain_search_method
|
49
49
|
when "Glob"
|
50
|
-
search_method =
|
50
|
+
search_method = :glob_search_method
|
51
51
|
else
|
52
|
-
search_method =
|
52
|
+
search_method = :regex_search_method
|
53
53
|
end
|
54
54
|
adoc = Redcar.app.focussed_notebook_tab.document
|
55
|
-
|
55
|
+
cmd = ReplaceNextCommand.new(current_query, current_replace, search_method)
|
56
|
+
count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
|
56
57
|
if count == 0
|
57
58
|
Redcar::Application::Dialog.message_box("No instance of the search string were found", {:type => :info, :buttons => :ok})
|
58
59
|
end
|
@@ -63,16 +64,16 @@ module DocumentSearch
|
|
63
64
|
current_replace = @previous_replace
|
64
65
|
case @previous_search_type
|
65
66
|
when "Regex"
|
66
|
-
search_method =
|
67
|
+
search_method = :regex_search_method
|
67
68
|
when "Plain"
|
68
|
-
search_method =
|
69
|
+
search_method = :plain_search_method
|
69
70
|
when "Glob"
|
70
|
-
search_method =
|
71
|
+
search_method = :glob_search_method
|
71
72
|
else
|
72
|
-
search_method =
|
73
|
+
search_method = :regex_search_method
|
73
74
|
end
|
74
|
-
|
75
|
-
count =
|
75
|
+
cmd = ReplaceAllCommand.new(current_query, current_replace, search_method)
|
76
|
+
count = cmd.run(:env => {:edit_view => Redcar::EditView.focussed_tab_edit_view})
|
76
77
|
if count == 0 or count > 1
|
77
78
|
message = "Replaced #{count} occurrences"
|
78
79
|
else
|
@@ -7,18 +7,6 @@ def escape_text(text)
|
|
7
7
|
text.gsub("\t", "\\t").gsub("\n", "\\n").gsub("\r", "\\r").gsub("\"", "\\\"")
|
8
8
|
end
|
9
9
|
|
10
|
-
Given /^the contents? is:$/ do |string|
|
11
|
-
start_index = string.index('<c>') || 0
|
12
|
-
end_index = string.index('<s>') && string.index('<s>') - 3 || 0
|
13
|
-
string.gsub!('<s>','')
|
14
|
-
When %{I replace the contents with "#{string}"}
|
15
|
-
When %{I select from #{start_index} to #{end_index}}
|
16
|
-
end
|
17
|
-
|
18
|
-
Then /^the content? should be:$/ do |string|
|
19
|
-
Then %{the contents should be "#{escape_text(string)}"}
|
20
|
-
end
|
21
|
-
|
22
10
|
When /^I undo$/ do
|
23
11
|
Redcar::Top::UndoCommand.new.run
|
24
12
|
end
|
@@ -32,11 +20,6 @@ When /^I select from (\d+) to (\d+)$/ do |start_offset, end_offset|
|
|
32
20
|
doc.set_selection_range(start_offset.to_i, end_offset.to_i)
|
33
21
|
end
|
34
22
|
|
35
|
-
When /^I select all$/ do
|
36
|
-
doc = Redcar.app.focussed_window.focussed_notebook.focussed_tab.edit_view.document
|
37
|
-
doc.set_selection_range(0, doc.length)
|
38
|
-
end
|
39
|
-
|
40
23
|
When /^I copy text$/ do
|
41
24
|
Redcar::Top::CopyCommand.new.run
|
42
25
|
end
|
@@ -232,6 +215,39 @@ When /^I select the word (right of|left of|around|at) (\d+)$/ do |direction, off
|
|
232
215
|
doc.set_selection_range(range.first, range.last)
|
233
216
|
end
|
234
217
|
|
218
|
+
When /^I turn block selection on$/ do
|
219
|
+
Redcar::EditView.focussed_edit_view_document.block_selection_mode?.should == false
|
220
|
+
Redcar::Top::ToggleBlockSelectionCommand.new.run
|
221
|
+
end
|
222
|
+
|
223
|
+
When /^I turn block selection off$/ do
|
224
|
+
Redcar::EditView.focussed_edit_view_document.block_selection_mode?.should == true
|
225
|
+
Redcar::Top::ToggleBlockSelectionCommand.new.run
|
226
|
+
end
|
235
227
|
|
228
|
+
def escape_text(text)
|
229
|
+
text.gsub("\t", "\\t").gsub("\n", "\\n").gsub("\r", "\\r").gsub("\"", "\\\"")
|
230
|
+
end
|
236
231
|
|
232
|
+
Given /^the contents? is:$/ do |string|
|
233
|
+
cursor_index = string.index('<c>')
|
234
|
+
selection_index = string.index('<s>')
|
235
|
+
string = string.gsub('<s>', '').gsub('<c>', '')
|
236
|
+
When %{I replace the contents with "#{string}"}
|
237
|
+
|
238
|
+
if cursor_index and selection_index
|
239
|
+
if cursor_index < selection_index
|
240
|
+
selection_index -= 3
|
241
|
+
else
|
242
|
+
cursor_index -= 3
|
243
|
+
end
|
244
|
+
When %{I select from #{selection_index} to #{cursor_index}}
|
245
|
+
elsif cursor_index
|
246
|
+
When "I move the cursor to #{cursor_index}"
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
Then /^the content? should be:$/ do |string|
|
251
|
+
Then %{the contents should be "#{escape_text(string)}"}
|
252
|
+
end
|
237
253
|
|