Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling drag-and-drop of text in Notepad++

Tags:

notepad++

I have a touch screen, and this makes it inconvenient for me to have drag-and-drop enabled in Notepad++. I never used drag-and-drop anyway.

However, I cannot find how to disable drag-and-drop for text in Notepad++. Is it possible to disable this?

Note that I am talking about text drag-and-drop. The only option I could find in the application's settings was related to the drag-and-drop of the tab bar.

like image 526
exebook Avatar asked Dec 20 '13 09:12

exebook


1 Answers

TL;DR: Build Notepad++ from here

Note: This question was asked here and here. There is also an enhancement request here which is still open..

The enhancement request was closed and here's the reason stated by the developer here:

Except that Scintilla makes it optional, it cannot be supported in Notepad++. I encourage you do the feature request in Scintilla project

If one is building Notepad++ from source, then I suggest the following workarounds.

Scintilla's editor component in Notepad++ is actually responsible for the drag and drop feature (this can be confirmed by using SciTE). So one way to disable this feature is to modify the source code used to build the SciLexer.dll here.

Upon debugging the Notepad++ project in Visual Studio, I found that this function ButtonMoveWithModifiers under Editor.cxx is responsible for the drag and drop feature. Particularly this snippet of code :


    if (inDragDrop == ddInitial) {
        if (DragThreshold(ptMouseLast, pt)) {
            SetMouseCapture(false);
            FineTickerCancel(tickScroll);
            SetDragPosition(movePos);
            CopySelectionRange(&drag);
            StartDrag();
        }
        return;
    }

So, commenting out the code block results to this

/*
if (inDragDrop == ddInitial) {
        if (DragThreshold(ptMouseLast, pt)) {
            SetMouseCapture(false);
            FineTickerCancel(tickScroll);
            SetDragPosition(movePos);
            CopySelectionRange(&drag);
            StartDrag();
        }
        return;
    }
*/

With this one change in the source code, build the new SciLexer.dll. You can keep the previous build of the dll as backup just in case you want to switch back to the Drag and Drop functionality.

However, if you are not building Notepad++ from source and prefer to install via an executable, then note down the current version of your Notepad++ and download the scintilla source for the same.

So if your Notepad++ version is v7.x.x, then the URL which points to the scintilla source would be :

https://github.com/notepad-plus-plus/notepad-plus-plus/tree/v7.x.x/scintilla

To download a single folder or directory, follow this, or just download using this link:

https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/notepad-plus-plus/notepad-plus-plus/tree/v7.x.x/scintilla 

(based on answer here)

Modify the Editor.cxx as mentioned before and build the new dll as per the guide specified here:

https://github.com/notepad-plus-plus/notepad-plus-plus/tree/v7.x.x

Note: Replace v7.x.x with your NPP version

Update: The above method does not work for NPP release versions >= v7.3.3, due to this "Fix CIA Hacking Notepad++" issue being fixed in v7.3.3 and above. This is because the SciLexer.dll is digitally signed by the author of NPP project, so if the dll is tampered with, then Notepad++ will complain saying:

Library verification failed - Authenticode check failed: signature or signing certificate are not recognized.

Source


Here's a forked repository with the changes done for you, just build Notepad++ from here.

(It should sync automatically with the parent repository due to this app however, if it doesn't due to some conflict then I will sync it manually as specified here)

Note: To keep the above forked repository in sync with the parent repository, the Pull Github App was used. Here's the pull.ymlused for configuration of the forked repository:

version: "1"
rules:
  - base: feature
    upstream: master
    mergeMethod: merge
  - base: master
    upstream: notepad-plus-plus:master
    mergeMethod: hardreset

This keeps the master branch of the forked repository up-to-date with the parent repository. It also keeps the feature branch of the forked repository (which contains the changes) updated via the master branch of the forked repository by merging the same.

If the Notepad++ Community ever decides to add or tweak this feature, the pull request generated by this App should lead to a merge conflict.


Note: If you are facing any certificate related issues when running the release config version of Notepad++ from source, refer to this.

like image 141
Saurabh P Bhandari Avatar answered Sep 30 '22 05:09

Saurabh P Bhandari