bruderstein / PythonScript

Python Script plugin for Notepad++
http://npppythonscript.sourceforge.net/
GNU General Public License v2.0
338 stars 65 forks source link

Notepad object member function to rename unsaved tab #147

Open sasumner opened 4 years ago

sasumner commented 4 years ago

This is a FEATURE REQUEST.

Notepad++ version 7.6.4 (I think) brought the capability to rename an unsaved tab.

For example, a tab with the title "new 2" can be right-clicked upon, "Rename" chosen from the resulting popup menu, and the following box presents:

image

Entering a value changes the current tab's title to the specified name.

WHAT I'D LIKE: A way to do this programmatically, say with a notepad.rename('My new name') function call.

Perhaps there are dependency problems with supporting this; for instance, does the Notepad++ plugin interface currently permit plugins to rename an unsaved tab?

There also might be logistical problems in uniquely identifying tabs with the same name (yes, Notepad++'s implementation currently allows this) for purposes of, say notepad.getFiles() calls. But, I suppose this is a Notepad++ "problem" (don't allow it), or a user "problem" (don't name two tabs with the same name).

chcg commented 4 years ago

Seems no interface is available for renaming in https://npp-user-manual.org/docs/plugin-communication/#notepad-messages.

Checkin was https://github.com/notepad-plus-plus/notepad-plus-plus/commit/3546268c235780a6ba15266e7685aab7f6d6ce7f.

So currently just the MENUCOMMAND.FILE_RENAME would be an option.

sasumner commented 3 years ago

Request for support in Notepad++ made here: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8916

alankilborn commented 2 years ago

It looks like the "N++ extension needed" part isn't going to be fulfilled (see https://github.com/notepad-plus-plus/notepad-plus-plus/issues/8916#issuecomment-1002661861) so I suppose it is appropriate to close this issue. :-(

alankilborn commented 1 year ago

OP said:

WHAT I'D LIKE: A way to do this programmatically, say with a notepad.rename('My new name') function call.

@chcg replied:

So currently just the MENUCOMMAND.FILE_RENAME would be an option.

My comment to that:

That doesn't fulfill the goal. What that does is pop-up a box and waits for the script user to "fill in the blank", and that's for a file that is going to be actually on disk.

What is wanted is a way to rename an unsaved tab, e.g. new 5, to something else (but still an unsaved tab, not on disk), without any user involvement.

alankilborn commented 2 months ago

@chcg

This could be achieved using: SendMessage(NPPM_INTERNAL_SETFILENAME, intptr_t bufferId, const char * newName);

Reopen?

Ekopalypse commented 1 month ago

Should pythonscript really rely on internal npp messages? Are they not called internal because they should not be used by plugins?

alankilborn commented 1 month ago

Should pythonscript really rely on internal npp messages?

No, I was just documenting it as a possible means. Since that time, the author of N++ has decided that the internal message itself should be removed, as it is unused (internally).

Are they not called internal because they should not be used by plugins?

Oddly enough, the internal message in question seems to have been create for a plugin's usage.

Ekopalypse commented 1 month ago

Oh, I see, I was late for the party :-)