Skip to content

Commit

Permalink
Refactoring in meta-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyObtiva committed Oct 21, 2020
1 parent 8d8bed7 commit d27f24b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 44 deletions.
19 changes: 1 addition & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ GEM
jwt (2.2.2)
kamelcase (0.0.2)
semver2 (~> 3)
kramdown (2.3.0)
rexml
little-plugger (1.1.4)
logging (2.3.0)
little-plugger (~> 1.1)
Expand Down Expand Up @@ -90,7 +88,6 @@ GEM
tty-prompt
rchardet (1.8.0)
rdoc (6.2.1)
rexml (3.2.4)
rouge (3.24.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
Expand All @@ -113,11 +110,6 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
simplecov-lcov (0.7.0)
strings (0.2.0)
strings-ansi (~> 0.2)
unicode-display_width (~> 1.5)
unicode_utils (~> 1.4)
strings-ansi (0.2.0)
super_module (1.4.1)
method_source (>= 0.8.2, < 1.1.0)
sync (0.5.0)
Expand All @@ -131,13 +123,6 @@ GEM
sync
tty-color (0.5.2)
tty-cursor (0.7.1)
tty-markdown (0.7.0)
kramdown (>= 1.16.2, < 3.0)
pastel (~> 0.8)
rouge (~> 3.14)
strings (~> 0.2.0)
tty-color (~> 0.5)
tty-screen (~> 0.8)
tty-prompt (0.22.0)
pastel (~> 0.8)
tty-reader (~> 0.8)
Expand All @@ -146,8 +131,6 @@ GEM
tty-screen (~> 0.8)
wisper (~> 2.0)
tty-screen (0.8.1)
unicode-display_width (1.7.0)
unicode_utils (1.4.0)
warbler (2.0.5)
jruby-jars (>= 9.0.0.0)
jruby-rack (>= 1.1.1, < 1.3)
Expand All @@ -170,13 +153,13 @@ DEPENDENCIES
puts_debuggerer (~> 0.10.2)
rake (>= 10.1.0, < 14.0.0)
rake-tui (>= 0.2.3, < 2.0.0)
rouge (>= 3.23.0, < 4.0.0)
rspec (~> 3.5.0)
rspec-mocks (~> 3.5.0)
simplecov (~> 0.16.1)
simplecov-lcov (~> 0.7.0)
super_module (~> 1.4.1)
text-table (>= 1.2.4, < 2.0.0)
tty-markdown (>= 0.6.0, < 2.0.0)
warbler (>= 2.0.5, < 3.0.0)

RUBY VERSION
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Here is a list of tasks to do (moved to [CHANGELOG.md](CHANGELOG.md) once done).

## Next

- Document code_text in README
- Document sash_form in README
- Update documentation with regards to how to run samples (removing references to sample:run)
- Document a third way of creating custom widgets (extending a standard WidgetProxy)

## Soon

Expand Down
14 changes: 8 additions & 6 deletions glimmer-dsl-swt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: glimmer-dsl-swt 4.17.3.0 ruby lib
# stub: glimmer-dsl-swt 4.17.4.0 ruby lib

Gem::Specification.new do |s|
s.name = "glimmer-dsl-swt".freeze
s.version = "4.17.3.0"
s.version = "4.17.4.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["AndyMaleh".freeze]
s.date = "2020-10-18"
s.date = "2020-10-21"
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Library)".freeze
s.email = "andy.am@gmail.com".freeze
s.executables = ["glimmer".freeze, "girb".freeze]
Expand Down Expand Up @@ -81,10 +81,10 @@ Gem::Specification.new do |s|
"lib/glimmer/rake_task.rb",
"lib/glimmer/rake_task/list.rb",
"lib/glimmer/rake_task/package.rb",
"lib/glimmer/rake_task/sample.rb",
"lib/glimmer/rake_task/scaffold.rb",
"lib/glimmer/swt/color_proxy.rb",
"lib/glimmer/swt/cursor_proxy.rb",
"lib/glimmer/swt/custom/code_text.rb",
"lib/glimmer/swt/display_proxy.rb",
"lib/glimmer/swt/dnd_proxy.rb",
"lib/glimmer/swt/font_proxy.rb",
Expand All @@ -94,6 +94,7 @@ Gem::Specification.new do |s|
"lib/glimmer/swt/menu_proxy.rb",
"lib/glimmer/swt/message_box_proxy.rb",
"lib/glimmer/swt/packages.rb",
"lib/glimmer/swt/sash_form_proxy.rb",
"lib/glimmer/swt/scrolled_composite_proxy.rb",
"lib/glimmer/swt/shell_proxy.rb",
"lib/glimmer/swt/style_constantizable.rb",
Expand Down Expand Up @@ -130,6 +131,7 @@ Gem::Specification.new do |s|
"samples/hello/hello_pop_up_context_menu.rb",
"samples/hello/hello_tab.rb",
"samples/hello/hello_world.rb",
"samples/meta_sample.rb",
"vendor/swt/linux/swt.jar",
"vendor/swt/mac/swt.jar",
"vendor/swt/windows/swt.jar"
Expand All @@ -155,7 +157,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
s.add_runtime_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
s.add_runtime_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
s.add_runtime_dependency(%q<tty-markdown>.freeze, [">= 0.6.0", "< 2.0.0"])
s.add_runtime_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
s.add_development_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
s.add_development_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
Expand All @@ -174,7 +176,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<os>.freeze, [">= 1.0.0", "< 2.0.0"])
s.add_dependency(%q<rake>.freeze, [">= 10.1.0", "< 14.0.0"])
s.add_dependency(%q<text-table>.freeze, [">= 1.2.4", "< 2.0.0"])
s.add_dependency(%q<tty-markdown>.freeze, [">= 0.6.0", "< 2.0.0"])
s.add_dependency(%q<rouge>.freeze, [">= 3.23.0", "< 4.0.0"])
s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9", "< 3.0.0"])
s.add_dependency(%q<warbler>.freeze, [">= 2.0.5", "< 3.0.0"])
s.add_dependency(%q<rspec-mocks>.freeze, ["~> 3.5.0"])
Expand Down
40 changes: 20 additions & 20 deletions lib/glimmer/swt/custom/code_text.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ module Custom
# CodeText is a customization of StyledText with support for Ruby Syntax Highlighting
class CodeText
include Glimmer::UI::CustomWidget
extend Glimmer

SYNTAX_COLOR_MAP = {
Builtin: rgb(215,58,73),
Class: rgb(3,47,98),
Constant: rgb(0,92,197),
Double: rgb(0,92,197),
Escape: color(:red),
Function: color(:blue),
Instance: rgb(227,98,9),
Integer: color(:blue),
Interpol: color(:blue),
Keyword: color(:blue),
Name: rgb(111,66,193), #purple
Operator: color(:red),
Pseudo: color(:dark_red),
Punctuation: color(:blue),
Single: rgb(106,115,125), # Also, Comments
Symbol: color(:dark_green),
Text: rgb(75, 75, 75),
Builtin: [215,58,73],
Class: [3,47,98],
Constant: [0,92,197],
Double: [0,92,197],
Escape: [:red],
Function: [:blue],
Instance: [227,98,9],
Integer: [:blue],
Interpol: [:blue],
Keyword: [:blue],
Name: [111,66,193], #purple
Operator: [:red],
Pseudo: [:dark_red],
Punctuation: [:blue],
Single: [106,115,125], # Also, Comments
Symbol: [:dark_green],
Text: [75, 75, 75],
}

# TODO support `option :language`
Expand Down Expand Up @@ -59,7 +58,7 @@ def syntax_highlighting

body {
styled_text(swt_style) {
font name: 'Lucida Console', height: 16
font name: 'Consolas', height: 15
foreground rgb(75, 75, 75)
left_margin 5
top_margin 5
Expand All @@ -73,7 +72,8 @@ def syntax_highlighting
if token_hash[:token_index] >= line_style_event.lineOffset && token_hash[:token_index] < (line_style_event.lineOffset + line_style_event.lineText.size)
start_index = token_hash[:token_index]
size = token_hash[:token_text].size
token_color = (SYNTAX_COLOR_MAP[token_hash[:token_type].name] || color(:black)).swt_color
token_color = SYNTAX_COLOR_MAP[token_hash[:token_type].name] || [:black]
token_color = color(*token_color).swt_color
styles << StyleRange.new(start_index, size, token_color, nil)
end
end
Expand Down

0 comments on commit d27f24b

Please sign in to comment.