Community
    • Login

    Other thoughts regarding the "ReWrap Text to (Clipboard or 72) width" of the old "TextFX" plugin

    Scheduled Pinned Locked Moved General Discussion
    20 Posts 4 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G Offline
      guy038
      last edited by guy038

      Hello, @alan-kilborn,

      You said :

      For clarity for future readers of this thread, which method is this one?

      I was referring to these steps :

      • First, run a Edit > Blank Operations > TAB to Space option

      • Then run the regex replacement below, where C represents the maximum number of chars after you want a line-break :

        • SEARCH [\x20\r\n]*\z|(?-s)^(?=.{C+1,}).{1,C}\K(?:\x20*\R|\x20+)

        • REPLACE \r\n for Windows files    or    \n for Unix files

      • Finally, run a Edit > Blank operations > Trim Trailing Space option


      You then said :

      And, because I’m currently away from my Notepad++ and can’t try it myself, why are these "must be OFF"s?

      I must apologize because I was mistaken ! I did some other tests and it happens that the status of the View > Word wrap does not matter

      But I confirm that showing the line-endings chars breaks the correct spliting of text when using the Edit > Line Operations > Split Lines option

      STR :

      • In Settings > Preferences... > Margins/Border/Edge > Vertical Edge Settings insert the value 78 , ONLY

      • For clarity, just uncheck the View > Word wrap option and the View > Show Symbol option

      • Paste the beginning of the License.txt file, below, in a new tab :

      COPYING -- Describes the terms under which Notepad++ is distributed.
      A copy of the GNU GPL is appended to this file.
      
      IMPORTANT NOTEPAD++ LICENSE TERMS
      
      Copyright (C)2021 Don HO <don.h@free.fr>.  This program is free software; you may redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; Version 3 with the clarifications and exceptions described below. This guarantees your right to use, modify, and redistribute this software under certain conditions.
      
      This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
      
      ******************************************************************
      
      
      GNU GENERAL PUBLIC LICENSE
      Version 3, 29 June 2007
      
      Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
      
      Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
      
      Preamble
      The GNU General Public License is a free, copyleft license for software and other kinds of works.
      
      The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
      
      • Now, in the new tab, select all this text with Ctrl + A

      • Run the Edit > Line Operations > Slipt Lines or Ctrl + I option

      => You should get the text below :

      COPYING -- Describes the terms under which Notepad++ is distributed.
      A copy of the GNU GPL is appended to this file.
      
      IMPORTANT NOTEPAD++ LICENSE TERMS
      
      Copyright (C)2021 Don HO <don.h@free.fr>.  This program is free software; 
      you may redistribute and/or modify it under the terms of the GNU General 
      Public License as published by the Free Software Foundation; Version 3 with 
      the clarifications and exceptions described below. This guarantees your 
      right to use, modify, and redistribute this software under certain 
      conditions.
      
      This program is distributed in the hope that it will be useful, but WITHOUT 
      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
      FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
      more details.
      
      ******************************************************************
      
      
      GNU GENERAL PUBLIC LICENSE
      Version 3, 29 June 2007
      
      Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
      
      Everyone is permitted to copy and distribute verbatim copies of this license 
      document, but changing it is not allowed.
      
      Preamble
      The GNU General Public License is a free, copyleft license for software and 
      other kinds of works.
      
      The licenses for most software and other practical works are designed to 
      take away your freedom to share and change the works. By contrast, the GNU 
      General Public License is intended to guarantee your freedom to share and 
      change all versions of a program--to make sure it remains free software for 
      all its users. We, the Free Software Foundation, use the GNU General Public 
      License for most of our software; it applies also to any other work released 
      this way by its authors. You can apply it to your programs, too.
      
      • Now, undo, with Ctrl + Z, the last action in order to return to the unwrapped text again

      • Click on the ¶ icon or run the View > Show Symbols > Show All Characters option

      • RE-select all contents of the new tab

      • Run again the Edit > Line Operations > Slipt Lines or Ctrl + I option

      => This time, you should get this text :

      COPYING -- Describes the terms under which Notepad++ is distributed.
      A copy of the GNU GPL is appended to this file.
      
      IMPORTANT NOTEPAD++ LICENSE TERMS
      
      Copyright (C)2021 Don HO <don.h@free.fr>.  This program is free software; 
      you may redistribute and/or modify it under the terms of the GNU 
      General 
      Public License as published by the Free Software Foundation; Version 3 
      with 
      the clarifications and exceptions described below. This guarantees your 
      right to use, modify, and redistribute this software under certain 
      conditions.
      
      This program is distributed in the hope that it will be useful, but WITHOUT 
      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
      FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
      for 
      more details.
      
      ******************************************************************
      
      
      GNU GENERAL PUBLIC LICENSE
      Version 3, 29 June 2007
      
      Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
      
      Everyone is permitted to copy and distribute verbatim copies of this license 
      document, but changing it is not allowed.
      
      Preamble
      The GNU General Public License is a free, copyleft license for software and 
      other kinds of works.
      
      The licenses for most software and other practical works are designed to 
      take away your freedom to share and change the works. By contrast, the 
      GNU 
      General Public License is intended to guarantee your freedom to share 
      and 
      change all versions of a program--to make sure it remains free software 
      for 
      all its users. We, the Free Software Foundation, use the GNU General 
      Public 
      License for most of our software; it applies also to any other work 
      released 
      this way by its authors. You can apply it to your programs, too.
      

      And, obviously, these two texts are quite different !

      Test done with a portable N++ v8.9.8 - 64 bits installation !

      Best Regards

      guy038

      1 Reply Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn
        last edited by

        @guy038 said:

        I confirm that showing the line-endings chars breaks the correct spliting of text when using the Edit > Line Operations > Split Lines option

        So then this is a Notepad++ bug, correct?

        CoisesC 1 Reply Last reply Reply Quote 0
        • guy038G Offline
          guy038
          last edited by

          Hi, @alan-kilborn and All,

          I suppose so ! But have you checked this behavior for yourself ?

          BR

          guy038

          Alan KilbornA 1 Reply Last reply Reply Quote 0
          • CoisesC Online
            Coises @Alan Kilborn
            last edited by Coises

            @Alan-Kilborn said:

            So then this is a Notepad++ bug, correct?

            Considering that Notepad++ just uses Scintilla’s SCI_LINESSPLIT, it’s more of a Scintilla bug, if that project would consider it a bug. The documentation says that function finds split points “in a similar manner to line wrapping”; line wrapping also treats line endings as part of the line when they are visible.

            However, I suppose Notepad++ could temporarily turn off showing line endings before doing the split.

            1 Reply Last reply Reply Quote 2
            • guy038G Offline
              guy038
              last edited by guy038

              Hi, @alan-kilborn, @coises and All,

              From the scintilla description, below :

              SCI_LINESSPLIT(pixels pixelWidth)
              Split a range of lines indicated by the target into lines that are at most pixelWidth wide. Splitting occurs on word boundaries wherever possible in a similar manner to line wrapping. When pixelWidth is 0 then the width of the window is used.
              
              • I made a try putting ONLY the 0 value ( instead of 78 ) In Settings > Preferences... > Margins/Border/Edge > Vertical Edge Settings. Well, it happens that for any value ≤ 2, the spliting occurs after 2 characters

              • I also tested with, for example, the value 220, which was larger than my physical screen. However, even in this case, the spliting occurs after 220 chars and not at the window’s width !

              Of course, for these additional tests, line-endings were not enabled !


              Oh, my God : I forgot to test with the Settings > Preferences... > Margins/Border/Edge > Vertical Edge Settings window completely empty ! Well, in this specific case, the spliting does occur at the window’s width and takes in account the possible increase or decrease in the ZOOM factor !

              BR

              guy038

              CoisesC 1 Reply Last reply Reply Quote 0
              • Alan KilbornA Offline
                Alan Kilborn @guy038
                last edited by

                @guy038 said:

                But have you checked this behavior for yourself ?

                I have not; I’ve been away from my PC.

                If it’s a bug, either Scintilla or Notepad++, it seems like it should be reported and made official?

                1 Reply Last reply Reply Quote 0
                • CoisesC Online
                  Coises @guy038
                  last edited by

                  @guy038 said:

                  Oh, my God : I forgot to test with

                  If you are interested in such things, you’ll find some very curious results using proportional fonts. When Vertical Edge Settings: Background mode is checked, the highlighting for overlong lines is based on counting characters; when it is not checked, the edge position is (or positions are) based on the width of a space in the default font. (You can see the difference by having a file with sufficiently long lines open, setting a proportional font, then opening Preferences to the Margin/Border/Edge panel, setting a single vertical edge, and toggling Background mode.)

                  The Notepad++ Split Lines command bases its division on the width of a capital “P” in the default font multiplied by the (last) edge column, and hence doesn’t match either.


                  Scintilla sets edge markers based on columns (counting in background mode, using the width of a space character otherwise), so there isn’t a lot Notepad++ can do about that. Scintilla does splitting based on pixel widths; there might be a fair argument for Notepad++ doing its own splitting instead of using Scintilla’s when splitting is based on an “edge” with Background mode checked. Except for the visible line ending oddity, splitting by view width (that is, when there is no edge) works as one would expect. Why Notepad++ uses the width of a capital “P” to get the width to which to split lines when Scintilla uses the width of a space to draw the edge line, I can’t guess.

                  1 Reply Last reply Reply Quote 1
                  • guy038G Offline
                    guy038
                    last edited by guy038

                    Hello, @coises, @alan-kilborn and All,

                    I made a test :

                    • First, disable the View > Word wrap option as well as the View > Show symbol option

                    • Put the value 78, ONLY, in the Settings > Preferences... > Margins/Border/Edge > Vertical Edge Settings dialog

                    • Leave the Background mode option unchecked

                    • Then, insert this text below in a N++ new tab :

                    iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
                                                                                                  <<<
                    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
                    PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
                    ______________________________________________________________________________
                    
                    
                    Copyright (C)2021 Don HO <don.h@free.fr>.  This program is free software; you may redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; Version 3 with the clarifications and exceptions described below. This guarantees your right to use, modify, and redistribute this software under certain conditions.
                    

                    Note : globally, the capital letter W is the largest letter in proportional fonts and the small letter i is the smallest letter in proportional fonts

                    • Now, select the 78 space characters, right before the string <<<

                    => You can verify that the status bar contains Col:79 Sel: 78 indication

                    • Open the Settings > Style configurator... dialog and select Global Styles for Language and Default Style for Style

                    • Now, click on the drop-down list of the Font name option

                    • Use the Up and Down arrow key to select an other font

                    => It easy to verify, in the status bar, that, whatever the font used, even exotic ones, the selection of the gap of space characters stays identical to the value 78


                    Now if, for any font, you select all the text of that new tab and run an Edit > Line Operations > Split Lines operation, for most of them, indeed, the spliting behaviour occured right after the 78 capital letter P.

                    However, for example :

                    • For the proportional Times New Roman font, the spliting action occured after 76 letters P

                    • For the fixed witdh Consolas font, the spliting action occured after 77 letters P

                    Best Regards,

                    guy038

                    CoisesC 1 Reply Last reply Reply Quote 1
                    • CoisesC Online
                      Coises @guy038
                      last edited by

                      @guy038 said:

                      Now if, for any font, you select all the text of that new tab and run an Edit > Line Operations > Split Lines operation, for most of them, indeed, the spliting behaviour occured right after the 78 capital letter P.

                      However, for eample :

                      • For the proportional Times New Roman font, the spliting action occured after 76 letters P

                      • For the fixed witdh **``Consolas font, the spliting action occured after 77 letters P

                      The explanation may lie in something I discovered while bug-hunting in the Elastic tabstops function of Columns++: when DirectWrite is in use, the width of characters can work out to fractional pixels (this is true for both fixed and proportional fonts); but Scintilla only reports the width of strings as integers. So due to the effect of rounding to integers, the width of a string of 78 letters P is not necessarily 78 times the (reported) width of one letter P. Notepad++ uses 78 times the width of one letter P. (Not that it matters much, since none of this is likely to be what anyone wants or expects anyway.)

                      1 Reply Last reply Reply Quote 1
                      • PeterJonesP PeterJones forked this topic on
                      • guy038G Offline
                        guy038
                        last edited by guy038

                        Hello, @coises,

                        I confirm that, if I choose the GDI (most compatible) rendering mode instead of the DirectWrite (default), the spliting action seems to always occur after 78 letters P !

                        I verified this assumption with, both, the proportional Times New Roman font and the fixed width Consolas font

                        BR

                        guy038

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors