Recent

Author Topic: synedit MarkupManager Count  (Read 344 times)

BubikolRamios

  • Full Member
  • ***
  • Posts: 240
synedit MarkupManager Count
« on: July 12, 2022, 07:39:42 pm »
Noticed that in another thread, but no one else did, thought I did write a comment into code.

This thing loops 12 or x times, for no reason ?
Fresh started form, with synedit, that nothing has been done to it
Code: Pascal  [Select][+][-]
  1. showmessage(IntToStr(SynEdit1.MarkupManager.Count));
  2. while SynEdit1.MarkupManager.Count > 0  do
  3. begin
  4.     SynEdit1.MarkupManager.RemoveMarkUp(SynEdit1.MarkupManager.Markup[0]);
  5. end;
  6.  

So, how to see if there has been, really, any markup added in past ?
« Last Edit: July 12, 2022, 07:45:13 pm by BubikolRamios »
lazarus-2.0.12-fpc-3.2.0-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8483
  • Debugger - SynEdit - and more
    • wiki
Re: synedit MarkupManager Count
« Reply #1 on: July 12, 2022, 09:27:19 pm »
There are some Markups installed in SynEdit by default.

Code: Pascal  [Select][+][-]
  1.   fMarkupManager.AddMarkUp(fMarkupSpecialChar);
  2.   fMarkupManager.AddMarkUp(fMarkupSpecialLine);
  3.   fMarkupManager.AddMarkUp(fMarkupHighCaret);
  4.   fMarkupManager.AddMarkUp(fMarkupHighAll);
  5.   fMarkupManager.AddMarkUp(fMarkupCtrlMouse);
  6.   fMarkupManager.AddMarkUp(fMarkupBracket);
  7.   fMarkupManager.AddMarkUp(fMarkupWordGroup);
  8.   fMarkupManager.AddMarkUp(fMarkupSelection);
  9.  

Those are 8 that I found right away.  There may be more.

Note that if you remove them all, then SynEdit will no longer markup any selected text. (TSynEditMarkupSelection)

BubikolRamios

  • Full Member
  • ***
  • Posts: 240
Re: synedit MarkupManager Count
« Reply #2 on: July 12, 2022, 10:14:54 pm »
Getting somewhere understanding that.

TSynEditMarkupHighlightAllMulti is not there by default

so if I add them multiple of class TSynEditMarkupHighlightAllMulti then there are multiple of that class in MarkupManager .

tested:
Code: Pascal  [Select][+][-]
  1. SynEdit1.MarkupManager.RemoveMarkUp(SynEdit1.MarkupManager.MarkupByClass[TSynEditMarkupHighlightAllMulti]);
  2.  

Removes one, I guess nobody knows which from list, next execution removes next of that class.

When there is no more markups of class TSynEditMarkupHighlightAllMulti, the upper code throws no error.

How to tell if there are no markups of class TSynEditMarkupHighlightAllMulti in markupmanager.
Can't find anything to find that out.

Probably loop thru all markups in  markupmanager, checking class ...
But I hope there is some count by class somewhere ?
« Last Edit: July 12, 2022, 10:28:14 pm by BubikolRamios »
lazarus-2.0.12-fpc-3.2.0-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8483
  • Debugger - SynEdit - and more
    • wiki
Re: synedit MarkupManager Count
« Reply #3 on: July 12, 2022, 10:43:18 pm »
IIRC (but please double check from the source) "MarkupByClass"  returns the first of that class.

I don't get exactly what you intent do to? Why do you try to remove Markups without knowing which ones you want to remove?

That is, it is expected that if you added your own markup (of whatever class that may be), and you indent to remove it later (rather than disable, when not used), then you would keep a reference to it.

Code: Pascal  [Select][+][-]
  1. MyMarkup := CreateMyMarkup();
  2. SynEdit1.MarkupManager.AddMarkUp(MyMarkup);
  3. ....
  4. // later
  5. SynEdit1.MarkupManager.RemoveMarkUp(MyMarkup);
  6.  

This is similar to
Code: Pascal  [Select][+][-]
  1. TButton.Create(Form1);
Now I can find that button in Form1.controls[] or components[]. But I may find many other buttons there too.



Of course if you create your own markup of class
Code: Pascal  [Select][+][-]
  1. TMyMarkup = class(TSynEditMarkup)
then you can use the class to identify it. And in case you have several, maybe it has some property you can search for.

 

TinyPortal © 2005-2018