• Login
Community
  • Login

Yet Another C++ Plugin Template...

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
11 Posts 3 Posters 2.3k 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.
  • T
    ThosRTanner
    last edited by Jan 6, 2024, 12:44 PM

    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.

    A C 2 Replies Last reply Jan 6, 2024, 1:12 PM Reply Quote 4
    • A Alan Kilborn referenced this topic on Jan 6, 2024, 1:11 PM
    • A
      Alan Kilborn @ThosRTanner
      last edited by Alan Kilborn Jan 6, 2024, 1:13 PM Jan 6, 2024, 1:12 PM

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

      1 Reply Last reply Reply Quote 0
      • C
        Coises @ThosRTanner
        last edited by Jan 6, 2024, 6:12 PM

        @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.

        A T 2 Replies Last reply Jan 6, 2024, 6:17 PM Reply Quote 4
        • A
          Alan Kilborn @Coises
          last edited by Jan 6, 2024, 6:17 PM

          @Coises @ThosRTanner

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

          1 Reply Last reply Reply Quote 1
          • T
            ThosRTanner @Coises
            last edited by Jan 6, 2024, 6:57 PM

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

            A 1 Reply Last reply Jan 8, 2024, 8:52 PM Reply Quote 0
            • A
              Alan Kilborn @ThosRTanner
              last edited by Jan 8, 2024, 8:52 PM

              @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.

              T 1 Reply Last reply Jan 8, 2024, 9:16 PM Reply Quote 0
              • T
                ThosRTanner @Alan Kilborn
                last edited by ThosRTanner Jan 8, 2024, 10:29 PM Jan 8, 2024, 9:16 PM

                @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.

                C 1 Reply Last reply Jan 9, 2024, 5:23 AM Reply Quote 1
                • C
                  Coises @ThosRTanner
                  last edited by Jan 9, 2024, 5:23 AM

                  @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
                  • T
                    ThosRTanner
                    last edited by Jan 12, 2024, 8:09 PM

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

                    A 1 Reply Last reply Feb 26, 2025, 1:38 AM Reply Quote 0
                    • A
                      Alan Kilborn @ThosRTanner
                      last edited by Alan Kilborn Feb 26, 2025, 1:39 AM Feb 26, 2025, 1:38 AM

                      @ThosRTanner

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

                      T 1 Reply Last reply Mar 7, 2025, 11:06 PM Reply Quote 0
                      • A Alan Kilborn referenced this topic on Feb 26, 2025, 11:47 AM
                      • T
                        ThosRTanner @Alan Kilborn
                        last edited by ThosRTanner Mar 7, 2025, 11:40 PM Mar 7, 2025, 11:06 PM

                        @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