Recent

Author Topic: Making highligher for C syntaxis  (Read 7735 times)

BlueIcaro

  • Hero Member
  • *****
  • Posts: 576
Making highligher for C syntaxis
« 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, 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
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5800
    • wiki
Re: Making highligher for C syntaxis
« Reply #1 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

BlueIcaro

  • Hero Member
  • *****
  • Posts: 576
Re: Making highligher for C syntaxis
« Reply #2 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
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5800
    • wiki
Re: Making highligher for C syntaxis
« Reply #3 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

mas steindorff

  • Sr. Member
  • ****
  • Posts: 428
Re: Making highligher for C syntaxis
« Reply #4 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
windows 7/10 - laz 2.0 / 1.2.6 general releases

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 5800
    • wiki
Re: Making highligher for C syntaxis
« Reply #5 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.
« Last Edit: August 24, 2010, 08:42:18 pm by Martin_fr »

garlar27

  • Hero Member
  • *****
  • Posts: 622
Re: Making highligher for C syntaxis
« Reply #6 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++.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 576
Re: Making highligher for C syntaxis
« Reply #7 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
Remenber, the lazarus wiki is your friend: http://wiki.lazarus.freepascal.org/Main_Page
General questions (several lenguages) http://wiki.lazarus.freepascal.org/