Recent

Author Topic: Synedit - Highlighting of comments backgrounds after //  (Read 4030 times)

Aeternitas

  • New Member
  • *
  • Posts: 42
    • The Dark Forests Web
Synedit - Highlighting of comments backgrounds after //
« on: March 28, 2017, 09:18:12 pm »
Hi,

I have a question. I'd like to have the full line background color of comments in highlighting after //. I use several highlighting components, but most important it is for SynAnySyn. I use Lazarus 1.1.99, but as I tried the actual version, it is not implemented yet.

Thank you in advance.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #1 on: March 28, 2017, 09:49:53 pm »
I don't think synanysyn is the ideal choice here.

You can modify the existing SynPasSyn. It already internally differentiates between 3 diff comment type.

So all you need to do is add a new attribute.
1) add a property SlashCommentAttrib: TSynHighlighterAttributes
2) init it in the constructor / you will see all the others ....
3) add it in TSynPasSyn.GetTokenAttribute
   for tkComment test
   if rsSlash in fRange then

--------------------
If you need it independent of the highlighter search the forum for TSynEditMarkup, and write your own code as markup

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #2 on: March 28, 2017, 09:52:05 pm »
I use Lazarus 1.1.99

You mean Lazarus 1.1.99.0 Alpha pre-release from 2013?
Why not 1.2, or 1.4 or current release 1.6.4?

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #3 on: March 28, 2017, 10:06:06 pm »
Or write your own highlighter, there is a tutorial on the wiki, and examples in the iDE example folder

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #4 on: March 28, 2017, 11:23:40 pm »
Or use SynFacilSyn, and this XML configuration:

Code: XML  [Select][+][-]
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Language>
  3.   <Attribute Name="Comment" BackCol="#808080"/>
  4.   <Token Start="//" End= "" attribute="Comment"/>
  5. </Language>
  6.  
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #5 on: March 28, 2017, 11:29:42 pm »
Or use SynFacilSyn, and this XML configuration:
Out of interest, does your sample config include the following situations (or do you need to add more config)?

// appears in string, not a comment
 c:= 'a // b';

// appears in comment, not a slash/end-of-line comment
 a := (* comment // description *) 1;

Edson

  • Hero Member
  • *****
  • Posts: 1301
Re: Synedit - Highlighting of comments backgrounds after //
« Reply #6 on: March 28, 2017, 11:40:41 pm »
// appears in string, not a comment
 c:= 'a // b';
You need to add:
Code: XML  [Select][+][-]
  1.     <Token Start="'" End= "'" attribute="string"/>

// appears in comment, not a slash/end-of-line comment
 a := (* comment // description *) 1;

You need to add:
Code: XML  [Select][+][-]
  1.    <Token Start="(*" End= "*)" attribute="Comment"/>

Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018