-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a context menu entry to "Open Windows Terminal here" #6100
Conversation
I need the PlaceholderType so a winmd gets produced, otherwise the wapproj gets _very_ unhappy. I renamed things to make more sense. I actually launch the terminal, which is awesome.
If you're adding a COM interface then you may as well update the WPF control too. Nice screenshot! I wonder if there's a way to re-use "Open Here" for shells like Powershell, which already have their own. Maybe you could link to their context menu and use it to execute the profile? |
I fail to see why adding a COM interface to make a shell extension should touch the WPF control whatsoever. What updates does it even need? |
namespace winrt::Microsoft::Terminal::ShellExtension::implementation | ||
{ | ||
struct PlaceholderType : PlaceholderTypeT<PlaceholderType> | ||
{ | ||
PlaceholderType() = default; | ||
GETSET_PROPERTY(int32_t, Placeholder, 42); | ||
}; | ||
} | ||
|
||
namespace winrt::Microsoft::Terminal::ShellExtension::factory_implementation | ||
{ | ||
BASIC_FACTORY(PlaceholderType); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WAT
// This class is just here to make our .wapproj play nicely with this project. | ||
// If we don't define any winrt types, then we won't generate a .winmd, and the | ||
// .wapproj will become _very_ mad at this project. So we'll use this | ||
// placeholder class just to trick cppwinrt into generating a winmd for us. If | ||
// we ever _do_ add a real winrt type to this project, this can be removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHY DO WE LIVE IN THIS HELLSCAPE
I mean if someone builds the WPF control, they should also get this feature. Since this adds a COM interface, I would think it wouldn't be too much effort to add it there. |
The WPF control is a DLL that gets integrated into your existing project. It is by no means a standalone terminal application. There's no reason for that WPF CONTROL to add a shell extension. |
// https://github.com/microsoft/PowerToys/blob/master/ | ||
// src/modules/powerrename/dll/dllmain.cpp | ||
// We don't need to implement DllGetActivationFactory or DllCanUnloadNow | ||
// manually, since the generated module.g.cpp will handle it for us, and will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised we get a module.g.cpp . . . did we make sure the cppwinrt WRL hookup works right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we get it because of PlaceholderType
? It does seem to do some WRL magic. I have no idea how, but it does seem to work ¯\_(ツ)_/¯
If the default Powershell $profile contains some sort of "cd path\to\folder", this overrides the path speification opened by WT through Explorer's Open WT here. Maybe it is not recommened that $profile contain such a path specification, but I thought I'd flag this here. |
Yea there's not really a way for the Terminal to prevent such a command from running in your powershell profile. I'd definitely recommend against doing that if you want to use this context menu entry. |
No icon? |
how i can disble this ? |
@Skyline404 discussion in #7008. |
Is there an ETA when the fix for not being able to launch it from an explorer window's "background", as was described in the release notes, will hit earlier Windows versions? |
@PTS93 I'd recommend subscribing to #6414 - we're at the mercy of the platform release cycle currently. When we have an update to share, we'll update that thread. |
@tiagoboeing thanks! please read the comment directly above yours. |
@DHowett yeap. Subscribed to the topic. Thanks!! |
for those who have an access error, there is such a solution |
I don't know if this is the right place to comment, but is there a task tracking
|
@AnderssonPeter I'd check the issues in this list to see if they match what you're looking for. That should have all the work we're tracking for this feature. |
When I open Windows Terminal, it opens a tab with TCC. When I press Ctrl+Shift+t, it opens with TCC. When I right-click Open in Windows Terminal, it opens Powershell - is there some different default profile that is being used here? |
@NetMage I'm not sure I can really help you with that off the top of my head. I don't really know how TCC works - we might be able to help you investigate, but a 8 month old PR is probably not the place to have that discussion. Maybe try filing a new issue? |
Summary of the Pull Request
I went with the simple option - just open the Terminal with the default profile in the selected directory. I'd love to add another entry for "Open Terminal here with Profile...", but that's going to be follow-up work, once we sort out pulling the Terminal Settings into their own dll.
References
dllname.dll,1
format, which is annoying.desktop5
lets you specify "Directory"PR Checklist
Detailed Description of the Pull Request / Additional comments
This adds a COM class that implements
IExplorerCommand
, which is what lets us populate the context menu entry. We expose that type through a new DLL that is simply responsible for the shell extension, so that explorer doesn't need to load the entire Terminal just to populate that entry.The COM class is tied to the application through some new entries in the manifest. The Clsid values are IMPORTANT - they must match the UUID of the implementation type. However, the
Verb
in the manifest didn't seem important.