glimmer-cs-gladiator 0.7.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ module Glimmer
2
+ class Gladiator
3
+ class FileEditMenu
4
+ include Glimmer::UI::CustomWidget
5
+
6
+ # Either receives a gladiator instance for menu bar parent or file instance for text editor parent
7
+ options :gladiator, :file
8
+
9
+ body {
10
+ menu { |menu_proxy|
11
+ text '&Edit' unless menu_proxy.swt_menu_item.nil? # unless used on the text editor directly
12
+
13
+ menu_item {
14
+ text '&Undo'
15
+ # TODO disable if not undoable
16
+
17
+ on_widget_selected {
18
+ Command.undo(current_file)
19
+ }
20
+ }
21
+ menu_item {
22
+ text '&Redo'
23
+ # TODO disable if not redoable
24
+
25
+ on_widget_selected {
26
+ Command.redo(current_file)
27
+ }
28
+ }
29
+ menu_item(:separator)
30
+ menu_item {
31
+ text 'Cu&t'
32
+
33
+ on_widget_selected {
34
+ Command.do(current_file, :cut!)
35
+ }
36
+ }
37
+ menu_item {
38
+ text '&Copy'
39
+
40
+ on_widget_selected {
41
+ current_file.copy
42
+ }
43
+ }
44
+ menu_item {
45
+ text '&Paste'
46
+
47
+ on_widget_selected {
48
+ Command.do(current_file, :paste!)
49
+ }
50
+ }
51
+ menu_item(:separator)
52
+ menu_item {
53
+ text 'Select &All'
54
+
55
+ on_widget_selected {
56
+ current_file.select_all
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ def current_file
63
+ file.nil? ? gladiator.project_dir.selected_child : file
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,216 @@
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 GladiatorMenuBar
25
+ include Glimmer::UI::CustomWidget
26
+
27
+ options :gladiator, :editing
28
+
29
+ body {
30
+ menu_bar {
31
+ menu {
32
+ text '&File'
33
+
34
+ menu_item {
35
+ text 'Open &Scratchpad'
36
+ accelerator COMMAND_KEY, :shift, :s
37
+ enabled editing
38
+ on_widget_selected {
39
+ project_dir.selected_child_path = ''
40
+ }
41
+ }
42
+ menu_item {
43
+ text 'Open &Project...'
44
+ accelerator COMMAND_KEY, :o
45
+ on_widget_selected {
46
+ gladiator.open_project
47
+ }
48
+ }
49
+ menu_item(:separator)
50
+ menu_item {
51
+ text '&Quit Project'
52
+ accelerator COMMAND_KEY, :alt, :q
53
+ on_widget_selected {
54
+ gladiator.save_config
55
+ project_dir.selected_child&.write_dirty_content
56
+ gladiator.body_root.close
57
+ }
58
+ }
59
+ }
60
+ if editing
61
+ file_edit_menu(gladiator: gladiator)
62
+ menu {
63
+ text '&View'
64
+ menu {
65
+ text '&Split Pane'
66
+ menu { |menu_proxy|
67
+ text '&Orientation'
68
+ menu_item(:radio) {
69
+ text '&Horizontal'
70
+ selection bind(gladiator, :split_orientation,
71
+ on_read: ->(o) { gladiator.split_pane? && o == swt(:horizontal) },
72
+ on_write: ->(b) { b.nil? ? nil : (b ? swt(:horizontal) : swt(:vertical)) })
73
+ }
74
+ menu_item(:radio) {
75
+ text '&Vertical'
76
+ selection bind(gladiator, :split_orientation,
77
+ on_read: ->(o) { gladiator.split_pane? && o == swt(:vertical) },
78
+ on_write: ->(b) { b.nil? ? nil : (b ? swt(:vertical) : swt(:horizontal)) })
79
+ }
80
+ }
81
+ menu_item(:check) {
82
+ text '&Maximize Pane'
83
+ enabled bind(gladiator, :tab_folder2)
84
+ accelerator COMMAND_KEY, :shift, :m
85
+ selection bind(gladiator, :maximized_pane)
86
+ }
87
+ menu_item {
88
+ text 'Reset &Panes'
89
+ enabled bind(gladiator, :tab_folder2)
90
+ accelerator COMMAND_KEY, :shift, :p
91
+ on_widget_selected {
92
+ if gladiator.tab_folder2
93
+ gladiator.maximized_pane = false
94
+ gladiator.tab_folder_sash_form.weights = [1, 1]
95
+ end
96
+ }
97
+ }
98
+ menu_item {
99
+ text '&Unsplit'
100
+ enabled bind(gladiator, :tab_folder2)
101
+ accelerator COMMAND_KEY, :shift, :u
102
+ on_widget_selected {
103
+ if gladiator.tab_folder2
104
+ gladiator.maximized_pane = false
105
+ gladiator.navigate_to_next_tab_folder if gladiator.current_tab_folder != gladiator.tab_folder2
106
+ gladiator.close_all_tabs(gladiator.tab_folder2)
107
+ gladiator.split_orientation = nil
108
+ gladiator.body_root.pack_same_size
109
+ end
110
+ }
111
+ }
112
+ }
113
+ menu_item(:check) {
114
+ text '&Maximize Editor'
115
+ accelerator COMMAND_KEY, CONTROL_KEY, :m
116
+ selection bind(gladiator, :maximized_editor)
117
+ }
118
+ menu_item {
119
+ text '&Reset All'
120
+ accelerator COMMAND_KEY, CONTROL_KEY, :r
121
+ on_widget_selected {
122
+ gladiator.maximized_editor = false
123
+ gladiator.file_area_and_editor_area_sash_form.weights = [1, 5]
124
+ gladiator.side_bar_sash_form.weights = [1, 1]
125
+ unless gladiator.file_lookup_expand_item.swt_expand_item.get_expanded
126
+ gladiator.file_lookup_expand_item.swt_expand_item.set_expanded true
127
+ gladiator.file_lookup_expand_item.swt_expand_item.height = gladiator.file_lookup_expand_item_height if gladiator.file_lookup_expand_item_height
128
+ end
129
+ unless gladiator.file_explorer_expand_item.swt_expand_item.get_expanded
130
+ gladiator.file_explorer_expand_item.swt_expand_item.set_expanded true
131
+ gladiator.file_explorer_expand_item.swt_expand_item.height = gladiator.file_explorer_expand_item_height if gladiator.file_explorer_expand_item_height
132
+ end
133
+ }
134
+ }
135
+ }
136
+ menu {
137
+ text '&Run'
138
+ # menu_item {
139
+ # text 'Launch Glimmer &App'
140
+ # on_widget_selected {
141
+ # parent_path = project_dir.path
142
+ ## current_directory_name = ::File.basename(parent_path)
143
+ ## assumed_shell_script = ::File.join(parent_path, 'bin', current_directory_name)
144
+ ## assumed_shell_script = ::Dir.glob(::File.join(parent_path, 'bin', '*')).detect {|f| ::File.file?(f) && !::File.read(f).include?('#!/usr/bin/env')} if !::File.exist?(assumed_shell_script)
145
+ ## load assumed_shell_script
146
+ # FileUtils.cd(parent_path) do
147
+ # system 'glimmer run'
148
+ # end
149
+ # }
150
+ # }
151
+ menu_item {
152
+ text '&Ruby'
153
+ accelerator COMMAND_KEY, :shift, :r
154
+ on_widget_selected {
155
+ begin
156
+ project_dir.selected_child.run
157
+ rescue Exception => e
158
+ Glimmer::Config.logger.error {e.full_message}
159
+ error_dialog(message: e.full_message).open
160
+ end
161
+ }
162
+ }
163
+ }
164
+ end
165
+ menu {
166
+ text '&Help'
167
+ menu_item {
168
+ text '&About'
169
+ accelerator COMMAND_KEY, :shift, :a
170
+ on_widget_selected {
171
+ gladiator.display_about_dialog
172
+ }
173
+ }
174
+ }
175
+ }
176
+ }
177
+
178
+ def project_dir
179
+ gladiator.project_dir
180
+ end
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
212
+ end
213
+
214
+ end
215
+
216
+ end
@@ -0,0 +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
+ 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
@@ -39,7 +39,7 @@ module Glimmer
39
39
  body {
40
40
  composite {
41
41
  grid_layout(2, false)
42
- layout_data :fill, :fill, true, true
42
+
43
43
  @line_numbers_text = styled_text(:multi, :border) {
44
44
  layout_data(:right, :fill, false, true)
45
45
  text ' '*4
@@ -62,7 +62,7 @@ module Glimmer
62
62
  }
63
63
  }
64
64
 
65
- @text_proxy = send(text_widget_keyword) { |the_text|
65
+ @text_proxy = code_text(language: file.language) {
66
66
  layout_data :fill, :fill, true, true
67
67
  font name: @font_name, height: OS.mac? ? 15 : 12
68
68
  foreground rgb(75, 75, 75)
@@ -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|
@@ -97,11 +100,6 @@ module Glimmer
97
100
  nil
98
101
  end
99
102
 
100
- def text_widget_keyword
101
- is_code_file = file.scratchpad? || file.path.end_with?('.rb')
102
- is_code_file ? 'code_text' : 'styled_text'
103
- end
104
-
105
103
  def text_widget
106
104
  @text_proxy.swt_widget
107
105
  end
@@ -127,6 +125,7 @@ module Glimmer
127
125
  selection_count bind(self, 'file.selection_count')
128
126
  caret_position bind(self, 'file.caret_position')
129
127
  top_pixel bind(self, 'file.top_pixel')
128
+ # key_binding swt(:ctrl, :home), ST::TEXT_START # This seems to make the caret disappear on Windows so disabling for now and relying on key event instead
130
129
  on_focus_lost {
131
130
  file&.write_dirty_content
132
131
  }
@@ -137,11 +136,23 @@ module Glimmer
137
136
  key_event.doit = !Command.undo(file)
138
137
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
139
138
  key_event.widget.selectAll
140
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a'
141
- Command.do(file, :start_of_line)
139
+ elsif (OS.mac? && key_event.keyCode == swt(:home)) || (!OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :ctrl) && key_event.keyCode == swt(:home))
140
+ file.home
141
+ key_event.doit = false
142
+ elsif (OS.mac? && key_event.keyCode == swt(:home)) || (!OS.mac? && Glimmer::SWT::SWTProxy.include?(key_event.stateMask, :ctrl) && key_event.keyCode == swt(:end))
143
+ file.end
142
144
  key_event.doit = false
143
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e'
144
- Command.do(file, :end_of_line)
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
151
+ elsif (OS.mac? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a') || (!OS.mac? && key_event.keyCode == swt(:home))
152
+ file.start_of_line
153
+ key_event.doit = false
154
+ elsif (OS.mac? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e') || (!OS.mac? && key_event.keyCode == swt(:end))
155
+ file.end_of_line
145
156
  key_event.doit = false
146
157
  elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
147
158
  Command.do(file, :comment_line!)
@@ -170,12 +181,6 @@ module Glimmer
170
181
  elsif key_event.keyCode == swt(:page_down)
171
182
  file.page_down
172
183
  key_event.doit = false
173
- elsif key_event.keyCode == swt(:home)
174
- file.home
175
- key_event.doit = false
176
- elsif key_event.keyCode == swt(:end)
177
- file.end
178
- key_event.doit = false
179
184
  elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_up)
180
185
  Command.do(file, :move_up!)
181
186
  key_event.doit = false
@@ -191,6 +196,8 @@ module Glimmer
191
196
  if file.selection_count.to_i == 0
192
197
  verify_event.text += file.current_line_indentation
193
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')
194
201
  when "\t"
195
202
  Command.do(file, :indent!)
196
203
  verify_event.doit = false
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.7.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-17 00:00:00.000000000 Z
11
+ date: 2021-03-04 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.18.0.2
18
+ version: 4.18.4.3
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.18.0.2
29
+ version: 4.18.4.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
88
  version: 2.3.9
89
+ - !ruby/object:Gem::Dependency
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '='
93
+ - !ruby/object:Gem::Version
94
+ version: 2.0.5
95
+ name: warbler
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '='
101
+ - !ruby/object:Gem::Version
102
+ version: 2.0.5
89
103
  - !ruby/object:Gem::Dependency
90
104
  requirement: !ruby/object:Gem::Requirement
91
105
  requirements:
@@ -108,7 +122,9 @@ description: Gladiator (short for Glimmer Editor) is a Glimmer sample project un
108
122
  use Glimmer one day.
109
123
  email: andy.am@gmail.com
110
124
  executables:
125
+ - glimmer-cs-gladiator
111
126
  - gladiator
127
+ - gladiator-setup
112
128
  extensions: []
113
129
  extra_rdoc_files:
114
130
  - LICENSE.txt
@@ -119,22 +135,30 @@ files:
119
135
  - README.md
120
136
  - VERSION
121
137
  - bin/gladiator
122
- - bin/gladiator_runner.rb
138
+ - bin/gladiator-setup
139
+ - bin/glimmer-cs-gladiator
123
140
  - glimmer-cs-gladiator.gemspec
124
141
  - images/glimmer-cs-gladiator-logo.png
125
142
  - lib/glimmer-cs-gladiator.rb
143
+ - lib/glimmer-cs-gladiator/launch.rb
126
144
  - lib/models/glimmer/gladiator/command.rb
127
145
  - lib/models/glimmer/gladiator/dir.rb
128
146
  - lib/models/glimmer/gladiator/file.rb
129
147
  - lib/views/glimmer/gladiator.rb
148
+ - lib/views/glimmer/gladiator/file_edit_menu.rb
130
149
  - lib/views/glimmer/gladiator/file_explorer_tree.rb
131
150
  - lib/views/glimmer/gladiator/file_lookup_list.rb
151
+ - lib/views/glimmer/gladiator/gladiator_menu_bar.rb
152
+ - lib/views/glimmer/gladiator/progress_shell.rb
132
153
  - lib/views/glimmer/gladiator/text_editor.rb
133
154
  homepage: http://github.com/AndyObtiva/glimmer-cs-gladiator
134
155
  licenses:
135
156
  - MIT
136
157
  metadata: {}
137
- post_install_message:
158
+ post_install_message: |2+
159
+
160
+ To make the gladiator command available system-wide (especially with RVM), make sure you run this command with jruby in path: gladiator-setup
161
+
138
162
  rdoc_options: []
139
163
  require_paths:
140
164
  - lib