glimmer-cs-gladiator 0.5.3 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,53 +5,47 @@ 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 {
16
+ grid_layout(2, false)
22
17
  layout_data :fill, :fill, true, true
23
- grid_layout 2, false
24
18
  @line_numbers_text = styled_text(:multi, :border) {
25
19
  layout_data(:right, :fill, false, true)
20
+ text ' '*4
26
21
  font name: 'Consolas', height: OS.mac? ? 15 : 12
27
22
  background color(:widget_background)
28
- foreground rgb(0, 0, 250)
29
- text bind(self, 'file.line_numbers_content')
30
- top_pixel bind(self, 'file.top_pixel', read_only: true)
23
+ foreground :dark_blue
31
24
  top_margin 5
32
25
  right_margin 5
33
26
  bottom_margin 5
34
27
  left_margin 5
35
28
  editable false
36
29
  on_focus_gained {
37
- @text&.swt_widget.setFocus
30
+ @text_proxy&.swt_widget.setFocus
38
31
  }
39
32
  on_key_pressed {
40
- @text&.swt_widget.setFocus
33
+ @text_proxy&.swt_widget.setFocus
41
34
  }
42
35
  on_mouse_up {
43
- @text&.swt_widget.setFocus
36
+ @text_proxy&.swt_widget.setFocus
44
37
  }
45
38
  }
46
39
 
47
- @text = send(@text_widget) {
40
+ @text_proxy = send(text_widget_keyword) { |the_text|
48
41
  layout_data :fill, :fill, true, true
49
42
  font name: 'Consolas', height: OS.mac? ? 15 : 12
50
43
  foreground rgb(75, 75, 75)
51
- text bind(self, 'file.content')
52
44
  focus true
53
- selection bind(self, 'file.selection')
54
- top_pixel bind(self, 'file.top_pixel')
45
+ top_margin 5
46
+ right_margin 5
47
+ bottom_margin 5
48
+ left_margin 5
55
49
  drop_target(DND::DROP_COPY) {
56
50
  transfer [TextTransfer.getInstance].to_java(Transfer)
57
51
  on_drag_enter { |event|
@@ -65,92 +59,126 @@ module Glimmer
65
59
  }
66
60
  }
67
61
 
68
- on_focus_lost {
69
- file&.write_dirty_content
70
- }
71
- on_verify_key { |key_event|
72
- 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')
73
- key_event.doit = !Command.redo(file)
74
- elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && extract_char(key_event) == 'r'
75
- project_dir.selected_child.run
76
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'z'
77
- key_event.doit = !Command.undo(file)
78
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'a'
79
- key_event.widget.selectAll
80
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'a'
81
- Command.do(file, :start_of_line)
82
- key_event.doit = false
83
- elsif !OS.windows? && key_event.stateMask == swt(:ctrl) && extract_char(key_event) == 'e'
84
- Command.do(file, :end_of_line)
85
- key_event.doit = false
86
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '/'
87
- Command.do(file, :comment_line!)
88
- key_event.doit = false
89
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'k'
90
- Command.do(file, :kill_line!)
91
- key_event.doit = false
92
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == 'd'
93
- Command.do(file, :duplicate_line!)
94
- key_event.doit = false
95
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == '['
96
- Command.do(file, :outdent!)
97
- key_event.doit = false
98
- elsif key_event.stateMask == swt(COMMAND_KEY) && extract_char(key_event) == ']'
99
- Command.do(file, :indent!)
100
- key_event.doit = false
101
- elsif Glimmer::SWT::SWTProxy.include?(key_event.stateMask, COMMAND_KEY, :shift) && key_event.keyCode == swt(:cr)
102
- Command.do(file, :prefix_new_line!)
103
- key_event.doit = false
104
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:cr)
105
- Command.do(file, :insert_new_line!)
106
- key_event.doit = false
107
- elsif key_event.keyCode == swt(:page_up)
108
- file.page_up
109
- key_event.doit = false
110
- elsif key_event.keyCode == swt(:page_down)
111
- file.page_down
112
- key_event.doit = false
113
- elsif key_event.keyCode == swt(:home)
114
- file.home
115
- key_event.doit = false
116
- elsif key_event.keyCode == swt(:end)
117
- file.end
118
- key_event.doit = false
119
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_up)
120
- Command.do(file, :move_up!)
121
- key_event.doit = false
122
- elsif key_event.stateMask == swt(COMMAND_KEY) && key_event.keyCode == swt(:arrow_down)
123
- Command.do(file, :move_down!)
124
- key_event.doit = false
125
- end
126
- }
127
- on_verify_text { |verify_event|
128
- # TODO convert these into File commands to support Undo/Redo
129
- case verify_event.text
130
- when "\n"
131
- if file.selection_count.to_i == 0
132
- verify_event.text += file.current_line_indentation
133
- end
134
- 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
141
- end
62
+ on_focus_gained {
63
+ load_content
142
64
  }
143
65
  }
144
66
  }
145
67
  }
146
-
68
+
147
69
  def extract_char(event)
148
70
  event.keyCode.chr
149
71
  rescue => e
150
72
  nil
151
73
  end
152
-
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
+
153
179
  end
180
+
154
181
  end
182
+
155
183
  end
156
184
 
metadata CHANGED
@@ -1,32 +1,32 @@
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.6.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: 2020-11-05 00:00:00.000000000 Z
11
+ date: 2020-12-29 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.3
19
19
  - - "<"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 5.0.0.0
22
22
  name: glimmer-dsl-swt
23
- prerelease: false
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.17.8.3
29
+ version: 4.17.10.3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 5.0.0.0
@@ -37,8 +37,8 @@ dependencies:
37
37
  - !ruby/object:Gem::Version
38
38
  version: 1.1.1
39
39
  name: filewatcher
40
- prerelease: false
41
40
  type: :runtime
41
+ prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
@@ -49,15 +49,15 @@ 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
- prerelease: false
55
54
  type: :runtime
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
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:
@@ -65,8 +65,8 @@ dependencies:
65
65
  - !ruby/object:Gem::Version
66
66
  version: 3.5.0
67
67
  name: rspec
68
- prerelease: false
69
68
  type: :development
69
+ prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
@@ -79,8 +79,8 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: 2.3.9
81
81
  name: jeweler
82
- prerelease: false
83
82
  type: :development
83
+ prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - '='
@@ -93,8 +93,8 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  name: simplecov
96
- prerelease: false
97
96
  type: :development
97
+ prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
@@ -114,11 +114,14 @@ extra_rdoc_files:
114
114
  - LICENSE.txt
115
115
  - README.md
116
116
  files:
117
+ - CHANGELOG.md
117
118
  - LICENSE.txt
118
119
  - README.md
119
120
  - VERSION
120
121
  - bin/gladiator
121
122
  - bin/gladiator_runner.rb
123
+ - glimmer-cs-gladiator.gemspec
124
+ - images/glimmer-cs-gladiator-logo.png
122
125
  - lib/glimmer-cs-gladiator.rb
123
126
  - lib/models/glimmer/gladiator/command.rb
124
127
  - lib/models/glimmer/gladiator/dir.rb
@@ -144,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
147
  - !ruby/object:Gem::Version
145
148
  version: '0'
146
149
  requirements: []
147
- rubygems_version: 3.1.4
150
+ rubygems_version: 3.0.6
148
151
  signing_key:
149
152
  specification_version: 4
150
153
  summary: Gladiator (Glimmer Editor) - Glimmer Custom Shell