4

我想能夠找到一種方法來顏色函數調用在不同顏色的名稱。這種行爲適用於C語言,但不適用於Python。這就是爲什麼我認爲應該可以做到這一點。突出顯示函數調用崇高文本(python)

編輯:

我不是在尋找的顏色方案語法具體,我寧願找特定的線路,我將不得不添加到Python.tmLanguage。

由JDI嘗試的建議後,我結束了這一點:

enter image description here

我想會是什麼只有陣列被不同顏色的,而不是括號,對象調用方法,等等。 。

+0

好吧,當你說的亮點,你的意思是所有的時間,或所選擇的顏色?因爲我無法弄清楚我的答案中缺少什麼。你以某種方式有一個Python.tmLanguage不包含那些已經存在的模式defs – jdi 2012-08-18 22:03:26

回答

1

這是我迄今爲止它並不完美,但它還挺作品:

我把這塊從C.tmLanguage文件它捆綁在每個ST2中並添加了一些內容,以便它們可以與Python.tmLanguage文件中定義的一些Python默認函數的顏色不同:

<dict> 
     <key>captures</key> 
     <dict> 
      <key>1</key> 
      <dict> 
       <key>name</key> 
       <string>punctuation.whitespace.function-call.leading.python</string> 
      </dict> 
      <key>2</key> 
      <dict> 
       <key>name</key> 
       <string>support.function.any-method.python</string> 
      </dict> 
      <key>3</key> 
      <dict> 
       <key>name</key> 
       <string>punctuation.definition.parameters.python</string> 
      </dict> 
     </dict> 
     <key>match</key> 
     <string>(?x) (?: (?= \s) (?:(?&lt;=else|new|return) | (?&lt;!\w)) (\s+))? 
(\b 
    (?!(while|for|do|if|else|switch|catch|enumerate|return|r?iterate| 
     __import__|all|abs|any|apply|callable|chr|cmp|coerce|compile|delattr|dir| 
     divmod|eval|execfile|filter|getattr|globals|hasattr|hash|hex|id| 
     input|intern|isinstance|issubclass|iter|len|locals|map|max|min|oct| 
     ord|pow|range|raw_input|reduce|reload|repr|round|setattr|sorted| 
     sum|unichr|vars|zip|basestring|bool|buffer|classmethod|complex|dict|enumerate|file| 
     float|frozenset|int|list|long|object|open|property|reversed|set| 
     slice|staticmethod|str|super|tuple|type|unicode|xrange| 
     abs|add|and|call|cmp|coerce|complex|contains|del|delattr| 
     delete|delitem|delslice|div|divmod|enter|eq|exit|float| 
     floordiv|ge|get|getattr|getattribute|getitem|getslice|gt| 
     hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|init| 
     int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len| 
     long|lshift|lt|mod|mul|ne|neg|new|nonzero|oct|or|pos|pow| 
     radd|rand|rdiv|rdivmod|repr|rfloordiv|rlshift|rmod|rmul|ror| 
     rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem| 
     setslice|str|sub|truediv|unicode|xor 
    )\s*\()(?:(?!NS)[A-Za-z_][A-Za-z0-9_]*+\b | ::)++     # actual name 
) 
\s*(\()</string> 
     <key>name</key> 
     <string>meta.function-call.python</string> 
    </dict> 

這就是輸出看起來像使用Monokai Bright主題的方式,雖然它非常微妙,您可以注意到open的格式與array不同。

enter image description here

4

您需要編輯現有的主題,或複製一個,修改它,並設置到...然後你就可以像這樣添加一些底部:

<dict> 
    <key>name</key> 
    <string>Function call</string> 
    <key>scope</key> 
    <string>meta.function-call - punctuation - meta.function-call.arguments</string> 
    <key>settings</key> 
    <dict> 
     <key>foreground</key> 
     <string>#FF0000</string> 
    </dict> 
</dict> 

這將採用函數調用模式,並減去調用括號的子集,只留下名稱。

默認主題位於:Packages/Color Scheme - Default

Highlighted Text example

+0

我試過這個,但它沒有工作。 – 2012-08-16 05:28:27

+0

適合我!確保您已設置爲在應用程序中使用該主題 – jdi 2012-08-16 05:42:25

+0

對不起,我的問題非常模糊,儘管這有助於我完全不在尋找。雖然謝謝! – 2012-08-16 05:52:29