Syntax Highlighting for Embeded Javascript

630 views
Skip to first unread message

HT

unread,
Nov 1, 2011, 5:35:22 PM11/1/11
to scintilla-interest
Hi,
I'm using wxStyledTextCtrl to make simple editor. I have been abled to
make syntax highlighting for PHP and HTML but not Javascript. How do I
activate Javascript in scintilla HTML Lexer?
Thanks!

Neil Hodgson

unread,
Nov 1, 2011, 7:15:05 PM11/1/11
to scintilla...@googlegroups.com
HT:

> I'm using wxStyledTextCtrl to make simple editor. I have been abled to
> make syntax highlighting for PHP and HTML but not Javascript. How do I
> activate Javascript in scintilla HTML Lexer?

The main thing to be aware of is that there are two sets of
Javascript styles because Javascript can be used both on the client
and the server. 40..52 are for client-side styles and 55..67 for
server-side. Since SciTE implements most Scintilla features, it is a
good source for examples.

Neil

HT

unread,
Nov 1, 2011, 11:57:10 PM11/1/11
to scintilla-interest
thNka let me check scite

HT

unread,
Nov 2, 2011, 8:48:50 AM11/2/11
to scintilla-interest
Hi Neil,
I compiled scite on ubuntu Oneiric and it displays PHP page with no
syntax highlighting. Language tool on toolbar is empty. Have anyone
experienced this?
Also I'm curious as to what the difference between the above
javascripts as far as scintilla is concerned!
Thanks

KHMan

unread,
Nov 2, 2011, 11:32:12 AM11/2/11
to scintilla...@googlegroups.com
On 11/2/2011 8:48 PM, HT wrote:
> Hi Neil,
> I compiled scite on ubuntu Oneiric and it displays PHP page with no
> syntax highlighting. Language tool on toolbar is empty. Have anyone
> experienced this?

If the property files are not imported (not shown in menu listing)
then they may not have been installed into the proper directory,
e.g. /usr/share/scite

> Also I'm curious as to what the difference between the above
> javascripts as far as scintilla is concerned!
> Thanks

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

Jérôme LAFORGE

unread,
Nov 2, 2011, 11:49:57 AM11/2/11
to scintilla-interest
The simplest way to configure Scite by default is to install scite
from ubuntu repository with this cmd for example :
aptitude install scite
Jérôme

Neil Hodgson

unread,
Nov 2, 2011, 6:25:34 PM11/2/11
to scintilla...@googlegroups.com
HT:

> Also I'm curious as to what the difference between the above
> javascripts as far as scintilla is concerned!

They are highlighted separately so the user can see where the
Javascript is interpreted.

Neil

HT

unread,
Nov 4, 2011, 9:09:46 AM11/4/11
to scintilla-interest
I have successfully been able to highlight JS and I have last problem
for now.
The php start/end tags (<?php and ?>) are not highlighted. How can I
do that?
I have tried searching scite files but cannot find file that does it
(scite layout is a bit confusing)
Thanks

KHMan

unread,
Nov 4, 2011, 9:15:13 AM11/4/11
to scintilla...@googlegroups.com
On 11/4/2011 9:09 PM, HT wrote:
> I have successfully been able to highlight JS and I have last problem
> for now.
> The php start/end tags (<?php and ?>) are not highlighted. How can I
> do that?
> I have tried searching scite files but cannot find file that does it
> (scite layout is a bit confusing)

HTML highlighting works for me. Look in html.properties.

If you still have problems, please provide a short snippet, it
will be easier for anyone in the list community to test and try to
reproduce your problem.

HT

unread,
Nov 4, 2011, 9:41:21 AM11/4/11
to scintilla-interest
Hi KHMan,
I was talking on highlighting <?php and ?> using scintilla not scite.
Sorry for confusion I introduced!

KHMan

unread,
Nov 4, 2011, 10:03:21 AM11/4/11
to scintilla...@googlegroups.com
On 11/4/2011 9:41 PM, HT wrote:
> Hi KHMan,
> I was talking on highlighting<?php and ?> using scintilla not scite.
> Sorry for confusion I introduced!

Scintilla? Are you using the edit control in some app? In any
case, SciTE is always a good reference point to check if something
doesn't work in some custom stuff.

IIRC all the PHP highlighting stuff is in LexHTML.cxx.

You should provide clear info if you need anyone on the list to
attempt to diagnose any problems you may be experiencing...

HT

unread,
Nov 4, 2011, 10:27:12 AM11/4/11
to scintilla-interest
Hi KHMan,


> Scintilla? Are you using the edit control in some app?
That is right. I'm making simple editor using wxStyledTextCtrl
(wxWidgets) and I have successfully done the HTML/JS and Much of PHP.
The problem is I cannot find the way to change color of <?php and ?>.
Are they considered html tags?

> In any
> case, SciTE is always a good reference point to check if something
> doesn't work in some custom stuff.
>
I have problem in finding files to check in scite. Too many scattered
folder/files :)

> IIRC all the PHP highlighting stuff is in LexHTML.cxx.
Thanks for pointing that. Let me check hot it handles things


> You should provide clear info if you need anyone on the list to
> attempt to diagnose any problems you may be experiencing...
I hope I have tried to in first paragraph

Thanks for help

Cody

unread,
Nov 4, 2011, 10:41:31 AM11/4/11
to scintilla...@googlegroups.com
Hi,

On Fri, Nov 4, 2011 at 9:27 AM, HT <hosanna.te...@gmail.com> wrote:
> Hi KHMan,
>
>
>> Scintilla? Are you using the edit control in some app?
> That is right. I'm making simple editor using wxStyledTextCtrl
> (wxWidgets) and I have successfully done the HTML/JS and Much of PHP.
> The problem is I cannot find the way to change color of <?php and ?>.
> Are they considered html tags?
>

IIRC, STC_H_XMLSTART and STC_H_XMLEND style are used for the embedded
php tags in the HTML lexer.

May also find this useful for the various style ids:
http://wiki.wxpython.org/StyledTextCtrl%20Lexer%20Quick%20Reference


Regards,

Cody

HT

unread,
Nov 4, 2011, 10:45:26 AM11/4/11
to scintilla-interest
Hello Cody,
this is fun because I was trying to figure out how you did it in
Editra.
Thanks for the Links also!

On Nov 4, 5:41 pm, Cody <codyprec...@gmail.com> wrote:
> Hi,
>

KHMan

unread,
Nov 4, 2011, 10:50:46 AM11/4/11
to scintilla...@googlegroups.com
On 11/4/2011 10:45 PM, HT wrote:
> Hello Cody,
> this is fun because I was trying to figure out how you did it in
> Editra.
> Thanks for the Links also!
>
> On Nov 4, 5:41 pm, Cody wrote:
>> Hi,
>>
>> On Fri, Nov 4, 2011 at 9:27 AM, HT wrote:
>>> Hi KHMan,
>>
>>>> Scintilla? Are you using the edit control in some app?
>>> That is right. I'm making simple editor using wxStyledTextCtrl
>>> (wxWidgets) and I have successfully done the HTML/JS and Much of PHP.
>>> The problem is I cannot find the way to change color of<?php and ?>.
>>> Are they considered html tags?
>>
>> IIRC, STC_H_XMLSTART and STC_H_XMLEND style are used for the embedded
>> php tags in the HTML lexer.

I don't know any of wxStyledTextCtrl, but in Scintilla.iface, the
property for the <?php start is SCE_H_QUESTION.

In LexHTML.cxx, see line 897 onwards. On SciTE, the line in
question in html.properties is:

# PHP
style.hypertext.18=fore:#0000FF,back:#FFEFBF

HTH,

HT

unread,
Nov 4, 2011, 10:52:44 AM11/4/11
to scintilla-interest
Thanks,
let me check what maps that in wxSTC
Thanks again

Cody

unread,
Nov 4, 2011, 10:53:03 AM11/4/11
to scintilla...@googlegroups.com
Hi,

On Fri, Nov 4, 2011 at 9:50 AM, KHMan <kein...@gmail.com> wrote:
> On 11/4/2011 10:45 PM, HT wrote:
>>
>> Hello Cody,
>> this is fun because I was trying to figure out how you did it in
>> Editra.
>> Thanks for the Links also!
>>
>> On Nov 4, 5:41 pm, Cody wrote:
>>>
>>> Hi,
>>>
>>> On Fri, Nov 4, 2011 at 9:27 AM, HT wrote:
>>>>
>>>> Hi KHMan,
>>>
>>>>> Scintilla? Are you using the edit control in some app?
>>>>
>>>> That is right. I'm making simple editor using wxStyledTextCtrl
>>>> (wxWidgets) and I have successfully done the HTML/JS and Much of PHP.
>>>> The problem is I cannot find the way to change color of<?php and ?>.
>>>> Are they considered html tags?
>>>
>>> IIRC, STC_H_XMLSTART and STC_H_XMLEND style are used for the embedded
>>> php tags in the HTML lexer.
>
> I don't know any of wxStyledTextCtrl, but in Scintilla.iface, the property
> for the <?php start is SCE_H_QUESTION.
>

Yes that is correct my mistake. (STC_H_QUESTION)


Cody

HT

unread,
Nov 4, 2011, 10:53:24 AM11/4/11
to scintilla-interest
Hi Cody,
it does not work, and here is what I suppode must do it
m_editor->StyleSetBold(wxSTC_H_XMLSTART, true);
m_editor->StyleSetItalic(wxSTC_H_XMLSTART, true);
m_editor->StyleSetForeground(wxSTC_H_XMLSTART, *wxRED);

On Nov 4, 5:41 pm, Cody <codyprec...@gmail.com> wrote:
> Hi,
>

HT

unread,
Nov 4, 2011, 10:54:26 AM11/4/11
to scintilla-interest
Let me change it
Thanks!

HT

unread,
Nov 4, 2011, 10:58:47 AM11/4/11
to scintilla-interest
It works,
thanks to everyone.
Thanks Cody for the link. It is great reference
Cheers!
Reply all
Reply to author
Forward
0 new messages