Recent

Author Topic: Synedit wordwrap  (Read 5235 times)

Tommi

  • Sr. Member
  • ****
  • Posts: 256
Synedit wordwrap
« on: November 17, 2022, 11:50:00 pm »
Hi,
is there in synedit any wordwrap option ? I cannot see it but it seems very strange that a so big and complex library has no word wrap.

Thank you

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #1 on: November 18, 2022, 12:40:47 am »
Yes, there is. But it's kind of beta... in progress.

Code: Pascal  [Select][+][-]
  1. uses SynEditWrappedView;
  2. begin
  3.   TLazSynEditLineWrapPlugin.Create(ASynEdit);

Tommi

  • Sr. Member
  • ****
  • Posts: 256
Re: Synedit wordwrap
« Reply #2 on: November 18, 2022, 01:10:16 pm »
Ok, thank you. And how to disable it after it has been enabled?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #3 on: November 18, 2022, 01:43:09 pm »
That isn't implemented yet....

You may be able to do something like
Code: Pascal  [Select][+][-]
  1. FLineMapView := aSynEdit.TextViewsManager.SynTextViewByClass[TSynEditLineMappingView];
  2. aSynEdit.TextViewsManager.RemoveSynTextView(FLineMapView);
and add it back later...
Mind that is only the visualization... So the rest is still running in the background.

I have not tested this.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #4 on: November 18, 2022, 01:44:48 pm »
Depending on what you need you may want to checkout AtSynEdit.
It has had wrapping for much longer...

ChristianH

  • New Member
  • *
  • Posts: 49
Re: Synedit wordwrap
« Reply #5 on: December 18, 2024, 02:09:44 pm »
The thread is quite old but the issue still exists. To fix this you should add the following code to the TLazSynEditLineWrapPlugin:

Code: Pascal  [Select][+][-]
  1. destructor TLazSynEditLineWrapPlugin.Destroy;
  2. begin
  3.  TSynEdit(Editor).UnRegisterStatusChangedHandler(@DoWidthChanged);
  4.  TSynEdit(Editor).TextViewsManager.RemoveSynTextView(FLineMapView, true);
  5.  TSynEdit(Editor).Invalidate;
  6.  
  7.   inherited;
  8. end;  


I do not know if this is missing on purpose, but I guess nobody tried to enable and disable the wrapper.

Christian

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #6 on: January 24, 2025, 09:54:08 pm »
The thread is quite old but the issue still exists. To fix this you should add the following code to the TLazSynEditLineWrapPlugin:

Thanks, sorry for the delay. Added now. Will merge to fixes-4 asap. (the fix(es) only, not the new feature that were added around it)

Removing the view crashed, when the editor itself was already in destruction. So I added guards for that.


The reason it wasn't there is, that the view may not have been owned by the plugin.

The plugin originally was thought to be able to share that. (see the constructor, there is a search for an existing view).
This will however be removed, it wont be needed any more.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #7 on: January 24, 2025, 10:26:36 pm »
I merged any fixes to the fixes-4 branch. If you are using git (e.g. fpcUpDeluxe), then you can pull them and test them. (Or you can view them online and patch your SynEdit).  RC2 does NOT contain them.

gompertz

  • Newbie
  • Posts: 5
Re: Synedit wordwrap
« Reply #8 on: December 06, 2025, 05:17:46 am »
Hi I'm trying to toggle wrapping in SynEdit and have confirmed my component library has the changes merged by Martin_fr, however I'm getting a crash in Linux when I trigger my callback.

Relevant code for removing wrapping:

Code: Pascal  [Select][+][-]
  1. var
  2. FLineMapView: TSynEditStringsLinked;
  3. begin
  4.  FLineMapView := ASynEdit.TextViewsManager.SynTextViewByClass[TSynEditLineMappingView];
  5.  ASynEdit.TextViewsManager.RemoveSynTextView(FLineMapView);
  6. ...
  7.  

Any ideas? Thanks



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12019
  • Debugger - SynEdit - and more
    • wiki
Re: Synedit wordwrap
« Reply #9 on: December 06, 2025, 09:42:04 am »
component library has the changes merged by Martin_fr, however I'm getting a crash in Linux when I trigger my callback.

Deos that mean you use 4.x with some code merged from git main branch?
Or 4.99 aka the git main branch?

I did a lot of work on SynEdit in 4.99. And afaik some that was related to how such addons (like wordwrap) are handled. But I can't recall all the details.
So, if in doubt, make sure  you use 4.99.

With 4.99, I checked what the IDE (in ide/SourceSynEditor) does.
And it simple destroys the line wrap, and that will take care of its own removal.

Add:
  FWrapView := TLazSynEditLineWrapPlugin.Create(Self);

Remove:
  FreeAndNil(FWrapView);

If you want to temp remove it, then you need to check what all happens in destroy.

 

TinyPortal © 2005-2018