oleg-shilo / cs-script.npp

CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)
MIT License
246 stars 52 forks source link

How to Close a specific Tab(file) #62

Closed pnjsinc closed 7 months ago

pnjsinc commented 2 years ago

Greetings Oleg:

Love the project, I am using this to run a specialized compiler. l am looking for a way to close a specific file or tab that is open.

Can you share with me how to accomplish this?

Regards, Pat

oleg-shilo commented 2 years ago

Ho @pnjsinc,

I am not sure I follow your question.

Are you asking how to close Notepad++ tab from the script you are running?

pnjsinc commented 2 years ago

Greetings Oleg:

That is correct. After the compiler runs, it creates a file that shows the code as it was compiled, minus the comments and compile directives. This file is then opened by the compiler in npp. I am wanting to close this file before the code compiles again when needing to make additional changes.

Thank you so much for the awesome tool.

On Sat, Jan 15, 2022, 07:03 Oleg Shilo @.***> wrote:

Ho @pnjsinc https://github.com/pnjsinc,

I am not sure I follow your question.

Are you asking how to close Notepad++ tab from the script you are running?

— Reply to this email directly, view it on GitHub https://github.com/oleg-shilo/cs-script.npp/issues/62#issuecomment-1013687841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPOCWELM6JHPYYEKRSTOMDUWF5E7ANCNFSM5MACRXIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

oleg-shilo commented 2 years ago

Then I am afraid it's not a simple task.

You see the script that you run is executed as a separate process. Thus you have very limited ability to control Notepad++. And yet it is possible.

This is the pseudocode:

codefile = StripCommentsFrom(scriptFile)
nppWindowHandle = OpenInNpp(codefile)
nppTabIndex = SendMessage(nppWindowHandle, find_tab_with_file, codefile)
SendMessage(nppWindowHandle, close_tab, nppTabIndex)

This is not a trivial task and it will require understanding the Scintilla API (a very old fashioned message-based interface).

pnjsinc commented 2 years ago

Thanks for the response, I was afraid that was going to be the case. Thanks again for the great product.

Pat