rmthemegen 0.0.32 → 0.0.33
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.
- data/bin/geany_fix.rb +274 -0
- data/bin/geanyfy.rb +45 -0
- data/bin/generate_themes.rb +1 -1
- data/lib/geanyfy.rb +45 -0
- data/lib/rmthemegen/rmthemegen_187.rb +19 -9
- data/lib/rmthemegen/rmthemegen_187_textmate.rb +96 -29
- data/lib/rmthemegen/token_list.rb +49 -0
- data/lib/rmthemegen/version.rb +1 -1
- data/rmthemegen.gemspec +1 -1
- data/test/rmt_beautiful_quality.tmTheme +399 -0
- data/test/rmt_beautiful_quality.xml +2089 -0
- data/test/test_generate_themes.rb +2 -1
- metadata +12 -16
- data/test/textmate_themes/rmt_attractive_Taiwan.tmTheme +0 -17
- data/test/textmate_themes/rmt_cruel_produce.tmTheme +0 -17
- data/test/textmate_themes/rmt_grubby_route.tmTheme +0 -17
- data/test/textmate_themes/rmt_hostile_wall.tmTheme +0 -17
- data/test/textmate_themes/rmt_inc_handsaw.tmTheme +0 -17
- data/test/textmate_themes/rmt_indirect_modem.tmTheme +0 -17
- data/test/textmate_themes/rmt_married_great-grandfather.tmTheme +0 -17
- data/test/textmate_themes/rmt_strong_lilac.tmTheme +0 -17
- data/test/textmate_themes/rmt_wide_stone.tmTheme +0 -17
data/bin/geany_fix.rb
ADDED
@@ -0,0 +1,274 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#require 'rubygems'
|
3
|
+
#require 'xmlsimple'
|
4
|
+
#require 'color'
|
5
|
+
|
6
|
+
#doing it with local files since these are stable gems and I want geany_fix.rb to function without gem dependencies.
|
7
|
+
|
8
|
+
#***********************************************************************
|
9
|
+
# geany_fix.rb - a utility to create a new, random color theme for the
|
10
|
+
# geany editor. http://www.geany.org/
|
11
|
+
#
|
12
|
+
# Released under an MIT-style license, see license.txt for details
|
13
|
+
#
|
14
|
+
# copyright (c) David Heitzman 2011
|
15
|
+
#
|
16
|
+
#***********************************************************************
|
17
|
+
|
18
|
+
# geany_fix.rb uses a local copy of gems color and xml-simple, in order
|
19
|
+
# ease use as a stand-alone utility.
|
20
|
+
|
21
|
+
require File.dirname(__FILE__)+"/token_list"
|
22
|
+
require File.dirname(__FILE__)+'/color/color'
|
23
|
+
require File.dirname(__FILE__)+'/xmlsimple.rb'
|
24
|
+
|
25
|
+
module RMThemeGen
|
26
|
+
class GeanyFixer < RMThemeParent
|
27
|
+
|
28
|
+
attr_reader :xmlout #a huge structure of xml that can be given to XmlSimple.xml_out() to create that actual color theme file
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
# @rand = Random.new
|
32
|
+
@iterations = 0
|
33
|
+
@iterations = ARGV[0].to_s.to_i
|
34
|
+
|
35
|
+
puts "geany_fix - puts a new (random) color theme into your geany directory"
|
36
|
+
puts " copyright (c) David Heitzman 2011 "
|
37
|
+
puts " Note: if you want to put back your old Geany colors, go to ~/.config/geany/filedefs/ and"
|
38
|
+
puts " copy the corresponding _old_xxx file back onto filetypes.xyz, eg. filetypes.html, etc. "
|
39
|
+
puts " Restart geany to see new colors "
|
40
|
+
|
41
|
+
begin
|
42
|
+
@dir = (File.expand_path "~/.config/geany/filedefs/")
|
43
|
+
@filelist = Dir.glob(@dir+"/filetypes.*")
|
44
|
+
# puts @dir+"filetypes.*"
|
45
|
+
# puts @filelist.inspect
|
46
|
+
t =Time.now
|
47
|
+
@extstring = t.year.to_s+t.month.to_s+t.day.to_s+t.sec.to_s
|
48
|
+
# rescue
|
49
|
+
# raise "Sorry. There was trouble accessing the files in " + @dir
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
@italic_candidates = ["STRING", "SYMBOL", "REQUIRE"]
|
54
|
+
|
55
|
+
@bold_candidates = ["KEYWORD","RUBY_SPECIFIC_CALL", "CONSTANT", "COMMA", "PAREN","RUBY_ATTR_ACCESSOR_CALL", "RUBY_ATTR_READER_CALL" ,"RUBY_ATTR_WRITER_CALL", "IDENTIFIER"]
|
56
|
+
# with code inspections we don't color the text, we just put a line or something under it .
|
57
|
+
@code_inspections = ["ERROR","WARNING_ATTRIBUTES","DEPRECATED", "TYPO","WARNING_ATTRIBUTES", "BAD_CHARACTER",
|
58
|
+
"CUSTOM_INVALID_STRING_ESCAPE_ATTRIBUTES","ERRORS_ATTRIBUTES", "MATCHED_BRACE_ATTRIBUTES"]
|
59
|
+
@cross_out = ["DEPRECATED_ATTRIBUTES" ]
|
60
|
+
|
61
|
+
@unders = %w(-1 0 1 2 5 )
|
62
|
+
@underline_candidates = ["STRING"]
|
63
|
+
@italic_chance = 0.2
|
64
|
+
@bold_chance = 0.4
|
65
|
+
@underline_chance = 0.3
|
66
|
+
@bright_median = 0.85
|
67
|
+
@min_bright = @bright_median * 0.65
|
68
|
+
@max_bright = [@bright_median * 1.35,1.0].max
|
69
|
+
|
70
|
+
@min_bright = 0.0
|
71
|
+
@max_bright = 1.0
|
72
|
+
|
73
|
+
# if we avoid any notion of "brightness", which is an absolute quality, then we
|
74
|
+
# can make our background any color we want !
|
75
|
+
|
76
|
+
#tighter contrast spec
|
77
|
+
@cont_median = 0.85
|
78
|
+
@min_cont = @cont_median * 0.65
|
79
|
+
@max_cont = [@cont_median * 1.35,1.0].max
|
80
|
+
|
81
|
+
#broad contrast spec
|
82
|
+
@min_cont = 0.32
|
83
|
+
@max_cont = 1.0
|
84
|
+
|
85
|
+
@schemeversion = 1
|
86
|
+
@background_max_brightness = 0.16
|
87
|
+
@background_grey = true #if false, allows background to be any color, as long as it meets brightness parameter
|
88
|
+
# @foreground_min_brightness = 0.4
|
89
|
+
|
90
|
+
|
91
|
+
@backgroundcolor= randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
|
92
|
+
|
93
|
+
end #initialize
|
94
|
+
|
95
|
+
def randthemename
|
96
|
+
out = " "
|
97
|
+
while out.include? " " do
|
98
|
+
out = @@adjectives[rand * @@adjectives.size]+"_"+@@nouns[rand * @@nouns.size]
|
99
|
+
|
100
|
+
end
|
101
|
+
return out
|
102
|
+
end
|
103
|
+
|
104
|
+
def randfilename(existing = "")
|
105
|
+
if existing != "" then
|
106
|
+
out=existing
|
107
|
+
else
|
108
|
+
ar=["a","b","f","h","z","1","5"]
|
109
|
+
ar.shuffle!
|
110
|
+
out =""
|
111
|
+
ar.each { |n|
|
112
|
+
out << n
|
113
|
+
}
|
114
|
+
end
|
115
|
+
return "rmt_"+out+".xml"
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def randcolor(opts={})
|
120
|
+
|
121
|
+
df= { :r=>nil, :g=>nil, :b=>nil, #these are the usual 0..255
|
122
|
+
:bg_rgb => nil,
|
123
|
+
:min_cont => @min_cont, #if a backrgb (background color) is supplied this will be used to create a minimum contrast with it.
|
124
|
+
:max_cont => @max_cont,
|
125
|
+
:max_bright => @max_bright,
|
126
|
+
:min_bright => @min_bright,
|
127
|
+
# :bright_median => 0.5,
|
128
|
+
:shade_of_grey => false} #forces r == g == b
|
129
|
+
df = df.merge opts
|
130
|
+
df[:bg_rgb] = Color::RGB.from_html(df[:bg_rgb]) if df[:bg_rgb]
|
131
|
+
color = brightok = contok = nil;
|
132
|
+
while (!color || !brightok || !contok ) do
|
133
|
+
r = (df[:r] || rand*256)%256 #mod for robustness
|
134
|
+
g = (df[:g] || rand*256)%256
|
135
|
+
b = (df[:b] || rand*256)%256
|
136
|
+
g = b = r if df[:shade_of_grey] == true
|
137
|
+
color = Color::RGB.new(r,g,b)
|
138
|
+
#puts "bg" + @backgroundcolor if df[:bg_rgb]
|
139
|
+
#puts "color "+color.html
|
140
|
+
#puts "contrast "+color.contrast(df[:bg_rgb]).to_s if df[:bg_rgb]
|
141
|
+
contok = df[:bg_rgb] ? (df[:min_cont]..df[:max_cont]).include?( color.contrast(df[:bg_rgb]) ) : true
|
142
|
+
#puts "contok "+contok.to_s
|
143
|
+
brightok = (df[:min_bright]..df[:max_bright]).include?( color.to_hsl.brightness )
|
144
|
+
#puts "brightok "+brightok.to_s
|
145
|
+
end
|
146
|
+
|
147
|
+
cn = color.html
|
148
|
+
cn= cn.slice(1,cn.size)
|
149
|
+
return cn
|
150
|
+
end
|
151
|
+
|
152
|
+
def go_fix_geany
|
153
|
+
#goes into the geany directory and kicks some ass. it replaces every single color definition with
|
154
|
+
#something random, of course with a consistent background.
|
155
|
+
|
156
|
+
@filelist.each do |f|
|
157
|
+
begin
|
158
|
+
# puts f+" -->"+@dir+"_old_"+@extstring+File.basename(f)
|
159
|
+
# IO.copy_stream(f,@dir+"_old_"+@extstring+File.basename(f))
|
160
|
+
copystring="cp #{f} #{@dir+"/_old_"+@extstring+File.basename(f)}"
|
161
|
+
# puts(copystring)
|
162
|
+
`#{copystring}`
|
163
|
+
rescue
|
164
|
+
backup_problem = true
|
165
|
+
raise "sorry there was a problem backing up the following file: "+f
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
##########################################
|
170
|
+
# copy in our new files from token_list.rb
|
171
|
+
##########################################
|
172
|
+
@@geany_file_contents.each_key do |key|
|
173
|
+
filename=@dir+'/filetypes.'+key.to_s
|
174
|
+
# puts filename
|
175
|
+
@fout1 = File.open(filename,"w+")
|
176
|
+
@@geany_file_contents[key].each do |c|
|
177
|
+
@fout1.puts c
|
178
|
+
end
|
179
|
+
@fout1.close
|
180
|
+
end
|
181
|
+
|
182
|
+
@filelist = Dir.glob(@dir+"/filetypes.*")
|
183
|
+
@filelist.each do |f|
|
184
|
+
# puts f.inspect
|
185
|
+
@fin = File.open(f,"r+")
|
186
|
+
@fout = File.open(@dir+"/tmp_out_"+rand.to_s,"w+")
|
187
|
+
# puts @fin.inspect
|
188
|
+
|
189
|
+
while !@fin.eof? do
|
190
|
+
curpos = @fin.pos
|
191
|
+
line = @fin.readline
|
192
|
+
if line[0] != "#" && line.include?("=") && line.include?("0x") then
|
193
|
+
# go in and root out the color and give it a new one.
|
194
|
+
# puts "here is the line I'm working on -- "
|
195
|
+
# puts line
|
196
|
+
r1 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont, :max_cont=>@max_cont).upcase
|
197
|
+
r2 = @backgroundcolor.upcase
|
198
|
+
token = line.split("=")[0]
|
199
|
+
p3 = line.split(";")[2] || "false"
|
200
|
+
p4 = line.split(";")[3] || "false"
|
201
|
+
case File.basename(f)
|
202
|
+
when "filetypes.common"
|
203
|
+
if token == "marker_search" then
|
204
|
+
r9 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.35, :max_cont=>@max_cont).upcase
|
205
|
+
newl = token +"="+"0x"+r1+";0x"+r9+";true;true"
|
206
|
+
elsif token == "caret" then
|
207
|
+
r9 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.35, :max_cont=>@max_cont).upcase
|
208
|
+
newl = token +"="+"0xFFFFFF;0x"+r9+";"+p3+";"+p4
|
209
|
+
elsif token == "current_line" then
|
210
|
+
r9 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0.15, :max_cont=>@min_cont*0.3).upcase
|
211
|
+
newl = token +"="+"0x"+r1+";0x"+r9+";"+"true"+";"+"false"
|
212
|
+
elsif token == "selection" then
|
213
|
+
r9 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0.25, :max_cont=>@min_cont*0.5).upcase
|
214
|
+
newl = token +"="+"0x"+r1+";0x"+r9+";"+"false"+";"+"true"
|
215
|
+
elsif token == "brace_good" then
|
216
|
+
rb = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.25, :max_cont=>@max_cont).upcase
|
217
|
+
rf = randcolor(:bg_rgb=>rb, :min_cont=>0.30, :max_cont=>1.0).upcase
|
218
|
+
newl = token +"="+"0x"+rf+";0x"+rb+";"+"true"+";"+"false"
|
219
|
+
elsif token == "brace_bad" then
|
220
|
+
rb = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont, :max_cont=>1.0).upcase
|
221
|
+
rf = randcolor(:bg_rgb=>rb, :min_cont=>0.30, :max_cont=>1.0).upcase
|
222
|
+
newl = token +"="+"0x"+rf+";0x"+rb+";"+"true"+";"+"false"
|
223
|
+
elsif token.include?("type") then
|
224
|
+
newl ="type=0xffffff;;true;false"
|
225
|
+
elsif token.include?("indent_guide") then
|
226
|
+
newl= "indent_guide=0xc0c0c0;;false;false"
|
227
|
+
else
|
228
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
229
|
+
end
|
230
|
+
|
231
|
+
when "filetypes.xml"
|
232
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
233
|
+
|
234
|
+
when "filetypes.ruby"
|
235
|
+
if token=="default" then
|
236
|
+
r3 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont, :max_cont=>@max_cont).upcase
|
237
|
+
#for whatever reason this needs to go in there in a ruby file : pod=0x388afb;0x131313;false;false
|
238
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4+"\npod=0x#{r3};0x#{@backgroundcolor};false;false"
|
239
|
+
elsif token.include?("comment") then
|
240
|
+
r1 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0.87, :max_cont=>@min_cont*0.95).upcase
|
241
|
+
r2 = @backgroundcolor.upcase
|
242
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
243
|
+
else
|
244
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
245
|
+
end
|
246
|
+
else ############ DEFAULT ############
|
247
|
+
if token.include?("comment") then
|
248
|
+
r1 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0.77, :max_cont=>@min_cont*0.95).upcase
|
249
|
+
r2 = @backgroundcolor.upcase
|
250
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
251
|
+
else
|
252
|
+
newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
|
253
|
+
end
|
254
|
+
end
|
255
|
+
@fout.puts(newl)
|
256
|
+
else
|
257
|
+
@fout.puts(line)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
if @fout then
|
261
|
+
# puts "wanting to delete "+@fin.path.to_s
|
262
|
+
# puts "wanting to copy this file onto it:"+@fout.path.to_s
|
263
|
+
File.delete(@fin.path.to_s)
|
264
|
+
File.rename(@fout.path.to_s, @fin.path.to_s )
|
265
|
+
else puts "there was a problem writing to the new file #{@fout.path.to_s} so I left the old one in place"
|
266
|
+
end
|
267
|
+
@fout.close
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end #class
|
271
|
+
end #module
|
272
|
+
|
273
|
+
l = RMThemeGen::GeanyFixer.new
|
274
|
+
l.go_fix_geany
|
data/bin/geanyfy.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#this is to open all of the editable text files in the current and all subdirectories into geany
|
4
|
+
if !File.exist?("/usr/bin/geany")
|
5
|
+
exit "Doesn't look like you have geany installed, sorry."
|
6
|
+
end
|
7
|
+
|
8
|
+
class Geanyfy
|
9
|
+
attr_accessor :filelist, :openables, :subs
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@openables = ["php","rb","sql","py","h","c","java"]
|
13
|
+
@filelist = []
|
14
|
+
@subs = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_file_list(curdir)
|
18
|
+
match_openables(curdir)
|
19
|
+
allfiles = Dir.entries(curdir)
|
20
|
+
allfiles.each do |f|
|
21
|
+
get_file_list(f) if File.directory?(f) && ![".",".."].include?( f)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def match_openables(dir_string)
|
26
|
+
#returns an array of filenames that are of the type specified by @openables
|
27
|
+
@openables.each do |o|
|
28
|
+
dir_string += File::SEPARATOR if dir_string[-1,1] != File::SEPARATOR
|
29
|
+
@filelist.concat Dir[dir_string+"*."+o]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def open_all_files
|
34
|
+
@open_string = "geany "
|
35
|
+
@filelist.each do |f|
|
36
|
+
@open_string += " " + f
|
37
|
+
end
|
38
|
+
`#{@open_string} &`
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
g=Geanyfy.new
|
43
|
+
g.get_file_list(File.dirname(__FILE__))
|
44
|
+
|
45
|
+
g.open_all_files
|
data/bin/generate_themes.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
#originally it was written and tested for ruby 1.9.2
|
13
13
|
|
14
14
|
|
15
|
-
require File.
|
15
|
+
require File.expand_path('../../lib/rmthemegen/rmthemegen_187',__FILE__)
|
16
16
|
|
17
17
|
puts
|
18
18
|
puts " rmthemegen - creates theme files for use with rubymine (3.0.0 and up) "
|
data/lib/geanyfy.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#this is to open all of the editable text files in the current and all subdirectories into geany
|
4
|
+
if !File.exist?("/usr/bin/geany")
|
5
|
+
exit "Doesn't look like you have geany installed, sorry."
|
6
|
+
end
|
7
|
+
|
8
|
+
class Geanyfy
|
9
|
+
attr_accessor :filelist, :openables, :subs
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@openables = ["php","rb","sql","py","h","c","java"]
|
13
|
+
@filelist = []
|
14
|
+
@subs = []
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_file_list(curdir)
|
18
|
+
match_openables(curdir)
|
19
|
+
allfiles = Dir.entries(curdir)
|
20
|
+
allfiles.each do |f|
|
21
|
+
get_file_list(f) if File.directory?(f) && ![".",".."].include?( f)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def match_openables(dir_string)
|
26
|
+
#returns an array of filenames that are of the type specified by @openables
|
27
|
+
@openables.each do |o|
|
28
|
+
dir_string += File::SEPARATOR if dir_string[-1,1] != File::SEPARATOR
|
29
|
+
@filelist.concat Dir[dir_string+"*."+o]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def open_all_files
|
34
|
+
@open_string = "geany "
|
35
|
+
@filelist.each do |f|
|
36
|
+
@open_string += " " + f
|
37
|
+
end
|
38
|
+
`#{@open_string} &`
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
g=Geanyfy.new
|
43
|
+
g.get_file_list(File.dirname(__FILE__))
|
44
|
+
|
45
|
+
g.open_all_files
|
@@ -52,7 +52,6 @@ module RMThemeGen
|
|
52
52
|
# underline not implemented yet. There are several font decorations in rubymine,
|
53
53
|
# probably should be used sparingly.
|
54
54
|
@italic_candidates = ["STRING", "SYMBOL", "REQUIRE"]
|
55
|
-
|
56
55
|
@bold_candidates = ["KEYWORD","RUBY_SPECIFIC_CALL", "CONSTANT", "COMMA", "PAREN","RUBY_ATTR_ACCESSOR_CALL", "RUBY_ATTR_READER_CALL" ,"RUBY_ATTR_WRITER_CALL", "IDENTIFIER"]
|
57
56
|
# with code inspections we don't color the text, we just put a line or something under it .
|
58
57
|
@code_inspections = ["ERROR","WARNING_ATTRIBUTES","DEPRECATED", "TYPO","WARNING_ATTRIBUTES", "BAD_CHARACTER",
|
@@ -70,7 +69,6 @@ module RMThemeGen
|
|
70
69
|
|
71
70
|
# if we avoid any notion of "brightness", which is an absolute quality, then we
|
72
71
|
# can make our background any color we want, then adjust contrast to taste
|
73
|
-
|
74
72
|
#tighter contrast spec
|
75
73
|
@cont_median = 0.85
|
76
74
|
# @min_cont = @cont_median * 0.65
|
@@ -89,9 +87,9 @@ module RMThemeGen
|
|
89
87
|
@bg_color_style = 0 #0 = grey/dark 1 = grey/light (whitish), 2 = any color
|
90
88
|
# @foreground_min_brightness = 0.4
|
91
89
|
|
92
|
-
|
93
|
-
@backgroundcolor= randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
|
94
|
-
|
90
|
+
@document_globals = {}
|
91
|
+
@backgroundcolor = randcolor( :shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness)# "0"
|
92
|
+
@textmate_hash = {}
|
95
93
|
reset_colorsets
|
96
94
|
end #def initialize
|
97
95
|
|
@@ -236,16 +234,18 @@ module RMThemeGen
|
|
236
234
|
if o == "CARET_ROW_COLOR" then
|
237
235
|
@caret_row_color = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.05,:max_cont => 0.08,:shade_of_grey=>false)
|
238
236
|
newopt << {:name=> o, :value => @caret_row_color }
|
237
|
+
@document_globals[:CARET_ROW_COLOR] = @caret_row_color
|
239
238
|
elsif o.include?("SELECTION_BACKGROUND") then
|
240
239
|
@selection_background = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.07,:max_cont => 0.09,:shade_of_grey=>false)
|
241
240
|
newopt << {:name=> o, :value => @selection_background }
|
241
|
+
@document_globals[:SELECTION_BACKGROUND] = @selection_background
|
242
242
|
elsif o.include?("SELECTION_FOREGROUND") then
|
243
243
|
newopt << {:name=> o }
|
244
244
|
elsif o.include?("GUTTER_BACKGROUND") then
|
245
245
|
newopt << {:name=> o, :value => @backgroundcolor }
|
246
246
|
elsif o.include?("CARET_COLOR") then
|
247
|
-
newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.30,:max_cont=>0.7,:shade_of_grey=>true) }
|
248
|
-
|
247
|
+
newopt << {:name=> o, :value => (@caret_color = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.30,:max_cont=>0.7,:shade_of_grey=>true) )}
|
248
|
+
@document_globals[:CARET_COLOR] = @caret_color
|
249
249
|
elsif o.include?("READONLY_BACKGROUND") then
|
250
250
|
newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.03,:max_cont=>0.09,:shade_of_grey=>@background_grey) }
|
251
251
|
elsif o.include?("READONLY_FRAGMENT_BACKGROUND") then
|
@@ -300,12 +300,13 @@ module RMThemeGen
|
|
300
300
|
{:name => "EFFECT_COLOR" },{:name => "FONT_TYPE", :value=>fonttype.to_s },
|
301
301
|
{:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor) }]}]
|
302
302
|
#default text and background for whole document
|
303
|
-
when ["TEXT","FOLDED_TEXT_ATTRIBUTES"].include?( o.to_s)
|
303
|
+
when ["TEXT","FOLDED_TEXT_ATTRIBUTES"].include?( o.to_s)
|
304
304
|
newcol = randcolor(:bg_rgb=>@backgroundcolor )
|
305
305
|
optblj=[{:option=>[ {:name => "FOREGROUND", :value => newcol},
|
306
306
|
{:name => "BACKGROUND", :value =>@backgroundcolor},
|
307
307
|
{:name => "EFFECT_COLOR" },{:name => "FONT_TYPE", :value=>fonttype.to_s },
|
308
|
-
{:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor)}]}]
|
308
|
+
{:name => "ERROR_STRIPE_COLOR", :value => (randcolor(:bg_rgb=>@backgroundcolor) ) }]}]
|
309
|
+
@document_globals[:TEXT] = newcol
|
309
310
|
when @code_inspections.include?(o.to_s)
|
310
311
|
newcol = randcolor(:bg_rgb=>@backgroundcolor)
|
311
312
|
optblj=[{:option=>[ {:name => "FOREGROUND"},
|
@@ -328,7 +329,13 @@ module RMThemeGen
|
|
328
329
|
{:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor) }]}]
|
329
330
|
end
|
330
331
|
newopt[0][:option] << {:name =>o.to_s , :value=>optblj}
|
332
|
+
tmphash = {}
|
333
|
+
optblj[0][:option].each do |siing|
|
334
|
+
tmphash[ siing[:name].to_sym ] = siing[:value]
|
335
|
+
end
|
336
|
+
@textmate_hash[o.to_sym] = tmphash
|
331
337
|
end
|
338
|
+
|
332
339
|
@xmlout[:scheme][0][:attributes] = newopt
|
333
340
|
end
|
334
341
|
|
@@ -377,6 +384,7 @@ module RMThemeGen
|
|
377
384
|
end
|
378
385
|
@backgroundcolor= randcolor(:shade_of_grey=>@background_grey, :max_bright=>@background_max_brightness,
|
379
386
|
:min_bright => @background_min_brightness )# "0"
|
387
|
+
@document_globals[:backgroundcolor] = @backgroundcolor
|
380
388
|
@themename = randthemename
|
381
389
|
@xmlout = {:scheme=>
|
382
390
|
[{
|
@@ -399,6 +407,8 @@ module RMThemeGen
|
|
399
407
|
XmlSimple.xml_out(@xmlout,{:keeproot=>true,:xmldeclaration=>true,:outputfile=> @outf, :rootname => "scheme"})
|
400
408
|
@outf.close
|
401
409
|
@theme_successfully_created = true
|
410
|
+
puts "textmate_hash: "
|
411
|
+
puts @textmate_hash.inspect
|
402
412
|
return File.expand_path(@outf.path)
|
403
413
|
end
|
404
414
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
require 'rubygems'
|
16
16
|
require 'color'
|
17
17
|
require 'xmlsimple'
|
18
|
+
require 'rexml/document'
|
18
19
|
require File.dirname(__FILE__)+"/token_list"
|
19
20
|
require File.dirname(__FILE__)+'/rgb_contrast_methods'
|
20
21
|
require File.dirname(__FILE__)+'/rmthemegen_to_css'
|
@@ -23,28 +24,7 @@ module RMThemeGen
|
|
23
24
|
|
24
25
|
class ThemeGenerator < RMThemeParent
|
25
26
|
|
26
|
-
|
27
|
-
#newopt has to be a hash of "key" => ["color"],"string" => ["color"]
|
28
|
-
#order matters here. ...
|
29
|
-
#newopt = {}
|
30
|
-
#newopt={:key => ["background"],:string=>["#00ff00"] }
|
31
|
-
#newopt.merge!( {:key => ["caret"],:string => ["#000000"]})
|
32
|
-
#newopt.merge!( {:key => ["foreground"],:string => ["#ffffff"] })
|
33
|
-
@xml_textmate_out[:dict][0][:array][0][:dict][0][:dict][0]
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_tm_doc_colors
|
37
|
-
end
|
38
|
-
|
39
|
-
def set_tm_element_colors
|
40
|
-
end
|
41
|
-
|
42
|
-
def read_tmfile
|
43
|
-
@inf = File.open("./iPlastic.tmTheme","r")
|
44
|
-
|
45
|
-
@xml_in=XmlSimple.xml_in(@inf)
|
46
|
-
puts @xml_in.inspect
|
47
|
-
end
|
27
|
+
|
48
28
|
|
49
29
|
def to_textmate
|
50
30
|
#it will save the theme file ".tmTheme" in the same directory as other themes
|
@@ -66,23 +46,110 @@ module RMThemeGen
|
|
66
46
|
:key =>["settings"],
|
67
47
|
:dict=> [{"string"=>["#000000","#FFFFFF"],
|
68
48
|
"key"=>["background","foreground"]
|
69
|
-
|
70
49
|
}]
|
71
|
-
|
72
|
-
|
73
50
|
}]}]
|
74
51
|
}]
|
75
52
|
}
|
76
53
|
@savefile = "rmt_"+@themename+".tmTheme"
|
77
54
|
@outf = File.new(@opts[:outputdir]+"/"+@savefile, "w+")
|
78
|
-
set_tm_doc_options
|
79
|
-
set_tm_doc_colors
|
80
|
-
set_tm_element_colors
|
81
|
-
XmlSimple.xml_out(@xml_textmate_out,{:keeproot=>false,:xmldeclaration=>true,:outputfile=> @outf, :rootname => ""})
|
55
|
+
#set_tm_doc_options
|
56
|
+
#set_tm_doc_colors
|
57
|
+
#set_tm_element_colors
|
58
|
+
#XmlSimple.xml_out(@xml_textmate_out,{:keeproot=>false,:xmldeclaration=>true,:outputfile=> @outf, :rootname => ""})
|
59
|
+
rexmlout = REXML::Document.new
|
60
|
+
rexmlout << REXML::DocType.new('plist','PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"')
|
61
|
+
rexmlout << REXML::XMLDecl.new("1.0","UTF-8",nil)
|
62
|
+
plist = REXML::Element.new "plist"
|
63
|
+
plist.add_attributes( "version"=>"1.0")
|
64
|
+
dict = REXML::Element.new( "dict", plist) #causes plist to be the parent of dict
|
65
|
+
dict.add_text(REXML::Element.new("key").add_text("name") )
|
66
|
+
dict.add_text(REXML::Element.new("string").add_text( @themename ) )
|
67
|
+
dict.add_text(REXML::Element.new("key").add_text("author") )
|
68
|
+
dict.add_text(REXML::Element.new("string").add_text("David Heitzman") )
|
69
|
+
dict.add_text(REXML::Element.new("key").add_text("settings") )
|
70
|
+
main_array = REXML::Element.new("array",dict)
|
71
|
+
doc_dict = REXML::Element.new("dict",main_array)
|
72
|
+
doc_dict.add_text(REXML::Element.new("key").add_text("settings") )
|
73
|
+
doc_dict.add_element(
|
74
|
+
make_dict(
|
75
|
+
:background=>"#"+@document_globals[:backgroundcolor].upcase,
|
76
|
+
:caret=>"#"+ @document_globals[:CARET_COLOR].upcase ,
|
77
|
+
:foreground=>"#"+@document_globals[:TEXT].upcase,
|
78
|
+
:invisibles=>"#"+@document_globals[:backgroundcolor].upcase,
|
79
|
+
:lineHighlight=>"#"+@document_globals[:CARET_ROW_COLOR].upcase,
|
80
|
+
:selection=>"#"+@document_globals[:SELECTION_BACKGROUND].upcase)
|
81
|
+
)
|
82
|
+
|
83
|
+
#puts @@document_opts_to_textmate.to_s
|
84
|
+
@@document_opts_to_textmate.each do |k,v|
|
85
|
+
main_array.add_element(
|
86
|
+
make_name_scope_settings(k,v)
|
87
|
+
) if @textmate_hash[k]
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
uuid_key = REXML::Element.new("key")
|
92
|
+
uuid_key.add_text("uuid")
|
93
|
+
uuid_element = REXML::Element.new("string")
|
94
|
+
uuid_element.add_text( gen_uuid)
|
95
|
+
dict.add_element uuid_key
|
96
|
+
dict.add_element uuid_element
|
97
|
+
|
98
|
+
rexmlout << plist
|
99
|
+
# rexmlout.write(@outf)
|
100
|
+
formatter = REXML::Formatters::Pretty.new
|
101
|
+
formatter.compact=true
|
102
|
+
formatter.write(rexmlout, @outf)
|
82
103
|
@outf.close
|
83
104
|
@theme_successfully_created = true
|
84
105
|
return File.expand_path(@outf.path)
|
85
106
|
end
|
107
|
+
|
108
|
+
|
109
|
+
def make_dict(a_hash)
|
110
|
+
new_dict = REXML::Element.new("dict")
|
111
|
+
a_hash.each do |k,v|
|
112
|
+
te1 = REXML::Element.new("key")
|
113
|
+
te1.add_text(k.to_s)
|
114
|
+
te2 = REXML::Element.new("string")
|
115
|
+
te2.add_text(v.to_s)
|
116
|
+
new_dict.add_element te1
|
117
|
+
new_dict.add_element te2
|
118
|
+
end
|
119
|
+
return new_dict
|
120
|
+
end
|
121
|
+
|
122
|
+
def make_name_scope_settings(ruby_symbol,an_array)
|
123
|
+
fontstyles = ["","bold","italic", "bold italic"]
|
124
|
+
#the array looks like ["name","scope",{}] . the third element in the array is a hash for "settings"
|
125
|
+
new_dict = REXML::Element.new("dict")
|
126
|
+
te1 = REXML::Element.new("key")
|
127
|
+
te1.add_text("name")
|
128
|
+
te2 = REXML::Element.new("string")
|
129
|
+
te2.add_text(an_array[0])
|
130
|
+
te3 = REXML::Element.new("key")
|
131
|
+
te3.add_text("scope")
|
132
|
+
te4 = REXML::Element.new("string")
|
133
|
+
te4.add_text(an_array[1])
|
134
|
+
te5 = REXML::Element.new("key")
|
135
|
+
te5.add_text("settings")
|
136
|
+
new_dict.add_element te1
|
137
|
+
new_dict.add_element te2
|
138
|
+
new_dict.add_element te3
|
139
|
+
new_dict.add_element te4
|
140
|
+
new_dict.add_element te5
|
141
|
+
fontStyle = fontstyles[@textmate_hash[ruby_symbol][:FONT_TYPE].to_i ]
|
142
|
+
di1 = make_dict(:foreground => "#"+@textmate_hash[ruby_symbol][:FOREGROUND].upcase, :fontStyle=>fontStyle)
|
143
|
+
new_dict.add_element di1
|
144
|
+
return new_dict
|
145
|
+
end
|
146
|
+
|
147
|
+
def gen_uuid
|
148
|
+
nn = sprintf("%X",rand(99999999999999999999999999999999999999999999999999).abs)
|
149
|
+
nn = nn[0,8]+"-"+nn[12,4]+"-4"+nn[17,3]+"-"+["8","9","A","B"].shuffle[0]+nn[21,3]+"-"+nn[24,12]
|
150
|
+
end
|
151
|
+
|
86
152
|
end #class
|
87
153
|
|
154
|
+
|
88
155
|
end #module
|