From ad69e3f69c3b20a12879ed25d4f5237ceb7efd2e Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 21 May 2020 12:18:59 -0500 Subject: [PATCH] cleanup for review --- .../CascadiaPackage/Package.appxmanifest | 21 ++++++++++++++++++- .../ShellExtension/OpenTerminalHere.cpp | 21 +++++++++++++++++++ .../ShellExtension/OpenTerminalHere.h | 11 +++++++++- src/cascadia/ShellExtension/PlaceholderType.h | 6 ++++++ .../ShellExtension/PlaceholderType.idl | 6 ++++++ src/cascadia/ShellExtension/dllmain.cpp | 7 ++++++- src/dep/fmt/fmt.vcxproj | 18 +++++++++++++--- 7 files changed, 84 insertions(+), 6 deletions(-) diff --git a/src/cascadia/CascadiaPackage/Package.appxmanifest b/src/cascadia/CascadiaPackage/Package.appxmanifest index ad429698b69..0cfa5ffa9b3 100644 --- a/src/cascadia/CascadiaPackage/Package.appxmanifest +++ b/src/cascadia/CascadiaPackage/Package.appxmanifest @@ -41,7 +41,7 @@ Square150x150Logo="Images\Square150x150Logo.png" Square44x44Logo="Images\Square44x44Logo.png"> @@ -60,6 +60,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/cascadia/ShellExtension/OpenTerminalHere.cpp b/src/cascadia/ShellExtension/OpenTerminalHere.cpp index a130b2c75de..1e665608989 100644 --- a/src/cascadia/ShellExtension/OpenTerminalHere.cpp +++ b/src/cascadia/ShellExtension/OpenTerminalHere.cpp @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + #include "pch.h" #include "OpenTerminalHere.h" @@ -12,6 +15,16 @@ static std::wstring VerbName{ L"WindowsTerminalOpenHere" }; // https://github.com/microsoft/Windows-classic-samples/blob/master/Samples/ // Win7Samples/winui/shell/appshellintegration/ExplorerCommandVerb/ExplorerCommandVerb.cpp +// Function Description: +// - This is a helper to determine if we're running as a part of the Dev Build +// Package or the release package. We'll need to return different text, icons, +// and use different commandlines depending on which one the user requested. +// - Uses a C++11 "magic static" to make sure this is only computed once. +// - If we can't determine if it's the dev build or not, we'll default to true +// Arguments: +// - +// Return Value: +// - true if we believe this extension is being run in hte dev build package. bool IsDevBuild() { // use C++11 magic statics to make sure we only do this once. @@ -31,6 +44,14 @@ bool IsDevBuild() return isDevBuild; } +// Method Description: +// - This method is called when the user activates the context menu item. We'll +// launch the Terminal using the current working directory. +// Arguments: +// - psiItemArray: a IShellItemArray which contains the item that's selected. +// Return Value: +// - S_OK if we successfully attempted to launch the Terminal, otherwise a +// failure from an earlier HRESULT. HRESULT OpenTerminalHere::Invoke(IShellItemArray* psiItemArray, IBindCtx* /*pbc*/) { diff --git a/src/cascadia/ShellExtension/OpenTerminalHere.h b/src/cascadia/ShellExtension/OpenTerminalHere.h index 03f9cf324d9..87b07cfce86 100644 --- a/src/cascadia/ShellExtension/OpenTerminalHere.h +++ b/src/cascadia/ShellExtension/OpenTerminalHere.h @@ -3,9 +3,16 @@ Copyright (c) Microsoft Corporation Licensed under the MIT license. Module Name: -- Foo.h +- OpenTerminalHere.h Abstract: +- This is the class that implements our Explorer Context Menu item. By + implementing IExplorerCommand, we can provide an entry to the context menu to + allow the user to open the Terminal in the current working directory. +- Importantly, we need to make sure to declare the GUID of this implementation + class explicitly, so we can refer to it in our manifest, and use it to create + instances of this class when the shell asks for one. + Author(s): - Mike Griese - May 2020 @@ -18,6 +25,7 @@ Author(s): struct __declspec(uuid("9f156763-7844-4dc4-bbb1-901f640f5155")) OpenTerminalHere : winrt::implements { +#pragma region IExplorerCommand HRESULT Invoke(IShellItemArray* psiItemArray, IBindCtx* pbc); HRESULT GetToolTip(IShellItemArray* psiItemArray, @@ -32,4 +40,5 @@ struct __declspec(uuid("9f156763-7844-4dc4-bbb1-901f640f5155")) HRESULT GetFlags(EXPCMDFLAGS* pFlags); HRESULT GetCanonicalName(GUID* pguidCommandName); HRESULT EnumSubCommands(IEnumExplorerCommand** ppEnum); +#pragma endregion }; diff --git a/src/cascadia/ShellExtension/PlaceholderType.h b/src/cascadia/ShellExtension/PlaceholderType.h index d5bd24f210e..d56395c9257 100644 --- a/src/cascadia/ShellExtension/PlaceholderType.h +++ b/src/cascadia/ShellExtension/PlaceholderType.h @@ -6,6 +6,12 @@ Module Name: - PlaceholderType.h Abstract: +- 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. + Author(s): - Mike Griese - May 2020 diff --git a/src/cascadia/ShellExtension/PlaceholderType.idl b/src/cascadia/ShellExtension/PlaceholderType.idl index 22e23f92f39..0dbe7adfacc 100644 --- a/src/cascadia/ShellExtension/PlaceholderType.idl +++ b/src/cascadia/ShellExtension/PlaceholderType.idl @@ -1,6 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +// 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. + namespace Microsoft.Terminal.ShellExtension { [default_interface] runtimeclass PlaceholderType { diff --git a/src/cascadia/ShellExtension/dllmain.cpp b/src/cascadia/ShellExtension/dllmain.cpp index db888b3144d..d7c6aeb3542 100644 --- a/src/cascadia/ShellExtension/dllmain.cpp +++ b/src/cascadia/ShellExtension/dllmain.cpp @@ -1,8 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + #include "pch.h" #include "OpenTerminalHere.h" // NOTE: All this file is pretty egregiously taken from PowerToys's PowerRename, // specifically: -// https://github.com/microsoft/PowerToys/blob/d16ebba9e0f06e7a0d41d981aeb1fd0a78192dc0/src/modules/powerrename/dll/dllmain.cpp +// +// https://github.com/microsoft/PowerToys/blob/d16ebba9e0f06e7a0d41d981aeb1fd0a78192dc0/ +// src/modules/powerrename/dll/dllmain.cpp // // I'm not positive how much of it we need, but we definitely need: // * a ClassFactory that can create our implementation of IExplorerCommand diff --git a/src/dep/fmt/fmt.vcxproj b/src/dep/fmt/fmt.vcxproj index 749b755b658..d60af82d693 100644 --- a/src/dep/fmt/fmt.vcxproj +++ b/src/dep/fmt/fmt.vcxproj @@ -16,11 +16,23 @@ - + + - + + + + + + + + + + + + - + \ No newline at end of file