Recent

Author Topic: New Scriptable Highlighter for SynEdit  (Read 31746 times)

Edson

  • Hero Member
  • *****
  • Posts: 1087
New Scriptable Highlighter for SynEdit
« on: February 04, 2014, 07:28:58 pm »
This new Highlighter for SynEdit is an evolution of:

http://forum.lazarus.freepascal.org/index.php/topic,22148.msg138836.html#msg138836

It is:

* Free.
* Fast (and Furious).
* Flexible.
* Foldable.
* File configurable.
* Full documented (only in spanish, sorry).

With this light HL, it's posible create blocks and change the back color.

As usually, it includes a comparison with the Lazarus Pascal Highlighter.

Download here: http://blog.pucp.edu.pe/action.php?action=plugin&name=LinkCounter&type=c&k=20140204-synfacilsyn02_pub.rar
« Last Edit: February 05, 2014, 12:48:40 am by Edson »
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: New Scriptable Highlighter for SynEdit
« Reply #1 on: February 04, 2014, 09:22:16 pm »
Thanks for sharing. There is a hidden file in the archive named "~WRL2608.tmp" over 1 mb of size. Assuming it's not needed, you might want to remove it.

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: New Scriptable Highlighter for SynEdit
« Reply #2 on: February 05, 2014, 12:48:11 am »
Removed.

Thanks for checking.
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

Edson

  • Hero Member
  • *****
  • Posts: 1087
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: New Scriptable Highlighter for SynEdit
« Reply #4 on: April 19, 2014, 01:24:56 am »
I'm in need of a run time editable highlighter that will allow the end user to add support for multiple highlighters of his own as well as build on top of it extra highlighters. The highlighter will be used in my code librarian http://sourceforge.net/projects/codelibrarian/. So a few questions if you don't mind.
1) How easy it is to define a highlighter?
2) is it different from the synAnysyn highlighter that comes with lazarus?
3) scripting? how? Or its just a name to distinguish it from the rest of the crowd?

Thank you for your input.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: New Scriptable Highlighter for SynEdit
« Reply #5 on: April 19, 2014, 01:57:22 am »
3) scripting? how? Or its just a name to distinguish it from the rest of the crowd?

Yes it's True. It can be configurated using an external XML file. In the example, it uses the file "prueba.xml", when it's defined one simple Pascal syntax.

You can define a syntax, using code too. It gives you more power but it's a little more complex.

1) How easy it is to define a highlighter?

It's supposed to be very easy. You can highlight some keywords, just using this simple file:

Code: [Select]
<?xml version="1.0"?>
<Language name="Pascal">
  <keyword>
    begin
    end
    procedure
    function
   </keyword>
</Language>

Then you can add some more complex structures for defining tokens. Many options are assumed by default. You can work with folding too.

2) is it different from the synAnysyn highlighter that comes with lazarus?

SynAnySyn is very slow.
SynAnySyn is not scriptable.
SynAnySyn can not define tokens.
SynAnySyn is too hard coded.
SynAnySyn has not folding.
SynAnySyn has not drive with blocks.
SynAnySyn can not manage Case Sensitivity.
SynAnySyn is not documented.
...

« Last Edit: April 19, 2014, 02:21:41 am by Edson »
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

taazz

  • Hero Member
  • *****
  • Posts: 5365
Re: New Scriptable Highlighter for SynEdit
« Reply #6 on: April 19, 2014, 02:21:51 am »
When you say scripting you mean the ability to save and load its properties and what not from a file?
Can I use some other file format eg ini or json something not XML based?
Can I define multiple keyword groups with different colors?
     eg SynAnySyn has only 3 groups consts, keywords, objects. the rest are some what
     parameterized but their values is fixed so a bit of a downer from a fast look.I might
     not need more than what it is offered but it is always nice to know that if I do I
     can add it.
Already downloaded your component and will take a closer look after the holidays thank you for any info.
I'm going to try and make a SQLite highlighter for starters and see how that goes.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: New Scriptable Highlighter for SynEdit
« Reply #7 on: April 19, 2014, 03:11:02 am »
When you say scripting you mean the ability to save and load its properties and what not from a file?

It is scriptable because its syntax is configurated using an script file. This file is like a language definiition for the Highlighter. Probably the name is not correct.

Some properties (like the color of blocks) are defined in the file, but the color of the tokens is configurated by code.

Can I use some other file format eg ini or json something not XML based?

The file has to be XML, no other formats. A translation has to be for other formats. I thought on using INI file at the beginning, but finally decided for XML.

Can I define multiple keyword groups with different colors?
     eg SynAnySyn has only 3 groups consts, keywords, objects. the rest are some what  parameterized

Practically, it is possible to use all these attributes:

1.   NULL
2.   IDENTIFIER
3.   KEYWORD
4.   DIRECTIVE
5.   VARIABLE
6.   NUMBER
7.   SPACE
8.   STRING
9.   COMMENT
10.   SYMBOL
11.   LABEL
12.   ASM
13.   EXTRA1
14.   EXTRA2

for an Identifier. But probably you don't want to use NUMBER or SPACE for a group of keyword.

Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

Alextp

  • Hero Member
  • *****
  • Posts: 1123
    • UVviewsoft
EC
« Reply #8 on: May 23, 2014, 06:37:28 pm »
GOOD idea. Do u know of EControl.ru component? Delphi. Pls see it's demo and call "Options-- Lexer Properties". GOOD visual editor of internal script. Internal script - in DFM format(not XML).

It's good idea how to make visual editor

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: New Scriptable Highlighter for SynEdit
« Reply #9 on: May 24, 2014, 10:46:16 pm »
I had not seen the Econtrol.ru. I was surprised of about what it can do with the SynEdit control. It would be better if it would have been free. :)

It seems very complete and documented. I couldn't see the Lexer Properties. It showed me an error message.

His lexer is powerful but, it seems to be a bit slow. My highlighter was designed for to be fast and easy for to configure, although probably not so powerful.

It's good idea how to make visual editor
I have thought on that, but it's no priority for me now.  If someone can do it, Welcome!.

Currently I'm working on integrate the code completion and other tools for Source Editors, on a library. In that way, it will be very easy to create editors with syntax highlighter, folding and code completion.
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

Alextp

  • Hero Member
  • *****
  • Posts: 1123
    • UVviewsoft
.
« Reply #10 on: May 24, 2014, 10:52:52 pm »
Code completion is not important. what do u mean - support for inserting fragments after pressing a key after "some_id" string? code snippet? or auto completion? Ctrl+Space?



Alextp

  • Hero Member
  • *****
  • Posts: 1123
    • UVviewsoft
-
« Reply #11 on: May 24, 2014, 11:04:22 pm »
EControl.ru: a) NOT SYNEDIT based. it's new. b) if u still want to see its lexer editor, try my SynWrite app (u see Lexer Properties command in Options menu, I don't tell details) - google for "synwrite".

« Last Edit: May 24, 2014, 11:06:39 pm by Alex22 »

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: .
« Reply #12 on: May 24, 2014, 11:20:46 pm »
Code completion is not important. what do u mean - support for inserting fragments after pressing a key after "some_id" string? code snippet? or auto completion? Ctrl+Space?

Code completion is very important for people like me, that can never remember the exact name of some property o keyword.

For me the code completion can include code snippet too. And code completion with one item = auto compeltion. If not need for Ctrl+Space , it would be better. I think the editors must be more "proactive".

But a useful code completion, need to know more about the code. I mean, more than the current word. An effective code completion need to know about  the syntax of the code he is serving. That's why it's necessary that the highlighter can manage with blocks of code (it's necessary for the code tree, too).
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

Alextp

  • Hero Member
  • *****
  • Posts: 1123
    • UVviewsoft
-
« Reply #13 on: May 24, 2014, 11:28:44 pm »
I make text editor 4 years. (Synwrite).I know about code completion (in EControl) much. Beleave me- code completion yes, important but ITS NOT JOB for lexer. All synedit need is API in synedit to show ANY list when user presses ctrl+Space.

INTELLIGENT pascal or C or java or PHP autocompletion is hard

Edson

  • Hero Member
  • *****
  • Posts: 1087
Re: New Scriptable Highlighter for SynEdit
« Reply #14 on: May 25, 2014, 03:28:02 am »
I haven't tested "Synwrite" in detail, but at first sight it seems great. Does it uses the Econtrol?

Beleave me- code completion yes, important but ITS NOT JOB for lexer.

Agree. It's job for Code Anlyzer or parser. In my editors, I use information of the highlighter for to have some kind of "intelligent" code compeltion. Before the list is opened, it checks the current block for to choose the more appropiate words.

I can see that Econtrol (the same that my highlighter), is more than a simple lexer.

All synedit need is API in synedit to show ANY list when user presses ctrl+Space.

OK, but it's just the visual part.
« Last Edit: May 25, 2014, 03:30:41 am by Edson »
Lazarus 2.0.6 - FPC 3.0.4 - x86_64-win64 on  Windows 8

 

TinyPortal © 2005-2018