glimmer-cs-gladiator 0.8.1 → 0.9.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.
@@ -1,64 +1,63 @@
1
- # Copyright (c) 2020-2021 Andy Maleh
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- module Glimmer
23
- class Gladiator
24
- class FileLookupList
25
- include Glimmer::UI::CustomWidget
26
-
27
- options :gladiator, :foreground_color
28
-
29
- body {
30
- list(:border, :h_scroll, :v_scroll) {
31
- selection bind(project_dir, :filtered_path)
32
- # visible bind(project_dir, 'filter') {|f| pd swt_widget&.get_shell&.get_data('proxy'); swt_widget&.get_shell&.get_data('proxy')&.pack_same_size; !!f}
33
- foreground foreground_color
34
- on_mouse_up {
35
- project_dir.selected_child_path = swt_widget.getSelection.first
36
- }
37
- on_key_pressed { |key_event|
38
- if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
39
- project_dir.selected_child_path = swt_widget.getSelection.first
40
- current_text_editor&.text_widget&.setFocus
41
- end
42
- }
43
- drag_source(DND::DROP_COPY) {
44
- transfer :text
45
- on_drag_set_data { |event|
46
- Gladiator.drag = true
47
- list = event.widget.getControl
48
- event.data = list.getSelection.first
49
- }
50
- }
51
- }
52
- }
53
-
54
- def project_dir
55
- gladiator.project_dir
56
- end
57
-
58
- def current_text_editor
59
- gladiator.current_text_editor
60
- end
61
-
62
- end
63
- end
64
- end
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ module Glimmer
23
+ class Gladiator
24
+ class FileLookupList
25
+ include Glimmer::UI::CustomWidget
26
+
27
+ options :gladiator, :foreground_color
28
+
29
+ body {
30
+ list(:border, :h_scroll, :v_scroll) {
31
+ selection bind(project_dir, :filtered_path)
32
+ foreground foreground_color
33
+ on_mouse_up {
34
+ project_dir.selected_child_path = swt_widget.getSelection.first
35
+ }
36
+ on_key_pressed { |key_event|
37
+ if Glimmer::SWT::SWTProxy.include?(key_event.keyCode, :cr)
38
+ project_dir.selected_child_path = swt_widget.getSelection.first
39
+ current_text_editor&.text_widget&.setFocus
40
+ end
41
+ }
42
+ drag_source(DND::DROP_COPY) {
43
+ transfer :text
44
+ on_drag_set_data { |event|
45
+ Gladiator.drag = true
46
+ list = event.widget.getControl
47
+ event.data = list.getSelection.first
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ def project_dir
54
+ gladiator.project_dir
55
+ end
56
+
57
+ def current_text_editor
58
+ gladiator.current_text_editor
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -32,7 +32,7 @@ module Glimmer
32
32
  text '&File'
33
33
 
34
34
  menu_item {
35
- text 'New &Scratchpad'
35
+ text 'Open &Scratchpad'
36
36
  accelerator COMMAND_KEY, :shift, :s
37
37
  enabled editing
38
38
  on_widget_selected {
@@ -49,7 +49,7 @@ module Glimmer
49
49
  menu_item(:separator)
50
50
  menu_item {
51
51
  text '&Quit Project'
52
- accelerator COMMAND_KEY, :alt, :q
52
+ accelerator :alt, :f4
53
53
  on_widget_selected {
54
54
  gladiator.save_config
55
55
  project_dir.selected_child&.write_dirty_content
@@ -58,6 +58,7 @@ module Glimmer
58
58
  }
59
59
  }
60
60
  if editing
61
+ file_edit_menu(gladiator: gladiator)
61
62
  menu {
62
63
  text '&View'
63
64
  menu {
@@ -154,12 +155,8 @@ module Glimmer
154
155
  begin
155
156
  project_dir.selected_child.run
156
157
  rescue Exception => e
157
- dialog {
158
- text 'Run - Ruby - Error Encountered!'
159
- label {
160
- text e.full_message
161
- }
162
- }.open
158
+ Glimmer::Config.logger.error {e.full_message}
159
+ error_dialog(message: e.full_message).open
163
160
  end
164
161
  }
165
162
  }
@@ -182,6 +179,36 @@ module Glimmer
182
179
  gladiator.project_dir
183
180
  end
184
181
 
182
+ # Method-based error_dialog custom widget
183
+ def error_dialog(message:)
184
+ return if message.nil?
185
+ dialog(gladiator) { |dialog_proxy|
186
+ row_layout(:vertical) {
187
+ center true
188
+ }
189
+
190
+ text 'Error Launching'
191
+
192
+ styled_text(:border, :h_scroll, :v_scroll) {
193
+ layout_data {
194
+ width gladiator.bounds.width*0.75
195
+ height gladiator.bounds.height*0.75
196
+ }
197
+
198
+ text message
199
+ editable false
200
+ caret nil
201
+ }
202
+
203
+ button {
204
+ text 'Close'
205
+
206
+ on_widget_selected {
207
+ dialog_proxy.close
208
+ }
209
+ }
210
+ }
211
+ end
185
212
  end
186
213
 
187
214
  end
@@ -1,31 +1,29 @@
1
- module Glimmer
2
- class Gladiator
3
- class ProgressShell
4
- include Glimmer::UI::CustomShell
5
-
6
- option :gladiator
7
- option :progress_text, default: 'Work In Progress'
8
-
9
- body {
10
- shell(gladiator.body_root, :title) {
11
- fill_layout(:vertical) {
12
- margin_width 15
13
- margin_height 15
14
- spacing 5
15
- }
16
-
17
- text 'Gladiator'
18
-
19
- gladiator_menu_bar(gladiator: gladiator, editing: true)
20
-
21
- label(:center) {
22
- text progress_text
23
- font height: 20
24
- }
25
- # @progress_bar = progress_bar(:horizontal, :indeterminate)
26
- }
27
- }
28
-
29
- end
30
- end
31
- end
1
+ module Glimmer
2
+ class Gladiator
3
+ class ProgressShell
4
+ include Glimmer::UI::CustomShell
5
+
6
+ option :gladiator
7
+ option :progress_text, default: 'Work In Progress'
8
+
9
+ body {
10
+ shell(gladiator.body_root, :title) {
11
+ fill_layout(:vertical) {
12
+ margin_width 15
13
+ margin_height 15
14
+ spacing 5
15
+ }
16
+
17
+ text 'Gladiator'
18
+
19
+ label(:center) {
20
+ text progress_text
21
+ font height: 20
22
+ }
23
+ # @progress_bar = progress_bar(:horizontal, :indeterminate)
24
+ }
25
+ }
26
+
27
+ end
28
+ end
29
+ end
@@ -71,6 +71,9 @@ module Glimmer
71
71
  right_margin 5
72
72
  bottom_margin 5
73
73
  left_margin 5
74
+
75
+ file_edit_menu(file: file)
76
+
74
77
  drop_target(DND::DROP_COPY) {
75
78
  transfer [TextTransfer.getInstance].to_java(Transfer)
76
79
  on_drag_enter { |event|
@@ -139,6 +142,12 @@ module Glimmer
139
142
  elsif (OS.mac? && key_event.keyCode == swt(:home)) || (!OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :ctrl) && key_event.keyCode == swt(:end))
140
143
  file.end
141
144
  key_event.doit = false
145
+ elsif !OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :shift) && key_event.keyCode == swt(:home)
146
+ file.select_to_start_of_line
147
+ key_event.doit = false
148
+ elsif !OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :shift) && key_event.keyCode == swt(:end)
149
+ file.select_to_end_of_line
150
+ key_event.doit = false
142
151
  elsif (OS.mac? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a') || (!OS.mac? && key_event.keyCode == swt(:home))
143
152
  file.start_of_line
144
153
  key_event.doit = false
@@ -187,6 +196,8 @@ module Glimmer
187
196
  if file.selection_count.to_i == 0
188
197
  verify_event.text += file.current_line_indentation
189
198
  end
199
+ # TODO implement this to borrowed line of code from Glimmer Meta-Sample
200
+ # verify_event.text += ' '*2 if line.strip.end_with?('{') || line.strip.match(/do[ ]+([|][^|]+[|])?$/) || line.start_with?('class') || line.start_with?('module') || line.strip.start_with?('def')
190
201
  when "\t"
191
202
  Command.do(file, :indent!)
192
203
  verify_event.doit = false