Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-02

Syntax highlighters for SynEdit

9 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Does anybody else see the problem here?

-------------------------------------
$ ls -ogh synhigh*
-rw-r--r-- 1 37K 2010-01-18 14:37 synhighlighterany.pas -rw-r--r-- 1 50K 2010-01-18 14:37 synhighlightercpp.pp -rw-r--r-- 1 44K 2010-01-18 14:37 synhighlightercss.pas -rw-r--r-- 1 8.3K 2010-01-18 14:37 synhighlighterhashentries.pas -rw-r--r-- 1 58K 2010-01-18 14:37 synhighlighterhtml.pp -rw-r--r-- 1 40K 2010-01-18 14:37 synhighlighterjava.pas -rw-r--r-- 1 65K 2010-01-18 14:37 synhighlighterjscript.pas -rw-r--r-- 1 23K 2010-02-04 10:00 synhighlighterlfm.pas -rw-r--r-- 1 25K 2010-01-18 14:37 synhighlightermulti.pas -rw-r--r-- 1 115K 2010-02-04 10:03 synhighlighterpas.pp -rw-r--r-- 1 80K 2010-01-18 14:37 synhighlighterperl.pas -rw-r--r-- 1 39K 2010-01-18 14:37 synhighlighterphp.pas -rw-r--r-- 1 12K 2010-01-18 14:37 synhighlighterposition.pas -rw-r--r-- 1 33K 2010-01-18 14:37 synhighlighterpython.pas -rw-r--r-- 1 79K 2010-01-18 14:37 synhighlightersql.pas -rw-r--r-- 1 13K 2010-01-18 14:37 synhighlightertex.pas -rw-r--r-- 1 23K 2010-01-18 14:37 synhighlighterunixshellscript.pas -rw-r--r-- 1 41K 2010-01-18 14:37 synhighlightervb.pas -rw-r--r-- 1 38K 2010-02-04 10:00 synhighlighterxml.pas -------------------------------------

Note the file sizes. 115K for Pascal syntax highlighting, 79K for SQL, 44K for CSS, 38K for XML etc. This is crazy!!! I couldn't find any other editor (that also supports syntax highlighting) with such large files. Also most other editors support external config files can a javascript file of 1930 bytes do syntax highlighting for Delphi, 2447bytes for SQL, 1977 bytes for XML etc.. Why is syntax highlighting in SynEdit so HUGE and overly complex?

I wanted to add a new syntax highlighter for IPF documents (markup file used to create INF help files) inside Lazarus IDE. I simply got lost in the complexity of SynEdit. Switched to MSEide which uses external text files loaded at runtime, and 10 minutes later I had a working syntax highlighter (all written without documentation - just trial and error).

Doesn't SynEdit support something like an external text based config file per file format? Most editor do. For example gEdit (default Gnome editor) includes stacks of such files - all in XML format and uses regular expressions to find language syntax. Not to mention gEdit's Pascal syntax file is 1/16th the size of SynEdit's. That's 7K vs 115K!

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Paul Ishenin
to Graeme Geldenhuys
Graeme Geldenhuys wrote 5 lines
Note the file sizes. 115K for Pascal syntax highlighting, 79K for SQL, 44K for CSS, 38K for XML etc. This is crazy!!! I couldn't find any other editor (that also supports syntax highlighting) with such large files. Also most other editors support external config files loaded at runtime.

Do you need a fast syntax highlighter with code folding support in a big unit or small unit with slow working highlighter which does not supports all the pascal syntax and no special features?

Best regards,
Paul Ishenin.

Reply by email

Brad Campbell
to Paul Ishenin
Paul Ishenin wrote 11 lines
17.02.2010 16:26, Graeme Geldenhuys wrote: > Note the file sizes. 115K for Pascal syntax highlighting, 79K for SQL, > 44K > for CSS, 38K for XML etc. This is crazy!!! I couldn't find any other > editor (that also supports syntax highlighting) with such large files. > Also > most other editors support external config files loaded at runtime. > Do you need a fast syntax highlighter with code folding support in a big unit or small unit with slow working highlighter which does not supports all the pascal syntax and no special features?

This is the key. Recently ( In the last 12 months anyway ) I've written a fairly complex highlighter for a project I've been working on. The complexity of the highlighter mechanism in SynEdit really seems to be in the extra features (like hierarchical folding, highlighting block pairs ... ) and speed.

Once you get your head around it, it all makes sense, but it can be a bit of a bear to get your head around from scratch.

The highlighter does much more than simply highlight words and can be incredibly powerful if you want to make it so.

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Mattias Gaertner
to Paul Ishenin: Do you need a fast syntax highlighter with code folding support in a big unit or small…
Show quoted text 9 lines
17.02.2010 16:26, Graeme Geldenhuys wrote: > Note the file sizes. 115K for Pascal syntax highlighting, 79K for SQL, 44K > for CSS, 38K for XML etc. This is crazy!!! I couldn't find any other > editor (that also supports syntax highlighting) with such large files. Also > most other editors support external config files loaded at runtime. > Do you need a fast syntax highlighter with code folding support in a big unit or small unit with slow working highlighter which does not supports all the pascal syntax and no special features?

The speed difference is dramatic. In synedit the highlighting is updated in real time.

The highlighter synhighlighterany.pas can be used to define your highlighter using lists of keywords.
If you need a more flexible any-highlighter, make a proposal. Then we need a gui or some config files to set it up in the IDE.

Mattias

Reply by email

Graeme Geldenhuys
to Paul Ishenin: Do you need a fast syntax highlighter with code folding support in a big unit or small…
Paul Ishenin wrote
> Do you need a fast syntax highlighter with code folding support in a big

Oh, is all the other editor features in Synedit also part of the synhighlighter*.pas files? I though those files only contains the syntax highlighting (aka. pretty colors) stuff.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Brad Campbell: This is the key. Recently ( In the last 12 months anyway ) I've written a fairly complex…
Brad Campbell wrote
The highlighter does much more than simply highlight words and can be incredibly powerful if you want to make it so.

OK, so the unit names is then very misleading. The synhighlighter*.pas files are not just about pretty colors, it's actually about editor features too. That would explain the complexity then. I didn't know this. Thanks for the info.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Paul Ishenin
to Graeme Geldenhuys: Oh, is all the other editor features in Synedit also part of the synhighlighter*.pas…
Graeme Geldenhuys wrote 6 lines
Do you need a fast syntax highlighter with code folding support in a big Oh, is all the other editor features in Synedit also part of the synhighlighter*.pas files? I though those files only contains the syntax highlighting (aka. pretty colors) stuff.

The main reason of the big unit size is the speed optimization but indeed, pascal highlighter performs more work like defining the begining and the end of the fold regions. Also it has a big piece of code preserved for delphi compatibility (in case we ever push our changes to the original synedit project).

Best regards,
Paul Ishenin.

Reply by email

Mattias Gaertner
to Paul Ishenin
Show quoted text 10 lines
17.02.2010 17:02, Graeme Geldenhuys wrote: > Do you need a fast syntax highlighter with code folding support in a big > > Oh, is all the other editor features in Synedit also part of the > synhighlighter*.pas files? I though those files only contains the syntax > highlighting (aka. pretty colors) stuff. > The main reason of the big unit size is the speed optimization but indeed, pascal highlighter performs more work like defining the begining and the end of the fold regions.

Yes, this saves redundant code.

Also it has a big piece of code preserved for delphi compatibility (in case we ever push our changes to the original synedit project).

Less than 100 lines (<2.5%).

Mattias

Reply by email

Flávio Etrusco
to Graeme Geldenhuys: OK, so the unit names is then very misleading. The synhighlighter*.pas files are not just…
Graeme Geldenhuys wrote 16 lines
Brad Campbell wrote: > > The highlighter does much more than simply highlight words and can be > incredibly powerful if you want to make it so. OK, so the unit names is then very misleading. The synhighlighter*.pas files are not just about pretty colors, it's actually about editor features too. That would explain the complexity then. I didn't know this. Thanks for the info. Regards, ?- Graeme -

You're comparing a static parser vs configurations for dynamic parsers; the latter will always be smaller. See UniSyn syntax files (even though they're XML!)
A dynamic parser was something always wanted for SynEdit, and it's original author (Martin Waldenburg) even a basic parser/lexer but nobody ever completed the integration and a configuration file nor a higher-level API. UniSyn is a dynamic parser, but it has some limitations, some bugs, and it uses a bit more memory than it should (and I'm not even sure lazarus' version is up-to-date).

Best regards,
Fl?vio

Reply by email