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
@@ -0,0 +1,246 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
3
+
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
+ <meta http-equiv="cache-control" content="no-cache" />
7
+ <meta http-equiv="expires" content="3600" />
8
+ <meta name="revisit-after" content="2 days" />
9
+ <meta name="robots" content="index,follow" />
10
+ <meta name="publisher" content="Dichodaemon" />
11
+ <meta name="copyright" content="Dichodaemon" />
12
+
13
+ <meta name="author" content="Dichodaemon" />
14
+ <meta name="distribution" content="global" />
15
+ <meta name="description" content="Ocatarinetabellachithchix" />
16
+ <meta name="keywords" content="arzaversperia flexilimosos toves" />
17
+ <link rel="stylesheet" type="text/css" media="screen,projection,print" href="css/espresso_libre.css" />
18
+ <title>espresso_libre</title>
19
+
20
+ </head>
21
+
22
+ <body>
23
+ <pre class="espresso_libre"><span class="line-numbers"> 1 </span> <span class="Comment"><span class="Comment">#</span>**********************************************************************</span>
24
+ <span class="line-numbers"> 2 </span> <span class="Comment"><span class="Comment">#</span>* *</span>
25
+ <span class="line-numbers"> 3 </span> <span class="Comment"><span class="Comment">#</span>* RmThemeGen - a ruby script to create random, usable themes for *</span>
26
+ <span class="line-numbers"> 4 </span> <span class="Comment"><span class="Comment">#</span>* text editors. Currently supports RubyMine 3.X.X *</span>
27
+ <span class="line-numbers"> 5 </span> <span class="Comment"><span class="Comment">#</span>* *</span>
28
+ <span class="line-numbers"> 6 </span> <span class="Comment"><span class="Comment">#</span>* By David Heitzman, 2011 *</span>
29
+ <span class="line-numbers"> 7 </span> <span class="Comment"><span class="Comment">#</span>* *</span>
30
+ <span class="line-numbers"> 8 </span> <span class="Comment"><span class="Comment">#</span>**********************************************************************</span>
31
+ <span class="line-numbers"> 9 </span>
32
+ <span class="line-numbers"> 10 </span> <span class="Comment"><span class="Comment">#</span>this is a version of the software that should work with ruby 1.8.7</span>
33
+ <span class="line-numbers"> 11 </span> <span class="Comment"><span class="Comment">#</span>originally it was written and tested for ruby 1.9.2</span>
34
+ <span class="line-numbers"> 12 </span>
35
+ <span class="line-numbers"> 13 </span> <span class="Keyword">require</span> <span class="String"><span class="String">'</span>rubygems<span class="String">'</span></span>
36
+ <span class="line-numbers"> 14 </span> <span class="Keyword">require</span> <span class="String"><span class="String">'</span>color<span class="String">'</span></span>
37
+ <span class="line-numbers"> 15 </span> <span class="Keyword">require</span> <span class="String"><span class="String">'</span>xmlsimple<span class="String">'</span></span>
38
+ <span class="line-numbers"> 16 </span> <span class="Keyword">require</span> <span class="String"><span class="String">'</span>rexml/document<span class="String">'</span></span>
39
+ <span class="line-numbers"> 17 </span> <span class="Keyword">require</span> <span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>/token_list<span class="String">&quot;</span></span>
40
+ <span class="line-numbers"> 18 </span> <span class="Keyword">require</span> <span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">'</span>/rgb_contrast_methods<span class="String">'</span></span>
41
+ <span class="line-numbers"> 19 </span> <span class="Keyword">require</span> <span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">'</span>/rmthemegen_to_css<span class="String">'</span></span>
42
+ <span class="line-numbers"> 20 </span>
43
+ <span class="line-numbers"> 21 </span> <span class="Keyword">module</span> <span class="TypeName">RMThemeGen</span>
44
+ <span class="line-numbers"> 22 </span> <span class="Keyword">class</span> <span class="TypeName">ThemeGenerator<span class="InheritedClassName"> <span class="InheritedClassName">&lt;</span> RMThemeParent</span></span>
45
+ <span class="line-numbers"> 23 </span> <span class="Keyword">attr_reader</span> <span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>for_tm_output</span>, <span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>repository_names</span>, <span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>under_patterns</span>, <span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>scopes_found</span>
46
+ <span class="line-numbers"> 24 </span>
47
+ <span class="line-numbers"> 25 </span> <span class="Comment"> <span class="Comment">#</span> process_plists is an attempt to take from teh syntax files that are included as &quot;textmate bundles&quot; </span>
48
+ <span class="line-numbers"> 26 </span> <span class="Comment"> <span class="Comment">#</span> and use the tokens described to create syntax-themes. This attempt has so far been unsuccessful.</span>
49
+ <span class="line-numbers"> 27 </span> <span class="Comment"> <span class="Comment">#</span> all of the example theme files found in the wild do not use the tokens found in the syntax files,</span>
50
+ <span class="line-numbers"> 28 </span> <span class="Comment"> <span class="Comment">#</span> so there is some other way it has of mapping code to symbols. </span>
51
+ <span class="line-numbers"> 29 </span>
52
+ <span class="line-numbers"> 30 </span> <span class="Keyword">def</span> <span class="FunctionName">process_plists</span>
53
+ <span class="line-numbers"> 31 </span> <span class="Variable"><span class="Variable">@</span>for_tm_output</span> <span class="Keyword">=</span> {}
54
+ <span class="line-numbers"> 32 </span> files_look_in <span class="Keyword">=</span> <span class="LibraryObject">Dir</span>[<span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>/syntaxes/*.plist<span class="String">&quot;</span></span>]
55
+ <span class="line-numbers"> 33 </span> files_look_in <span class="Keyword">=</span> <span class="LibraryObject">Dir</span>[<span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>/syntaxes/Ruby.plist<span class="String">&quot;</span></span>]
56
+ <span class="line-numbers"> 34 </span> puts files_look_in.<span class="FunctionName">inspect</span>
57
+ <span class="line-numbers"> 35 </span>
58
+ <span class="line-numbers"> 36 </span> files_look_in.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">f</span>|
59
+ <span class="line-numbers"> 37 </span> puts <span class="String"><span class="String">&quot;</span>opening file <span class="String">&quot;</span></span><span class="Keyword">+</span>f.<span class="FunctionName">to_s</span>
60
+ <span class="line-numbers"> 38 </span> syntax_file <span class="Keyword">=</span> <span class="LibraryObject">File</span>.<span class="FunctionName">open</span>(f,<span class="String"><span class="String">&quot;</span>r<span class="String">&quot;</span></span>)
61
+ <span class="line-numbers"> 39 </span> indoc <span class="Keyword">=</span> <span class="Variable">REXML</span>::<span class="FunctionName">Document</span>.<span class="FunctionName">new</span>( syntax_file )
62
+ <span class="line-numbers"> 40 </span>
63
+ <span class="line-numbers"> 41 </span>
64
+ <span class="line-numbers"> 42 </span> <span class="FunctionName">visit_all_nodes</span>(indoc.<span class="FunctionName">root</span>) { |<span class="Variable">k</span>|
65
+ <span class="line-numbers"> 43 </span> <span class="Keyword">begin</span>
66
+ <span class="line-numbers"> 44 </span> <span class="Keyword">if</span> (k.<span class="FunctionName">respond_to?</span>(<span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>local_name</span>) )
67
+ <span class="line-numbers"> 45 </span> <span class="Keyword">if</span> (k.<span class="FunctionName">parent</span>.<span class="FunctionName">name</span><span class="Keyword">==</span><span class="String"><span class="String">'</span>dict<span class="String">'</span></span> <span class="Keyword">&amp;&amp;</span> (k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">respond_to?</span>(<span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>local_name</span>) ) )
68
+ <span class="line-numbers"> 46 </span> <span class="Keyword">if</span> ( k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">local_name</span><span class="Keyword">==</span><span class="String"><span class="String">'</span>key<span class="String">'</span></span> <span class="Keyword">&amp;&amp;</span> k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">text</span><span class="Keyword">==</span><span class="String"><span class="String">&quot;</span>name<span class="String">&quot;</span></span> )
69
+ <span class="line-numbers"> 47 </span> <span class="Variable"><span class="Variable">@</span>for_tm_output</span>[k.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>]<span class="Keyword">=</span><span class="String"><span class="String">'</span><span class="String">'</span></span>
70
+ <span class="line-numbers"> 48 </span> <span class="Keyword">end</span>
71
+ <span class="line-numbers"> 49 </span> <span class="Keyword">end</span>
72
+ <span class="line-numbers"> 50 </span> <span class="Keyword">end</span>
73
+ <span class="line-numbers"> 51 </span> <span class="Keyword">rescue</span> =&gt; e
74
+ <span class="line-numbers"> 52 </span> puts <span class="String"><span class="String">&quot;</span>an exception in process_plists(): <span class="String">&quot;</span></span><span class="Keyword">+</span>e.<span class="FunctionName">to_s</span>
75
+ <span class="line-numbers"> 53 </span> <span class="Keyword">end</span>
76
+ <span class="line-numbers"> 54 </span> }
77
+ <span class="line-numbers"> 55 </span>
78
+ <span class="line-numbers"> 56 </span> <span class="Comment"> <span class="Comment">#</span> take the list of tokens. Find all unique word.word prefixes. Each of them becomes a key in a new hash</span>
79
+ <span class="line-numbers"> 57 </span> <span class="Comment"> <span class="Comment">#</span> Each key points to a long string made up of a concatenation of all of the tokens from the list whose prefix</span>
80
+ <span class="line-numbers"> 58 </span> <span class="Comment"> <span class="Comment">#</span> matches the found prefix.</span>
81
+ <span class="line-numbers"> 59 </span> <span class="Comment"> <span class="Comment">#</span> so, given keyword.other.new.php and keyword.other.phpdoc.doc, we would have @hash['keyword.other']=&quot;keyword.other.new.php and keyword.other.phpdoc.doc&quot;</span>
82
+ <span class="line-numbers"> 60 </span>
83
+ <span class="line-numbers"> 61 </span> puts <span class="String"><span class="String">'</span>@for_tm_output keys listed alphabetically <span class="String">'</span></span>
84
+ <span class="line-numbers"> 62 </span> token_ary <span class="Keyword">=</span> []
85
+ <span class="line-numbers"> 63 </span> <span class="Variable"><span class="Variable">@</span>for_tm_output</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">k</span>,<span class="Variable">v</span>|
86
+ <span class="line-numbers"> 64 </span> <span class="Comment"> <span class="Comment">#</span> puts k.inspect</span>
87
+ <span class="line-numbers"> 65 </span> token_ary <span class="Keyword">&lt;&lt;</span> k.<span class="FunctionName">to_s</span>
88
+ <span class="line-numbers"> 66 </span> <span class="Keyword">end</span>
89
+ <span class="line-numbers"> 67 </span>
90
+ <span class="line-numbers"> 68 </span> token_ary.<span class="FunctionName">sort!</span>
91
+ <span class="line-numbers"> 69 </span> token_ary.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">i</span>|
92
+ <span class="line-numbers"> 70 </span> puts i.<span class="FunctionName">to_s</span>
93
+ <span class="line-numbers"> 71 </span> <span class="Keyword">end</span>
94
+ <span class="line-numbers"> 72 </span>
95
+ <span class="line-numbers"> 73 </span> <span class="Variable"><span class="Variable">@</span>nhash2</span> <span class="Keyword">=</span> {}
96
+ <span class="line-numbers"> 74 </span> <span class="Variable"><span class="Variable">@</span>for_tm_output</span>.<span class="FunctionName">each_key</span> <span class="Keyword">do </span>|<span class="Variable">t</span>|
97
+ <span class="line-numbers"> 75 </span> tkary<span class="Keyword">=</span>t.<span class="FunctionName">to_s</span>.<span class="FunctionName">split</span>(<span class="String"><span class="String">&quot;</span>.<span class="String">&quot;</span></span>)
98
+ <span class="line-numbers"> 76 </span> <span class="Keyword">if</span> tkary.<span class="FunctionName">size</span> <span class="Keyword">&gt;=</span> <span class="Number">2</span>
99
+ <span class="line-numbers"> 77 </span> <span class="Variable"><span class="Variable">@</span>nhash2</span>[ tkary[<span class="Number">0</span>]<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>.<span class="String">&quot;</span></span><span class="Keyword">+</span>tkary[<span class="Number">1</span>] ] <span class="Keyword">||=</span> <span class="String"><span class="String">'</span><span class="String">'</span></span>
100
+ <span class="line-numbers"> 78 </span> <span class="Variable"><span class="Variable">@</span>nhash2</span>[ tkary[<span class="Number">0</span>]<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>.<span class="String">&quot;</span></span><span class="Keyword">+</span>tkary[<span class="Number">1</span>] ] <span class="Keyword">+=</span> t<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span> <span class="String">&quot;</span></span>
101
+ <span class="line-numbers"> 79 </span> <span class="Keyword">else</span>
102
+ <span class="line-numbers"> 80 </span> <span class="Variable"><span class="Variable">@</span>nhash2</span>[t]<span class="Keyword">=</span><span class="String"><span class="String">'</span><span class="String">'</span></span>
103
+ <span class="line-numbers"> 81 </span> <span class="Keyword">end</span>
104
+ <span class="line-numbers"> 82 </span> <span class="Keyword">end</span>
105
+ <span class="line-numbers"> 83 </span>
106
+ <span class="line-numbers"> 84 </span>
107
+ <span class="line-numbers"> 85 </span> <span class="Comment"> <span class="Comment">#</span> @for_tm_output = @nhash2</span>
108
+ <span class="line-numbers"> 86 </span> <span class="Variable"><span class="Variable">@</span>repository_names</span> <span class="Keyword">=</span> {}
109
+ <span class="line-numbers"> 87 </span>
110
+ <span class="line-numbers"> 88 </span> indoc.<span class="FunctionName">root</span>.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span>(<span class="String"><span class="String">&quot;</span>*/dict<span class="String">&quot;</span></span>) <span class="Keyword">do </span>|<span class="Variable">e</span>|
111
+ <span class="line-numbers"> 89 </span> <span class="Comment"> <span class="Comment">#</span>okay, so this does reliably give us the top-level names (each of the ee's is one of them) </span>
112
+ <span class="line-numbers"> 90 </span> e.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">ee</span>|
113
+ <span class="line-numbers"> 91 </span> <span class="Keyword">if</span> ee.<span class="FunctionName">name</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>key<span class="String">&quot;</span></span>
114
+ <span class="line-numbers"> 92 </span> puts <span class="String"><span class="String">&quot;</span> ***** <span class="String">&quot;</span></span>
115
+ <span class="line-numbers"> 93 </span> <span class="Variable"><span class="Variable">@</span>repository_names</span>[ee.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>] <span class="Keyword">=</span> <span class="String"><span class="String">'</span><span class="String">'</span></span>
116
+ <span class="line-numbers"> 94 </span> puts ee.<span class="FunctionName">to_s</span>
117
+ <span class="line-numbers"> 95 </span> puts <span class="String"><span class="String">&quot;</span> ***** <span class="String">&quot;</span></span>
118
+ <span class="line-numbers"> 96 </span> <span class="Keyword">if</span> ee.<span class="FunctionName">next_element</span>
119
+ <span class="line-numbers"> 97 </span> <span class="FunctionName">visit_all_nodes</span>(ee.<span class="FunctionName">next_element</span>) <span class="Keyword">do </span>|<span class="Variable">eer</span>|
120
+ <span class="line-numbers"> 98 </span> <span class="Keyword">if</span> eer.<span class="FunctionName">name</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>string<span class="String">&quot;</span></span> <span class="Keyword">&amp;&amp;</span> eer.<span class="FunctionName">previous_element</span>.<span class="FunctionName">name</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>key<span class="String">&quot;</span></span> <span class="Keyword">&amp;&amp;</span> eer.<span class="FunctionName">previous_element</span>.<span class="FunctionName">text</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>name<span class="String">&quot;</span></span>
121
+ <span class="line-numbers"> 99 </span> <span class="Variable"><span class="Variable">@</span>repository_names</span>[ee.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>] <span class="Keyword">+=</span> eer.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span><span class="Keyword">+</span><span class="String"><span class="String">&quot;</span> <span class="String">&quot;</span></span>
122
+ <span class="line-numbers"> 100 </span> <span class="Keyword">end</span>
123
+ <span class="line-numbers"> 101 </span> <span class="Keyword">end</span>
124
+ <span class="line-numbers"> 102 </span> <span class="Keyword">end</span>
125
+ <span class="line-numbers"> 103 </span> <span class="Keyword">end</span>
126
+ <span class="line-numbers"> 104 </span> <span class="Keyword">end</span>
127
+ <span class="line-numbers"> 105 </span> <span class="Keyword">end</span>
128
+ <span class="line-numbers"> 106 </span>
129
+ <span class="line-numbers"> 107 </span> <span class="Variable"><span class="Variable">@</span>under_patterns</span><span class="Keyword">=</span>{}
130
+ <span class="line-numbers"> 108 </span> indoc.<span class="FunctionName">root</span>.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span>(<span class="String"><span class="String">&quot;</span>*/key<span class="String">&quot;</span></span>) <span class="Keyword">do </span>|<span class="Variable">e</span>|
131
+ <span class="line-numbers"> 109 </span> main_name<span class="Keyword">=</span><span class="String"><span class="String">'</span><span class="String">'</span></span>
132
+ <span class="line-numbers"> 110 </span> <span class="Keyword">if</span> e.<span class="FunctionName">text</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>patterns<span class="String">&quot;</span></span>
133
+ <span class="line-numbers"> 111 </span> e.<span class="FunctionName">next_element</span>.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">ee</span>| <span class="Comment"><span class="Comment">#</span>this is the main array of patterns -- these should be the dicts who define the patterns caught by the syntax engine</span>
134
+ <span class="line-numbers"> 112 </span> <span class="Keyword">if</span> ee.<span class="FunctionName">name</span><span class="Keyword">==</span><span class="String"><span class="String">&quot;</span>dict<span class="String">&quot;</span></span>
135
+ <span class="line-numbers"> 113 </span> <span class="Comment"><span class="Comment">#</span> puts &quot;&lt;&lt;&gt;&gt;&quot;+ee.inspect+&quot;&lt;&lt;&gt;&gt;&quot;</span>
136
+ <span class="line-numbers"> 114 </span> <span class="Comment"><span class="Comment">#</span> puts &quot;&lt;&lt;again&gt;&gt;&quot;+ee.elements.size.to_s+&quot;&lt;&lt;&gt;&gt;&quot;</span>
137
+ <span class="line-numbers"> 115 </span> ee.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">cc</span>|
138
+ <span class="line-numbers"> 116 </span> <span class="Keyword">if</span> [<span class="String"><span class="String">&quot;</span>name<span class="String">&quot;</span></span>, <span class="String"><span class="String">&quot;</span>contentName<span class="String">&quot;</span></span>].<span class="FunctionName">include?</span> cc.<span class="FunctionName">text</span>
139
+ <span class="line-numbers"> 117 </span> main_name <span class="Keyword">=</span> cc.<span class="FunctionName">next_element</span>.<span class="FunctionName">text</span>
140
+ <span class="line-numbers"> 118 </span> puts <span class="String"><span class="String">&quot;</span>main_name<span class="String">&quot;</span></span><span class="Keyword">+</span>main_name
141
+ <span class="line-numbers"> 119 </span> <span class="Variable"><span class="Variable">@</span>under_patterns</span>[main_name]<span class="Keyword">=</span><span class="String"><span class="String">&quot;</span><span class="String">&quot;</span></span>
142
+ <span class="line-numbers"> 120 </span> <span class="Keyword">end</span>
143
+ <span class="line-numbers"> 121 </span> <span class="Keyword">end</span>
144
+ <span class="line-numbers"> 122 </span>
145
+ <span class="line-numbers"> 123 </span> ee.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">di</span>|
146
+ <span class="line-numbers"> 124 </span> <span class="Keyword">if</span> di.<span class="FunctionName">name</span><span class="Keyword">=</span><span class="String"><span class="String">&quot;</span>dict<span class="String">&quot;</span></span>
147
+ <span class="line-numbers"> 125 </span> di.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">di_ch</span>|
148
+ <span class="line-numbers"> 126 </span> di_ch.<span class="FunctionName">elements</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">leaf</span>|
149
+ <span class="line-numbers"> 127 </span> <span class="Keyword">if</span> leaf.<span class="FunctionName">previous_element</span>
150
+ <span class="line-numbers"> 128 </span> <span class="Variable"><span class="Variable">@</span>under_patterns</span>[main_name] <span class="Keyword">+=</span> leaf.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span><span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>, <span class="String">&quot;</span></span> <span class="Keyword">if</span> (leaf.<span class="FunctionName">name</span><span class="Keyword">==</span><span class="String"><span class="String">&quot;</span>string<span class="String">&quot;</span></span> <span class="Keyword">&amp;&amp;</span> leaf.<span class="FunctionName">previous_element</span>.<span class="FunctionName">text</span> <span class="Keyword">==</span> <span class="String"><span class="String">&quot;</span>name<span class="String">&quot;</span></span>)
151
+ <span class="line-numbers"> 129 </span> <span class="Keyword">end</span>
152
+ <span class="line-numbers"> 130 </span> <span class="Keyword">end</span>
153
+ <span class="line-numbers"> 131 </span> <span class="Keyword">end</span>
154
+ <span class="line-numbers"> 132 </span> <span class="Keyword">end</span>
155
+ <span class="line-numbers"> 133 </span> <span class="Keyword">end</span>
156
+ <span class="line-numbers"> 134 </span> <span class="Keyword">end</span>
157
+ <span class="line-numbers"> 135 </span> <span class="Keyword">end</span>
158
+ <span class="line-numbers"> 136 </span> <span class="Keyword">end</span>
159
+ <span class="line-numbers"> 137 </span> <span class="Keyword">end</span>
160
+ <span class="line-numbers"> 138 </span> <span class="Comment"><span class="Comment">#</span> @under_patterns.each_key do |k| @under_patterns[k] = @under_patterns[k][ 0, @under_patterns[k].size-2 ] end </span>
161
+ <span class="line-numbers"> 139 </span> <span class="Variable"><span class="Variable">@</span>under_patterns</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">k</span>,<span class="Variable">v</span>| <span class="Variable"><span class="Variable">@</span>under_patterns</span>[k] <span class="Keyword">=</span> v[ <span class="Number">0</span>, v.<span class="FunctionName">size</span><span class="Keyword">-</span><span class="Number">2</span> ] <span class="Keyword">end</span>
162
+ <span class="line-numbers"> 140 </span> syntax_file.<span class="FunctionName">close</span>
163
+ <span class="line-numbers"> 141 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>files_look_in.each</span>
164
+ <span class="line-numbers"> 142 </span>
165
+ <span class="line-numbers"> 143 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>process_plists</span>
166
+ <span class="line-numbers"> 144 </span>
167
+ <span class="line-numbers"> 145 </span> <span class="Keyword">def</span> <span class="FunctionName">visit_all_nodes</span>(<span class="FunctionParameter">element<span class="FunctionParameter">,</span> <span class="Keyword">&amp;</span>block</span>)
168
+ <span class="line-numbers"> 146 </span> <span class="Keyword">if</span> element.<span class="FunctionName">is_a?</span>(<span class="Variable">REXML</span>::<span class="FunctionName">Element</span>)
169
+ <span class="line-numbers"> 147 </span> <span class="Keyword">if</span> element.<span class="FunctionName">has_elements?</span> <span class="Keyword">then</span>
170
+ <span class="line-numbers"> 148 </span> element.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">kkid</span>|
171
+ <span class="line-numbers"> 149 </span> <span class="FunctionName">visit_all_nodes</span>( kkid, <span class="Keyword">&amp;</span>block)
172
+ <span class="line-numbers"> 150 </span> <span class="Keyword">end</span>
173
+ <span class="line-numbers"> 151 </span> <span class="Keyword">else</span>
174
+ <span class="line-numbers"> 152 </span> <span class="Keyword">yield</span> element
175
+ <span class="line-numbers"> 153 </span> <span class="Keyword">end</span>
176
+ <span class="line-numbers"> 154 </span> <span class="Keyword">end</span>
177
+ <span class="line-numbers"> 155 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>visit_all_nodes</span>
178
+ <span class="line-numbers"> 156 </span>
179
+ <span class="line-numbers"> 157 </span>
180
+ <span class="line-numbers"> 158 </span> <span class="Keyword">def</span> <span class="FunctionName">get_scopes_from_themefiles</span>
181
+ <span class="line-numbers"> 159 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span> <span class="Keyword">=</span> {}
182
+ <span class="line-numbers"> 160 </span> <span class="Variable"><span class="Variable">@</span>files_look_in</span> <span class="Keyword">=</span> <span class="LibraryObject">Dir</span>[<span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>/textmate_themes/*.tmTheme<span class="String">&quot;</span></span>]
183
+ <span class="line-numbers"> 161 </span> <span class="Comment"> <span class="Comment">#</span> @files_look_in = Dir[File.dirname(__FILE__)+&quot;/textmate_themes/Brilliance Dull.tmTheme&quot;]</span>
184
+ <span class="line-numbers"> 162 </span> <span class="Variable"><span class="Variable">@</span>files_look_in</span> <span class="Keyword">=</span> <span class="LibraryObject">Dir</span>[<span class="LibraryObject">File</span>.<span class="FunctionName">dirname</span>(<span class="Variable">__FILE__</span>)<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>/textmate_themes/choco.tmTheme<span class="String">&quot;</span></span>]
185
+ <span class="line-numbers"> 163 </span> puts <span class="String"><span class="String">'</span>@files_look_in.inspect<span class="String">'</span></span>
186
+ <span class="line-numbers"> 164 </span> puts <span class="Variable"><span class="Variable">@</span>files_look_in</span>.<span class="FunctionName">inspect</span>
187
+ <span class="line-numbers"> 165 </span>
188
+ <span class="line-numbers"> 166 </span> <span class="Variable"><span class="Variable">@</span>files_look_in</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">f</span>|
189
+ <span class="line-numbers"> 167 </span> puts <span class="String"><span class="String">&quot;</span>opening file <span class="String">&quot;</span></span><span class="Keyword">+</span>f.<span class="FunctionName">to_s</span>
190
+ <span class="line-numbers"> 168 </span> <span class="Variable"><span class="Variable">@</span>num_sf</span> <span class="Keyword">=</span><span class="Number">0</span>
191
+ <span class="line-numbers"> 169 </span> syntax_file <span class="Keyword">=</span> <span class="LibraryObject">File</span>.<span class="FunctionName">open</span>(f,<span class="String"><span class="String">&quot;</span>r<span class="String">&quot;</span></span>)
192
+ <span class="line-numbers"> 170 </span> indoc <span class="Keyword">=</span> <span class="Variable">REXML</span>::<span class="FunctionName">Document</span>.<span class="FunctionName">new</span>( syntax_file )
193
+ <span class="line-numbers"> 171 </span> <span class="FunctionName">visit_all_nodes</span>(indoc.<span class="FunctionName">root</span>) { |<span class="Variable">k</span>|
194
+ <span class="line-numbers"> 172 </span> <span class="Keyword">begin</span>
195
+ <span class="line-numbers"> 173 </span> <span class="Keyword">if</span> (k.<span class="FunctionName">respond_to?</span>(<span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>local_name</span>) )
196
+ <span class="line-numbers"> 174 </span> <span class="Keyword">if</span> (k.<span class="FunctionName">parent</span>.<span class="FunctionName">name</span><span class="Keyword">==</span><span class="String"><span class="String">'</span>dict<span class="String">'</span></span> <span class="Keyword">&amp;&amp;</span> (k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">respond_to?</span>(<span class="UserDefinedConstant"><span class="UserDefinedConstant">:</span>local_name</span>) ) )
197
+ <span class="line-numbers"> 175 </span> <span class="Keyword">if</span> ( k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">local_name</span><span class="Keyword">==</span><span class="String"><span class="String">'</span>key<span class="String">'</span></span> <span class="Keyword">&amp;&amp;</span> k.<span class="FunctionName">previous_element</span>.<span class="FunctionName">text</span><span class="Keyword">==</span><span class="String"><span class="String">&quot;</span>scope<span class="String">&quot;</span></span> )
198
+ <span class="line-numbers"> 176 </span> <span class="Comment"> <span class="Comment">#</span> the following monkey business allows us to see how many times we've seen a key</span>
199
+ <span class="line-numbers"> 177 </span> <span class="Variable"><span class="Variable">@</span>num_sf</span> <span class="Keyword">+=</span> <span class="Number">1</span>
200
+ <span class="line-numbers"> 178 </span> <span class="Keyword">if</span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>[k.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>]
201
+ <span class="line-numbers"> 179 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>[k.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>] <span class="Keyword">+=</span> <span class="Number">1</span>
202
+ <span class="line-numbers"> 180 </span> <span class="Keyword">else</span>
203
+ <span class="line-numbers"> 181 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>[k.<span class="FunctionName">text</span>.<span class="FunctionName">to_s</span>] <span class="Keyword">=</span> <span class="Number">1</span>
204
+ <span class="line-numbers"> 182 </span> <span class="Keyword">end</span>
205
+ <span class="line-numbers"> 183 </span> <span class="Keyword">end</span>
206
+ <span class="line-numbers"> 184 </span> <span class="Keyword">end</span>
207
+ <span class="line-numbers"> 185 </span> <span class="Keyword">end</span>
208
+ <span class="line-numbers"> 186 </span> <span class="Keyword">rescue</span> =&gt; e
209
+ <span class="line-numbers"> 187 </span> puts <span class="String"><span class="String">&quot;</span>an exception in process_plists(): <span class="String">&quot;</span></span><span class="Keyword">+</span>e.<span class="FunctionName">to_s</span>
210
+ <span class="line-numbers"> 188 </span> <span class="Keyword">end</span>
211
+ <span class="line-numbers"> 189 </span> }
212
+ <span class="line-numbers"> 190 </span> <span class="Comment"><span class="Comment">#</span> puts &quot;Found #{@num_sf} scopes in file #{syntax_file.to_s}&quot; </span>
213
+ <span class="line-numbers"> 191 </span> syntax_file.<span class="FunctionName">close</span>
214
+ <span class="line-numbers"> 192 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>files_look_in.each</span>
215
+ <span class="line-numbers"> 193 </span> <span class="Variable"><span class="Variable">@</span>use_scope_threshhold</span> <span class="Keyword">=</span> <span class="Number">0</span> <span class="Comment"><span class="Comment">#</span> a scope will be used only if it appears at least this number of times in the existing themes </span>
216
+ <span class="line-numbers"> 194 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">k</span>,<span class="Variable">v</span>|
217
+ <span class="line-numbers"> 195 </span> puts k<span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>-&gt;<span class="String">&quot;</span></span><span class="Keyword">+</span>v.<span class="FunctionName">to_s</span>
218
+ <span class="line-numbers"> 196 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>.<span class="FunctionName">delete</span>(k) <span class="Keyword">unless</span> v <span class="Keyword">&gt;=</span> <span class="Variable"><span class="Variable">@</span>use_scope_threshhold</span>
219
+ <span class="line-numbers"> 197 </span> <span class="Keyword">end</span>
220
+ <span class="line-numbers"> 198 </span>
221
+ <span class="line-numbers"> 199 </span> outf<span class="Keyword">=</span><span class="LibraryObject">File</span>.<span class="FunctionName">new</span>(<span class="String"><span class="String">&quot;</span>scopes_harvested<span class="String">&quot;</span></span>,<span class="String"><span class="String">&quot;</span>w<span class="String">&quot;</span></span>)
222
+ <span class="line-numbers"> 200 </span> outf.<span class="FunctionName">printf</span> <span class="String"><span class="String">&quot;</span>%s<span class="String">&quot;</span></span>,<span class="String"><span class="String">&quot;</span>[<span class="String">&quot;</span></span>
223
+ <span class="line-numbers"> 201 </span> <span class="Variable"><span class="Variable">@</span>scopes_found</span>.<span class="FunctionName">each</span> <span class="Keyword">do </span>|<span class="Variable">k</span>,<span class="Variable">v</span>|
224
+ <span class="line-numbers"> 202 </span> outf.<span class="FunctionName">printf</span>(<span class="String"><span class="String">&quot;</span>%s<span class="String">&quot;</span></span>,<span class="String"><span class="String">&quot;</span>'<span class="String">&quot;</span></span><span class="Keyword">+</span>k.<span class="FunctionName">to_s</span><span class="Keyword">+</span><span class="String"><span class="String">&quot;</span>', <span class="String">&quot;</span></span>)
225
+ <span class="line-numbers"> 203 </span> <span class="Keyword">end</span>
226
+ <span class="line-numbers"> 204 </span> outf.<span class="FunctionName">printf</span> <span class="String"><span class="String">&quot;</span>]<span class="String">&quot;</span></span>
227
+ <span class="line-numbers"> 205 </span> outf.<span class="FunctionName">close</span>
228
+ <span class="line-numbers"> 206 </span> puts <span class="String"><span class="String">&quot;</span>harvested <span class="StringInterpolation"><span class="StringInterpolation">#{</span><span class="Variable"><span class="Variable">@</span>scopes_found</span><span class="StringInterpolation"><span class="StringInterpolation">.</span><span class="FunctionName">size</span></span><span class="StringInterpolation">}</span></span> scopes from <span class="StringInterpolation"><span class="StringInterpolation">#{</span><span class="Variable"><span class="Variable">@</span>files_look_in</span><span class="StringInterpolation"><span class="StringInterpolation">.</span><span class="FunctionName">size</span></span><span class="StringInterpolation">}</span></span> files.<span class="String">&quot;</span></span>
229
+ <span class="line-numbers"> 207 </span>
230
+ <span class="line-numbers"> 208 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>get_scopes_from_themefiles</span>
231
+ <span class="line-numbers"> 209 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>class</span>
232
+ <span class="line-numbers"> 210 </span> <span class="Keyword">end</span> <span class="Comment"><span class="Comment">#</span>module </span>
233
+ </pre> <p>
234
+ <a href="http://validator.w3.org/check?uri=referer">
235
+ <img style="border:0"
236
+ src="http://www.w3.org/Icons/valid-xhtml10"
237
+ alt="Valid XHTML 1.0 Strict" height="31" width="88" />
238
+ </a>
239
+ <a href="http://jigsaw.w3.org/css-validator/check?uri=referer">
240
+ <img style="border:0;width:88px;height:31px"
241
+ src="http://jigsaw.w3.org/css-validator/images/vcss"
242
+ alt="Valid CSS!" />
243
+ </a>
244
+ </p>
245
+ </body>
246
+ </html>
@@ -0,0 +1,242 @@
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
+ #this is a version of the software that should work with ruby 1.8.7
11
+ #originally it was written and tested for ruby 1.9.2
12
+
13
+
14
+ module RMThemeGen
15
+ class ThemeTextmate < RMThemeParent
16
+ attr_reader :for_tm_output, :repository_names, :under_patterns, :scopes_found
17
+ attr_accessor :scopes_found_count, :uses_same_foreground, :color_2_group, :group_2_color, :scope_2_group
18
+ #color_group_colors is a hash: it points from a hex color (#FE2301) => a string ('group14'). Many different colors might point to 1 string
19
+ #color_groups hashes from a scope name to a color group.
20
+ # process_plists is an attempt to take from teh syntax files that are included as "textmate bundles"
21
+ # and use the tokens described to create syntax-themes. This attempt has so far been unsuccessful.
22
+ # all of the example theme files found in the wild do not use the tokens found in the syntax files,
23
+ # so there is some other way it has of mapping code to symbols.
24
+
25
+ def process_plists
26
+ @for_tm_output = {}
27
+ files_look_in = Dir[File.dirname(__FILE__)+"/syntaxes/*.plist"]
28
+ files_look_in = Dir[File.dirname(__FILE__)+"/syntaxes/Ruby.plist"]
29
+ puts files_look_in.inspect
30
+
31
+ files_look_in.each do |f|
32
+ puts "opening file "+f.to_s
33
+ syntax_file = File.open(f,"r")
34
+ indoc = REXML::Document.new( syntax_file )
35
+
36
+
37
+ visit_all_nodes(indoc.root) { |k|
38
+ begin
39
+ if (k.respond_to?(:local_name) )
40
+ if (k.parent.name=='dict' && (k.previous_element.respond_to?(:local_name) ) )
41
+ if ( k.previous_element.local_name=='key' && k.previous_element.text=="name" )
42
+ @for_tm_output[k.text.to_s]=''
43
+ end
44
+ end
45
+ end
46
+ rescue => e
47
+ puts "an exception in process_plists(): "+e.to_s
48
+ end
49
+ }
50
+
51
+ # take the list of tokens. Find all unique word.word prefixes. Each of them becomes a key in a new hash
52
+ # Each key points to a long string made up of a concatenation of all of the tokens from the list whose prefix
53
+ # matches the found prefix.
54
+ # so, given keyword.other.new.php and keyword.other.phpdoc.doc, we would have @hash['keyword.other']="keyword.other.new.php and keyword.other.phpdoc.doc"
55
+
56
+ token_ary = []
57
+ @for_tm_output.each do |k,v|
58
+ token_ary << k.to_s
59
+ end
60
+
61
+ token_ary.sort!
62
+ token_ary.each do |i|
63
+ end
64
+
65
+ @nhash2 = {}
66
+ @for_tm_output.each_key do |t|
67
+ tkary=t.to_s.split(".")
68
+ if tkary.size >= 2
69
+ @nhash2[ tkary[0]+"."+tkary[1] ] ||= ''
70
+ @nhash2[ tkary[0]+"."+tkary[1] ] += t+" "
71
+ else
72
+ @nhash2[t]=''
73
+ end
74
+ end
75
+
76
+ @repository_names = {}
77
+
78
+ indoc.root.elements.each("*/dict") do |e|
79
+ #okay, so this does reliably give us the top-level names (each of the ee's is one of them)
80
+ e.elements.each do |ee|
81
+ if ee.name == "key"
82
+ puts " ***** "
83
+ @repository_names[ee.text.to_s] = ''
84
+ puts ee.to_s
85
+ puts " ***** "
86
+ if ee.next_element
87
+ visit_all_nodes(ee.next_element) do |eer|
88
+ if eer.name == "string" && eer.previous_element.name == "key" && eer.previous_element.text == "name"
89
+ @repository_names[ee.text.to_s] += eer.text.to_s+" "
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ @under_patterns={}
98
+ indoc.root.elements.each("*/key") do |e|
99
+ main_name=''
100
+ if e.text == "patterns"
101
+ e.next_element.elements.each do |ee| #this is the main array of patterns -- these should be the dicts who define the patterns caught by the syntax engine
102
+ if ee.name=="dict"
103
+ # puts "<<>>"+ee.inspect+"<<>>"
104
+ # puts "<<again>>"+ee.elements.size.to_s+"<<>>"
105
+ ee.elements.each do |cc|
106
+ if ["name", "contentName"].include? cc.text
107
+ main_name = cc.next_element.text
108
+ puts "main_name"+main_name
109
+ @under_patterns[main_name]=""
110
+ end
111
+ end
112
+
113
+ ee.elements.each do |di|
114
+ if di.name="dict"
115
+ di.elements.each do |di_ch|
116
+ di_ch.elements.each do |leaf|
117
+ if leaf.previous_element
118
+ @under_patterns[main_name] += leaf.text.to_s+", " if (leaf.name=="string" && leaf.previous_element.text == "name")
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
128
+ # @under_patterns.each_key do |k| @under_patterns[k] = @under_patterns[k][ 0, @under_patterns[k].size-2 ] end
129
+ @under_patterns.each do |k,v| @under_patterns[k] = v[ 0, v.size-2 ] end
130
+ syntax_file.close
131
+ end #files_look_in.each
132
+
133
+ end #process_plists
134
+
135
+ def visit_all_nodes(element, &block)
136
+ if element.is_a?(REXML::Element)
137
+ if element.has_elements? then
138
+ element.each do |kkid|
139
+ visit_all_nodes( kkid, &block)
140
+ end
141
+ else
142
+ yield element
143
+ end
144
+ end
145
+ end #visit_all_nodes
146
+
147
+
148
+ def get_scopes_from_themefiles
149
+ @scopes_found_count = {}
150
+ @scopes_found = []
151
+ @scopes_found_hash = {}
152
+ # self.group_2_color = {}
153
+ @color_2_group = {} #each key returns an array of strings, each of which is a scope that shares the color of the key
154
+ @scope_2_group = {} #key is a string for a scope, and the value is an array of strings that are scopes.
155
+
156
+ @uses_same_foreground = {} #the key is a color in uppercase hex such as #FFAAB1, etc. it points to an array of scope names that use this color. it is necessary to color certain elements the same, so as to achieve effects, like @a -- an object variable
157
+ #should all be the same color not 1 color for the @ and 1 color for the a
158
+ # files_look_in = Dir[File.dirname(__FILE__)+"/textmate_themes/*.tmTheme"]
159
+ files_look_in = Dir[File.dirname(__FILE__)+"/textmate_themes/IR_Black.tmTheme"]
160
+ # files_look_in = Dir[File.dirname(__FILE__)+"/textmate_themes/Brilliance\ Black.tmTheme"]
161
+ use_scope_threshhold =0 # a scope will be used only if it appears at least this number of times in the existing themes
162
+
163
+ num_sf =0
164
+
165
+ files_look_in.each do |f|
166
+ syntax_file = File.open(f,"r")
167
+ indoc = REXML::Document.new( syntax_file )
168
+ visit_all_nodes(indoc.root) { |k|
169
+ begin
170
+ if (k.respond_to?(:local_name) )
171
+ if (k.parent.name=='dict' && (k.previous_element.respond_to?(:local_name) ) )
172
+ if ( k.previous_element.local_name=='key' && k.previous_element.text=="scope" )
173
+ # the following monkey business allows us to see how many times we've seen a key
174
+ num_sf += 1
175
+ ssk = String.new(k.text.to_s)
176
+ @scopes_found_count[ssk] ||= 0
177
+ @scopes_found_count[ssk] += 1
178
+ @scopes_found << ssk
179
+ curstyle=get_style_here(k)
180
+ @color_2_group[curstyle["foreground"]] ||= [] if curstyle["foreground"]
181
+ #lku = ssk+unique_number.to_s #unique group string
182
+ if curstyle["foreground"]
183
+ @color_2_group[curstyle["foreground"]]<<ssk
184
+ else
185
+ @color_2_group[curstyle["nocolor"] ] << ssk
186
+ end
187
+ @scope_2_group[ssk] = curstyle["foreground"] || "nocolor"
188
+ end
189
+ end
190
+ end
191
+ rescue Exception => e
192
+ puts "an exception in process_plists(): "+e.to_s
193
+ end
194
+ }
195
+ uses_same_foreground.delete_if do |k,v| v.size == 1 end
196
+ # puts "uses same foreground: "+uses_same_foreground.inspect
197
+ # puts "Found #{@num_sf} scopes in file #{syntax_file.to_s}"
198
+ syntax_file.close
199
+ end #files_look_in.each
200
+
201
+ self.scopes_found_count.each do |k,v|
202
+ self.scopes_found_count.delete(k) unless v >= use_scope_threshhold
203
+ end
204
+
205
+ outf=File.new("scopes_harvested","w")
206
+ outf.printf "%s","["
207
+ scopes_found.each do |k,v|
208
+ outf.printf("%s","'"+k.to_s+"',\n ")
209
+ end
210
+ outf.printf "]"
211
+ outf.close
212
+ puts "plist_to_tokenlist line 205: harvested #{scopes_found.size} scopes from #{files_look_in.size} files."
213
+ return scopes_found
214
+ end #get_scopes_from_themefiles
215
+
216
+
217
+ def get_style_here(element)
218
+ #this is for getting the style features of a single element, given that we are given an element within a top-level dict
219
+
220
+ n = element
221
+ fail=0
222
+ while n.local_name != "dict" && fail < 15
223
+ n = n.next_element
224
+ fail += 1
225
+ end
226
+ return nil if n.local_name != "dict" || !n.has_elements?
227
+
228
+ h={}
229
+ # puts "plist_to_tokenlist#get_style_here (line 207) - n.local_name.inspect == "+n.local_name
230
+ n.elements.each do |kid|
231
+ if kid.local_name == "key"
232
+ #puts "key found "+kid.text
233
+ h[kid.text]=kid.next_element.text if kid.next_element
234
+ end
235
+ end
236
+ #puts "plist_to_tokenlist#get_style_here (line 207) - <dict> == "+h.inspect
237
+ return h
238
+ end #get_style_here
239
+
240
+
241
+ end #class
242
+ end #module