rmthemegen 0.0.38 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. data/.project +18 -0
  2. data/bin/geanyfy.rb +4 -41
  3. data/lib/rmthemegen/basis_theme.tmTheme +971 -0
  4. data/lib/rmthemegen/geany.filetypes.all +2945 -0
  5. data/lib/rmthemegen/plist.html +246 -0
  6. data/lib/rmthemegen/plist_to_tokenlist.rb +242 -0
  7. data/lib/rmthemegen/rmtg_rubymine.rb +196 -0
  8. data/lib/rmthemegen/rmtg_textmate.rb +262 -0
  9. data/lib/rmthemegen/rmthemegen_187.rb +32 -233
  10. data/lib/rmthemegen/rmthemegen_parent.rb +235 -0
  11. data/lib/rmthemegen/rmthemegen_to_css.rb +1 -0
  12. data/lib/rmthemegen/syntaxes/Apache.plist +544 -0
  13. data/lib/rmthemegen/syntaxes/Bibtex.plist +406 -0
  14. data/lib/rmthemegen/syntaxes/Blog___HTML__.plist +88 -0
  15. data/lib/rmthemegen/syntaxes/Blog___Markdown__.plist +89 -0
  16. data/lib/rmthemegen/syntaxes/Blog___Text__.plist +74 -0
  17. data/lib/rmthemegen/syntaxes/Blog___Textile__.plist +74 -0
  18. data/lib/rmthemegen/syntaxes/C.plist +1126 -0
  19. data/lib/rmthemegen/syntaxes/CSS.plist +543 -0
  20. data/lib/rmthemegen/syntaxes/C____.plist +521 -0
  21. data/lib/rmthemegen/syntaxes/ClojureRepl.plist +40 -0
  22. data/lib/rmthemegen/syntaxes/Diff.plist +229 -0
  23. data/lib/rmthemegen/syntaxes/GroovyRepl.plist +40 -0
  24. data/lib/rmthemegen/syntaxes/HTML.plist +960 -0
  25. data/lib/rmthemegen/syntaxes/HTML___Rails__.plist +92 -0
  26. data/lib/rmthemegen/syntaxes/Haskell.plist +646 -0
  27. data/lib/rmthemegen/syntaxes/Io.plist +225 -0
  28. data/lib/rmthemegen/syntaxes/Java.plist +1156 -0
  29. data/lib/rmthemegen/syntaxes/JavaProperties.plist +70 -0
  30. data/lib/rmthemegen/syntaxes/JavaScript.plist +712 -0
  31. data/lib/rmthemegen/syntaxes/LaTeX.plist +1601 -0
  32. data/lib/rmthemegen/syntaxes/LaTeX_Beamer.plist +106 -0
  33. data/lib/rmthemegen/syntaxes/LaTeX_Log.plist +141 -0
  34. data/lib/rmthemegen/syntaxes/Lisp.plist +160 -0
  35. data/lib/rmthemegen/syntaxes/Literate_Haskell.plist +90 -0
  36. data/lib/rmthemegen/syntaxes/Makefile.plist +103 -0
  37. data/lib/rmthemegen/syntaxes/Markdown.plist +1192 -0
  38. data/lib/rmthemegen/syntaxes/Mirah.plist +22 -0
  39. data/lib/rmthemegen/syntaxes/PHP.plist +3481 -0
  40. data/lib/rmthemegen/syntaxes/PHP.xml +3481 -0
  41. data/lib/rmthemegen/syntaxes/Perl.plist +3209 -0
  42. data/lib/rmthemegen/syntaxes/Plain_text.plist +83 -0
  43. data/lib/rmthemegen/syntaxes/Processing.plist +296 -0
  44. data/lib/rmthemegen/syntaxes/Rez.plist +219 -0
  45. data/lib/rmthemegen/syntaxes/Ruby.plist +2891 -0
  46. data/lib/rmthemegen/syntaxes/RubyRepl.plist +40 -0
  47. data/lib/rmthemegen/syntaxes/Ruby_on_Rails.plist +288 -0
  48. data/lib/rmthemegen/syntaxes/SQL.plist +705 -0
  49. data/lib/rmthemegen/syntaxes/SQL___Rails__.plist +51 -0
  50. data/lib/rmthemegen/syntaxes/Shell__Unix__Generic.plist +1855 -0
  51. data/lib/rmthemegen/syntaxes/TeX.plist +246 -0
  52. data/lib/rmthemegen/syntaxes/TeX_Math.plist +132 -0
  53. data/lib/rmthemegen/syntaxes/Textile.plist +490 -0
  54. data/lib/rmthemegen/syntaxes/Vala.plist +285 -0
  55. data/lib/rmthemegen/syntaxes/XML.plist +576 -0
  56. data/lib/rmthemegen/syntaxes/XSL.plist +157 -0
  57. data/lib/rmthemegen/syntaxes/YAML.plist +467 -0
  58. data/lib/rmthemegen/textmate_themes/Active4D.tmTheme +407 -0
  59. data/lib/rmthemegen/textmate_themes/All Hallow's Eve Custom.tmTheme +273 -0
  60. data/lib/rmthemegen/textmate_themes/All Hallow's Eve.tmTheme +277 -0
  61. data/lib/rmthemegen/textmate_themes/Amy.tmTheme +557 -0
  62. data/lib/rmthemegen/textmate_themes/BBEdit.tmTheme +437 -0
  63. data/lib/rmthemegen/textmate_themes/Black Pearl II.tmTheme +496 -0
  64. data/lib/rmthemegen/textmate_themes/Black Pearl.tmTheme +400 -0
  65. data/lib/rmthemegen/textmate_themes/Blackboard Black.tmTheme +350 -0
  66. data/lib/rmthemegen/textmate_themes/Blackboard.tmTheme +350 -0
  67. data/lib/rmthemegen/textmate_themes/Bongzilla.tmTheme +223 -0
  68. data/lib/rmthemegen/textmate_themes/Brilliance Black.tmTheme +2619 -0
  69. data/lib/rmthemegen/textmate_themes/Brilliance Dull.tmTheme +2243 -0
  70. data/lib/rmthemegen/textmate_themes/CSSEdit.tmTheme +203 -0
  71. data/lib/rmthemegen/textmate_themes/Clouds Midnight.tmTheme +361 -0
  72. data/lib/rmthemegen/textmate_themes/Clouds.tmTheme +348 -0
  73. data/lib/rmthemegen/textmate_themes/Cobalt.tmTheme +559 -0
  74. data/lib/rmthemegen/textmate_themes/Coda.tmTheme +313 -0
  75. data/lib/rmthemegen/textmate_themes/Cool Glow.tmTheme +350 -0
  76. data/lib/rmthemegen/textmate_themes/Dawn.tmTheme +437 -0
  77. data/lib/rmthemegen/textmate_themes/Django (Smoothy).tmTheme +453 -0
  78. data/lib/rmthemegen/textmate_themes/Django.tmTheme +436 -0
  79. data/lib/rmthemegen/textmate_themes/Eiffel.tmTheme +439 -0
  80. data/lib/rmthemegen/textmate_themes/Emacs Strict.tmTheme +241 -0
  81. data/lib/rmthemegen/textmate_themes/Espresso Libre.tmTheme +402 -0
  82. data/lib/rmthemegen/textmate_themes/Espresso Tutti.tmTheme +392 -0
  83. data/lib/rmthemegen/textmate_themes/Espresso.tmTheme +329 -0
  84. data/lib/rmthemegen/textmate_themes/Fade to Grey.tmTheme +308 -0
  85. data/lib/rmthemegen/textmate_themes/Fluidvision.tmTheme +443 -0
  86. data/lib/rmthemegen/textmate_themes/ForLaTeX.tmTheme +214 -0
  87. data/lib/rmthemegen/textmate_themes/Freckle.tmTheme +279 -0
  88. data/lib/rmthemegen/textmate_themes/Friendship Bracelet.tmTheme +303 -0
  89. data/lib/rmthemegen/textmate_themes/GitHub.tmTheme +653 -0
  90. data/lib/rmthemegen/textmate_themes/GlitterBomb.tmTheme +387 -0
  91. data/lib/rmthemegen/textmate_themes/Happy happy joy joy 2.tmTheme +841 -0
  92. data/lib/rmthemegen/textmate_themes/IDLE.tmTheme +235 -0
  93. data/lib/rmthemegen/textmate_themes/IR_Black.tmTheme +810 -0
  94. data/lib/rmthemegen/textmate_themes/IR_White.tmTheme +792 -0
  95. data/lib/rmthemegen/textmate_themes/LAZY.tmTheme +291 -0
  96. data/lib/rmthemegen/textmate_themes/Lowlight.tmTheme +605 -0
  97. data/lib/rmthemegen/textmate_themes/Mac Classic.tmTheme +450 -0
  98. data/lib/rmthemegen/textmate_themes/Made of Code.tmTheme +695 -0
  99. data/lib/rmthemegen/textmate_themes/MagicWB (Amiga).tmTheme +376 -0
  100. data/lib/rmthemegen/textmate_themes/Merbivore Soft.tmTheme +285 -0
  101. data/lib/rmthemegen/textmate_themes/Merbivore.tmTheme +285 -0
  102. data/lib/rmthemegen/textmate_themes/Monokai.tmTheme +289 -0
  103. data/lib/rmthemegen/textmate_themes/MultiMarkdown.tmTheme +183 -0
  104. data/lib/rmthemegen/textmate_themes/Pastels on Dark.tmTheme +701 -0
  105. data/lib/rmthemegen/textmate_themes/Pastie.tmTheme +321 -0
  106. data/lib/rmthemegen/textmate_themes/Putty.tmTheme +275 -0
  107. data/lib/rmthemegen/textmate_themes/RDark.tmTheme +235 -0
  108. data/lib/rmthemegen/textmate_themes/Rails Envy.tmTheme +299 -0
  109. data/lib/rmthemegen/textmate_themes/Railscasts.tmTheme +278 -0
  110. data/lib/rmthemegen/textmate_themes/Ryan Light.tmTheme +232 -0
  111. data/lib/rmthemegen/textmate_themes/Slush & Poppies.tmTheme +336 -0
  112. data/lib/rmthemegen/textmate_themes/Smoothy.tmTheme +623 -0
  113. data/lib/rmthemegen/textmate_themes/SpaceCadet.tmTheme +212 -0
  114. data/lib/rmthemegen/textmate_themes/Spectacular.tmTheme +436 -0
  115. data/lib/rmthemegen/textmate_themes/Starlight.tmTheme +111 -0
  116. data/lib/rmthemegen/textmate_themes/Summer Camp Mod.tmTheme +229 -0
  117. data/lib/rmthemegen/textmate_themes/Summer Camp.tmTheme +229 -0
  118. data/lib/rmthemegen/textmate_themes/Sunburst.tmTheme +665 -0
  119. data/lib/rmthemegen/textmate_themes/Swyphs II.tmTheme +306 -0
  120. data/lib/rmthemegen/textmate_themes/Tango.tmTheme +450 -0
  121. data/lib/rmthemegen/textmate_themes/Text Ex Machina.tmTheme +295 -0
  122. data/lib/rmthemegen/textmate_themes/Tubster.tmTheme +280 -0
  123. data/lib/rmthemegen/textmate_themes/Twilight.tmTheme +518 -0
  124. data/lib/rmthemegen/textmate_themes/Vibrant Fin.tmTheme +447 -0
  125. data/lib/rmthemegen/textmate_themes/Vibrant Ink.tmTheme +447 -0
  126. data/lib/rmthemegen/textmate_themes/Vibrant Tango.tmTheme +438 -0
  127. data/lib/rmthemegen/textmate_themes/WhysPoignant.tmTheme +191 -0
  128. data/lib/rmthemegen/textmate_themes/Zenburnesque.tmTheme +343 -0
  129. data/lib/rmthemegen/textmate_themes/[ Argonaut ].tmTheme +387 -0
  130. data/lib/rmthemegen/textmate_themes/choco.tmTheme +542 -0
  131. data/lib/rmthemegen/textmate_themes/fake.tmTheme +669 -0
  132. data/lib/rmthemegen/textmate_themes/iLife 05.tmTheme +619 -0
  133. data/lib/rmthemegen/textmate_themes/iPlastic.tmTheme +286 -0
  134. data/lib/rmthemegen/textmate_themes/idleFingers.tmTheme +380 -0
  135. data/lib/rmthemegen/textmate_themes/krTheme.tmTheme +551 -0
  136. data/lib/rmthemegen/textmate_themes/monoindustrial.tmTheme +451 -0
  137. data/lib/rmthemegen/token_list.rb +171 -101
  138. data/lib/rmthemegen/uv_addons.rb +176 -0
  139. data/rmthemegen.gemspec +4 -1
  140. data/spec/rmthemegen/plist_to_tokenlist_spec.rb +0 -0
  141. data/test/choco.css +138 -0
  142. data/test/choco.render +136 -0
  143. data/test/get_tm_scopes.rb +79 -0
  144. data/test/get_tm_tokens.rb +0 -3
  145. data/test/newtheme.sh +6 -0
  146. data/test/output +14 -0
  147. data/test/rexml.element.methods +100 -0
  148. data/test/scopes_harvested +61 -0
  149. data/test/scopes_harvested.rb +15 -0
  150. data/test/test_generate_themes.rb +75 -38
  151. metadata +198 -13
  152. data/lib/rmthemegen/index.html +0 -2
  153. data/lib/rmthemegen/rmthemegen_187_textmate.rb +0 -155
  154. data/test/rmt_beautiful_quality.tmTheme +0 -399
  155. data/test/rmt_beautiful_quality.xml +0 -2089
@@ -15,29 +15,26 @@
15
15
  require 'rubygems'
16
16
  require 'color'
17
17
  require 'xmlsimple'
18
+ require 'textpow'
19
+ require 'uv' #ultraviolet
20
+ require 'plist'
18
21
  require File.dirname(__FILE__)+"/token_list"
19
22
  require File.dirname(__FILE__)+'/rgb_contrast_methods'
20
23
  require File.dirname(__FILE__)+'/rmthemegen_to_css'
24
+ require File.dirname(__FILE__)+'/rmtg187_new_textmate.rb'
25
+ require File.dirname(__FILE__)+'/uv_addons.rb'
26
+ require File.dirname(__FILE__)+'/rmthemegen_parent'
27
+ require File.dirname(__FILE__)+'/plist_to_tokenlist'
21
28
 
22
29
  module RMThemeGen
23
30
 
24
- class ThemeGenerator < RMThemeParent
31
+ class ThemeRubyMine < RMThemeParent
25
32
 
26
33
  attr_reader :xml_save, :themename
27
34
  attr_reader :xmlout #a huge structure of xml that can be given to XmlSimple.xml_out() to create that actual color theme file
28
35
 
29
- def initialize
30
- @random_seed = Kernel.srand
31
- Kernel.srand(@random_seed)
32
-
33
- @theme_successfully_created = false
34
-
35
- @iterations = 1
36
- @iterations = ARGV[0].to_s.to_i if ARGV[0]
37
- #bold: <option name="FONT_TYPE" value="1" />
38
- #italic: <option name="FONT_TYPE" value="2" />
39
- #bold & italic: <option name="FONT_TYPE" value="3" />
40
-
36
+ def initialize
37
+ super
41
38
  #"EFFECT-TYPE" s:
42
39
  # 3 ==> cross-out
43
40
  # 1 ==> underline
@@ -51,6 +48,8 @@ module RMThemeGen
51
48
  # be exposed equally to
52
49
  # underline not implemented yet. There are several font decorations in rubymine,
53
50
  # probably should be used sparingly.
51
+ @bold_chance = 0.4
52
+ @underline_chance = 0.3
54
53
  @italic_candidates = ["STRING", "SYMBOL", "REQUIRE"]
55
54
  @bold_candidates = ["KEYWORD","RUBY_SPECIFIC_CALL", "CONSTANT", "COMMA", "PAREN","RUBY_ATTR_ACCESSOR_CALL", "RUBY_ATTR_READER_CALL" ,"RUBY_ATTR_WRITER_CALL", "IDENTIFIER"]
56
55
  # with code inspections we don't color the text, we just put a line or something under it .
@@ -61,178 +60,13 @@ module RMThemeGen
61
60
  @unders = %w(-1 0 1 2 5 )
62
61
  @underline_candidates = ["STRING"]
63
62
  @italic_chance = 0.2
64
- @bold_chance = 0.4
65
- @underline_chance = 0.3
66
-
67
- @min_bright = 0.0
68
- @max_bright = 1.0
69
-
70
- # if we avoid any notion of "brightness", which is an absolute quality, then we
71
- # can make our background any color we want, then adjust contrast to taste
72
- #tighter contrast spec
73
- @cont_median = 0.85
74
- # @min_cont = @cont_median * 0.65
75
- @min_cont = 0.25
76
- @max_cont = [@cont_median * 1.35,1.0].max
77
-
78
- #broad contrast spec
79
- @min_cont = 0.30
80
- @max_cont = 1.0
81
-
82
- @themeversion = 1
83
- @themename = ''
84
- @background_max_brightness = 0.14
85
- @background_min_brightness = 0.65
86
- @background_grey = true #if false, allows background to be any color, as long as it meets brightness parameter
87
- @bg_color_style = 0 #0 = grey/dark 1 = grey/light (whitish), 2 = any color
88
- # @foreground_min_brightness = 0.4
89
-
90
- @document_globals = {}
91
- @backgroundcolor = randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
92
- @textmate_hash = {}
93
- reset_colorsets
94
- end #def initialize
95
-
96
-
97
- def reset_colorsets()
98
- #color sets: add to the variable @color_sets a hash containing 1 or 2 values in [0..1), indicating a shade
99
- # of red or green that the random colors will interpolate around.
100
- # if anything exists in @color_sets, the program will, when choosing its next random color, grab a random
101
- # color set, and then the next random color value produced will have up to 2 of its components (r, g, or b)
102
- # chosen with the specified r,g, or b as the median for a random gaussian, which will of course be limited
103
- # to the range [0..1)
104
-
105
- @color_sets = []
106
- (rand*4).to_i.times {
107
- @color_set = {}
108
- 3.times do
109
- case
110
- when rand < 0.333 then @color_set[:r] = rand
111
- when rand < 0.666 then @color_set[:g] = rand
112
- else @color_set[:b] = rand
113
- end
114
- end #8times
115
- @color_sets << @color_set
116
- } #rand*4times
117
- # @color_set = {:b => rand, :g=>rand, :r => rand}
118
- # @color_sets << @color_set
119
- # puts @color_sets.inspect
120
- end
121
-
122
- def clean_colorsets
123
- # trim each color set down to at most 2 colors
124
- if @color_sets.size > 0
125
- ncs = []
126
- # puts @color_sets.inspect
127
- @color_sets.each do |cs|
128
- while cs.size > 3 do
129
- cs.delete(cs.keys[0])
130
- end
131
- ncs << cs
132
- end
133
- @color_sets = ncs
134
- # puts "@color_sets "+@color_sets.to_s
135
- end
136
- end
137
-
138
- def clear_colorsets
139
- @color_sets=[]
140
- end
141
-
142
- def randthemename
143
- out = " "
144
- while out.include? " " do
145
- out = @@adjectives[rand * @@adjectives.size]+"_"+@@nouns[rand * @@nouns.size]
146
- end
147
- return out
148
- end
149
-
150
- def randfilename(existing = "")
151
- if existing != "" then
152
- out=existing
153
- else
154
- ar=["a","b","f","h","z","1","5"]
155
- ar.shuffle!
156
- out =""
157
- ar.each { |n|
158
- out << n
159
- }
160
- end
161
- return "rmt_"+out+".xml"
162
- end
163
-
164
-
165
- def randcolor(opts={})
166
- df= { :r=>nil, :g=>nil, :b=>nil, #these are the usual 0..255
167
- :bg_rgb => nil,
168
- :min_cont => @min_cont, #if a backrgb (background color) is supplied this will be used to create a minimum contrast with it.
169
- :max_cont => @max_cont,
170
- :max_bright => @max_bright,
171
- :min_bright => @min_bright,
172
- # :bright_median => 0.5,
173
- :shade_of_grey => false} #forces r == g == b
174
- df = df.merge opts
175
- df[:bg_rgb] = Color::RGB.from_html(df[:bg_rgb]) if df[:bg_rgb]
176
- color = brightok = contok = nil;
177
- cr=Color::RGB.new
178
- #failsafe should make sure the program never hangs trying to create
179
- # a random color.
180
- failsafe=200
181
- failsafe_mid = (failsafe/2).to_i
182
- usecolorsets = (!@color_sets.nil? && @color_sets != [])
183
-
184
- last_contrast = this_contrast = nil
185
- best_color_yet = nil
186
- contok = true # this will only get switched off if there is a background color submitted
187
- contrast_mid = ( (df[:min_cont] + df[:max_cont]) / 2.0 ).abs
188
- while (!color || !brightok || !contok && failsafe > 0) do
189
- if df[:shade_of_grey] == true
190
- g = b = r = rand*256
191
- elsif usecolorsets && failsafe > failsafe_mid
192
- cs = @color_sets.shuffle[0]
193
- #puts "doing gaussian thing "+cs.inspect
194
- if cs.keys.include? :r then r = cr.next_gaussian( cs[:r])*256 else r = (df[:r] || rand*256)%256 end
195
- if cs.keys.include? :g then g = cr.next_gaussian( cs[:g])*256 else g = (df[:g] || rand*256)%256 end
196
- if cs.keys.include? :b then b = cr.next_gaussian( cs[:b])*256 else b = (df[:b] || rand*256)%256 end
197
- else
198
- r = (df[:r] || rand*256)%256 #mod for robustness
199
- g = (df[:g] || rand*256)%256
200
- b = (df[:b] || rand*256)%256
201
- end
202
-
203
- color = Color::RGB.new(r,g,b)
204
- best_color_yet ||= color
205
-
206
- if (df[:bg_rgb]) then
207
- this_contrast = color.contrast(df[:bg_rgb])
208
- last_contrast ||= this_contrast
209
- best_color_yet = (this_contrast - contrast_mid).abs < (last_contrast - contrast_mid ).abs ? color : best_color_yet
210
- contok = (df[:min_cont]..df[:max_cont]).include?( this_contrast )
211
- end
212
- # puts color.inspect
213
- #puts "bg" + @backgroundcolor if df[:bg_rgb]
214
- #puts "color "+color.html
215
- #puts "contrast "+color.contrast(df[:bg_rgb]).to_s if df[:bg_rgb]
216
- #puts "contok "+contok.to_s
217
- brightok = (df[:min_bright]..df[:max_bright]).include?( color.to_hsl.brightness )
218
-
219
- #puts "brightok "+brightok.to_s
220
- failsafe -= 1
221
- # if failsafe == 0 then puts "failsafe reached " end;
222
- end #while
223
- # cn = color.html
224
-
225
- cn= failsafe <= 0 ? best_color_yet.html : color.html
226
- cn= cn.slice(1,cn.size)
227
-
228
- return cn
229
- end
63
+ end
230
64
 
231
65
  def set_doc_colors
232
66
  newopt = []
233
67
  @@doc_color_keys.each do |o|
234
68
  if o == "CARET_ROW_COLOR" then
235
- @caret_row_color = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.05,:max_cont => 0.08,:shade_of_grey=>false)
69
+ @caret_row_color = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.05,:max_cont => 0.08,:shade_of_grey=>false)
236
70
  newopt << {:name=> o, :value => @caret_row_color }
237
71
  @document_globals[:CARET_ROW_COLOR] = @caret_row_color
238
72
  elsif o.include?("SELECTION_BACKGROUND") then
@@ -253,13 +87,11 @@ module RMThemeGen
253
87
  elsif o.include?("INDENT_GUIDE") then
254
88
  newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.08,:max_cont=>0.22,:shade_of_grey=>@background_grey) }
255
89
  else
256
- # puts "bgc"+@backgroundcolor
257
90
  newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont,:max_cont=>@max_cont,:shade_of_grey=>@background_grey).to_s }
258
91
  end
259
92
  end
260
93
 
261
94
  @xmlout[:scheme][0][:colors][0][:option] = newopt
262
- #Kernel.exit
263
95
  end
264
96
 
265
97
  def set_doc_options
@@ -337,55 +169,24 @@ module RMThemeGen
337
169
  end
338
170
 
339
171
  @xmlout[:scheme][0][:attributes] = newopt
172
+ end
173
+
174
+
175
+
176
+ def make_rm_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
177
+ make_theme_file(outputdir, bg_color_style, colorsets, rand_seed)
178
+ end
179
+
180
+ def make_tm_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
181
+ create_textmate_theme(outputdir, bg_color_style, colorsets, rand_seed)
340
182
  end
341
-
183
+
342
184
  # (output directory, bg_color_style, colorsets [])
343
- def make_theme_file(outputdir = ENV["PWD"], bg_color_style=0, colorsets=[], rand_seed=nil)
344
- #bg_color_style: 0 = blackish, 1 = whitish, 2 = any color
345
- if rand_seed then
346
- #if a random seed is given, we need to reset the colorsets and bgstyle according to random numbers created AFTER the generator is seeded, forsaking whatever came in as parameters, since they are irrelevant if the desire is to recreate a previous theme from a random number seed
347
- Kernel.srand(rand_seed)
348
- @random_seed=rand_seed
349
- bg_color_style=rand(3).to_i
350
- reset_colorsets
351
- else
352
- #the reason we want the native seed used by this ruby implementation is that creating one ourselves might be erroneous in not using enough bits. There is a "formula" used by MRI but we don't know what it is, so we'll just harvest the number from a fresh call to srand, then reseed the rng using that number.
353
- Kernel.srand
354
- @random_seed = Kernel.srand #this sets @random_seed to the seed used in the call above
355
- Kernel.srand(@random_seed)
356
- end
185
+ def make_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
186
+ #bg_color_style: 0 = blackish, 1 = whitish, 2 = any color, from #000000 to #FFFFFF
187
+ handle_rand_seed(rand_seed)
357
188
  @theme_successfully_created=false
358
- defaults = {}
359
- defaults[:outputdir] = outputdir
360
- defaults[:bg_color_style] = bg_color_style
361
- opts = defaults
362
- @opts = opts
363
- @bg_color_style = opts[:bg_color_style]
364
- @background_grey = (opts[:bg_color_style] < 2) #whitish or blackish bg are both "grey"
365
-
366
- if colorsets.is_a?(Array) && colorsets.size > 0
367
- @color_sets = colorsets
368
- clean_colorsets
369
- else
370
- reset_colorsets
371
- end
372
-
373
- # puts "@color_sets: "+@color_sets.inspect
374
- case opts[:bg_color_style]
375
- when 0 #blackish background
376
- @background_min_brightness = 0.0
377
- @background_max_brightness = 0.14
378
- when 1 #whitish background
379
- @background_min_brightness = 0.75
380
- @background_max_brightness = 1.0
381
- when 2 #colored (any) bg
382
- @background_min_brightness = 0.0
383
- @background_max_brightness = 1.0
384
- end
385
- @backgroundcolor= randcolor(:shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness,
386
- :min_bright => @background_min_brightness )# "0"
387
- @document_globals[:backgroundcolor] = @backgroundcolor
388
- @themename = randthemename
189
+ before_create(outputdir, bg_color_style, colorsets, rand_seed)
389
190
  @xmlout = {:scheme=>
390
191
  [{
391
192
  :attributes => [{:option=>[
@@ -400,17 +201,15 @@ module RMThemeGen
400
201
  }]
401
202
  }
402
203
  @savefile = randfilename(@themename)
403
- @outf = File.new(opts[:outputdir]+"/"+@savefile, "w+")
204
+ @outf = File.new(@opts[:outputdir]+"/"+@savefile, "w+")
404
205
  set_element_colors
405
206
  set_doc_colors
406
207
  set_doc_options
407
208
  XmlSimple.xml_out(@xmlout,{:keeproot=>true,:xmldeclaration=>true,:outputfile=> @outf, :rootname => "scheme"})
408
209
  @outf.close
409
210
  @theme_successfully_created = true
410
- #puts "textmate_hash: "
411
- #puts @textmate_hash.inspect
412
211
  return File.expand_path(@outf.path)
413
212
  end
414
-
415
- end #class
213
+
214
+ end #class
416
215
  end #module
@@ -0,0 +1,235 @@
1
+ #**********************************************************************
2
+ #* *
3
+ #* RmThemeGen - a ruby script to create random, usable themes for *
4
+ #* text editors. Currently supports RubyMine 3.X.X *
5
+ #* *
6
+ #* By David Heitzman, 2011 *
7
+ #* *
8
+ #**********************************************************************
9
+
10
+ require 'rubygems'
11
+ require 'color'
12
+ require 'xmlsimple'
13
+ require 'textpow'
14
+ require 'uv' #ultraviolet
15
+ require 'plist'
16
+ require File.dirname(__FILE__)+"/token_list"
17
+ require File.dirname(__FILE__)+'/rgb_contrast_methods'
18
+ require File.dirname(__FILE__)+'/rmthemegen_to_css'
19
+ require File.dirname(__FILE__)+'/uv_addons.rb'
20
+ require File.dirname(__FILE__)+'/plist_to_tokenlist'
21
+
22
+
23
+ module RMThemeGen
24
+ class RMThemeParent
25
+ attr_accessor :themename
26
+
27
+ def initialize
28
+
29
+ @theme_successfully_created = false
30
+
31
+ @iterations = 1
32
+ @iterations = ARGV[0].to_s.to_i if ARGV[0]
33
+ #bold: <option name="FONT_TYPE" value="1" />
34
+ #italic: <option name="FONT_TYPE" value="2" />
35
+ #bold & italic: <option name="FONT_TYPE" value="3" />
36
+
37
+
38
+ @min_bright = 0.0
39
+ @max_bright = 1.0
40
+
41
+ # if we avoid any notion of "brightness", which is an absolute quality, then we
42
+ # can make our background any color we want, then adjust contrast to taste
43
+ #tighter contrast spec
44
+
45
+ #with the contrast-determining functions we actually have available, 0.3 is actually quite high, near
46
+ # the 80th percentile or so. FYI
47
+
48
+ @min_cont = 0.30
49
+ @max_cont = 1.0
50
+
51
+ @themeversion = 1
52
+ @themename = ''
53
+ @background_max_brightness = 0.14
54
+ @background_min_brightness = 0.65
55
+ @background_grey = true #if false, allows background to be any color, as long as it meets brightness parameter
56
+ @background_color_styles = [:dark,:light,:any]
57
+
58
+ @bg_color_style = @background_color_styles[0] #0 = dark 1 = light (whitish), 2 = any color
59
+ # @foreground_min_brightness = 0.4
60
+
61
+ @document_globals = {}
62
+ @backgroundcolor = randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
63
+ @textmate_hash = {}
64
+ reset_colorsets
65
+ end #def initialize
66
+
67
+ def reset_colorsets()
68
+ #color sets: add to the variable @color_sets a hash containing 1 or 2 values in [0..1), indicating a shade
69
+ # of red or green that the random colors will interpolate around.
70
+ # if anything exists in @color_sets, the program will, when choosing its next random color, grab a random
71
+ # color set, and then the next random color value produced will have up to 2 of its components (r, g, or b)
72
+ # chosen with the specified r,g, or b as the median for a random gaussian, which will of course be limited
73
+ # to the range [0..1)
74
+
75
+ @color_sets = []
76
+ (rand*4).to_i.times {
77
+ @color_set = {}
78
+ 3.times do
79
+ case
80
+ when rand < 0.333 then @color_set[:r] = rand
81
+ when rand < 0.666 then @color_set[:g] = rand
82
+ else @color_set[:b] = rand
83
+ end
84
+ end #8times
85
+ @color_sets << @color_set
86
+ } #rand*4times
87
+ end
88
+
89
+ def clean_colorsets
90
+ # trim each color set down to at most 2 colors
91
+ if @color_sets.size > 0
92
+ ncs = []
93
+ @color_sets.each do |cs|
94
+ while cs.size > 3 do
95
+ cs.delete(cs.keys[0])
96
+ end
97
+ ncs << cs
98
+ end
99
+ @color_sets = ncs
100
+ end
101
+ end
102
+
103
+ def clear_colorsets
104
+ @color_sets=[]
105
+ end
106
+
107
+ def randthemename
108
+ out = " "
109
+ while out.include? " " do
110
+ out = @@adjectives[rand * @@adjectives.size]+"_"+@@nouns[rand * @@nouns.size]
111
+ end
112
+ return out
113
+ end
114
+
115
+ def randfilename(existing = "")
116
+ if existing != "" then
117
+ out=existing
118
+ else
119
+ ar=["a","b","f","h","z","1","5"]
120
+ ar.shuffle!
121
+ out =""
122
+ ar.each { |n|
123
+ out << n
124
+ }
125
+ end
126
+ return "rmt_"+out+".xml"
127
+ end
128
+
129
+
130
+ def randcolor(opts={})
131
+ df= { :r=>nil, :g=>nil, :b=>nil, #these are the usual 0..255
132
+ :bg_rgb => nil,
133
+ :min_cont => @min_cont, #if a backrgb (background color) is supplied this will be used to create a minimum contrast with it.
134
+ :max_cont => @max_cont,
135
+ :max_bright => @max_bright,
136
+ :min_bright => @min_bright,
137
+ :shade_of_grey => false} #forces r == g == b
138
+ df = df.merge opts
139
+ df[:bg_rgb] = Color::RGB.from_html(df[:bg_rgb]) if df[:bg_rgb]
140
+ color = brightok = contok = nil;
141
+ cr=Color::RGB.new
142
+ #failsafe should make sure the program never hangs trying to create
143
+ # a random color.
144
+ failsafe=200
145
+ failsafe_mid = (failsafe/2).to_i
146
+ usecolorsets = (!@color_sets.nil? && @color_sets != [])
147
+
148
+ last_contrast = this_contrast = nil
149
+ best_color_yet = nil
150
+ contok = true # this will only get switched off if there is a background color submitted
151
+ contrast_mid = ( (df[:min_cont] + df[:max_cont]) / 2.0 ).abs
152
+ while (!color || !brightok || !contok && failsafe > 0) do
153
+ if df[:shade_of_grey] == true
154
+ g = b = r = rand*256
155
+ elsif usecolorsets && failsafe > failsafe_mid
156
+ cs = @color_sets.shuffle[0]
157
+ if cs.keys.include? :r then r = cr.next_gaussian( cs[:r])*256 else r = (df[:r] || rand*256)%256 end
158
+ if cs.keys.include? :g then g = cr.next_gaussian( cs[:g])*256 else g = (df[:g] || rand*256)%256 end
159
+ if cs.keys.include? :b then b = cr.next_gaussian( cs[:b])*256 else b = (df[:b] || rand*256)%256 end
160
+ else
161
+ r = (df[:r] || rand*256)%256 #mod for robustness
162
+ g = (df[:g] || rand*256)%256
163
+ b = (df[:b] || rand*256)%256
164
+ end
165
+
166
+ color = Color::RGB.new(r,g,b)
167
+ best_color_yet ||= color
168
+
169
+ if (df[:bg_rgb]) then
170
+ this_contrast = color.contrast(df[:bg_rgb])
171
+ last_contrast ||= this_contrast
172
+ best_color_yet = (this_contrast - contrast_mid).abs < (last_contrast - contrast_mid ).abs ? color : best_color_yet
173
+ contok = (df[:min_cont]..df[:max_cont]).include?( this_contrast )
174
+ end
175
+ brightok = (df[:min_bright]..df[:max_bright]).include?( color.to_hsl.brightness )
176
+
177
+ failsafe -= 1
178
+ end #while
179
+
180
+ cn= failsafe <= 0 ? best_color_yet.html : color.html
181
+ cn= cn.slice(1,cn.size)
182
+
183
+ return cn
184
+ end
185
+
186
+ def handle_rand_seed(rand_seed=nil)
187
+ if rand_seed then
188
+ #if a random seed is given, we need to reset the colorsets and bgstyle according to random numbers created AFTER the generator is seeded, forsaking whatever came in as parameters, since they are irrelevant if the desire is to recreate a previous theme from a random number seed
189
+ Kernel.srand(rand_seed)
190
+ @random_seed=rand_seed
191
+ bg_color_style=rand(@background_color_styles.size).to_i
192
+ reset_colorsets
193
+ else
194
+ #the reason we want the native seed used by this ruby implementation is that creating one ourselves might be erroneous in not using enough bits, or otherwise being insufficiently entropic. There is a "formula" used by MRI but we don't know what it is, so we'll just harvest the number from a fresh call to srand, then reseed the rng using that number.
195
+ Kernel.srand
196
+ @random_seed = Kernel.srand #this sets @random_seed to the value used in the call above
197
+ Kernel.srand(@random_seed)
198
+ end
199
+ end #def handle_rand_seed
200
+
201
+ def before_create(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
202
+ defaults = {}
203
+ defaults[:outputdir] = outputdir
204
+ defaults[:bg_color_style] = bg_color_style
205
+ opts = defaults
206
+ @opts = opts
207
+ @bg_color_style = opts[:bg_color_style]
208
+ @background_grey = ([:dark, :light].include? opts[:bg_color_style] ) #whitish or blackish bg are both "grey"
209
+
210
+ if colorsets.is_a?(Array) && colorsets.size > 0
211
+ @color_sets = colorsets
212
+ clean_colorsets
213
+ else
214
+ reset_colorsets
215
+ end
216
+
217
+ case opts[:bg_color_style]
218
+ when :dark #blackish background
219
+ @background_min_brightness = 0.0
220
+ @background_max_brightness = 0.14
221
+ when :light #whitish background
222
+ @background_min_brightness = 0.75
223
+ @background_max_brightness = 1.0
224
+ when :any #colored (any) bg
225
+ @background_min_brightness = 0.0
226
+ @background_max_brightness = 1.0
227
+ end
228
+ @backgroundcolor= randcolor(:shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness,
229
+ :min_bright => @background_min_brightness )# "0"
230
+ @document_globals[:backgroundcolor] = @backgroundcolor
231
+ @themename = randthemename
232
+ end #before_create
233
+
234
+ end #class
235
+ end #module
@@ -16,6 +16,7 @@ require 'xmlsimple'
16
16
  require File.dirname(__FILE__)+"/token_list"
17
17
  require File.dirname(__FILE__)+'/rgb_contrast_methods'
18
18
 
19
+
19
20
  module RMThemeGen
20
21
 
21
22
  class ThemeGenerator < RMThemeParent