glimmer-cs-gladiator 0.6.1 → 0.6.2

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: 3b9a2287522769ac69c26758b818fa5a6f6bc67f9dac12b51133f67d3f2fc4fa
4
- data.tar.gz: c9904337e408dcd98ae08fd29a68612a1a02e43bff4b60b076d296849b807f81
3
+ metadata.gz: 3c07882b7fc3a12df1d64f02148ac6d018c1edd45fdea10c6d5285bdd55df137
4
+ data.tar.gz: fdacfe1e7f81879c96f0d746cc1e62ec66e6a202a934dae2f9bb7c1027f91a95
5
5
  SHA512:
6
- metadata.gz: 9437901ac67de9d73faea8c23e75b375144ba09c134e5434aeb1d1a70f320c3265fc0859076b036064d34974d3f819272a660ee8630bf95f151c9ea636d2f33d
7
- data.tar.gz: e02c401d726608a8f6ffbceeb98670bed11d8db002ecc4aebf38f77863842e709bac7cb3739aa4061f52abb7c8bd2259c55333ec1a1b57d6bbf9ef3c3390ee76
6
+ metadata.gz: 42e38a486000c47409ecefd8f120950e856abd9163a3131b8733e65f9bbb337437ed660374c363ccded21db8c4491c158922be6e5510b2af2a8ed2b3e5aa96f1
7
+ data.tar.gz: 36fcaddd1f4d6766f53fb19bd26aaeeaf5e2f86164e6244620f3d5cc5e9067bf48b2172005c850d408d1dc7a80c43dabbe5e9f59c6be53664de4f312d78de844
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.6.0 - [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.6.2 - [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
 
@@ -36,7 +36,7 @@ Gladiator currently supports the following text editing features (including keyb
36
36
  ### File Lookup List Filter
37
37
 
38
38
  - Collapsable file lookup list filter (CMD+R)
39
- - Semi-fuzzy filtering by ignoring slashes, underscores, and dots to ease lookup
39
+ - Semi-fuzzy filtering by ignoring slashes, underscores, and dots to ease lookup
40
40
 
41
41
  ### Navigation Area
42
42
 
@@ -70,7 +70,7 @@ Gladiator currently supports the following text editing features (including keyb
70
70
 
71
71
  ## Pre-requisites
72
72
 
73
- - [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library): '>= 4.17.2.0', '< 5.0.0.0' (dependency included in Ruby gem).
73
+ - [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Framework): '>= 4.17.2.0', '< 5.0.0.0' (dependency included in Ruby gem).
74
74
  - [JRuby](https://www.jruby.org/download): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt)
75
75
  - [JDK](https://www.oracle.com/java/technologies/javase-downloads.html): Same version required by [Glimmer](https://github.com/AndyObtiva/glimmer-dsl-swt)
76
76
 
@@ -136,7 +136,7 @@ To reuse Gladiator as a Glimmer Custom Shell inside another Glimmer application,
136
136
  following to the application's `Gemfile`:
137
137
 
138
138
  ```
139
- gem 'glimmer-cs-gladiator', '~> 0.6.0'
139
+ gem 'glimmer-cs-gladiator', '~> 0.6.2'
140
140
  ```
141
141
 
142
142
  Run:
@@ -200,6 +200,6 @@ Copyright (c) 2020 Andy Maleh. See [LICENSE.txt](LICENSE.txt) for further detail
200
200
 
201
201
  --
202
202
 
203
- [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Library)
203
+ [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) (JRuby Desktop Development GUI Framework)
204
204
 
205
- Gladiator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
205
+ Gladiator icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
@@ -36,10 +36,7 @@ module Glimmer
36
36
  the_dirty_content.split("\n") # test that it is not a binary file (crashes to rescue block otherwise)
37
37
  self.dirty_content = the_dirty_content
38
38
  observe(self, :caret_position) do |new_caret_position|
39
- new_line_number = line_index_for_caret_position(caret_position) + 1
40
- current_line_number = line_number
41
- self.line_number = new_line_number unless current_line_number && current_line_number == new_line_number
42
- self.line_position = caret_position - caret_position_for_line_index(line_number - 1) + 1
39
+ update_line_number_from_caret_position(new_caret_position)
43
40
  end
44
41
  observe(self, :line_number) do |new_line_number|
45
42
  line_index = line_number - 1
@@ -55,6 +52,16 @@ module Glimmer
55
52
  end
56
53
  end
57
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
+
58
65
  def path=(the_path)
59
66
  @path = the_path
60
67
  generate_display_path
@@ -134,6 +141,7 @@ module Glimmer
134
141
 
135
142
  def change_content!(value)
136
143
  self.dirty_content = value
144
+ update_line_number_from_caret_position(caret_position)
137
145
  end
138
146
 
139
147
  def start_command
@@ -527,7 +535,7 @@ module Glimmer
527
535
  def line_index_for_caret_position(caret_position)
528
536
  dirty_content[0...caret_position.to_i].count("\n")
529
537
  end
530
-
538
+
531
539
  def caret_position_for_line_index(line_index)
532
540
  cp = lines[0...line_index].join("\n").size
533
541
  cp += 1 if line_index > 0
@@ -22,6 +22,7 @@ module Glimmer
22
22
  class << self
23
23
  attr_accessor :drag_and_drop
24
24
  attr_accessor :drag
25
+ attr_accessor :startup
25
26
  end
26
27
 
27
28
  ## Add options like the following to configure CustomShell by outside consumers
@@ -88,7 +89,7 @@ module Glimmer
88
89
  #
89
90
  after_body {
90
91
  observe(project_dir, 'children') do
91
- select_tree_item unless @rename_in_progress
92
+ select_tree_item unless @rename_in_progress || Gladiator.startup
92
93
  end
93
94
  observe(project_dir, 'selected_child') do |selected_file|
94
95
  if selected_file
@@ -99,12 +100,12 @@ module Glimmer
99
100
  @current_tab_folder.swt_widget.setData('proxy', @current_tab_folder)
100
101
  }
101
102
  end
102
- select_tree_item unless @rename_in_progress
103
+ select_tree_item unless @rename_in_progress || Gladiator.startup
103
104
  found_tab_item = selected_tab_item
104
105
  if found_tab_item
105
106
  @current_tab_folder.swt_widget.setSelection(found_tab_item)
106
107
  @current_tab_item = found_tab_item.getData('proxy')
107
- @current_text_editor = found_tab_item.getData('text_editor')
108
+ @current_text_editor = found_tab_item.getData('text_editor') unless found_tab_item.getData('text_editor').nil?
108
109
  @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
109
110
  elsif selected_file
110
111
  @current_tab_folder.content {
@@ -114,19 +115,25 @@ module Glimmer
114
115
  margin_width 0
115
116
  margin_height 0
116
117
  }
117
- @current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
118
- @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
119
- @current_text_editor.text_proxy.content {
120
- on_focus_gained {
121
- tab_folder = the_text_editor.swt_widget.getParent.getParent
122
- @current_tab_folder = tab_folder.getData('proxy')
123
- @current_tab_item = the_tab_item
124
- @current_text_editor = the_text_editor
125
- @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
126
- @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
127
- project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
118
+ tab_folder = nil
119
+ the_text_editor = nil
120
+ the_tab_item.content {
121
+ @current_text_editor = the_text_editor = text_editor(project_dir: project_dir, file: selected_file)
122
+ @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
123
+ the_tab_item.swt_tab_item.setData('text_editor', @current_text_editor)
124
+ @current_text_editor.text_proxy.content {
125
+ on_focus_gained {
126
+ tab_folder = the_text_editor.swt_widget.getParent.getParent
127
+ @current_tab_folder = tab_folder.getData('proxy')
128
+ @current_tab_item = the_tab_item
129
+ @current_text_editor = the_text_editor
130
+ @current_tab_folder.swt_widget.setData('selected_tab_item', @current_tab_item)
131
+ @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
132
+ project_dir.selected_child = @current_tab_item.swt_tab_item.getData('file')
133
+ }
128
134
  }
129
135
  }
136
+
130
137
  on_swt_show {
131
138
  @current_tab_item = the_tab_item
132
139
  @current_text_editor = the_text_editor
@@ -144,7 +151,6 @@ module Glimmer
144
151
  }
145
152
  @current_tab_item.swt_tab_item.setData('file_path', selected_file.path)
146
153
  @current_tab_item.swt_tab_item.setData('file', selected_file)
147
- @current_tab_item.swt_tab_item.setData('text_editor', @current_text_editor)
148
154
  @current_tab_item.swt_tab_item.setData('proxy', @current_tab_item)
149
155
  }
150
156
  @current_tab_folder.swt_widget.setSelection(@current_tab_item.swt_tab_item)
@@ -181,8 +187,19 @@ module Glimmer
181
187
  swt_widget.setLocation(@config[:shell_x], @config[:shell_y]) if @config[:shell_x] && @config[:shell_y]
182
188
  @loaded_config = true
183
189
  }
184
- on_swt_close {
190
+ on_shell_closed {
191
+ save_config
185
192
  project_dir.selected_child&.write_dirty_content
193
+ if @tab_folder2
194
+ current_tab_folder.swt_widget.getItems.each do |tab_item|
195
+ tab_item.getData('proxy')&.dispose
196
+ end
197
+ close_tab_folder
198
+ end
199
+ current_tab_folder.swt_widget.getItems.each do |tab_item|
200
+ tab_item.getData('proxy')&.dispose
201
+ end
202
+ body_root.close unless current_tab_folder.swt_widget.getItems.empty?
186
203
  }
187
204
  on_widget_disposed {
188
205
  project_dir.selected_child&.write_dirty_content
@@ -763,37 +780,55 @@ module Glimmer
763
780
  open_file_paths1.to_a.each do |file_path|
764
781
  async_exec {
765
782
  Gladiator.drag = false
783
+ Gladiator.startup = file_path != open_file_paths1.to_a[-1]
766
784
  project_dir.selected_child_path = file_path
767
785
  }
768
786
  end
769
787
  # TODO replace the next line with one that selects the visible tab
770
788
  async_exec {
771
- Gladiator.drag = false
772
- project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths1.to_a.include?(@config[:selected_child_path])
773
- 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]
774
- project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
789
+ # TODO check why this is not working
790
+ if open_file_paths1.to_a.include?(@config[:selected_child_path])
791
+ Gladiator.drag = false
792
+ Gladiator.startup = false
793
+ project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
794
+ 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]
795
+ project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
796
+ end
775
797
  }
776
798
  async_exec {
777
799
  open_file_paths2.to_a.each do |file_path|
778
800
  async_exec {
779
801
  Gladiator.drag = true
802
+ Gladiator.startup = file_path != open_file_paths2.to_a[-1]
780
803
  project_dir.selected_child_path = file_path
781
804
  }
782
805
  end
783
806
  # TODO replace the next line with one that selects the visible tab
784
807
  async_exec {
785
- Gladiator.drag = true
786
- project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path] && open_file_paths2.to_a.include?(@config[:selected_child_path])
787
- 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]
788
- project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
808
+ # TODO check why this is not working
809
+ if open_file_paths2.to_a.include?(@config[:selected_child_path])
810
+ Gladiator.drag = true
811
+ Gladiator.startup = false
812
+ project_dir.selected_child_path = @config[:selected_child_path] if @config[:selected_child_path]
813
+ 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]
814
+ project_dir.selected_child&.top_pixel = @config[:top_pixel].to_i if @config[:top_pixel]
815
+ end
789
816
  }
790
817
  async_exec {
791
818
  Gladiator.drag = false
792
- @progress_bar_shell.close
819
+ @progress_bar_shell&.close
793
820
  @progress_bar_shell = nil
794
821
  @loaded_config = true
795
822
  }
796
823
  }
824
+ async_exec {
825
+ Thread.new {
826
+ all_files = open_file_paths1.to_a + open_file_paths2.to_a
827
+ all_files.each do |file|
828
+ project_dir.find_child_file(file)&.dirty_content
829
+ end
830
+ }
831
+ }
797
832
  else
798
833
  @loaded_config = true
799
834
  end
@@ -982,6 +1017,7 @@ module Glimmer
982
1017
 
983
1018
  def open_project
984
1019
  selected_directory = directory_dialog.open
1020
+ return if selected_directory.nil?
985
1021
  @progress_bar_shell = shell(body_root, :title) {
986
1022
  text 'Gladiator'
987
1023
  fill_layout(:vertical) {
@@ -1010,11 +1046,18 @@ module Glimmer
1010
1046
 
1011
1047
  def handle_display_shortcut(key_event)
1012
1048
  if key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'f'
1013
- if current_text_editor&.text_widget&.getSelectionText && current_text_editor&.text_widget&.getSelectionText&.size.to_i > 0
1014
- find_text.swt_widget.setText current_text_editor.text_widget.getSelectionText
1015
- end
1016
- find_text.swt_widget.selectAll
1017
- find_text.swt_widget.setFocus
1049
+ @navigation_expand_item.swt_expand_item.set_expanded true
1050
+ @navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
1051
+ async_exec {
1052
+ body_root.pack_same_size
1053
+ }
1054
+ async_exec {
1055
+ if current_text_editor&.text_widget&.getSelectionText && current_text_editor&.text_widget&.getSelectionText&.size.to_i > 0
1056
+ find_text.swt_widget.setText current_text_editor.text_widget.getSelectionText
1057
+ end
1058
+ find_text.swt_widget.selectAll
1059
+ find_text.swt_widget.setFocus
1060
+ }
1018
1061
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'c'
1019
1062
  Clipboard.copy(project_dir.selected_child.path)
1020
1063
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'g'
@@ -1110,12 +1153,34 @@ module Glimmer
1110
1153
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'g'
1111
1154
  project_dir.selected_child.find_next
1112
1155
  elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY) && extract_char(key_event) == 'l'
1113
- line_number_text.swt_widget.selectAll
1114
- line_number_text.swt_widget.setFocus
1156
+ unless @navigation_expand_item.swt_expand_item.get_expanded
1157
+ @navigation_expand_item.swt_expand_item.set_expanded true
1158
+ @navigation_expand_item.swt_expand_item.height = @navigation_expand_item_height if @navigation_expand_item_height
1159
+ async_exec {
1160
+ body_root.pack_same_size
1161
+ }
1162
+ async_exec {
1163
+ line_number_text.swt_widget.selectAll
1164
+ line_number_text.swt_widget.setFocus
1165
+ }
1166
+ else
1167
+ line_number_text.swt_widget.selectAll
1168
+ line_number_text.swt_widget.setFocus
1169
+ end
1115
1170
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'r'
1171
+ unless @file_lookup_expand_item.swt_expand_item.get_expanded
1172
+ @file_lookup_expand_item.swt_expand_item.set_expanded true
1173
+ @file_lookup_expand_item.swt_expand_item.height = @file_lookup_expand_item_height if @file_lookup_expand_item_height
1174
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
1175
+ end
1116
1176
  filter_text.swt_widget.selectAll
1117
1177
  filter_text.swt_widget.setFocus
1118
1178
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 't'
1179
+ unless @file_explorer_expand_item.swt_expand_item.get_expanded
1180
+ @file_explorer_expand_item.swt_expand_item.set_expanded true
1181
+ @file_explorer_expand_item.swt_expand_item.height = @file_explorer_expand_item_height if @file_explorer_expand_item_height
1182
+ @side_bar_sash_form.weights = [@file_lookup_expand_bar_height, @file_explorer_expand_bar_height]
1183
+ end
1119
1184
  select_tree_item unless rename_in_progress
1120
1185
  file_tree.swt_widget.setFocus
1121
1186
  elsif key_event.keyCode == swt(:esc)
@@ -5,60 +5,43 @@ module Glimmer
5
5
 
6
6
  options :file, :project_dir
7
7
 
8
- attr_reader :text_proxy, :text_widget
8
+ attr_reader :text_proxy
9
9
 
10
- before_body {
11
- @is_code_file = file.scratchpad? || file.path.end_with?('.rb')
12
- @text_widget = @is_code_file ? 'code_text' : 'styled_text'
13
- }
14
-
15
10
  after_body {
16
- @text_widget = @text.swt_widget
17
- @text_proxy = @text
11
+ load_content
18
12
  }
19
13
 
20
14
  body {
21
15
  composite {
22
- grid_layout(2, false)
23
- # TODO troubleshoot why adding margin height 0 causes gladiator to start resizing window smaller than necessary upon launch of Gladiator
24
- # {
25
- # margin_height 0
26
- # }
27
-
16
+ grid_layout(2, false)
28
17
  layout_data :fill, :fill, true, true
29
18
  @line_numbers_text = styled_text(:multi, :border) {
30
19
  layout_data(:right, :fill, false, true)
31
-
20
+ text ' '*4
32
21
  font name: 'Consolas', height: OS.mac? ? 15 : 12
33
22
  background color(:widget_background)
34
23
  foreground :dark_blue
35
- text bind(self, 'file.line_numbers_content')
36
- top_pixel bind(self, 'file.top_pixel', read_only: true)
37
24
  top_margin 5
38
25
  right_margin 5
39
26
  bottom_margin 5
40
27
  left_margin 5
41
28
  editable false
42
29
  on_focus_gained {
43
- @text&.swt_widget.setFocus
30
+ @text_proxy&.swt_widget.setFocus
44
31
  }
45
32
  on_key_pressed {
46
- @text&.swt_widget.setFocus
33
+ @text_proxy&.swt_widget.setFocus
47
34
  }
48
35
  on_mouse_up {
49
- @text&.swt_widget.setFocus
36
+ @text_proxy&.swt_widget.setFocus
50
37
  }
51
38
  }
52
39
 
53
- @text = send(@text_widget) {
40
+ @text_proxy = send(text_widget_keyword) { |the_text|
54
41
  layout_data :fill, :fill, true, true
55
42
  font name: 'Consolas', height: OS.mac? ? 15 : 12
56
43
  foreground rgb(75, 75, 75)
57
- text bind(self, 'file.content')
58
44
  focus true
59
- selection_count bind(self, 'file.selection_count')
60
- caret_position bind(self, 'file.caret_position')
61
- top_pixel bind(self, 'file.top_pixel')
62
45
  top_margin 5
63
46
  right_margin 5
64
47
  bottom_margin 5
@@ -76,76 +59,8 @@ module Glimmer
76
59
  }
77
60
  }
78
61
 
79
- on_focus_lost {
80
- file&.write_dirty_content
81
- }
82
- on_verify_key { |key_event|
83
- if (Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'z') || (key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'y')
84
- key_event.doit = !Command.redo(file)
85
- elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'r'
86
- project_dir.selected_child.run
87
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'z'
88
- key_event.doit = !Command.undo(file)
89
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
90
- key_event.widget.selectAll
91
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a'
92
- Command.do(file, :start_of_line)
93
- key_event.doit = false
94
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e'
95
- Command.do(file, :end_of_line)
96
- key_event.doit = false
97
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
98
- Command.do(file, :comment_line!)
99
- key_event.doit = false
100
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'k'
101
- Command.do(file, :kill_line!)
102
- key_event.doit = false
103
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'd'
104
- Command.do(file, :duplicate_line!)
105
- key_event.doit = false
106
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '['
107
- Command.do(file, :outdent!)
108
- key_event.doit = false
109
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == ']'
110
- Command.do(file, :indent!)
111
- key_event.doit = false
112
- elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && key_event.keyCode == swt(:cr)
113
- Command.do(file, :prefix_new_line!)
114
- key_event.doit = false
115
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
116
- Command.do(file, :insert_new_line!)
117
- key_event.doit = false
118
- elsif key_event.keyCode == swt(:page_up)
119
- file.page_up
120
- key_event.doit = false
121
- elsif key_event.keyCode == swt(:page_down)
122
- file.page_down
123
- key_event.doit = false
124
- elsif key_event.keyCode == swt(:home)
125
- file.home
126
- key_event.doit = false
127
- elsif key_event.keyCode == swt(:end)
128
- file.end
129
- key_event.doit = false
130
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_up)
131
- Command.do(file, :move_up!)
132
- key_event.doit = false
133
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_down)
134
- Command.do(file, :move_down!)
135
- key_event.doit = false
136
- end
137
- }
138
- on_verify_text { |verify_event|
139
- # TODO convert these into File commands to support Undo/Redo
140
- case verify_event.text
141
- when "\n"
142
- if file.selection_count.to_i == 0
143
- verify_event.text += file.current_line_indentation
144
- end
145
- when "\t"
146
- Command.do(file, :indent!)
147
- verify_event.doit = false
148
- end
62
+ on_focus_gained {
63
+ load_content
149
64
  }
150
65
  }
151
66
  }
@@ -156,8 +71,114 @@ module Glimmer
156
71
  rescue => e
157
72
  nil
158
73
  end
159
-
74
+
75
+ def text_widget_keyword
76
+ is_code_file = file.scratchpad? || file.path.end_with?('.rb')
77
+ is_code_file ? 'code_text' : 'styled_text'
78
+ end
79
+
80
+ def text_widget
81
+ @text_proxy.swt_widget
82
+ end
83
+
84
+ def load_content
85
+ if !@initialized && !Gladiator.startup
86
+ load_line_numbers_text_content
87
+ load_text_content
88
+ @initialized = true
89
+ end
90
+ end
91
+
92
+ def load_line_numbers_text_content
93
+ @line_numbers_text.content {
94
+ text bind(self, 'file.line_numbers_content')
95
+ top_pixel bind(self, 'file.top_pixel', read_only: true)
96
+ }
97
+ end
98
+
99
+ def load_text_content
100
+ @text_proxy.content {
101
+ text bind(self, 'file.content')
102
+ selection_count bind(self, 'file.selection_count')
103
+ caret_position bind(self, 'file.caret_position')
104
+ top_pixel bind(self, 'file.top_pixel')
105
+ on_focus_lost {
106
+ file&.write_dirty_content
107
+ }
108
+ on_verify_key { |key_event|
109
+ if (Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'z') || (key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'y')
110
+ key_event.doit = !Command.redo(file)
111
+ elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'r'
112
+ project_dir.selected_child.run
113
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'z'
114
+ key_event.doit = !Command.undo(file)
115
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
116
+ key_event.widget.selectAll
117
+ elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a'
118
+ Command.do(file, :start_of_line)
119
+ key_event.doit = false
120
+ elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e'
121
+ Command.do(file, :end_of_line)
122
+ key_event.doit = false
123
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
124
+ Command.do(file, :comment_line!)
125
+ key_event.doit = false
126
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'k'
127
+ Command.do(file, :kill_line!)
128
+ key_event.doit = false
129
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'd'
130
+ Command.do(file, :duplicate_line!)
131
+ key_event.doit = false
132
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '['
133
+ Command.do(file, :outdent!)
134
+ key_event.doit = false
135
+ elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == ']'
136
+ Command.do(file, :indent!)
137
+ key_event.doit = false
138
+ elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && key_event.keyCode == swt(:cr)
139
+ Command.do(file, :prefix_new_line!)
140
+ key_event.doit = false
141
+ elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
142
+ Command.do(file, :insert_new_line!)
143
+ key_event.doit = false
144
+ elsif key_event.keyCode == swt(:page_up)
145
+ file.page_up
146
+ key_event.doit = false
147
+ elsif key_event.keyCode == swt(:page_down)
148
+ file.page_down
149
+ key_event.doit = false
150
+ elsif key_event.keyCode == swt(:home)
151
+ file.home
152
+ key_event.doit = false
153
+ elsif key_event.keyCode == swt(:end)
154
+ file.end
155
+ key_event.doit = false
156
+ elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_up)
157
+ Command.do(file, :move_up!)
158
+ key_event.doit = false
159
+ elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_down)
160
+ Command.do(file, :move_down!)
161
+ key_event.doit = false
162
+ end
163
+ }
164
+ on_verify_text { |verify_event|
165
+ # TODO convert these into File commands to support Undo/Redo
166
+ case verify_event.text
167
+ when "\n"
168
+ if file.selection_count.to_i == 0
169
+ verify_event.text += file.current_line_indentation
170
+ end
171
+ when "\t"
172
+ Command.do(file, :indent!)
173
+ verify_event.doit = false
174
+ end
175
+ }
176
+ }
177
+ end
178
+
160
179
  end
180
+
161
181
  end
182
+
162
183
  end
163
184
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-cs-gladiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
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-24 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement