Recent

Author Topic: How to setup text sharing between two or more synedits?  (Read 6548 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
How to setup text sharing between two or more synedits?
« on: May 11, 2016, 10:54:42 am »
Hello,

how can i setup two or more synedits which share the same textbuffer?

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

Thaddy

  • Hero Member
  • *****
  • Posts: 18765
  • To Europe: simply sell USA bonds: dollar collapses
Re: How to setup text sharing between two or more synedits?
« Reply #1 on: May 11, 2016, 11:11:55 am »
Do you mean fully synchronized including the caret, or just the same buffer? (Look for the assign method for the same buffer)
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: How to setup text sharing between two or more synedits?
« Reply #2 on: May 11, 2016, 02:09:28 pm »
Alternatively, there's package from one member which can split Source Editor into two (horizontally or vertically).
It's a few years old but when I tested it last time it worked well.
http://forum.lazarus.freepascal.org/index.php?topic=19769.0
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to setup text sharing between two or more synedits?
« Reply #3 on: May 11, 2016, 02:40:37 pm »
I want to edit one textbuffer with two different tsynedits. So no syncronized carets.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to setup text sharing between two or more synedits?
« Reply #4 on: May 11, 2016, 02:41:41 pm »
use the following.
Code: Pascal  [Select][+][-]
  1.     procedure ShareTextBufferFrom(AShareEditor: TCustomSynEdit);
  2.     procedure UnShareTextBuffer;
  3.     property ShareOptions: TSynEditorShareOptions read FShareOptions write SetShareOptions
  4.       default SYNEDIT_DEFAULT_SHARE_OPTIONS; experimental;
  5.  

This can only be done in code, not in the designer.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to setup text sharing between two or more synedits?
« Reply #5 on: May 11, 2016, 08:43:03 pm »
use the following.
Code: Pascal  [Select][+][-]
  1.     procedure ShareTextBufferFrom(AShareEditor: TCustomSynEdit);
  2.     procedure UnShareTextBuffer;
  3.     property ShareOptions: TSynEditorShareOptions read FShareOptions write SetShareOptions
  4.       default SYNEDIT_DEFAULT_SHARE_OPTIONS; experimental;
  5.  

This can only be done in code, not in the designer.

Okay. Thanks. I will try it.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to setup text sharing between two or more synedits?
« Reply #6 on: May 11, 2016, 10:58:49 pm »
Does destroying one of the connected synedits automaticaly UnShareTextBuffer
or do i have to do it in Destroy of my synedit? As i have seen calling
UnShareTextBuffer on an unshared synedit doesn't do anything with the TextBuffer.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to setup text sharing between two or more synedits?
« Reply #7 on: May 11, 2016, 11:12:25 pm »
It should automatically detach on destroy.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: How to setup text sharing between two or more synedits?
« Reply #8 on: May 11, 2016, 11:57:43 pm »
TextBuffer sharing doesn't work with my decendant of SynEdit. It uses TSourceLazSynSurfaceManager and
crashes (AV) when painting (FOriginalManager.Paint). Has something to do with gutter marks.

See callstack:
Code: Pascal  [Select][+][-]
  1. #0 GETMARKLINE(0x0, 1) at ..\..\laz\components\synedit\syneditmarks.pp:893
  2. #1 PAINTMARKS(0xb9693d0, 0, 0x1f05d6e0, {LEFT = 5, TOP = 0, RIGHT = 29, BOTTOM = 16, TOPLEFT = {X = 5, Y = 0}, BOTTOMRIGHT = {X = 29, Y = 16}}, 1) at ..\..\laz\components\synedit\synguttermarks.pp:129
  3. #2 PAINTLINE(0xb9693d0, 0, 0x1f05d6e0, {LEFT = 5, TOP = 0, RIGHT = 29, BOTTOM = 16, TOPLEFT = {X = 5, Y = 0}, BOTTOMRIGHT = {X = 29, Y = 16}}) at ..\..\laz\components\synedit\synguttermarks.pp:181
  4. #3 PAINT(0xb9693d0, 0x1f05d6e0, {LEFT = 5, TOP = 0, RIGHT = 29, BOTTOM = 581, TOPLEFT = {X = 5, Y = 0}, BOTTOMRIGHT = {X = 29, Y = 581}}, 0, 36) at ..\..\laz\components\synedit\synguttermarks.pp:211
  5. #4 PAINT(0xfcec230, 0x1f05d6e0, 0xfc356d0, {LEFT = 0, TOP = 0, RIGHT = 67, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 67, Y = 581}}, 0, 36) at ..\..\laz\components\synedit\syngutter.pp:281
  6. #5 DOPAINT(0xfc356d0, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 67, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 67, Y = 581}}) at ..\..\laz\components\synedit\syngutter.pp:136
  7. #6 PAINT(0xfc356d0, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 67, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 67, Y = 581}}) at ..\..\laz\components\synedit\syneditmiscclasses.pp:1304
  8. #7 DOPAINT(0x104b0a20, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 672, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 672, Y = 581}}) at ..\..\laz\components\synedit\lazsyntextarea.pp:1062
  9. #8 PAINT(0x104b0a20, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 672, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 672, Y = 581}}) at ..\..\laz\components\synedit\syneditmiscclasses.pp:1304
  10. #9 DOPAINT(0x10509988, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 672, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 672, Y = 581}}) at primeedit.pas:1053
  11. #10 PAINT(0x10509988, 0x1f05d6e0, {LEFT = 0, TOP = 0, RIGHT = 672, BOTTOM = 581, TOPLEFT = {X = 0, Y = 0}, BOTTOMRIGHT = {X = 672, Y = 581}}) at ..\..\laz\components\synedit\syneditmiscclasses.pp:1304
  12. #11 PAINT(0xbb5b830) at ..\..\laz\components\synedit\synedit.pp:3848
  13. #12 PAINTWINDOW(0xbb5b830, 453053116) at ..\..\laz\lcl\include\customcontrol.inc:126
  14. #13 PAINTHANDLER(0xbb5b830, {MSG = 15, DC = 453053116, PAINTSTRUCT = 0x4beef34, RESULT = 0}) at ..\..\laz\lcl\include\wincontrol.inc:4801
  15. #14 WMPAINT(0xbb5b830, {MSG = 15, DC = 453053116, PAINTSTRUCT = 0x4beef34, RESULT = 0}) at ..\..\laz\lcl\include\wincontrol.inc:6754
  16. #15 WMPAINT(0xbb5b830, {MSG = 15, DC = 453053116, PAINTSTRUCT = 0x4beef34, RESULT = 0}) at ..\..\laz\lcl\include\customcontrol.inc:106
  17. #16 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
  18. #17 VMT_$CONTROLS_$$_TCUSTOMCONTROL at :0
  19. #18 ?? at :0
  20. #19 WNDPROC(0xbb5b830, {MSG = 15, WPARAM = 453053116, LPARAM = 79621940, RESULT = 0, WPARAMLO = 2748, WPARAMHI = 6913, WPARAMFILLER = {}, LPARAMLO = 61236, LPARAMHI = 1214, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at ..\..\laz\lcl\include\wincontrol.inc:5386
  21. #20 WNDPROC(0xbb5b830, {MSG = 15, WPARAM = 453053116, LPARAM = 79621940, RESULT = 0, WPARAMLO = 2748, WPARAMHI = 6913, WPARAMFILLER = {}, LPARAMLO = 61236, LPARAMHI = 1214, LPARAMFILLER = {}, RESULTLO = 0, RESULTHI = 0, RESULTFILLER = {}}) at ..\..\laz\components\synedit\synedit.pp:5969
  22. #21 DELIVERMESSAGE(0xbb5b830, 0) at ..\..\laz\lcl\lclmessageglue.pas:112
  23. #22 WIN32INT$_$TWINDOWPROCHELPER_$__$$_SENDPAINTMESSAGE$LONGWORD at :0
  24. #23 WIN32INT$_$TWINDOWPROCHELPER_$__$$_DOWINDOWPROC$$LONGINT at :0
  25. #24 WIN32INT_$$_WINDOWPROC$LONGWORD$LONGWORD$LONGINT$LONGINT$$LONGINT at :0
  26. #25 ?? at :0
  27. #26 ?? at :0
  28. #27 ?? at :0
  29. #28 ?? at :0
  30. #29 ?? at :0
  31. #30 ?? at :0
  32. #31 ?? at :0
  33. #32 ?? at :0
  34. #33 ?? at :0
  35. #34 ?? at :0
  36. #35 ?? at :0
  37. #36 WIN32INT_$$_CALLDEFAULTWINDOWPROC$LONGWORD$LONGWORD$LONGINT$LONGINT$$LONGINT at :0
  38. #37 WIN32INT$_$TWIN32WIDGETSET_$__$$_CALLDEFAULTWNDHANDLER$TOBJECT$formal at :0
  39. #38 WSCONTROLS$_$TWSWINCONTROL_$__$$_DEFAULTWNDHANDLER$TWINCONTROL$formal at :0
  40. #39 DEFAULTHANDLER(0xd35d090, 0) at ..\..\laz\lcl\include\wincontrol.inc:3610
  41. #40 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
  42. #41 ?? at :0
  43.  
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12195
  • Debugger - SynEdit - and more
    • wiki
Re: How to setup text sharing between two or more synedits?
« Reply #9 on: May 12, 2016, 01:30:27 am »
Can the original SynEdit draw the guttermarks in your app?

Can you test with/without the mark-share option? (in ShareOptions)
I think in the IDE it shares marks (both synedit have the same marks and keep them in sync), and that works. It is possible that is broken without mark-sharing, but it needs to be tested with the synedit as it is, not a subclass.

If you can reproduce with the original SynEdit then please report on mantis, with details how to reproduce.

You can check in TCustomSynEdit.RecreateMarkList
The trace looks like maybe FMarkList is not re-created. Or something, somewhere keeps a pointer to a deleted FMarkList.

 

TinyPortal © 2005-2018