glimmer-cs-gladiator 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -11
- data/VERSION +1 -1
- data/bin/gladiator_runner.rb +2 -1
- data/lib/models/glimmer/gladiator/dir.rb +51 -51
- data/lib/models/glimmer/gladiator/file.rb +106 -76
- data/lib/views/glimmer/gladiator.rb +358 -278
- data/lib/views/glimmer/gladiator/text_editor.rb +21 -16
- metadata +4 -4
@@ -14,8 +14,9 @@ module Glimmer
|
|
14
14
|
# Gladiator (Glimmer Editor)
|
15
15
|
class Gladiator
|
16
16
|
include Glimmer::UI::CustomShell
|
17
|
-
|
18
|
-
APP_ROOT = ::File.expand_path('../../../..', __FILE__)
|
17
|
+
|
18
|
+
APP_ROOT = ::File.expand_path('../../../..', __FILE__)
|
19
|
+
# TODO make sure COMMAND_KEY doesn't clash on Linux/Windows for CMD+CTRL shortcuts
|
19
20
|
COMMAND_KEY = OS.mac? ? :command : :ctrl
|
20
21
|
|
21
22
|
class << self
|
@@ -28,208 +29,113 @@ module Glimmer
|
|
28
29
|
# options :title, :background_color
|
29
30
|
# option :width, 320
|
30
31
|
# option :height, 240
|
32
|
+
option :project_dir_path
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
def project_dir
|
35
|
+
@project_dir ||= Dir.new(project_dir_path)
|
36
|
+
end
|
37
|
+
|
38
|
+
attr_reader :find_text, :tab_folder1, :tab_folder2, :filter_text, :rename_in_progress, :line_number_text, :file_tree
|
39
|
+
attr_accessor :split_orientation, :current_tab_item, :current_tab_folder, :current_text_editor
|
40
|
+
|
34
41
|
## Uncomment before_body block to pre-initialize variables to use in body
|
35
42
|
#
|
36
43
|
#
|
37
44
|
before_body {
|
45
|
+
Thread.new {
|
46
|
+
project_dir #pre-initialize directory
|
47
|
+
}
|
48
|
+
at_exit do
|
49
|
+
project_dir.selected_child&.write_raw_dirty_content
|
50
|
+
end
|
38
51
|
Display.setAppName('Gladiator')
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@find_text.swt_widget.setFocus
|
47
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'c'
|
48
|
-
Clipboard.copy(Dir.local_dir.selected_child.path)
|
49
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'g'
|
50
|
-
Dir.local_dir.selected_child.find_previous
|
51
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'w'
|
52
|
-
@tab_folder.swt_widget.getItems.each do |tab_item|
|
53
|
-
Dir.local_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
54
|
-
tab_item.getData('proxy')&.dispose
|
55
|
-
end
|
56
|
-
close_tab_folder
|
57
|
-
@tab_item = @text_editor = Dir.local_dir.selected_child = nil
|
58
|
-
@filter_text.swt_widget.selectAll
|
59
|
-
@filter_text.swt_widget.setFocus
|
60
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :alt) && extract_char(key_event) == 'w'
|
61
|
-
other_tab_items.each do |tab_item|
|
62
|
-
Dir.local_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
63
|
-
tab_item.getData('proxy')&.dispose
|
64
|
-
end
|
65
|
-
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'w'
|
66
|
-
if selected_tab_item
|
67
|
-
Dir.local_dir.selected_child_path_history.delete(Dir.local_dir.selected_child.path)
|
68
|
-
selected_tab_item.getData('proxy')&.dispose
|
69
|
-
close_tab_folder
|
70
|
-
if selected_tab_item.nil?
|
71
|
-
@tab_item = @text_editor = Dir.local_dir.selected_child = nil
|
72
|
-
@filter_text.swt_widget.selectAll
|
73
|
-
@filter_text.swt_widget.setFocus
|
74
|
-
else
|
75
|
-
@text_editor&.text_widget&.setFocus
|
76
|
-
end
|
77
|
-
end
|
78
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'o'
|
79
|
-
self.split_orientation = split_orientation == swt(:horizontal) ? swt(:vertical) : swt(:horizontal)
|
80
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
|
81
|
-
@tab_folder.swt_widget.setSelection((@tab_folder.swt_widget.getSelectionIndex() + 1) % @tab_folder.swt_widget.getItemCount) if @tab_folder.swt_widget.getItemCount > 0
|
82
|
-
@text_editor&.text_widget&.setFocus
|
83
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == '['
|
84
|
-
@tab_folder.swt_widget.setSelection((@tab_folder.swt_widget.getSelectionIndex() - 1) % @tab_folder.swt_widget.getItemCount) if @tab_folder.swt_widget.getItemCount > 0
|
85
|
-
@text_editor&.text_widget&.setFocus
|
86
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == ']'
|
87
|
-
if @tab_folder2
|
88
|
-
if @tab_folder == @tab_folder1
|
89
|
-
@tab_folder = @tab_folder2
|
90
|
-
else
|
91
|
-
@tab_folder = @tab_folder1
|
92
|
-
end
|
93
|
-
@tab_item = @tab_folder.swt_widget.getData('selected_tab_item')
|
94
|
-
Dir.local_dir.selected_child = @tab_item&.swt_tab_item&.getData('file')
|
95
|
-
@tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
96
|
-
end
|
97
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == '['
|
98
|
-
if @tab_folder2
|
99
|
-
if @tab_folder == @tab_folder2
|
100
|
-
@tab_folder = @tab_folder1
|
101
|
-
else
|
102
|
-
@tab_folder = @tab_folder2
|
103
|
-
end
|
104
|
-
@tab_item = @tab_folder.swt_widget.getData('selected_tab_item')
|
105
|
-
Dir.local_dir.selected_child = @tab_item&.swt_tab_item&.getData('file')
|
106
|
-
@tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
107
|
-
end
|
108
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '1'
|
109
|
-
@tab_folder.swt_widget.setSelection(0) if @tab_folder.swt_widget.getItemCount >= 1
|
110
|
-
@text_editor&.text_widget&.setFocus
|
111
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '2'
|
112
|
-
@tab_folder.swt_widget.setSelection(1) if @tab_folder.swt_widget.getItemCount >= 2
|
113
|
-
@text_editor&.text_widget&.setFocus
|
114
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '3'
|
115
|
-
@tab_folder.swt_widget.setSelection(2) if @tab_folder.swt_widget.getItemCount >= 3
|
116
|
-
@text_editor&.text_widget&.setFocus
|
117
|
-
@tab_folder.swt_widget.setSelection(3) if @tab_folder.swt_widget.getItemCount >= 4
|
118
|
-
@text_editor&.text_widget&.setFocus
|
119
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '5'
|
120
|
-
@tab_folder.swt_widget.setSelection(4) if @tab_folder.swt_widget.getItemCount >= 5
|
121
|
-
@text_editor&.text_widget&.setFocus
|
122
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '4'
|
123
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '6'
|
124
|
-
@tab_folder.swt_widget.setSelection(5) if @tab_folder.swt_widget.getItemCount >= 6
|
125
|
-
@text_editor&.text_widget&.setFocus
|
126
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '7'
|
127
|
-
@tab_folder.swt_widget.setSelection(6) if @tab_folder.swt_widget.getItemCount >= 7
|
128
|
-
@text_editor&.text_widget&.setFocus
|
129
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '8'
|
130
|
-
@tab_folder.swt_widget.setSelection(7) if @tab_folder.swt_widget.getItemCount >= 8
|
131
|
-
@text_editor&.text_widget&.setFocus
|
132
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '9'
|
133
|
-
@tab_folder.swt_widget.setSelection(@tab_folder.swt_widget.getItemCount - 1) if @tab_folder.swt_widget.getItemCount > 0
|
134
|
-
@text_editor&.text_widget&.setFocus
|
135
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'g'
|
136
|
-
Dir.local_dir.selected_child.find_next
|
137
|
-
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
|
138
|
-
@line_number_text.swt_widget.selectAll
|
139
|
-
@line_number_text.swt_widget.setFocus
|
140
|
-
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'r'
|
141
|
-
@filter_text.swt_widget.selectAll
|
142
|
-
@filter_text.swt_widget.setFocus
|
143
|
-
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 't'
|
144
|
-
select_tree_item unless @rename_in_progress
|
145
|
-
@tree.swt_widget.setFocus
|
146
|
-
elsif key_event.keyCode == swt(:esc)
|
147
|
-
if @text_editor
|
148
|
-
Dir.local_dir.selected_child_path = @text_editor.file.path
|
149
|
-
@text_editor&.text_widget&.setFocus
|
150
|
-
end
|
151
|
-
end
|
52
|
+
# make sure the display events are only hooked once if multiple gladiators are created
|
53
|
+
unless defined?(@@display)
|
54
|
+
@@display = display {
|
55
|
+
on_swt_keydown { |key_event|
|
56
|
+
focused_gladiator = display.focus_control.shell&.get_data('custom_shell')
|
57
|
+
focused_gladiator.handle_display_shortcut(key_event) if !focused_gladiator.nil? && key_event.widget.shell == focused_gladiator&.swt_widget
|
58
|
+
}
|
152
59
|
}
|
153
|
-
|
60
|
+
end
|
154
61
|
|
155
62
|
@split_orientation = swt(:horizontal)
|
156
|
-
|
157
|
-
@config_file_path = ::File.join(local_dir, '.gladiator')
|
63
|
+
@config_file_path = ::File.join(project_dir.path, '.gladiator')
|
158
64
|
@config = {}
|
159
65
|
load_config_ignore_paths
|
160
|
-
#
|
66
|
+
# project_dir.all_children # pre-caches children
|
161
67
|
}
|
162
68
|
|
163
69
|
## Uncomment after_body block to setup observers for widgets in body
|
164
70
|
#
|
165
71
|
after_body {
|
166
|
-
observe(
|
72
|
+
observe(project_dir, 'children') do
|
167
73
|
select_tree_item unless @rename_in_progress
|
168
74
|
end
|
169
|
-
observe(
|
75
|
+
observe(project_dir, 'selected_child') do |selected_file|
|
170
76
|
if selected_file
|
171
77
|
if Gladiator.drag && !@tab_folder2
|
172
|
-
@tab_folder1 = @
|
78
|
+
@tab_folder1 = @current_tab_folder
|
173
79
|
@tab_folder_sash_form.content {
|
174
|
-
@
|
175
|
-
@
|
80
|
+
@current_tab_folder = @tab_folder2 = tab_folder
|
81
|
+
@current_tab_folder.swt_widget.setData('proxy', @current_tab_folder)
|
176
82
|
}
|
177
83
|
end
|
178
84
|
select_tree_item unless @rename_in_progress
|
179
85
|
found_tab_item = selected_tab_item
|
180
86
|
if found_tab_item
|
181
|
-
@
|
182
|
-
@
|
183
|
-
@
|
184
|
-
@
|
87
|
+
@current_tab_folder.swt_widget.setSelection(found_tab_item)
|
88
|
+
@current_tab_item = found_tab_item.getData('proxy')
|
89
|
+
@current_text_editor = found_tab_item.getData('text_editor')
|
90
|
+
@current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
|
185
91
|
elsif selected_file
|
186
|
-
@
|
187
|
-
@
|
92
|
+
@current_tab_folder.content {
|
93
|
+
@current_tab_item = tab_item { |the_tab_item|
|
188
94
|
text selected_file.name
|
189
95
|
fill_layout :horizontal
|
190
|
-
@
|
191
|
-
@
|
192
|
-
@
|
96
|
+
@current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
|
97
|
+
@current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
|
98
|
+
@current_text_editor.text_proxy.content {
|
193
99
|
on_focus_gained {
|
194
100
|
tab_folder = the_text_editor.swt_widget.getParent.getParent
|
195
|
-
@
|
196
|
-
@
|
197
|
-
@
|
198
|
-
@
|
199
|
-
@
|
200
|
-
|
101
|
+
@current_tab_folder = tab_folder.getData('proxy')
|
102
|
+
@current_tab_item = the_tab_item
|
103
|
+
@current_text_editor = the_text_editor
|
104
|
+
@current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
|
105
|
+
@current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
|
106
|
+
project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
|
201
107
|
}
|
202
108
|
}
|
203
109
|
on_swt_show {
|
204
|
-
@
|
205
|
-
@
|
206
|
-
@
|
207
|
-
@
|
208
|
-
@
|
209
|
-
|
110
|
+
@current_tab_item = the_tab_item
|
111
|
+
@current_text_editor = the_text_editor
|
112
|
+
@current_tab_folder = @current_tab_item.swt_widget.getParent.getData('proxy')
|
113
|
+
@current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
|
114
|
+
@current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
|
115
|
+
project_dir.selected_child = selected_file
|
210
116
|
async_exec {
|
211
|
-
@
|
117
|
+
@current_text_editor&.text_widget&.setFocus
|
212
118
|
}
|
213
119
|
}
|
214
120
|
}
|
215
|
-
@
|
216
|
-
@
|
217
|
-
@
|
218
|
-
@
|
219
|
-
}
|
220
|
-
@
|
121
|
+
@current_tab_item.swt_tab_item.setData('file_path', selected_file.path)
|
122
|
+
@current_tab_item.swt_tab_item.setData('file', selected_file)
|
123
|
+
@current_tab_item.swt_tab_item.setData('text_editor', @current_text_editor)
|
124
|
+
@current_tab_item.swt_tab_item.setData('proxy', @current_tab_item)
|
125
|
+
}
|
126
|
+
@current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
|
221
127
|
body_root.pack_same_size
|
222
128
|
end
|
223
|
-
@
|
129
|
+
@current_text_editor&.text_widget&.setFocus
|
224
130
|
end
|
225
131
|
end
|
226
|
-
observe(
|
132
|
+
observe(project_dir, 'selected_child') do
|
227
133
|
save_config
|
228
134
|
end
|
229
|
-
observe(
|
135
|
+
observe(project_dir, 'selected_child.caret_position') do
|
230
136
|
save_config
|
231
137
|
end
|
232
|
-
observe(
|
138
|
+
observe(project_dir, 'selected_child.top_pixel') do
|
233
139
|
save_config
|
234
140
|
end
|
235
141
|
load_config
|
@@ -240,20 +146,20 @@ module Glimmer
|
|
240
146
|
#
|
241
147
|
body {
|
242
148
|
shell {
|
243
|
-
text "Gladiator - #{::File.expand_path(
|
149
|
+
text "Gladiator - #{::File.expand_path(project_dir.path)}"
|
244
150
|
minimum_size 520, 250
|
245
|
-
size 1440, 900
|
151
|
+
size 1440, 900
|
246
152
|
grid_layout(2, false)
|
247
153
|
on_swt_show {
|
248
154
|
swt_widget.setSize(@config[:shell_width], @config[:shell_height]) if @config[:shell_width] && @config[:shell_height]
|
249
|
-
swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
|
155
|
+
swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
|
250
156
|
@loaded_config = true
|
251
157
|
}
|
252
158
|
on_swt_close {
|
253
|
-
|
159
|
+
project_dir.selected_child&.write_dirty_content
|
254
160
|
}
|
255
161
|
on_widget_disposed {
|
256
|
-
|
162
|
+
project_dir.selected_child&.write_dirty_content
|
257
163
|
}
|
258
164
|
on_control_resized {
|
259
165
|
save_config
|
@@ -262,10 +168,31 @@ module Glimmer
|
|
262
168
|
save_config
|
263
169
|
}
|
264
170
|
on_shell_deactivated {
|
265
|
-
@
|
266
|
-
}
|
171
|
+
@current_text_editor&.file&.write_dirty_content
|
172
|
+
}
|
267
173
|
|
268
174
|
menu_bar {
|
175
|
+
menu {
|
176
|
+
text '&File'
|
177
|
+
|
178
|
+
menu_item {
|
179
|
+
text 'New &Scratchpad'
|
180
|
+
on_widget_selected {
|
181
|
+
begin
|
182
|
+
project_dir.selected_child_path = ''
|
183
|
+
rescue => e
|
184
|
+
pd e
|
185
|
+
end
|
186
|
+
}
|
187
|
+
}
|
188
|
+
menu_item(:separator)
|
189
|
+
menu_item {
|
190
|
+
text 'Open &Project...'
|
191
|
+
on_widget_selected {
|
192
|
+
open_project
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
269
196
|
menu {
|
270
197
|
text '&View'
|
271
198
|
menu {
|
@@ -285,9 +212,9 @@ module Glimmer
|
|
285
212
|
# menu_item {
|
286
213
|
# text 'Launch Glimmer &App'
|
287
214
|
# on_widget_selected {
|
288
|
-
# parent_path =
|
215
|
+
# parent_path = project_dir.path
|
289
216
|
## current_directory_name = ::File.basename(parent_path)
|
290
|
-
## assumed_shell_script = ::File.join(parent_path, 'bin', current_directory_name)
|
217
|
+
## assumed_shell_script = ::File.join(parent_path, 'bin', current_directory_name)
|
291
218
|
## assumed_shell_script = ::Dir.glob(::File.join(parent_path, 'bin', '*')).detect {|f| ::File.file?(f) && !::File.read(f).include?('#!/usr/bin/env')} if !::File.exist?(assumed_shell_script)
|
292
219
|
## load assumed_shell_script
|
293
220
|
# FileUtils.cd(parent_path) do
|
@@ -296,9 +223,9 @@ module Glimmer
|
|
296
223
|
# }
|
297
224
|
# }
|
298
225
|
menu_item {
|
299
|
-
text '&
|
226
|
+
text '&Ruby'
|
300
227
|
on_widget_selected {
|
301
|
-
|
228
|
+
project_dir.selected_child.run
|
302
229
|
}
|
303
230
|
}
|
304
231
|
}
|
@@ -311,16 +238,16 @@ module Glimmer
|
|
311
238
|
}
|
312
239
|
@filter_text = text {
|
313
240
|
layout_data :fill, :center, true, false
|
314
|
-
text bind(
|
241
|
+
text bind(project_dir, 'filter')
|
315
242
|
on_key_pressed { |key_event|
|
316
|
-
if key_event.keyCode == swt(:tab) ||
|
317
|
-
key_event.keyCode == swt(:cr) ||
|
243
|
+
if key_event.keyCode == swt(:tab) ||
|
244
|
+
key_event.keyCode == swt(:cr) ||
|
318
245
|
key_event.keyCode == swt(:arrow_up) ||
|
319
246
|
key_event.keyCode == swt(:arrow_down)
|
320
247
|
@list.swt_widget.select(0) if @list.swt_widget.getSelectionIndex() == -1
|
321
248
|
@list.swt_widget.setFocus
|
322
249
|
end
|
323
|
-
}
|
250
|
+
}
|
324
251
|
}
|
325
252
|
composite {
|
326
253
|
fill_layout(:vertical) {
|
@@ -328,15 +255,15 @@ module Glimmer
|
|
328
255
|
}
|
329
256
|
layout_data(:fill, :fill, true, true)
|
330
257
|
@list = list(:border, :h_scroll, :v_scroll) {
|
331
|
-
#visible bind(
|
332
|
-
selection bind(
|
258
|
+
#visible bind(self, 'project_dir.filter') {|f| !!f}
|
259
|
+
selection bind(project_dir, :filtered_path)
|
333
260
|
on_mouse_up {
|
334
|
-
|
261
|
+
project_dir.selected_child_path = @list.swt_widget.getSelection.first
|
335
262
|
}
|
336
263
|
on_key_pressed { |key_event|
|
337
264
|
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
338
|
-
|
339
|
-
@
|
265
|
+
project_dir.selected_child_path = @list.swt_widget.getSelection.first
|
266
|
+
@current_text_editor&.text_widget&.setFocus
|
340
267
|
end
|
341
268
|
}
|
342
269
|
drag_source(DND::DROP_COPY) {
|
@@ -346,11 +273,11 @@ module Glimmer
|
|
346
273
|
list = event.widget.getControl
|
347
274
|
event.data = list.getSelection.first
|
348
275
|
}
|
349
|
-
}
|
276
|
+
}
|
350
277
|
}
|
351
|
-
@
|
352
|
-
#visible bind(
|
353
|
-
items bind(
|
278
|
+
@file_tree = tree(:virtual, :border, :h_scroll, :v_scroll) {
|
279
|
+
#visible bind(self, 'project_dir.filter') {|f| !f}
|
280
|
+
items bind(self, :project_dir), tree_properties(children: :children, text: :name)
|
354
281
|
drag_source(DND::DROP_COPY) {
|
355
282
|
transfer [TextTransfer.getInstance].to_java(Transfer)
|
356
283
|
on_drag_set_data { |event|
|
@@ -364,21 +291,21 @@ module Glimmer
|
|
364
291
|
@open_menu_item = menu_item {
|
365
292
|
text 'Open'
|
366
293
|
on_widget_selected {
|
367
|
-
|
294
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
|
368
295
|
}
|
369
296
|
}
|
370
297
|
menu_item(:separator)
|
371
298
|
menu_item {
|
372
299
|
text 'Delete'
|
373
300
|
on_widget_selected {
|
374
|
-
tree_item = @
|
301
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
375
302
|
delete_tree_item(tree_item)
|
376
303
|
}
|
377
304
|
}
|
378
305
|
menu_item {
|
379
306
|
text 'Refresh'
|
380
307
|
on_widget_selected {
|
381
|
-
|
308
|
+
project_dir.refresh
|
382
309
|
}
|
383
310
|
}
|
384
311
|
menu_item {
|
@@ -401,25 +328,25 @@ module Glimmer
|
|
401
328
|
}
|
402
329
|
}
|
403
330
|
on_swt_menudetect { |event|
|
404
|
-
path = extract_tree_item_path(@
|
331
|
+
path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
|
405
332
|
@open_menu_item.swt_widget.setEnabled(!::Dir.exist?(path)) if path
|
406
333
|
}
|
407
334
|
on_mouse_up {
|
408
335
|
if Gladiator.drag_and_drop
|
409
336
|
Gladiator.drag_and_drop = false
|
410
337
|
else
|
411
|
-
|
412
|
-
@
|
338
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
|
339
|
+
@current_text_editor&.text_widget&.setFocus
|
413
340
|
end
|
414
341
|
}
|
415
342
|
on_key_pressed { |key_event|
|
416
343
|
if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
|
417
|
-
|
418
|
-
@
|
344
|
+
project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
|
345
|
+
@current_text_editor&.text_widget&.setFocus
|
419
346
|
end
|
420
347
|
}
|
421
348
|
on_paint_control {
|
422
|
-
root_item = @
|
349
|
+
root_item = @file_tree.swt_widget.getItems.first
|
423
350
|
if root_item && !root_item.getExpanded
|
424
351
|
root_item.setExpanded(true)
|
425
352
|
end
|
@@ -427,10 +354,11 @@ module Glimmer
|
|
427
354
|
}
|
428
355
|
}
|
429
356
|
|
430
|
-
|
431
|
-
@
|
432
|
-
@
|
433
|
-
@
|
357
|
+
# TODO see if you could replace some of this with Glimmer DSL/API syntax
|
358
|
+
@file_tree_editor = TreeEditor.new(@file_tree.swt_widget);
|
359
|
+
@file_tree_editor.horizontalAlignment = swt(:left);
|
360
|
+
@file_tree_editor.grabHorizontal = true;
|
361
|
+
@file_tree_editor.minimumHeight = 20;
|
434
362
|
|
435
363
|
}
|
436
364
|
@editor_container = composite {
|
@@ -438,9 +366,9 @@ module Glimmer
|
|
438
366
|
layout_data :fill, :fill, true, true
|
439
367
|
composite {
|
440
368
|
grid_layout 3, false
|
441
|
-
|
369
|
+
|
442
370
|
# row 1
|
443
|
-
|
371
|
+
|
444
372
|
label {
|
445
373
|
text 'File:'
|
446
374
|
}
|
@@ -452,7 +380,7 @@ module Glimmer
|
|
452
380
|
background color(:widget_background)
|
453
381
|
editable false
|
454
382
|
caret nil
|
455
|
-
text bind(
|
383
|
+
text bind(project_dir, 'selected_child.path')
|
456
384
|
on_mouse_up {
|
457
385
|
@file_path_label.swt_widget.selectAll
|
458
386
|
}
|
@@ -460,9 +388,9 @@ module Glimmer
|
|
460
388
|
@file_path_label.swt_widget.setSelection(0, 0)
|
461
389
|
}
|
462
390
|
}
|
463
|
-
|
391
|
+
|
464
392
|
# row 2
|
465
|
-
|
393
|
+
|
466
394
|
label {
|
467
395
|
text 'Line:'
|
468
396
|
}
|
@@ -470,18 +398,18 @@ module Glimmer
|
|
470
398
|
layout_data(:fill, :fill, true, false) {
|
471
399
|
minimum_width 400
|
472
400
|
}
|
473
|
-
text bind(
|
401
|
+
text bind(project_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
|
474
402
|
on_key_pressed { |key_event|
|
475
403
|
if key_event.keyCode == swt(:cr)
|
476
|
-
@
|
404
|
+
@current_text_editor&.text_widget&.setFocus
|
477
405
|
end
|
478
406
|
}
|
479
407
|
on_verify_text { |event|
|
480
|
-
event.doit = !event.text.match(/^\d*$/).to_a.empty?
|
408
|
+
event.doit = !event.text.match(/^\d*$/).to_a.empty?
|
481
409
|
}
|
482
410
|
}
|
483
411
|
label
|
484
|
-
|
412
|
+
|
485
413
|
# row 3
|
486
414
|
|
487
415
|
label {
|
@@ -491,34 +419,34 @@ module Glimmer
|
|
491
419
|
layout_data(:fill, :center, true, false) {
|
492
420
|
minimum_width 400
|
493
421
|
}
|
494
|
-
text bind(
|
422
|
+
text bind(project_dir, 'selected_child.find_text')
|
495
423
|
on_key_pressed { |key_event|
|
496
424
|
if key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
|
497
|
-
|
498
|
-
|
425
|
+
project_dir.selected_child.case_sensitive = !project_dir.selected_child.case_sensitive
|
426
|
+
project_dir.selected_child&.find_next
|
499
427
|
end
|
500
428
|
if key_event.keyCode == swt(:cr)
|
501
|
-
|
429
|
+
project_dir.selected_child&.find_next
|
502
430
|
end
|
503
431
|
}
|
504
432
|
}
|
505
433
|
composite {
|
506
434
|
row_layout
|
507
435
|
button(:check) {
|
508
|
-
selection bind(
|
436
|
+
selection bind(project_dir, 'selected_child.case_sensitive')
|
509
437
|
on_key_pressed { |key_event|
|
510
438
|
if key_event.keyCode == swt(:cr)
|
511
|
-
|
439
|
+
project_dir.selected_child&.find_next
|
512
440
|
end
|
513
|
-
}
|
441
|
+
}
|
514
442
|
}
|
515
443
|
label {
|
516
444
|
text 'Case-sensitive'
|
517
445
|
}
|
518
446
|
}
|
519
|
-
|
447
|
+
|
520
448
|
# row 4
|
521
|
-
|
449
|
+
|
522
450
|
label {
|
523
451
|
text 'Replace:'
|
524
452
|
}
|
@@ -526,14 +454,14 @@ module Glimmer
|
|
526
454
|
layout_data(:fill, :fill, true, false) {
|
527
455
|
minimum_width 300
|
528
456
|
}
|
529
|
-
text bind(
|
530
|
-
on_focus_gained {
|
531
|
-
|
457
|
+
text bind(project_dir, 'selected_child.replace_text')
|
458
|
+
on_focus_gained {
|
459
|
+
project_dir.selected_child&.ensure_find_next
|
532
460
|
}
|
533
461
|
on_key_pressed { |key_event|
|
534
462
|
if key_event.keyCode == swt(:cr)
|
535
|
-
if
|
536
|
-
Command.do(
|
463
|
+
if project_dir.selected_child
|
464
|
+
Command.do(project_dir.selected_child, :replace_next!)
|
537
465
|
end
|
538
466
|
end
|
539
467
|
}
|
@@ -547,7 +475,7 @@ module Glimmer
|
|
547
475
|
}
|
548
476
|
sash_width 10
|
549
477
|
orientation bind(self, :split_orientation)
|
550
|
-
@
|
478
|
+
@current_tab_folder = tab_folder {
|
551
479
|
drag_source(DND::DROP_COPY) {
|
552
480
|
transfer [TextTransfer.getInstance].to_java(Transfer)
|
553
481
|
event_data = nil
|
@@ -562,7 +490,7 @@ module Glimmer
|
|
562
490
|
}
|
563
491
|
}
|
564
492
|
}
|
565
|
-
@
|
493
|
+
@current_tab_folder.swt_widget.setData('proxy', @current_tab_folder)
|
566
494
|
}
|
567
495
|
}
|
568
496
|
}
|
@@ -574,43 +502,46 @@ module Glimmer
|
|
574
502
|
config_yaml = ::File.read(@config_file_path)
|
575
503
|
return if config_yaml.to_s.strip.empty?
|
576
504
|
@config = YAML.load(config_yaml)
|
577
|
-
|
578
|
-
|
505
|
+
project_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
|
506
|
+
project_dir.ignore_paths ||= ['packages', 'tmp']
|
579
507
|
else
|
580
508
|
@loaded_config = true
|
581
509
|
end
|
582
510
|
end
|
583
|
-
|
511
|
+
|
584
512
|
def load_config
|
585
513
|
if ::File.exists?(@config_file_path)
|
586
514
|
config_yaml = ::File.read(@config_file_path)
|
587
515
|
return if config_yaml.to_s.strip.empty?
|
588
516
|
@config = YAML.load(config_yaml)
|
589
|
-
|
590
|
-
|
517
|
+
project_dir.ignore_paths = @config[:ignore_paths] if @config[:ignore_paths]
|
518
|
+
project_dir.ignore_paths ||= ['packages', 'tmp']
|
591
519
|
open_file_paths1 = @config[:open_file_paths1] || @config[:open_file_paths]
|
592
520
|
open_file_paths2 = @config[:open_file_paths2]
|
593
521
|
open_file_paths1.to_a.each do |file_path|
|
594
|
-
|
522
|
+
project_dir.selected_child_path = file_path
|
595
523
|
end
|
524
|
+
# TODO replace the next line with one that selects the visible tab
|
525
|
+
project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths1.to_a.include?(@config[:selected_child_path])
|
596
526
|
Gladiator.drag = true
|
597
527
|
open_file_paths2.to_a.each do |file_path|
|
598
|
-
|
528
|
+
project_dir.selected_child_path = file_path
|
599
529
|
end
|
530
|
+
# TODO replace the next line with one that selects the visible tab
|
531
|
+
project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths2.to_a.include?(@config[:selected_child_path])
|
600
532
|
Gladiator.drag = false
|
601
|
-
|
602
|
-
|
603
|
-
Dir.local_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
|
533
|
+
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]
|
534
|
+
project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
|
604
535
|
else
|
605
536
|
@loaded_config = true
|
606
537
|
end
|
607
538
|
end
|
608
|
-
|
539
|
+
|
609
540
|
def save_config
|
610
541
|
return unless @loaded_config
|
611
|
-
child =
|
542
|
+
child = project_dir.selected_child
|
612
543
|
return if child.nil?
|
613
|
-
tab_folder1 = @tab_folder1 || @
|
544
|
+
tab_folder1 = @tab_folder1 || @current_tab_folder
|
614
545
|
tab_folder2 = @tab_folder2
|
615
546
|
open_file_paths1 = tab_folder1&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
|
616
547
|
open_file_paths2 = tab_folder2&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
|
@@ -624,39 +555,39 @@ module Glimmer
|
|
624
555
|
shell_y: swt_widget&.getBounds&.y,
|
625
556
|
open_file_paths1: open_file_paths1,
|
626
557
|
open_file_paths2: open_file_paths2,
|
627
|
-
ignore_paths:
|
558
|
+
ignore_paths: project_dir.ignore_paths
|
628
559
|
}
|
629
560
|
config_yaml = YAML.dump(@config)
|
630
561
|
::File.write(@config_file_path, config_yaml) unless config_yaml.to_s.empty?
|
631
562
|
rescue => e
|
632
563
|
puts e.full_message
|
633
564
|
end
|
634
|
-
|
565
|
+
|
635
566
|
def close_tab_folder
|
636
567
|
if @tab_folder2 && !selected_tab_item
|
637
|
-
if @
|
568
|
+
if @current_tab_folder == @tab_folder2
|
638
569
|
@tab_folder2.swt_widget.dispose
|
639
|
-
@
|
570
|
+
@current_tab_folder = @tab_folder1
|
640
571
|
else
|
641
572
|
@tab_folder1.swt_widget.dispose
|
642
|
-
@
|
573
|
+
@current_tab_folder = @tab_folder1 = @tab_folder2
|
643
574
|
end
|
644
|
-
@tab_folder2 = nil
|
645
|
-
|
646
|
-
@
|
647
|
-
@
|
648
|
-
|
649
|
-
|
575
|
+
@tab_folder2 = nil
|
576
|
+
|
577
|
+
@current_tab_item = @current_tab_folder.swt_widget.getData('selected_tab_item')
|
578
|
+
@current_text_editor = @current_tab_item.swt_tab_item.getData('text_editor')
|
579
|
+
project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
|
580
|
+
|
650
581
|
body_root.pack_same_size
|
651
582
|
end
|
652
583
|
end
|
653
|
-
|
584
|
+
|
654
585
|
def selected_tab_item
|
655
|
-
@
|
586
|
+
@current_tab_folder.swt_widget.getItems.detect { |ti| ti.getData('file_path') == project_dir.selected_child&.path }
|
656
587
|
end
|
657
588
|
|
658
589
|
def other_tab_items
|
659
|
-
@
|
590
|
+
@current_tab_folder.swt_widget.getItems.reject { |ti| ti.getData('file_path') == project_dir.selected_child&.path }
|
660
591
|
end
|
661
592
|
|
662
593
|
def extract_tree_item_path(tree_item)
|
@@ -664,14 +595,14 @@ module Glimmer
|
|
664
595
|
if tree_item.getParentItem
|
665
596
|
::File.join(extract_tree_item_path(tree_item.getParentItem), tree_item.getText)
|
666
597
|
else
|
667
|
-
|
598
|
+
project_dir.path
|
668
599
|
end
|
669
600
|
end
|
670
|
-
|
601
|
+
|
671
602
|
def select_tree_item
|
672
|
-
return unless
|
673
|
-
tree_items_to_select = @
|
674
|
-
@
|
603
|
+
return unless project_dir.selected_child&.name
|
604
|
+
tree_items_to_select = @file_tree.depth_first_search { |ti| ti.getData.path == project_dir.selected_child.path }
|
605
|
+
@file_tree.swt_widget.setSelection(tree_items_to_select)
|
675
606
|
end
|
676
607
|
|
677
608
|
def delete_tree_item(tree_item)
|
@@ -679,27 +610,27 @@ module Glimmer
|
|
679
610
|
file = tree_item.getData
|
680
611
|
parent_path = ::File.dirname(file.path)
|
681
612
|
file.delete! # TODO consider supporting command undo/redo
|
682
|
-
|
683
|
-
parent_tree_item = @
|
684
|
-
@
|
613
|
+
project_dir.refresh(async: false)
|
614
|
+
parent_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == parent_path}.first
|
615
|
+
@file_tree.swt_widget.showItem(parent_tree_item)
|
685
616
|
parent_tree_item.setExpanded(true)
|
686
|
-
# TODO close text editor tab
|
617
|
+
# TODO close text editor tab
|
687
618
|
# if file.is_a?(::File)
|
688
619
|
# close tab
|
689
620
|
# end
|
690
621
|
rescue => e
|
691
|
-
puts e.full_message
|
622
|
+
puts e.full_message
|
692
623
|
end
|
693
|
-
|
624
|
+
|
694
625
|
def rename_selected_tree_item
|
695
|
-
|
696
|
-
tree_item = @
|
626
|
+
project_dir.pause_refresh
|
627
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
697
628
|
rename_tree_item(tree_item)
|
698
629
|
end
|
699
|
-
|
630
|
+
|
700
631
|
def add_new_directory_to_selected_tree_item
|
701
|
-
|
702
|
-
tree_item = @
|
632
|
+
project_dir.pause_refresh
|
633
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
703
634
|
directory_path = extract_tree_item_path(tree_item)
|
704
635
|
return if directory_path.nil?
|
705
636
|
if !::Dir.exist?(directory_path)
|
@@ -708,15 +639,15 @@ module Glimmer
|
|
708
639
|
end
|
709
640
|
new_directory_path = ::File.expand_path(::File.join(directory_path, 'new_directory'))
|
710
641
|
FileUtils.mkdir_p(new_directory_path)
|
711
|
-
|
712
|
-
new_tree_item = @
|
713
|
-
@
|
642
|
+
project_dir.refresh(async: false, force: true)
|
643
|
+
new_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == new_directory_path}.first
|
644
|
+
@file_tree.swt_widget.showItem(new_tree_item)
|
714
645
|
rename_tree_item(new_tree_item, true)
|
715
646
|
end
|
716
|
-
|
647
|
+
|
717
648
|
def add_new_file_to_selected_tree_item
|
718
|
-
|
719
|
-
tree_item = @
|
649
|
+
project_dir.pause_refresh
|
650
|
+
tree_item = @file_tree.swt_widget.getSelection.first
|
720
651
|
directory_path = extract_tree_item_path(tree_item)
|
721
652
|
if !::Dir.exist?(directory_path)
|
722
653
|
tree_item = tree_item.getParentItem
|
@@ -725,24 +656,24 @@ module Glimmer
|
|
725
656
|
new_file_path = ::File.expand_path(::File.join(directory_path, 'new_file'))
|
726
657
|
FileUtils.touch(new_file_path)
|
727
658
|
# TODO look into refreshing only the parent directory to avoid slowdown
|
728
|
-
|
729
|
-
new_tree_item = @
|
730
|
-
@
|
659
|
+
project_dir.refresh(async: false, force: true)
|
660
|
+
new_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == new_file_path}.first
|
661
|
+
@file_tree.swt_widget.showItem(new_tree_item)
|
731
662
|
rename_tree_item(new_tree_item, true)
|
732
663
|
end
|
733
|
-
|
664
|
+
|
734
665
|
def rename_tree_item(tree_item, open_afterwards = false)
|
735
|
-
@
|
666
|
+
@file_tree.edit_tree_item(
|
736
667
|
tree_item,
|
737
668
|
after_write: -> (edited_tree_item) {
|
738
669
|
file = edited_tree_item.getData
|
739
670
|
file_path = file.path
|
740
671
|
# TODO rename file in tab title
|
741
|
-
|
742
|
-
|
672
|
+
project_dir.selected_child_path = file_path if open_afterwards
|
673
|
+
project_dir.resume_refresh
|
743
674
|
},
|
744
675
|
after_cancel: -> {
|
745
|
-
|
676
|
+
project_dir.resume_refresh
|
746
677
|
}
|
747
678
|
)
|
748
679
|
end
|
@@ -752,5 +683,154 @@ module Glimmer
|
|
752
683
|
rescue => e
|
753
684
|
nil
|
754
685
|
end
|
686
|
+
|
687
|
+
def open_project
|
688
|
+
selected_directory = directory_dialog.open
|
689
|
+
@progress_bar_shell = shell(body_root) {
|
690
|
+
text 'Opening Project'
|
691
|
+
fill_layout(:vertical) {
|
692
|
+
margin_width 15
|
693
|
+
margin_height 15
|
694
|
+
spacing 5
|
695
|
+
}
|
696
|
+
label(:center) {
|
697
|
+
text "Opening Project: #{::File.basename(selected_directory)}"
|
698
|
+
font height: 20
|
699
|
+
}
|
700
|
+
# @progress_bar = progress_bar(:horizontal, :indeterminate)
|
701
|
+
}
|
702
|
+
Thread.new {
|
703
|
+
async_exec {
|
704
|
+
@progress_bar_shell.open
|
705
|
+
}
|
706
|
+
}
|
707
|
+
Thread.new {
|
708
|
+
async_exec {
|
709
|
+
gladiator(project_dir_path: selected_directory) {
|
710
|
+
on_swt_show {
|
711
|
+
@progress_bar_shell.close
|
712
|
+
}
|
713
|
+
}.open if selected_directory
|
714
|
+
}
|
715
|
+
}
|
716
|
+
end
|
717
|
+
|
718
|
+
def handle_display_shortcut(key_event)
|
719
|
+
if key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'f'
|
720
|
+
if current_text_editor&.text_widget&.getSelectionText && current_text_editor&.text_widget&.getSelectionText&.size.to_i > 0
|
721
|
+
find_text.swt_widget.setText current_text_editor.text_widget.getSelectionText
|
722
|
+
end
|
723
|
+
find_text.swt_widget.selectAll
|
724
|
+
find_text.swt_widget.setFocus
|
725
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'c'
|
726
|
+
Clipboard.copy(project_dir.selected_child.path)
|
727
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'g'
|
728
|
+
project_dir.selected_child.find_previous
|
729
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'p'
|
730
|
+
open_project
|
731
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 's'
|
732
|
+
project_dir.selected_child_path = '' # scratchpad
|
733
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'w'
|
734
|
+
current_tab_folder.swt_widget.getItems.each do |tab_item|
|
735
|
+
project_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
736
|
+
tab_item.getData('proxy')&.dispose
|
737
|
+
end
|
738
|
+
close_tab_folder
|
739
|
+
self.current_tab_item = self.current_text_editor = project_dir.selected_child = nil
|
740
|
+
filter_text.swt_widget.selectAll
|
741
|
+
filter_text.swt_widget.setFocus
|
742
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :alt) && extract_char(key_event) == 'w'
|
743
|
+
other_tab_items.each do |tab_item|
|
744
|
+
project_dir.selected_child_path_history.delete(tab_item.getData('file_path'))
|
745
|
+
tab_item.getData('proxy')&.dispose
|
746
|
+
end
|
747
|
+
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'w'
|
748
|
+
if selected_tab_item
|
749
|
+
project_dir.selected_child_path_history.delete(project_dir.selected_child.path)
|
750
|
+
selected_tab_item.getData('proxy')&.dispose
|
751
|
+
close_tab_folder
|
752
|
+
if selected_tab_item.nil?
|
753
|
+
self.current_tab_item = self.current_text_editor = project_dir.selected_child = nil
|
754
|
+
filter_text.swt_widget.selectAll
|
755
|
+
filter_text.swt_widget.setFocus
|
756
|
+
else
|
757
|
+
current_text_editor&.text_widget&.setFocus
|
758
|
+
end
|
759
|
+
end
|
760
|
+
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)
|
762
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
|
763
|
+
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
|
+
current_text_editor&.text_widget&.setFocus
|
765
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == '['
|
766
|
+
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
|
767
|
+
current_text_editor&.text_widget&.setFocus
|
768
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == ']'
|
769
|
+
if tab_folder2
|
770
|
+
if current_tab_folder == tab_folder1
|
771
|
+
self.current_tab_folder = tab_folder2
|
772
|
+
else
|
773
|
+
self.current_tab_folder = tab_folder1
|
774
|
+
end
|
775
|
+
self.current_tab_item = current_tab_folder.swt_widget.getData('selected_tab_item')
|
776
|
+
self.project_dir.selected_child = current_tab_item&.swt_tab_item&.getData('file')
|
777
|
+
current_tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
778
|
+
end
|
779
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :ctrl) && extract_char(key_event) == '['
|
780
|
+
if tab_folder2
|
781
|
+
if current_tab_folder == tab_folder2
|
782
|
+
self.current_tab_folder = tab_folder1
|
783
|
+
else
|
784
|
+
self.current_tab_folder = tab_folder2
|
785
|
+
end
|
786
|
+
self.current_tab_item = current_tab_folder.swt_widget.getData('selected_tab_item')
|
787
|
+
self.project_dir.selected_child = current_tab_item&.swt_tab_item&.getData('file')
|
788
|
+
current_tab_item&.swt_tab_item&.getData('text_editor')&.text_widget&.setFocus
|
789
|
+
end
|
790
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '1'
|
791
|
+
current_tab_folder.swt_widget.setSelection(0) if current_tab_folder.swt_widget.getItemCount >= 1
|
792
|
+
current_text_editor&.text_widget&.setFocus
|
793
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '2'
|
794
|
+
current_tab_folder.swt_widget.setSelection(1) if current_tab_folder.swt_widget.getItemCount >= 2
|
795
|
+
current_text_editor&.text_widget&.setFocus
|
796
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '3'
|
797
|
+
current_tab_folder.swt_widget.setSelection(2) if current_tab_folder.swt_widget.getItemCount >= 3
|
798
|
+
current_text_editor&.text_widget&.setFocus
|
799
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '4'
|
800
|
+
current_tab_folder.swt_widget.setSelection(3) if current_tab_folder.swt_widget.getItemCount >= 4
|
801
|
+
current_text_editor&.text_widget&.setFocus
|
802
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '5'
|
803
|
+
current_tab_folder.swt_widget.setSelection(4) if current_tab_folder.swt_widget.getItemCount >= 5
|
804
|
+
current_text_editor&.text_widget&.setFocus
|
805
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '6'
|
806
|
+
current_tab_folder.swt_widget.setSelection(5) if current_tab_folder.swt_widget.getItemCount >= 6
|
807
|
+
current_text_editor&.text_widget&.setFocus
|
808
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '7'
|
809
|
+
current_tab_folder.swt_widget.setSelection(6) if current_tab_folder.swt_widget.getItemCount >= 7
|
810
|
+
current_text_editor&.text_widget&.setFocus
|
811
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '8'
|
812
|
+
current_tab_folder.swt_widget.setSelection(7) if current_tab_folder.swt_widget.getItemCount >= 8
|
813
|
+
current_text_editor&.text_widget&.setFocus
|
814
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == '9'
|
815
|
+
current_tab_folder.swt_widget.setSelection(current_tab_folder.swt_widget.getItemCount - 1) if current_tab_folder.swt_widget.getItemCount > 0
|
816
|
+
current_text_editor&.text_widget&.setFocus
|
817
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'g'
|
818
|
+
project_dir.selected_child.find_next
|
819
|
+
elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
|
820
|
+
line_number_text.swt_widget.selectAll
|
821
|
+
line_number_text.swt_widget.setFocus
|
822
|
+
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'r'
|
823
|
+
filter_text.swt_widget.selectAll
|
824
|
+
filter_text.swt_widget.setFocus
|
825
|
+
elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 't'
|
826
|
+
select_tree_item unless rename_in_progress
|
827
|
+
file_tree.swt_widget.setFocus
|
828
|
+
elsif key_event.keyCode == swt(:esc)
|
829
|
+
if current_text_editor
|
830
|
+
project_dir.selected_child_path = current_text_editor.file.path
|
831
|
+
current_text_editor&.text_widget&.setFocus
|
832
|
+
end
|
833
|
+
end
|
834
|
+
end
|
755
835
|
end
|
756
|
-
end
|
836
|
+
end
|