* * *

Author Topic: TSynEdit wordwrap  (Read 687 times)

polpero

  • Jr. Member
  • **
  • Posts: 60
TSynEdit wordwrap
« on: March 19, 2017, 04:53:12 pm »
Hi

i've installed David's WordWrapping files from the bugTracker,
recompiled and installed synEdit  successfully...

now loading from file with eowordwrap in options2 checked
   i get a range checking error message
or
  if loaded from stream i get a white display (no text, no gutter numbers...)

***
when  checked (via a menu) at runtime
nothing happens (text doesn't move)


am i forgetting something?
any hint of where/what to look for, would be appreciated...

thanks





polpero

  • Jr. Member
  • **
  • Posts: 60
Re: TSynEdit wordwrap
« Reply #1 on: March 20, 2017, 01:31:54 am »
After doing more tests i must admit the
the error seemed to be on my part (mostly)
i had a bad assignment on eoWordWrap
and had not considered the length of the file a was testing...

Everything works as expected except
  • loading a file with wordWrap on sometimes raises rangeCheck error
  • it seems that the process of wordwrapping would be faster
    inside a beginUpdate endUpdate block
    but the code seems to be allergic to it (rangecheck error)
  • Large files are particuliarly long to process...

Thought i'd update the information
not to give any false impressions...

///

Would anyone have an idea about how to
wordwrap to right margin instead of window width?

thanks again
« Last Edit: March 21, 2017, 01:01:16 pm by polpero »

polpero

  • Jr. Member
  • **
  • Posts: 60
Re: TSynEdit wordwrap
« Reply #2 on: March 21, 2017, 03:25:34 am »
////////////////////////////////////////
//   WRAP TO RIGHT EDGE

If anyone is interested, wrapping to right edge requires very few modifications to David's patch.
( Find the patch in the BugTracker 30395 http://bugs.freepascal.org/view.php?id=30395 )

In order to wrap to Right edge 2 modifications are needed, both in synedit file:
  • adding a new option: eoREdgeWrap
  • adding a choice between both modes of display

First, eoREdgeWrap must be appended to Options2:

Code: Pascal  [Select]
  1. File: synedit
  2.  
  3.   TSynEditorOption2 = (
  4.   [..]
  5.     eoWordWrap,                // Truncates long lines into lines that fits onscreen
  6.     eoREdgeWrap                // If previous is true, wraps to Right Edge value
  7.   );
  8.  

The second modification is in TCustomSynEdit.RecalcCharsAndLinesInWin :
Code: Pascal  [Select]
  1. procedure TCustomSynEdit.RecalcCharsAndLinesInWin(CheckCaret: Boolean);
  2. [..]
  3.   FWrappedLinesView.CharsInWindow:= CharsInWindow;
  4. [..]
  5.  
  6. //This line becomes
  7.  
  8.  
  9.   if eoREdgeWrap in options2 then
  10.      FWrappedLinesView.CharsInWindow:= RightEdge
  11.         else FWrappedLinesView.CharsInWindow:= CharsInWindow;
  12.  
  13.  
 

Done!...

Now checking, from your application, both WrapWords and WrapToRightEdge
you get the REdgeWrap otherwise WrapWords alone Wraps to window width.

If anyone find this useful...


 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus