• Read This First

    Pinned Locked
    1
    5 Votes
    1 Posts
    5k Views
    No one has replied
  • New API to fix eventual regression regarding SCN_MODIFIED for some plugins

    Pinned
    32
    2 Votes
    32 Posts
    22k Views
    ThosRTannerT

    Just a quick question - when will the plugintemplate repo be updated to include the new message?

    Thanks

  • Looking for Scintilla examples for a Notepad++ plugin

    3
    0 Votes
    3 Posts
    75 Views
    CoisesC

    @John-HUANG-0 said in Looking for Scintilla examples for a Notepad++ plugin:

    I want to write a Notepad++ plugin that can change the font color and background color of certain specific text.

    Depending on your needs, the first thing you should consider is whether you really need a plugin, or whether a User Defined Language could do what you want.

    However, using a method like this:

    SendMessage(hSci, SCI_STYLESETFORE, SCE_USER1, RGB(255, 0, 0));

    is not very efficient, especially when dealing with very large files.

    When making many calls to Scintilla, it is best to use Direct Access. Even better, if you are writing in C++, is to use the ScintillaCall interface. Annoyingly, that interface does not seem to be documented anywhere. You can read the relevant section in the help for my Visual Studio template and, if it makes sense, either use that template or look at the code (start here) to see how it’s done.

    I asked ChatGPT about this, and it suggested that using Lexilla could be much more efficient. I found the Lexilla source code here:
    https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/scintilla

    I have never attempted to write a lexer, so I can’t give advice there, except to say that unless you are trying to implement full syntax highlighting for a computer language that doesn’t already have a lexer, it’s probably not the way to go. The efficiency problem can be solved by using the direct access interface or ScintillaCall.

  • Unicode Normalize: A simple plugin

    1
    3 Votes
    1 Posts
    69 Views
    No one has replied
  • 4 Votes
    68 Posts
    24k Views
    PeterJonesP

    Notepad++ v8.8.6 Plugins Admin links to CollectionInterface v1.2.0

    comes with Dark Mode support and bulk-mode download (actually from v1.1, which I mentioned over here) v1.2.0 has better handling of -settingsDir and Cloud Directory. (It was implementing the -settingsDir handling which lead to the new v8.8.6 plugin message NPPM_GETNPPSETTINGSDIRPATH , which my plugin uses when Notepad++ version is new enough (though it does have a workaround that works even if you manually install it on an older N++).)

    CollectionInterface v1.3.0 is now available for manual installation:

    When downloading functionList defitions(s) (either on the FunctionList tab, or in bulk along with the UDL), the plugin will ask if you want to update the overrideMap.xml, which allows the functionList to be fully installed through the automatic process, so that functionList will immediately start working, without requiring you to manually update overrideMap.xml to link to the definition. I wasn’t fast enough with this feature to get it in the v8.8.6 Plugins Admin, so it’s manual installation only, for now.
  • Columns++ version 1.3: All Unicode, all the time

    2
    3 Votes
    2 Posts
    135 Views
    guy038G

    Hello, @coises and All,

    I’ve just tried your last ColumnsPlusPlus v1.3 release and indeed, the search is now considered as a true Unicode search, whatever the individual encoding of each file !

    Let’s consider this simple UTF-8 text :

    This ‟ is a † very • small ‰ text ‱ for › test 201F 2020 2022 2030 2031 203A in Unicode UTF-8 enoding

    And this ANSI text :

    This ? is a † very • small ‰ text ? for › test ? 0086 0095 0089 ? 009B in Windows-1252 encoding

    IMPORTANT Don’t forget, when this second text is opened in N++, to run the Encoding > Convert to ANSI option, first !

    Now, we can create the following table, which recapitulates the Non-ASCII characters used in my examples :

    •--------•-----------------•-----------------• | | Windows-1252 | Unicode | | •--------•--------•--------•--------• | Char | Dec | Hex | Dec | Hex | •--------•--------•--------•--------•--------• | ‟ | ? | ? | 8223 | 201F | | | | | | | | † | 0134 | 0086 | 8224 | 2020 | | | | | | | | • | 0149 | 0095 | 8226 | 2022 | | | | | | | | ‰ | 0137 | 0089 | 8240 | 2030 | | | | | | | | ‱ | ? | ? | 8241 | 2031 | | | | | | | | › | 0155 | 009B | 8250 | 203A | •--------•--------•--------•--------•--------•

    In Notepad++ :

    Within an ANSI file, the regexes [†-‰] or [\x86-\x89] would only find the characters and but not the whose Win-1252 code ( \x95 ) is after \x89

    Within an UTF8 file, the regexes [†-‰] or [\x{2020}-\x{2030}] would find the characters and and also the whose Unicode code-point is between 2020 and 2030

    In Columns++ :

    Within an ANSI file, the regexes [†-‰] or [\x{2020}-\x{2030}] would find the characters and and also the whose Unicode code-point is between 2020 and 2030

    Within an UTF8 file, the regexes [†-‰] or [\x{2020}-\x{2030}] would find the characters and and also the whose Unicode code-point is between 2020 and 2030

    Note that using the range [†-›] within an ANSI file, a N++ search of the char would have been successful as its code-point ( 2022 ) lies within the 2020 and 203A range !

    Now, @coises, I cannot test easily the CJK behaviour of your new search engine as it’s obvious that I do not a default CJK code-page, needed for such a study ! However, I do not see why your new search behavior couln’t be applied to any kind of Unicode chars ;-)

    Best Regards,

    guy038

  • Add additional command line parameter for plugins

    2
    1 Votes
    2 Posts
    2k Views
    Vitalii DovganV

    There is one more thing that requires an explicit mentioning in the documentation:

    When exactly NPPN_CMDLINEPLUGINMSG is sent to plugins? In particular, is it sent before or after NPPN_READY? (Currently it is sent before NPPN_READY. But will it be so in the future?)
  • XBrackets Lite v2.0 has been released!

    2
    3 Votes
    2 Posts
    2k Views
    Vitalii DovganV

    Guys, please immediately update to the version 2.0.1:
    https://github.com/d0vgan/npp-XBracketsLite/releases/tag/XBrackets_v201

    XBrackets Lite v2.0.1

    Glory to Ukraine! Glory to the heroes! hot-fix for NPPM_MSGTOPLUGIN

    The version 2.0 broke NPPM_MSGTOPLUGIN for all the other plugins because I was mistakenly handling all the NPPM_MSGTOPLUGIN messages for all the plugins, not just for XBrackets. My bad.
    As this was a critical problem, please update immediately.

  • 3 Votes
    1 Posts
    261 Views
    No one has replied
  • SCI_GETCODEPAGE is NOT always either 0 or 65001

    3
    4 Votes
    3 Posts
    3k Views
    CoisesC

    I wrote in SCI_GETCODEPAGE is NOT always either 0 or 65001:

    When I did a test by changing my system default character set to Japanese, I started a new file, set it to ANSI, and pasted in some Japanese text. SCI_GETCODEPAGE was 932. I saved it that way. When I opened it again, the encoding was set to Shift-JIS — not ANSI — and SCI_GETCODEPAGE was 65001.

    For future reference:

    This only happens if Settings | Preferences | MISC | Autodetect character encoding is checked. When it is not checked, the file opens, as expected, as ANSI (SCI_GETCODEPAGE returns 932).

  • Handling Ctrl+C in a c++ plugin dialog

    7
    0 Votes
    7 Posts
    4k Views
    CoisesC

    @PeterJones said in Handling Ctrl+C in a c++ plugin dialog:

    I interpreted as wanting to have a keyboard shortcut specific to an action inside the dialog.
    […]
    It would very much surprise me if it weren’t possible for a plugin to do that (though I cannot think of any off the top of my head that do so). But whether “subclassing” or some other strategy is the right way to implement the shortcut capture is beyond me.

    (Following based on theory/understanding. I have not actually tried to do this.)

    Subclassing the NPP window would be horrific way to go about this (if it would even work at all). Making shortcuts work specifically in a plugin window is a bit of an awkward problem, because (as far as I can tell) there is only one accelerator table for an entire running program — and Notepad++ already “owns” that table.

    In a modal dialog or a non-modal window that was registered with NPPM_MODELESSDIALOG it wouldn’t work at all, because messages for those don’t go through TranslateAccelerator. The message would get sent to the window/dialog. This is actually the right way to go, but subclassing the main NPP window would be irrelevant, because the message would never get to that window; it would be dispatched to the plugin window or one of its controls.

    For a non-modal window without NPPM_MODELESSDIALOG, the shortcut key would still send whatever menu command was assigned to it. In that case, a subclass procedure could check whether the keyboard focus is in a window belonging to the plugin. If it is, process it; if it isn’t, pass it through normally. But note that you’d be catching the command, not the shortcut. Your command would always take over from the NPP command, regardless of whether it was by menu, by tool button, or by whatever shortcut key the user assigned to the NPP function.

    For modeless dialogs that don’t register, NPP now works around this for cut, copy and paste by sending WM_CUT, WM_COPY and WM_PASTE to the window/control with keyboard focus when one of those commands is invoked and focus is not in an NPP-managed window or control. Note that if you change the shortcut for one of those commands, the dialog will respond to the new shortcut. (It will respond to the “normal” shortcut as well if and only if that shortcut isn’t assigned to a Notepad++ command. Scintilla assignments don’t count; that’s why the problem didn’t show up until the shortcuts were moved from Scintilla to Notepad++.)

    So to get it right, you have to register the window if it is modeless, and you have to pick up the key combination in your plugin code. How to pick it up is a bit of a pain in the butt, because usually the main window (typically a dialog box) won’t have focus, so the keystrokes will go to whatever control does have focus — unless the dialog manager captures it and applies its own logic (such as it does for the tab key and for Alt+ accelerators).

    I still haven’t found a clear and complete description of what the dialog manager does when the message loop calls IsDialogMessage. Part of it is bound up with WM_GETDLGCODE, which is sent to controls — not the dialog procedure — which further complicates things. Subclassing every control which could have focus when you want your key combination to work would probably be necessary. I suspect some key combinations cannot be captured, but I don’t know that for a fact.

    It’s messy. Finding another way — like adding a button for your action and then underlining a letter so that Alt+letter will activate it — is likely to be a lot easier and less fragile. (If the action is control-based, rather than independent of which control in your plugin has focus, then of course the way you did it is correct.)

  • 0 Votes
    6 Posts
    4k Views
    Lycan ThropeL

    @PeterJones ,
    Good point. Luckily, it’s still one of a handful of functionList files…at least until you figure out how to mass produce those. :-)

  • JSON String Escape / Unescape

    11
    0 Votes
    11 Posts
    20k Views
    Mark OlsonM

    @Artem-Repko
    @PeterJones correctly pointed to the D&ump selected text as JSON string(s) and Dump JSON string(s) as ra&w text commands in JsonTools. I just wanted to add this comment because I just added new documentation for both of those commands.

  • [New Plugin] MultiReplace

    76
    3 Votes
    76 Posts
    42k Views
    Thomas KnoefelT

    A new version of MultiReplace (v4.5.0.30) is ready and will be available with the next Notepad++ release. It can be dowloaded here.

    The focus of this release is on expanding the search functionality and giving you more flexibility.

    Implemented updates:

    Find All: This is a new feature that lets you find all matches and see them in the search results window. It’s not limited to the current file – you can also search across all open documents or in entire folders.

    GroupResults: To go with “Find All,” this new INI option lets you choose how your results are displayed. You can see them all mixed together in document order (the default), or neatly grouped by each list entry, which is great for getting a clear overview of complex searches.

    lcmd: A new command for the “Use Variables” feature. It allows you to load your own custom helper functions from external files, which opens up a lot of possibilities for complex and reusable logic.

    AllFromCursor: Another new INI setting that gives you more control. You can now choose to start “Find All”, “Replace All” and “Mark” operations from your current cursor position instead of from the top of the file.

    Here is a visual take on the changes:
    MultiReplace45.png

  • Display markdown outline view through Functionlist

    16
    2 Votes
    16 Posts
    9k Views
    A

    New try: Now it works, like you described it. Seems I set it up wrong!

  • .Net versions

    6
    0 Votes
    6 Posts
    5k Views
    Guido ThelenG

    @General-Coder
    I had the same issue when I installed a new Visual Studio 2022 and forgot to install the packages for C++ development.
    Regards
    Guido

  • How dynamic-ID menu commands are executed and relation to macros

    7
    0 Votes
    7 Posts
    5k Views
    ?

    @PeterJones said in How dynamic-ID menu commands are executed and relation to macros:

    There is no “universally constant value” necessary for Notepad++ to store for it to be working the way it is.

    And creating a new identifier rather than using menuCmdID is not likely to happen (nor should it, IMO)

    That scheme (even if hypothetical) seems to work very well as long as it’s not a problem that the IDs change when you remove menu entries.
    But we do know that it is in fact a problem for recording macros.
    Here are 2 approaches I can think of (besides the “shut up and hack the XML files” one :) ) :

    A. Constant IDs version

    Still have a linked list to represent the structure of the (dynamic) menus, but whose contents are just the IDs of those commands. Can still be in same range as current IDs, if needed.
    Add a dictionary (hashmap) to map from those IDs to the respective actual commands, or in case of macros - list of actions , as you describe in your post above.
    Npp getting command 20001 for ex, involves looking up in the dictionary - most often a constant time operation.

    Deleting an menu entry involves deleting the respective entry in the linked list and also the ID-value pair in the dictionary.

    In addition to that, to ensure that generated IDs stay within a given range: Several schemes are possible, one of the simplest can be just generate a key in range and test that it is not present in the dictionary.

    B. Dynamic IDs, but synchronized in every saved macro

    Basically, keep the scheme as it is at present, but add a way to update, for each macro, every stored referenced menu command ID in an Action record:
    at every removal of a menu entry, compute how the rest of entries’ IDs would change (if located After those removed, the ID would decrease by one) and traverse the linked list of all macros and update that ID in every action that refers to a menu-command in the range of the dynamic-IDs types (Run, Plugin and Macro commands).
    Thus on Npp closing, the macros written in XML will also contain updated IDs.

    But don’t pretend the niche [for a more powerful macro system ] doesn’t already have a plethora of entries.

    I think there is plenty of room for a macro system to grow in power and STILL be much easier to do a lot of common tasks, than the same tasks in any scripting language.
    Because with macros you don’t have to learn and remember syntax.

  • [New Plugin] NppOpenAI

    47
    8 Votes
    47 Posts
    55k Views
    Richárd StockingerR

    @erik-neyman
    Hi,

    first of all, please hide/change your secret_key setting (or remove the image), as this is a public forum and others may misuse it. :(

    Unfortunately, there may be bugs in the latest NppOpenAI v0.5 update (updates/fixes can be found on the NppOpenAI development project page), so I suggest that instead of setting a route_chat_completions, you should specify the URL “all at once”, e.g.

    api_url=https://api.openai.com/v1/chat/completions

    Edit: You can leave the route_chat_completions setting unchanged.

    I apologise for the error!

  • XBrackets 2.0 is coming!

    9
    4 Votes
    9 Posts
    5k Views
    Vitalii DovganV

    @Ekopalypse
    Wow, thank you!

  • Plugin request: insert relative path

    10
    0 Votes
    10 Posts
    6k Views
    ?

    Has anyone here found how to open those relative path links from within the Notepad++ file, in their default app ?

    That would make the solutions listed here even more useful IMO; one could have for instance have the documentation of a project in simple text files.

    Opening the links at either double-click (better, & underlined) or some other action.
    I’ve requested the feature on github https://github.com/notepad-plus-plus/notepad-plus-plus/issues/16942