redcar-dev 0.12.11dev-java → 0.12.12dev-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/lib/redcar/installer.rb +36 -1
- data/lib/redcar.rb +1 -1
- data/plugins/application/features/navigation_history.feature +66 -0
- data/plugins/application/features/step_definitions/navigation_history_steps.rb +4 -0
- data/plugins/application/lib/application/navigation_history.rb +71 -0
- data/plugins/application/lib/application/tab.rb +1 -1
- data/plugins/application/lib/application.rb +3 -1
- data/plugins/application/spec/application/navigation_history_spec.rb +96 -0
- data/plugins/application_swt/lib/application_swt/notebook.rb +9 -2
- data/plugins/application_swt/lib/application_swt/treebook.rb +8 -2
- data/plugins/application_swt/lib/application_swt.rb +8 -3
- data/plugins/declarations/lib/declarations.rb +7 -1
- data/plugins/edit_view/lib/edit_view/edit_tab.rb +10 -1
- data/plugins/outline_view/lib/outline_view.rb +2 -0
- data/plugins/project/lib/project/dir_mirror.rb +10 -3
- data/plugins/project/lib/project/find_file_dialog.rb +5 -0
- data/plugins/project_search/lib/project_search/word_search_controller.rb +1 -0
- data/plugins/redcar/redcar.rb +23 -0
- data/plugins/splash_screen/splash_screen.rb +4 -4
- data/plugins/tree_view_swt/lib/tree_view_swt.rb +65 -55
- metadata +6 -2
data/CHANGES
CHANGED
@@ -15,6 +15,10 @@ Version 0.12 (TBA)
|
|
15
15
|
* Added open line, transpose characters commands (Dan Lucraft)
|
16
16
|
* OSX style unified toolbars (Dan Lucraft)
|
17
17
|
* Supports OS X Lion fullscreen mode (Dan Lucraft)
|
18
|
+
* Jump back and forward through navigation history (Shinichi Katayama)
|
19
|
+
* Added option to add editable ComboItem widgets to Speedbars (Delisa Mason)
|
20
|
+
* Updated UI Styling (Delisa Mason)
|
21
|
+
* Added option to color tree background color via ApplicationSWT preferences (Delisa Mason)
|
18
22
|
|
19
23
|
Version 0.11 (23 March 2011)
|
20
24
|
============================
|
data/lib/redcar/installer.rb
CHANGED
@@ -25,6 +25,7 @@ module Redcar
|
|
25
25
|
fetch_all_assets
|
26
26
|
precache_textmate_bundles
|
27
27
|
ensure_user_plugins_directory_exists
|
28
|
+
replace_windows_batch_file
|
28
29
|
puts "Success!"
|
29
30
|
puts ""
|
30
31
|
puts "To open just the editor: redcar"
|
@@ -79,6 +80,40 @@ module Redcar
|
|
79
80
|
download_file_to(source, absolute_target)
|
80
81
|
unzip_file(absolute_target) if absolute_target =~ /\.zip$/
|
81
82
|
end
|
83
|
+
|
84
|
+
def replace_windows_batch_file
|
85
|
+
if RUBY_PLATFORM.downcase =~ /mswin|mingw|win32/
|
86
|
+
require 'rbconfig'
|
87
|
+
bin_dir = Config::CONFIG["bindir"]
|
88
|
+
ruby_path = File.join(bin_dir,
|
89
|
+
"rubyw.exe")
|
90
|
+
script_path = File.join(bin_dir,"redcar.bat")
|
91
|
+
File.open script_path, 'w' do |file|
|
92
|
+
file.puts <<-TEXT
|
93
|
+
@Echo Off
|
94
|
+
IF NOT "%~f0" == "~f0" GOTO :WinNT
|
95
|
+
@"#{ruby_path}" "#{File.join(bin_dir,"redcar")}" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
96
|
+
GOTO :EOF
|
97
|
+
:WinNT
|
98
|
+
SET STARTUP=%*
|
99
|
+
SET RUBY="rubyw.exe"
|
100
|
+
|
101
|
+
:LOOP
|
102
|
+
if "%1"=="--with-windows-console" GOTO USERUBY
|
103
|
+
if "%1"=="" GOTO STARTREDCAR
|
104
|
+
shift
|
105
|
+
GOTO LOOP
|
106
|
+
|
107
|
+
:USERUBY
|
108
|
+
SET RUBY="ruby.exe"
|
109
|
+
|
110
|
+
:STARTREDCAR
|
111
|
+
IF NOT "X"%STARTUP% == "X" SET STARTUP=%STARTUP:"="""%
|
112
|
+
start "RedCar" %RUBY% "#{File.join(bin_dir,"redcar")}" %STARTUP%
|
113
|
+
TEXT
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
82
117
|
|
83
118
|
def implicit_target(source)
|
84
119
|
URI.parse(source).path.gsub(/^\//, "")
|
@@ -140,4 +175,4 @@ module Redcar
|
|
140
175
|
end
|
141
176
|
end
|
142
177
|
end
|
143
|
-
end
|
178
|
+
end
|
data/lib/redcar.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
Feature: Navigation History
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I have opened "plugins/application/spec/application/navigation_history_spec.rb"
|
5
|
+
And I move to line 2
|
6
|
+
And I run the command Redcar::OutlineView::OpenOutlineViewCommand
|
7
|
+
And I select the outline view
|
8
|
+
Then the cursor should be on line 1
|
9
|
+
And I run the command Redcar::OutlineView::OpenOutlineViewCommand
|
10
|
+
When I set the outline filter to "con"
|
11
|
+
And I wait 2 seconds
|
12
|
+
And I select the outline view
|
13
|
+
Then the cursor should be on line 14
|
14
|
+
Given I have opened "plugins/application/lib/application/navigation_history.rb"
|
15
|
+
And I move to line 5
|
16
|
+
And I run the command Redcar::OutlineView::OpenOutlineViewCommand
|
17
|
+
And I select the outline view
|
18
|
+
Then the cursor should be on line 0
|
19
|
+
|
20
|
+
Scenario: Backward/forward history
|
21
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
22
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
23
|
+
And the cursor should be on line 5
|
24
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
25
|
+
Then the focussed document path is "plugins/application/spec/application/navigation_history_spec.rb"
|
26
|
+
And the cursor should be on line 14
|
27
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
28
|
+
Then the focussed document path is "plugins/application/spec/application/navigation_history_spec.rb"
|
29
|
+
And the cursor should be on line 1
|
30
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
31
|
+
Then the focussed document path is "plugins/application/spec/application/navigation_history_spec.rb"
|
32
|
+
And the cursor should be on line 2
|
33
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
34
|
+
Then the focussed document path is "plugins/application/spec/application/navigation_history_spec.rb"
|
35
|
+
And the cursor should be on line 1
|
36
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
37
|
+
Then the focussed document path is "plugins/application/spec/application/navigation_history_spec.rb"
|
38
|
+
And the cursor should be on line 14
|
39
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
40
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
41
|
+
And the cursor should be on line 5
|
42
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
43
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
44
|
+
And the cursor should be on line 0
|
45
|
+
|
46
|
+
Scenario: Change middle history
|
47
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
48
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
49
|
+
And the cursor should be on line 5
|
50
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
51
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
52
|
+
And the cursor should be on line 0
|
53
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
54
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
55
|
+
And the cursor should be on line 5
|
56
|
+
And I run the command Redcar::OutlineView::OpenOutlineViewCommand
|
57
|
+
When I set the outline filter to "can"
|
58
|
+
And I wait 2 seconds
|
59
|
+
And I select the outline view
|
60
|
+
Then the cursor should be on line 21
|
61
|
+
When I run the command Redcar::Top::BackwardNavigationCommand
|
62
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
63
|
+
And the cursor should be on line 5
|
64
|
+
When I run the command Redcar::Top::ForwardNavigationCommand
|
65
|
+
Then the focussed document path is "plugins/application/lib/application/navigation_history.rb"
|
66
|
+
And the cursor should be on line 21
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Redcar
|
2
|
+
# A class that holds a cursor navigation history. The maximum length
|
3
|
+
# defaults to 100.
|
4
|
+
class NavigationHistory < Array
|
5
|
+
def initialize
|
6
|
+
@max_history_size = 100
|
7
|
+
@current = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def save(doc)
|
11
|
+
return if last && last[:path] == doc.path && last[:cursor_offset] == doc.cursor_offset
|
12
|
+
|
13
|
+
# Invoking this method means new future is about to be created, so remove old one.
|
14
|
+
self.slice!(@current...self.size)
|
15
|
+
|
16
|
+
ensure_size_less_than_max
|
17
|
+
self << {:path => doc.path, :cursor_offset => doc.cursor_offset}
|
18
|
+
@current += 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def can_backward?
|
22
|
+
return @current > 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def backward
|
26
|
+
move_current_and_restore(-1) if can_backward?
|
27
|
+
end
|
28
|
+
|
29
|
+
def can_forward?
|
30
|
+
return @current < self.size - 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def forward
|
34
|
+
move_current_and_restore(1) if can_forward?
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def ensure_size_less_than_max
|
40
|
+
while self.size >= @max_history_size
|
41
|
+
self.delete_at(0)
|
42
|
+
@current -= 1
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def move_current_and_restore(history_size)
|
47
|
+
save_current_doc
|
48
|
+
@current += history_size
|
49
|
+
restore_hisotry
|
50
|
+
end
|
51
|
+
|
52
|
+
def restore_hisotry
|
53
|
+
Project::Manager.open_file(self[@current][:path])
|
54
|
+
new_doc = Redcar.app.focussed_window.focussed_notebook_tab_document
|
55
|
+
new_doc.cursor_offset = self[@current][:cursor_offset]
|
56
|
+
new_doc.ensure_cursor_visible
|
57
|
+
end
|
58
|
+
|
59
|
+
def save_current_doc
|
60
|
+
if win = Redcar.app.focussed_window and cur_doc = win.focussed_notebook_tab_document
|
61
|
+
history = {:path => cur_doc.path, :cursor_offset => cur_doc.cursor_offset}
|
62
|
+
if @current < self.size
|
63
|
+
self[@current] = history
|
64
|
+
else
|
65
|
+
save(cur_doc)
|
66
|
+
@current = self.size - 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -24,6 +24,7 @@ require 'application/menu/item'
|
|
24
24
|
require 'application/menu/lazy_menu'
|
25
25
|
require 'application/menu/builder'
|
26
26
|
require 'application/menu/builder/group'
|
27
|
+
require 'application/navigation_history'
|
27
28
|
require 'application/notebook'
|
28
29
|
require 'application/speedbar'
|
29
30
|
require 'application/tab'
|
@@ -106,7 +107,7 @@ module Redcar
|
|
106
107
|
]
|
107
108
|
end
|
108
109
|
|
109
|
-
attr_reader :clipboard, :keymap, :menu, :toolbar, :history, :task_queue, :show_toolbar
|
110
|
+
attr_reader :clipboard, :keymap, :menu, :toolbar, :history, :task_queue, :show_toolbar, :navigation_history
|
110
111
|
|
111
112
|
# Create an application instance with a Redcar::Clipboard and a Redcar::History.
|
112
113
|
def initialize
|
@@ -114,6 +115,7 @@ module Redcar
|
|
114
115
|
@window_handlers = Hash.new {|h,k| h[k] = []}
|
115
116
|
create_clipboard
|
116
117
|
create_history
|
118
|
+
@navigation_history = NavigationHistory.new
|
117
119
|
@event_spewer = EventSpewer.new
|
118
120
|
@task_queue = TaskQueue.new
|
119
121
|
@show_toolbar = !!Application.storage['show_toolbar']
|
@@ -0,0 +1,96 @@
|
|
1
|
+
describe Redcar::NavigationHistory do
|
2
|
+
module NavigationHistoryTest
|
3
|
+
class TestEditView
|
4
|
+
include Redcar::Observable
|
5
|
+
attr_accessor :title
|
6
|
+
|
7
|
+
def controller
|
8
|
+
o = Object.new
|
9
|
+
def o.method_missing(*_)
|
10
|
+
end
|
11
|
+
o
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class TestDocumentController
|
16
|
+
attr_accessor :text, :cursor_offset
|
17
|
+
|
18
|
+
def line_at_offset(_)
|
19
|
+
0
|
20
|
+
end
|
21
|
+
|
22
|
+
def line_count
|
23
|
+
0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class TestMirror
|
28
|
+
include Redcar::Observable
|
29
|
+
attr_accessor :path
|
30
|
+
|
31
|
+
def read
|
32
|
+
"Test content"
|
33
|
+
end
|
34
|
+
|
35
|
+
def title
|
36
|
+
"foo"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Redcar::NavigationHistory
|
42
|
+
attr_accessor :current, :max_history_size
|
43
|
+
end
|
44
|
+
|
45
|
+
before do
|
46
|
+
@controller = NavigationHistoryTest::TestDocumentController.new
|
47
|
+
@controller.cursor_offset = 100
|
48
|
+
@mirror = NavigationHistoryTest::TestMirror.new
|
49
|
+
@mirror.path = "hoge.rb"
|
50
|
+
@doc = Redcar::Document.new(NavigationHistoryTest::TestEditView.new)
|
51
|
+
@doc.controller = @controller
|
52
|
+
@doc.mirror = @mirror
|
53
|
+
@history = Redcar::NavigationHistory.new
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should save current cursor location" do
|
57
|
+
@doc.cursor_offset.should == 100
|
58
|
+
@history.size.should == 0
|
59
|
+
@history.save(@doc)
|
60
|
+
@history.size.should == 1
|
61
|
+
@history[0][:path].should == "hoge.rb"
|
62
|
+
@history[0][:cursor_offset].should == 100
|
63
|
+
end
|
64
|
+
|
65
|
+
it "can backward?" do
|
66
|
+
@history.save(@doc)
|
67
|
+
@history.can_backward?.should be_true
|
68
|
+
end
|
69
|
+
|
70
|
+
it "can forward?" do
|
71
|
+
@history.save(@doc)
|
72
|
+
@controller.cursor_offset = 50
|
73
|
+
@history.save(@doc)
|
74
|
+
@history.size.should == 2
|
75
|
+
@history.current -= 2
|
76
|
+
@history.can_forward?.should be_true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should not exceed max history size" do
|
80
|
+
(@history.max_history_size + 10).times do
|
81
|
+
@history.save(@doc)
|
82
|
+
@controller.cursor_offset += 1
|
83
|
+
end
|
84
|
+
@history.size.should == @history.max_history_size
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should delete old future when forward" do
|
88
|
+
5.times do
|
89
|
+
@history.save(@doc)
|
90
|
+
@controller.cursor_offset += 1
|
91
|
+
end
|
92
|
+
@history.current = 2
|
93
|
+
@history.save(@doc)
|
94
|
+
@history.size.should == 3
|
95
|
+
end
|
96
|
+
end
|
@@ -53,10 +53,17 @@ module Redcar
|
|
53
53
|
attach_model_listeners
|
54
54
|
attach_view_listeners
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def create_tab_folder(sash)
|
58
|
-
folder_style = Swt::SWT::
|
58
|
+
folder_style = Swt::SWT::CLOSE
|
59
59
|
@tab_folder = Swt::Custom::CTabFolder.new(sash, folder_style)
|
60
|
+
font_data = @tab_folder.font.font_data.first
|
61
|
+
font = Swt::Graphics::Font.new(
|
62
|
+
ApplicationSWT.display,
|
63
|
+
font_data.name,
|
64
|
+
Redcar::EditView.font_size - 1,
|
65
|
+
Swt::SWT::NORMAL)
|
66
|
+
@tab_folder.font = font
|
60
67
|
grid_data = Swt::Layout::GridData.new
|
61
68
|
grid_data.grabExcessHorizontalSpace = true
|
62
69
|
grid_data.horizontalAlignment = Swt::Layout::GridData::FILL
|
@@ -4,7 +4,7 @@ require 'swt/vtab_item'
|
|
4
4
|
module Redcar
|
5
5
|
class ApplicationSWT
|
6
6
|
class Treebook
|
7
|
-
attr_reader :tab_folder
|
7
|
+
attr_reader :tab_folder, :font
|
8
8
|
|
9
9
|
def initialize(window, model)
|
10
10
|
@window, @model = window, model
|
@@ -38,7 +38,13 @@ module Redcar
|
|
38
38
|
|
39
39
|
def create_tree_view
|
40
40
|
@tab_folder = Swt::Widgets::VTabFolder.new(@window.tree_sash, Swt::SWT::NONE)
|
41
|
-
|
41
|
+
font_data = @tab_folder.font.font_data.first
|
42
|
+
font = Swt::Graphics::Font.new(
|
43
|
+
ApplicationSWT.display,
|
44
|
+
font_data.name,
|
45
|
+
Redcar::EditView.font_size - 1,
|
46
|
+
Swt::SWT::NORMAL)
|
47
|
+
@tab_folder.font = font
|
42
48
|
selected_tab_background = Redcar::ApplicationSWT.selected_tab_background
|
43
49
|
@tab_folder.set_selection_background(selected_tab_background.swt_colors, selected_tab_background.swt_stops, true)
|
44
50
|
|
@@ -50,20 +50,25 @@ module Redcar
|
|
50
50
|
Redcar.gui.register_dialog_adapter(ApplicationSWT::DialogAdapter.new)
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
def self.selected_tab_background
|
55
55
|
Gradient.new(Redcar::ApplicationSWT.storage['selected_tab_background'])
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def self.unselected_tab_background
|
59
59
|
Gradient.new(Redcar::ApplicationSWT.storage['unselected_tab_background'])
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
|
+
def self.tree_background
|
63
|
+
Gradient.new(Redcar::ApplicationSWT.storage['tree_background'])
|
64
|
+
end
|
65
|
+
|
62
66
|
def self.storage
|
63
67
|
@storage ||= begin
|
64
68
|
storage = Plugin::Storage.new('application_swt')
|
65
69
|
storage.set_default('selected_tab_background', {0 => "#FEFEFE", 100 => "#EEEEEE"})
|
66
70
|
storage.set_default('unselected_tab_background', {0 => "#E5E5E5", 100 => "#D0D0D0"})
|
71
|
+
storage.set_default('tree_background', "#FFFFFF")
|
67
72
|
storage
|
68
73
|
end
|
69
74
|
end
|
@@ -87,7 +87,7 @@ module Redcar
|
|
87
87
|
@tags_for_path.delete(path)
|
88
88
|
end
|
89
89
|
|
90
|
-
def self.go_to_definition(match)
|
90
|
+
def self.go_to_definition(match)
|
91
91
|
path = match[:file]
|
92
92
|
Project::Manager.open_file(path)
|
93
93
|
regexp = Regexp.new(Regexp.escape(match[:match]))
|
@@ -127,6 +127,10 @@ module Redcar
|
|
127
127
|
return
|
128
128
|
end
|
129
129
|
matches = find_tag(tags_path, token).uniq
|
130
|
+
|
131
|
+
# save current cursor position before jump to another location.
|
132
|
+
Redcar.app.navigation_history.save(doc) if matches.size > 0
|
133
|
+
|
130
134
|
case matches.size
|
131
135
|
when 0
|
132
136
|
Application::Dialog.message_box("There is no declaration for '#{token}' in the 'tags' file.")
|
@@ -135,6 +139,8 @@ module Redcar
|
|
135
139
|
else
|
136
140
|
open_select_tag_dialog(matches)
|
137
141
|
end
|
142
|
+
|
143
|
+
Redcar.app.navigation_history.save(doc) if matches.size > 0
|
138
144
|
end
|
139
145
|
|
140
146
|
def find_tag(tags_path, tag)
|
@@ -15,7 +15,16 @@ module Redcar
|
|
15
15
|
unless doc.mirror.adapter.is_a?(Redcar::Project::Adapters::Remote)
|
16
16
|
if File.exists?(doc.path)
|
17
17
|
if File.writable?(doc.path)
|
18
|
-
|
18
|
+
key = File.basename(doc.path).split('.').last.split(//).first.downcase
|
19
|
+
if key =~ /[a-z]/
|
20
|
+
if key == 'a'
|
21
|
+
i = :document_attribute
|
22
|
+
else
|
23
|
+
i = :"document_attribute_#{key}"
|
24
|
+
end
|
25
|
+
else
|
26
|
+
i = DEFAULT_ICON
|
27
|
+
end
|
19
28
|
else
|
20
29
|
i = NO_WRITE_ICON
|
21
30
|
end
|
@@ -55,7 +55,9 @@ module Redcar
|
|
55
55
|
|
56
56
|
def selected(match, closing=true)
|
57
57
|
if @last_list
|
58
|
+
Redcar.app.navigation_history.save(@document)
|
58
59
|
DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(match)), true).run_in_focussed_tab_edit_view
|
60
|
+
Redcar.app.navigation_history.save(@document)
|
59
61
|
close if closing
|
60
62
|
end
|
61
63
|
end
|
@@ -118,12 +118,19 @@ module Redcar
|
|
118
118
|
def icon
|
119
119
|
case @type
|
120
120
|
when :file
|
121
|
-
|
121
|
+
key = text.split('.').last.split(//).first.downcase
|
122
|
+
if key =~ /[b-z]/
|
123
|
+
:"document_attribute_#{key}"
|
124
|
+
elsif key == 'a'
|
125
|
+
:document_attribute
|
126
|
+
else
|
127
|
+
:document
|
128
|
+
end
|
122
129
|
when :dir
|
123
|
-
:
|
130
|
+
:blue_folder
|
124
131
|
end
|
125
132
|
end
|
126
|
-
|
133
|
+
|
127
134
|
def leaf?
|
128
135
|
file?
|
129
136
|
end
|
@@ -45,7 +45,12 @@ module Redcar
|
|
45
45
|
def selected(text, ix, closing=false)
|
46
46
|
if @last_list
|
47
47
|
close
|
48
|
+
if win = Redcar.app.focussed_window and tab = win.focussed_notebook_tab and doc = tab.document
|
49
|
+
Redcar.app.navigation_history.save(doc)
|
50
|
+
end
|
48
51
|
OpenFileCommand.new(@last_list[ix]).run
|
52
|
+
cur_doc = Redcar.app.focussed_window.focussed_notebook_tab.document
|
53
|
+
Redcar.app.navigation_history.save(cur_doc) if cur_doc
|
49
54
|
end
|
50
55
|
end
|
51
56
|
|
data/plugins/redcar/redcar.rb
CHANGED
@@ -293,6 +293,18 @@ Redcar.environment: #{Redcar.environment}
|
|
293
293
|
end
|
294
294
|
end
|
295
295
|
end
|
296
|
+
|
297
|
+
class BackwardNavigationCommand < Command
|
298
|
+
def execute
|
299
|
+
Redcar.app.navigation_history.backward
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
class ForwardNavigationCommand < Command
|
304
|
+
def execute
|
305
|
+
Redcar.app.navigation_history.forward
|
306
|
+
end
|
307
|
+
end
|
296
308
|
|
297
309
|
class ChangeIndentCommand < DocumentCommand
|
298
310
|
def execute
|
@@ -670,6 +682,9 @@ Redcar.environment: #{Redcar.environment}
|
|
670
682
|
link "Ctrl+O", OpenLineCommand
|
671
683
|
link "Ctrl+D", DeleteCharCommand
|
672
684
|
link "Ctrl+H", BackspaceCommand
|
685
|
+
|
686
|
+
link "Ctrl+Alt+Left", BackwardNavigationCommand
|
687
|
+
link "Ctrl+Alt+Right", ForwardNavigationCommand
|
673
688
|
|
674
689
|
link "Cmd+[", DecreaseIndentCommand
|
675
690
|
link "Cmd+]", IncreaseIndentCommand
|
@@ -759,6 +774,9 @@ Redcar.environment: #{Redcar.environment}
|
|
759
774
|
link "End", MoveEndCommand
|
760
775
|
link "Ctrl+Alt+E", MoveEndCommand
|
761
776
|
link "Ctrl+End", MoveBottomCommand
|
777
|
+
|
778
|
+
link "Alt+[", BackwardNavigationCommand
|
779
|
+
link "Alt+]", ForwardNavigationCommand
|
762
780
|
|
763
781
|
link "Ctrl+[", DecreaseIndentCommand
|
764
782
|
link "Ctrl+]", IncreaseIndentCommand
|
@@ -911,6 +929,11 @@ Redcar.environment: #{Redcar.environment}
|
|
911
929
|
item "Delete Character", DeleteCharCommand
|
912
930
|
item "Backspace", BackspaceCommand
|
913
931
|
item "Transpose", TransposeCharactersCommand
|
932
|
+
|
933
|
+
separator
|
934
|
+
|
935
|
+
item "Backward Navigation", BackwardNavigationCommand
|
936
|
+
item "Forward Navigation", ForwardNavigationCommand
|
914
937
|
end
|
915
938
|
end
|
916
939
|
|
@@ -18,7 +18,7 @@ module Redcar
|
|
18
18
|
|
19
19
|
def show
|
20
20
|
@image = Swt::Graphics::Image.new(Swt.display, Redcar.icons_directory + "/redcar-splash.png")
|
21
|
-
@splash = Swt::Widgets::Shell.new(Swt::SWT::
|
21
|
+
@splash = Swt::Widgets::Shell.new(Swt::SWT::NO_TRIM)
|
22
22
|
@bar = Swt::Widgets::ProgressBar.new(@splash, Swt::SWT::NONE)
|
23
23
|
@bar.setMaximum(max)
|
24
24
|
label = Swt::Widgets::Label.new(@splash, Swt::SWT::NONE)
|
@@ -30,9 +30,9 @@ module Redcar
|
|
30
30
|
labelData.bottom = Swt::Layout::FormAttachment.new(100, 0)
|
31
31
|
label.setLayoutData(labelData)
|
32
32
|
progressData = Swt::Layout::FormData.new
|
33
|
-
progressData.left = Swt::Layout::FormAttachment.new(0,
|
34
|
-
progressData.right = Swt::Layout::FormAttachment.new(100, -
|
35
|
-
progressData.bottom = Swt::Layout::FormAttachment.new(100, -
|
33
|
+
progressData.left = Swt::Layout::FormAttachment.new(0, 70)
|
34
|
+
progressData.right = Swt::Layout::FormAttachment.new(100, -32)
|
35
|
+
progressData.bottom = Swt::Layout::FormAttachment.new(100, -30)
|
36
36
|
@bar.setLayoutData(progressData)
|
37
37
|
@splash.pack
|
38
38
|
|
@@ -12,9 +12,17 @@ module Redcar
|
|
12
12
|
storage
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def initialize(composite, model)
|
17
17
|
@composite, @model = composite, model
|
18
|
+
color = ApplicationSWT.tree_background.swt_colors.first
|
19
|
+
font_data = @composite.font.font_data.first
|
20
|
+
font = Swt::Graphics::Font.new(
|
21
|
+
ApplicationSWT.display,
|
22
|
+
font_data.name,
|
23
|
+
Redcar::EditView.font_size - 1,
|
24
|
+
Swt::SWT::NORMAL)
|
25
|
+
@composite.background = color
|
18
26
|
tree_style = Swt::SWT::MULTI | Swt::SWT::H_SCROLL | Swt::SWT::V_SCROLL
|
19
27
|
@viewer = JFace::Viewers::TreeViewer.new(@composite, tree_style)
|
20
28
|
grid_data = Swt::Layout::GridData.new
|
@@ -26,11 +34,13 @@ module Redcar
|
|
26
34
|
@composite.layout
|
27
35
|
JFace::Viewers::ColumnViewerToolTipSupport.enableFor(@viewer)
|
28
36
|
@viewer.set_content_provider(TreeMirrorContentProvider.new(self))
|
37
|
+
@viewer.tree.font = font
|
38
|
+
@viewer.tree.background = color
|
29
39
|
#@viewer.getTree.setLinesVisible(true)
|
30
40
|
#@viewer.getTree.setHeaderVisible(true)
|
31
41
|
@viewer.set_label_provider(TreeMirrorLabelProvider.new(self))
|
32
42
|
@viewer.set_input(@model.tree_mirror)
|
33
|
-
|
43
|
+
|
34
44
|
if @model.tree_controller
|
35
45
|
@viewer.add_tree_listener(@viewer.getControl, TreeListener.new)
|
36
46
|
@viewer.add_double_click_listener(DoubleClickListener.new)
|
@@ -38,9 +48,9 @@ module Redcar
|
|
38
48
|
@viewer.add_selection_changed_listener(SelectionChangedListener.new(@model, @viewer))
|
39
49
|
control.add_mouse_listener(MouseListener.new(self))
|
40
50
|
end
|
41
|
-
|
51
|
+
|
42
52
|
register_dnd if @model.tree_mirror.drag_and_drop?
|
43
|
-
|
53
|
+
|
44
54
|
@model.add_listener(:refresh) do
|
45
55
|
begin
|
46
56
|
@model.tree_mirror.refresh_operation(@model) do
|
@@ -50,12 +60,12 @@ module Redcar
|
|
50
60
|
handle_mirror_error(e)
|
51
61
|
end
|
52
62
|
end
|
53
|
-
|
63
|
+
|
54
64
|
@editor = Swt::Custom::TreeEditor.new(control)
|
55
|
-
|
65
|
+
|
56
66
|
@editor.horizontalAlignment = Swt::SWT::LEFT
|
57
67
|
@editor.grabHorizontal = true
|
58
|
-
|
68
|
+
|
59
69
|
@model.add_listener(:edit_element, &method(:edit_element))
|
60
70
|
@model.add_listener(:expand_element, &method(:expand_element))
|
61
71
|
@model.add_listener(:select_element, &method(:select_element))
|
@@ -70,12 +80,12 @@ module Redcar
|
|
70
80
|
|
71
81
|
class DragSourceListener
|
72
82
|
attr_reader :tree, :dragged_elements
|
73
|
-
|
83
|
+
|
74
84
|
def initialize(tree_view_swt, tree)
|
75
85
|
@tree_view_swt = tree_view_swt
|
76
86
|
@tree = tree
|
77
87
|
end
|
78
|
-
|
88
|
+
|
79
89
|
def drag_start(event)
|
80
90
|
selection = tree.get_selection
|
81
91
|
if selection.length > 0
|
@@ -90,7 +100,7 @@ module Redcar
|
|
90
100
|
event.doit = false
|
91
101
|
end
|
92
102
|
end
|
93
|
-
|
103
|
+
|
94
104
|
def drag_set_data(event)
|
95
105
|
case tree_mirror.data_type
|
96
106
|
when :file
|
@@ -107,28 +117,28 @@ module Redcar
|
|
107
117
|
raise "unknown tree data_type #{tree.tree_mirror.data_type}"
|
108
118
|
end
|
109
119
|
end
|
110
|
-
|
120
|
+
|
111
121
|
def drag_finished(*_); end
|
112
|
-
|
122
|
+
|
113
123
|
def tree_mirror
|
114
124
|
@tree_view_swt.model.tree_mirror
|
115
125
|
end
|
116
126
|
end
|
117
|
-
|
127
|
+
|
118
128
|
class DropAdapter < JFace::Viewers::ViewerDropAdapter
|
119
129
|
def initialize(tree_view_swt, drag_source_listener, viewer)
|
120
130
|
@tree_view_swt = tree_view_swt
|
121
131
|
@drag_source_listener = drag_source_listener
|
122
132
|
super(viewer)
|
123
133
|
end
|
124
|
-
|
134
|
+
|
125
135
|
def validateDrop(target, operation, transfer_data_type)
|
126
136
|
pos = location_to_position(get_current_location)
|
127
137
|
Redcar.safely do
|
128
138
|
@tree_view_swt.drag_controller.can_drop?(@drag_source_listener.dragged_elements, target, pos)
|
129
139
|
end
|
130
140
|
end
|
131
|
-
|
141
|
+
|
132
142
|
def performDrop(data)
|
133
143
|
elements = data.to_a.map {|datum| @tree_view_swt.model.tree_mirror.from_data(datum) }
|
134
144
|
pos = location_to_position(get_current_location)
|
@@ -139,9 +149,9 @@ module Redcar
|
|
139
149
|
end
|
140
150
|
true
|
141
151
|
end
|
142
|
-
|
152
|
+
|
143
153
|
private
|
144
|
-
|
154
|
+
|
145
155
|
def location_to_position(location)
|
146
156
|
if Redcar.safely { @tree_view_swt.drag_controller.reorderable? }
|
147
157
|
{1 => :before, 2 => :after, 3 => :onto}[location]
|
@@ -150,7 +160,7 @@ module Redcar
|
|
150
160
|
end
|
151
161
|
end
|
152
162
|
end
|
153
|
-
|
163
|
+
|
154
164
|
def register_dnd
|
155
165
|
case Redcar.safely { @model.tree_mirror.data_type }
|
156
166
|
when :file
|
@@ -161,31 +171,31 @@ module Redcar
|
|
161
171
|
raise "unknown tree data_type #{Redcar.safely { tree.tree_mirror.data_type }}"
|
162
172
|
end
|
163
173
|
operations = Swt::DND::DND::DROP_MOVE | Swt::DND::DND::DROP_COPY
|
164
|
-
|
174
|
+
|
165
175
|
source_listener = DragSourceListener.new(self, @viewer.get_tree)
|
166
176
|
drop_adapter = DropAdapter.new(self, source_listener, @viewer)
|
167
177
|
drop_adapter.set_feedback_enabled(drag_controller.reorderable?)
|
168
|
-
|
178
|
+
|
169
179
|
@viewer.add_drag_support(operations, types, source_listener)
|
170
180
|
@viewer.add_drop_support(operations, types, drop_adapter)
|
171
181
|
end
|
172
|
-
|
182
|
+
|
173
183
|
def drag_controller
|
174
184
|
@model.tree_controller.drag_controller(@model)
|
175
185
|
end
|
176
|
-
|
186
|
+
|
177
187
|
def edit_element(element, select_from, select_to)
|
178
188
|
item = element_to_item(element)
|
179
189
|
unless item
|
180
190
|
puts "ERROR: when trying to edit, no visible item for #{element.inspect}"
|
181
191
|
return
|
182
192
|
end
|
183
|
-
|
193
|
+
|
184
194
|
text = Swt::Widgets::Text.new(control, Swt::SWT::NONE)
|
185
195
|
text.set_text(item.get_text)
|
186
196
|
colour = ApplicationSWT.display.get_system_color(Swt::SWT::COLOR_GRAY)
|
187
197
|
text.set_background(colour)
|
188
|
-
|
198
|
+
|
189
199
|
@editor.set_editor(text, item)
|
190
200
|
text.set_selection(select_from || 0, select_to || text.get_text.length)
|
191
201
|
listener = EditorListener.new(self, element, text)
|
@@ -194,7 +204,7 @@ module Redcar
|
|
194
204
|
|
195
205
|
text.set_focus
|
196
206
|
end
|
197
|
-
|
207
|
+
|
198
208
|
def edited_element(element, text)
|
199
209
|
if @model.tree_controller and @model.tree_controller.respond_to?(:edited)
|
200
210
|
Redcar.safely("edit element") do
|
@@ -202,13 +212,13 @@ module Redcar
|
|
202
212
|
end
|
203
213
|
end
|
204
214
|
end
|
205
|
-
|
215
|
+
|
206
216
|
def expand_element(element)
|
207
217
|
if item = element_to_item(element)
|
208
218
|
@viewer.expandToLevel(element, 1)
|
209
219
|
end
|
210
220
|
end
|
211
|
-
|
221
|
+
|
212
222
|
def focus
|
213
223
|
@viewer.get_tree.set_focus
|
214
224
|
end
|
@@ -222,21 +232,21 @@ module Redcar
|
|
222
232
|
def element_to_item(element)
|
223
233
|
@viewer.test_find_item(element)
|
224
234
|
end
|
225
|
-
|
235
|
+
|
226
236
|
def item_to_element(item)
|
227
237
|
@viewer.getViewerRowFromItem(item).get_element
|
228
238
|
end
|
229
|
-
|
239
|
+
|
230
240
|
def selection
|
231
241
|
@viewer.get_tree.get_selection.map {|i| item_to_element(i) }
|
232
242
|
end
|
233
|
-
|
243
|
+
|
234
244
|
def visible_nodes
|
235
245
|
items = @viewer.get_tree.get_items
|
236
246
|
all_items = items.map {|item| [item, visible_children_of(item)] }.flatten
|
237
247
|
all_items.map {|item| item_to_element(item) }
|
238
248
|
end
|
239
|
-
|
249
|
+
|
240
250
|
def visible_children_of(item)
|
241
251
|
if item.get_expanded
|
242
252
|
items = item.get_items
|
@@ -245,14 +255,14 @@ module Redcar
|
|
245
255
|
[]
|
246
256
|
end
|
247
257
|
end
|
248
|
-
|
258
|
+
|
249
259
|
class EditorListener
|
250
260
|
def initialize(tree_view_swt, element, text_widget)
|
251
261
|
@tree_view_swt = tree_view_swt
|
252
262
|
@element = element
|
253
263
|
@text = text_widget
|
254
264
|
end
|
255
|
-
|
265
|
+
|
256
266
|
def handle_event(e)
|
257
267
|
case e.type
|
258
268
|
when Swt::SWT::FocusOut
|
@@ -273,11 +283,11 @@ module Redcar
|
|
273
283
|
end
|
274
284
|
end
|
275
285
|
end
|
276
|
-
|
286
|
+
|
277
287
|
def control
|
278
288
|
@viewer.get_control
|
279
289
|
end
|
280
|
-
|
290
|
+
|
281
291
|
def close
|
282
292
|
@viewer.getControl.dispose
|
283
293
|
end
|
@@ -295,7 +305,7 @@ module Redcar
|
|
295
305
|
end
|
296
306
|
end
|
297
307
|
end
|
298
|
-
|
308
|
+
|
299
309
|
def handle_mirror_error(e)
|
300
310
|
if @model.tree_controller.respond_to?(:handle_error)
|
301
311
|
begin
|
@@ -311,45 +321,45 @@ module Redcar
|
|
311
321
|
Application::Dialog.message_box(e.message, :type => :error)
|
312
322
|
end
|
313
323
|
end
|
314
|
-
|
324
|
+
|
315
325
|
class TreeListener
|
316
326
|
def tree_collapsed(e)
|
317
327
|
end
|
318
|
-
|
328
|
+
|
319
329
|
def tree_expanded(e)
|
320
330
|
end
|
321
331
|
end
|
322
|
-
|
332
|
+
|
323
333
|
class SelectionListener
|
324
334
|
def widget_default_selected(e)
|
325
335
|
end
|
326
|
-
|
336
|
+
|
327
337
|
def widget_selected(e)
|
328
338
|
end
|
329
339
|
end
|
330
|
-
|
340
|
+
|
331
341
|
class MouseListener
|
332
342
|
def initialize(tree_view_swt)
|
333
343
|
@tree_view_swt = tree_view_swt
|
334
344
|
end
|
335
|
-
|
345
|
+
|
336
346
|
def mouse_double_click(_); end
|
337
347
|
def mouse_up(_)
|
338
348
|
end
|
339
|
-
|
349
|
+
|
340
350
|
def mouse_down(e)
|
341
351
|
if e.button == 3
|
342
352
|
@tree_view_swt.right_click(e)
|
343
353
|
end
|
344
354
|
end
|
345
355
|
end
|
346
|
-
|
356
|
+
|
347
357
|
class SelectionChangedListener
|
348
358
|
def initialize(tree_model, viewer)
|
349
359
|
@tree_model = tree_model
|
350
360
|
@viewer = viewer
|
351
361
|
end
|
352
|
-
|
362
|
+
|
353
363
|
def selection_changed(e)
|
354
364
|
Redcar.safely do
|
355
365
|
element = e.getSelection.toArray.to_a.first
|
@@ -359,7 +369,7 @@ module Redcar
|
|
359
369
|
end
|
360
370
|
end
|
361
371
|
end
|
362
|
-
|
372
|
+
|
363
373
|
class DoubleClickListener
|
364
374
|
def double_click(e)
|
365
375
|
|
@@ -369,7 +379,7 @@ module Redcar
|
|
369
379
|
return if double_clicked_element.leaf?
|
370
380
|
|
371
381
|
viewer = e.get_viewer
|
372
|
-
node_is_expanded = viewer.getExpandedState(double_clicked_element)
|
382
|
+
node_is_expanded = viewer.getExpandedState(double_clicked_element)
|
373
383
|
|
374
384
|
if node_is_expanded
|
375
385
|
viewer.collapseToLevel(double_clicked_element, 1)
|
@@ -379,22 +389,22 @@ module Redcar
|
|
379
389
|
rescue
|
380
390
|
end
|
381
391
|
end
|
382
|
-
|
392
|
+
|
383
393
|
class OpenListener
|
384
394
|
def initialize(tree_model)
|
385
395
|
@tree_model = tree_model
|
386
396
|
end
|
387
|
-
|
397
|
+
|
388
398
|
def open(e)
|
389
399
|
Redcar.safely("tree row activation") do
|
390
400
|
@tree_model.tree_controller.activated(@tree_model, e.getSelection.toArray.to_a.first)
|
391
401
|
end
|
392
402
|
end
|
393
403
|
end
|
394
|
-
|
404
|
+
|
395
405
|
class TreeMirrorContentProvider
|
396
406
|
include JFace::Viewers::ITreeContentProvider
|
397
|
-
|
407
|
+
|
398
408
|
def initialize(tree_view_swt)
|
399
409
|
@tree_view_swt = tree_view_swt
|
400
410
|
end
|
@@ -431,7 +441,7 @@ module Redcar
|
|
431
441
|
puts e.backtrace
|
432
442
|
@tree_view_swt.handle_mirror_error(e)
|
433
443
|
end
|
434
|
-
|
444
|
+
|
435
445
|
def get_parent(tree_node)
|
436
446
|
# not sure why this is necessary
|
437
447
|
end
|
@@ -442,7 +452,7 @@ module Redcar
|
|
442
452
|
|
443
453
|
class TreeMirrorLabelProvider
|
444
454
|
include JFace::Viewers::ILabelProvider
|
445
|
-
|
455
|
+
|
446
456
|
def initialize(tree_view_swt)
|
447
457
|
@tree_view_swt = tree_view_swt
|
448
458
|
end
|
@@ -463,7 +473,7 @@ module Redcar
|
|
463
473
|
|
464
474
|
def dispose
|
465
475
|
end
|
466
|
-
|
476
|
+
|
467
477
|
#def getToolTipShift(*_)
|
468
478
|
# Swt::Graphics::Point.new(5, 5)
|
469
479
|
#end
|
@@ -480,7 +490,7 @@ module Redcar
|
|
480
490
|
#def getToolTipTimeDisplayed(*_)
|
481
491
|
# 5000
|
482
492
|
#end
|
483
|
-
|
493
|
+
|
484
494
|
end
|
485
495
|
end
|
486
496
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: redcar-dev
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 7
|
5
|
-
version: 0.12.
|
5
|
+
version: 0.12.12dev
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Daniel Lucraft
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-14 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -252,11 +252,13 @@ files:
|
|
252
252
|
- lib/redcar/usage.rb
|
253
253
|
- plugins/application/plugin.rb
|
254
254
|
- plugins/application/features/main_menu.feature
|
255
|
+
- plugins/application/features/navigation_history.feature
|
255
256
|
- plugins/application/features/step_definitions/command_steps.rb
|
256
257
|
- plugins/application/features/step_definitions/dialog_steps.rb
|
257
258
|
- plugins/application/features/step_definitions/filter_list_dialog_steps.rb
|
258
259
|
- plugins/application/features/step_definitions/key_steps.rb
|
259
260
|
- plugins/application/features/step_definitions/menu_steps.rb
|
261
|
+
- plugins/application/features/step_definitions/navigation_history_steps.rb
|
260
262
|
- plugins/application/features/step_definitions/speedbar_steps.rb
|
261
263
|
- plugins/application/features/step_definitions/tree_steps.rb
|
262
264
|
- plugins/application/features/step_definitions/window_steps.rb
|
@@ -269,6 +271,7 @@ files:
|
|
269
271
|
- plugins/application/lib/application/event_spewer.rb
|
270
272
|
- plugins/application/lib/application/keymap.rb
|
271
273
|
- plugins/application/lib/application/menu.rb
|
274
|
+
- plugins/application/lib/application/navigation_history.rb
|
272
275
|
- plugins/application/lib/application/notebook.rb
|
273
276
|
- plugins/application/lib/application/sensitive.rb
|
274
277
|
- plugins/application/lib/application/sensitivity.rb
|
@@ -306,6 +309,7 @@ files:
|
|
306
309
|
- plugins/application/spec/application/clipboard_spec.rb
|
307
310
|
- plugins/application/spec/application/command_spec.rb
|
308
311
|
- plugins/application/spec/application/menu_spec.rb
|
312
|
+
- plugins/application/spec/application/navigation_history_spec.rb
|
309
313
|
- plugins/application/spec/application/notebook_spec.rb
|
310
314
|
- plugins/application/spec/application/sensitive_spec.rb
|
311
315
|
- plugins/application/spec/application/speedbar_spec.rb
|