glimmer-cs-gladiator 0.5.4 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -219,7 +219,7 @@ module Glimmer
219
219
  def eql?(other)
220
220
  self.path.eql?(other&.path)
221
221
  end
222
-
222
+
223
223
  def hash
224
224
  self.path.hash
225
225
  end
@@ -3,7 +3,7 @@ module Glimmer
3
3
  class File
4
4
  include Glimmer
5
5
 
6
- attr_accessor :line_numbers_content, :selection, :line_number, :find_text, :replace_text, :top_pixel, :display_path, :case_sensitive
6
+ attr_accessor :line_numbers_content, :line_number, :find_text, :replace_text, :top_pixel, :display_path, :case_sensitive, :caret_position, :selection_count, :last_caret_position, :last_selection_count, :line_position
7
7
  attr_reader :name, :path, :project_dir
8
8
 
9
9
  def initialize(path='', project_dir=nil)
@@ -13,9 +13,11 @@ module Glimmer
13
13
  @name = path.empty? ? 'Scratchpad' : ::File.basename(path)
14
14
  self.path = ::File.expand_path(path) unless path.empty?
15
15
  @top_pixel = 0
16
+ @caret_position = 0
16
17
  @selection_count = 0
17
- @selection = Point.new(0, 0 + @selection_count)
18
+ @last_selection_count = 0
18
19
  @line_number = 1
20
+ @init = nil
19
21
  end
20
22
 
21
23
  def init_content
@@ -24,29 +26,25 @@ module Glimmer
24
26
  begin
25
27
  # test read dirty content
26
28
  observe(self, :dirty_content) do
27
- lines_text_size = lines.size.to_s.size
29
+ line_count = lines.empty? ? 1 : lines.size
30
+ lines_text_size = [line_count.to_s.size, 4].max
28
31
  old_top_pixel = top_pixel
29
- self.line_numbers_content = lines.size.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n")
32
+ self.line_numbers_content = line_count.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n")
30
33
  self.top_pixel = old_top_pixel
31
34
  end
32
35
  the_dirty_content = read_dirty_content
33
36
  the_dirty_content.split("\n") # test that it is not a binary file (crashes to rescue block otherwise)
34
37
  self.dirty_content = the_dirty_content
35
- observe(self, :selection) do
36
- new_line_number = line_index_for_caret_position(caret_position) + 1
37
- async_exec {
38
- self.line_number = new_line_number
39
- }
38
+ observe(self, :caret_position) do |new_caret_position|
39
+ update_line_number_from_caret_position(new_caret_position)
40
40
  end
41
- observe(self, :line_number) do
42
- if line_number
43
- line_index = line_number - 1
44
- new_caret_position = caret_position_for_line_index(line_index)
45
- current_caret_position = self.caret_position
46
- async_exec {
47
- self.caret_position = new_caret_position unless current_caret_position && line_index_for_caret_position(new_caret_position) == line_index_for_caret_position(current_caret_position)
48
- }
49
- end
41
+ observe(self, :line_number) do |new_line_number|
42
+ line_index = line_number - 1
43
+ new_caret_position = caret_position_for_line_index(line_index)
44
+ current_caret_position = caret_position
45
+ line_index_for_new_caret_position = line_index_for_caret_position(new_caret_position)
46
+ line_index_for_current_caret_position = line_index_for_caret_position(current_caret_position)
47
+ self.caret_position = new_caret_position unless (current_caret_position && line_index_for_new_caret_position == line_index_for_current_caret_position)
50
48
  end
51
49
  rescue # in case of a binary file
52
50
  stop_filewatcher
@@ -54,6 +52,16 @@ module Glimmer
54
52
  end
55
53
  end
56
54
 
55
+ def update_line_number_from_caret_position(new_caret_position)
56
+ new_line_number = line_index_for_caret_position(caret_position) + 1
57
+ current_line_number = line_number
58
+ unless (current_line_number && current_line_number == new_line_number)
59
+ self.line_number = new_line_number
60
+ # TODO check if the following line is needed
61
+ self.line_position = caret_position - caret_position_for_line_index(line_number - 1) + 1
62
+ end
63
+ end
64
+
57
65
  def path=(the_path)
58
66
  @path = the_path
59
67
  generate_display_path
@@ -63,6 +71,15 @@ module Glimmer
63
71
  return if @path.empty?
64
72
  @display_path = @path.sub(project_dir.path, '').sub(/^\//, '')
65
73
  end
74
+
75
+ def name=(the_name)
76
+ new_path = path.sub(/#{Regexp.escape(@name)}$/, the_name) unless scratchpad?
77
+ @name = the_name
78
+ if !scratchpad? && ::File.exist?(path)
79
+ FileUtils.mv(path, new_path)
80
+ self.path = new_path
81
+ end
82
+ end
66
83
 
67
84
  def scratchpad?
68
85
  path.to_s.empty?
@@ -80,48 +97,18 @@ module Glimmer
80
97
  send("#{property}=", value)
81
98
  end
82
99
  end
83
-
84
- # to use for widget data-binding
85
- def content=(value)
86
- value = value.gsub("\t", ' ')
87
- if dirty_content != value
88
- # TODO fix this command recording hack by truly recording every text change as a proper command (add process_key command, paste command, cut command, etc...)
89
- Command.do(self) # record a native (OS-widget) operation
90
- self.dirty_content = value
91
- end
92
- end
93
-
94
- def content
95
- dirty_content
96
- end
97
-
100
+
98
101
  def caret_position=(value)
99
- old_top_pixel = top_pixel
100
- self.selection = Point.new(value, value + selection_count.to_i)
101
- self.top_pixel = old_top_pixel
102
- end
103
-
104
- def caret_position
105
- selection.x
106
- end
107
-
108
- def selection_count
109
- selection.y - selection.x
102
+ @last_caret_position = @caret_position
103
+ @caret_position = value
110
104
  end
111
105
 
112
106
  def selection_count=(value)
113
- self.selection = Point.new(caret_position, caret_position + value.to_i)
107
+ #@last_selection_count = @selection_count
108
+ @selection_count = value
109
+ @last_selection_count = @selection_count
114
110
  end
115
111
 
116
- def name=(the_name)
117
- new_path = path.sub(/#{Regexp.escape(@name)}$/, the_name) unless scratchpad?
118
- @name = the_name
119
- if !scratchpad? && ::File.exist?(path)
120
- FileUtils.mv(path, new_path)
121
- self.path = new_path
122
- end
123
- end
124
-
125
112
  def dirty_content
126
113
  init_content
127
114
  @dirty_content
@@ -132,14 +119,50 @@ module Glimmer
132
119
  @dirty_content = the_content
133
120
  old_caret_position = caret_position
134
121
  old_top_pixel = top_pixel
122
+
135
123
  notify_observers(:content)
136
124
  if @formatting_dirty_content_for_writing
137
125
  self.caret_position = old_caret_position
138
- self.selection_count = 0
139
126
  self.top_pixel = old_top_pixel
140
127
  end
141
128
  end
142
129
 
130
+ def content
131
+ dirty_content
132
+ end
133
+
134
+ # to use for widget data-binding
135
+ def content=(value)
136
+ value = value.gsub("\t", ' ')
137
+ if dirty_content != value
138
+ Command.do(self, :change_content!, value)
139
+ end
140
+ end
141
+
142
+ def change_content!(value)
143
+ self.dirty_content = value
144
+ update_line_number_from_caret_position(caret_position)
145
+ end
146
+
147
+ def start_command
148
+ @commmand_in_progress = true
149
+ end
150
+
151
+ def end_command
152
+ @commmand_in_progress = false
153
+ end
154
+
155
+ def command_in_progress?
156
+ @commmand_in_progress
157
+ end
158
+
159
+ def close
160
+ stop_filewatcher
161
+ remove_all_observers
162
+ initialize(path, project_dir)
163
+ Command.clear(self)
164
+ end
165
+
143
166
  def read_dirty_content
144
167
  path.empty? ? '' : ::File.read(path)
145
168
  end
@@ -176,7 +199,9 @@ module Glimmer
176
199
  end
177
200
 
178
201
  def format_dirty_content_for_writing!
179
- new_dirty_content = dirty_content.split("\n").map {|line| line.strip.empty? ? line : line.rstrip }.join("\n")
202
+ return if @commmand_in_progress
203
+ # TODO f ix c ar e t pos it ion after formatting dirty content (diff?)
204
+ new_dirty_content = dirty_content.to_s.split("\n").map {|line| line.strip.empty? ? line : line.rstrip }.join("\n")
180
205
  new_dirty_content = "#{new_dirty_content.gsub("\r\n", "\n").gsub("\r", "\n").sub(/\n+\z/, '')}\n"
181
206
  if new_dirty_content != self.dirty_content
182
207
  @formatting_dirty_content_for_writing = true
@@ -494,13 +519,18 @@ module Glimmer
494
519
  write_dirty_content
495
520
  load path
496
521
  end
497
- rescue SyntaxError, StandardError => e
522
+ rescue LoadError, SyntaxError, StandardError => e
523
+ # TODO consider showing a message dialog or error message console in the future
498
524
  puts e.full_message
499
525
  end
500
526
  end
501
527
 
502
528
  def lines
503
- dirty_content.split("\n")
529
+ need_padding = dirty_content.to_s.end_with?("\n")
530
+ splittable_content = need_padding ? "#{dirty_content} " : dirty_content
531
+ the_lines = splittable_content.split("\n")
532
+ the_lines[-1] = the_lines[-1].strip if need_padding
533
+ the_lines
504
534
  end
505
535
 
506
536
  def line_for_caret_position(caret_position)
@@ -510,7 +540,7 @@ module Glimmer
510
540
  def line_index_for_caret_position(caret_position)
511
541
  dirty_content[0...caret_position.to_i].count("\n")
512
542
  end
513
-
543
+
514
544
  def caret_position_for_line_index(line_index)
515
545
  cp = lines[0...line_index].join("\n").size
516
546
  cp += 1 if line_index > 0
@@ -18,10 +18,14 @@ module Glimmer
18
18
  APP_ROOT = ::File.expand_path('../../../..', __FILE__)
19
19
  # TODO make sure COMMAND_KEY doesn't clash on Linux/Windows for CMD+CTRL shortcuts
20
20
  COMMAND_KEY = OS.mac? ? :command : :ctrl
21
+ VERSION = ::File.read(::File.join(APP_ROOT, 'VERSION')).to_s.strip
22
+ LICENSE = ::File.read(::File.join(APP_ROOT, 'LICENSE.txt')).to_s.strip
23
+ ICON = ::File.expand_path(::File.join(APP_ROOT, 'images', 'glimmer-cs-gladiator-logo.png'))
21
24
 
22
25
  class << self
23
26
  attr_accessor :drag_and_drop
24
27
  attr_accessor :drag
28
+ attr_accessor :startup
25
29
  end
26
30
 
27
31
  ## Add options like the following to configure CustomShell by outside consumers
@@ -62,20 +66,29 @@ module Glimmer
62
66
  before_body {
63
67
  # TODO consider doing loading project files after displaying the GUI instead of holding it up before
64
68
  project_dir #pre-initialize directory
65
- at_exit do
69
+ TOPLEVEL_BINDING.receiver.send(:at_exit) do
66
70
  project_dir.selected_child&.write_raw_dirty_content
67
71
  end
68
72
  Display.setAppName('Gladiator')
69
73
  # make sure the display events are only hooked once if multiple gladiators are created
70
74
  unless defined?(@@display)
71
75
  @@display = display {
76
+ # TODO look into why a weird java dialog comes up on about (maybe a non-issue once packaged)
77
+ on_about {
78
+ display_about_dialog
79
+ }
72
80
  on_swt_keydown { |key_event|
73
81
  focused_gladiator = display.focus_control.shell&.get_data('custom_shell')
74
82
  focused_gladiator.handle_display_shortcut(key_event) if !focused_gladiator.nil? && key_event.widget.shell == focused_gladiator&.swt_widget
75
83
  }
84
+ on_swt_Close {
85
+ save_config
86
+ project_dir.selected_child&.write_dirty_content
87
+ }
76
88
  }
77
89
  end
78
90
 
91
+ @default_foreground = :dark_blue
79
92
  @split_orientation = swt(:horizontal)
80
93
  @config_file_path = ::File.join(project_dir.path, '.gladiator')
81
94
  @config = {}
@@ -87,42 +100,52 @@ module Glimmer
87
100
  #
88
101
  after_body {
89
102
  observe(project_dir, 'children') do
90
- select_tree_item unless @rename_in_progress
103
+ select_tree_item unless @rename_in_progress || Gladiator.startup
91
104
  end
92
105
  observe(project_dir, 'selected_child') do |selected_file|
93
106
  if selected_file
94
107
  if Gladiator.drag && !@tab_folder2
95
108
  @tab_folder1 = @current_tab_folder
109
+ async_exec { body_root.pack_same_size}
96
110
  @tab_folder_sash_form.content {
97
111
  @current_tab_folder = @tab_folder2 = tab_folder
98
112
  @current_tab_folder.swt_widget.setData('proxy', @current_tab_folder)
99
113
  }
100
114
  end
101
- select_tree_item unless @rename_in_progress
115
+ select_tree_item unless @rename_in_progress || Gladiator.startup
102
116
  found_tab_item = selected_tab_item
103
117
  if found_tab_item
104
118
  @current_tab_folder.swt_widget.setSelection(found_tab_item)
105
119
  @current_tab_item = found_tab_item.getData('proxy')
106
- @current_text_editor = found_tab_item.getData('text_editor')
120
+ @current_text_editor = found_tab_item.getData('text_editor') unless found_tab_item.getData('text_editor').nil?
107
121
  @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
108
122
  elsif selected_file
109
123
  @current_tab_folder.content {
110
124
  @current_tab_item = tab_item { |the_tab_item|
111
125
  text selected_file.name
112
- fill_layout :horizontal
113
- @current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
114
- @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
115
- @current_text_editor.text_proxy.content {
116
- on_focus_gained {
117
- tab_folder = the_text_editor.swt_widget.getParent.getParent
118
- @current_tab_folder = tab_folder.getData('proxy')
119
- @current_tab_item = the_tab_item
120
- @current_text_editor = the_text_editor
121
- @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
122
- @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
123
- project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
126
+ fill_layout(:horizontal) {
127
+ margin_width 0
128
+ margin_height 0
129
+ }
130
+ tab_folder = nil
131
+ the_text_editor = nil
132
+ the_tab_item.content {
133
+ @current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
134
+ @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
135
+ the_tab_item.swt_tab_item.setData('text_editor', @current_text_editor)
136
+ @current_text_editor.text_proxy.content {
137
+ on_focus_gained {
138
+ tab_folder = the_text_editor.swt_widget.getParent.getParent
139
+ @current_tab_folder = tab_folder.getData('proxy')
140
+ @current_tab_item = the_tab_item
141
+ @current_text_editor = the_text_editor
142
+ @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
143
+ @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
144
+ project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
145
+ }
124
146
  }
125
147
  }
148
+
126
149
  on_swt_show {
127
150
  @current_tab_item = the_tab_item
128
151
  @current_text_editor = the_text_editor
@@ -134,14 +157,20 @@ module Glimmer
134
157
  @current_text_editor&.text_widget&.setFocus
135
158
  }
136
159
  }
160
+ on_widget_disposed {
161
+ project_dir.selected_child&.write_dirty_content
162
+ tab_item_file = the_tab_item.swt_tab_item.get_data('file')
163
+ tab_item_file.close unless [@tab_folder1, @tab_folder2].compact.map(&:items).flatten(1).detect {|ti| ti.get_data('file') == tab_item_file}
164
+ }
137
165
  }
138
166
  @current_tab_item.swt_tab_item.setData('file_path', selected_file.path)
139
167
  @current_tab_item.swt_tab_item.setData('file', selected_file)
140
- @current_tab_item.swt_tab_item.setData('text_editor', @current_text_editor)
141
168
  @current_tab_item.swt_tab_item.setData('proxy', @current_tab_item)
142
169
  }
143
170
  @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
171
+
144
172
  body_root.pack_same_size
173
+ async_exec { body_root.pack_same_size}
145
174
  end
146
175
  @current_text_editor&.text_widget&.setFocus
147
176
  end
@@ -163,17 +192,31 @@ module Glimmer
163
192
  #
164
193
  body {
165
194
  shell {
195
+ grid_layout(2, false)
166
196
  text "Gladiator - #{::File.expand_path(project_dir.path)}"
167
197
  minimum_size 520, 250
168
198
  size 1440, 900
169
- grid_layout(2, false)
199
+ image ICON
200
+
170
201
  on_swt_show {
171
202
  swt_widget.setSize(@config[:shell_width], @config[:shell_height]) if @config[:shell_width] && @config[:shell_height]
172
203
  swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
173
204
  @loaded_config = true
174
205
  }
175
- on_swt_close {
206
+
207
+ on_shell_closed {
208
+ save_config
176
209
  project_dir.selected_child&.write_dirty_content
210
+ if @tab_folder2
211
+ current_tab_folder.swt_widget.getItems.each do |tab_item|
212
+ tab_item.getData('proxy')&.dispose
213
+ end
214
+ close_tab_folder
215
+ end
216
+ current_tab_folder.swt_widget.getItems.each do |tab_item|
217
+ tab_item.getData('proxy')&.dispose
218
+ end
219
+ body_root.close unless current_tab_folder.swt_widget.getItems.empty?
177
220
  }
178
221
  on_widget_disposed {
179
222
  project_dir.selected_child&.write_dirty_content
@@ -185,9 +228,17 @@ module Glimmer
185
228
  save_config
186
229
  }
187
230
  on_shell_deactivated {
188
- @current_text_editor&.file&.write_dirty_content
231
+ project_dir.selected_child&.write_dirty_content
189
232
  }
190
233
 
234
+ if OS.mac?
235
+ display.swt_display.system_menu.items.find {|mi| mi.id == swt(:id_quit)}.add_selection_listener {
236
+ save_config
237
+ project_dir.selected_child&.write_dirty_content
238
+ exit(0)
239
+ }
240
+ end
241
+
191
242
  menu_bar {
192
243
  menu {
193
244
  text '&File'
@@ -216,14 +267,14 @@ module Glimmer
216
267
  text '&Split'
217
268
  menu_item(:radio) {
218
269
  text '&Horizontal'
219
- selection bind(self, :split_orientation,
220
- on_read: ->(o) { split_pane? && o == swt(:horizontal)},
270
+ selection bind(self, :split_orientation,
271
+ on_read: ->(o) { split_pane? && o == swt(:horizontal) },
221
272
  on_write: ->(b) { b ? swt(:horizontal) : swt(:vertical) })
222
273
  }
223
274
  menu_item(:radio) {
224
275
  text '&Vertical'
225
- selection bind(self, :split_orientation,
226
- on_read: ->(o) { split_pane? && o == swt(:vertical)},
276
+ selection bind(self, :split_orientation,
277
+ on_read: ->(o) { split_pane? && o == swt(:vertical) },
227
278
  on_write: ->(b) { b ? swt(:vertical) : swt(:horizontal) })
228
279
  }
229
280
  }
@@ -250,127 +301,227 @@ module Glimmer
250
301
  }
251
302
  }
252
303
  }
304
+ menu {
305
+ text '&Help'
306
+ menu_item {
307
+ text '&About'
308
+ on_widget_selected {
309
+ display_about_dialog
310
+ }
311
+ }
312
+ }
253
313
  }
254
314
 
255
315
  composite {
256
- grid_layout 1, false
316
+ grid_layout(1, false) {
317
+ margin_width 0
318
+ margin_height 0
319
+ }
320
+
257
321
  layout_data(:fill, :fill, false, true) {
258
322
  width_hint 300
259
323
  }
260
- @filter_text = text {
261
- layout_data :fill, :center, true, false
262
- text bind(project_dir, 'filter')
263
- on_key_pressed { |key_event|
264
- if key_event.keyCode == swt(:tab) ||
265
- key_event.keyCode == swt(:cr) ||
266
- key_event.keyCode == swt(:arrow_up) ||
267
- key_event.keyCode == swt(:arrow_down)
268
- @list.swt_widget.select(0) if @list.swt_widget.getSelectionIndex() == -1
269
- @list.swt_widget.setFocus
270
- end
271
- }
272
- }
273
- sash_form(:vertical) {
324
+ @side_bar_sash_form = sash_form(:vertical) {
274
325
  layout_data(:fill, :fill, true, true)
275
326
  sash_width 4
276
- @list = list(:border, :h_scroll, :v_scroll) {
277
- #visible bind(self, 'project_dir.filter') {|f| !!f}
278
- selection bind(project_dir, :filtered_path)
279
- on_mouse_up {
280
- project_dir.selected_child_path = @list.swt_widget.getSelection.first
281
- }
282
- on_key_pressed { |key_event|
283
- if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
284
- project_dir.selected_child_path = @list.swt_widget.getSelection.first
285
- @current_text_editor&.text_widget&.setFocus
286
- end
327
+
328
+ resize_expand_items = lambda { |event=nil|
329
+ @file_lookup_expand_item&.swt_expand_item&.height = @file_lookup_expand_bar.size.y - @file_lookup_expand_item.swt_expand_item.header_height
330
+ @file_explorer_expand_item&.swt_expand_item&.height = @file_explorer_expand_bar.size.y - @file_explorer_expand_item.swt_expand_item.header_height
331
+ }
332
+
333
+ @file_lookup_expand_bar = expand_bar {
334
+ layout_data :fill, :fill, true, true
335
+ font height: 17, style: :bold
336
+ foreground @default_foreground
337
+
338
+ on_swt_show {
339
+ @file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_bar.size.y - @file_lookup_expand_item.swt_expand_item.header_height
287
340
  }
288
- drag_source(DND::DROP_COPY) {
289
- transfer [TextTransfer.getInstance].to_java(Transfer)
290
- on_drag_set_data { |event|
291
- Gladiator.drag = true
292
- list = event.widget.getControl
293
- event.data = list.getSelection.first
341
+
342
+ on_swt_Resize(&resize_expand_items)
343
+
344
+ @file_lookup_expand_item = expand_item {
345
+ grid_layout {
346
+ margin_width 0
347
+ margin_height 0
294
348
  }
349
+ text 'File Lookup'
350
+ height display.bounds.height
351
+
352
+ @filter_text = text {
353
+ layout_data :fill, :center, true, false
354
+ text bind(project_dir, 'filter')
355
+ on_key_pressed { |key_event|
356
+ if key_event.keyCode == swt(:tab) ||
357
+ key_event.keyCode == swt(:cr) ||
358
+ key_event.keyCode == swt(:arrow_up) ||
359
+ key_event.keyCode == swt(:arrow_down)
360
+ @file_lookup_list.swt_widget.select(0) if @file_lookup_list.swt_widget.getSelectionIndex() == -1
361
+ @file_lookup_list.swt_widget.setFocus
362
+ end
363
+ }
364
+ }
365
+
366
+ @file_lookup_list = list(:border, :h_scroll, :v_scroll) {
367
+ layout_data :fill, :fill, true, true
368
+ #visible bind(self, 'project_dir.filter') {|f| !!f}
369
+ selection bind(project_dir, :filtered_path)
370
+ foreground @default_foreground
371
+ on_mouse_up {
372
+ project_dir.selected_child_path = @file_lookup_list.swt_widget.getSelection.first
373
+ }
374
+ on_key_pressed { |key_event|
375
+ if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
376
+ project_dir.selected_child_path = @file_lookup_list.swt_widget.getSelection.first
377
+ @current_text_editor&.text_widget&.setFocus
378
+ end
379
+ }
380
+ drag_source(DND::DROP_COPY) {
381
+ transfer [TextTransfer.getInstance].to_java(Transfer)
382
+ on_drag_set_data { |event|
383
+ Gladiator.drag = true
384
+ list = event.widget.getControl
385
+ event.data = list.getSelection.first
386
+ }
387
+ }
388
+ }
389
+ }
390
+
391
+ on_item_collapsed { |event|
392
+ if @file_explorer_expand_item.swt_expand_item.get_expanded
393
+ @file_lookup_expand_item_height = @file_lookup_expand_item.swt_expand_item.height
394
+ @file_lookup_expand_item.swt_expand_item.height = 0
395
+ @file_lookup_expand_bar_height = @file_lookup_expand_bar.swt_widget.size.y
396
+ @file_explorer_expand_bar_height = @file_explorer_expand_bar.swt_widget.size.y
397
+ @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]
398
+ end
399
+ }
400
+
401
+ on_item_expanded {
402
+ @file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_item_height if @file_lookup_expand_item_height
403
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
295
404
  }
405
+
296
406
  }
297
- @file_tree = tree(:virtual, :border, :h_scroll, :v_scroll) {
298
- #visible bind(self, 'project_dir.filter') {|f| !f}
299
- items bind(self, :project_dir), tree_properties(children: :children, text: :name)
300
- drag_source(DND::DROP_COPY) {
301
- transfer [TextTransfer.getInstance].to_java(Transfer)
302
- on_drag_set_data { |event|
303
- Gladiator.drag = true
304
- tree = event.widget.getControl
305
- tree_item = tree.getSelection.first
306
- event.data = tree_item.getData.path
307
- }
407
+
408
+ @file_explorer_expand_bar = expand_bar {
409
+ layout_data :fill, :fill, true, true
410
+ font height: 17, style: :bold
411
+ foreground @default_foreground
412
+
413
+ on_swt_show {
414
+ @file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_bar.size.y - @file_explorer_expand_item.swt_expand_item.header_height
308
415
  }
309
- menu {
310
- @open_menu_item = menu_item {
311
- text 'Open'
312
- on_widget_selected {
313
- project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
314
- }
416
+
417
+ on_swt_Resize(&resize_expand_items)
418
+
419
+ @file_explorer_expand_item = expand_item {
420
+ grid_layout {
421
+ margin_width 0
422
+ margin_height 0
315
423
  }
316
- menu_item(:separator)
317
- menu_item {
318
- text 'Delete'
319
- on_widget_selected {
320
- tree_item = @file_tree.swt_widget.getSelection.first
321
- delete_tree_item(tree_item)
424
+ text 'File Explorer'
425
+ height display.bounds.height
426
+
427
+ @file_tree = tree(:virtual, :border, :h_scroll, :v_scroll) {
428
+ layout_data :fill, :fill, true, true
429
+ #visible bind(self, 'project_dir.filter') {|f| !f}
430
+ items bind(self, :project_dir), tree_properties(children: :children, text: :name)
431
+ foreground @default_foreground
432
+ drag_source(DND::DROP_COPY) {
433
+ transfer [TextTransfer.getInstance].to_java(Transfer)
434
+ on_drag_set_data { |event|
435
+ Gladiator.drag = true
436
+ tree = event.widget.getControl
437
+ tree_item = tree.getSelection.first
438
+ event.data = tree_item.getData.path
439
+ }
322
440
  }
323
- }
324
- menu_item {
325
- text 'Refresh'
326
- on_widget_selected {
327
- project_dir.refresh
441
+ menu {
442
+ @open_menu_item = menu_item {
443
+ text 'Open'
444
+ on_widget_selected {
445
+ project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
446
+ }
447
+ }
448
+ menu_item(:separator)
449
+ menu_item {
450
+ text 'Delete'
451
+ on_widget_selected {
452
+ tree_item = @file_tree.swt_widget.getSelection.first
453
+ delete_tree_item(tree_item)
454
+ }
455
+ }
456
+ menu_item {
457
+ text 'Refresh'
458
+ on_widget_selected {
459
+ project_dir.refresh
460
+ }
461
+ }
462
+ menu_item {
463
+ text 'Rename'
464
+ on_widget_selected {
465
+ rename_selected_tree_item
466
+ }
467
+ }
468
+ menu_item {
469
+ text 'New Directory'
470
+ on_widget_selected {
471
+ add_new_directory_to_selected_tree_item
472
+ }
473
+ }
474
+ menu_item {
475
+ text 'New File'
476
+ on_widget_selected {
477
+ add_new_file_to_selected_tree_item
478
+ }
479
+ }
328
480
  }
329
- }
330
- menu_item {
331
- text 'Rename'
332
- on_widget_selected {
333
- rename_selected_tree_item
481
+ on_swt_menudetect { |event|
482
+ path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
483
+ @open_menu_item.swt_widget.setEnabled(!::Dir.exist?(path)) if path
334
484
  }
335
- }
336
- menu_item {
337
- text 'New Directory'
338
- on_widget_selected {
339
- add_new_directory_to_selected_tree_item
485
+ on_mouse_up {
486
+ if Gladiator.drag_and_drop
487
+ Gladiator.drag_and_drop = false
488
+ else
489
+ project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
490
+ @current_text_editor&.text_widget&.setFocus
491
+ end
340
492
  }
341
- }
342
- menu_item {
343
- text 'New File'
344
- on_widget_selected {
345
- add_new_file_to_selected_tree_item
493
+ on_key_pressed { |key_event|
494
+ if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
495
+ project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
496
+ @current_text_editor&.text_widget&.setFocus
497
+ end
498
+ }
499
+ on_paint_control {
500
+ root_item = @file_tree.swt_widget.getItems.first
501
+ if root_item && !root_item.getExpanded
502
+ root_item.setExpanded(true)
503
+ end
346
504
  }
347
505
  }
348
506
  }
349
- on_swt_menudetect { |event|
350
- path = extract_tree_item_path(@file_tree.swt_widget.getSelection.first)
351
- @open_menu_item.swt_widget.setEnabled(!::Dir.exist?(path)) if path
352
- }
353
- on_mouse_up {
354
- if Gladiator.drag_and_drop
355
- Gladiator.drag_and_drop = false
356
- else
357
- project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
358
- @current_text_editor&.text_widget&.setFocus
507
+
508
+ on_item_collapsed { |event|
509
+ if @file_lookup_expand_item.swt_expand_item.get_expanded
510
+ @file_explorer_expand_item_height = @file_explorer_expand_item.swt_expand_item.height
511
+ @file_explorer_expand_item.swt_expand_item.height = 0
512
+ @file_explorer_expand_bar_height = @file_explorer_expand_bar.swt_widget.size.y
513
+ @file_lookup_expand_bar_height = @file_lookup_expand_bar.swt_widget.size.y
514
+ @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]
359
515
  end
360
516
  }
361
- on_key_pressed { |key_event|
362
- if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
363
- project_dir.selected_child_path = extract_tree_item_path(@file_tree.swt_widget.getSelection&.first)
364
- @current_text_editor&.text_widget&.setFocus
365
- end
366
- }
367
- on_paint_control {
368
- root_item = @file_tree.swt_widget.getItems.first
369
- if root_item && !root_item.getExpanded
370
- root_item.setExpanded(true)
371
- end
517
+
518
+ on_item_expanded {
519
+ @file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_item_height if @file_explorer_expand_item_height
520
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
372
521
  }
522
+
373
523
  }
524
+
374
525
  }
375
526
 
376
527
  # TODO see if you could replace some of this with Glimmer DSL/API syntax
@@ -380,120 +531,224 @@ module Glimmer
380
531
  @file_tree_editor.minimumHeight = 20;
381
532
 
382
533
  }
383
- @editor_container = composite {
384
- grid_layout 1, false
534
+
535
+ composite {
536
+ grid_layout(1, false) {
537
+ margin_width 0
538
+ margin_height 0
539
+ }
385
540
  layout_data :fill, :fill, true, true
386
- composite {
387
- grid_layout 3, false
388
-
389
- # row 1
541
+
542
+ @navigation_expand_bar = expand_bar {
543
+ layout_data :fill, :top, true, false
544
+ font height: 17, style: :bold
545
+ foreground @default_foreground
546
+
547
+ @navigation_expand_item = expand_item {
548
+ text 'Navigation'
549
+ height 115
390
550
 
391
- label {
392
- text 'File:'
393
- }
394
-
395
- @file_path_label = styled_text(:none) {
396
- layout_data(:fill, :fill, true, false) {
397
- horizontal_span 2
551
+ grid_layout(5, false) {
552
+ margin_right 5
398
553
  }
399
- background color(:widget_background)
400
- editable false
401
- caret nil
402
- text bind(project_dir, 'selected_child.path')
403
- on_mouse_up {
404
- @file_path_label.swt_widget.selectAll
554
+
555
+ stat_font = {name: 'Consolas', height: OS.mac? ? 15 : 12}
556
+
557
+ # row 1
558
+
559
+ label {
560
+ layout_data(:left, :center, false, false)
561
+ text 'File:'
562
+ foreground @default_foreground
405
563
  }
406
- on_focus_lost {
407
- @file_path_label.swt_widget.setSelection(0, 0)
564
+
565
+ @file_path_label = styled_text(:none) {
566
+ layout_data(:fill, :center, true, false) {
567
+ horizontal_span 2
568
+ }
569
+ background color(:widget_background)
570
+ foreground @default_foreground
571
+ editable false
572
+ caret nil
573
+ text bind(project_dir, 'selected_child.path')
574
+ on_mouse_up {
575
+ @file_path_label.swt_widget.selectAll
576
+ }
577
+ on_focus_lost {
578
+ @file_path_label.swt_widget.setSelection(0, 0)
579
+ }
408
580
  }
409
- }
410
-
411
- # row 2
412
-
413
- label {
414
- text 'Line:'
415
- }
416
- @line_number_text = text {
417
- layout_data(:fill, :fill, true, false) {
418
- minimum_width 400
419
- }
420
- text bind(project_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
421
- on_key_pressed { |key_event|
422
- if key_event.keyCode == swt(:cr)
423
- @current_text_editor&.text_widget&.setFocus
424
- end
581
+
582
+ label {
583
+ layout_data(:left, :center, false, false)
584
+ text 'Caret Position:'
585
+ foreground @default_foreground
425
586
  }
426
- on_verify_text { |event|
427
- event.doit = !event.text.match(/^\d*$/).to_a.empty?
587
+ label(:right) {
588
+ layout_data(:fill, :center, true, false)
589
+ text bind(project_dir, 'selected_child.caret_position')
590
+ foreground @default_foreground
591
+ font stat_font
428
592
  }
429
- }
430
- label
431
-
432
- # row 3
433
-
434
- label {
435
- text 'Find:'
436
- }
437
- @find_text = text {
438
- layout_data(:fill, :center, true, false) {
439
- minimum_width 400
440
- }
441
- text bind(project_dir, 'selected_child.find_text')
442
- on_key_pressed { |key_event|
443
- if key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
444
- project_dir.selected_child.case_sensitive = !project_dir.selected_child.case_sensitive
445
- project_dir.selected_child&.find_next
446
- end
447
- if key_event.keyCode == swt(:cr)
448
- project_dir.selected_child&.find_next
449
- end
593
+
594
+ # row 2
595
+
596
+ label {
597
+ layout_data(:left, :center, false, false)
598
+ text 'Line:'
599
+ foreground @default_foreground
450
600
  }
451
- }
452
- composite {
453
- row_layout
454
- button(:check) {
455
- selection bind(project_dir, 'selected_child.case_sensitive')
601
+ @line_number_text = text {
602
+ layout_data(:fill, :center, true, false) {
603
+ minimum_width 400
604
+ }
605
+ text bind(project_dir, 'selected_child.line_number', on_read: :to_s, on_write: :to_i)
606
+ foreground @default_foreground
607
+ font stat_font
608
+ on_key_pressed { |key_event|
609
+ if key_event.keyCode == swt(:cr)
610
+ @current_text_editor&.text_widget&.setFocus
611
+ end
612
+ }
613
+ on_verify_text { |event|
614
+ event.doit = !event.text.match(/^\d*$/).to_a.empty?
615
+ }
616
+ }
617
+ label # filler
618
+
619
+ label {
620
+ layout_data(:left, :center, false, false)
621
+ text 'Line Position:'
622
+ foreground @default_foreground
623
+ }
624
+ label(:right) {
625
+ layout_data(:fill, :center, true, false)
626
+ text bind(project_dir, 'selected_child.line_position')
627
+ foreground @default_foreground
628
+ font stat_font
629
+ }
630
+
631
+ # row 3
632
+
633
+ label {
634
+ layout_data(:left, :center, false, false)
635
+ text 'Find:'
636
+ foreground @default_foreground
637
+ }
638
+ @find_text = text {
639
+ layout_data(:fill, :center, true, false) {
640
+ minimum_width 400
641
+ }
642
+ text bind(project_dir, 'selected_child.find_text')
643
+ foreground @default_foreground
644
+ font stat_font
456
645
  on_key_pressed { |key_event|
646
+ if key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
647
+ project_dir.selected_child.case_sensitive = !project_dir.selected_child.case_sensitive
648
+ project_dir.selected_child&.find_next
649
+ end
457
650
  if key_event.keyCode == swt(:cr)
458
651
  project_dir.selected_child&.find_next
459
652
  end
460
653
  }
461
654
  }
655
+ composite {
656
+ layout_data(:left, :center, true, false)
657
+ row_layout {
658
+ margin_width 0
659
+ margin_height 0
660
+ }
661
+ button(:check) {
662
+ selection bind(project_dir, 'selected_child.case_sensitive')
663
+ on_key_pressed { |key_event|
664
+ if key_event.keyCode == swt(:cr)
665
+ project_dir.selected_child&.find_next
666
+ end
667
+ }
668
+ }
669
+ label {
670
+ text 'Case-sensitive'
671
+ foreground @default_foreground
672
+ }
673
+ }
674
+
675
+ label {
676
+ layout_data(:left, :center, false, false)
677
+ text 'Selection Count:'
678
+ foreground @default_foreground
679
+ }
680
+ label(:right) {
681
+ layout_data(:fill, :center, true, false)
682
+ text bind(project_dir, 'selected_child.selection_count')
683
+ foreground @default_foreground
684
+ font stat_font
685
+ }
686
+
687
+ # row 4
688
+
462
689
  label {
463
- text 'Case-sensitive'
690
+ layout_data(:left, :center, false, false)
691
+ text 'Replace:'
692
+ foreground @default_foreground
693
+ }
694
+ @replace_text = text {
695
+ layout_data(:fill, :center, true, false) {
696
+ minimum_width 400
697
+ }
698
+ text bind(project_dir, 'selected_child.replace_text')
699
+ foreground @default_foreground
700
+ font stat_font
701
+ on_focus_gained {
702
+ project_dir.selected_child&.ensure_find_next
703
+ }
704
+ on_key_pressed { |key_event|
705
+ if key_event.keyCode == swt(:cr)
706
+ if project_dir.selected_child
707
+ Command.do(project_dir.selected_child, :replace_next!)
708
+ end
709
+ end
710
+ }
711
+ }
712
+ label # filler
713
+ label {
714
+ layout_data(:left, :center, false, false)
715
+ text 'Top Pixel:'
716
+ foreground @default_foreground
717
+ }
718
+ label(:right) {
719
+ layout_data(:fill, :center, true, false)
720
+ text bind(project_dir, 'selected_child.top_pixel')
721
+ foreground @default_foreground
722
+ font stat_font
464
723
  }
465
724
  }
466
-
467
- # row 4
468
-
469
- label {
470
- text 'Replace:'
725
+
726
+ on_item_collapsed {
727
+ @navigation_expand_item_height = @navigation_expand_item.swt_expand_item.height if @navigation_expand_item.swt_expand_item.height > 0
728
+ @navigation_expand_item.swt_expand_item.height = 0
729
+ async_exec {
730
+ body_root.pack_same_size
731
+ }
471
732
  }
472
- @replace_text = text {
473
- layout_data(:fill, :fill, true, false) {
474
- minimum_width 300
475
- }
476
- text bind(project_dir, 'selected_child.replace_text')
477
- on_focus_gained {
478
- project_dir.selected_child&.ensure_find_next
479
- }
480
- on_key_pressed { |key_event|
481
- if key_event.keyCode == swt(:cr)
482
- if project_dir.selected_child
483
- Command.do(project_dir.selected_child, :replace_next!)
484
- end
485
- end
733
+
734
+ on_item_expanded {
735
+ @navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
736
+ async_exec {
737
+ body_root.pack_same_size
486
738
  }
487
739
  }
488
- label
740
+
489
741
  }
742
+
490
743
  @tab_folder_sash_form = sash_form {
491
744
  layout_data(:fill, :fill, true, true) {
492
- width_hint 640
493
- height_hint 480
745
+ width_hint 768
746
+ height_hint 576
747
+ minimum_width 768
748
+ minimum_height 576
494
749
  }
495
750
  sash_width 10
496
- orientation bind(self, :split_orientation)
751
+ orientation bind(self, :split_orientation) {|value| async_exec { body_root.pack_same_size}; value}
497
752
  @current_tab_folder = tab_folder {
498
753
  drag_source(DND::DROP_COPY) {
499
754
  transfer [TextTransfer.getInstance].to_java(Transfer)
@@ -539,8 +794,8 @@ module Glimmer
539
794
  open_file_paths2 = @config[:open_file_paths2]
540
795
  self.split_orientation = swt(@config[:split_orientation] || :horizontal) rescue swt(:horizontal)
541
796
  if @progress_bar_shell.nil?
542
- @progress_bar_shell = shell(body_root) {
543
- text 'Opening Last Open Files'
797
+ @progress_bar_shell = shell(body_root, :title) {
798
+ text 'Gladiator'
544
799
  fill_layout(:vertical) {
545
800
  margin_width 15
546
801
  margin_height 15
@@ -559,37 +814,55 @@ module Glimmer
559
814
  open_file_paths1.to_a.each do |file_path|
560
815
  async_exec {
561
816
  Gladiator.drag = false
817
+ Gladiator.startup = file_path != open_file_paths1.to_a[-1]
562
818
  project_dir.selected_child_path = file_path
563
819
  }
564
820
  end
565
821
  # TODO replace the next line with one that selects the visible tab
566
822
  async_exec {
567
- Gladiator.drag = false
568
- project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths1.to_a.include?(@config[:selected_child_path])
569
- 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]
570
- project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
823
+ # TODO check why this is not working
824
+ if open_file_paths1.to_a.include?(@config[:selected_child_path])
825
+ Gladiator.drag = false
826
+ Gladiator.startup = false
827
+ project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
828
+ 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]
829
+ project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
830
+ end
571
831
  }
572
832
  async_exec {
573
833
  open_file_paths2.to_a.each do |file_path|
574
834
  async_exec {
575
835
  Gladiator.drag = true
836
+ Gladiator.startup = file_path != open_file_paths2.to_a[-1]
576
837
  project_dir.selected_child_path = file_path
577
838
  }
578
839
  end
579
840
  # TODO replace the next line with one that selects the visible tab
580
841
  async_exec {
581
- Gladiator.drag = true
582
- project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths2.to_a.include?(@config[:selected_child_path])
583
- 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]
584
- project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
842
+ # TODO check why this is not working
843
+ if open_file_paths2.to_a.include?(@config[:selected_child_path])
844
+ Gladiator.drag = true
845
+ Gladiator.startup = false
846
+ project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
847
+ 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]
848
+ project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
849
+ end
585
850
  }
586
851
  async_exec {
587
852
  Gladiator.drag = false
588
- @progress_bar_shell.close
853
+ @progress_bar_shell&.close
589
854
  @progress_bar_shell = nil
590
855
  @loaded_config = true
591
856
  }
592
857
  }
858
+ async_exec {
859
+ Thread.new {
860
+ all_files = open_file_paths1.to_a + open_file_paths2.to_a
861
+ all_files.each do |file|
862
+ project_dir.find_child_file(file)&.dirty_content
863
+ end
864
+ }
865
+ }
593
866
  else
594
867
  @loaded_config = true
595
868
  end
@@ -636,8 +909,8 @@ module Glimmer
636
909
  @current_tab_item = @current_tab_folder.swt_widget.getData('selected_tab_item')
637
910
  @current_text_editor = @current_tab_item.swt_tab_item.getData('text_editor')
638
911
  project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
639
-
640
- body_root.pack_same_size
912
+
913
+ async_exec { body_root.pack_same_size }
641
914
  end
642
915
  end
643
916
 
@@ -674,6 +947,7 @@ module Glimmer
674
947
  parent_path = ::File.dirname(file.path)
675
948
  if file.is_a?(Gladiator::Dir)
676
949
  file_paths = file.all_children.select {|f| f.is_a?(Gladiator::File)}.map(&:path)
950
+ file.remove_all_observers
677
951
  else
678
952
  file_paths = [file.path]
679
953
  end
@@ -777,8 +1051,9 @@ module Glimmer
777
1051
 
778
1052
  def open_project
779
1053
  selected_directory = directory_dialog.open
780
- @progress_bar_shell = shell(body_root) {
781
- text 'Opening Project'
1054
+ return if selected_directory.nil?
1055
+ @progress_bar_shell = shell(body_root, :title) {
1056
+ text 'Gladiator'
782
1057
  fill_layout(:vertical) {
783
1058
  margin_width 15
784
1059
  margin_height 15
@@ -803,13 +1078,49 @@ module Glimmer
803
1078
  }
804
1079
  end
805
1080
 
1081
+ def display_about_dialog
1082
+ dialog {
1083
+ grid_layout(2, false) {
1084
+ margin_width 15
1085
+ margin_height 15
1086
+ }
1087
+
1088
+ background :white
1089
+ image ICON
1090
+ text 'About'
1091
+
1092
+ label {
1093
+ layout_data :center, :center, false, false
1094
+ background :white
1095
+ image ICON, height: 260
1096
+ }
1097
+ label {
1098
+ layout_data :fill, :fill, true, true
1099
+ background :white
1100
+ text "Gladiator v#{VERSION}\n\n#{LICENSE}\n\nGladiator icon made by Freepik from www.flaticon.com"
1101
+ }
1102
+ }.open
1103
+ end
1104
+
806
1105
  def handle_display_shortcut(key_event)
807
1106
  if key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'f'
808
- if current_text_editor&.text_widget&.getSelectionText && current_text_editor&.text_widget&.getSelectionText&.size.to_i > 0
809
- find_text.swt_widget.setText current_text_editor.text_widget.getSelectionText
1107
+ find_action = lambda do
1108
+ if current_text_editor&.text_widget&.getSelectionText && current_text_editor&.text_widget&.getSelectionText&.size.to_i > 0
1109
+ find_text.swt_widget.setText current_text_editor.text_widget.getSelectionText
1110
+ end
1111
+ find_text.swt_widget.selectAll
1112
+ find_text.swt_widget.setFocus
1113
+ end
1114
+ if @navigation_expand_item.swt_expand_item.get_expanded
1115
+ find_action.call
1116
+ else
1117
+ @navigation_expand_item.swt_expand_item.set_expanded true
1118
+ @navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
1119
+ async_exec {
1120
+ body_root.pack_same_size
1121
+ }
1122
+ async_exec(&find_action)
810
1123
  end
811
- find_text.swt_widget.selectAll
812
- find_text.swt_widget.setFocus
813
1124
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'c'
814
1125
  Clipboard.copy(project_dir.selected_child.path)
815
1126
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'g'
@@ -905,12 +1216,34 @@ module Glimmer
905
1216
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'g'
906
1217
  project_dir.selected_child.find_next
907
1218
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
908
- line_number_text.swt_widget.selectAll
909
- line_number_text.swt_widget.setFocus
1219
+ unless @navigation_expand_item.swt_expand_item.get_expanded
1220
+ @navigation_expand_item.swt_expand_item.set_expanded true
1221
+ @navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
1222
+ async_exec {
1223
+ body_root.pack_same_size
1224
+ }
1225
+ async_exec {
1226
+ line_number_text.swt_widget.selectAll
1227
+ line_number_text.swt_widget.setFocus
1228
+ }
1229
+ else
1230
+ line_number_text.swt_widget.selectAll
1231
+ line_number_text.swt_widget.setFocus
1232
+ end
910
1233
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'r'
1234
+ unless @file_lookup_expand_item.swt_expand_item.get_expanded
1235
+ @file_lookup_expand_item.swt_expand_item.set_expanded true
1236
+ @file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_item_height if @file_lookup_expand_item_height
1237
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
1238
+ end
911
1239
  filter_text.swt_widget.selectAll
912
1240
  filter_text.swt_widget.setFocus
913
1241
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 't'
1242
+ unless @file_explorer_expand_item.swt_expand_item.get_expanded
1243
+ @file_explorer_expand_item.swt_expand_item.set_expanded true
1244
+ @file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_item_height if @file_explorer_expand_item_height
1245
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
1246
+ end
914
1247
  select_tree_item unless rename_in_progress
915
1248
  file_tree.swt_widget.setFocus
916
1249
  elsif key_event.keyCode == swt(:esc)
@@ -921,4 +1254,4 @@ module Glimmer
921
1254
  end
922
1255
  end
923
1256
  end
924
- end
1257
+ end