Recent

Author Topic: TSynedit - how to remove highlighting?  (Read 2001 times)

john60

  • New Member
  • *
  • Posts: 24
TSynedit - how to remove highlighting?
« on: July 08, 2018, 09:38:34 am »
Using TSynedit I have a document open with highlighting I want to remove.

I can turn off the highlighter object but can't see a way to remove the existing
highlights of an open document without reloading it.



Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: TSynedit - how to remove highlighting?
« Reply #1 on: July 08, 2018, 10:14:36 am »
I cannot understand what you meant you can turn off but cannot remove.

Have you tried:
Code: Pascal  [Select][+][-]
  1.   MySynEdit.Highlighter := nil;

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: TSynedit - how to remove highlighting?
« Reply #2 on: July 08, 2018, 10:48:55 am »
What exactly is highlighted?

Keywords and symbols are done by the highlighter. And if you set it to nil, then they should no longer highlight (with immediate effect).
Maybe try calling SynEdit.Invalidate; after removing the HL

Matching Bracket, or the highlight of the "word at caret" are done by various Markup modules.
SynEdit.MarkupByClass[TSynEditMarkupHighlightAllCaret].enabled := false;
SynEdit.MarkupByClass[TSynEditMarkupBracket].enabled := false;
SynEdit.MarkupByClass[TSynEditMarkupSpecialLine].enabled := false;
Similar for
TSynEditMarkupWordGroup
TSynEditMarkupCtrlMouseLink
TSynEditMarkupSpecialChar


If you do a copy of SynEdit it is just a few lines of code that need to be removed, to remove the entire markup.
Currently they are all added in the constructor.

If anything else highlights, maybe attach a screenshot.
« Last Edit: July 08, 2018, 10:50:44 am by Martin_fr »

john60

  • New Member
  • *
  • Posts: 24
Re: TSynedit - how to remove highlighting?
« Reply #3 on: July 08, 2018, 12:10:59 pm »
Thanks guys -

the answer is to use := nil as handoko suggests.

I was trying to use
highlighter.enabled := false
but that doesn't cause a refresh even if redrawing/invalidating etc - I tried quite a bit
but I'm very much out of practice with lazarus.
The simple answer is always best ... if you can find it.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: TSynedit - how to remove highlighting?
« Reply #4 on: July 08, 2018, 02:24:52 pm »
Well, looks like you found a bug. On a first glance, Enabled does nothing. I reported it https://bugs.freepascal.org/view.php?id=33953

john60

  • New Member
  • *
  • Posts: 24
Re: TSynedit - how to remove highlighting?
« Reply #5 on: July 08, 2018, 03:48:48 pm »
oops.... thank you.



 

TinyPortal © 2005-2018