• Плагин расширенного поиска

    3
    0 Votes
    3 Posts
    2k Views
    guy038G

    Hello, @pavel-san, @terry-r and All,

    As @terry-r said, there are a lot of questions concerning your requests !!

    First, when you speak of text-1 do you mean :

    The word, as in the sentence “This abc text-1 xyz is right, but not abctext-1xyz

    The string as in the sentence “This abctext-1xyz is right, as well as abc text-1 xyz

    Secondly, do you mind about the case of letters in text-1 and/or text-2 ?

    In other words, must the string text-1 have :

    The exact case text-1

    Are the Text-1, TEXT-1, text-1 and tExT-1 syntaxes all OK ?

    Idem for text-2 !

    Now, your first statement :

    you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-1 or text-2 with text-3.

    can be slipt into two different goals :

    (A) you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-1 with text-3

    (B) you need to find text-1 and from text-1 find up or down the occurrence of text-2 and then replace text-2 with text 3

    But, in this case, this could also be expressed as :

    (A) Change text-1 with text-3, if current file contains, at least, one occurrence of text-2

    (B) Change text-2 with text-3, if current file contains, at least, one occurrence of text-1

    Case (A) could be achieved with the regex S/R :

    SEARCH (?s)(?=.*text-2).*?\Ktext-1

    REPLACE text-3

    Tick the Wrap-around option

    Select the Regular expression search mode

    Click once on the Replace All button

    Case (B) could be achieved with the regex S/R :

    SEARCH (?s)(?=.*text-1).*?\Ktext-2

    REPLACE text-3

    Tick the Wrap-around option

    Select the Regular expression search mode

    Click once on the Replace All button

    Finally, your second statement is :

    You have to find text-1, and then move from the text-1 to the left or to the right by a given number of characters, and then replace it starting from this position

    Many questions !

    Do you want to find all occurrences of text-1 or a specific one ?

    What you want to replace ( an exact number of chars, the next word, an exact string or even some text splited on several lines ? )

    Anyway, here is a first idea :

    To get the zero-length position, after text-1 and N characters on the right, use the search regex :

    (?-s)text-1.{N}\K

    To get the zero-length position, before text-1 and N characters on the left, use the search regex :

    (?-s)\K(?=.{N}text-1)

    See you later,

    Best Regards,

    guy038

  • How to set a lexer from a plugin?

    4
    1 Votes
    4 Posts
    426 Views
    dinkumoilD

    @dail

    Ah, OK. Now I understand why YOU asked that question. ;-)

  • Importing PythonScript Library to IDE

    11
    0 Votes
    11 Posts
    1k Views
    John Doe 1J

    @peterjones There’s no need for an apology, you’ve been a great deal of help in learning Notepad++ development. I truly appreciate all of the demonstrations you’ve provided and they were very helpful. I would advise you not to take a break from this forum, you’ve helped a lot and I am sure there are others that could use your assistance. I can be a bit hard headed at times which can lead to frustration and I am sorry for that. Have a great one! : - )

  • PythonScript Toggleable Script?

    34
    0 Votes
    34 Posts
    3k Views
    John Doe 1J

    @alan-kilborn You’re exactly correct, this has been a great learning experience for me regarding Notepad++ plugin development. I plan to continue improving my current plugins and write new ones. Once again thank you @Alan-Kilborn and @PeterJones for pointing me in the right direction, you’ve been helped a great deal! : - )

  • PythonScript: Check If Notepad++ Was Closed To Terminate an Infinite Loop

    14
    0 Votes
    14 Posts
    1k Views
    John Doe 1J

    @peterjones Yeah that is my concern, I’m gonna work on this some more later to see if I can get the script all cleaned up so that is no longer an issue. Thanks for your help so far!

  • Interesting behavior from editor.getFirstVisibleLine()

    7
    0 Votes
    7 Posts
    417 Views
    PeterJonesP

    @alan-kilborn ,

    Do we know of any workarounds in order to get good data?

    Yes, like I showed above, editor.docLineFromVisible(editor.getFirstVisibleLine()), gives the actual document line number as derived from the display line number. Hence, the correct 75 that got printed on the second line in the final example box.

    Addenda:

    As implied in the editor section of the PythonScript docs when searching for “display line”, the visible line’s number is influenced by hidden lines and line wrapping. The “document line” is the real underlying line number for the line in the file. So there are a few conversion helpers: visibleFromDocLine converts the “document line” into the “display line”; docLineFromVisible converts the “display line” into “document line”; and wrapCount gives the number of “display lines” necessary to render the given “document line”. (All the other mentions of “display line” have to do with where HOME and END and their related commands end up.)

    Similarly, if you want to set the first visible line (to scroll) based on an actual document line number, it would be editor.setFirstVisibleLine(editor.visibleFromDocLine(actualLineNumber))

  • PythonScript and Customize Toolbar Question

    9
    0 Votes
    9 Posts
    743 Views
    Alan KilbornA

    @john-doe-1 said in PythonScript and Customize Toolbar Question:

    if the user does not turn off Column Mode before closing Notepad++ the “Alt” key remains pressed, this is of course a bit of an issue. If you know of a way to detect when Notepad++ is tabbed out of or closed I would appreciate your help.

    This is bringing the discussion back to the other script you hinted at in your first posting in this thread. See HERE for that other thread, and some ideas about the “Alt” key.

  • occurences or comparison with a list

    9
    0 Votes
    9 Posts
    1k Views
    guy038G

    Hi, @chamzon-chamzon, @lycan-thrope, @peterjones and All,

    OK… I understand that in real cases, this causes a complete failure of the regex engine :-(( Why ?

    Well, let’s suppose the temporary file containing, first, your entire firewall configuration file followed with your entire IP-adresses list file

    Now, imagine the worst case : an unique match between the first IP-address of your firewall configuration file and the last IP-address of your IP-adresses list

    Then, and despite I use a non-capturing regex group, the part of the regex (?s:.*?...) represents all the characters, included line-endings, right after the first IP-address till the same IP-address excluded, at the very end of file

    As you said that your firewall configuration file has about 68,000 lines, it’s easy to guess that it probably exceeds the capacity of the regex engine to handle such a gap of chars !!

    So, in order to find out, somehow, a work-around to this situation, could you give me :

    The number of lines of your firewall configuration file and its approximate size

    The number of lines of your IP-addreses list and its approximate size

    A short example of your real firewall configuration file

    A short example of your real IP-addresses list

    In order to get the raw text, click on that button, when writing your post, to insert text in the right way !

    41d95003-7608-410a-958d-539e9c906c41-Capture d’écran 2022-03-07 123711.png

    Thanks for your time to collect these infos !

    Best Regards,

    guy038

  • 0 Votes
    6 Posts
    1k Views
    J KoJ

    @klaus-isbruchdn try disabling the XML tools --> Enable XML syntax auto-check

  • Bypassing the download process when installing plugins

    4
    0 Votes
    4 Posts
    401 Views
    Alan KilbornA

    @e5584071

    Can you follow the steps above to obtain and install it, or do you really need someone to walk you through the process specifically with the Compare plugin?

  • Add Loading Screen to Script?

    4
    0 Votes
    4 Posts
    532 Views
    John Doe 1J

    @PeterJones Thanks for your input and search advice, it is much appreciated. @Alan-Kilborn Yeah that is what I ended up doing, funny we had the same thought. The loading screen seems to be too much of a time sink for right now. Maybe later on in development.

  • PythonScript CSV Sort Help

    17
    0 Votes
    17 Posts
    1k Views
    John Doe 1J

    @chcg I would say it is pretty far from usable currently, and I have plans to add some libraries to it (including pandas) in the near future, thanks for the suggestion though : - )

  • Make External Lexer Plugin work with v8.4

    1
    3 Votes
    1 Posts
    6k Views
    No one has replied
  • NppExec v0.8.1 has been released!

    1
    6 Votes
    1 Posts
    306 Views
    No one has replied
  • Lokking for a line filter plugin

    2
    0 Votes
    2 Posts
    962 Views
    Alan KilbornA

    @richard-devenezia

    One word: Analyse (plugin)

  • Where to begin

    3
    0 Votes
    3 Posts
    376 Views
    Derek BrownD

    I believe you could use the NPPN_FILEOPENED notification and check the filename to see if it’s a new file (it will have no path and just a name like “new 1”). Then run your code to have the user select a template and insert text.

    Alternatively, you could just create a menu command for your plugin that lets the user select a template, then create a new file with that template text. Also note that the user can bind shortcut keys to plugin menu items.

  • NppExec Console not recognizing block pasting of input into it.

    7
    0 Votes
    7 Posts
    789 Views
  • Adding Libraries to PythonScript Plugin

    40
    0 Votes
    40 Posts
    8k Views
    Alan KilbornA

    @john-doe-1 said in Adding Libraries to PythonScript Plugin:

    point me to a more specific forum for Pandas

    Hmm, can’t say I’ve ever used one.
    I searched it up; apparently a “more important” pandas is a medical condition. And of course the cute bears…

    But I did find this one, no idea of its quality: https://community.developers.refinitiv.com/tags/pandas.html

    I’m sure some more intensive searching will provide others.

  • Icons in Menus.

    4
    0 Votes
    4 Posts
    396 Views
    Alan KilbornA

    @alan-kilborn said in Icons in Menus.:

    Issue created

    When I said this, I was meaning an issue requesting the native support.

  • Is there a way to use the CustomFileDialog from a plugin?

    2
    0 Votes
    2 Posts
    311 Views
    PeterJonesP

    @martin-honnen ,

    I do not believe that you can have access from the plugin to the custom file dialog already compiled into Notepad++.exe – at least, it doesn’t seem to be exposed by any of the API commands, and I don’t know of a way for a DLL to access a function from the parent EXE.

    That said, rather than fully implementing your own version, you might just be able to copy the source code for the CustomFileDialog, and compile it as part of your plugin’s DLL. I know, it has downsides (if they changed the source code, you would have to change your source code, rather than just calling their function), but it might be easier than completely re-implementing.

    Or you could just use a win32api-standard file-selection dialog, like GetOpenFileName or GetSaveFileName rather than NPP’s customized version.

    Caveat: I am not a plugin-authoring expert, though I have dealt heavily with the NPP messaging API, and know a tiny bit about generic win32 coding.