Community
    • Login

    [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    30 Posts 8 Posters 4.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.
    • Patrick SheppardP
      Patrick Sheppard
      last edited by

      Thanks, Michael.

      I had downgraded to 7.8.5 because of this issue and was reluctant to jump back up, but I just did and your modification works a charm.

      Appreciated.

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

        Hello, @matthew-au, @i-neuw, @michael-Vincent, @ekopalypse, @alan-kilborn, @peterjones, @terry-r and All,

        I revisited my previous posts of that discussion about the new Vertical Multi-Edge lines feature !

        First, when I said :

        A work-around has been found but needs to choose one column number only and tick once on the Background mode option !

        I want to insist that the fact of ticking on the Background mode option, then unticking it, is needed to update the sole edge boundary value, displayed ! Even with the last 7.9.0 N++ version, this step is necessary !


        Now, I did some additional tests, on, both, the final version of my regex and the native Split Lines N++ feature ( Ctrl + I ), using the license.txt file !

        • Using my regex S/R method, to split the lines, we get the same result :

          • Whatever the Line or Background mode is used, in Settings > Preferences... > Editing > Vertical Edge Settings

          • Whatever the View > Word wrap option is set or not

          • Whatever the View > Show Symbol > Show All Characters option is set or not

          • Whatever the current font used is a MonoSpaced or a Proportional font, in the Style Configurator...

        provided that you previously ran the Edit > BLank Operations > TAB to Space option if your file contains some TAB characters !


        • Using the native Edit > Line Operations > Split Lines feature, we get the same result

          • Whatever the Line or Background mode is used, in Settings > Preferences... > Editing > Vertical Edge Settings

          • Whatever the View > Word wrap option is set or not


        But, unlike what I said in my first post, the results of the Ctrl + I feature are totally different depending on whether :

        • The View > Show Symbol > Show All Characters option is set or not

        • The current font used is a Monospaced or a Proportional font, in the Style Configurator...


        So, regarding my previous argumentation, my regex method and the native Split Lines N++ feature give the same results ONLY IF :

        • A monospaced font is currently used

        • The EOL symbol ( CRLF ) is not displayed

        • The column number is superior to a minimum of about 15 for normal text. When I say “normal”, I refer, for instance, to the license.txt text, from line 28 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 till the end of file !

        Note also that, with these hypotheses, the splitting operation of a selection of lines with, both, the regex S/R and the native Split Lines feature gives the same text contents !


        IMPORTANT : My regex S/R is built in order to exactly replace the native Split Lines N++ feature, with the hypotheses above. But, of course, you may decide to not follow this rule and use, instead, a more simple search regex as, for instance :

        SEARCH (?-s)^.{75,}?\K\x20+

        REPLACE \r\n

        which would split lines, roughly, after 80 characters

        Best Regards,

        guy038

        1 Reply Last reply Reply Quote 2
        • Michael AldenM
          Michael Alden
          last edited by Michael Alden

          Posting this in case it’s useful to anyone else. I worked around this issue using this plugin: dail8859/LuaScript: Notepad++ plugin for Lua scripting capabilities. Specifically, I added this code to my Lua startup script.

          -- Lua function for Scintilla colors
          local function RGB(red, green, blue)
              return red | green << 8 | blue << 16
          end
          
          -- Teal color value same as default used in Notepad++
          local COLOR_TEAL = RGB(128, 255, 255)
          
          -- Set line mode to EDGE_Line at 80 characters with teal color
          npp.SendEditor(SCI_SETEDGEMODE, EDGE_LINE)
          npp.SendEditor(SCI_SETEDGECOLUMN, 80)
          npp.SendEditor(SCI_SETEDGECOLOUR, COLOR_TEAL)
          

          So, every time Notepad++ starts it resets the column marker. This has the same affect as if one were to toggle the “Background mode” setting.

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @Michael Alden
            last edited by

            @Michael-Alden

            Thanks for your contribution.
            It is a Lua variation on @Michael-Vincent 's original NppExec solution.
            There hasn’t been a Pythonscript implementation, so I’ll add that now:

            editor.setEdgeMode(1)
            editor.setEdgeColumn(80)
            
            Michael VincentM 1 Reply Last reply Reply Quote 2
            • Michael VincentM
              Michael Vincent @Alan Kilborn
              last edited by Michael Vincent

              @Alan-Kilborn said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):

              Pythonscript implementation

              And of course “PerlScript”:

                  editor->setEdgeMode( $SC_EDGEMODE{EDGE_LINE} );
                  editor->setEdgeColumn(80);
              

              Cheers.

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

                Cross-linking: https://community.notepad-plus-plus.org/topic/20581/restore-right-margin-word-wrap-as-in-7-8-5

                1 Reply Last reply Reply Quote 2
                • dinkumoilD
                  dinkumoil @Matthew Au
                  last edited by dinkumoil

                  @Matthew-Au @rd4gh @Alan-Kilborn @Michael-Vincent and all

                  Since this is the older thread I will drop my two cents here.

                  Notepad++ v7.8.6 introduced support for drawing multiple vertical lines (also called “edges”) inside of an editor window. But this new feature is not simply an extension of the old well-known single-edge-line feature, instead it is a completely new edge mode that replaced the old one. Unfortunately this broke the ability to word-wrap a document’s content at such an edge line (using the standard keyboard shortcut Ctrl+I).

                  In the following I provide some scripts for the NppExec plugin to get back the old single-edge-line feature and being able to control it. Additionally I provide a fixed implementation of the related “word-wrap at single-edge-line” feature. That’s because I became aware that Notepad++'s internal implementation of this feature has two bugs:

                  1. If the font size of the line numbers margin is set to a different value than the font size for documents, the “word-wrap at single-edge-line” code calculates a wrong wrapping position. This position has to be provided in pixels. To calculate this pixel value, a Scintilla function has to be called that calculates the width in pixels of a provided string from a provided text style. It seems like Notepad++'s internal code erroneously takes the text style of the line numbers margin font when calling this Scintilla function.

                  2. To generate the template string for the pixel calculation mentioned above, it is necessary to query the set column number of the single-edge-line. Since column numbers in Scintilla are 0-based, the retrieved result has to be incremented by 1 to get the required length of the template string. It seems Notepad++'s internal code doesn’t do that because when word-wrapping a line that has a word boundary exactly at the single-edge-line it wraps this line at the beginning of that word instead at its end.

                  Here are the scripts. Most of them could be assigned to a keyboard shortcut using Shortcut Mapper.

                  Initialize Single-Edge-Line Mode

                  ::SetSingleEdgeLine
                  npp_console keep
                  sci_sendmsg SCI_SETEDGECOLUMN 80
                  sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
                  

                  This script is intended to be used as a NppExec startup-script. It sets the single-edge-line column to column 80 and activates single-edge-line mode. It is able to override a multiple-edge-line or background-color-edge mode set in Notepad++ preferences dialog.

                  Change Single-Edge-Line Column

                  ::ConfigSingleEdgeLine
                  npp_console keep
                  sci_sendmsg SCI_GETEDGECOLUMN
                  inputbox "Input edge column" : "Edge column" : $(MSG_RESULT)
                  sci_sendmsg SCI_SETEDGECOLUMN $(INPUT)
                  sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
                  

                  This script opens an input box where users can change the single-edge-line column. The current column is shown as default value. When the user closes the box, the provided value is set as the new column and single-edge-line mode is activated.

                  Turn on Single-Edge-Line Mode

                  ::SingleEdgeLineOn
                  npp_console keep
                  sci_sendmsg SCI_SETEDGEMODE EDGE_LINE
                  

                  This script activates single-edge-line mode with its current settings.

                  Turn on Multiple-Edge-Line Mode

                  ::MultipleEdgeLinesOn
                  npp_console keep
                  sci_sendmsg SCI_SETEDGEMODE EDGE_MULTILINE
                  

                  This script activates multiple-edge-line mode with its current settings.

                  Turn on Backgound-Color-Edge Mode

                  ::BackgroundEdgeOn
                  npp_console keep
                  sci_sendmsg SCI_SETEDGEMODE EDGE_BACKGROUND
                  

                  This script activates background-color-edge mode with its current settings.

                  Turn all Edges off

                  ::EdgesOff
                  npp_console keep
                  sci_sendmsg SCI_SETEDGEMODE EDGE_NONE
                  

                  This script deactivates all edges.

                  Word-Wrap Selected Text at Single-Edge-Line

                  ::WrapSelectedLinesAtEdge
                  npp_console keep
                  
                  set local $(EdgeModeSingleLine) ~ EDGE_LINE
                  sci_sendmsg SCI_GETEDGEMODE
                  
                  if $(MSG_RESULT) != $(EdgeModeSingleLine) then
                    set local $(LinePixelWidth) = 0
                    goto :DoWrap
                  endif
                    
                  sci_sendmsg SCI_GETEDGECOLUMN
                  set local $(LineCharWidth) ~ $(MSG_RESULT) + 1
                  
                  set local $(TemplateStr) = W
                  set local $(Cnt) = 2
                  
                  :ForLoopStart
                    if $(Cnt) > $(LineCharWidth) goto :ForLoopEnd
                    set local $(TemplateStr) = $(TemplateStr)W
                    set local $(Cnt) ~ $(Cnt) + 1
                  goto :ForLoopStart
                  
                  :ForLoopEnd
                  sci_sendmsg SCI_TEXTWIDTH STYLE_DEFAULT "$(TemplateStr)"
                  set local $(LinePixelWidth) = $(MSG_RESULT)
                  
                  :DoWrap
                  sci_sendmsg SCI_TARGETFROMSELECTION
                  sci_sendmsg SCI_LINESSPLIT $(LinePixelWidth)
                  

                  This script provides a fixed version of the “word-wrap at single-edge-line” feature. As the original one, it word-wraps at the right edit window border if edge mode is not set to single line. This script could be assigned to the Ctrl+I keyboard shortcut in order to replace the buggy built-in version of Notepad++.

                  Alan KilbornA 1 Reply Last reply Reply Quote 4
                  • guy038G
                    guy038
                    last edited by guy038

                    Hello, @dinkumoil and All,

                    Very interesting insight and solutions about the new multiple vertical edges and word-wrapping at a specific position …and, incidentally, some good and short examples of the NppExec scripting language ;-))

                    One question :

                    When trying to find out a regex emulation of the Ctrl + I feature, some months ago, I realized that some mandatory conditions were needed to get the expected behaviour. Refer to the middle part of this post

                    • So, did you verify the behaviour of your last ::WrapSelectedLinesAtEdge script in these three cases :

                    • A proportional font is used instead of the monospaced one ?

                    • The EOL symbol is displayed, with the View > Show Symbol > Show End of Line or View > Show Symbol > Show All Characters options

                    • The current file contains some tabulation characters, as the number of pixels used by a TAB char is generally different from the space character !

                    Indeed, the Ctrl + I behaviour, with a single edge, seemed broken when one of these cases occur !

                    Best Regards,

                    guy038

                    dinkumoilD 1 Reply Last reply Reply Quote 1
                    • dinkumoilD
                      dinkumoil @guy038
                      last edited by dinkumoil

                      @guy038

                      Of course, I had not tested the behaviour of my WrapSelectedLinesAtEdge script in conjunction with a proportional font before you asked me because it makes no sense. ;-) Besides that, I’m sure it will not work .

                      After testing I can say: I got the expected results.

                      When using a proportional font, the edge line is still drawn as a straight vertical line and when moving the cursor up and down along this line, the Col : field of the status bar shows different values in every single line, depending on the crrent line’s content - obiously because the font is proportional and the characters have different widths. And when running my script, Scintilla does the word-wrap at totally wrong positions.

                      An edge line simply makes no sense when using proportional fonts, thus my script makes no sense as well in this case. That’s the reason why I have not tested it and why I don’t care that it doesn’t work. :-)

                      BTW: When I activated the proportional font in style configurator, Notepad++ immediately turned off the single-edge-line.

                      1 Reply Last reply Reply Quote 3
                      • Alan KilbornA
                        Alan Kilborn @dinkumoil
                        last edited by Alan Kilborn

                        @dinkumoil said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):

                        If the font size of the line numbers margin is set to a different value than the font size for documents

                        In experimenting with this, I think I discovered a hidden “feature”.
                        It has been asked before how to get increased vertical spacing between lines in a document (visually only, of course).
                        This seems to be another method:

                        • Go into Style Configurator and set the Font size of the Line number margin to a large number, e.g. 28:
                          Imgur

                        The effect:

                        Imgur

                        OK, the line numbers are really large, but you could always turn them off (in which case the vertical spacing remains, even after restart of N++).

                        Note: Regarding @dinkumoil 's comment, my new technique could really cause line-splitting with Ctrl+i to yield some wrong/undesired results!!

                        Michael VincentM dinkumoilD 2 Replies Last reply Reply Quote 3
                        • Michael VincentM
                          Michael Vincent @Alan Kilborn
                          last edited by

                          @Alan-Kilborn said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):

                          It has been asked before how to get increased vertical spacing between lines in a document (visually only, of course).

                          Can you just use SCI_SETEXTRAASCENT and SCI_SETEXTRADESCENT?

                          In NppExec:

                          SCI_SENDMSG SCI_SETEXTRADESCENT 2
                          

                          I actually use the value of 1 in my startup script.

                          Cheers.

                          Alan KilbornA 1 Reply Last reply Reply Quote 1
                          • Alan KilbornA
                            Alan Kilborn @Michael Vincent
                            last edited by

                            @Michael-Vincent said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):

                            Can you just use SCI_SETEXTRAASCENT and SCI_SETEXTRADESCENT?

                            Well, yes… I was just showing another way of doing it, and an interesting way at that. :-)

                            And of course, there’s a leap to using NppExec (or the other usual suspect: PythonScript) that some people are unable/afraid to take.

                            1 Reply Last reply Reply Quote 2
                            • dinkumoilD
                              dinkumoil @Alan Kilborn
                              last edited by

                              @Alan-Kilborn

                              Yes, I discovered that already in the past. Increasing inter-line spacing is also possible with other styles, for example the Brace highlight style.

                              1 Reply Last reply Reply Quote 1
                              • Alan KilbornA Alan Kilborn referenced this topic on
                              • First post
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors