Recent

Author Topic: [SOLVED] TSynEdit highlight special keyword  (Read 809 times)

AsleyCruz

  • Full Member
  • ***
  • Posts: 118
    • Graphic and web designer
[SOLVED] TSynEdit highlight special keyword
« on: August 03, 2023, 12:10:39 am »
Hello, team

How can I add keywords to highlight any text within "[" and "]" on TSynEdit control?

Please, take a look at the attached image.
Thanks a lot
« Last Edit: August 03, 2023, 06:14:57 pm by AsleyCruz »
Graphic & web designer

AsleyCruz

  • Full Member
  • ***
  • Posts: 118
    • Graphic and web designer
Re: TSynEdit highlight special keyword
« Reply #1 on: August 03, 2023, 07:59:10 am »
Any solution or idea, bros?

I just want to highlight the text within the brackets [test] as in the attached image.

The controls that I am using are SynEdit and SynAnySyn (this contains the keywords)

Thanks!
Graphic & web designer

WooBean

  • Sr. Member
  • ****
  • Posts: 303
Re: TSynEdit highlight special keyword
« Reply #2 on: August 03, 2023, 08:42:36 am »
Possible direction:
 choose Main menu / Tools / Options / IDE Options (window) / Editor /Display / User defined markup and then at right panel - "Add list" (i.e. "My list 1")  and add "keywords" like [test], [anything], something, and so on ... . 
   
Colour for "keywords" is defined as Foreground and then you can have [test]

I cannot see possibility to use wildcards like [prefix*] or *suffix or prefix*suffix.

Somebody can try it some day. However this can be prone to errors - imagine keyword  "[ * ]"  and somewhere in the source single square bracket  "[" waiting to find "]" with thousands characters between.

Attention - a feature is rather at beta state, backup your Lazarus config first.

« Last Edit: August 03, 2023, 09:24:51 am by WooBean »
Platforms: Win7/64, Linux Mint 22.1 Xia

Edson

  • Hero Member
  • *****
  • Posts: 1326
Re: TSynEdit highlight special keyword
« Reply #3 on: August 03, 2023, 05:23:02 pm »
I just want to highlight the text within the brackets [test] as in the attached image.

The controls that I am using are SynEdit and SynAnySyn (this contains the keywords)

SynAnySyn is a very basic highlighter. Can be modified for suit your needs but it could be some complex to add new features.

I recommend to use https://github.com/t-edson/SynFacilSyn. It's a powerful highlighter and simple to use.

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

 

TinyPortal © 2005-2018