STC_LEX_HTML, highlight control structures of php

Hi everyone,

I'm working on a gui, with wxPython, intented to write php code (in a
StyledTextCtrl). I managed to set styles for different elements of php
code, but i can't find any helpful informations about the way to set
style for special words and control structures of php (i.e. "class",
"function", "while", "for", "if", "else", etc...)

I thank you in advance for your help!

Stéphane

Hi,

Hi everyone,

I'm working on a gui, with wxPython, intented to write php code (in a
StyledTextCtrl). I managed to set styles for different elements of php
code, but i can't find any helpful informations about the way to set
style for special words and control structures of php (i.e. "class",
"function", "while", "for", "if", "else", etc...)

I thank you in advance for your help!

1) You need to set the style for:

STC_HPHP_WORD

2) You need to tell the control what the special keywords are by calling

StyledTextCtrl.SetKeyWords(SET_INDEX, STRING_OF_KEYWORDS)

The SET_INDEX is an integer that represents the set of keywords,
unfortunately the only real way to see what index to use for what set
of keywords is to look at the Scintilla source code. For PHP keywords
using the HTML lexer you can use 4.

The STRING_OF_KEYWORDS is a string of space separated keywords that
are to be highlighted using the style that was set for the set of
keywords.

SetKeyWords(4, "while if else for ...")

Cody

···

On Tue, Mar 1, 2011 at 5:54 AM, stephane <stephanehnzr@gmail.com> wrote:

Thank you very much! I managed to solve my problem according to the
infos you gave!! :slight_smile:

···

On 1 mar, 17:34, Cody Precord <codyprec...@gmail.com> wrote:

1) You need to set the style for:

STC_HPHP_WORD

2) You need to tell the control what the special keywords are by calling

StyledTextCtrl.SetKeyWords(SET_INDEX, STRING_OF_KEYWORDS)

The SET_INDEX is an integer that represents the set of keywords,
unfortunately the only real way to see what index to use for what set
of keywords is to look at the Scintilla source code. For PHP keywords
using the HTML lexer you can use 4.

The STRING_OF_KEYWORDS is a string of space separated keywords that
are to be highlighted using the style that was set for the set of
keywords.

SetKeyWords(4, "while if else for ...")

Cody