Community
    • Login

    Is there a way to keep a blank "working space" as I'm logging information?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 5 Posters 492 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.
    • NexusN
      Nexus
      last edited by

      I use Notepad++ primarily for taking notes and logging information. I usually have it running always on top on the right side of my screen while I watch an informational video through the left. It may sound like a silly or unorthodox request, but is there any way to make it so that any new information entered doesn’t eventually fall to the bottom of the screen as I log new lines, and for there to be a permanent empty space around 1/3 from the bottom of the screen (or halfway) as I log new text?

      Apologies if this is an incredibly simple solution.

      Image example:
      As I log information, it eventually falls to the bottom of the screen
      Screenshot 2024-10-03 135128.png

      Whereas I would prefer for it to always remain like this; with a “blank space”
      Screenshot 2024-10-03 135332.png

      PeterJonesP mkupperM 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Nexus
        last edited by

        @Nexus ,

        I am assuming you already have Settings > Preferences > Editing 1 > Enable Scrolling Beyond Last Line checkmarked (based on your screenshot, unless that was an edited screenshot) – but if you don’t, turn it on.

        The manual way, with beyond-last-line enabled, is to give your mouse’s scrollwheel a twirl when you get “too far down” on the screen, and it will allow you to move the last line up higher on the screen. If you don’t like moving your hand to scroll

        Notepad++ doesn’t have an auto-scroll feature built in. But using the PythonScript plugin (or one of the other scripting plugins), there are couple of things you could do:

        1. create a simple script which does the scrolling, and bind that script to a keyboard shortcut (so when you get low enough for it to bother you, you could just use the shortcut instead of moving your hand to the mouse to scroll)
        2. you could set up a callback which will poll as you are typing, and if you get to something more than XX% of the screen down in your typing, it could automatically

        the underlying function would be something like the following, which scrolls 1/3 of a window if the current line is more than 2/3 of the way from top to bottom:

        def scrollThirdIfBottomThird():
            p = editor.getCurrentPos()
            l = editor.lineFromPosition(p)
            v = editor.getFirstVisibleLine()
            h = editor.linesOnScreen()
            if (l-v) > 2/3*h: 
                editor.lineScroll(0, round(h/3))
        

        and you would either just run that function when the script is called (for option 1), or you would call that function for the callback (for option 2).

        NexusN 1 Reply Last reply Reply Quote 1
        • NexusN
          Nexus @PeterJones
          last edited by

          @PeterJones Thanks! I installed the PythonScript plugin and created the script based off your code, but I still can’t seem to get it working with my document. Also, yes, I do have the “Enable Scrolling Beyond Last Line” box ticked, which I should have mentioned is how I was able to take that screenshot.

          How would I go about setting up a callback to use this script in my document? I would rather have it run automatically as opposed to using a keyboard shortcut every so often. All things considered, this is a very minor issue – but I nonetheless appreciate any input!

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

            @Nexus said in Is there a way to keep a blank "working space" as I'm logging information?:

            I still can’t seem to get it working with my document

            The snippet I posted is just the function; you would have to call that function at the end of the script. (Also, you have to make sure your from Npp import editor at the top of your script; I don’t think PythonScript turns on Plugins > Python Script > Configuration… > Automatically open console on error, so you probably have error message in the console that you haven’t seen)

            How would I go about setting up a callback to use this script in my document

            The Plugins > Python Script > Context-Help will open the PythonScript docs in your browser, and the section on “Handling Notifications” describes how to set up a callback.

            But in terms of this script, I think this will get you close to what you want:

            from Npp import editor, SCINTILLANOTIFICATION
            
            def scrollThirdIfBottomThird(args):
                p = editor.getCurrentPos()
                l = editor.lineFromPosition(p)
                v = editor.getFirstVisibleLine()
                h = editor.linesOnScreen()
                if (l-v) > 2/3*h:
                    editor.lineScroll(0, round(h/3))
            
            editor.callback(scrollThirdIfBottomThird, [SCINTILLANOTIFICATION.CHARADDED])
            

            Run that once when you start Notepad++, and it will scroll every time your caret gets to the ~2/3 point of the screen.

            To make it automatic, you’d have to go to Plugins > Python Script > Configuration and set Initialisation to ATSTARTUP, and you’d have to save your script as startup.py in your %AppData%\Notepad++\plugins\config\PythonScript\scripts\ directory.

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

              I said,

              save your script as startup.py

              To other readers: that advice was given in that way because I knew that @Nexus had just installed PythonScript, and thus wouldn’t have a user startup.py yet. If someone who already has a user startup.py wanted this functionality, add the code from my post to the existing startup.py instead of overwriting it.

              1 Reply Last reply Reply Quote 1
              • mkupperM
                mkupper @Nexus
                last edited by

                @Nexus, did you try Notepad++'s monitoring feature? It’s available under View / Monitoring (tail -f) This will cause Notepad++ to watch the file and as things are added to it shows you the changes. Notepad++'s Monitoring feature autoscrolls as stuff gets added to the bottom of the file.

                The downsides are that you won’t get the 1/3rd of the screen blank area at the bottom and that while you are monitoring a file then Notepad++ won’t allow you to edit it. To manually edit the file you turn monitoring off, edit, and re-enable monitoring. If you have Notepad+++ toolbar enabled then Notepad++ is that eye (👁) styled icon.

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

                  @Nexus

                  I’m not sure why you’d feel more comfortable having this “blank working space”, but I would try this:

                  from Npp import *
                  editor.setYCaretPolicy(CARETPOLICY.SLOP | CARETPOLICY.STRICT | CARETPOLICY.EVEN, 12)
                  

                  Maybe it would be just for grins and giggles (as a solution), but if I were you I’d try it, on the off chance that it gives you something close to what you want.

                  NexusN 1 Reply Last reply Reply Quote 2
                  • NexusN
                    Nexus @Alan Kilborn
                    last edited by Nexus

                    @Alan-Kilborn This actually worked perfectly! Thank you.

                    I’m not sure why you’d feel more comfortable having this “blank working space”

                    Honestly, I’m not sure! It’s really just a preference thing. It’s like I have a bit of “extra room” to type.

                    @PeterJones said in Is there a way to keep a blank "working space" as I'm logging information?:

                    @Nexus said in Is there a way to keep a blank "working space" as I'm logging information?:

                    I still can’t seem to get it working with my document

                    The snippet I posted is just the function; you would have to call that function at the end of the script. (Also, you have to make sure your from Npp import editor at the top of your script; I don’t think PythonScript turns on Plugins > Python Script > Configuration… > Automatically open console on error, so you probably have error message in the console that you haven’t seen)

                    How would I go about setting up a callback to use this script in my document

                    The Plugins > Python Script > Context-Help will open the PythonScript docs in your browser, and the section on “Handling Notifications” describes how to set up a callback.

                    But in terms of this script, I think this will get you close to what you want:

                    from Npp import editor, SCINTILLANOTIFICATION
                    
                    def scrollThirdIfBottomThird(args):
                        p = editor.getCurrentPos()
                        l = editor.lineFromPosition(p)
                        v = editor.getFirstVisibleLine()
                        h = editor.linesOnScreen()
                        if (l-v) > 2/3*h:
                            editor.lineScroll(0, round(h/3))
                    
                    editor.callback(scrollThirdIfBottomThird, [SCINTILLANOTIFICATION.CHARADDED])
                    

                    Run that once when you start Notepad++, and it will scroll every time your caret gets to the ~2/3 point of the screen.

                    To make it automatic, you’d have to go to Plugins > Python Script > Configuration and set Initialisation to ATSTARTUP, and you’d have to save your script as startup.py in your %AppData%\Notepad++\plugins\config\PythonScript\scripts\ directory.

                    Unfortunately, this alternative didn’t work with me. I’m not sure if maybe I had made a mistake somewhere, but I still very much appreciate your time and advice!

                    @mkupper said in Is there a way to keep a blank "working space" as I'm logging information?:

                    @Nexus, did you try Notepad++'s monitoring feature? It’s available under View / Monitoring (tail -f) This will cause Notepad++ to watch the file and as things are added to it shows you the changes. Notepad++'s Monitoring feature autoscrolls as stuff gets added to the bottom of the file.

                    The downsides are that you won’t get the 1/3rd of the screen blank area at the bottom and that while you are monitoring a file then Notepad++ won’t allow you to edit it. To manually edit the file you turn monitoring off, edit, and re-enable monitoring. If you have Notepad+++ toolbar enabled then Notepad++ is that eye (👁) styled icon.

                    I need to be able to edit in real time which wouldn’t work with the monitoring feature, as I’d have to go back between enabling and disabling it. Thank you for the suggestion, though!

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

                      @Nexus said in Is there a way to keep a blank "working space" as I'm logging information?:

                      Unfortunately, this alternative didn’t work with me. I’m not sure if maybe I had made a mistake somewhere, but I still very much appreciate your time and advice!

                      If you can ever spend more time on it, and give feedback as to what did and did not happen (making sure to check things like the PythonScript console to see if there were any errors), here is a debug version of the script, which will print every time you add a char (ie, type something). If you hit ENTER enough in your file that your caret (typing cursor) is over 2/3 of the way down, it scrolls.

                      from Npp import editor, console, SCINTILLANOTIFICATION
                      import datetime
                      
                      def scrollThirdIfBottomThird(args):
                          p = editor.getCurrentPos()
                          l = editor.lineFromPosition(p)
                          v = editor.getFirstVisibleLine()
                          h = editor.linesOnScreen()
                          console.write("t:{} pos:{} line:{} first:{} height:{} l-v:{} 2/3h: {} DoScroll?:{}\n".format(datetime.datetime.now(), p,l,v,h,l-v, 2/3*h, (l-v) > 2/3*h))
                          if (l-v) > 2/3*h:
                              editor.lineScroll(0, round(h/3))
                      
                      console.show()
                      editor.callback(scrollThirdIfBottomThird, [SCINTILLANOTIFICATION.CHARADDED])
                      console.write("Registered CHARADDED=>scrollThirdIfBottomThird() callback\n")
                      

                      If you run this script, the PythonScript console should show up automatically, and it will print a message that it Registered CHARADDED=>scrollThirdIfBottomThird() callback. Then as you add characters (by typing or pasting or what have you), if your caret (typing cursor) is below 2/3 of the screen height, it will show a True and scroll the screen.

                      Here’s an animated screencap showing the steps I use to run the script, and how I prove to myself that it works as I type down to go below about 2/3 of the way (which is ~24 of the 35 lines):
                      4c04cf9a-e29d-4b0e-8221-dfa25a6f5e07-auto-scroll.gif

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

                        Hello, All,

                        From the solution, provided by @alan-kilborn, I decided to explore the diffent behaviours of the caret, when using the Scintilla method editor.setYCaretPolicy

                        In the table, below, all possible combinations are listed but I restricted my findings to the vertical caret position and behaviour only


                        Each Python command can be expressed in two different ways. For example :

                        • editor.setYCaretPolicy(CARETPOLICY.SLOP | CARETPOLICY.STRICT | CARETPOLICY.EVEN, UZ)

                        or

                        • editor.setYCaretPolicy(13, UZ)

                        Where UZ represents the number of unwanted lines to avoid, near the top and the bottom of the screen


                        Some of these commands do not need the unwanted zone parameter ( UZ ). For instance, the default behaviour of the caret can be expressed as :

                        • editor.setYCaretPolicy(CARETPOLICY.EVEN, x)

                        or

                        • editor.setYCaretPolicy(8, x)

                        Where x is any integer and you can safely use the 0 value


                        Note that several commands may produce the same behaviour and also that, generally, the behaviour of the caret depends on the direction of the move : downward or upwards !

                        Here is the list :


                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |                                     editor.setYCaretPolicy...                                     |   JUMPS   |  EVEN   |   STRICT  |  SLOP  |                      CARET behaviour                       |        On LIMIT, when caret is NOT visible or WITHIN the Unwanted Zone ( UZ), the display is ...                |
                            |                                                                                                   |     16    |    8    |      4    |    1   |                                                            |                                                                                                                 |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |  (CARETPOLICY.EVEN, x)                                         ( = DEFAULT case )    |   (8, x)   |      0    |    1    |      0    |    0   |  CARET can move from TOP to BOTTOM                         |  Moved by ONE position DOWNWARDS or UPWARDS                                                                     |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |  (CARETPOLICY.STRICT, x)                                                             |   (4, x)   |      0    |    0    |      1    |    0   |  CARET line is ALWAYS located on TOP of the screen         |    -                                                                                                            |
                            |  (CARETPOLICY.STRICT | CARETPOLICY.JUMPS, x)                                         |  (20, x)   |      1    |    0    |      1    |    0   |  CARET line is ALWAYS located on TOP of the screen         |    -                                                                                                            |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.SLOP|CARETPOLICY.STRICT, UZ)                                           |   (5, UZ)  |      0    |    0    |      1    |    1   |  CARET line is ALWAYS located AFTER UZ lines from the TOP  |    -                                                                                                            |
                            |  (CARETPOLICY.SLOP | CARETPOLICY.STRICT | CARETPOLICY.JUMPS, UZ)                     |  (21, UZ)  |      1    |    0    |      1    |    1   |  CARET line is ALWAYS located AFTER UZ lines from the TOP  |    -                                                                                                            |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |  (CARETPOLICY.STRICT | CARETPOLICY.EVEN, x)                                          |  (12, x)   |      0    |    1    |      1    |    0   |  CARET line is ALWAYS CENTERED on the screen               |    -                                                                                                            |
                            |  (CARETPOLICY.STRICT | CARETPOLICY.JUMPS | CARETPOLICY.EVEN, x)                      |  (28, x)   |      1    |    1    |      1    |    0   |  CARET line is ALWAYS CENTERED on the screen               |    -                                                                                                            |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.JUMPS | CARETPOLICY.EVEN, x)                                           |  (24, x)   |      1    |    1    |      0    |    0   |  CARET can move from TOP to BOTTOM                         |  Moved to CENTER on the screen the LAST     line as CARET line,                                going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to CENTER on the screen the PREVIOUS line as CARET line,                                going UPWARDS    |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |      N/A                                                                             |   (0, x)   |      0    |    0    |      0    |    0   |  CARET can move from TOP to BOTTOM                         |  Moved to put the LAST     line of the screen as CARET line on TOP of the screen,              going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to put the PREVIOUS line of the screen as CARET line on TOP of the screen,              going UPWARDS    |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.JUMPS, x)                                                              |  (16, x)   |      1    |    0    |      0    |    0   |  CARET can move from TOP to BOTTOM                         |  Moved to put the LAST     line of the screen as CARET line on TOP of the screen,              going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to put the PREVIOUS line of the screen as CARET line on TOP of the screen,              going UPWARDS    |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |  (CARETPOLICY.SLOP, UZ)                                                              |   (1, UZ)  |      0    |    0    |      0    |    1   |  CARET can move from TOP to BOTTOM                         |  Moved to ALWAYS have UZ lines at the TOP, BEFORE the CARET line,                              going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to ALWAYS have UZ lines at the TOP, BEFORE the PREVIOUS line as CARET line,             going UPWARDS    |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.SLOP | CARETPOLICY.EVEN, UZ)                                           |   (9, UZ)  |      0    |    1    |      0    |    1   |  CARET can move from TOP to BOTTOM                         |  Moved to ALWAYS have UZ lines [ + 1 ] at the BOTTOM, AFTER  the CARET line,                  going DOWNWARDS   |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to ALWAYS have UZ lines         at the TOP,    BEFORE the PREVIOUS line as CARET line, going UPWARDS     |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.SLOP | CARETPOLICY.STRICT | CARETPOLICY.EVEN, UZ)                      |  (13, UZ)  |      0    |    1    |      1    |    1   |  CARET can move OUTSIDE the Unwanted Zone (UZ) ONLY        |  Ajusted to ALWAYS have UZ lines [ + 1 ] at the BOTTOM, AFTER  the CARET line,                 going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Ajusted to ALWAYS have UZ lines         at the TOP,    BEFORE the CARET line                  going UPWARDS    |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |  (CARETPOLICY.SLOP | CARETPOLICY.JUMPS, UZ)                                          |  (17, UZ)  |      1    |    0    |      0    |    1   |  CARET can move from TOP to BOTTOM                         |  Moved to ALWAYS have 3UZ lines at the TOP, BEFORE the CARET line,                             going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to ALWAYS have 3UZ lines at the TOP, BEFORE the PREVIOUS line as CARET line,            going UPWARDS    |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.SLOP | CARETPOLICY.JUMPS | CARETPOLICY.EVEN, UZ)                       |  (25, UZ)  |      1    |    1    |      0    |    1   |  CARET can move from TOP to BOTTOM                         |  Moved to ALWAYS have 3UZ lines [ + 1 ] at the BOTTOM, AFTER  the LAST     line as CARET line, going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to ALWAYS have 3UZ lines         at the TOP,    BEFORE the PREVIOUS line as CARET line, going UPWARDS    |
                            •--------------------------------------------------------------------------------------•------------•-----------•---------•-----------•--------•------------------------------------------------------------•-----------------------------------------------------------------------------------------------------------------•
                            |  (CARETPOLICY.SLOP | CARETPOLICY.STRICT | CARETPOLICY.JUMPS | CARETPOLICY.EVEN, UZ)  |  (29, UZ)  |      1    |    1    |      1    |    1   |  CARET can move OUTSIDE the Unwanted Zone (UZ) ONLY        |  Moved to ALWAYS have 3UZ lines [ + 1 ] at the BOTTOM, AFTER  the CARET line,                  going DOWNWARDS  |
                            |                                                                                      |            |           |         |           |        |                                                            |  Moved to ALWAYS have 3UZ lines         at the TOP   , BEFORE the CARET line,                  going UPWARDS    |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                            |                                                                                                   |     16    |    8    |      4    |    1   |                                                            |                                                                                                                 |
                            |                                     editor.setYCaretPolicy...                                     |   JUMPS   |  EVEN   |   STRICT  |  SLOP  |                      CARET behaviour                       |        On LIMIT, when caret is NOT visible or WITHIN the Unwanted Zone ( UZ), the display is ...                |
                            •======================================================================================•============•===========•=========•===========•========•============================================================•=================================================================================================================•
                        

                        So, just experiment some of these caret behaviours : you could be surprised ! I did not think of so many ways to move the caret :-))

                        Best Regards,

                        guy038

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

                          @guy038 said :

                          Here is the list

                          Which hopefully bears some similarity to:

                          https://www.scintilla.org/ScintillaDoc.html#SCI_SETYCARETPOLICY

                          :-)

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