How to create custom function names in gedit?

I am trying to customize the gedit style so that user functions have a different color.

I searched for http://library.gnome.org/devel/gtksourceview-2.0/stable/lang-reference.html but didn't find anything.

I thought I <style name="def:function" />could do this, but it doesn't seem to affect gedit.

<?xml version="1.0" ?>
<style-scheme id="wombat" name="Wombat" version="1.0">
        <author/>
        <_description>Wombat theme</_description>
        <style background="#2d2d2d" name="current-line"/>
        <style background="#857b6f" bold="true" foreground="#fff000" name="bracket-match"/>
        <style background="#242424" bold="true" foreground="#fff000" name="search-match"/>
        <style background="#656565" name="cursor"/>
        <style background="#242424" foreground="#f6f3e8" name="text"/>
        <style background="#272727" foreground="#857b6f" name="line-numbers"/>
        <style foreground="#363636" italic="true" name="def:comment"/>
        <style foreground="#e5786d" name="def:constant"/>
        <style foreground="#95e454" italic="true" name="def:string"/>
        <style foreground="#cae682" name="def:identifier"/>
        <style foreground="#000000" name="def:function"/>
        <style foreground="#cae682" name="def:type"/>
        <style foreground="#8ac6f2" name="def:statement"/>
        <style foreground="#8ac6f2" name="def:keyword"/>
        <style foreground="#e5786d" name="def:preprocessor"/>
        <style foreground="#e5786d" name="def:number"/>
        <style foreground="#e7f6da" name="def:specials"/>
    </style-scheme>

Any clues? Thank!

+3
source share
2 answers

You need to edit the language definition file to add a new section. The definition of language is python.langalso for me /usr/share/gtksourceview-2.0/language-specs.

First you need to add a style for the identifier of the style that you are going to create:

<style id="class-name"    _name="Python Class Name"  map-to="def:type"/>

<context-id="python":

<context id="class-name" style-ref="class-name" style-inside="true">
    <start>\%{string-prefix}def\ </start>
    <end>\(</end>
    <include>
        <context ref="python"/>
        <context ref="format"/>
        <context ref="escaped-char"/>
    </include>
</context>

style-inside="true", def (, . :

() "true", ; .

, gedit, , , . AttributeError . map-to , , .

, , , gedit, , - , python .


: , "def". " " ( ) " ", , , . , .

: enter image description here

, : enter image description here

+1

, , *.lang

<style id="function" _name="Functions"/>

,

<context id="functions" style-ref="function">
    <keyword>abs</keyword>
    <keyword>acos</keyword>
    <keyword>acosh</keyword>
</context>

<context ref="functions"/>

, , allways gos , .

formmat style/*. xml,

<style name="php:function" foreground="#0000ee" bold="false"/>

php, , , *.lang.

0

Source: https://habr.com/ru/post/1773609/


All Articles