Community
    • Login

    Editor right-click, outside current text selection, lose this selection

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    35 Posts 6 Posters 10.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.
    • Michael VincentM
      Michael Vincent @frying-pan
      last edited by

      @frying-pan
      Wow, that’s quite a script. Maybe post to GitHub or a Gist and then link from here to that post?

      Cheers.

      frying-panF 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @frying-pan
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • frying-panF
          frying-pan @Michael Vincent
          last edited by

          @Michael-Vincent

          Uploaded on GitHub the last posted script in this thread, as version v1 (without the backslash error)

          [https://github.com/frying-pan/NotepadPP-PythonScript-Mouse-Gesture/blob/master/Perso_ScintWndProc_Hook.v1.py](link url)

          and made a version v2.0 : with some code cleaning and more object_oriented style

          [https://github.com/frying-pan/NotepadPP-PythonScript-Mouse-Gesture/blob/master/Perso_ScintWndProc_Hook.v2.0.py](link url)

          frying-panF 1 Reply Last reply Reply Quote 2
          • frying-panF
            frying-pan @frying-pan
            last edited by

            @frying-pan
            Because of file name changes, above links are not valid any more,
            see below for new links to each repository.

            1 Reply Last reply Reply Quote 0
            • frying-panF
              frying-pan
              last edited by

              An update of :
              Perso_ScintWndProc_Hook_v1_0.py to Perso_ScintWndProc_Hook_v1_1.py and
              Perso_ScintWndProc_Hook_v2_0.py to Perso_ScintWndProc_Hook_v2.1.py for the same small bug

              Update to Perso_ScintWndProc_Hook_v3_0.py with new features :

              • option to select brackets/quotes with content
              • option to auto-copy selection to clipboard and/or console
              • expand selection from a previous selection
                -> now requires the two libraries : Perso__Lib_Edit.py, Perso__Lib_Window.py

              all files provided in the GitHub repository :
              https://github.com/frying-pan/NotepadPP-PythonScript-Mouse-Gesture

              ===

              And another small python script to tweak the CR and LF graphic :
              these changes can be applied at each Notepad++ start by running the script from startup.py

              Screenshot.jpg

              Perso_CrLfDisplay_Callback_v1_0.py

              file provided in the GitHub repository :
              https://github.com/frying-pan/NotepadPP-PythonScript-CrLf-Graphic-Tweak

              1 Reply Last reply Reply Quote 3
              • frying-panF
                frying-pan
                last edited by

                I take advantage of this thread to advertise about two other python scripts that I wrote:

                +++

                Bracket Indicator : highlight the bracket () [] {} where is the selection/caret
                based on BracketHighlighter.py idea, with easier customization for highlight style,
                a different algo for highlighting (using the ‘re’ regexp object, possibly more efficient),
                following the brackets matching rules of Scintilla

                RestartNPP : to restart Notepad++ remembering the current session (opened file),
                can possibly made into a button, and be run with a keyboard shortcut via ‘Shortcut Mapper’
                can be handy when developping a script/plugin

                +++

                Perso_ScintWndProc_Hook was renamed to FP_MouseSelectGest_Hook, and updated
                Perso_CrLfDisplay_Callback was renamed to FP_CrLfDisplay_Callback, and updated

                FP_MouseSelectGest_Hook, FP_BracketIndicator_Callback and FP_CrLfDisplay_Callback
                can be run from startup.py on each NPP start (with pythonscript option : initialisation=ATSTARTUP)

                All four scripts have options at the top of the main script file that can be changed by the user
                Some of these scripts use libraries which are provided in the same Github folder as the main script

                Here is the root of the Github repositories :
                https://github.com/frying-pan?tab=repositories

                and the four repositories for the four scripts :
                https://github.com/frying-pan/NotepadPP-PythonScript-Mouse_Select_Gesture
                https://github.com/frying-pan/NotepadPP-PythonScript-Bracket_Indicator
                https://github.com/frying-pan/NotepadPP-PythonScript-Restart_NotepadPP
                https://github.com/frying-pan/NotepadPP-PythonScript-CrLf_Display

                Alan KilbornA 1 Reply Last reply Reply Quote 1
                • Alan KilbornA
                  Alan Kilborn @frying-pan
                  last edited by

                  This thread got rather out of control.

                  Anyway, I’m back to say that I did change my mind and I like the very first basic functionality this thread introduced: The ability to not lose your selection if you right click somewhere not on that selection.

                  However, I noticed that it isn’t compatible with one of the new features of Notepad++: The ability go right-click the bookmark margin and get a right-click popup menu of bookmarking functions.

                  I like the idea of both features; I wonder if there is some way to get both functionalities. Hmmm…

                  frying-panF 1 Reply Last reply Reply Quote 0
                  • frying-panF
                    frying-pan @Alan Kilborn
                    last edited by

                    @Alan-Kilborn

                    “This thread got rather out of control.”

                    I could create a separate thread to describe and post the links for the 4 scripts I have made available on Github

                    “However, I noticed that it isn’t compatible with one of the new features of Notepad++: The ability go right-click the bookmark margin and get a right-click popup menu of bookmarking functions.”

                    I have NPP 7.8.2 and the right-click on the bookmark margin has been introduced later, so I can not test this for the moment
                    (I guess the right-click context-menu on the bookmark margin does not appear at all…)

                    I could discriminate between right-clicks on the margin or the text by pixel position,
                    I will need the widths in pixels of all left margins :
                    the function “editor.getMarginWidthN(margin_index) → int”, gives that for each margin_index,
                    but I don’t know how many of margin_indexes must be checked (probably 5, from 0 to SC_MAX_MARGIN (4)),
                    the function SCI_GETMARGINS (that gives the number of margins) seems to be missing from the NPP Scintilla commands

                    Possible workarounds :
                    My script does not intercept shift+right-click, so it could be tried on the bookmark margin
                    (in case this context-menu is not sensitive to the shift key, which is often the case for context-menus)

                    Also control+right-click and alt+right-click can be disabled in my script
                    (there is a middle-click alternative for these features)
                    to see if they trigger the bookmark margin context-menu, which seems less likely…

                    Alan KilbornA 1 Reply Last reply Reply Quote 1
                    • Alan KilbornA
                      Alan Kilborn @frying-pan
                      last edited by

                      @frying-pan

                      I noticed that the feature that this thread started with is being implemented natively in Notepad++. See HERE.

                      frying-panF 1 Reply Last reply Reply Quote 1
                      • frying-panF
                        frying-pan @Alan Kilborn
                        last edited by

                        @Alan-Kilborn

                        ok i see
                        [https://github.com/notepad-plus-plus/notepad-plus-plus/pull/8564](link url)
                        ‘Keep selection when right-click outside of selection’ has been added, or will be added to the next NPP version (as an option).

                        So I will remove this specific feature from my
                        NotepadPP-PythonScript-Mouse_Select_Gesture script
                        once I have updated my NPP and tested the native option.

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