Recent

Author Topic: [SynEdit] How to make markups move with editing the text?  (Read 1730 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
[SynEdit] How to make markups move with editing the text?
« on: March 27, 2015, 07:09:48 am »
Hallo,

is it possible to make the markups move with the editied text. For example when lines are inserted or text is entered inside a makup?
Like the IDE does with error markups?

I've created my own markups derived from TSynEditMarkupHighlightMatches. But they do not move with the text.

Pascal
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9868
  • Debugger - SynEdit - and more
    • wiki
Re: [SynEdit] How to make markups move with editing the text?
« Reply #1 on: March 27, 2015, 04:24:19 pm »
There is no code in the Markup tat does this for you.

The Markup receives a call to:
Code: [Select]
procedure TSynEditMarkup.DoTextChanged(StartLine, EndLine, ACountDiff: Integer);
This allows you to
1) Recreate the matches in the affected lines
2) Move up/down any matches after the lines affected.


If you need a more exact notification what was edited, in order to move items on a line left/right, then you can add a hook to
Code: [Select]
  Lines.AddEditHandler(@DoLinesEdited);
see components\synedit\synpluginmulticaret.pp
for how to do that.(It is rather tricky, as you need to also catch senrTextBufferChanged, and re-register. (subject to change in future...)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9868
  • Debugger - SynEdit - and more
    • wiki
Re: [SynEdit] How to make markups move with editing the text?
« Reply #2 on: March 27, 2015, 04:28:10 pm »
Given the common nature of the issue, there probably should be a baseclass to do that. But currently there is not.

 

TinyPortal © 2005-2018