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