Editor right-click, outside current text selection, lose this selection
-
Hey ! the forum changed the line 313 of my uploaded code
line 313 was uploaded as :
(I must replace \ by BKL to have it displayed)
s_pattern_sqr = “BKL[BKL]”
but is displayed without the \ as :
s_pattern_sqr = “[]”which breaks the ‘CTRL + SHIFT + double-left-click’ feature : select brackets content : () [] {}
having compared the whole uploaded code with my original code there should no other error
(I used a simple file compare utility to do that : ExamDiff)So there is a bug in the text parser of the forum :
the preview is ok but the final post has lost the backslashes -
@frying-pan
Wow, that’s quite a script. Maybe post to GitHub or a Gist and then link from here to that post?Cheers.
-
This post is deleted! -
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
-
@frying-pan
Because of file name changes, above links are not valid any more,
see below for new links to each repository. -
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 bugUpdate 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.pyPerso_CrLfDisplay_Callback_v1_0.py
file provided in the GitHub repository :
https://github.com/frying-pan/NotepadPP-PythonScript-CrLf-Graphic-Tweak -
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 ScintillaRestartNPP : 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 updatedFP_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 scriptHere is the root of the Github repositories :
https://github.com/frying-pan?tab=repositoriesand 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 -
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…
-
“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 commandsPossible 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… -
I noticed that the feature that this thread started with is being implemented natively in Notepad++. See HERE.
-
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.