glimmer-cs-gladiator 0.5.0 → 0.6.0
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.
- checksums.yaml +4 -4
- data/README.md +56 -27
- data/VERSION +1 -1
- data/lib/glimmer-cs-gladiator.rb +1 -1
- data/lib/models/glimmer/gladiator/command.rb +44 -11
- data/lib/models/glimmer/gladiator/dir.rb +54 -18
- data/lib/models/glimmer/gladiator/file.rb +126 -61
- data/lib/views/glimmer/gladiator.rb +534 -242
- data/lib/views/glimmer/gladiator/text_editor.rb +22 -14
- metadata +6 -6
@@ -23,7 +23,7 @@ module Glimmer
|
|
23
23
|
attr_accessor :drag_and_drop
|
24
24
|
attr_accessor :drag
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
## Add options like the following to configure CustomShell by outside consumers
|
28
28
|
#
|
29
29
|
# options :title, :background_color
|
@@ -35,16 +35,33 @@ module Glimmer
|
|
35
35
|
@project_dir ||= Dir.new(project_dir_path)
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
def split_orientation=(value)
|
39
|
+
@split_orientation = value
|
40
|
+
save_config
|
41
|
+
if @loaded_config && !split_pane?
|
42
|
+
Gladiator.drag = true
|
43
|
+
child_path = project_dir.selected_child_path
|
44
|
+
project_dir.selected_child = nil
|
45
|
+
project_dir.selected_child_path = child_path
|
46
|
+
Gladiator.drag = false
|
47
|
+
end
|
48
|
+
@split_orientation
|
49
|
+
end
|
50
|
+
|
51
|
+
def split_pane?
|
52
|
+
pane_count = @tab_folder_sash_form&.children&.size
|
53
|
+
pane_count && pane_count > 1
|
54
|
+
end
|
55
|
+
|
56
|
+
attr_reader :find_text, :tab_folder1, :tab_folder2, :filter_text, :rename_in_progress, :line_number_text, :file_tree, :split_orientation
|
57
|
+
attr_accessor :current_tab_item, :current_tab_folder, :current_text_editor
|
40
58
|
|
41
59
|
## Uncomment before_body block to pre-initialize variables to use in body
|
42
60
|
#
|
43
61
|
#
|
44
62
|
before_body {
|
45
|
-
|
46
|
-
|
47
|
-
}
|
63
|
+
# TODO consider doing loading project files after displaying the GUI instead of holding it up before
|
64
|
+
project_dir #pre-initialize directory
|
48
65
|
at_exit do
|
49
66
|
project_dir.selected_child&.write_raw_dirty_content
|
50
67
|
end
|
@@ -59,6 +76,7 @@ module Glimmer
|
|
59
76
|
}
|
60
77
|
end
|
61
78
|
|
79
|
+
@default_foreground = :dark_blue
|
62
80
|
@split_orientation = swt(:horizontal)
|
63
81
|
@config_file_path = ::File.join(project_dir.path, '.gladiator')
|
64
82
|
@config = {}
|
@@ -92,7 +110,10 @@ module Glimmer
|
|
92
110
|
@current_tab_folder.content {
|
93
111
|
@current_tab_item = tab_item { |the_tab_item|
|
94
112
|
text selected_file.name
|
95
|
-
fill_layout
|
113
|
+
fill_layout(:horizontal) {
|
114
|
+
margin_width 0
|
115
|
+
margin_height 0
|
116
|
+
}
|
96
117
|
@current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
|
97
118
|
@current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
|
98
119
|
@current_text_editor.text_proxy.content {
|
@@ -117,6 +138,9 @@ module Glimmer
|
|
117
138
|
@current_text_editor&.text_widget&.setFocus
|
118
139
|
}
|
119
140
|
}
|
141
|
+
on_widget_disposed {
|
142
|
+
the_tab_item.swt_tab_item.get_data('file').close
|
143
|
+
}
|
120
144
|
}
|
121
145
|
@current_tab_item.swt_tab_item.setData('file_path', selected_file.path)
|
122
146
|
@current_tab_item.swt_tab_item.setData('file', selected_file)
|
@@ -146,10 +170,12 @@ module Glimmer
|
|
146
170
|
#
|
147
171
|
body {
|
148
172
|
shell {
|
173
|
+
grid_layout(2, false)
|
174
|
+
|
149
175
|
text "Gladiator - #{::File.expand_path(project_dir.path)}"
|
150
176
|
minimum_size 520, 250
|
151
177
|
size 1440, 900
|
152
|
-
|
178
|
+
|
153
179
|
on_swt_show {
|
154
180
|
swt_widget.setSize(@config[:shell_width], @config[:shell_height]) if @config[:shell_width] && @config[:shell_height]
|
155
181
|
swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
|
@@ -181,7 +207,7 @@ module Glimmer
|
|
181
207
|
begin
|
182
208
|
project_dir.selected_child_path = ''
|
183
209
|
rescue => e
|
184
|
-
|
210
|
+
puts e.full_message
|
185
211
|
end
|
186
212
|
}
|
187
213
|
}
|
@@ -199,11 +225,15 @@ module Glimmer
|
|
199
225
|
text '&Split'
|
200
226
|
menu_item(:radio) {
|
201
227
|
text '&Horizontal'
|
202
|
-
selection bind(self, :split_orientation,
|
228
|
+
selection bind(self, :split_orientation,
|
229
|
+
on_read: ->(o) { split_pane? && o == swt(:horizontal)},
|
230
|
+
on_write: ->(b) { b ? swt(:horizontal) : swt(:vertical) })
|
203
231
|
}
|
204
232
|
menu_item(:radio) {
|
205
233
|
text '&Vertical'
|
206
|
-
selection bind(self, :split_orientation,
|
234
|
+
selection bind(self, :split_orientation,
|
235
|
+
on_read: ->(o) { split_pane? && o == swt(:vertical)},
|
236
|
+
on_write: ->(b) { b ? swt(:vertical) : swt(:horizontal) })
|
207
237
|
}
|
208
238
|
}
|
209
239
|
}
|
@@ -232,126 +262,215 @@ module Glimmer
|
|
232
262
|
}
|
233
263
|
|
234
264
|
composite {
|
235
|
-
grid_layout
|
265
|
+
grid_layout(1, false) {
|
266
|
+
margin_width 0
|
267
|
+
margin_height 0
|
268
|
+
}
|
269
|
+
|
236
270
|
layout_data(:fill, :fill, false, true) {
|
237
271
|
width_hint 300
|
238
272
|
}
|
239
|
-
@
|
240
|
-
layout_data :fill, :center, true, false
|
241
|
-
text bind(project_dir, 'filter')
|
242
|
-
on_key_pressed { |key_event|
|
243
|
-
if key_event.keyCode == swt(:tab) ||
|
244
|
-
key_event.keyCode == swt(:cr) ||
|
245
|
-
key_event.keyCode == swt(:arrow_up) ||
|
246
|
-
key_event.keyCode == swt(:arrow_down)
|
247
|
-
@list.swt_widget.select(0) if @list.swt_widget.getSelectionIndex() == -1
|
248
|
-
@list.swt_widget.setFocus
|
249
|
-
end
|
250
|
-
}
|
251
|
-
}
|
252
|
-
composite {
|
253
|
-
fill_layout(:vertical) {
|
254
|
-
spacing 5
|
255
|
-
}
|
273
|
+
@side_bar_sash_form = sash_form(:vertical) {
|
256
274
|
layout_data(:fill, :fill, true, true)
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
}
|
263
|
-
on_key_pressed { |key_event|
|
264
|
-
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
265
|
-
project_dir.selected_child_path = @list.swt_widget.getSelection.first
|
266
|
-
@current_text_editor&.text_widget&.setFocus
|
267
|
-
end
|
268
|
-
}
|
269
|
-
drag_source(DND::DROP_COPY) {
|
270
|
-
transfer [TextTransfer.getInstance].to_java(Transfer)
|
271
|
-
on_drag_set_data { |event|
|
272
|
-
Gladiator.drag = true
|
273
|
-
list = event.widget.getControl
|
274
|
-
event.data = list.getSelection.first
|
275
|
-
}
|
276
|
-
}
|
275
|
+
sash_width 4
|
276
|
+
|
277
|
+
resize_expand_items = lambda { |event=nil|
|
278
|
+
@file_lookup_expand_item&.swt_expand_item&.height = @file_lookup_expand_bar.size.y - @file_lookup_expand_item.swt_expand_item.header_height
|
279
|
+
@file_explorer_expand_item&.swt_expand_item&.height = @file_explorer_expand_bar.size.y - @file_explorer_expand_item.swt_expand_item.header_height
|
277
280
|
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
281
|
+
|
282
|
+
@file_lookup_expand_bar = expand_bar {
|
283
|
+
layout_data :fill, :fill, true, true
|
284
|
+
font height: 17, style: :bold
|
285
|
+
foreground @default_foreground
|
286
|
+
|
287
|
+
on_swt_show {
|
288
|
+
@file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_bar.size.y - @file_lookup_expand_item.swt_expand_item.header_height
|
289
|
+
}
|
290
|
+
|
291
|
+
on_swt_Resize(&resize_expand_items)
|
292
|
+
|
293
|
+
@file_lookup_expand_item = expand_item {
|
294
|
+
grid_layout {
|
295
|
+
margin_width 0
|
296
|
+
margin_height 0
|
297
|
+
}
|
298
|
+
text 'File Lookup'
|
299
|
+
height display.bounds.height
|
300
|
+
|
301
|
+
@filter_text = text {
|
302
|
+
layout_data :fill, :center, true, false
|
303
|
+
text bind(project_dir, 'filter')
|
304
|
+
on_key_pressed { |key_event|
|
305
|
+
if key_event.keyCode == swt(:tab) ||
|
306
|
+
key_event.keyCode == swt(:cr) ||
|
307
|
+
key_event.keyCode == swt(:arrow_up) ||
|
308
|
+
key_event.keyCode == swt(:arrow_down)
|
309
|
+
@file_lookup_list.swt_widget.select(0) if @file_lookup_list.swt_widget.getSelectionIndex() == -1
|
310
|
+
@file_lookup_list.swt_widget.setFocus
|
311
|
+
end
|
295
312
|
}
|
296
313
|
}
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
314
|
+
|
315
|
+
@file_lookup_list = list(:border, :h_scroll, :v_scroll) {
|
316
|
+
layout_data :fill, :fill, true, true
|
317
|
+
#visible bind(self, 'project_dir.filter') {|f| !!f}
|
318
|
+
selection bind(project_dir, :filtered_path)
|
319
|
+
foreground @default_foreground
|
320
|
+
on_mouse_up {
|
321
|
+
project_dir.selected_child_path = @file_lookup_list.swt_widget.getSelection.first
|
303
322
|
}
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
323
|
+
on_key_pressed { |key_event|
|
324
|
+
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
325
|
+
project_dir.selected_child_path = @file_lookup_list.swt_widget.getSelection.first
|
326
|
+
@current_text_editor&.text_widget&.setFocus
|
327
|
+
end
|
309
328
|
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
329
|
+
drag_source(DND::DROP_COPY) {
|
330
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
331
|
+
on_drag_set_data { |event|
|
332
|
+
Gladiator.drag = true
|
333
|
+
list = event.widget.getControl
|
334
|
+
event.data = list.getSelection.first
|
335
|
+
}
|
315
336
|
}
|
316
337
|
}
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
338
|
+
}
|
339
|
+
|
340
|
+
on_item_collapsed { |event|
|
341
|
+
if @file_explorer_expand_item.swt_expand_item.get_expanded
|
342
|
+
@file_lookup_expand_item_height = @file_lookup_expand_item.swt_expand_item.height
|
343
|
+
@file_lookup_expand_item.swt_expand_item.height = 0
|
344
|
+
@file_lookup_expand_bar_height = @file_lookup_expand_bar.swt_widget.size.y
|
345
|
+
@file_explorer_expand_bar_height = @file_explorer_expand_bar.swt_widget.size.y
|
346
|
+
@side_bar_sash_form.weights = [@file_lookup_expand_item.swt_expand_item.header_height, @file_lookup_expand_bar_height + @file_explorer_expand_bar_height - @file_lookup_expand_item.swt_expand_item.header_height]
|
347
|
+
end
|
348
|
+
}
|
349
|
+
|
350
|
+
on_item_expanded {
|
351
|
+
@file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_item_height if @file_lookup_expand_item_height
|
352
|
+
@side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
|
353
|
+
}
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
@file_explorer_expand_bar = expand_bar {
|
358
|
+
layout_data :fill, :fill, true, true
|
359
|
+
font height: 17, style: :bold
|
360
|
+
foreground @default_foreground
|
361
|
+
|
362
|
+
on_swt_show {
|
363
|
+
@file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_bar.size.y - @file_explorer_expand_item.swt_expand_item.header_height
|
364
|
+
}
|
365
|
+
|
366
|
+
on_swt_Resize(&resize_expand_items)
|
367
|
+
|
368
|
+
@file_explorer_expand_item = expand_item {
|
369
|
+
grid_layout {
|
370
|
+
margin_width 0
|
371
|
+
margin_height 0
|
372
|
+
}
|
373
|
+
text 'File Explorer'
|
374
|
+
height display.bounds.height
|
375
|
+
|
376
|
+
@file_tree = tree(:virtual, :border, :h_scroll, :v_scroll) {
|
377
|
+
layout_data :fill, :fill, true, true
|
378
|
+
#visible bind(self, 'project_dir.filter') {|f| !f}
|
379
|
+
items bind(self, :project_dir), tree_properties(children: :children, text: :name)
|
380
|
+
foreground @default_foreground
|
381
|
+
drag_source(DND::DROP_COPY) {
|
382
|
+
transfer [TextTransfer.getInstance].to_java(Transfer)
|
383
|
+
on_drag_set_data { |event|
|
384
|
+
Gladiator.drag = true
|
385
|
+
tree = event.widget.getControl
|
386
|
+
tree_item = tree.getSelection.first
|
387
|
+
event.data = tree_item.getData.path
|
388
|
+
}
|
321
389
|
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
390
|
+
menu {
|
391
|
+
@open_menu_item = menu_item {
|
392
|
+
text 'Open'
|
393
|
+
on_widget_selected {
|
394
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
|
395
|
+
}
|
396
|
+
}
|
397
|
+
menu_item(:separator)
|
398
|
+
menu_item {
|
399
|
+
text 'Delete'
|
400
|
+
on_widget_selected {
|
401
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
402
|
+
delete_tree_item(tree_item)
|
403
|
+
}
|
404
|
+
}
|
405
|
+
menu_item {
|
406
|
+
text 'Refresh'
|
407
|
+
on_widget_selected {
|
408
|
+
project_dir.refresh
|
409
|
+
}
|
410
|
+
}
|
411
|
+
menu_item {
|
412
|
+
text 'Rename'
|
413
|
+
on_widget_selected {
|
414
|
+
rename_selected_tree_item
|
415
|
+
}
|
416
|
+
}
|
417
|
+
menu_item {
|
418
|
+
text 'New Directory'
|
419
|
+
on_widget_selected {
|
420
|
+
add_new_directory_to_selected_tree_item
|
421
|
+
}
|
422
|
+
}
|
423
|
+
menu_item {
|
424
|
+
text 'New File'
|
425
|
+
on_widget_selected {
|
426
|
+
add_new_file_to_selected_tree_item
|
427
|
+
}
|
428
|
+
}
|
429
|
+
}
|
430
|
+
on_swt_menudetect { |event|
|
431
|
+
path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
|
432
|
+
@open_menu_item.swt_widget.setEnabled(!::Dir.exist?(path)) if path
|
433
|
+
}
|
434
|
+
on_mouse_up {
|
435
|
+
if Gladiator.drag_and_drop
|
436
|
+
Gladiator.drag_and_drop = false
|
437
|
+
else
|
438
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
|
439
|
+
@current_text_editor&.text_widget&.setFocus
|
440
|
+
end
|
441
|
+
}
|
442
|
+
on_key_pressed { |key_event|
|
443
|
+
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
444
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
|
445
|
+
@current_text_editor&.text_widget&.setFocus
|
446
|
+
end
|
447
|
+
}
|
448
|
+
on_paint_control {
|
449
|
+
root_item = @file_tree.swt_widget.getItems.first
|
450
|
+
if root_item && !root_item.getExpanded
|
451
|
+
root_item.setExpanded(true)
|
452
|
+
end
|
327
453
|
}
|
328
454
|
}
|
329
455
|
}
|
330
|
-
|
331
|
-
|
332
|
-
@
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
|
339
|
-
@current_text_editor&.text_widget&.setFocus
|
456
|
+
|
457
|
+
on_item_collapsed { |event|
|
458
|
+
if @file_lookup_expand_item.swt_expand_item.get_expanded
|
459
|
+
@file_explorer_expand_item_height = @file_explorer_expand_item.swt_expand_item.height
|
460
|
+
@file_explorer_expand_item.swt_expand_item.height = 0
|
461
|
+
@file_explorer_expand_bar_height = @file_explorer_expand_bar.swt_widget.size.y
|
462
|
+
@file_lookup_expand_bar_height = @file_lookup_expand_bar.swt_widget.size.y
|
463
|
+
@side_bar_sash_form.weights = [@file_explorer_expand_bar_height + @file_explorer_expand_bar_height - @file_explorer_expand_item.swt_expand_item.header_height, @file_explorer_expand_item.swt_expand_item.header_height]
|
340
464
|
end
|
341
|
-
}
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
if root_item && !root_item.getExpanded
|
351
|
-
root_item.setExpanded(true)
|
352
|
-
end
|
353
|
-
}
|
354
|
-
}
|
465
|
+
}
|
466
|
+
|
467
|
+
on_item_expanded {
|
468
|
+
@file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_item_height if @file_explorer_expand_item_height
|
469
|
+
@side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
|
470
|
+
}
|
471
|
+
|
472
|
+
}
|
473
|
+
|
355
474
|
}
|
356
475
|
|
357
476
|
# TODO see if you could replace some of this with Glimmer DSL/API syntax
|
@@ -361,117 +480,220 @@ module Glimmer
|
|
361
480
|
@file_tree_editor.minimumHeight = 20;
|
362
481
|
|
363
482
|
}
|
364
|
-
|
365
|
-
|
483
|
+
|
484
|
+
composite {
|
485
|
+
grid_layout(1, false) {
|
486
|
+
margin_width 0
|
487
|
+
margin_height 0
|
488
|
+
}
|
366
489
|
layout_data :fill, :fill, true, true
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
490
|
+
|
491
|
+
@navigation_expand_bar = expand_bar {
|
492
|
+
layout_data :fill, :top, true, false
|
493
|
+
font height: 17, style: :bold
|
494
|
+
foreground @default_foreground
|
495
|
+
|
496
|
+
@navigation_expand_item = expand_item {
|
497
|
+
text 'Navigation'
|
498
|
+
height 115
|
371
499
|
|
372
|
-
|
373
|
-
|
374
|
-
}
|
375
|
-
|
376
|
-
@file_path_label = styled_text(:none) {
|
377
|
-
layout_data(:fill, :fill, true, false) {
|
378
|
-
horizontal_span 2
|
500
|
+
grid_layout(5, false) {
|
501
|
+
margin_right 5
|
379
502
|
}
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
503
|
+
|
504
|
+
stat_font = {name: 'Consolas', height: OS.mac? ? 15 : 12}
|
505
|
+
|
506
|
+
# row 1
|
507
|
+
|
508
|
+
label {
|
509
|
+
layout_data(:left, :center, false, false)
|
510
|
+
text 'File:'
|
511
|
+
foreground @default_foreground
|
386
512
|
}
|
387
|
-
|
388
|
-
|
513
|
+
|
514
|
+
@file_path_label = styled_text(:none) {
|
515
|
+
layout_data(:fill, :center, true, false) {
|
516
|
+
horizontal_span 2
|
517
|
+
}
|
518
|
+
background color(:widget_background)
|
519
|
+
foreground @default_foreground
|
520
|
+
editable false
|
521
|
+
caret nil
|
522
|
+
text bind(project_dir, 'selected_child.path')
|
523
|
+
on_mouse_up {
|
524
|
+
@file_path_label.swt_widget.selectAll
|
525
|
+
}
|
526
|
+
on_focus_lost {
|
527
|
+
@file_path_label.swt_widget.setSelection(0, 0)
|
528
|
+
}
|
389
529
|
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
text 'Line:'
|
396
|
-
}
|
397
|
-
@line_number_text = text {
|
398
|
-
layout_data(:fill, :fill, true, false) {
|
399
|
-
minimum_width 400
|
530
|
+
|
531
|
+
label {
|
532
|
+
layout_data(:left, :center, false, false)
|
533
|
+
text 'Caret Position:'
|
534
|
+
foreground @default_foreground
|
400
535
|
}
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
536
|
+
label(:right) {
|
537
|
+
layout_data(:fill, :center, true, false)
|
538
|
+
text bind(project_dir, 'selected_child.caret_position')
|
539
|
+
foreground @default_foreground
|
540
|
+
font stat_font
|
406
541
|
}
|
407
|
-
|
408
|
-
|
542
|
+
|
543
|
+
# row 2
|
544
|
+
|
545
|
+
label {
|
546
|
+
layout_data(:left, :center, false, false)
|
547
|
+
text 'Line:'
|
548
|
+
foreground @default_foreground
|
409
549
|
}
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
550
|
+
@line_number_text = text {
|
551
|
+
layout_data(:fill, :center, true, false) {
|
552
|
+
minimum_width 400
|
553
|
+
}
|
554
|
+
text bind(project_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
|
555
|
+
foreground @default_foreground
|
556
|
+
font stat_font
|
557
|
+
on_key_pressed { |key_event|
|
558
|
+
if key_event.keyCode == swt(:cr)
|
559
|
+
@current_text_editor&.text_widget&.setFocus
|
560
|
+
end
|
561
|
+
}
|
562
|
+
on_verify_text { |event|
|
563
|
+
event.doit = !event.text.match(/^\d*$/).to_a.empty?
|
564
|
+
}
|
421
565
|
}
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
if key_event.keyCode == swt(:cr)
|
429
|
-
project_dir.selected_child&.find_next
|
430
|
-
end
|
566
|
+
label # filler
|
567
|
+
|
568
|
+
label {
|
569
|
+
layout_data(:left, :center, false, false)
|
570
|
+
text 'Line Position:'
|
571
|
+
foreground @default_foreground
|
431
572
|
}
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
573
|
+
label(:right) {
|
574
|
+
layout_data(:fill, :center, true, false)
|
575
|
+
text bind(project_dir, 'selected_child.line_position')
|
576
|
+
foreground @default_foreground
|
577
|
+
font stat_font
|
578
|
+
}
|
579
|
+
|
580
|
+
# row 3
|
581
|
+
|
582
|
+
label {
|
583
|
+
layout_data(:left, :center, false, false)
|
584
|
+
text 'Find:'
|
585
|
+
foreground @default_foreground
|
586
|
+
}
|
587
|
+
@find_text = text {
|
588
|
+
layout_data(:fill, :center, true, false) {
|
589
|
+
minimum_width 400
|
590
|
+
}
|
591
|
+
text bind(project_dir, 'selected_child.find_text')
|
592
|
+
foreground @default_foreground
|
593
|
+
font stat_font
|
437
594
|
on_key_pressed { |key_event|
|
595
|
+
if key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
|
596
|
+
project_dir.selected_child.case_sensitive = !project_dir.selected_child.case_sensitive
|
597
|
+
project_dir.selected_child&.find_next
|
598
|
+
end
|
438
599
|
if key_event.keyCode == swt(:cr)
|
439
600
|
project_dir.selected_child&.find_next
|
440
601
|
end
|
441
602
|
}
|
442
603
|
}
|
604
|
+
composite {
|
605
|
+
layout_data(:left, :center, true, false)
|
606
|
+
row_layout {
|
607
|
+
margin_width 0
|
608
|
+
margin_height 0
|
609
|
+
}
|
610
|
+
button(:check) {
|
611
|
+
selection bind(project_dir, 'selected_child.case_sensitive')
|
612
|
+
on_key_pressed { |key_event|
|
613
|
+
if key_event.keyCode == swt(:cr)
|
614
|
+
project_dir.selected_child&.find_next
|
615
|
+
end
|
616
|
+
}
|
617
|
+
}
|
618
|
+
label {
|
619
|
+
text 'Case-sensitive'
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
443
623
|
label {
|
444
|
-
|
624
|
+
layout_data(:left, :center, false, false)
|
625
|
+
text 'Selection Count:'
|
626
|
+
foreground @default_foreground
|
445
627
|
}
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
text 'Replace:'
|
452
|
-
}
|
453
|
-
@replace_text = text {
|
454
|
-
layout_data(:fill, :fill, true, false) {
|
455
|
-
minimum_width 300
|
628
|
+
label(:right) {
|
629
|
+
layout_data(:fill, :center, true, false)
|
630
|
+
text bind(project_dir, 'selected_child.selection_count')
|
631
|
+
foreground @default_foreground
|
632
|
+
font stat_font
|
456
633
|
}
|
457
|
-
|
458
|
-
|
459
|
-
|
634
|
+
|
635
|
+
# row 4
|
636
|
+
|
637
|
+
label {
|
638
|
+
layout_data(:left, :center, false, false)
|
639
|
+
text 'Replace:'
|
640
|
+
foreground @default_foreground
|
460
641
|
}
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
642
|
+
@replace_text = text {
|
643
|
+
layout_data(:fill, :center, true, false) {
|
644
|
+
minimum_width 400
|
645
|
+
}
|
646
|
+
text bind(project_dir, 'selected_child.replace_text')
|
647
|
+
foreground @default_foreground
|
648
|
+
font stat_font
|
649
|
+
on_focus_gained {
|
650
|
+
project_dir.selected_child&.ensure_find_next
|
651
|
+
}
|
652
|
+
on_key_pressed { |key_event|
|
653
|
+
if key_event.keyCode == swt(:cr)
|
654
|
+
if project_dir.selected_child
|
655
|
+
Command.do(project_dir.selected_child, :replace_next!)
|
656
|
+
end
|
465
657
|
end
|
466
|
-
|
658
|
+
}
|
659
|
+
}
|
660
|
+
label # filler
|
661
|
+
label {
|
662
|
+
layout_data(:left, :center, false, false)
|
663
|
+
text 'Top Pixel:'
|
664
|
+
foreground @default_foreground
|
665
|
+
}
|
666
|
+
label(:right) {
|
667
|
+
layout_data(:fill, :center, true, false)
|
668
|
+
text bind(project_dir, 'selected_child.top_pixel')
|
669
|
+
foreground @default_foreground
|
670
|
+
font stat_font
|
467
671
|
}
|
468
672
|
}
|
469
|
-
|
673
|
+
|
674
|
+
on_item_collapsed {
|
675
|
+
@navigation_expand_item_height = @navigation_expand_item.swt_expand_item.height if @navigation_expand_item.swt_expand_item.height > 0
|
676
|
+
@navigation_expand_item.swt_expand_item.height = 0
|
677
|
+
async_exec {
|
678
|
+
body_root.pack_same_size
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
682
|
+
on_item_expanded {
|
683
|
+
@navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
|
684
|
+
async_exec {
|
685
|
+
body_root.pack_same_size
|
686
|
+
}
|
687
|
+
}
|
688
|
+
|
470
689
|
}
|
690
|
+
|
471
691
|
@tab_folder_sash_form = sash_form {
|
472
692
|
layout_data(:fill, :fill, true, true) {
|
473
|
-
width_hint
|
474
|
-
height_hint
|
693
|
+
width_hint 768
|
694
|
+
height_hint 576
|
695
|
+
minimum_width 768
|
696
|
+
minimum_height 576
|
475
697
|
}
|
476
698
|
sash_width 10
|
477
699
|
orientation bind(self, :split_orientation)
|
@@ -518,20 +740,59 @@ module Glimmer
|
|
518
740
|
project_dir.ignore_paths ||= ['packages', 'tmp']
|
519
741
|
open_file_paths1 = @config[:open_file_paths1] || @config[:open_file_paths]
|
520
742
|
open_file_paths2 = @config[:open_file_paths2]
|
521
|
-
|
522
|
-
|
743
|
+
self.split_orientation = swt(@config[:split_orientation] || :horizontal) rescue swt(:horizontal)
|
744
|
+
if @progress_bar_shell.nil?
|
745
|
+
@progress_bar_shell = shell(body_root, :title) {
|
746
|
+
text 'Gladiator'
|
747
|
+
fill_layout(:vertical) {
|
748
|
+
margin_width 15
|
749
|
+
margin_height 15
|
750
|
+
spacing 5
|
751
|
+
}
|
752
|
+
label(:center) {
|
753
|
+
text "Opening Last Open Files"
|
754
|
+
font height: 20
|
755
|
+
}
|
756
|
+
# @progress_bar = progress_bar(:horizontal, :indeterminate)
|
757
|
+
}
|
758
|
+
async_exec {
|
759
|
+
@progress_bar_shell.open
|
760
|
+
}
|
523
761
|
end
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
762
|
+
open_file_paths1.to_a.each do |file_path|
|
763
|
+
async_exec {
|
764
|
+
Gladiator.drag = false
|
765
|
+
project_dir.selected_child_path = file_path
|
766
|
+
}
|
529
767
|
end
|
530
768
|
# TODO replace the next line with one that selects the visible tab
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
769
|
+
async_exec {
|
770
|
+
Gladiator.drag = false
|
771
|
+
project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths1.to_a.include?(@config[:selected_child_path])
|
772
|
+
project_dir.selected_child&.caret_position = project_dir.selected_child&.caret_position_for_caret_position_start_of_line(@config[:caret_position].to_i) if @config[:caret_position]
|
773
|
+
project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
|
774
|
+
}
|
775
|
+
async_exec {
|
776
|
+
open_file_paths2.to_a.each do |file_path|
|
777
|
+
async_exec {
|
778
|
+
Gladiator.drag = true
|
779
|
+
project_dir.selected_child_path = file_path
|
780
|
+
}
|
781
|
+
end
|
782
|
+
# TODO replace the next line with one that selects the visible tab
|
783
|
+
async_exec {
|
784
|
+
Gladiator.drag = true
|
785
|
+
project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths2.to_a.include?(@config[:selected_child_path])
|
786
|
+
project_dir.selected_child&.caret_position = project_dir.selected_child&.caret_position_for_caret_position_start_of_line(@config[:caret_position].to_i) if @config[:caret_position]
|
787
|
+
project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
|
788
|
+
}
|
789
|
+
async_exec {
|
790
|
+
Gladiator.drag = false
|
791
|
+
@progress_bar_shell.close
|
792
|
+
@progress_bar_shell = nil
|
793
|
+
@loaded_config = true
|
794
|
+
}
|
795
|
+
}
|
535
796
|
else
|
536
797
|
@loaded_config = true
|
537
798
|
end
|
@@ -547,6 +808,7 @@ module Glimmer
|
|
547
808
|
open_file_paths2 = tab_folder2&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
|
548
809
|
@config = {
|
549
810
|
selected_child_path: child.path,
|
811
|
+
split_orientation: split_orientation == swt(:horizontal) ? 'horizontal' : 'vertical',
|
550
812
|
caret_position: child.caret_position,
|
551
813
|
top_pixel: child.top_pixel,
|
552
814
|
shell_width: swt_widget&.getBounds&.width,
|
@@ -582,8 +844,12 @@ module Glimmer
|
|
582
844
|
end
|
583
845
|
end
|
584
846
|
|
847
|
+
def find_tab_item(file_path)
|
848
|
+
@current_tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') == file_path }
|
849
|
+
end
|
850
|
+
|
585
851
|
def selected_tab_item
|
586
|
-
|
852
|
+
find_tab_item(project_dir.selected_child&.path)
|
587
853
|
end
|
588
854
|
|
589
855
|
def other_tab_items
|
@@ -609,25 +875,28 @@ module Glimmer
|
|
609
875
|
return if tree_item.nil?
|
610
876
|
file = tree_item.getData
|
611
877
|
parent_path = ::File.dirname(file.path)
|
878
|
+
if file.is_a?(Gladiator::Dir)
|
879
|
+
file_paths = file.all_children.select {|f| f.is_a?(Gladiator::File)}.map(&:path)
|
880
|
+
file.remove_all_observers
|
881
|
+
else
|
882
|
+
file_paths = [file.path]
|
883
|
+
end
|
884
|
+
file_paths.each do |file_path|
|
885
|
+
found_tab_item = find_tab_item(file_path)
|
886
|
+
if found_tab_item
|
887
|
+
project_dir.selected_child_path_history.delete(found_tab_item.getData('file_path'))
|
888
|
+
found_tab_item.getData('proxy')&.dispose
|
889
|
+
end
|
890
|
+
end
|
612
891
|
file.delete! # TODO consider supporting command undo/redo
|
613
892
|
project_dir.refresh(async: false)
|
614
893
|
parent_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == parent_path}.first
|
615
894
|
@file_tree.swt_widget.showItem(parent_tree_item)
|
616
895
|
parent_tree_item.setExpanded(true)
|
617
|
-
# TODO close text editor tab
|
618
|
-
# if file.is_a?(::File)
|
619
|
-
# close tab
|
620
|
-
# end
|
621
896
|
rescue => e
|
622
897
|
puts e.full_message
|
623
898
|
end
|
624
899
|
|
625
|
-
def rename_selected_tree_item
|
626
|
-
project_dir.pause_refresh
|
627
|
-
tree_item = @file_tree.swt_widget.getSelection.first
|
628
|
-
rename_tree_item(tree_item)
|
629
|
-
end
|
630
|
-
|
631
900
|
def add_new_directory_to_selected_tree_item
|
632
901
|
project_dir.pause_refresh
|
633
902
|
tree_item = @file_tree.swt_widget.getSelection.first
|
@@ -642,7 +911,7 @@ module Glimmer
|
|
642
911
|
project_dir.refresh(async: false, force: true)
|
643
912
|
new_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == new_directory_path}.first
|
644
913
|
@file_tree.swt_widget.showItem(new_tree_item)
|
645
|
-
rename_tree_item(new_tree_item
|
914
|
+
rename_tree_item(new_tree_item)
|
646
915
|
end
|
647
916
|
|
648
917
|
def add_new_file_to_selected_tree_item
|
@@ -662,14 +931,40 @@ module Glimmer
|
|
662
931
|
rename_tree_item(new_tree_item, true)
|
663
932
|
end
|
664
933
|
|
665
|
-
def
|
934
|
+
def rename_selected_tree_item
|
935
|
+
project_dir.pause_refresh
|
936
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
937
|
+
rename_tree_item(tree_item)
|
938
|
+
end
|
939
|
+
|
940
|
+
def rename_tree_item(tree_item, new_file = false)
|
941
|
+
original_file = tree_item.getData
|
942
|
+
current_file = project_dir.selected_child_path == original_file.path
|
943
|
+
found_tab_item = find_tab_item(original_file.path)
|
944
|
+
found_text_editor = found_tab_item&.getData('text_editor')
|
666
945
|
@file_tree.edit_tree_item(
|
667
946
|
tree_item,
|
668
947
|
after_write: -> (edited_tree_item) {
|
669
948
|
file = edited_tree_item.getData
|
670
949
|
file_path = file.path
|
671
|
-
|
672
|
-
|
950
|
+
file.name
|
951
|
+
if new_file
|
952
|
+
project_dir.selected_child_path = file_path
|
953
|
+
else
|
954
|
+
found_text_editor&.file = file
|
955
|
+
found_tab_item&.setData('file', file)
|
956
|
+
found_tab_item&.setData('file_path', file.path)
|
957
|
+
found_tab_item&.setText(file.name)
|
958
|
+
body_root.pack_same_size
|
959
|
+
if current_file
|
960
|
+
project_dir.selected_child_path = file_path
|
961
|
+
else
|
962
|
+
selected_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
963
|
+
end
|
964
|
+
async_exec {
|
965
|
+
@file_tree.swt_widget.showItem(edited_tree_item)
|
966
|
+
}
|
967
|
+
end
|
673
968
|
project_dir.resume_refresh
|
674
969
|
},
|
675
970
|
after_cancel: -> {
|
@@ -686,8 +981,8 @@ module Glimmer
|
|
686
981
|
|
687
982
|
def open_project
|
688
983
|
selected_directory = directory_dialog.open
|
689
|
-
@progress_bar_shell = shell(body_root) {
|
690
|
-
text '
|
984
|
+
@progress_bar_shell = shell(body_root, :title) {
|
985
|
+
text 'Gladiator'
|
691
986
|
fill_layout(:vertical) {
|
692
987
|
margin_width 15
|
693
988
|
margin_height 15
|
@@ -699,19 +994,16 @@ module Glimmer
|
|
699
994
|
}
|
700
995
|
# @progress_bar = progress_bar(:horizontal, :indeterminate)
|
701
996
|
}
|
702
|
-
|
703
|
-
|
704
|
-
@progress_bar_shell.open
|
705
|
-
}
|
997
|
+
async_exec {
|
998
|
+
@progress_bar_shell.open
|
706
999
|
}
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
}
|
1000
|
+
async_exec {
|
1001
|
+
gladiator(project_dir_path: selected_directory) {
|
1002
|
+
on_swt_show {
|
1003
|
+
@progress_bar_shell.close
|
1004
|
+
@progress_bar_shell = nil
|
1005
|
+
}
|
1006
|
+
}.open if selected_directory
|
715
1007
|
}
|
716
1008
|
end
|
717
1009
|
|
@@ -758,7 +1050,7 @@ module Glimmer
|
|
758
1050
|
end
|
759
1051
|
end
|
760
1052
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'o'
|
761
|
-
self.split_orientation = split_orientation == swt(:horizontal) ? swt(:vertical) : swt(:horizontal)
|
1053
|
+
self.split_orientation = split_pane? && split_orientation == swt(:horizontal) ? swt(:vertical) : swt(:horizontal)
|
762
1054
|
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
|
763
1055
|
current_tab_folder.swt_widget.setSelection((current_tab_folder.swt_widget.getSelectionIndex() + 1) % current_tab_folder.swt_widget.getItemCount) if current_tab_folder.swt_widget.getItemCount > 0
|
764
1056
|
current_text_editor&.text_widget&.setFocus
|
@@ -833,4 +1125,4 @@ module Glimmer
|
|
833
1125
|
end
|
834
1126
|
end
|
835
1127
|
end
|
836
|
-
end
|
1128
|
+
end
|