Community
    • Login

    Same line spacing with other view

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 825 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.
    • Saya PS
      Saya P
      last edited by

      I’m currently using other view with left side being the original language and right side being translated, but due to the nature of the language, the line numbers start being displaced due to word wrap. Is it possible for both lines to have the same line spacing if one of them is spaced?

      For example, in the screenshot below, line #231 is only 1 line on the left, but due to the translation, 2 lines on the right. And because of that, lines are now displaced. I would like to keep word wrap if possible.

      alt text

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Saya P
        last edited by

        @Saya-P said in Same line spacing with other view:

        And because of that, lines are now displaced. I would like to keep word wrap if possible.

        Notepad++ does not have that feature.

        The easiest workaround, as you realized, is to turn off word-wrap, but that makes it harder to see all the data.

        I had hoped that maybe View > Synchronize Vertical Scrolling would get close, because I was hoping it would synchronize by line number, but it actually synchronizes by visual-line

        It would be possible to use PythonScript or one of the scripting languages to make a quick script that would SynchronizeBothViewsByLineNumber by making the top visible line number the same in both… something like

        # encoding=utf-8
        """in response to https://community.notepad-plus-plus.org/topic/25396/
        
        Finds the first line _number_ in the active View.
        Scrolls the other View to have that same line number as the first visible line.
        """
        from Npp import editor,editor1,editor2
        
        class SynchronizeBothViewsByLineNumber(object):
            def __init__(self):
                a = editor.getFirstVisibleLine()
                b = editor1.getFirstVisibleLine()
                c = editor2.getFirstVisibleLine()
                console.write("{} {} {}\n".format(a,b,c))
                editor1.setFirstVisibleLine(a)
                editor2.setFirstVisibleLine(a)
        
        SynchronizeBothViewsByLineNumber()
        

        So if you installed that script for PythonScript (see our FAQ if you need help with that – it even explains how to set a keyboard shortcut), then every time you ran that script, it would make sure the top line was the same on both. It wouldn’t line up everything, but it would line up the top, which might be better than nothing. (Or might not be.)

        My gut feeling is that there’s a way using PythonScript to change the heights of each line individually, which might allow it to sync more like you want… but I don’t know off the top of my head. Maybe another PythonScript guru will remember, or know the right search term, and could figure out a way to make that work.

        Alan KilbornA Saya PS 2 Replies Last reply Reply Quote 0
        • PeterJonesP PeterJones referenced this topic on
        • Alan KilbornA
          Alan Kilborn @PeterJones
          last edited by

          @PeterJones said in Same line spacing with other view:

          I had hoped that maybe View > Synchronize Vertical Scrolling would get close, because I was hoping it would synchronize by line number, but it actually synchronizes by visual-line

          Maybe it should synch by line number… i.e., it’s a bug that it doesn’t?

          1 Reply Last reply Reply Quote 2
          • Saya PS
            Saya P @PeterJones
            last edited by

            @PeterJones I appreciate the help. I assume this script is supposed to set top line to be same line number on both views every time I run this script, but due to the nature of vertical sync snapping lines into place, the script refuses to do anything. I would like to keep vertical sync on if possible.

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Saya P
              last edited by

              @Saya-P said in Same line spacing with other view:

              @PeterJones I appreciate the help. I assume this script is supposed to set top line to be same line number on both views every time I run this script, but due to the nature of vertical sync snapping lines into place, the script refuses to do anything. I would like to keep vertical sync on if possible.

              Sorry. Other than turning off word wrapping, or using this script without vertical-sync turned on, I don’t know of a way to keep your lines in sync when the wrapping-length is different on each. (I tried adding a couple instances of notepad.menuCommand(MENUCOMMAND.VIEW_SYNSCROLLV), which toggles the vertical-sync, so I was hoping I could turn off sync, re-align, then turn back on sync, but unfortunately, it didn’t realign like I thought it would. And I haven’t been able to find a way to send a message to Scintilla (the library that Notepad++ uses for the doing the editor commands) to change the height of individual lines.

              I cannot think of any other workarounds for you. Maybe someone else will.

              Again, sorry.

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

                @PeterJones said in Same line spacing with other view:

                I haven’t been able to find a way to send a message to Scintilla (the library that Notepad++ uses for the doing the editor commands) to change the height of individual lines.

                “All lines of text in Scintilla are the same height, and this height is calculated from the largest font in any current style. This restriction is for performance; if lines differed in height then calculations involving positioning of text would require the text to be styled first.“
                — https://www.scintilla.org/ScintillaDoc.html#TextRetrievalAndModification

                1 Reply Last reply Reply Quote 4
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors