Forum > LCL

TSynedit - how to remove highlighting?

(1/2) > >>

john60:
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:
I cannot understand what you meant you can turn off but cannot remove.

Have you tried:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  MySynEdit.Highlighter := nil;

Martin_fr:
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.

john60:
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:
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

Navigation

[0] Message Index

[#] Next page

Go to full version