Recent

Author Topic: Modifying the WordWrap parameter  (Read 6984 times)

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Modifying the WordWrap parameter
« on: August 13, 2016, 05:25:11 pm »
Using Windows XP Pro, Laz vrs 1.4.4, FPC vrs 2.6.4, windows unit

There are two problems with the following code:

1) If PageMemo.WordWrap is set as either true or false, it sets the WordWrap properly, but it also erases all RTF formatting for the entire document.

2) Setting PageMemo.scrollbars to ssboth or ssvertical sets them properly, but they behave as "auto" parameters. My impression of non-auto function is that the bar or bars should always be visible.

Code: Pascal  [Select][+][-]
  1. procedure TCmdForm.MnuWrapClick(Sender: TObject);
  2. begin
  3.   if PageMemo.WordWrap=true
  4.      then begin
  5.             PageMemo.WordWrap:= false;
  6.             PageMemo.scrollbars:= ssboth;
  7.             MnuWrap.caption:= 'Wrap On';
  8.             end
  9.      else Begin
  10.            PageMemo.WordWrap:= true;
  11.            PageMemo.scrollbars:= ssvertical;
  12.            MnuWrap.caption:= 'Wrap Off';
  13.            end;
  14. end;
  15.  

Rick
« Last Edit: August 13, 2016, 08:26:33 pm by rick2691 »
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Modifying the WordWrap parameter
« Reply #1 on: August 13, 2016, 11:24:35 pm »
1) If PageMemo.WordWrap is set as either true or false, it sets the WordWrap properly, but it also erases all RTF formatting for the entire document.
you might want to update richmemo to r5068.
The revision was to address a different issue, but it also handles wordwrap problem.

The issue remains with any copy-pasted objects - they are likely to be lost.
« Last Edit: August 13, 2016, 11:26:43 pm by skalogryz »

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #2 on: August 14, 2016, 01:27:45 pm »
I haven't encountered any copy/paste problems. Is that an "other than windows" issue?

In the interim to your response I had devised a workaround method do handle the snag. I saved the file with a bogus extension (.000), set the wrap, and loaded the saved file. Time loss is insignificant on most files, but a large one is painfully noticeable.

I was considering copy/paste as an alternative... so is it an issue with windows? And is it an issue on account of your r5068 update?

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #3 on: August 14, 2016, 01:39:14 pm »
I just copy/pasted the entire utf8 New Testament, and it did so without any fault. That is a major file size and formatting task.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #4 on: August 14, 2016, 02:52:59 pm »
OK... I just went for a walk and remembered the copy/paste problem. Selecting from the start down, or selecting all, are both OK. But selecting a portion inside the text does not collect the header information. So it doesn't do right-to-left writing, and wrongly parses when mixed with left-to-right writing.

I'll go ahead and upgrade to the newest version. Thanks for doing it.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #5 on: August 14, 2016, 03:13:09 pm »
When I do a save-as from the component listing it saves as a ".pas" in HTML format. When I open the page it can only be saved in the same manner.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #6 on: August 14, 2016, 03:28:47 pm »
OK, now I remember... its the weekend and team doesn't convert your files until monday night. I am parsing out the HTML and proceeding manually.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #7 on: August 14, 2016, 03:49:50 pm »
OK. I installed the revised units. It worked. On the New testament file it has a similar slowness to my save to disk and reload method, but I am sure you are doing in with preferred method.

Is item 2 fixable?

2) Setting PageMemo.scrollbars to ssboth or ssvertical sets them properly, but they behave as "auto" parameters. My impression of non-auto function is that the bar or bars should always be visible.

I need fixed bars because I set the width of my form to paper size. That way I can expect the wordwrapping that will show up upon being printed to paper. Consequently I need a fixed vertical scrollbar so the form width method will work.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #8 on: August 14, 2016, 07:29:48 pm »
This something I tried to see if it could be faster...

Code: Pascal  [Select][+][-]
  1.         PageMemo.SelectAll;
  2.         PageMemo.CutToClipboard;
  3.         PageMemo.SetFocus;
  4.        
  5.         PageMemo.ClearSelection;
  6.         showmessage('cleared');
  7.        
  8.         ss:= PageMemo.SelStart;
  9.         if PageMemo.WordWrap=true
  10.            then begin
  11.                 PageMemo.WordWrap:= false;
  12.                 PageMemo.scrollbars:= ssboth;
  13.                 MnuWrap.caption:= 'Wrap On';
  14.                 end
  15.            else Begin
  16.                 PageMemo.WordWrap:= true;
  17.                 PageMemo.scrollbars:= ssvertical;
  18.                 MnuWrap.caption:= 'Wrap Off';
  19.                 end;
  20.         PageMemo.SelStart:= ss;
  21.        
  22.         PageMemo.PasteFromClipboard;
  23.         PageMemo.SelStart:= ss;
  24.         PageMemo.SetFocus;
  25.  

I don't think it is going to be faster. Nevertheless it is a method I might want to use in other applications. The problem is that the CutToClipboard doesn't happen unless there is a manual interaction, which the showmessage happens to accomplish. Is there a way to push the CutToClipboard operation?

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Modifying the WordWrap parameter
« Reply #9 on: August 15, 2016, 03:49:46 am »
OK... I just went for a walk and remembered the copy/paste problem. Selecting from the start down, or selecting all, are both OK. But selecting a portion inside the text does not collect the header information. So it doesn't do right-to-left writing, and wrongly parses when mixed with left-to-right writing.
Actually I was referring to this problem.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Modifying the WordWrap parameter
« Reply #10 on: August 15, 2016, 04:13:54 am »
Is item 2 fixable?

2) Setting PageMemo.scrollbars to ssboth or ssvertical sets them properly, but they behave as "auto" parameters. My impression of non-auto function is that the bar or bars should always be visible.
r5090

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Modifying the WordWrap parameter
« Reply #11 on: August 15, 2016, 04:15:16 am »
This something I tried to see if it could be faster...
Did I get you right - changing word-wrap on a large file is time consuming and user noticeable?

You'd like to avoid messing up the clipboard, since a user might have an important information there, that would be erased by such workaround.

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Modifying the WordWrap parameter
« Reply #12 on: August 15, 2016, 12:49:13 pm »
Good point on "user activity". I had not thought of that. I had started this immediately after doing the "save to disk and load from disk" routine. Then you fixed the WordWrap problem.

But the issue of doing a CutToClipboard by code is still a valid concern. It might be a function that the user is intending. To that end, why isn't it executing on command? It appears to be in a "wait for finally done" mode, indicated by the ShowMessage interaction, and that isn't efficient when coding a function.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

 

TinyPortal © 2005-2018