Can't define php color for functions
-
Hi
I am trying to create my own template which I was using till now with another app, but I have trouble with php functions and reserver words like “echo” or “include”. I am trying to set the foreground and background colour for it, I can’t find how.
E.g. I know how to set all other elements color, it’s just for these ones. Can someone help me?My xml config file contains regarding php:
```
<LexerType name=“php” desc=“php” ext=“”>
<WordsStyle name=“QUESTION MARK” styleID=“18” fgColor=“000000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“DEFAULT” styleID=“118” fgColor=“000000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“STRING” styleID=“119” fgColor=“008000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“STRING VARIABLE” styleID=“126” fgColor=“808000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“COMPLEX VARIABLE” styleID=“104” fgColor=“000000” bgColor=“FFFFFF” fontName=“” fontStyle=“1” fontSize=“” />
<WordsStyle name=“SIMPLESTRING” styleID=“120” fgColor=“008000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“WORD” styleID=“121” fgColor=“8959A8” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” keywordClass=“instre1” />
<WordsStyle name=“NUMBER” styleID=“122” fgColor=“000080” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“VARIABLE” styleID=“123” fgColor=“0000FF” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“COMMENT” styleID=“124” fgColor=“808080” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“COMMENTLINE” styleID=“125” fgColor=“808080” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
<WordsStyle name=“OPERATOR” styleID=“127” fgColor=“000000” bgColor=“FFFFFF” fontName=“” fontStyle=“0” fontSize=“” />
</LexerType> -
In PHP, the
echo
andinclude
keywords are set with the WORD color style, along with all the all the other keywords.If you are changing the WORD entry as shown above, and it’s not changing, make sure you are exiting Notepad++ and re-running, because it doesn’t see “live” changes in your
stylers.xml
orthemes\MyTheme.xml
– the application needs to be reloaded to see changes to those config files.–
update: In case it’s not clear: the entire list of keywords in the Settings > Style Configurator > php > WORD’s Default keywords box will all get the same color. If you want a different color for just those two keywords, that’s not something that the PHP lexer can do on its own. You might use the EnhanceAnyLexer plugin to add “extra” colors for those keywords using something like
0x0000FF = \b(echo|include)\b.
OTOH: if you want them to be the same color as other keywords, and they aren’t, then maybe it’s because you updated Notepad++ from a version that didn’t have those two keywords. If that’s the case, they will be missing from the Default keywords box mentioned above. You can edit
%AppData%\Notepad++\langs.xml
and change the list of default keywords in there… or, easier, you can just add them to the User-defined keywords box on the same Style Configurator page. (Though it looks likeecho
andinclude
have been there for at least a decade, so that’s probably not it) -
@PeterJones Thank you. Don’t know why I didn’t saw it…
-
Update from the future:
this post shares instructions for using the PythonScript plugin to add one or more “substyles” to the PHP lexer, so that you can define your own PHP keyword lists with their own custom colors.