Community
    • Login

    Yet Another C++ Plugin Template...

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    11 Posts 3 Posters 946 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ThosRTannerT
      ThosRTanner
      last edited by

      I felt the existing C++ notepad++ plugin template was a little unclear, left some things unexplained, and was prone to error (well, prone to the sort of errors I tend to make), and left it very unclear about how you’d fit in a docking dialogue.

      Also it wasn’t really class oriented. And I like classes.

      So I wrote my own. Complete with a demo plugin. And a fair amount of documentation in the readme (which could be better, sorry).

      It’s still a little bit work in progress - in the way of computer projects, it’s hit 95% complete, and now I keep finding extra bits to do before it gets to 100%

      It provides a layer between notepad++ and your plugin, enabling you to keep your code nicely in a few classes without loads of static or global variable, and attempts to hide some of the vagaries of the windows APIs. Or at least make them less horrifying.

      It can be found here

      Feel free to try it out and comment here or raise issues in the repo.

      Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 4
      • Alan KilbornA Alan Kilborn referenced this topic on
      • Alan KilbornA
        Alan Kilborn @ThosRTanner
        last edited by Alan Kilborn

        This was originally mentioned in THIS THREAD in the Dec 17 2023 1:04PM POSTING.

        1 Reply Last reply Reply Quote 0
        • CoisesC
          Coises @ThosRTanner
          last edited by

          @ThosRTanner said in Yet Another C++ Plugin Template...:

          One comment, just a thought…

          Since you are making a C++ template, perhaps instead of:

          LRESULT send_to_editor(UINT message, WPARAM = 0, LPARAM = 0) const noexcept
          LRESULT send_to_editor(UINT message, WPARAM wParam, void const *buff) const noexcept
          

          it would be better to set up the Scintilla C++ API.

          Because of an annoyance with exception handling — ScintillaCall.h defines an exception but doesn’t derive it from std::exception, which prevents Notepad++ from displaying a sensible error message — I created a macro wrapper for ScintillaCall.h for Columns++, which you can see here.

          There is also an oddity whereby the C++ interface will raise an exception due to a leftover failure status code previously set but never cleared in the C interface, making it appear that something went wrong in the plugin using the C++ interface. Executing Scintilla::ScintillaCall::SetStatus(Scintilla::Status::Ok) before executing other C++ Scintilla calls avoids that, so it’s a good idea to call that somewhere in entry code each time before the plugin gets control.

          Alan KilbornA ThosRTannerT 2 Replies Last reply Reply Quote 4
          • Alan KilbornA
            Alan Kilborn @Coises
            last edited by

            @Coises @ThosRTanner

            I like it, guys, keep up the good work!

            1 Reply Last reply Reply Quote 1
            • ThosRTannerT
              ThosRTanner @Coises
              last edited by

              @Coises thanks. I shall go and have a look at that. I possibly need to fiddle with scintilla a bit before I release that…

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @ThosRTanner
                last edited by

                @ThosRTanner

                @Coises says HERE :

                …mapped shortcuts other than Scintilla commands are sent to Notepad++ when used in a non-modal dialog that doesn’t register with NPPM_MODELESSDIALOG. Apparently many plugins never did this, because the most commonly used shortcuts were Scintilla commands. Moving three very common shortcuts from Scintilla commands to Notepad++ accelerators changes that.

                Maybe it is appropriate to have the correct way of doing the above shown in a plugin template. Then future plugin authors are less likely to do it wrong. Just a thought.

                ThosRTannerT 1 Reply Last reply Reply Quote 0
                • ThosRTannerT
                  ThosRTanner @Alan Kilborn
                  last edited by ThosRTanner

                  @Alan-Kilborn Indeed. On my todo list.

                  Addendum - it actually already does that for docking dialogues.

                  Not for non-docking dialogues which I don’t currently support. Though if someone would like to point me to a plugin that creates floating dialogues, I’d be happy to have a play.

                  CoisesC 1 Reply Last reply Reply Quote 1
                  • CoisesC
                    Coises @ThosRTanner
                    last edited by

                    @ThosRTanner said in Yet Another C++ Plugin Template...:

                    a plugin that creates floating dialogues

                    The Search dialog in Columns++.

                    1 Reply Last reply Reply Quote 1
                    • ThosRTannerT
                      ThosRTanner
                      last edited by

                      Latest version now has a Non_Modal_Dialogue_Interface class (after a chunk of refactoring!)

                      Alan KilbornA 1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @ThosRTanner
                        last edited by Alan Kilborn

                        @ThosRTanner

                        Hello, was wondering about how mature your template is now?
                        @PeterJones 's posting HERE got me thinking about other plugin templates…

                        ThosRTannerT 1 Reply Last reply Reply Quote 0
                        • Alan KilbornA Alan Kilborn referenced this topic on
                        • ThosRTannerT
                          ThosRTanner @Alan Kilborn
                          last edited by ThosRTanner

                          @Alan-Kilborn fairly mature. I have a couple of other tweaks to do while trying to do a version of the linter plugin, which needed some extra functionality to make a few things simpler.

                          That and it’s not really a template of course. It’s a library you can use.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors