glimmer-dsl-swt 4.18.7.2 → 4.18.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +31 -0
- data/README.md +113 -17
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_COMMAND.md +82 -5
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +3 -5
- data/glimmer-dsl-swt.gemspec +10 -9
- data/lib/glimmer/data_binding/widget_binding.rb +1 -1
- data/lib/glimmer/rake_task.rb +36 -6
- data/lib/glimmer/rake_task/list.rb +8 -0
- data/lib/glimmer/rake_task/scaffold.rb +103 -0
- data/lib/glimmer/swt/custom/code_text.rb +19 -3
- data/lib/glimmer/swt/custom/shape.rb +366 -198
- data/lib/glimmer/swt/custom/shape/image.rb +7 -9
- data/lib/glimmer/swt/custom/shape/path.rb +1 -5
- data/lib/glimmer/swt/custom/shape/polygon.rb +24 -8
- data/lib/glimmer/swt/custom/shape/polyline.rb +5 -0
- data/lib/glimmer/swt/custom/shape/rectangle.rb +10 -19
- data/lib/glimmer/swt/image_proxy.rb +5 -1
- data/samples/elaborate/tetris.rb +1 -15
- data/samples/elaborate/tetris/model/game.rb +3 -0
- data/samples/elaborate/tetris/view/bevel.rb +81 -0
- data/samples/elaborate/tetris/view/block.rb +5 -30
- data/samples/hello/hello_code_text.rb +141 -73
- metadata +7 -6
@@ -34,13 +34,9 @@ module Glimmer
|
|
34
34
|
class Shape
|
35
35
|
class Image < Shape
|
36
36
|
def parameter_names
|
37
|
-
|
38
|
-
image_part_parameter_names
|
39
|
-
else
|
40
|
-
image_whole_parameter_names
|
41
|
-
end
|
37
|
+
@parameter_names || image_whole_parameter_names
|
42
38
|
end
|
43
|
-
|
39
|
+
|
44
40
|
def possible_parameter_names
|
45
41
|
(image_part_parameter_names + image_whole_parameter_names).uniq
|
46
42
|
end
|
@@ -53,13 +49,15 @@ module Glimmer
|
|
53
49
|
[:image, :x, :y]
|
54
50
|
end
|
55
51
|
|
56
|
-
def
|
52
|
+
def set_parameter_attribute(attribute_name, *args)
|
53
|
+
return super if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
|
57
54
|
####TODO refactor and improve this method through meta-programming (and share across other shapes)
|
58
55
|
if image_part_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
59
|
-
image_part_parameter_names
|
56
|
+
@parameter_names = image_part_parameter_names
|
60
57
|
elsif image_whole_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
61
|
-
image_whole_parameter_names
|
58
|
+
@parameter_names = image_whole_parameter_names
|
62
59
|
end
|
60
|
+
super
|
63
61
|
end
|
64
62
|
|
65
63
|
def x
|
@@ -112,11 +112,7 @@ module Glimmer
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
def
|
116
|
-
super
|
117
|
-
end
|
118
|
-
|
119
|
-
def calculated_args
|
115
|
+
def calculate_args!
|
120
116
|
new_swt_path = @swt_path.nil? || !@calculated_paint_args || !@calculated_path_args
|
121
117
|
if new_swt_path
|
122
118
|
Glimmer::SWT::DisplayProxy.instance.auto_exec do
|
@@ -119,16 +119,28 @@ module Glimmer
|
|
119
119
|
|
120
120
|
# Logical x coordinate relative to parent
|
121
121
|
def x
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
x_dependencies = [bounds.x, parent.is_a?(Shape) && parent.absolute_x]
|
123
|
+
if x_dependencies != @x_dependencies
|
124
|
+
# avoid recalculating values
|
125
|
+
bounds_x, parent_absolute_x = @x_dependencies = x_dependencies
|
126
|
+
x_value = bounds_x
|
127
|
+
x_value -= parent_absolute_x if parent.is_a?(Shape)
|
128
|
+
@x = x_value
|
129
|
+
end
|
130
|
+
@x
|
125
131
|
end
|
126
132
|
|
127
133
|
# Logical y coordinate relative to parent
|
128
134
|
def y
|
129
|
-
|
130
|
-
|
131
|
-
|
135
|
+
y_dependencies = [bounds.y, parent.is_a?(Shape) && parent.absolute_y]
|
136
|
+
if y_dependencies != @y_dependencies
|
137
|
+
# avoid recalculating values
|
138
|
+
bounds_y, parent_absolute_y = @y_dependencies = y_dependencies
|
139
|
+
y_value = bounds_y
|
140
|
+
y_value -= parent_absolute_y if parent.is_a?(Shape)
|
141
|
+
@y = y_value
|
142
|
+
end
|
143
|
+
@y
|
132
144
|
end
|
133
145
|
|
134
146
|
def width
|
@@ -144,8 +156,12 @@ module Glimmer
|
|
144
156
|
end
|
145
157
|
|
146
158
|
def include?(x, y)
|
147
|
-
|
148
|
-
|
159
|
+
if filled?
|
160
|
+
contain?(x, y)
|
161
|
+
else
|
162
|
+
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
|
163
|
+
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
|
164
|
+
end
|
149
165
|
end
|
150
166
|
|
151
167
|
def move_by(x_delta, y_delta)
|
@@ -42,19 +42,23 @@ module Glimmer
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def point_count
|
45
|
+
point_array = args.size > 1 ? args : self.point_array
|
45
46
|
point_array.count / 2
|
46
47
|
end
|
47
48
|
|
48
49
|
def [](index)
|
50
|
+
point_array = args.size > 1 ? args : self.point_array
|
49
51
|
index = 0 if index == point_count
|
50
52
|
org.eclipse.swt.graphics.Point.new(point_array[index * 2], point_array[index * 2 + 1])
|
51
53
|
end
|
52
54
|
|
53
55
|
def x_array
|
56
|
+
point_array = args.size > 1 ? args : self.point_array
|
54
57
|
point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
|
55
58
|
end
|
56
59
|
|
57
60
|
def y_array
|
61
|
+
point_array = args.size > 1 ? args : self.point_array
|
58
62
|
point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
|
59
63
|
end
|
60
64
|
|
@@ -63,6 +67,7 @@ module Glimmer
|
|
63
67
|
end
|
64
68
|
|
65
69
|
def absolute_point_array
|
70
|
+
point_array = args.size > 1 ? args : self.point_array
|
66
71
|
if parent.is_a?(Shape)
|
67
72
|
point_array.each_with_index.map do |coordinate, i|
|
68
73
|
if i.even?
|
@@ -23,7 +23,6 @@ require 'glimmer/swt/custom/shape'
|
|
23
23
|
require 'glimmer/swt/swt_proxy'
|
24
24
|
require 'glimmer/swt/display_proxy'
|
25
25
|
require 'glimmer/swt/color_proxy'
|
26
|
-
require 'glimmer/swt/font_proxy'
|
27
26
|
require 'glimmer/swt/transform_proxy'
|
28
27
|
|
29
28
|
module Glimmer
|
@@ -34,16 +33,7 @@ module Glimmer
|
|
34
33
|
class Shape
|
35
34
|
class Rectangle < Shape
|
36
35
|
def parameter_names
|
37
|
-
|
38
|
-
if @args.to_a.size >= 6
|
39
|
-
rectangle_round_parameter_names
|
40
|
-
elsif @args.to_a.size == 5
|
41
|
-
rectangle_gradient_parameter_names
|
42
|
-
elsif @args.to_a.size == 1
|
43
|
-
rectangle_rectangle_parameter_names
|
44
|
-
else
|
45
|
-
rectangle_parameter_names
|
46
|
-
end
|
36
|
+
@parameter_names || rectangle_parameter_names
|
47
37
|
end
|
48
38
|
|
49
39
|
def possible_parameter_names
|
@@ -68,17 +58,18 @@ module Glimmer
|
|
68
58
|
[:rectangle]
|
69
59
|
end
|
70
60
|
|
71
|
-
def
|
72
|
-
|
73
|
-
if
|
74
|
-
|
61
|
+
def set_parameter_attribute(attribute_name, *args)
|
62
|
+
return super if @parameter_names.to_a.map(&:to_s).include?(attribute_name.to_s)
|
63
|
+
if rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
64
|
+
@parameter_names = rectangle_parameter_names
|
65
|
+
elsif rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
66
|
+
@parameter_names = rectangle_round_parameter_names
|
75
67
|
elsif rectangle_gradient_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
76
|
-
rectangle_gradient_parameter_names
|
77
|
-
elsif rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
78
|
-
rectangle_parameter_names.map(&:to_s).index(attribute_name.to_s)
|
68
|
+
@parameter_names = rectangle_gradient_parameter_names
|
79
69
|
elsif rectangle_rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
|
80
|
-
rectangle_rectangle_parameter_names
|
70
|
+
@parameter_names = rectangle_rectangle_parameter_names
|
81
71
|
end
|
72
|
+
super
|
82
73
|
end
|
83
74
|
|
84
75
|
def point_xy_array
|
@@ -57,7 +57,7 @@ module Glimmer
|
|
57
57
|
include_package 'org.eclipse.swt.widgets'
|
58
58
|
include_package 'org.eclipse.swt.graphics'
|
59
59
|
|
60
|
-
attr_reader :file_path, :jar_file_path, :image_data, :swt_image
|
60
|
+
attr_reader :file_path, :jar_file_path, :image_data, :swt_image, :parent_proxy, :parent
|
61
61
|
|
62
62
|
# Initializes a proxy for an SWT Image object
|
63
63
|
#
|
@@ -141,6 +141,10 @@ module Glimmer
|
|
141
141
|
self
|
142
142
|
end
|
143
143
|
|
144
|
+
def size
|
145
|
+
org.eclipse.swt.graphics.Point.new(bounds.width, bounds.height)
|
146
|
+
end
|
147
|
+
|
144
148
|
def gc
|
145
149
|
@gc ||= reset_gc
|
146
150
|
end
|
data/samples/elaborate/tetris.rb
CHANGED
@@ -156,21 +156,7 @@ class Tetris
|
|
156
156
|
color = colored ? color(([:white] + Model::Tetromino::LETTER_COLORS.values).sample) : color(:white)
|
157
157
|
x = column * icon_block_size
|
158
158
|
y = row * icon_block_size
|
159
|
-
|
160
|
-
background color
|
161
|
-
}
|
162
|
-
polygon(x, y, x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
|
163
|
-
background rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
164
|
-
}
|
165
|
-
polygon(x + icon_block_size, y, x + icon_block_size - icon_bevel_pixel_size, y + icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size, y + icon_block_size) {
|
166
|
-
background rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
167
|
-
}
|
168
|
-
polygon(x + icon_block_size, y + icon_block_size, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_block_size - icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size) {
|
169
|
-
background rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
170
|
-
}
|
171
|
-
polygon(x, y, x, y + icon_block_size, x + icon_bevel_pixel_size, y + icon_block_size - icon_bevel_pixel_size, x + icon_bevel_pixel_size, y + icon_bevel_pixel_size) {
|
172
|
-
background rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
173
|
-
}
|
159
|
+
bevel(x: x, y: y, base_color: color, size: icon_block_size)
|
174
160
|
}
|
175
161
|
}
|
176
162
|
}
|
@@ -33,6 +33,8 @@ class Tetris
|
|
33
33
|
class Game
|
34
34
|
PLAYFIELD_WIDTH = 10
|
35
35
|
PLAYFIELD_HEIGHT = 20
|
36
|
+
# PLAYFIELD_WIDTH = 5
|
37
|
+
# PLAYFIELD_HEIGHT = 5
|
36
38
|
PREVIEW_PLAYFIELD_WIDTH = 4
|
37
39
|
PREVIEW_PLAYFIELD_HEIGHT = 2
|
38
40
|
SCORE_MULTIPLIER = {1 => 40, 2 => 100, 3 => 300, 4 => 1200}
|
@@ -199,6 +201,7 @@ class Tetris
|
|
199
201
|
|
200
202
|
def delay
|
201
203
|
[1.1 - (level.to_i * 0.1), 0.001].max
|
204
|
+
# 99999
|
202
205
|
end
|
203
206
|
|
204
207
|
def beep
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Copyright (c) 2007-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
|
+
# Creates a class-based custom shape representing the `bevel` keyword by convention
|
23
|
+
class Tetris
|
24
|
+
module View
|
25
|
+
class Bevel
|
26
|
+
include Glimmer::UI::CustomShape
|
27
|
+
|
28
|
+
options :base_color, :size, :bevel_pixel_size
|
29
|
+
option :x, default: 0
|
30
|
+
option :y, default: 0
|
31
|
+
|
32
|
+
before_body {
|
33
|
+
self.bevel_pixel_size = 0.16*size.to_f if bevel_pixel_size.nil?
|
34
|
+
}
|
35
|
+
|
36
|
+
body {
|
37
|
+
rectangle(x, y, size, size) {
|
38
|
+
background bind(self, :base_color)
|
39
|
+
polygon(0, 0, size, 0, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
40
|
+
background bind(self, :base_color) { |color_value|
|
41
|
+
unless color_value.nil?
|
42
|
+
color = color(color_value)
|
43
|
+
rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
44
|
+
end
|
45
|
+
}
|
46
|
+
}
|
47
|
+
polygon(size, 0, size - bevel_pixel_size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size, size) {
|
48
|
+
background bind(self, :base_color) { |color_value|
|
49
|
+
unless color_value.nil?
|
50
|
+
color = color(color_value)
|
51
|
+
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
52
|
+
end
|
53
|
+
}
|
54
|
+
}
|
55
|
+
polygon(size, size, 0, size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size) {
|
56
|
+
background bind(self, :base_color) { |color_value|
|
57
|
+
unless color_value.nil?
|
58
|
+
color = color(color_value)
|
59
|
+
rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
60
|
+
end
|
61
|
+
}
|
62
|
+
}
|
63
|
+
polygon(0, 0, 0, size, bevel_pixel_size, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
64
|
+
background bind(self, :base_color) { |color_value|
|
65
|
+
unless color_value.nil?
|
66
|
+
color = color(color_value)
|
67
|
+
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
68
|
+
end
|
69
|
+
}
|
70
|
+
}
|
71
|
+
rectangle(0, 0, size, size) {
|
72
|
+
foreground bind(self, :base_color) { |color_value|
|
73
|
+
# use gray instead of white for the border
|
74
|
+
color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -19,6 +19,8 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require_relative 'bevel'
|
23
|
+
|
22
24
|
class Tetris
|
23
25
|
module View
|
24
26
|
class Block
|
@@ -27,36 +29,9 @@ class Tetris
|
|
27
29
|
options :game_playfield, :block_size, :row, :column
|
28
30
|
|
29
31
|
body {
|
30
|
-
canvas {
|
31
|
-
|
32
|
-
|
33
|
-
background bind(game_playfield[row][column], :color) { |color_value|
|
34
|
-
color = color(color_value)
|
35
|
-
rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
36
|
-
}
|
37
|
-
}
|
38
|
-
polygon(block_size, 0, block_size - 4, 4, block_size - 4, block_size - 4, block_size, block_size) {
|
39
|
-
background bind(game_playfield[row][column], :color) { |color_value|
|
40
|
-
color = color(color_value)
|
41
|
-
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
42
|
-
}
|
43
|
-
}
|
44
|
-
polygon(block_size, block_size, 0, block_size, 4, block_size - 4, block_size - 4, block_size - 4) {
|
45
|
-
background bind(game_playfield[row][column], :color) { |color_value|
|
46
|
-
color = color(color_value)
|
47
|
-
rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
48
|
-
}
|
49
|
-
}
|
50
|
-
polygon(0, 0, 0, block_size, 4, block_size - 4, 4, 4) {
|
51
|
-
background bind(game_playfield[row][column], :color) { |color_value|
|
52
|
-
color = color(color_value)
|
53
|
-
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
54
|
-
}
|
55
|
-
}
|
56
|
-
rectangle(0, 0, block_size, block_size) {
|
57
|
-
foreground bind(game_playfield[row][column], :color) { |color_value|
|
58
|
-
color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
|
59
|
-
}
|
32
|
+
canvas { |canvas_proxy|
|
33
|
+
bevel(size: block_size) {
|
34
|
+
base_color bind(game_playfield[row][column], :color)
|
60
35
|
}
|
61
36
|
}
|
62
37
|
}
|
@@ -21,86 +21,154 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
shell {
|
27
|
-
minimum_size 640, 480
|
28
|
-
text 'Hello, Code Text!'
|
24
|
+
class HelloCodeText
|
25
|
+
include Glimmer::UI::CustomShell
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
27
|
+
attr_accessor :ruby_code, :js_code, :html_code
|
28
|
+
|
29
|
+
before_body {
|
30
|
+
self.ruby_code = <<~RUBY
|
31
|
+
greeting = 'Hello, World!'
|
32
|
+
|
33
|
+
include Glimmer
|
34
|
+
|
35
|
+
shell {
|
36
|
+
text 'Glimmer'
|
37
|
+
|
38
|
+
label {
|
39
|
+
text greeting
|
40
|
+
font height: 30, style: :bold
|
41
|
+
}
|
42
|
+
}.open
|
43
|
+
RUBY
|
44
|
+
|
45
|
+
self.js_code = <<~JS
|
46
|
+
function greet(greeting) {
|
47
|
+
alert(greeting);
|
49
48
|
}
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
49
|
+
|
50
|
+
var greetingString = 'Hello, World!';
|
51
|
+
|
52
|
+
greet(greetingString);
|
53
|
+
|
54
|
+
var moreGreetings = ['Howdy!', 'Aloha!', 'Hey!']
|
55
|
+
|
56
|
+
for(var greeting of moreGreetings) {
|
57
|
+
greet(greeting)
|
58
|
+
}
|
59
|
+
JS
|
60
|
+
|
61
|
+
self.html_code = <<~HTML
|
62
|
+
<html>
|
63
|
+
<body>
|
64
|
+
<section class="accordion">
|
65
|
+
<form method="post" id="name">
|
66
|
+
<label for="name">
|
67
|
+
Name
|
68
|
+
</label>
|
69
|
+
<input name="name" type="text" />
|
70
|
+
<input type="submit" />
|
71
|
+
</form>
|
72
|
+
</section>
|
73
|
+
</body>
|
74
|
+
</html>
|
75
|
+
HTML
|
76
|
+
}
|
77
|
+
|
78
|
+
body {
|
79
|
+
shell {
|
80
|
+
minimum_size 640, 480
|
81
|
+
text 'Hello, Code Text!'
|
82
|
+
|
83
|
+
tab_folder {
|
84
|
+
tab_item {
|
85
|
+
fill_layout
|
86
|
+
text 'Ruby (glimmer)'
|
87
|
+
code_text(language: 'ruby', theme: 'glimmer', lines: true) {
|
88
|
+
text bind(self, :ruby_code)
|
60
89
|
}
|
61
|
-
background :white
|
62
90
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
91
|
+
tab_item {
|
92
|
+
fill_layout
|
93
|
+
text 'Ruby (pastie)'
|
94
|
+
code_text(language: 'ruby', theme: 'pastie', lines: {width: 2}) {
|
95
|
+
text bind(self, :ruby_code)
|
96
|
+
}
|
66
97
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
98
|
+
tab_item {
|
99
|
+
fill_layout
|
100
|
+
text 'Ruby (github)'
|
101
|
+
code_text(language: 'ruby', theme: 'github', lines: false) {
|
102
|
+
text bind(self, :ruby_code)
|
70
103
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
104
|
+
}
|
105
|
+
tab_item {
|
106
|
+
fill_layout
|
107
|
+
text 'JavaScript (glimmer)'
|
108
|
+
# No border (SWT styles are passed explicitly)
|
109
|
+
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'glimmer', lines: true) {
|
110
|
+
# With lines, the custom widget has a root composite, which can be configured separately
|
111
|
+
root {
|
112
|
+
grid_layout(2, false) {
|
113
|
+
margin_width 2
|
114
|
+
}
|
115
|
+
background :white
|
116
|
+
}
|
117
|
+
# With lines, the line numbers widget can be configured separately
|
118
|
+
line_numbers {
|
119
|
+
background :white
|
120
|
+
}
|
121
|
+
text bind(self, :js_code)
|
80
122
|
}
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
123
|
+
}
|
124
|
+
tab_item {
|
125
|
+
fill_layout
|
126
|
+
text 'JavaScript (pastie)'
|
127
|
+
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', lines: {width: 2}) {
|
128
|
+
root {
|
129
|
+
grid_layout(2, false) {
|
130
|
+
margin_width 2
|
131
|
+
}
|
132
|
+
background :white
|
133
|
+
}
|
134
|
+
line_numbers {
|
135
|
+
background :white
|
136
|
+
}
|
137
|
+
text bind(self, :js_code)
|
138
|
+
}
|
139
|
+
}
|
140
|
+
tab_item {
|
141
|
+
fill_layout
|
142
|
+
text 'JavaScript (github)'
|
143
|
+
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'github') { # default is lines: false
|
144
|
+
text bind(self, :js_code)
|
145
|
+
}
|
146
|
+
}
|
147
|
+
tab_item {
|
148
|
+
fill_layout
|
149
|
+
text 'HTML (glimmer)'
|
150
|
+
code_text(language: 'html', theme: 'glimmer', lines: true) {
|
151
|
+
text bind(self, :html_code)
|
152
|
+
}
|
153
|
+
}
|
154
|
+
tab_item {
|
155
|
+
fill_layout
|
156
|
+
text 'HTML (pastie)'
|
157
|
+
code_text(language: 'html', theme: 'pastie', lines: {width: 2}) {
|
158
|
+
text bind(self, :html_code)
|
159
|
+
}
|
160
|
+
}
|
161
|
+
tab_item {
|
162
|
+
fill_layout
|
163
|
+
text 'HTML (github)'
|
164
|
+
code_text(language: 'html', theme: 'github') { # default is lines: false
|
165
|
+
text bind(self, :html_code)
|
166
|
+
}
|
167
|
+
}
|
103
168
|
}
|
104
169
|
}
|
105
170
|
}
|
106
|
-
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
HelloCodeText.launch
|