Lazarus

Programming => General => Topic started by: BlueIcaro on August 21, 2010, 03:42:33 pm

Title: Making highligher for C syntaxis
Post by: BlueIcaro on August 21, 2010, 03:42:33 pm
Hello, I would like highligh a C source. For  the moment I use TSynAnySyn, but I would like a folding, like does TSynPassyn.

I read the wiki, http://wiki.lazarus.freepascal.org/SynEdit_Highlighter (http://wiki.lazarus.freepascal.org/SynEdit_Highlighter), that wrotes Martin_fr, as I read in this forum.

I understand the "idea" of folding, but I don't know how to start.

Any suggestion, or idea, or info?.

Thanks in advance

/BlueIcaro
Title: Re: Making highligher for C syntaxis
Post by: Martin_fr on August 21, 2010, 10:09:23 pm
There is synhighlightercpp for C++ highlighting. However, it doesn't have folding.

There are several highlighters with folding by now. I would say synhighlighterlfm is the easiest to read. So that could serve as example.

(Get)FoldConfig* methods are *not* mandatory. folding will work without them. It's only for the IDE, to be able to switch on/off individual kinds of fold.

Otherwise, best is to ask concrete questions.
There are also one or two (literally only one or two) remarks in the docs folder, xml

---
First step would be to move the existing (or modified copy) under the foldhighlighter base class.

Main issue I can think of is the "range" (search in SetLine / search fRange). This may be an int, or a set. But in fold, it is an object.
The object provides a space (pointer, need typecast) for the old range.

Then if thats working, you can go about adding the calls to Start/EndCodeFoldBlock
Title: Re: Making highligher for C syntaxis
Post by: BlueIcaro on August 24, 2010, 03:43:37 pm
Thank you for the information Martin_fr. I need time to study the problem. But I think yout information it's a good starting.

/BlueIcaro
Title: Re: Making highligher for C syntaxis
Post by: Martin_fr on August 24, 2010, 03:48:43 pm
Also look at the diff in revision 22552. that is where the LFM higlighter moved into folding.

So you see the exact differences.
Also check rev 22606, 22608

Basically the diff from before 22552 to after 22608
Title: Re: Making highligher for C syntaxis
Post by: mas steindorff on August 24, 2010, 07:17:14 pm
notepad++ has both.  I beleve it is writen in pascal too.  It is license under GNU s you may be able to get the source if you need or you can just inprove one of it's plugins

http://notepad-plus.sourceforge.net
Title: Re: Making highligher for C syntaxis
Post by: Martin_fr on August 24, 2010, 08:30:37 pm
notepad++ is in c++, it's based on Scintilla.

and while it does have more highlighters, and folding on many of them, the folding is less than impressive (except for the ability to hide arbitrary selections of text => on my todo for synedit).

SynEdit needs a way to define highlight and folding in a text-format file, so a new language can be added more easily. Also on my todo... (unfortunately not the only two things that are on my todo...)

---
Edit:
I do not mean to make Notepad++ in any way bad looking. It's a good editor, and I actually use it sometimes.
Title: Re: Making highligher for C syntaxis
Post by: garlar27 on August 24, 2010, 08:35:14 pm
And also is 100% windows dependent. It uses direct API calls for sake of speed (according to the Notepad++ home page). That's why there's no Linux version of Notepad++.
Title: Re: Making highligher for C syntaxis
Post by: BlueIcaro on August 25, 2010, 03:04:10 pm
Also look at the diff in revision 22552. that is where the LFM higlighter moved into folding.

So you see the exact differences.
Also check rev 22606, 22608

Basically the diff from before 22552 to after 22608
Thank you again for the information, I'll check the versions

/BlueIcaro