Community
    • Login

    Distraction-free mode

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    postit modedistractionzenmode
    4 Posts 4 Posters 4.4k 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.
    • gracile-frG
      gracile-fr
      last edited by

      I’ve seen two discussions about a distraction-free mode: https://sourceforge.net/p/notepad-plus/discussion/331754/thread/c0b3127a/ and https://notepad-plus-plus.org/community/topic/13703/is-there-a-distraction-free-writing-mode-like-vimroom-a-plugin-of-vim
      In the latter, @dail posted a nice screenshot of what could be such a mode: the text is centered on screen with wide margins. Would it be possible to have the source code of this plugin? Thank you!

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • dailD
        dail
        last edited by

        Hi @gracile-fr

        I don’t have the source code any more. I just did some quick tests on an existing plugin I was working with. To get the basic functionality is easy, just set the margins wide so that it centers the text. You can do some testing with the PythonScript plugin. (Normally I would be a bit biased to use LuaScript but there is an issue using it to set the margins). So using Python:

        w = 1980
        editor.setMarginLeft(w/3)
        editor.setMarginRight(w/3)
        notepad.runMenuCommand("View", "Post-It")
        

        That’s the general idea. Obviously the screen width is hard coded, don’t know off the top of my head how to get the width of the editor.

        1 Reply Last reply Reply Quote 2
        • Claudia FrankC
          Claudia Frank @gracile-fr
          last edited by

          @gracile-fr

          you could use @dail s script and ctypes to get the size of the fullscreen notepad++ window like this

          import ctypes
          from ctypes.wintypes import RECT
          
          FindWindow = ctypes.windll.user32.FindWindowW
          GetWindowRect = ctypes.windll.user32.GetWindowRect
          Rect = RECT()
          
          nppHandle = FindWindow(u'Notepad++', None)
          notepad.runMenuCommand("View", "Post-It")
          
          if GetWindowRect(nppHandle, ctypes.byref(Rect)) != 0:
              w = Rect.right
              editor.setMarginLeft(w/3)
              editor.setMarginRight(w/3)
          

          Cheers
          Claudia

          1 Reply Last reply Reply Quote 1
          • donhoD
            donho
            last edited by

            FYI:
            This feature will be in the next release (v7.9.6).

            5726c59e-2b26-4f74-a358-f242c2aa9092-image.png

            1 Reply Last reply Reply Quote 4
            • Neko NekokovicN Neko Nekokovic referenced this topic on
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors