• Login
Community
  • Login

how to call the API to rename a new tab?

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
8 Posts 3 Posters 797 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.
  • Z
    Zhixun Qu
    last edited by May 21, 2024, 2:31 AM

    As the title suggests, how to call the API to rename a new tab?

    A 1 Reply Last reply May 21, 2024, 11:16 AM Reply Quote 0
    • A
      Alan Kilborn @Zhixun Qu
      last edited by Alan Kilborn May 21, 2024, 11:19 AM May 21, 2024, 11:16 AM

      @Zhixun-Qu

      I presume you mean you have a new 4 tab, for example, and you want to rename it but still not save it into the file system, i.e., you want to keep it “soft named”.

      I asked for this, HERE , and it was rejected by the Notepad++ author with this reasoning:
      “I don’t add the features which are requested by (very) few users, and the features in question needs a lot of coding effort.” (SOURCE ).

      See also HERE for a plugin request that would need this N++ support to be fulfilled.

      A Z 2 Replies Last reply May 21, 2024, 12:57 PM Reply Quote 3
      • A
        Alan Kilborn @Alan Kilborn
        last edited by May 21, 2024, 12:57 PM

        @Alan-Kilborn said in how to call the API to rename a new tab?:

        it was rejected by the Notepad++ author

        Apparently author has reconsidered, see HERE ; the issue in question has been reopened.

        1 Reply Last reply Reply Quote 2
        • Z
          Zhixun Qu @Alan Kilborn
          last edited by May 22, 2024, 2:35 AM

          @Alan-Kilborn :: SendMessage (nppData. nppHandle, NPPM-MENUCOMMAND, 0, IDM-FILE-RENAME); Can a naming dialog box be displayed? How can I use the program to operate this pop-up dialog box?

          A 1 Reply Last reply May 22, 2024, 2:06 PM Reply Quote 0
          • M
            Mark Olson
            last edited by May 22, 2024, 3:42 AM

            This can already be done using
            SendMessage(NPPM_INTERNAL_SETFILENAME, intptr_t bufferId, const char * newName);
            However, because you are directly calling an internal API and circumventing the normal machinery of Notepad++, calling NPPM_INTERNAL_SETFILENAME does not automatically trigger the NPPN_FILEBEFFORERENAME and NPPN_FILERENAMED notifications, which may cause strange behavior in plugins that respond to those notifications, and is therefore perhaps not a great idea. That said, I do this myself in the JsonTools plugin and it seems to work fine.

            A 2 Replies Last reply May 22, 2024, 2:00 PM Reply Quote 6
            • A
              Alan Kilborn @Mark Olson
              last edited by May 22, 2024, 2:00 PM

              @Mark-Olson said in how to call the API to rename a new tab?:

              This can already be done using…

              Ah. I was not aware of this.

              In the N++ source code near the NPPM_INTERNAL_SETFILENAME definition is a comment “Used by netnote plugin”.

              Plugins Admin shows a NppNetNote plugin and a link to its site: https://sourceforge.net/projects/npp-plugins/files/NppDocShare/ although that’s a bit confusing because it is called “share” instead of “note”.

              Anyway that plugin has a date of 2008 on it, so it is really old and apparently hasn’t been modified since then.

              It’s curious why, if a plugin was going to use it, why it wasn’t made into a full-fledged plugin message rather than an “internal” message.

              Also interesting is that it provided a means to rename a soft-named tab (e.g. new 5) to something less generic, many years before a Notepad++ release allowed such tabs to be renamed.

              1 Reply Last reply Reply Quote 0
              • A
                Alan Kilborn @Zhixun Qu
                last edited by May 22, 2024, 2:06 PM

                @Zhixun-Qu said in how to call the API to rename a new tab?:

                SendMessage (nppData. nppHandle, NPPM-MENUCOMMAND, 0, IDM-FILE-RENAME);

                I’d think something like that would get you the Rename Current Tab dialog displayed if executed when a soft-named tab is active.

                Can a naming dialog box be displayed?

                Yes (see above / below).

                How can I use the program to operate this pop-up dialog box?

                I wouldn’t do this if I were doing it. I’d create my own renaming interface in whatever language I’m writing the plugin in. It gives you more direct control over what’s going on.


                For my purposes (and I do have some), I just want to (have a script) rename the softnamed tab with a single (script) command…no popup prompt from N++ wanted (I already know the name I want to give the tab). Thanks to Mark’s posting, I can now achieve this with a little bit of SendMessage code.

                1 Reply Last reply Reply Quote 0
                • A
                  Alan Kilborn @Mark Olson
                  last edited by May 22, 2024, 2:08 PM

                  @Mark-Olson said in how to call the API to rename a new tab?:

                  calling NPPM_INTERNAL_SETFILENAME does not automatically trigger the NPPN_FILEBEFFORERENAME and NPPN_FILERENAMED notifications,

                  I can’t think of any circumstance where I’d care about this. But, I suppose it could be important to others…

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