ScintillaGadget and web language

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5611
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

ScintillaGadget and web language

Post by Kwai chang caine »

Hello at all

Since several days, i try to create an editor for web language
I believed, that is not also hard than another language, but i have see i'm wrong :oops:
The problem is in fact web language are not one simple language like PB, C, etc.. But four languages together
Then for the syntax coloring, it's a hell :twisted:
Because detecting the keywords of the four languages and coloring each one, not wotks, some words exists in several languages
Furthermore for the folding it's not also simple too, because the end keyword is the same that several other
If => } and function => } so detecting the } is not enough a } can close the FUNCTION then it's a } for a IF :cry:

Then i have thinking to try to parsing the code before, for separate the 4 languages and after coloring each part, for finally remix the 4 part

At your advice, is it the best way for do that ?
Or is it possible to coloring all in one time

Have a good day
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
Skipper
User
User
Posts: 71
Joined: Thu Dec 19, 2024 1:26 pm
Location: Europe

Re: ScintillaGadget and web language

Post by Skipper »

For four languages, do not try to offer syntax highlighting for all of them at the same time.
Detect the language currently in use first, then only use the highlighter for that language. Invariably, there will be overlaps between the languages (keywords, structures, etc.), making parallel support for each of them at the same time more difficult.
It's easier to treat each one of them separately.

Using PureBasic 6.21 on:
  • Win-11 on x64 XEON
  • Mint Linux on x64 i3 and on x64 i5
  • MacOS Monterey on x64 MacBook Pro
  • Various Raspberry Pi's

User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5611
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: ScintillaGadget and web language

Post by Kwai chang caine »

Ok thanks for your advice 8)
I agree with you, which is why I'll first try parsing the language headers to determine which language we're using (HTML/CSS/JS/PHP) and then color-code the words for that language.
Thank you very much. :wink:
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
User avatar
Skipper
User
User
Posts: 71
Joined: Thu Dec 19, 2024 1:26 pm
Location: Europe

Re: ScintillaGadget and web language

Post by Skipper »

you might want to introduce a 'state' variable and store the current language at hand. If you discover, perhaps in HTML, that you find JS, you can change the state and continue with the JS highlighter...

Using PureBasic 6.21 on:
  • Win-11 on x64 XEON
  • Mint Linux on x64 i3 and on x64 i5
  • MacOS Monterey on x64 MacBook Pro
  • Various Raspberry Pi's

User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5611
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: ScintillaGadget and web language

Post by Kwai chang caine »

Yes, I'm making good progress, or at least it seems to me, in that direction. :wink:
ImageThe happiness is a road...
Not a destination

PureBasic French Forum
Post Reply