Class: RMThemeGen::ThemeRubyMine

Inherits:
RMThemeParent show all
Defined in:
lib/rmthemegen/rmtg_rubymine.rb,
lib/rmthemegen/rmthemegen_187.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RMThemeParent

#before_create, #clean_colorsets, #clear_colorsets, #handle_rand_seed, #randcolor, #randfilename, #randthemename, #reset_colorsets

Constructor Details

#initializeThemeRubyMine

Returns a new instance of ThemeRubyMine.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 23

def initialize
   super
   #"EFFECT-TYPE" s: 
   #   3 ==> cross-out 
   #   1 ==> underline
   #   2 == >squiggle underline
   #   5 => blockey underline 
   #   0 ==> box around word
   #   -1 ==> seems to have no effect

   # if the element name contains a string from the following arrays it makes that element
   # eligible for bold, italic or both. This allows elements from multiple languages to all
   # be exposed equally to 
   # underline not implemented yet. There are several font decorations in rubymine, 
   # probably should be used sparingly. 
   @bold_chance = 0.4
   @underline_chance = 0.3
   @italic_candidates = ["STRING", "SYMBOL", "REQUIRE"]
   @bold_candidates = ["KEYWORD","RUBY_SPECIFIC_CALL", "CONSTANT", "COMMA", "PAREN","RUBY_ATTR_ACCESSOR_CALL", "RUBY_ATTR_READER_CALL" ,"RUBY_ATTR_WRITER_CALL", "IDENTIFIER"]
# with code inspections we don't color the text, we just put a line or something under it .
   @code_inspections = ["ERROR","WARNING_ATTRIBUTES","DEPRECATED", "TYPO","WARNING_ATTRIBUTES", "BAD_CHARACTER",
   "CUSTOM_INVALID_STRING_ESCAPE_ATTRIBUTES","ERRORS_ATTRIBUTES", "MATCHED_BRACE_ATTRIBUTES"]
   @cross_out = ["DEPRECATED_ATTRIBUTES" ]
   
   @unders = %w(-1 0 1 2 5  )
   @underline_candidates = ["STRING"]
   @italic_chance = 0.2
end

Instance Attribute Details

#themenameObject (readonly)

Returns the value of attribute themename.



33
34
35
# File 'lib/rmthemegen/rmthemegen_187.rb', line 33

def themename
  @themename
end

#xml_saveObject (readonly)

Returns the value of attribute xml_save.



20
21
22
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 20

def xml_save
  @xml_save
end

#xmloutObject (readonly)

a huge structure of xml that can be given to XmlSimple.xml_out() to create that actual color theme file



21
22
23
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 21

def xmlout
  @xmlout
end

Instance Method Details

#make_rm_theme_file(outputdir = , bg_color_style = :dark, colorsets = [], rand_seed = nil) ⇒ Object

(output directory, bg_color_style, colorsets [])



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 166

def make_rm_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
#bg_color_style: 0 = blackish, 1 = whitish, 2 = any color, from #000000 to #FFFFFF
  handle_rand_seed(rand_seed)
  @theme_successfully_created=false
  before_create(outputdir, bg_color_style, colorsets, rand_seed)  
  @xmlout = {:scheme=>
            [{
              :attributes => [{:option=>[
                              {:name=>"2ABSTRACT_CLASS_NAME_ATTRIBUTES", :value=>[{:option=>{:name=>"foreground",:value=>"red"}}] },
                              {:name=>"4ABSTRACT_CLASS_NAME_ATTRIBUTES", :value=>[{:option=>{:name=>"foreground",:value=>"red"}}] }
                              ] 
                             }],
              :colors => [{ :option => [{:name=>"foreground",:value => "yellow"},{:name=>"background",:value => "black"} ],
              :option =>[{:name=>"pencil length",:value=>"48 cm"},{:name => "Doowop level", :value=>"medium"}]
               }],
            :name => @themename,:version=>@themeversion,:parent_scheme=>"Default", :author=>"David Heitzman, http://rmthemegen.com"
            }]
            }
    @savefile = randfilename(@themename)
    @outf = File.new(@opts[:outputdir]+"/"+@savefile, "w+")
    set_element_colors
    set_doc_colors
    set_doc_options
    XmlSimple.xml_out(@xmlout,{:keeproot=>true,:xmldeclaration=>true,:outputfile=> @outf, :rootname => "scheme"})
    @outf.close	
    @theme_successfully_created = true
    return File.expand_path(@outf.path)
end

#make_theme_file(outputdir = , bg_color_style = :dark, colorsets = [], rand_seed = nil) ⇒ Object

(output directory, bg_color_style, colorsets [])



185
186
187
# File 'lib/rmthemegen/rmthemegen_187.rb', line 185

def make_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
   make_rm_theme_file(outputdir, bg_color_style, colorsets, rand_seed)
end

#make_tm_theme_file(outputdir = , bg_color_style = :dark, colorsets = [], rand_seed = nil) ⇒ Object



180
181
182
# File 'lib/rmthemegen/rmthemegen_187.rb', line 180

def make_tm_theme_file(outputdir = ENV["PWD"], bg_color_style=:dark, colorsets=[], rand_seed=nil)
  create_textmate_theme(outputdir, bg_color_style, colorsets, rand_seed)
end

#set_doc_colorsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 52

def set_doc_colors
  newopt = []
  @@doc_color_keys.each do |o|
    if o == "CARET_ROW_COLOR" then
     @caret_row_color = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.05,:max_cont => 0.08,:shade_of_grey=>false)
      newopt << {:name=> o, :value => @caret_row_color }
      @document_globals[:CARET_ROW_COLOR] = @caret_row_color
    elsif o.include?("SELECTION_BACKGROUND") then
      @selection_background = randcolor(:bg_rgb=>@backgroundcolor,:min_cont=>0.07,:max_cont => 0.09,:shade_of_grey=>false)
      newopt << {:name=> o, :value => @selection_background }
      @document_globals[:SELECTION_BACKGROUND] = @selection_background
    elsif o.include?("SELECTION_FOREGROUND") then
      newopt << {:name=> o }
    elsif o.include?("GUTTER_BACKGROUND") then
      newopt << {:name=> o, :value => @backgroundcolor }
    elsif o.include?("CARET_COLOR") then
      newopt << {:name=> o, :value => (@caret_color = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.30,:max_cont=>0.7,:shade_of_grey=>true) )}
      @document_globals[:CARET_COLOR] = @caret_color
    elsif o.include?("READONLY_BACKGROUND") then
      newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.03,:max_cont=>0.09,:shade_of_grey=>@background_grey) }
    elsif o.include?("READONLY_FRAGMENT_BACKGROUND") then
      newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.03,:max_cont=>0.09,:shade_of_grey=>@background_grey) }
    elsif o.include?("INDENT_GUIDE") then
      newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.08,:max_cont=>0.22,:shade_of_grey=>@background_grey) }
    else
      newopt << {:name=> o, :value => randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont,:max_cont=>@max_cont,:shade_of_grey=>@background_grey).to_s }
    end 
  end
  
  @xmlout[:scheme][0][:colors][0][:option] = newopt
end

#set_doc_optionsObject



84
85
86
87
88
89
90
91
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 84

def set_doc_options
  newopt = []
  newopt << {:name => "LINE_SPACING",:value=>'1.0' } #:value=>'1.3' works all right 
  newopt << {:name => "EDITOR_FONT_NAME",:value => "DejaVu Sans Mono" }
  newopt << {:name => "EDITOR_FONT_SIZE",:value => "12"} #:value = "14" is a safe default if you want to specify something
  newopt << {:name => "RANDOM_SEED",:value => @random_seed.to_s }
  @xmlout[:scheme][0][:option] = newopt
end

#set_element_colorsObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/rmthemegen/rmtg_rubymine.rb', line 93

def set_element_colors
  newopt = []
  newopt[0]={:option=>[]}
  ################      set the fonttype 
  @@element_keys.each do |o|
    fonttype = 0 #bold: 1,  #italic: 2, bold & italic: 3   
    @bold_candidates.each do |bc|
      if o.include? bc.to_s then 
        if rand < @bold_chance then fonttype = 1 end
      end 
    end 
    @italic_candidates.each do |ic|
      if o.include? ic.to_s then 
        if rand < @italic_chance then fonttype += 2 end 
      end 
    end 
    #this block is for setting up special cases for the new color - ie, comments darker,
    #reserved words are yellowins, whatever 
    fonttype = "" unless fonttype.is_a? Fixnum
    case 
      when o.include?( "COMMENT") 
  #comments -- this is done so that COMMENTED texts skew toward darker shades. 
        newcol = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>0.25, :max_cont => 0.27) 
        optblj=[{:option=>[ {:name => "FOREGROUND", :value => newcol},     
#           {:name => "BACKGROUND", :value =>@backgroundcolor},
        {:name => "BACKGROUND"},
        {:name => "EFFECT_COLOR" },{:name => "FONT_TYPE", :value=>fonttype.to_s },
        {:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor) }]}] 
   #default text and background for whole document
      when ["TEXT","FOLDED_TEXT_ATTRIBUTES"].include?( o.to_s)
        newcol = randcolor(:bg_rgb=>@backgroundcolor ) 
        optblj=[{:option=>[ {:name => "FOREGROUND", :value => newcol},     
        {:name => "BACKGROUND", :value =>@backgroundcolor},
        {:name => "EFFECT_COLOR" },{:name => "FONT_TYPE", :value=>fonttype.to_s },
        {:name => "ERROR_STRIPE_COLOR", :value => (randcolor(:bg_rgb=>@backgroundcolor) ) }]}] 
        @document_globals[:TEXT] = newcol
      when @code_inspections.include?(o.to_s)  
        newcol = randcolor(:bg_rgb=>@backgroundcolor) 
        optblj=[{:option=>[ {:name => "FOREGROUND"},     
        {:name => "BACKGROUND"},
        {:name => "EFFECT_COLOR", :value =>newcol},{:name => "FONT_TYPE", :value=>fonttype.to_s },
        {:name => "EFFECT_TYPE", :value=>@unders.shuffle[0].to_s },
        {:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor) }]}] 
      when @cross_out.include?(o.to_s)
        newcol = randcolor(:bg_rgb=>@backgroundcolor) 
        optblj=[{:option=>[ {:name => "FOREGROUND"},     
        {:name => "BACKGROUND"},
        {:name => "EFFECT_COLOR", :value =>newcol},{:name => "FONT_TYPE", :value=>fonttype.to_s },
        {:name => "EFFECT_TYPE", :value=>"3" },
        {:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor)}]}] 
      else
        newcol=randcolor(:bg_rgb=>@backgroundcolor) 
        optblj=[{:option=>[ {:name => "FOREGROUND", :value => newcol},     
        {:name => "BACKGROUND"},
        {:name => "EFFECT_COLOR" },{:name => "FONT_TYPE", :value=>fonttype.to_s },
        {:name => "ERROR_STRIPE_COLOR", :value =>randcolor(:bg_rgb=>@backgroundcolor) }]}] 
    end
    newopt[0][:option] << {:name =>o.to_s , :value=>optblj}
    tmphash = {}
    optblj[0][:option].each do |siing| 
      tmphash[ siing[:name].to_sym ] = siing[:value] 
    end 
    @textmate_hash[o.to_sym] = tmphash
  end
  
  @xmlout[:scheme][0][:attributes] = newopt
end