rmthemegen 0.0.22 → 0.0.23
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/lib/rmthemegen/geany_fix.rb +35 -15
- data/lib/rmthemegen/token_list.rb +2733 -67
- data/lib/rmthemegen/version.rb +1 -1
- data/rmthemegen.gemspec +1 -1
- data/test/rmt_cruel_produce.tmTheme +17 -0
- data/test/rmt_cruel_produce.xml +2088 -0
- data/test/test_generate_themes.rb +2 -1
- data/test/tm_token_to_scope_list +823 -0
- metadata +7 -4
    
        data/lib/rmthemegen/geany_fix.rb
    CHANGED
    
    | @@ -21,8 +21,8 @@ module RMThemeGen | |
| 21 21 | 
             
                puts "  Restart geany to see new colors  "
         | 
| 22 22 |  | 
| 23 23 | 
             
                begin
         | 
| 24 | 
            -
                @dir = (File.expand_path "~/.config/geany/filedefs/") | 
| 25 | 
            -
                @filelist = Dir.glob(@dir+"filetypes.*")
         | 
| 24 | 
            +
                @dir = (File.expand_path "~/.config/geany/filedefs/")
         | 
| 25 | 
            +
                @filelist = Dir.glob(@dir+"/filetypes.*")
         | 
| 26 26 | 
             
            #  puts @dir+"filetypes.*"
         | 
| 27 27 | 
             
            #    puts @filelist.inspect
         | 
| 28 28 | 
             
                t =Time.now
         | 
| @@ -138,17 +138,34 @@ module RMThemeGen | |
| 138 138 | 
             
                  @filelist.each do |f|
         | 
| 139 139 | 
             
                    begin
         | 
| 140 140 | 
             
            #          puts f+" -->"+@dir+"_old_"+@extstring+File.basename(f)
         | 
| 141 | 
            -
                      IO.copy_stream(f,@dir+"_old_"+@extstring+File.basename(f))
         | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 141 | 
            +
            #          IO.copy_stream(f,@dir+"_old_"+@extstring+File.basename(f))
         | 
| 142 | 
            +
                    copystring="cp #{f} #{@dir+"/_old_"+@extstring+File.basename(f)}"
         | 
| 143 | 
            +
            #        puts(copystring) 
         | 
| 144 | 
            +
                    `#{copystring}`
         | 
| 145 | 
            +
                    rescue
         | 
| 146 | 
            +
                      backup_problem = true
         | 
| 147 | 
            +
                      raise "sorry there was a problem backing up the following file: "+f
         | 
| 145 148 | 
             
                    end
         | 
| 146 149 | 
             
                  end
         | 
| 147 150 |  | 
| 151 | 
            +
                  ##########################################
         | 
| 152 | 
            +
                  # copy in our new files from token_list.rb
         | 
| 153 | 
            +
                  ##########################################
         | 
| 154 | 
            +
                  @@geany_file_contents.each_key do |key|
         | 
| 155 | 
            +
                  filename=@dir+'/filetypes.'+key.to_s
         | 
| 156 | 
            +
            #      puts filename
         | 
| 157 | 
            +
                  @fout1 = File.open(filename,"w+")
         | 
| 158 | 
            +
                    @@geany_file_contents[key].each do |c|
         | 
| 159 | 
            +
                      @fout1.puts c
         | 
| 160 | 
            +
                    end
         | 
| 161 | 
            +
                  @fout1.close
         | 
| 162 | 
            +
                  end 
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                  @filelist = Dir.glob(@dir+"/filetypes.*")
         | 
| 148 165 | 
             
                  @filelist.each do |f|
         | 
| 149 166 | 
             
              #      puts f.inspect
         | 
| 150 167 | 
             
                    @fin = File.open(f,"r+")
         | 
| 151 | 
            -
                    @fout = File.open("/ | 
| 168 | 
            +
                    @fout = File.open(@dir+"/tmp_out_"+rand.to_s,"w+")
         | 
| 152 169 | 
             
              #      puts @fin.inspect
         | 
| 153 170 |  | 
| 154 171 | 
             
                    while !@fin.eof? do
         | 
| @@ -185,6 +202,10 @@ module RMThemeGen | |
| 185 202 | 
             
                              rb = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont, :max_cont=>1.0).upcase
         | 
| 186 203 | 
             
                              rf = randcolor(:bg_rgb=>rb, :min_cont=>0.30, :max_cont=>1.0).upcase
         | 
| 187 204 | 
             
                              newl = token +"="+"0x"+rf+";0x"+rb+";"+"true"+";"+"false"
         | 
| 205 | 
            +
                            elsif token.include?("type") then 
         | 
| 206 | 
            +
                              newl ="type=0xffffff;;true;false"
         | 
| 207 | 
            +
                            elsif token.include?("indent_guide") then
         | 
| 208 | 
            +
                              newl= "indent_guide=0xc0c0c0;;false;false"
         | 
| 188 209 | 
             
                            else
         | 
| 189 210 | 
             
                              newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
         | 
| 190 211 | 
             
                            end
         | 
| @@ -204,9 +225,9 @@ module RMThemeGen | |
| 204 225 | 
             
                            else
         | 
| 205 226 | 
             
                              newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
         | 
| 206 227 | 
             
                            end
         | 
| 207 | 
            -
                          else
         | 
| 228 | 
            +
                          else  ############ DEFAULT  ############ 
         | 
| 208 229 | 
             
                            if token.include?("comment") then
         | 
| 209 | 
            -
                              r1 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0. | 
| 230 | 
            +
                              r1 = randcolor(:bg_rgb=>@backgroundcolor, :min_cont=>@min_cont*0.77, :max_cont=>@min_cont*0.95).upcase
         | 
| 210 231 | 
             
                              r2 = @backgroundcolor.upcase
         | 
| 211 232 | 
             
                              newl = token +"="+"0x"+r1+";0x"+r2+";"+p3+";"+p4
         | 
| 212 233 | 
             
                            else
         | 
| @@ -214,17 +235,16 @@ module RMThemeGen | |
| 214 235 | 
             
                            end
         | 
| 215 236 | 
             
                        end
         | 
| 216 237 | 
             
                        @fout.puts(newl)
         | 
| 217 | 
            -
             #           puts newl
         | 
| 218 | 
            -
              #r2= randcolor(:back_rgb=>@backgroundcolor, :min_cont=>@min_cont, :max_cont=>@max_cont)
         | 
| 219 | 
            -
              #newl = line.sub(/\=0x*\;/,"=0x"+r1+";")
         | 
| 220 238 | 
             
                      else
         | 
| 221 239 | 
             
                        @fout.puts(line)
         | 
| 222 240 | 
             
                      end
         | 
| 223 241 | 
             
                    end
         | 
| 224 242 | 
             
                    if @fout then
         | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 243 | 
            +
            #        puts "wanting to delete "+@fin.path.to_s
         | 
| 244 | 
            +
            #        puts "wanting to copy this file onto it:"+@fout.path.to_s
         | 
| 245 | 
            +
                      File.delete(@fin.path.to_s)
         | 
| 246 | 
            +
                      File.rename(@fout.path.to_s, @fin.path.to_s )
         | 
| 247 | 
            +
                    else puts "there was a problem writing to the new file #{@fout.path.to_s} so I left the old one in place"
         | 
| 228 248 | 
             
                    end
         | 
| 229 249 | 
             
                    @fout.close
         | 
| 230 250 | 
             
                  end
         |