• openSession from dblclick

    7
    0 Votes
    7 Posts
    520 Views
    Alan KilbornA

    @MysticJay

    I’m not really following your meanings.

    but also forget al pending changes to the files is that session

    What does that mean?
    If you are invoking Notepad++ (from a no-Notepad++ -running situation), what pending changes would there be to “forget”?

    commandline parameters do not seem to be passed correctly to NPP when launching from Windows dblclick

    Well, my first comment on this would be “Notepad++ cannot control how it is invoked, so I’d think if command line arguments are not passed correctly, you should think about blaming whatever is running Notepad++, not Notepad++ itself”.

    However, there should be an easy test for this, as in your earlier post you said:

    The commandline is fine in CMD

    How could I debug what is passed to NPP?

    Do this:

    Close Notepad++ and then invoke the CMD command line and then go to the ? menu in Notepad++ and choose Debug Info. This will show the Command line: that Notepad++ was run with. Copy this data somewhere else.

    Then close Notepad++ and repeat the Debug Info check after running with your “double-click” setup. Compare the results with the CMD line approach’s results.

    But as I learned this is no BUG or feature request forum so there will be no one to fix this.

    We haven’t even determined what there is to fix yet.

  • 0 Votes
    6 Posts
    1k Views
    guy038G

    Hello, @robin-cruise, and All,

    I suppose that, if the sentence contains a single word, followed with a full stop like Paul., it should not be concerned by the replacement, ins’t it ?

    So, the correct regex S/R is :

    SEARCH (?-s)^(\w+)\b(.+)\b(\w+)\.$

    REPLACE \3\2\1.

    Notes :

    The \b assertions ensure that the group \1 and group 3 contain true words, i.e. the first and last character of group 2 are non-word characters

    In group 2 we just can use a greedy quantifier + ( not +? ) as we’re looking for the last word of current line, anyway !

    As the search regex contains three expressions with the + quantifier, this means that each group is not empty. And, in case of the minimal sentence Paul John., the group 2 is just the space char between the two firstnames !

    Best Regards,

    guy038

  • reorganize numbers/words inside punctuations

    3
    0 Votes
    3 Posts
    187 Views
    Handa FlockaH

    Thank you, it has been fixed using some other form, with:

    hello: +(?:\w+\|){N}\K(\w+)\|(\w+)

    to replace with

    $2|$1
  • Menu -> File -> Save session (is doesn't save the Bookmarks)

    10
    0 Votes
    10 Posts
    441 Views
    mere-humanM

    @Vasile-Caraus Works for me in version 7.9.5.
    Which version do you use?
    By the way, if the file was modified since the session has been saved, then the bookmarks would be off.
    This is expected, because the position of the bookmark is a line number. More lines - wrong position.

  • Notepad ++ version 7.9.5

    4
    0 Votes
    4 Posts
    900 Views
    PeterJonesP

    @Thiago-Sasasinho ,

    The problem is, many of your words appear to be English, but when put next to each other, the phrase or sentence doesn’t immediately make sense.

    If English is not your native language, you might want to try writing in your native language, and plug it into an online translator like translate.google.com or deepl.com and paste the English results in the forum. (Before pasting here, you might want to paste it back into the English->NativeLanguage form, and see if it still makes sense.) If English is your native language, then I’m sorry, but we cannot understand you, and you are going to have to work on making sure there aren’t any typos, and that terms that take a special knowledge set are defined, and that you generate full English sentences, with clear subjects, verbs, and objects.

    On to specifics:

    does anyone use Notepad in the Iq option

    I assume you mean Notepad++, not Notepad, because those are two different applications, and this forum is about Notepad++.

    What is “Iq option” or “Iq option platform”?

    what are the commands used to make scrip

    What is “scrip”, and why are we expected to know what commands make it? Or is that a typo for “script”?

    type command of confluences between indicators

    I have no clue what that is trying to say

    and as if it were a hack, and robot

    again, no clue what this is intending to say.

    If I were to hazard a wild guess, I would say that “Iq option” is some other software platform that has a scripting or configuration or option language. So you can edit the text source code for that language in Notepad++. Even more wild guessing, after writing the script in Notepad++, you want to try to run it through whatever compiler / interpreter / executable comes with “Iq option”. If this is the case, then this Forum has FAQ that explains “How do I use Notepad++ to Compile my Source Code (or Convert My Text)?”.

    I hope that helps.

  • remove letters only in text

    3
    0 Votes
    3 Posts
    7k Views
    Handa FlockaH

    @PeterJones said in remove letters only in text:

    [[:alpha:]]

    @PeterJones It worked
    Thank you! and for the explanation I will try to learn from it

  • Reorganize numbers

    4
    0 Votes
    4 Posts
    224 Views
    Handa FlockaH

    Thank you!! @guy038
    I got it and I got the idea thanks for further explanations

  • Not able to install XML plugin ()

    16
    0 Votes
    16 Posts
    22k Views
    PeterJonesP

    @Arif-Syed ,

    Your version (v7.3.2) is very out-of-date. The reason the sequences above didn’t work for you is because the plugin hierarchy changed in v7.6.3 in 2019 (well, it started changing in v7.6 in late 2018, but 7.6-7.6.2 are not recommended due to instabilities).

    Future readers: only follow @Arif-Syed’s procedure if you have a version v7.5.9 or earlier; it will not work for you if you have v7.6.3 or later.

  • no next line in results?

    5
    0 Votes
    5 Posts
    346 Views
    Alan KilbornA

    @guy038

    In light of Guy’s solution (nice one, too!), when I said earlier:

    you can’t use the Search results window for copying multline match data … it only displays the first line of a multiline match.

    This is still a true statement.

    What Guy’s solution to the problem does is create a second match.
    As this match is (somewhat) independent of the first, it DOES appear in the Search results window and thus can be copied from there, as originally desired.

  • multiple text replacing with different text

    20
    0 Votes
    20 Posts
    6k Views
    Handa FlockaH

    @PeterJones After your update it’s a piece of art now!
    thanks again

  • File Assicoacion.

    3
    0 Votes
    3 Posts
    259 Views
    AndreiA

    Thansk you ! I make registry in HKLM\Software\Classes with GPO. Problem solved.

  • Regex: Replace after I between tags

    3
    1 Votes
    3 Posts
    171 Views
    Alan KilbornA

    Plus, it doesn’t work like you say anyway. :-(

    If you use literal ( or ) in your replace expression, you must escape them as \(, \) or they do not appear!

  • Delete everything except a word

    6
    0 Votes
    6 Posts
    2k Views
    Alan KilbornA

    @P4R0D-Y

    I gave you the answer to exactly what you asked here.

    Now, if someone else interpreted your question differently and that interpretation lined up with yours, and worked for you, that’s great I guess.

    Try to ask better questions, I guess is the moral of the story.

  • Unable to Install plugins from plugin Manager in Notepad 7.9.5

    9
    0 Votes
    9 Posts
    4k Views
    PeterJonesP

    @Raja-Siva said in Unable to Install plugins from plugin Manager in Notepad 7.9.5:

    How do I correct Plugin Manager.

    As I said already, it’s not the Plugin Manager, which hasn’t worked with Notepad++ for years. It’s the Plugins Admin, as your screenshot clearly showed.

    And there’s nothing to correct: as far as I am aware, the Plugins Admin works just fine. Either you need to set your proxy, or you need to fix your permissions, or if you’re in some very strange networking situation you will have to manually download the plugins and install them yourself. But Plugins Admin works as designed, and nothing you have shown indicates there is anything wrong with it. If you can show that Plugins Admin is doing something wrong, then we’ll work with you to ask the developers to correct the problem; but you haven’t shown that yet.

  • UDL 2.1: When an Operator is also a Delimeter

    3
    0 Votes
    3 Posts
    367 Views
    Erin D. SmaleE

    @PeterJones - Thanks very much for the tip. I’ll give this a shot over the weekend and post results in case others have the same problem.

    Cheers,
    -Erin

  • Select data between tabs

    6
    0 Votes
    6 Posts
    739 Views
    PeterJonesP

    @Vasile-Caraus ,

    The OP’s data has a TAB character (\t or \x09) followed by some data followed by a TAB character, and wants to select the data that comes between two
    490bb2c0-2678-4ac6-831e-4bcc3a6a1dd7-image.png

  • Way to disallow copying text?

    7
    1 Votes
    7 Posts
    1k Views
    Alan KilbornA

    So I “solved” this issue.
    Disclaimer: I didn’t do it all by myself; I enlisted the aid of a former contributor on this forum to get it done with a PythonScript – and he said that even he consulted some others about certain aspects…so it is not a trivial endeavor!

    And solving this problem is not an absolute. It only prevents the novice user from copying from a Notepad++ window – it can totally be circumvented if a user renames a file to have a file extension that isn’t enforced, or one that knows how to disable the script, or one that does a Find All in Current Document search and then copies results from “THAT” window, etc., etc., etc… That’s why I said “solved” – with the quotes.

    Ok, so let’s go with some details before presenting the script…

    The general approach is to “hook” the Windows message loops for the Notepad++ window, and the two editor windows used for Notepad++'s two views. “Hooking” allows one to pre-process messages, and when you do this, you can “filter out” messages selectively – and not allow Notepad++ to process them. This is perfect for when you want to disallow a copy – you just intercept messages relating to copying of text and don’t allow Notepad++ to get them and do their default duty.

    However, we can’t get at certain things by hooking the message loops. Meaning, we can’t get at a WM_COPY or an SCI_COPY message directly. This would be ideal: Any time we receive something that looks like a user request to copy data, it should look like a WM_COPY message which we could throw away – and nothing will be copied. Reality, however, is a bit more complicated. Here are the general rules:

    A Notepad++ command that has no keycombo assigned in Shortcut Mapper is easily intercepted; one merely has to “hook” into WM_COMMAND messages and check to see if wParam has a value corresponding to the command of interest. The command values are found by looking at the Notepad++ source code file called menuCmdID.h, see HERE.

    A Notepad++ command that has a keycombo assigned to it in Shortcut Mapper – and one that is NOT a “Scintilla command” – gets translated into something else BEFORE the “hook” function can obtain the keycombo. These commands get translated into a WM_COMMAND message with a wParam parameter (as described above for an command with no keycombo assigned). But it does mean that you can’t decide, for example, “I’m going to intercept anytime the user presses F5!” because it just won’t work; your “hook” function won’t see the WM_KEYDOWN messages for F5 (by default, this is the “Run” command on N++'s Run menu).

    A keycombo that has a “Scintilla command” function tied to it can be directly intercepted as a WM_KEYDOWN message. While you can intercept at the keycombo level, you can’t – for key-assigned “Scintilla commands” – intercept at the functional (or command) level. As an example, you can intercept “Ctrl+c” but you can’t intercept the “copy” functionality itself – thus if your intent is to intercept “copy” and user assigns it to a non-standard keycombo, you can’t get at it that way, you have to go directly after the specific keycombo. And how would you know what that non-standard assignment is? – you wouldn’t.

    So how do we apply the “rules” above to what I originally wanted to do, specifically, prevent a user from copying data out of Notepad++?

    Well, we need to:

    prevent menu commands (which possibly have keycombos assigned to them) that have to do with copying (or cutting) data from running – examples include Edit menu’s Copy and Cut commands, the right-click context menu’s Copy and Cut commands, the Edit menu’s Paste Special commands for Copy Binary Content and Cut Binary Content

    prevent Scintilla cut/copy-related keycombos from executing their functions – examples include Ctrl+c, Ctrl+x, Ctrl+Ins, Shift+Delete

    we also need to decide what file types (extensions) the copy functionality should be disabled for

    The following script does all that. I call the script PreventCopyFromCertainFileTypes.py and here’s its listing:

    # -*- coding: utf-8 -*- from __future__ import print_function from Npp import editor, notepad import ctypes from ctypes.wintypes import HWND, INT, UINT, WPARAM, LPARAM, BOOL import platform import os user32 = ctypes.WinDLL('user32', use_last_error=True) LRESULT = LPARAM WndProcType = ctypes.WINFUNCTYPE(LRESULT, HWND, UINT, WPARAM, LPARAM) user32.CallWindowProcW.restype = LRESULT user32.CallWindowProcW.argtypes = [WndProcType, HWND, UINT, WPARAM, LPARAM] if platform.architecture()[0] == '32bit': user32.SetWindowLongW.restype = WndProcType user32.SetWindowLongW.argtypes = [HWND, INT, WndProcType] SetWindowLong = user32.SetWindowLongW else: user32.SetWindowLongPtrW.restype = WndProcType user32.SetWindowLongPtrW.argtypes = [HWND, INT, WndProcType] SetWindowLong = user32.SetWindowLongPtrW GWL_WNDPROC = -4 WM_KEYDOWN = 0x100; WM_COMMAND = 0x111; WM_CHAR = 0x102 VK_SHIFT = 0x10; VK_CONTROL = 0x11; VK_MENU = VK_ALT = 0x12 VK_C = 67; VK_X = 88; VK_INSERT = 45; VK_DELETE = 46 CTRL_C_CHAR = 3; CTRL_X_CHAR = 24 IDM_EDIT_COPY = 42002; IDM_EDIT_CUT = 42001; IDM_EDIT_COPY_BINARY = 42048; IDM_EDIT_CUT_BINARY = 42049 class PCFCFT(object): def __init__(self, debug=False): self.debug = debug self.registered = False self.npp_hwnd = user32.FindWindowW(u'Notepad++', None) assert self.npp_hwnd self.enum_scintilla(self.npp_hwnd) # get hwnds for editor1 and editor2 assert all([ self.scintilla1_hwnd, self.scintilla2_hwnd ]) self.STOP_PROCESSING_MSG = False # consume the msg; don't let npp/scintilla process it when we return self.CONTINUE_PROCESSING_MSG = True # let npp/scintilla process the message when we return self.register() def enum_scintilla(self, npp_hwnd): self.scintilla1_hwnd = self.scintilla2_hwnd = None EnumWindowsProc = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM) def foreach_window(hwnd, lParam): curr_class = ctypes.create_unicode_buffer(256) user32.GetClassNameW(hwnd, curr_class, 256) if curr_class.value in [u'Scintilla']: if user32.GetParent(hwnd) == npp_hwnd: if self.scintilla1_hwnd is None: self.scintilla1_hwnd = hwnd elif self.scintilla2_hwnd is None: self.scintilla2_hwnd = hwnd return False # stop enumeration return True # continue enumeration user32.EnumChildWindows(npp_hwnd, EnumWindowsProc(foreach_window), 0) def register(self): if not self.registered: self.new_npp_wnd_proc = WndProcType(self.new_npp_hook_proc) self.old_npp_wnd_proc = SetWindowLong(self.npp_hwnd, GWL_WNDPROC, self.new_npp_wnd_proc) self.new_editor1_wnd_proc = WndProcType(self.new_editor1_hook_proc) self.old_editor1_wnd_proc = SetWindowLong(self.scintilla1_hwnd, GWL_WNDPROC, self.new_editor1_wnd_proc) self.new_editor2_wnd_proc = WndProcType(self.new_editor2_hook_proc) self.old_editor2_wnd_proc = SetWindowLong(self.scintilla2_hwnd, GWL_WNDPROC, self.new_editor2_wnd_proc) self.registered = True def unregister(self): if self.registered: _ = SetWindowLong(self.npp_hwnd, GWL_WNDPROC, self.old_npp_wnd_proc) _ = SetWindowLong(self.scintilla1_hwnd, GWL_WNDPROC, self.old_editor1_wnd_proc) _ = SetWindowLong(self.scintilla2_hwnd, GWL_WNDPROC, self.old_editor2_wnd_proc) self.registered = False def modifier_key_pressed(self, the_key): # the_key can be VK_SHIFT, VK_CONTROL, VK_ALT return (user32.GetAsyncKeyState(the_key) & 0x8000) == 0x8000 def new_npp_hook_proc(self, hWnd, msg, wParam, lParam): retval = self.common_msg_processing_function(hWnd, msg, wParam, lParam) if retval: retval = user32.CallWindowProcW(self.old_npp_wnd_proc, hWnd, msg, wParam, lParam) return retval def new_editor1_hook_proc(self, hWnd, msg, wParam, lParam): retval = self.common_msg_processing_function(hWnd, msg, wParam, lParam) if retval: retval = user32.CallWindowProcW(self.old_editor1_wnd_proc, hWnd, msg, wParam, lParam) return retval def new_editor2_hook_proc(self, hWnd, msg, wParam, lParam): retval = self.common_msg_processing_function(hWnd, msg, wParam, lParam) if retval: retval = user32.CallWindowProcW(self.old_editor2_wnd_proc, hWnd, msg, wParam, lParam) return retval def common_msg_processing_function(self, hWnd, msg, wParam, lParam): if msg in [ WM_KEYDOWN, WM_COMMAND, WM_CHAR ]: # maybe the active file is NOT one that we are looking for... filename = notepad.getCurrentFilename().rsplit(os.sep, 1)[-1] if '.' in filename: (file, ext) = filename.rsplit('.', 1) if ext.lower() not in [ 'txt', 'py' ]: if self.debug: print('received a msg we handle, but not in a file with an excluded extension') return self.CONTINUE_PROCESSING_MSG if self.debug: origin = 'npp' if hWnd == self.npp_hwnd else 'editor1' if hWnd == self.scintilla1_hwnd else 'editor2' if msg == WM_KEYDOWN: if wParam not in [ VK_SHIFT, VK_CONTROL, VK_ALT ]: # these keys come thru when they are pressed by themselves (we don't care about that case) shift = self.modifier_key_pressed(VK_SHIFT) control = self.modifier_key_pressed(VK_CONTROL) alt = self.modifier_key_pressed(VK_ALT) if self.debug: print('origin:{o}, msg:WM_KEYDOWN, wParam:{w}, lParam:{L}, Shift:{s}, Ctrl:{c}, Alt:{a}'.format( o=origin, w=wParam, L=lParam, s=shift, c=control, a=alt)) if wParam == VK_C and control and not shift and not alt: if self.debug: print('Ctrl+c keydown consumed!') return self.STOP_PROCESSING_MSG if wParam == VK_X and control and not shift and not alt: if self.debug: print('Ctrl+x keydown consumed!') return self.STOP_PROCESSING_MSG if wParam == VK_INSERT and control and not shift and not alt: if self.debug: print('Ctrl+Insert keydown consumed!') return self.STOP_PROCESSING_MSG if wParam == VK_DELETE and not control and shift and not alt: if self.debug: print('Shift+Delete keydown consumed!') return self.STOP_PROCESSING_MSG elif msg == WM_COMMAND: if wParam not in [ VK_SHIFT, VK_CONTROL, VK_ALT ]: # for some reason these happen with WM_COMMAND...filter them out if self.debug: print('origin:{o}, msg:WM_COMMAND, wParam:{w}, lParam:{L}'.format(o=origin, w=wParam, L=lParam)) if wParam in [ IDM_EDIT_COPY, IDM_EDIT_CUT, IDM_EDIT_COPY_BINARY, IDM_EDIT_CUT_BINARY ]: if self.debug: print('copy/cut related menu item consumed!') return self.STOP_PROCESSING_MSG elif msg == WM_CHAR: if self.debug: print('origin:{o}, msg:WM_CHAR, wParam:{w}, lParam:{L}'.format(o=origin, w=wParam, L=lParam)) if wParam == CTRL_C_CHAR: if self.debug: print('Ctrl+c char consumed!') return self.STOP_PROCESSING_MSG if wParam == CTRL_X_CHAR: if self.debug: print('Ctrl+x char consumed!') return self.STOP_PROCESSING_MSG return self.CONTINUE_PROCESSING_MSG if __name__ == '__main__': try: pcfcft except NameError: debug = True if 1 else False pcfcft = PCFCFT(debug) if pcfcft.debug: print('installed') else: if pcfcft.registered: pcfcft.unregister() if pcfcft.debug: print('deactivated') else: pcfcft.register() if pcfcft.debug: print('reactivated')

    Some supplmental info:

    An interesting thing about “hook” functions is that you can use them to either avoid original functionality (like our example here shows) or you can “add on” functionality. To “add on” you simply call the original window function in addition to doing your special functionality. So maybe some add on functionality is just to print to the console “got message” or something like that. You do that print in your hook function, and then call the original function – blammo, add-on functionality! If you’re interested in seeing how that is accomplished in the script, look for usage of CONTINUE_PROCESSING_MSG and STOP_PROCESSING_MSG. This is also what lets the script be selective about which filetypes copies/cuts are disallowed from (the demo script chooses .txt and .py files).

    In the case of the non-keycombo commands, looking up the IDs for the commands in menuCmdID.h in Notepad++ source code yields this information (C++ code):

    #define IDM 40000 #define IDM_EDIT (IDM + 2000) #define IDM_EDIT_CUT (IDM_EDIT + 1) #define IDM_EDIT_COPY (IDM_EDIT + 2) #define IDM_EDIT_COPY_BINARY (IDM_EDIT + 48) #define IDM_EDIT_CUT_BINARY (IDM_EDIT + 49)

    leading to these "equivalent"s in the PythonScript code:

    IDM_EDIT_COPY = 42002; IDM_EDIT_CUT = 42001; IDM_EDIT_COPY_BINARY = 42048; IDM_EDIT_CUT_BINARY = 42049

    Another interesting thing with the script’s execution is that if you don’t allow Notepad++ to process the Ctrl+c keycombo as a WM_KEYDOWN event, you’ll get an “ETX” (hex code = 0x03) character in your document at the caret position. This occurs because, with Notepad++ ignoring the Ctrl+c as a command, it thinks that you want to embed a control character with value “3” into the doc (it gets a WM_CHAR message to that effect, which it would normally filter out on its own). So… in the case of preventing copying data, we have to remove any Ctrl+c or Ctrl+x characters that might get inserted; we do this by processing the WM_CHAR message and filtering those as well.

  • Simple is as Simple Does

    12
    0 Votes
    12 Posts
    638 Views
    Doc Trins O'GraceD

    @Alan-Kilborn Thank you!

  • 0 Votes
    2 Posts
    486 Views
    PeterJonesP

    @thompsop ,

    For Notepad++ versions through v7.9.5, the Style Configurator > Global Styles > Selected Text Color defines the background color for selection, but ignores the foreground color of that setting. So you could set the background color to something that contrasts with your active foreground color.

    However, the developers have heard the cries of pain over that setting, and for the v8.0 and newer, the Style Configurator will honor both the background and the foreground if you put the new 0-byte enableSelectFgColor.xml in the same folder as the notepad++.exe executable. Right now, v8 is in Release Candidate mode, and you can download it from the announcement topic, but it will likely be fully released soon (and sent to auto-update shortly after that). If you need that feature right away, feel free to download the v8.0-RC version. Otherwise, you can wait for the full release or for it to be pushed to the Notepad++ auto-updater.

  • "Dot Notation" Folding

    2
    0 Votes
    2 Posts
    424 Views
    PeterJonesP

    @Daniel-McMahon said in "Dot Notation" Folding:

    How can I get the code to fold (using a custom language) such that collapsing “O” would hide everything below it

    If O were your only start keyword, then you could define your UserDefinedLanguage with Folding-in-Code-2 with START = O and something else (maybe ((A B C D E F G H I J K L M N O P Q R S T U V W X Y Z))) as the close.

    Actually, using the ((A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)) list shown for both open and close comes close, but not quite, because it’s seeing each one as a new nested open, rather than a close for the previous one.

    The User Defined Language feature is great for “simple” languages, where the folding is just pairs of OPEN/CLOSE keywords or symbols (with optional middle for “if-else-endif”-like situations)… but it’s not hard to find yourself straying beyond what it can handle.

    In theory, you could look at the FAQ section of this Forum, and see the FAQ Desk entry on creating official feature requests … but the UDL system hasn’t had much attention (really, not any attention) for a few years, and nothing is likely to come about from such a feature request, unfortunately.

    The first options at this point are creating your own lexer plugin, which would be able to implement the syntax highlighting and code folding according to whatever rules you want to program.

    The second option is that the scripting plugins like PythonScript have access to the underlying Scintilla folding commands – so you might be able to code up a script that will enable the folding you want; I don’t know if there are examples in the forum, but you could search for “pythonscript fold” or some such and see what you find. (My guess in PythonScript is that editor.setFoldLevel(line, level) which implements scintilla SCI_SETFOLDLEVEL message is where you would start, which would define how many levels deep, and which line is the start of each fold block).