redcar 0.5.5dev → 0.5.6dev
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/Rakefile +1 -1
- data/lib/redcar.rb +1 -1
- data/lib/redcar/jvm_options_probe.rb +26 -7
- data/plugins/auto_completer/lib/auto_completer.rb +46 -24
- data/plugins/edit_view/lib/edit_view.rb +92 -70
- data/plugins/edit_view_swt/lib/edit_view_swt.rb +75 -48
- data/plugins/edit_view_swt/lib/edit_view_swt/document.rb +50 -35
- data/plugins/edit_view_swt/vendor/java-mateview.rb +1 -2
- data/plugins/file_parser/lib/file_parser.rb +71 -7
- data/plugins/find-in-project/TODO.md +0 -2
- data/plugins/find-in-project/lib/find_in_project.rb +1 -0
- data/plugins/find-in-project/lib/find_in_project/controllers.rb +38 -17
- data/plugins/find-in-project/lib/find_in_project/stylesheets/style.css +27 -8
- data/plugins/find-in-project/lib/find_in_project/views/_file_heading.html.erb +2 -2
- data/plugins/find-in-project/lib/find_in_project/views/_file_line.html.erb +3 -3
- data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +13 -7
- data/plugins/redcar/redcar.rb +4 -3
- data/plugins/scm/lib/scm/scm_changes_mirror/change.rb +2 -0
- data/plugins/swt/lib/swt/full_swt.rb +4 -1
- metadata +4 -4
@@ -11,14 +11,14 @@ require File.dirname(__FILE__) + '/../vendor/java-mateview'
|
|
11
11
|
module Redcar
|
12
12
|
class EditViewSWT
|
13
13
|
include Redcar::Observable
|
14
|
-
|
14
|
+
|
15
15
|
def self.start
|
16
16
|
if gui = Redcar.gui
|
17
17
|
gui.register_controllers(Redcar::EditTab => EditViewSWT::Tab)
|
18
18
|
end
|
19
19
|
load_textmate_assets
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def self.load_textmate_assets
|
23
23
|
s = Time.now
|
24
24
|
load_textmate_assets_from_dir(Redcar.root + "/plugins/textmate/vendor/redcar-bundles")
|
@@ -29,12 +29,12 @@ module Redcar
|
|
29
29
|
puts "took #{Time.now - s}s to load textmate assets"
|
30
30
|
EditView.themes.unshift(*JavaMateView::ThemeManager.themes.to_a.map {|th| th.name })
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def self.load_textmate_assets_from_dir(dir)
|
34
34
|
JavaMateView::Bundle.load_bundles(dir)
|
35
35
|
JavaMateView::ThemeManager.load_themes(dir)
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
attr_reader :mate_text, :widget, :model
|
39
39
|
|
40
40
|
def initialize(model, parent, options={})
|
@@ -58,61 +58,61 @@ module Redcar
|
|
58
58
|
@model.set_grammar(new_grammar)
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def create_mate_text
|
63
63
|
@mate_text = JavaMateView::MateText.new(@parent, !!@options[:single_line])
|
64
64
|
@mate_text.set_font(EditView.font, EditView.font_size)
|
65
|
-
|
65
|
+
|
66
66
|
@model.controller = self
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def create_undo_manager
|
70
70
|
@undo_manager = JFace::Text::TextViewerUndoManager.new(100)
|
71
71
|
@undo_manager.connect(@mate_text.viewer)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def undo
|
75
75
|
@undo_manager.undo
|
76
76
|
EditView.undo_sensitivity.recompute
|
77
77
|
EditView.redo_sensitivity.recompute
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
def undoable?
|
81
81
|
@undo_manager.undoable
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
def redo
|
85
85
|
@undo_manager.redo
|
86
86
|
EditView.undo_sensitivity.recompute
|
87
87
|
EditView.redo_sensitivity.recompute
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
def redoable?
|
91
91
|
@undo_manager.redoable
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
def reset_undo
|
95
95
|
@undo_manager.reset
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
def compound
|
99
99
|
begin_compound
|
100
100
|
yield
|
101
101
|
end_compound
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
def begin_compound
|
105
105
|
@undo_manager.begin_compound_change
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def end_compound
|
109
109
|
@undo_manager.end_compound_change
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def create_document
|
113
113
|
@document = EditViewSWT::Document.new(@model.document, @mate_text.mate_document)
|
114
114
|
@model.document.controller = @document
|
115
|
-
h1 = @model.document.add_listener(:before => :new_mirror,
|
115
|
+
h1 = @model.document.add_listener(:before => :new_mirror,
|
116
116
|
&method(:update_grammar))
|
117
117
|
h2 = @model.add_listener(:grammar_changed, &method(:model_grammar_changed))
|
118
118
|
h3 = @model.add_listener(:focussed, &method(:focus))
|
@@ -147,21 +147,32 @@ module Redcar
|
|
147
147
|
@mate_text.set_margin_column(-1)
|
148
148
|
end
|
149
149
|
end
|
150
|
+
@mate_text.getTextWidget.addMouseListener(MouseListener.new(self))
|
150
151
|
@mate_text.getTextWidget.addFocusListener(FocusListener.new(self))
|
151
152
|
@mate_text.getTextWidget.addVerifyListener(VerifyListener.new(@model.document, self))
|
152
153
|
@mate_text.getTextWidget.addModifyListener(ModifyListener.new(@model.document, self))
|
153
154
|
@mate_text.get_control.add_verify_key_listener(VerifyKeyListener.new(self))
|
154
155
|
@mate_text.get_control.add_key_listener(KeyListener.new(self))
|
155
|
-
@handlers << [@model.document, h1] << [@model, h2] << [@model, h3] << [@model, h4] <<
|
156
|
+
@handlers << [@model.document, h1] << [@model, h2] << [@model, h3] << [@model, h4] <<
|
156
157
|
[@model, h5] << [@model, h6] << [@model, h7] << [@model, h8] <<
|
157
158
|
[@model, h9] << [@model, h10] << [@model, h11]
|
158
159
|
end
|
159
|
-
|
160
|
+
|
161
|
+
def right_click(mouse_event)
|
162
|
+
if @model.document.controller and @model.document.controller.respond_to?(:right_click)
|
163
|
+
location = ApplicationSWT.display.get_cursor_location
|
164
|
+
#offset = @mate_text.parser.styledText.get_offset_at_location(location)
|
165
|
+
Redcar.safely("right click on edit view") do
|
166
|
+
@model.document.controller.right_click(@model)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
160
171
|
class VerifyKeyListener
|
161
172
|
def initialize(edit_view_swt)
|
162
173
|
@edit_view_swt = edit_view_swt
|
163
174
|
end
|
164
|
-
|
175
|
+
|
165
176
|
def verify_key(key_event)
|
166
177
|
if @edit_view_swt.model.document.block_selection_mode?
|
167
178
|
@edit_view_swt.begin_compound
|
@@ -181,88 +192,88 @@ module Redcar
|
|
181
192
|
end
|
182
193
|
end
|
183
194
|
end
|
184
|
-
|
195
|
+
|
185
196
|
class KeyListener
|
186
197
|
def initialize(edit_view_swt)
|
187
198
|
@edit_view_swt = edit_view_swt
|
188
199
|
end
|
189
|
-
|
200
|
+
|
190
201
|
def key_pressed(_)
|
191
202
|
@was_in_block_selection = @edit_view_swt.model.document.block_selection_mode?
|
192
203
|
end
|
193
|
-
|
204
|
+
|
194
205
|
def key_released(_)
|
195
206
|
if @was_in_block_selection
|
196
207
|
@edit_view_swt.end_compound
|
197
208
|
end
|
198
209
|
end
|
199
210
|
end
|
200
|
-
|
211
|
+
|
201
212
|
def delay_parsing
|
202
213
|
mate_text.delay_parsing { yield }
|
203
214
|
end
|
204
|
-
|
215
|
+
|
205
216
|
def swt_focus_gained
|
206
217
|
EditView.focussed_edit_view = @model
|
207
218
|
@model.focus
|
208
219
|
end
|
209
|
-
|
220
|
+
|
210
221
|
def swt_focus_lost
|
211
222
|
EditView.focussed_edit_view = nil
|
212
223
|
end
|
213
|
-
|
224
|
+
|
214
225
|
def focus
|
215
226
|
@mate_text.get_control.set_focus
|
216
227
|
end
|
217
|
-
|
228
|
+
|
218
229
|
def is_current?
|
219
230
|
EditView.current == @mate_text.get_control
|
220
231
|
end
|
221
|
-
|
232
|
+
|
222
233
|
def has_focus?
|
223
234
|
focus_control = ApplicationSWT.display.get_focus_control
|
224
235
|
focus_control == @mate_text.get_control
|
225
236
|
end
|
226
|
-
|
237
|
+
|
227
238
|
def exists?
|
228
239
|
@mate_text.get_control and !@mate_text.get_control.disposed
|
229
240
|
end
|
230
|
-
|
241
|
+
|
231
242
|
def attach_listeners
|
232
243
|
# h = @document.add_listener(:set_text, &method(:reparse))
|
233
244
|
# @handlers << [@document, h]
|
234
245
|
@mate_text.get_text_widget.add_word_movement_listener(WordMoveListener.new(self))
|
235
246
|
end
|
236
|
-
|
247
|
+
|
237
248
|
def reparse
|
238
249
|
@mate_text.parser.parse_range(0, @mate_text.parser.styledText.get_line_count-1)
|
239
250
|
end
|
240
|
-
|
251
|
+
|
241
252
|
def cursor_offset=(offset)
|
242
253
|
@mate_text.get_text_widget.set_caret_offset(offset)
|
243
254
|
end
|
244
|
-
|
255
|
+
|
245
256
|
def cursor_offset
|
246
257
|
@mate_text.get_text_widget.get_caret_offset
|
247
258
|
end
|
248
|
-
|
259
|
+
|
249
260
|
def scroll_to_line(line_index)
|
250
261
|
@mate_text.parser.parserScheduler.last_visible_line_changed(line_index + 100)
|
251
262
|
@mate_text.viewer.set_top_index(line_index)
|
252
263
|
end
|
253
|
-
|
264
|
+
|
254
265
|
def model_grammar_changed(name)
|
255
266
|
@mate_text.set_grammar_by_name(name)
|
256
267
|
end
|
257
|
-
|
268
|
+
|
258
269
|
def smallest_visible_line
|
259
270
|
@mate_text.viewer.get_top_index
|
260
271
|
end
|
261
|
-
|
272
|
+
|
262
273
|
def biggest_visible_line
|
263
274
|
@mate_text.viewer.get_bottom_index
|
264
275
|
end
|
265
|
-
|
276
|
+
|
266
277
|
def ensure_visible(offset)
|
267
278
|
line = @document.line_at_offset(offset)
|
268
279
|
line_start_offset = @document.offset_at_line(line)
|
@@ -275,7 +286,7 @@ module Redcar
|
|
275
286
|
@mate_text.viewer.reveal_range(offset, 1)
|
276
287
|
end
|
277
288
|
end
|
278
|
-
|
289
|
+
|
279
290
|
def update_grammar(new_mirror)
|
280
291
|
title = new_mirror.title
|
281
292
|
contents = new_mirror.read
|
@@ -287,25 +298,41 @@ module Redcar
|
|
287
298
|
grammar_name ||= "Plain Text"
|
288
299
|
@model.set_grammar(grammar_name)
|
289
300
|
end
|
290
|
-
|
301
|
+
|
291
302
|
STRIP_KEYS = {
|
292
303
|
:cut => 120|Swt::SWT::MOD1,
|
293
304
|
:copy => 99|Swt::SWT::MOD1,
|
294
305
|
:paste => 118|Swt::SWT::MOD1
|
295
306
|
}
|
296
|
-
|
307
|
+
|
297
308
|
def remove_control_keybindings
|
298
309
|
styled_text = @mate_text.get_text_widget
|
299
310
|
STRIP_KEYS.each do |_, key|
|
300
311
|
styled_text.set_key_binding(key, Swt::SWT::NULL)
|
301
312
|
end
|
302
313
|
end
|
303
|
-
|
314
|
+
|
304
315
|
def dispose
|
305
316
|
@handlers.each {|obj, h| obj.remove_listener(h) }
|
306
317
|
@handlers.clear
|
307
318
|
end
|
308
|
-
|
319
|
+
|
320
|
+
class MouseListener
|
321
|
+
def initialize(obj)
|
322
|
+
@obj = obj
|
323
|
+
end
|
324
|
+
|
325
|
+
def mouse_double_click(_); end
|
326
|
+
def mouse_up(_)
|
327
|
+
end
|
328
|
+
|
329
|
+
def mouse_down(e)
|
330
|
+
if e.button == 3
|
331
|
+
@obj.right_click(e)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
309
336
|
class FocusListener
|
310
337
|
def initialize(obj)
|
311
338
|
@obj = obj
|
@@ -319,22 +346,22 @@ module Redcar
|
|
319
346
|
@obj.swt_focus_lost
|
320
347
|
end
|
321
348
|
end
|
322
|
-
|
349
|
+
|
323
350
|
class VerifyListener
|
324
351
|
def initialize(document, obj)
|
325
352
|
@document, @obj = document, obj
|
326
353
|
end
|
327
|
-
|
354
|
+
|
328
355
|
def verify_text(e)
|
329
356
|
@document.verify_text(e.start, e.end, e.text)
|
330
357
|
end
|
331
358
|
end
|
332
|
-
|
359
|
+
|
333
360
|
class ModifyListener
|
334
361
|
def initialize(document, obj)
|
335
362
|
@document, @obj = document, obj
|
336
363
|
end
|
337
|
-
|
364
|
+
|
338
365
|
def modify_text(e)
|
339
366
|
@document.modify_text
|
340
367
|
end
|
@@ -4,56 +4,71 @@ module Redcar
|
|
4
4
|
class Document
|
5
5
|
include Redcar::Observable
|
6
6
|
attr_reader :jface_document
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(model, swt_mate_document)
|
9
9
|
@model = model
|
10
10
|
@swt_mate_document = swt_mate_document
|
11
11
|
@jface_document = swt_mate_document.mateText.get_document
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
def right_click(edit_view)
|
15
|
+
menu = Menu.new
|
16
|
+
Redcar.plugin_manager.objects_implementing(:edit_view_context_menus).each do |object|
|
17
|
+
case object.method(:edit_view_context_menus).arity
|
18
|
+
when 0
|
19
|
+
menu.merge(object.edit_view_context_menus)
|
20
|
+
when 1
|
21
|
+
menu.merge(object.edit_view_context_menus(edit_view))
|
22
|
+
else
|
23
|
+
puts("Invalid edit_view_context_menus hook detected in "+object.class.name)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
Application::Dialog.popup_menu(menu, :pointer)
|
27
|
+
end
|
28
|
+
|
14
29
|
def attach_modification_listeners
|
15
30
|
jface_document.add_document_listener(DocumentListener.new(@model))
|
16
31
|
styledText.add_selection_listener(SelectionListener.new(@model))
|
17
32
|
styledText.add_caret_listener(CaretListener.new(@model))
|
18
33
|
end
|
19
|
-
|
34
|
+
|
20
35
|
def single_line?
|
21
36
|
@swt_mate_document.mateText.isSingleLine
|
22
37
|
end
|
23
|
-
|
38
|
+
|
24
39
|
def to_s
|
25
40
|
jface_document.get
|
26
41
|
end
|
27
|
-
|
42
|
+
|
28
43
|
def length
|
29
44
|
jface_document.length
|
30
45
|
end
|
31
|
-
|
46
|
+
|
32
47
|
def line_count
|
33
48
|
jface_document.get_number_of_lines
|
34
49
|
end
|
35
|
-
|
50
|
+
|
36
51
|
def get_line_delimiter
|
37
52
|
styledText.get_line_delimiter
|
38
53
|
end
|
39
|
-
|
54
|
+
|
40
55
|
def line_at_offset(offset)
|
41
56
|
jface_document.get_line_of_offset(offset)
|
42
57
|
end
|
43
|
-
|
58
|
+
|
44
59
|
def offset_at_line(line_ix)
|
45
60
|
jface_document.get_line_offset(line_ix)
|
46
61
|
end
|
47
|
-
|
62
|
+
|
48
63
|
def get_line(line_ix)
|
49
64
|
line_info = jface_document.get_line_information(line_ix)
|
50
65
|
jface_document.get(line_info.offset, line_info.length)
|
51
66
|
end
|
52
|
-
|
67
|
+
|
53
68
|
def get_range(start, length)
|
54
69
|
jface_document.get(start, length)
|
55
70
|
end
|
56
|
-
|
71
|
+
|
57
72
|
def replace(offset, length, text)
|
58
73
|
@model.verify_text(offset, offset+length, text)
|
59
74
|
jface_document.replace(offset, length, text)
|
@@ -62,46 +77,46 @@ module Redcar
|
|
62
77
|
#end
|
63
78
|
@model.modify_text
|
64
79
|
end
|
65
|
-
|
80
|
+
|
66
81
|
def text=(text)
|
67
82
|
@model.verify_text(0, length, text)
|
68
83
|
jface_document.set(text)
|
69
84
|
@model.modify_text
|
70
85
|
notify_listeners(:set_text)
|
71
86
|
end
|
72
|
-
|
87
|
+
|
73
88
|
def cursor_offset
|
74
89
|
styledText.get_caret_offset
|
75
90
|
end
|
76
|
-
|
91
|
+
|
77
92
|
def selection_offset
|
78
93
|
range = styledText.get_selection_range
|
79
94
|
range.x == cursor_offset ? range.x + range.y : range.x
|
80
95
|
end
|
81
|
-
|
96
|
+
|
82
97
|
def cursor_offset=(offset)
|
83
98
|
styledText.set_caret_offset(offset)
|
84
99
|
end
|
85
|
-
|
100
|
+
|
86
101
|
def selection_range
|
87
102
|
range = styledText.get_selection_range
|
88
103
|
range.x...(range.x + range.y)
|
89
104
|
end
|
90
|
-
|
105
|
+
|
91
106
|
def selection_ranges
|
92
107
|
ranges = styledText.get_selection_ranges
|
93
108
|
ranges.to_a.each_slice(2).map do |from, length|
|
94
109
|
from...(from + length)
|
95
110
|
end
|
96
111
|
end
|
97
|
-
|
112
|
+
|
98
113
|
def set_selection_range(cursor_offset, selection_offset)
|
99
114
|
if block_selection_mode?
|
100
115
|
start_offset, end_offset = *[cursor_offset, selection_offset].sort
|
101
116
|
start_location = styledText.getLocationAtOffset(start_offset)
|
102
117
|
end_location = styledText.getLocationAtOffset(end_offset)
|
103
118
|
styledText.set_block_selection_bounds(
|
104
|
-
start_location.x,
|
119
|
+
start_location.x,
|
105
120
|
start_location.y,
|
106
121
|
end_location.x - start_location.x,
|
107
122
|
end_location.y - start_location.y + styledText.get_line_height
|
@@ -111,7 +126,7 @@ module Redcar
|
|
111
126
|
end
|
112
127
|
@model.selection_range_changed(cursor_offset, selection_offset)
|
113
128
|
end
|
114
|
-
|
129
|
+
|
115
130
|
@markStruct ||= Struct.new(:location, :category) # save away the parent class
|
116
131
|
class Mark < @markStruct
|
117
132
|
def get_offset; location.get_offset; end
|
@@ -119,7 +134,7 @@ module Redcar
|
|
119
134
|
def get_line_offset; location.get_line_offset; end
|
120
135
|
def inspect; "<Mark #{get_line}:#{get_line_offset} (#{get_offset})>"; end
|
121
136
|
end
|
122
|
-
|
137
|
+
|
123
138
|
def create_mark(offset, gravity)
|
124
139
|
line = line_at_offset(offset)
|
125
140
|
line_offset = offset - offset_at_line(line)
|
@@ -133,37 +148,37 @@ module Redcar
|
|
133
148
|
@swt_mate_document.add_text_location(category, location)
|
134
149
|
Mark.new(location, category)
|
135
150
|
end
|
136
|
-
|
151
|
+
|
137
152
|
def delete_mark(mark)
|
138
153
|
@swt_mate_document.remove_text_location(mark.category, mark.location)
|
139
154
|
end
|
140
|
-
|
155
|
+
|
141
156
|
def block_selection_mode?
|
142
157
|
styledText.get_block_selection
|
143
158
|
end
|
144
|
-
|
159
|
+
|
145
160
|
def block_selection_mode=(bool)
|
146
161
|
styledText.set_block_selection(bool)
|
147
162
|
end
|
148
|
-
|
163
|
+
|
149
164
|
def styledText
|
150
165
|
@swt_mate_document.mateText.getControl
|
151
166
|
end
|
152
|
-
|
167
|
+
|
153
168
|
def scope_at(line, line_offset)
|
154
169
|
@swt_mate_document.mateText.scope_at(line, line_offset)
|
155
170
|
end
|
156
|
-
|
171
|
+
|
157
172
|
class CaretListener
|
158
173
|
def initialize(model)
|
159
174
|
@model = model
|
160
175
|
end
|
161
|
-
|
176
|
+
|
162
177
|
def caret_moved(event)
|
163
178
|
@model.cursor_moved(event.caretOffset)
|
164
179
|
end
|
165
180
|
end
|
166
|
-
|
181
|
+
|
167
182
|
class SelectionListener
|
168
183
|
def initialize(model)
|
169
184
|
@model = model
|
@@ -172,21 +187,21 @@ module Redcar
|
|
172
187
|
def widget_default_selected(e)
|
173
188
|
@model.selection_range_changed(e.x, e.y)
|
174
189
|
end
|
175
|
-
|
190
|
+
|
176
191
|
def widget_selected(e)
|
177
192
|
@model.selection_range_changed(e.x, e.y)
|
178
|
-
end
|
193
|
+
end
|
179
194
|
end
|
180
|
-
|
195
|
+
|
181
196
|
class DocumentListener
|
182
197
|
def initialize(model)
|
183
198
|
@model = model
|
184
199
|
end
|
185
|
-
|
200
|
+
|
186
201
|
def document_about_to_be_changed(e)
|
187
202
|
@model.about_to_be_changed(e.offset, e.length, e.text)
|
188
203
|
end
|
189
|
-
|
204
|
+
|
190
205
|
def document_changed(e)
|
191
206
|
@model.changed(e.offset, e.length, e.text)
|
192
207
|
end
|