glimmer-cs-gladiator 0.5.3 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9b90cb14c65857fcd2aae74b253de63975e07979598fff9859016fa49eab9c2
4
- data.tar.gz: 780b56d9e8e71e1d25d0399eec1c634fa1283af07059f4ec7042a4ff42c7c31d
3
+ metadata.gz: d31e7dd5189317eaeb3a91a175a050ffaaeb4e82d6c8709167477d26dd7bf237
4
+ data.tar.gz: 370a540665a9d7f3d08154f1e98530521f72e9a720f35fa83f982747e2e5bf5e
5
5
  SHA512:
6
- metadata.gz: 381596e40835072897b07ed25faa61f3edd72fba81a4637303b4e2dbb5698a0564f7737b01e7e9ff40f038673d25b5ad20fc8e8875d40a1082df8e1169cf3b09
7
- data.tar.gz: d5fd3e26fe95a495eb4ce84eea62ceb3a0080eeae41a15ea45dbfd53275615daa2f90dfa2a0c07de67893387febed5021fb5e46af81be0e5a17afb8aa000453c
6
+ metadata.gz: 7af2ad9407c442ad6634a843ad3b5fc6cac47dadbd84ec0dc0b19f8d38b858950648a951383be811f040232ab426cbf0dffc1ad1d003a33a6a3cefd07d6c6832
7
+ data.tar.gz: a9d30dc68de3f7de8fa25c9860c57885892e4ceeea734c63bc4fd2b257736afc0e1b0c7a062d03af93991d03d05907dbfbe058adcf6e13d695ce524167ce5aef
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.5.3 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
1
+ # <img src='https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-gladiator/master/images/glimmer-cs-gladiator-logo.svg' height=85 /> Gladiator 0.5.4 - [Ugliest Text Editor Ever](https://www.reddit.com/r/ruby/comments/hgve8k/gladiator_glimmer_editor_ugliest_text_editor_ever/)
2
2
  ## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer-dsl-swt#custom-shell-gem)
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-cs-gladiator.svg)](http://badge.fury.io/rb/glimmer-cs-gladiator)
4
4
 
@@ -13,6 +13,9 @@ I leave building truly professional text editors to software tooling experts who
13
13
 
14
14
  Gladiator currently supports the following text editing features (including keyboard shortcuts with Mac CMD=CTRL on Windows/Linux):
15
15
  - Ruby Syntax Highlighting with colors
16
+ - Open Project from File Menu (CMD+SHIFT+P)
17
+ - Scratchpad for running arbitrary Ruby/Glimmer code without saving to disk (CMD+SHIFT+S)
18
+ - Run Ruby code (CMD+SHIFT+R)
16
19
  - File explorer navigation with context menu to open file, rename, delete, add new file, add new directory, or refresh tree (CMD+T)
17
20
  - File lookup by name ignoring slashes, underscores, and dots to ease lookup (CMD+R)
18
21
  - Watch open file for external changes to automatically refresh in editor
@@ -30,10 +33,8 @@ Gladiator currently supports the following text editing features (including keyb
30
33
  - Comment/Uncomment line/selection (CMD+/)
31
34
  - Indent/Unindent line/selection (CMD+] & CMD+[)
32
35
  - Insert/Prefix New Line (CMD+ENTER & CMD+SHIFT+ENTER)
33
- - Drag and Drop Text Editor Split Screen (drag a file from File Tree or File Lookup List, and it splits the screen)
34
- - Run Ruby code (CMD+SHIFT+R)
35
- - Scratchpad for running arbitrary Ruby/Glimmer code without saving to disk (CMD+SHIFT+S)
36
- - Change Split Orientation to Horizontal/Vertical via View Menu (CMD+SHIFT+O)
36
+ - Split Pane & Change Split Orientation to Horizontal/Vertical via View Menu (CMD+SHIFT+O)
37
+ - Drag and Drop Text Editor Split Screen (drag a file from File Tree or File Lookup List, and it splits the pane)
37
38
 
38
39
  ## Platforms
39
40
 
@@ -77,6 +78,12 @@ You may run the `gladiator` command to bring up the text editor in the project d
77
78
  gladiator
78
79
  ```
79
80
 
81
+ On Linux, you may need to run with extra memory via this command instead:
82
+
83
+ ```
84
+ gladiator -J-Xmx1200M
85
+ ```
86
+
80
87
  On Windows, you may need to run with extra memory via this command instead:
81
88
 
82
89
  ```
@@ -103,7 +110,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
103
110
  following to the application's `Gemfile`:
104
111
 
105
112
  ```
106
- gem 'glimmer-cs-gladiator', '~> 0.5.3'
113
+ gem 'glimmer-cs-gladiator', '~> 0.5.4'
107
114
  ```
108
115
 
109
116
  Run:
@@ -132,13 +139,9 @@ Opens Gladiator with "/Users/User/code" as the root directory.
132
139
  Gladiator automatically saves configuration data in a `.gladiator` file at the directory it is run from.
133
140
 
134
141
  It currently remembers:
135
- - Last opened file
136
- - Caret position
137
- - Top line position
138
- - Window size
139
- - Opened tabs
140
- - Split tabs
141
- - Ignore Paths
142
+ - Last opened files (in both split panes if split)
143
+ - Window size and position
144
+ - Ignore Paths (default: '.gladiator', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor')
142
145
 
143
146
  ## Gotcha
144
147
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -6,8 +6,6 @@ module Glimmer
6
6
  include Glimmer
7
7
  include Glimmer::DataBinding::ObservableModel
8
8
 
9
- REFRESH_DELAY = 7
10
-
11
9
  attr_accessor :selected_child, :filter, :children, :filtered_path_options, :filtered_path, :display_path, :ignore_paths
12
10
  attr_reader :name, :parent, :path
13
11
  attr_writer :all_children
@@ -15,19 +13,30 @@ module Glimmer
15
13
  def initialize(path, project_dir = nil)
16
14
  @project_dir = project_dir
17
15
  if is_local_dir
18
- @filewatcher = Filewatcher.new(path)
19
- @thread = Thread.new(@filewatcher) do |fw|
20
- fw.watch do |filename, event|
21
- if @last_update.nil? || (Time.now.to_f - @last_update) > REFRESH_DELAY
22
- refresh if !filename.include?('new_file') && !selected_child_path_history.include?(filename) && filename != selected_child_path
23
- end
24
- @last_update = Time.now.to_f
25
- end
26
- end
16
+ @filewatcher = Filewatcher.new(path)
17
+ Thread.new(@filewatcher) do |fw|
18
+ begin
19
+ fw.watch do |filename, event|
20
+ # TODO do fine grained processing of events for enhanced performance (e.g. dir refresh vs file change)
21
+ # TODO do fine grained file change only without a refresh delay for enhanced performance
22
+ begin
23
+ if !@refresh_in_progress && !filename.include?('new_file') && (event != :updated || find_child_file(filename).nil?)
24
+ Thread.new {
25
+ refresh
26
+ }
27
+ end
28
+ rescue => e
29
+ puts e.full_message
30
+ end
31
+ end
32
+ rescue => e
33
+ puts e.full_message
34
+ end
35
+ end
27
36
  end
28
37
  self.path = ::File.expand_path(path)
29
38
  @name = ::File.basename(::File.expand_path(path))
30
- @ignore_paths = ['.gladiator', '.git', 'coverage', 'packages', 'tmp', 'vendor']
39
+ @ignore_paths = ['.gladiator', '.git', 'coverage', 'packages', 'node_modules', 'tmp', 'vendor']
31
40
  self.filtered_path_options = []
32
41
  end
33
42
 
@@ -67,7 +76,7 @@ module Glimmer
67
76
  result || p.include?(ignore_path)
68
77
  end
69
78
  end.map do |p|
70
- ::File.file?(p) ? Gladiator::File.new(p, project_dir) : Gladiator::Dir.new(p, project_dir)
79
+ ::File.file?(p) ? File.new(p, project_dir) : Dir.new(p, project_dir)
71
80
  end.sort_by do |c|
72
81
  c.path.to_s.downcase
73
82
  end.sort_by do |c|
@@ -76,6 +85,22 @@ module Glimmer
76
85
  child.retrieve_children if child.is_a?(Dir)
77
86
  end
78
87
  end
88
+
89
+ def find_child_file(child_path)
90
+ depth_first_search_file(self, child_path)
91
+ end
92
+
93
+ def depth_first_search_file(dir, file_path)
94
+ dir.children.each do |child|
95
+ if child.is_a?(File)
96
+ return child if child.path.include?(file_path)
97
+ else
98
+ result = depth_first_search_file(child, file_path)
99
+ return result unless result.nil?
100
+ end
101
+ end
102
+ nil
103
+ end
79
104
 
80
105
  def selected_child_path_history
81
106
  @selected_child_path_history ||= []
@@ -91,6 +116,7 @@ module Glimmer
91
116
 
92
117
  def refresh(async: true, force: false)
93
118
  return if @refresh_paused && !force
119
+ @refresh_in_progress = true
94
120
  retrieve_children
95
121
  collect_all_children
96
122
  refresh_operation = lambda do
@@ -102,6 +128,7 @@ module Glimmer
102
128
  else
103
129
  sync_exec(&refresh_operation)
104
130
  end
131
+ @refresh_in_progress = false
105
132
  end
106
133
 
107
134
  def filter=(value)
@@ -144,7 +171,7 @@ module Glimmer
144
171
  def selected_child_path=(selected_path)
145
172
  return (project_dir.selected_child = nil) if selected_path.nil?
146
173
  # scratchpad scenario
147
- if selected_path.empty? #scratchpad
174
+ if selected_path.empty? # Scratchpad
148
175
  @selected_child&.write_dirty_content
149
176
  return (self.selected_child = File.new)
150
177
  end
@@ -154,7 +181,7 @@ module Glimmer
154
181
  selected_path = full_selected_path
155
182
  if ::File.file?(selected_path)
156
183
  @selected_child&.write_dirty_content
157
- new_child = Gladiator::File.new(selected_path, project_dir)
184
+ new_child = find_child_file(selected_path)
158
185
  begin
159
186
  unless new_child.dirty_content.nil?
160
187
  self.selected_child&.stop_filewatcher
@@ -175,6 +202,7 @@ module Glimmer
175
202
  end
176
203
 
177
204
  def selected_child=(new_child)
205
+ return if selected_child == new_child
178
206
  file_properties = @selected_child&.backup_properties if @selected_child == new_child
179
207
  @selected_child = new_child
180
208
  @selected_child.restore_properties(file_properties) if file_properties
@@ -3,7 +3,7 @@ module Glimmer
3
3
  class File
4
4
  include Glimmer
5
5
 
6
- attr_accessor :dirty_content, :line_numbers_content, :selection, :line_number, :find_text, :replace_text, :top_pixel, :display_path, :case_sensitive
6
+ attr_accessor :line_numbers_content, :selection, :line_number, :find_text, :replace_text, :top_pixel, :display_path, :case_sensitive
7
7
  attr_reader :name, :path, :project_dir
8
8
 
9
9
  def initialize(path='', project_dir=nil)
@@ -15,31 +15,45 @@ module Glimmer
15
15
  @top_pixel = 0
16
16
  @selection_count = 0
17
17
  @selection = Point.new(0, 0 + @selection_count)
18
- read_dirty_content = path.empty? ? '' : ::File.read(path)
19
- begin
20
- # test read dirty content
21
- read_dirty_content.split("\n")
22
- observe(self, :dirty_content) do
23
- lines_text_size = lines.size.to_s.size
24
- self.line_numbers_content = lines.size.times.map {|n| (' ' * (lines_text_size - (n+1).to_s.size)) + (n+1).to_s }.join("\n")
25
- end
26
- @line_number = 1
27
- self.dirty_content = read_dirty_content
28
- observe(self, :selection) do
29
- self.line_number = line_index_for_caret_position(caret_position) + 1
30
- end
31
- observe(self, :line_number) do
32
- if line_number
33
- line_index = line_number - 1
34
- new_caret_position = caret_position_for_line_index(line_index)
35
- self.caret_position = new_caret_position unless self.caret_position && line_index_for_caret_position(new_caret_position) == line_index_for_caret_position(caret_position)
18
+ @line_number = 1
19
+ end
20
+
21
+ def init_content
22
+ unless @init
23
+ @init = true
24
+ begin
25
+ # test read dirty content
26
+ observe(self, :dirty_content) do
27
+ lines_text_size = lines.size.to_s.size
28
+ 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")
30
+ self.top_pixel = old_top_pixel
31
+ end
32
+ the_dirty_content = read_dirty_content
33
+ the_dirty_content.split("\n") # test that it is not a binary file (crashes to rescue block otherwise)
34
+ 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
+ }
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
36
50
  end
51
+ rescue # in case of a binary file
52
+ stop_filewatcher
37
53
  end
38
- rescue
39
- # no op in case of a binary file
40
54
  end
41
55
  end
42
-
56
+
43
57
  def path=(the_path)
44
58
  @path = the_path
45
59
  generate_display_path
@@ -71,6 +85,7 @@ module Glimmer
71
85
  def content=(value)
72
86
  value = value.gsub("\t", ' ')
73
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...)
74
89
  Command.do(self) # record a native (OS-widget) operation
75
90
  self.dirty_content = value
76
91
  end
@@ -107,9 +122,26 @@ module Glimmer
107
122
  end
108
123
  end
109
124
 
125
+ def dirty_content
126
+ init_content
127
+ @dirty_content
128
+ end
129
+
110
130
  def dirty_content=(the_content)
131
+ # TODO set partial dirty content by line(s) for enhanced performance
111
132
  @dirty_content = the_content
133
+ old_caret_position = caret_position
134
+ old_top_pixel = top_pixel
112
135
  notify_observers(:content)
136
+ if @formatting_dirty_content_for_writing
137
+ self.caret_position = old_caret_position
138
+ self.selection_count = 0
139
+ self.top_pixel = old_top_pixel
140
+ end
141
+ end
142
+
143
+ def read_dirty_content
144
+ path.empty? ? '' : ::File.read(path)
113
145
  end
114
146
 
115
147
  def start_filewatcher
@@ -117,15 +149,13 @@ module Glimmer
117
149
  @filewatcher = Filewatcher.new(@path)
118
150
  @thread = Thread.new(@filewatcher) do |fw|
119
151
  fw.watch do |filename, event|
120
- begin
121
- read_dirty_content = ::File.read(path)
122
- # test read dirty content
123
- read_dirty_content.split("\n")
124
- async_exec do
152
+ async_exec do
153
+ begin
125
154
  self.dirty_content = read_dirty_content if read_dirty_content != dirty_content
155
+ rescue StandardError, Errno::ENOENT
156
+ # in case of a binary file
157
+ stop_filewatcher
126
158
  end
127
- rescue
128
- # no op in case of a binary file
129
159
  end
130
160
  end
131
161
  end
@@ -135,21 +165,26 @@ module Glimmer
135
165
  @filewatcher&.stop
136
166
  end
137
167
 
138
- def format_dirty_content_for_writing!
139
- new_dirty_content = dirty_content.split("\n").map {|line| line.strip.empty? ? line : line.rstrip }.join("\n")
140
- new_dirty_content = "#{new_dirty_content.gsub("\r\n", "\n").gsub("\r", "\n").sub(/\n+\z/, '')}\n"
141
- self.dirty_content = new_dirty_content if new_dirty_content != self.dirty_content
142
- end
143
-
144
168
  def write_dirty_content
145
- return if scratchpad? || !::File.exist?(path)
169
+ # TODO write partial dirty content by line(s) for enhanced performance
170
+ return if scratchpad? || !::File.exist?(path) || !::File.exists?(path) || read_dirty_content == dirty_content
146
171
  format_dirty_content_for_writing!
147
- ::File.write(path, dirty_content) if ::File.exists?(path)
148
- rescue => e
172
+ ::File.write(path, dirty_content)
173
+ rescue StandardError, ArgumentError => e
149
174
  puts "Error in writing dirty content for #{path}"
150
175
  puts e.full_message
151
176
  end
152
177
 
178
+ def format_dirty_content_for_writing!
179
+ new_dirty_content = dirty_content.split("\n").map {|line| line.strip.empty? ? line : line.rstrip }.join("\n")
180
+ new_dirty_content = "#{new_dirty_content.gsub("\r\n", "\n").gsub("\r", "\n").sub(/\n+\z/, '')}\n"
181
+ if new_dirty_content != self.dirty_content
182
+ @formatting_dirty_content_for_writing = true
183
+ self.dirty_content = new_dirty_content
184
+ @formatting_dirty_content_for_writing = false
185
+ end
186
+ end
187
+
153
188
  def write_raw_dirty_content
154
189
  return if scratchpad? || !::File.exist?(path)
155
190
  ::File.write(path, dirty_content) if ::File.exists?(path)
@@ -185,7 +220,7 @@ module Glimmer
185
220
  self.caret_position = caret_position_for_line_index(line_number) + current_line_indentation.size
186
221
  self.selection_count = 0
187
222
  end
188
-
223
+
189
224
  def comment_line!
190
225
  old_lines = lines
191
226
  return if old_lines.size < 1
@@ -219,6 +254,7 @@ module Glimmer
219
254
  new_caret_position = old_caret_position + delta
220
255
  new_caret_position = [new_caret_position, old_caret_position_line_caret_position].max
221
256
  self.caret_position = new_caret_position
257
+ self.selection_count = 0
222
258
  end
223
259
  end
224
260
 
@@ -243,6 +279,7 @@ module Glimmer
243
279
  self.selection_count = (caret_position_for_line_index(old_end_caret_line_index + 1) - self.caret_position)
244
280
  else
245
281
  self.caret_position = old_caret_position + delta
282
+ self.selection_count = 0
246
283
  end
247
284
  end
248
285
 
@@ -274,6 +311,7 @@ module Glimmer
274
311
  new_caret_position = old_caret_position + delta
275
312
  new_caret_position = [new_caret_position, old_caret_position_line_caret_position].max
276
313
  self.caret_position = new_caret_position
314
+ self.selection_count = 0
277
315
  end
278
316
  end
279
317
 
@@ -311,6 +349,7 @@ module Glimmer
311
349
  self.selection_count = (caret_position_for_line_index(old_end_caret_line_index + 1) - self.caret_position)
312
350
  else
313
351
  self.caret_position = old_caret_position + delta
352
+ self.selection_count = 0
314
353
  end
315
354
  end
316
355
 
@@ -35,8 +35,26 @@ module Glimmer
35
35
  @project_dir ||= Dir.new(project_dir_path)
36
36
  end
37
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
38
+ def split_orientation=(value)
39
+ @split_orientation = value
40
+ save_config
41
+ if @loaded_config && !split_pane?
42
+ Gladiator.drag = true
43
+ child_path = project_dir.selected_child_path
44
+ project_dir.selected_child = nil
45
+ project_dir.selected_child_path = child_path
46
+ Gladiator.drag = false
47
+ end
48
+ @split_orientation
49
+ end
50
+
51
+ def split_pane?
52
+ pane_count = @tab_folder_sash_form&.children&.size
53
+ pane_count && pane_count > 1
54
+ end
55
+
56
+ attr_reader :find_text, :tab_folder1, :tab_folder2, :filter_text, :rename_in_progress, :line_number_text, :file_tree, :split_orientation
57
+ attr_accessor :current_tab_item, :current_tab_folder, :current_text_editor
40
58
 
41
59
  ## Uncomment before_body block to pre-initialize variables to use in body
42
60
  #
@@ -180,7 +198,7 @@ module Glimmer
180
198
  begin
181
199
  project_dir.selected_child_path = ''
182
200
  rescue => e
183
- pd e
201
+ puts e.full_message
184
202
  end
185
203
  }
186
204
  }
@@ -198,11 +216,15 @@ module Glimmer
198
216
  text '&Split'
199
217
  menu_item(:radio) {
200
218
  text '&Horizontal'
201
- selection bind(self, :split_orientation, on_read: ->(o) { o == swt(:horizontal)}, on_write: ->(b) { b ? swt(:horizontal) : swt(:vertical)})
219
+ selection bind(self, :split_orientation,
220
+ on_read: ->(o) { split_pane? && o == swt(:horizontal)},
221
+ on_write: ->(b) { b ? swt(:horizontal) : swt(:vertical) })
202
222
  }
203
223
  menu_item(:radio) {
204
224
  text '&Vertical'
205
- selection bind(self, :split_orientation, on_read: ->(o) { o == swt(:vertical)}, on_write: ->(b) { b ? swt(:vertical) : swt(:horizontal)})
225
+ selection bind(self, :split_orientation,
226
+ on_read: ->(o) { split_pane? && o == swt(:vertical)},
227
+ on_write: ->(b) { b ? swt(:vertical) : swt(:horizontal) })
206
228
  }
207
229
  }
208
230
  }
@@ -248,11 +270,9 @@ module Glimmer
248
270
  end
249
271
  }
250
272
  }
251
- composite {
252
- fill_layout(:vertical) {
253
- spacing 5
254
- }
273
+ sash_form(:vertical) {
255
274
  layout_data(:fill, :fill, true, true)
275
+ sash_width 4
256
276
  @list = list(:border, :h_scroll, :v_scroll) {
257
277
  #visible bind(self, 'project_dir.filter') {|f| !!f}
258
278
  selection bind(project_dir, :filtered_path)
@@ -517,20 +537,59 @@ module Glimmer
517
537
  project_dir.ignore_paths ||= ['packages', 'tmp']
518
538
  open_file_paths1 = @config[:open_file_paths1] || @config[:open_file_paths]
519
539
  open_file_paths2 = @config[:open_file_paths2]
520
- open_file_paths1.to_a.each do |file_path|
521
- project_dir.selected_child_path = file_path
540
+ self.split_orientation = swt(@config[:split_orientation] || :horizontal) rescue swt(:horizontal)
541
+ if @progress_bar_shell.nil?
542
+ @progress_bar_shell = shell(body_root) {
543
+ text 'Opening Last Open Files'
544
+ fill_layout(:vertical) {
545
+ margin_width 15
546
+ margin_height 15
547
+ spacing 5
548
+ }
549
+ label(:center) {
550
+ text "Opening Last Open Files"
551
+ font height: 20
552
+ }
553
+ # @progress_bar = progress_bar(:horizontal, :indeterminate)
554
+ }
555
+ async_exec {
556
+ @progress_bar_shell.open
557
+ }
522
558
  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])
525
- Gladiator.drag = true
526
- open_file_paths2.to_a.each do |file_path|
527
- project_dir.selected_child_path = file_path
559
+ open_file_paths1.to_a.each do |file_path|
560
+ async_exec {
561
+ Gladiator.drag = false
562
+ project_dir.selected_child_path = file_path
563
+ }
528
564
  end
529
565
  # 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])
531
- Gladiator.drag = false
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]
566
+ 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]
571
+ }
572
+ async_exec {
573
+ open_file_paths2.to_a.each do |file_path|
574
+ async_exec {
575
+ Gladiator.drag = true
576
+ project_dir.selected_child_path = file_path
577
+ }
578
+ end
579
+ # TODO replace the next line with one that selects the visible tab
580
+ 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]
585
+ }
586
+ async_exec {
587
+ Gladiator.drag = false
588
+ @progress_bar_shell.close
589
+ @progress_bar_shell = nil
590
+ @loaded_config = true
591
+ }
592
+ }
534
593
  else
535
594
  @loaded_config = true
536
595
  end
@@ -546,6 +605,7 @@ module Glimmer
546
605
  open_file_paths2 = tab_folder2&.swt_widget&.items.to_a.map {|i| i.get_data('file_path')}
547
606
  @config = {
548
607
  selected_child_path: child.path,
608
+ split_orientation: split_orientation == swt(:horizontal) ? 'horizontal' : 'vertical',
549
609
  caret_position: child.caret_position,
550
610
  top_pixel: child.top_pixel,
551
611
  shell_width: swt_widget&.getBounds&.width,
@@ -612,17 +672,23 @@ module Glimmer
612
672
  return if tree_item.nil?
613
673
  file = tree_item.getData
614
674
  parent_path = ::File.dirname(file.path)
675
+ if file.is_a?(Gladiator::Dir)
676
+ file_paths = file.all_children.select {|f| f.is_a?(Gladiator::File)}.map(&:path)
677
+ else
678
+ file_paths = [file.path]
679
+ end
680
+ file_paths.each do |file_path|
681
+ found_tab_item = find_tab_item(file_path)
682
+ if found_tab_item
683
+ project_dir.selected_child_path_history.delete(found_tab_item.getData('file_path'))
684
+ found_tab_item.getData('proxy')&.dispose
685
+ end
686
+ end
615
687
  file.delete! # TODO consider supporting command undo/redo
616
688
  project_dir.refresh(async: false)
617
689
  parent_tree_item = @file_tree.depth_first_search {|ti| ti.getData.path == parent_path}.first
618
690
  @file_tree.swt_widget.showItem(parent_tree_item)
619
691
  parent_tree_item.setExpanded(true)
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
626
692
  rescue => e
627
693
  puts e.full_message
628
694
  end
@@ -691,6 +757,9 @@ module Glimmer
691
757
  else
692
758
  selected_tab_item&.getData('text_editor')&.text_widget&.setFocus
693
759
  end
760
+ async_exec {
761
+ @file_tree.swt_widget.showItem(edited_tree_item)
762
+ }
694
763
  end
695
764
  project_dir.resume_refresh
696
765
  },
@@ -721,19 +790,16 @@ module Glimmer
721
790
  }
722
791
  # @progress_bar = progress_bar(:horizontal, :indeterminate)
723
792
  }
724
- Thread.new {
725
- async_exec {
726
- @progress_bar_shell.open
727
- }
793
+ async_exec {
794
+ @progress_bar_shell.open
728
795
  }
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
- }
796
+ async_exec {
797
+ gladiator(project_dir_path: selected_directory) {
798
+ on_swt_show {
799
+ @progress_bar_shell.close
800
+ @progress_bar_shell = nil
801
+ }
802
+ }.open if selected_directory
737
803
  }
738
804
  end
739
805
 
@@ -780,7 +846,7 @@ module Glimmer
780
846
  end
781
847
  end
782
848
  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)
849
+ self.split_orientation = split_pane? && split_orientation == swt(:horizontal) ? swt(:vertical) : swt(:horizontal)
784
850
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == ']'
785
851
  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
852
  current_text_editor&.text_widget&.setFocus
@@ -855,4 +921,4 @@ module Glimmer
855
921
  end
856
922
  end
857
923
  end
858
- end
924
+ end
@@ -21,7 +21,7 @@ module Glimmer
21
21
  composite {
22
22
  layout_data :fill, :fill, true, true
23
23
  grid_layout 2, false
24
- @line_numbers_text = styled_text(:multi, :border) {
24
+ @line_numbers_text = styled_text(:multi, :wrap, :border) {
25
25
  layout_data(:right, :fill, false, true)
26
26
  font name: 'Consolas', height: OS.mac? ? 15 : 12
27
27
  background color(:widget_background)
@@ -33,6 +33,7 @@ module Glimmer
33
33
  bottom_margin 5
34
34
  left_margin 5
35
35
  editable false
36
+ alignment swt(:right)
36
37
  on_focus_gained {
37
38
  @text&.swt_widget.setFocus
38
39
  }
@@ -52,6 +53,10 @@ module Glimmer
52
53
  focus true
53
54
  selection bind(self, 'file.selection')
54
55
  top_pixel bind(self, 'file.top_pixel')
56
+ top_margin 5
57
+ right_margin 5
58
+ bottom_margin 5
59
+ left_margin 5
55
60
  drop_target(DND::DROP_COPY) {
56
61
  transfer [TextTransfer.getInstance].to_java(Transfer)
57
62
  on_drag_enter { |event|
@@ -132,12 +137,8 @@ module Glimmer
132
137
  verify_event.text += file.current_line_indentation
133
138
  end
134
139
  when "\t"
135
- if file.selection_count.to_i > 0
136
- Command.do(file, :indent!)
137
- verify_event.doit = false
138
- else
139
- verify_event.text = ' '
140
- end
140
+ Command.do(file, :indent!)
141
+ verify_event.doit = false
141
142
  end
142
143
  }
143
144
  }
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-gladiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-05 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 4.17.8.3
18
+ version: 4.17.10.0
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 5.0.0.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.17.8.3
29
+ version: 4.17.10.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0
@@ -49,7 +49,7 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: 1.3.4
52
+ version: 1.3.5
53
53
  name: clipboard
54
54
  prerelease: false
55
55
  type: :runtime
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.3.4
60
+ version: 1.3.5
61
61
  - !ruby/object:Gem::Dependency
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements: