Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    two questions on my first plugin

    Plugin Development
    2
    4
    1231
    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 Rosenbohm
      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
      • dinkumoil
        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 Rosenbohm
          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 Rosenbohm
            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
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors