Ho to modify search results output

2013-08-18
2013-08-19
  • Hello,

    writing small plugin, that is adding comments to lines in main document, nothing more.
    User is using usual "find" or "find in all open files" dialog box, and get's the search results.
    My task is to modify somehow search result output.
    So user was able to see, that some line has a comment added by my plugin.
    For me is enough if I could add a "+" char a the beginning of each line in search results.
    I don't want to add this sigh to main document, as don't want to change it.

    "+" (this sign I want to add) Line 122057: 21:06:34.355705 дбг 001;104;002;003;000;000;171;205;205;239 00360 process_cms_error() - CMS ERROR получен от сима!!!;err_code=515

    The question is, is there a way, to modify the "search results" output?

    I guess I can obtain from Npp a scintilla handler to output results, and then modify them, but how do I know that search is finished? Is there some notifications raised by Npp?

    Thanks in advance!

     
  • cchris
    cchris
    2013-08-19

    Your Scintilla will send notifications to the main N++ handle once it gets search results written in. Set the parent of youe Scintilla to some message window the parent of which is the main N++ window. This way you can snoop notifications while maintaining expected behaviour.

    Finding when search is over is ore difficult. You'll probably miss anything that is not reflected in the status bar. However, if you manage to subclass the statusbar in the find/replace dialog - that won't work for macro launched searches - you can take advantage of the fact that all searches end up performing

    return (::SendMessage(_hSelf, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)_lastSetText.c_str()) == TRUE);

    Catching such messages will provide an end of search signal. An ugly, fragile hack admittedly, but better than nothing.

    When no statusbar is involved, there is a call to FlashWindowEx, which is defined in user.dll. If you can WinSpy what this function does, you may be able to also pick failed search signals up. An even uglier hack.

    CChris