Community
    • Login

    two questions on my first plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    4 Posts 2 Posters 1.9k Views 2 Watching
    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.
    • Mario RosenbohmM Offline
      Mario Rosenbohm
      last edited by

      Hello,

      i now programing on my first npp plugin (in C#) and i have any little questions ;-)

      a) Is there exist an event or an message when the user change to another document?
      b) Is exist an example or dev-guide for using localization?

      Thats all for the begin.

      regards Mario

      1 Reply Last reply Reply Quote 3
      • dinkumoilD Offline
        dinkumoil
        last edited by

        I’m only able to tell you something about your question a)

        There is a notification called NPPM_BUFFERACTIVATED (see here (slightly outdated) and here (up to date)). It is send to a plugin whenever a document’s text buffer (i.e. its tab) gets activated.

        I’m a plugin author too (see here) thus I know that there are some pitfalls with NPPM_BUFFERACTIVATED. Activating a buffer often happens even in situations where you do not expect it.

        Especially if your plugin does something with a text buffer which has to be done only one times you need to implement some sort of buffer management to remember that a certain buffer already has undergone your manipulations.

        I personally ended up with a dictionary: The keys are buffer IDs and the values are the full paths of the related files. I solved it this way because it can happen that an already closed buffer ID gets reused by another file.

        1 Reply Last reply Reply Quote 5
        • Mario RosenbohmM Offline
          Mario Rosenbohm
          last edited by Mario Rosenbohm

          Hello dinkumoil,

          thanks for suggestion, it is exactly what i search.

          For all other C#-developers:

          1. In file Main.cs write a new function with header “internal static void bufferIsActivated()”
            this function is called by eventmanager on 2.

          2. In file PluginInfrastructure/UnmanagedExports.cs in the function “static void beNotified(IntPtr notifyCode)” add follow code above the else statement:

                 else if (notification.Header.Code == (uint)NppMsg.NPPN_BUFFERACTIVATED)
                 {
                     Main.bufferIsActivated();
                 }
            

          And now is calling your “bufferIsActivated”-function by change / activate a other tab.

          thanks and regards
          Mario

          1 Reply Last reply Reply Quote 0
          • Mario RosenbohmM Offline
            Mario Rosenbohm
            last edited by Mario Rosenbohm

            Hello everyone,

            “see the forest for the trees” 8-)

            in file PluginInfrastructure/UnmanagedExports.cs in the function “static void beNotified(IntPtr notifyCode)” in the else statement

                    else
                    {
                        Main.OnNotification(notification);
                    }
            

            … Main.OnNotification(notification); … oh no
            That is an callback. I am so stup…

            have a nice day
            Mario

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors