coloration 0.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "coloration"
4
+
5
+ Coloration::Converters::Textmate2JEditConverter.process_cmd_line
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "coloration"
4
+
5
+ Coloration::Converters::Textmate2KatePartConverter.process_cmd_line
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "coloration"
4
+
5
+ Coloration::Converters::Textmate2VimConverter.process_cmd_line
@@ -0,0 +1,17 @@
1
+ require 'color'
2
+
3
+ require "coloration/version.rb"
4
+ require "coloration/extensions.rb"
5
+ require "coloration/style.rb"
6
+ require "coloration/abstract_converter.rb"
7
+ require "coloration/color_rgba.rb"
8
+
9
+ require "coloration/readers/textmate_theme_reader.rb"
10
+
11
+ require "coloration/writers/jedit_theme_writer.rb"
12
+ require "coloration/writers/katepart_theme_writer.rb"
13
+ require "coloration/writers/vim_theme_writer.rb"
14
+
15
+ require "coloration/converters/textmate2jedit.rb"
16
+ require "coloration/converters/textmate2katepart.rb"
17
+ require "coloration/converters/textmate2vim.rb"
@@ -0,0 +1,34 @@
1
+ module Coloration
2
+ module Converters
3
+ class AbstractConverter
4
+ attr_accessor :name, :ui, :items, :input, :result
5
+ class << self; attr_reader :in_theme_type; end
6
+
7
+ def self.process_cmd_line
8
+ if ARGV.size > 0
9
+ converter = self.new
10
+ converter.feed(File.read(ARGV[0]))
11
+ out_filename = ARGV[1] || ARGV[0].gsub(/\.#{@in_theme_ext}$/, ".#{@out_theme_ext}")
12
+ converter.convert!
13
+ File.open(out_filename, "w") { |f| f.write(converter.result) }
14
+ else
15
+ puts "#{File.basename($0)} <in #{@in_theme_type} theme> [out #{@out_theme_type} theme]"
16
+ end
17
+ end
18
+
19
+ def feed(data)
20
+ self.input = data
21
+ end
22
+
23
+ def convert!
24
+ parse_input
25
+ build_result
26
+ end
27
+
28
+ protected
29
+ def comment_text
30
+ "Converted from #{self.class.in_theme_type} theme #{name} using Coloration v#{VERSION} (http://github.com/sickill/coloration)"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ class Color::RGBA < Color::RGB
2
+ def self.from_html(col, bg)
3
+ if col.size > 7 # we have color with alpha channel
4
+ alpha = (100 * ((col[-2..-1]).to_i(16) / 255.0)).to_i
5
+ color = super(col[0..-3])
6
+ color.mix_with(bg, alpha)
7
+ else
8
+ super(col)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module Coloration
2
+ module Converters
3
+ class Textmate2JEditConverter < AbstractConverter
4
+ @in_theme_type = "Textmate"
5
+ @in_theme_ext = "tmTheme"
6
+ @out_theme_type = "JEdit"
7
+ @out_theme_ext = "jedit-scheme"
8
+ include Readers::TextMateThemeReader
9
+ include Writers::JEditThemeWriter
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Coloration
2
+ module Converters
3
+ class Textmate2KatePartConverter < AbstractConverter
4
+ @in_theme_type = "Textmate"
5
+ @in_theme_ext = "tmTheme"
6
+ @out_theme_type = "KatePart"
7
+ @out_theme_ext = "txt"
8
+ include Readers::TextMateThemeReader
9
+ include Writers::KatePartThemeWriter
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module Coloration
2
+ module Converters
3
+ class Textmate2VimConverter < AbstractConverter
4
+ @in_theme_type = "Textmate"
5
+ @in_theme_ext = "tmTheme"
6
+ @out_theme_type = "Vim"
7
+ @out_theme_ext = "vim"
8
+ include Readers::TextMateThemeReader
9
+ include Writers::VimThemeWriter
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ class Object
2
+ def blank?
3
+ false
4
+ end
5
+
6
+ def try(*args)
7
+ send(*args) if respond_to?(args.first)
8
+ end
9
+ end
10
+
11
+ class String
12
+ def blank?
13
+ self.strip == ""
14
+ end
15
+ end
16
+
17
+ class NilClass
18
+ def blank?
19
+ true
20
+ end
21
+ end
22
+
23
+ class FalseClass
24
+ def to_i
25
+ 0
26
+ end
27
+ end
28
+
29
+ class TrueClass
30
+ def to_i
31
+ 1
32
+ end
33
+ end
@@ -0,0 +1,68 @@
1
+ require 'plist'
2
+ require 'textpow'
3
+
4
+ module Coloration
5
+ module Readers
6
+ module TextMateThemeReader
7
+ class InvalidThemeError < RuntimeError; end
8
+
9
+ def parse_input
10
+ tm_theme = Plist.parse_xml(input.gsub("ustring", "string"))
11
+ raise InvalidThemeError if tm_theme.nil?
12
+ self.name = tm_theme["name"]
13
+ settings = tm_theme["settings"]
14
+
15
+ self.ui = settings.delete_at(0)["settings"]
16
+ bg = Color::RGB.from_html(ui["background"][0..6])
17
+ ui.each do |key, value|
18
+ ui[key] = Color::RGBA.from_html(value, bg)
19
+ end
20
+ ui["background"] = bg
21
+
22
+ items = {}
23
+ settings.each do |rule|
24
+ selectors = rule["scope"]
25
+ style = rule["settings"]
26
+ if font_style = style.delete("fontStyle")
27
+ if font_style.include?("bold")
28
+ style[:bold] = true
29
+ end
30
+ if font_style.include?("italic")
31
+ style[:italic] = true
32
+ end
33
+ if font_style.include?("underline")
34
+ style[:underline] = true
35
+ end
36
+ end
37
+ style = Style.new(style, bg)
38
+ unless selectors.blank? || style.blank?
39
+ selectors.split(",").each do |selector|
40
+ items[selector.strip] = style
41
+ end
42
+ end
43
+ end
44
+ self.items = ItemsLookup.new(items)
45
+ end
46
+ end
47
+
48
+ class ItemsLookup
49
+ def initialize(items)
50
+ @items = items
51
+ @score_manager = Textpow::ScoreManager.new
52
+ end
53
+
54
+ def [](key)
55
+ best_selector = nil
56
+ best_score = 0
57
+ @items.keys.each do |selector|
58
+ score = @score_manager.score(selector, key)
59
+ if score > best_score
60
+ best_score, best_selector = score, selector
61
+ end
62
+ end
63
+ best_selector && @items[best_selector]
64
+ end
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,37 @@
1
+ module Coloration
2
+
3
+ class Style
4
+ attr_accessor :foreground, :background, :bold, :italic, :underline, :strike, :inverse
5
+
6
+ def initialize(obj=nil, bg=nil)
7
+ if obj
8
+ case obj
9
+ when String
10
+ initialize_from_hash({ :foreground => obj }, bg)
11
+ when Hash
12
+ initialize_from_hash(obj, bg)
13
+ end
14
+ end
15
+ end
16
+
17
+ def initialize_from_hash(h, bg=nil)
18
+ h.each do |key, value|
19
+ if value.is_a?(String)
20
+ value = Color::RGBA.from_html(value, bg)
21
+ end
22
+ if key == :fg
23
+ key = :foreground
24
+ end
25
+ if key == :bg
26
+ key = :background
27
+ end
28
+ send("#{key}=", value)
29
+ end
30
+ end
31
+
32
+ def blank?
33
+ foreground.nil? && background.nil?
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ module Coloration
2
+ VERSION = "0.1".freeze
3
+ end
@@ -0,0 +1,94 @@
1
+ module Coloration
2
+ module Writers
3
+ module JEditThemeWriter
4
+
5
+ def build_result
6
+ add_line(format_comment(comment_text))
7
+ add_line
8
+
9
+ ui_mapping = {
10
+ "scheme.name" => @name,
11
+ "view.fgColor" => @ui["foreground"],
12
+ "view.bgColor" => @ui["background"],
13
+ "view.caretColor" => @ui["caret"],
14
+ "view.selectionColor" => @ui["selection"],
15
+ "view.eolMarkerColor" => @ui["invisibles"],
16
+ "view.lineHighlightColor" => @ui["lineHighlight"],
17
+ }
18
+
19
+ ui_mapping.keys.each do |key|
20
+ add_line(format_ui(key, ui_mapping[key]))
21
+ end
22
+
23
+ items_mapping = {
24
+ "view.style.comment1" => @items["comment"], # #foo
25
+ "view.style.literal1" => @items["string"], # "foo"
26
+ "view.style.label" => @items["constant.other.symbol"], # :foo
27
+ "view.style.digit" => @items["constant.numeric"], # 123
28
+ "view.style.keyword1" => @items["keyword.control"], # class, def, if, end
29
+ "view.style.keyword2" => @items["support.function"], # require, include
30
+ "view.style.keyword3" => @items["constant.language"], # true, false, nil
31
+ "view.style.keyword4" => @items["variable.other"], # @foo
32
+ "view.style.operator" => @items["keyword.operator"], # = < + -
33
+ "view.style.function" => @items["entity.name.function"], # def foo
34
+ "view.style.literal3" => @items["string.regexp"], # /jola/
35
+ # "view.style.invalid" => @items["invalid"], # errors etc
36
+ #"view.style.literal4" => :constant # MyClass, USER_SPACE
37
+ "view.style.markup" => @items["meta.tag"] || @items["entity.name.tag"] # <div>
38
+ #TODO: gutter etc
39
+ }
40
+
41
+ default_style = Style.new
42
+ default_style.foreground = @ui["foreground"]
43
+ items_mapping.keys.each do |key|
44
+ add_line(format_item(key, items_mapping[key] || default_style))
45
+ end
46
+
47
+ self.result = @lines.join("\n")
48
+ end
49
+
50
+ protected
51
+
52
+ def add_line(line="")
53
+ (@lines ||= []) << line
54
+ end
55
+
56
+ def escape(value)
57
+ value.gsub(':', '\:').gsub('#', '\#').strip
58
+ end
59
+
60
+ def format_ui(name, value)
61
+ case value
62
+ when Color::RGB
63
+ value = value.html
64
+ else
65
+ value = value.to_s
66
+ end
67
+ "#{name}=#{escape(value)}"
68
+ end
69
+
70
+ def format_item(name, style)
71
+ raise RuntimeError.new("Style for #{name} is missing!") if style.nil?
72
+ "#{name}=#{format_style(style)}"
73
+ end
74
+
75
+ def format_style(style)
76
+ s = ""
77
+ s << " color:#{style.foreground.html}" if style.foreground
78
+ s << " bgColor:#{style.background.html}" if style.background
79
+ if s.size > 0
80
+ s << " style:"
81
+ s << "b" if style.bold
82
+ s << "u" if style.underline
83
+ s << "i" if style.italic
84
+ end
85
+ escape(s)
86
+ end
87
+
88
+ def format_comment(text)
89
+ "\# #{text}"
90
+ end
91
+
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,158 @@
1
+ module Coloration
2
+ module Writers
3
+ module KatePartThemeWriter
4
+
5
+ def build_result
6
+ add_comment comment_text
7
+ add_comment "-" * 20 + " Put following in katesyntaxhighlightingrc " + "-" * 20
8
+ add_line
9
+
10
+ add_line "[Default Item Styles - Schema #{name}]"
11
+
12
+ @default_style = Style.new
13
+ @default_style.foreground = @ui["foreground"]
14
+
15
+ items_mapping = {
16
+ "Alert" => @items["invalid"],
17
+ "Base-N Integer" => @items["constant.numeric"],
18
+ "Character" => @items["keyword.operator"],
19
+ "Comment" => @items["comment"],
20
+ "Data Type" => @items["entity.name.type"] || @items["entity.name.class"],
21
+ "Decimal/Value" => @items["constant.numeric"],
22
+ "Error" => @items["invalid"],
23
+ "Floating Point" => @items["constant.numeric"],
24
+ "Function" => @items["entity.name.function"],
25
+ "Keyword" => @items["keyword"],
26
+ "Normal" => nil,
27
+ "Others" => nil,
28
+ "Region Marker" => nil,
29
+ "String" => @items["string"]
30
+ }
31
+
32
+ items_mapping.keys.each do |key|
33
+ add_line(format_item(key, items_mapping[key] || @default_style))
34
+ end
35
+
36
+ add_line
37
+
38
+ add_line "[Highlighting Ruby - Schema #{name}]"
39
+ add_line "Ruby:Access Control=0," + format_style(@items["storage.modifier"])
40
+ add_line "Ruby:Command=0," + format_style(@items["string.interpolated"])
41
+ add_line "Ruby:Constant=0," + format_style(@items["constant"])
42
+ add_line "Ruby:Constant Value=0," + format_style(@items["constant.other"])
43
+ add_line "Ruby:Default globals=0," + format_style(@items["variable.other"])
44
+ add_line "Ruby:Definition=0," + format_style(@items["entity.name.function"])
45
+ add_line "Ruby:Delimiter=0," + format_style(@items["keyword.other"])
46
+ add_line "Ruby:Global Constant=0," + format_style(@items["constant.other"])
47
+ add_line "Ruby:Global Variable=0," + format_style(@items["variable.other"])
48
+ add_line "Ruby:Instance Variable=0," + format_style(@items["variable"])
49
+ add_line "Ruby:Class Variable=0," + format_style(@items["variable"])
50
+ add_line "Ruby:Kernel methods=0," + format_style(@items["support.function"])
51
+ add_line "Ruby:Member=0," + format_style(@items["entity.name.function"])
52
+ add_line "Ruby:Message=0," + format_style(@default_style)
53
+ add_line "Ruby:Operator=0," + format_style(@items["keyword.operator"])
54
+ add_line "Ruby:Pseudo variable=0," + format_style(@items["variable.language"])
55
+ add_line "Ruby:Raw String=0," + format_style(@items["string.quoted.single"])
56
+ # add_line "Ruby:Region Marker=7," + format_style(@items[""])
57
+ add_line "Ruby:Regular Expression=0," + format_style(@items["string.regexp.ruby"])
58
+ add_line "Ruby:Symbol=0," + format_style(@items["constant.other.symbol.ruby"])
59
+
60
+ add_line
61
+
62
+ add_line "[Highlighting JavaScript - Schema #{name}]"
63
+ add_line "JavaScript:Objects=0," + format_style(@items["variable.language"])
64
+
65
+ add_line
66
+
67
+ add_line "[Highlighting Ruby/Rails/RHTML - Schema #{name}]"
68
+ add_line "Ruby/Rails/RHTML:Message=0," + format_style(@default_style)
69
+ add_line "Ruby/Rails/RHTML:Raw String=0," + format_style(@items["string.quoted.single"])
70
+ add_line "Ruby/Rails/RHTML:Symbol=0," + format_style(@items["constant.other.symbol.ruby"])
71
+ add_line "Ruby/Rails/RHTML:Value=0," + format_style(@items["string"])
72
+ add_line "Ruby/Rails/RHTML:Element=0," + format_style(@items["meta.tag"] || @items["entity.name.tag"])
73
+ add_line "Ruby/Rails/RHTML:Kernel methods=0," + format_style(@items["support.function"])
74
+ add_line "Ruby/Rails/RHTML:Attribute=0," + format_style(@items["entity.other.attribute-name"])
75
+
76
+ add_line
77
+
78
+ add_line "[Highlighting XML - Schema #{name}]"
79
+ add_line "XML:Value=0," + format_style(@items["string"])
80
+ add_line "XML:Element=0," + format_style(@items["meta.tag"] || @items["entity.name.tag"])
81
+ add_line "XML:Attribute=0," + format_style(@items["entity.other.attribute-name"])
82
+
83
+ add_line
84
+ add_comment "-" * 20 + " Put following in kateschemarc " + "-" * 20
85
+ add_line
86
+
87
+ add_line "[#{name}]"
88
+
89
+ ui_mapping = {
90
+ "Color Background" => @ui["background"],
91
+ "Color Highlighted Bracket" => @ui["background"],
92
+ "Color Highlighted Line" => @ui["lineHighlight"],
93
+ # "Color Icon Bar" => @ui[:background],
94
+ # "Color Line Number" => :,
95
+ # "Color MarkType1" => :,
96
+ # "Color MarkType2" => :,
97
+ # "Color MarkType3" => :,
98
+ # "Color MarkType4" => :,
99
+ # "Color MarkType5" => :,
100
+ # "Color MarkType6" => :,
101
+ # "Color MarkType7" => :,
102
+ "Color Selection" => @ui["selection"],
103
+ "Color Tab Marker" => @ui["invisibles"],
104
+ # "Color Template Background" => :,
105
+ # "Color Template Editable Placeholder" => :,
106
+ # "Color Template Focused Editable Placeholder" => :,
107
+ # "Color Template Not Editable Placeholder" => :,
108
+ "Color Word Wrap Marker" => @ui["invisibles"]
109
+ }
110
+ ui_mapping.keys.each do |key|
111
+ add_line "#{key}=#{hex2rgb(ui_mapping[key])}"
112
+ end
113
+
114
+ self.result = @lines.join("\n")
115
+ end
116
+
117
+ protected
118
+
119
+ def add_comment(c)
120
+ add_line(format_comment(c))
121
+ end
122
+
123
+ def add_line(line="")
124
+ (@lines ||= []) << line
125
+ end
126
+
127
+ def format_style(style)
128
+ style ||= @default_style
129
+ # normal,selected,bold,italic,strike,underline,bg,bg_selected,---
130
+ s = []
131
+ s << style.foreground.html.gsub('#', '')
132
+ s << style.foreground.html.gsub('#', '')
133
+ s << style.bold.to_i
134
+ s << style.italic.to_i
135
+ s << style.strike.to_i
136
+ s << style.underline.to_i
137
+ s << (style.background ? style.background.html.gsub('#', '') : nil)
138
+ s << nil
139
+ s << "---"
140
+ s.join(",")
141
+ end
142
+
143
+ def format_item(name, style)
144
+ raise RuntimeError.new("Style for #{name} is missing!") if style.nil?
145
+ "#{name}=#{format_style(style)}"
146
+ end
147
+
148
+ def format_comment(text)
149
+ "# #{text}"
150
+ end
151
+
152
+ def hex2rgb(col)
153
+ "#{(col.r*255).to_i},#{(col.g*255).to_i},#{(col.b*255).to_i}"
154
+ end
155
+
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,188 @@
1
+ module Coloration
2
+ module Writers
3
+ module VimThemeWriter
4
+
5
+ def build_result
6
+ add_line "\" Vim color file"
7
+ add_line "\" #{comment_text}"
8
+ add_line
9
+
10
+ add_line "set background=dark"
11
+ add_line "highlight clear"
12
+ add_line
13
+ add_line 'if exists("syntax_on")'
14
+ add_line " syntax reset"
15
+ add_line "endif"
16
+ add_line
17
+ add_line "let g:colors_name = \"#{@name}\""
18
+ add_line
19
+
20
+ ui_mapping = {
21
+ "Cursor" => Style.new(:bg => @ui["caret"]),
22
+ "Visual" => Style.new(:bg => @ui["selection"]),
23
+ "CursorLine" => Style.new(:bg => @ui["lineHighlight"]),
24
+ "CursorColumn" => Style.new(:bg => @ui["lineHighlight"]),
25
+ "LineNr" => Style.new(:fg => @ui["foreground"].mix_with(@ui["background"], 50), :bg => @ui["background"]),
26
+ "VertSplit" => Style.new(:fg => @ui["selection"], :bg => @ui["selection"]),
27
+ "MatchParen" => @items["keyword"],
28
+ "StatusLine" => Style.new(:fg => @ui["foreground"], :bg => @ui["selection"], :bold => true),
29
+ "StatusLineNC" => Style.new(:fg => @ui["foreground"], :bg => @ui["selection"]),
30
+ "Pmenu" => "entity.name",
31
+ "PmenuSel" => Style.new(:bg => @ui["selection"]),
32
+ "IncSearch" => Style.new(:bg => @items["variable"].foreground.mix_with(@ui["background"], 33)),
33
+ "Search" => Style.new(:bg => @items["variable"].foreground.mix_with(@ui["background"], 33)),
34
+ "Directory" => "constant.other.symbol",
35
+ "Folded" => Style.new(:fg => @items["comment"].foreground, :bg => @ui["background"]),
36
+ }
37
+
38
+ ui_mapping.keys.each do |key|
39
+ add_line(format_item(key, ui_mapping[key]))
40
+ end
41
+
42
+ add_line
43
+
44
+ items_mapping = {
45
+ # general colors for all languages
46
+ "Normal" => Style.new(:fg => @ui["foreground"], :bg => @ui["background"]),
47
+ "Boolean" => "constant.language",
48
+ "Character" => "constant.character",
49
+ "Comment" => "comment",
50
+ "Conditional" => "keyword.control",
51
+ "Constant" => "constant",
52
+ #"Debug" => [],
53
+ "Define" => "keyword",
54
+ #"Delimiter" => "meta.separator",
55
+ "ErrorMsg" => "invalid",
56
+ "WarningMsg" => "invalid",
57
+ #"Exception" => [],
58
+ "Float" => "constant.numeric",
59
+ "Function" => "entity.name.function",
60
+ "Identifier" => "storage.type",
61
+ #"Include" => [],
62
+ "Keyword" => "keyword",
63
+ "Label" => "string.other",
64
+ #"Macro" => [],
65
+ "NonText" => Style.new(:fg => @ui["invisibles"], :bg => @ui["lineHighlight"]),
66
+ "Number" => "constant.numeric",
67
+ "Operator" => "keyword.operator",
68
+ #"PreCondit" => [],
69
+ "PreProc" => "keyword.other",
70
+ #"Repeat" => [],
71
+ "Special" => Style.new(:fg => @ui["foreground"]),
72
+ #"SpecialChar" => [],
73
+ #"SpecialComment" => [],
74
+ "SpecialKey" => Style.new(:fg => @ui["invisibles"], :bg => @ui["lineHighlight"]),
75
+ "Statement" => "keyword.control",
76
+ "StorageClass" => "storage.type",
77
+ "String" => "string",
78
+ #"Structure" => [],
79
+ "Tag" => "entity.name.tag",
80
+ "Title" => Style.new(:fg => @ui["foreground"], :bold => true),
81
+ "Todo" => @items["comment"].clone.tap { |c| c.inverse = true; c.bold = true },
82
+ "Type" => "entity.name.type",
83
+ #"Typedef" => [],
84
+ "Underlined" => Style.new(:underline => true),
85
+
86
+ # ruby
87
+ "rubyClass" => "keyword.controll.class.ruby",
88
+ "rubyFunction" => "entity.name.function.ruby",
89
+ "rubyInterpolationDelimiter" => "",
90
+ "rubySymbol" => "constant.other.symbol.ruby",
91
+ "rubyConstant" => "support",
92
+ "rubyStringDelimiter" => "string",
93
+ "rubyBlockParameter" => "variable.parameter",
94
+ "rubyInstanceVariable" => "variable.language",
95
+ "rubyInclude" => "keyword.other.special-method.ruby",
96
+ "rubyGlobalVariable" => "variable.other",
97
+ "rubyRegexp" => "string.regexp",
98
+ "rubyRegexpDelimiter" => "string.regexp",
99
+ "rubyEscape" => "constant.character.escape",
100
+ "rubyControl" => "keyword.control",
101
+ "rubyClassVariable" => "variable",
102
+ "rubyOperator" => "keyword.operator",
103
+ "rubyException" => "keyword.other.special-method.ruby",
104
+ "rubyPseudoVariable" => "variable.language.ruby",
105
+
106
+ # rails
107
+ "rubyRailsUserClass" => "support.class.ruby",
108
+ "rubyRailsARAssociationMethod" => "support.function.activerecord.rails",
109
+ "rubyRailsARMethod" => "support.function.activerecord.rails",
110
+ "rubyRailsRenderMethod" => "support.function",
111
+ "rubyRailsMethod" => "support.function",
112
+
113
+ # eruby
114
+ "erubyDelimiter" => "punctuation.section.embedded.ruby",
115
+ "erubyComment" => "comment",
116
+ "erubyRailsMethod" => "support.function",
117
+ #"erubyExpression" => "text.html.ruby source",
118
+ #"erubyDelimiter" => "",
119
+
120
+ # html
121
+ "htmlTag" => "meta.tag entity",
122
+ "htmlEndTag" => "meta.tag entity",
123
+ "htmlTagName" => "meta.tag entity",
124
+ "htmlArg" => "meta.tag entity",
125
+ "htmlSpecialChar" => "constant.character.entity.html",
126
+
127
+ # javascript
128
+ "javaScriptFunction" => "storage.type.function.js",
129
+ "javaScriptRailsFunction" => "support.function",
130
+ "javaScriptBraces" => "meta.brace.curly.js",
131
+
132
+ # yaml
133
+ "yamlKey" => "entity.name.tag.yaml",
134
+ "yamlAnchor" => "variable.other.yaml",
135
+ "yamlAlias" => "variable.other.yaml",
136
+ "yamlDocumentHeader" => "string.unquoted.yaml",
137
+
138
+ # css
139
+ "cssURL" => "variable.parameter.misc.css",
140
+ "cssFunctionName" => "support.function.misc.css",
141
+ "cssColor" => "constant.other.color.rgb-value.css",
142
+ "cssPseudoClassId" => "entity.other.attribute-name.pseudo-class.css",
143
+ "cssClassName" => "entity.other.attribute-name.class.css",
144
+ "cssValueLength" => "constant.numeric.css",
145
+ "cssCommonAttr" => "support.constant.property-value.css",
146
+ "cssBraces" => "punctuation.section.property-list.css",
147
+ }
148
+
149
+ items_mapping.keys.each do |key|
150
+ add_line(format_item(key, items_mapping[key]))
151
+ end
152
+
153
+ self.result = @lines.join("\n")
154
+ end
155
+
156
+ protected
157
+
158
+ def add_line(line="")
159
+ (@lines ||= []) << line
160
+ end
161
+
162
+ def format_item(name, style_or_item_name)
163
+ raise RuntimeError.new("Style for #{name} is missing!") if style_or_item_name.nil?
164
+ if style_or_item_name == :inverse
165
+ "hi #{name} gui=inverse"
166
+ else
167
+ if style_or_item_name.is_a?(Style)
168
+ style = style_or_item_name
169
+ else
170
+ style = @items[style_or_item_name]
171
+ end
172
+ "hi #{name} #{format_style(style)}"
173
+ end
174
+ end
175
+
176
+ def format_style(style)
177
+ style ||= Style.new
178
+ s = ""
179
+ s << " guifg=" << (style.foreground.try(:html) || "NONE")
180
+ s << " guibg=" << (style.background.try(:html) || "NONE")
181
+ gui = [style.inverse && "inverse", style.bold && "bold", style.underline && "underline", style.italic && "italic"].compact
182
+ s << " gui=" << (gui.empty? ? "NONE" : gui.join(","))
183
+ s
184
+ end
185
+
186
+ end
187
+ end
188
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coloration
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Marcin Kulik
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2010-07-20 00:00:00 +02:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: textpow19
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 11
30
+ version: "0.11"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: color-tools
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 3
44
+ - 0
45
+ version: 1.3.0
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: plist
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ segments:
57
+ - 3
58
+ - 1
59
+ - 0
60
+ version: 3.1.0
61
+ type: :runtime
62
+ version_requirements: *id003
63
+ description: Color scheme converters for vim, textmate, kate/kwrite, jedit
64
+ email: marcin.kulik@gmail.com
65
+ executables:
66
+ - tm2jedit
67
+ - tm2katepart
68
+ - tm2vim
69
+ extensions: []
70
+
71
+ extra_rdoc_files: []
72
+
73
+ files:
74
+ - bin/tm2jedit
75
+ - bin/tm2katepart
76
+ - bin/tm2vim
77
+ - lib/coloration/color_rgba.rb
78
+ - lib/coloration/style.rb
79
+ - lib/coloration/version.rb
80
+ - lib/coloration/extensions.rb
81
+ - lib/coloration/abstract_converter.rb
82
+ - lib/coloration/converters/textmate2vim.rb
83
+ - lib/coloration/converters/textmate2jedit.rb
84
+ - lib/coloration/converters/textmate2katepart.rb
85
+ - lib/coloration/writers/katepart_theme_writer.rb
86
+ - lib/coloration/writers/vim_theme_writer.rb
87
+ - lib/coloration/writers/jedit_theme_writer.rb
88
+ - lib/coloration/readers/textmate_theme_reader.rb
89
+ - lib/coloration.rb
90
+ - README.md
91
+ has_rdoc: true
92
+ homepage: http://github.com/sickill/coloration
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 1
107
+ - 9
108
+ version: "1.9"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ requirements: []
118
+
119
+ rubyforge_project:
120
+ rubygems_version: 1.3.7
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Color scheme converters for vim, textmate, kate/kwrite, jedit
124
+ test_files: []
125
+