Skip to content

Commit

Permalink
cleanup for review
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed May 21, 2020
1 parent 643125f commit ad69e3f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 6 deletions.
21 changes: 20 additions & 1 deletion src/cascadia/CascadiaPackage/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile
Wide310x150Logo="Images\Wide310x150Logo.png"
Wide310x150Logo="Images\Wide310x150Logo.png"
Square71x71Logo="Images\SmallTile.png"
Square310x310Logo="Images\LargeTile.png"
ShortName="ms-resource:AppShortName">
Expand All @@ -60,6 +60,25 @@
<desktop:ExecutionAlias Alias="wt.exe" />
</uap3:AppExecutionAlias>
</uap3:Extension>

<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="ShellExtension">
<com:Class Id="9f156763-7844-4dc4-bbb1-901f640f5155" Path="ShellExtension.dll" ThreadingModel="STA"/>
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
<desktop4:Extension Category="windows.fileExplorerContextMenus">
<desktop4:FileExplorerContextMenus>
<desktop5:ItemType Type="Directory">
<desktop5:Verb Id="Command1" Clsid="9f156763-7844-4dc4-bbb1-901f640f5155" />
</desktop5:ItemType>
<desktop5:ItemType Type="Directory\Background">
<desktop5:Verb Id="Command2" Clsid="9f156763-7844-4dc4-bbb1-901f640f5155" />
</desktop5:ItemType>
</desktop4:FileExplorerContextMenus>
</desktop4:Extension>

</Extensions>

</Application>
Expand Down
21 changes: 21 additions & 0 deletions src/cascadia/ShellExtension/OpenTerminalHere.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#include "pch.h"
#include "OpenTerminalHere.h"

Expand All @@ -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:
// - <none>
// 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.
Expand All @@ -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*/)
{
Expand Down
11 changes: 10 additions & 1 deletion src/cascadia/ShellExtension/OpenTerminalHere.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,6 +25,7 @@ Author(s):
struct __declspec(uuid("9f156763-7844-4dc4-bbb1-901f640f5155"))
OpenTerminalHere : winrt::implements<OpenTerminalHere, IExplorerCommand>
{
#pragma region IExplorerCommand
HRESULT Invoke(IShellItemArray* psiItemArray,
IBindCtx* pbc);
HRESULT GetToolTip(IShellItemArray* psiItemArray,
Expand All @@ -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
};
6 changes: 6 additions & 0 deletions src/cascadia/ShellExtension/PlaceholderType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/cascadia/ShellExtension/PlaceholderType.idl
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion src/cascadia/ShellExtension/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 15 additions & 3 deletions src/dep/fmt/fmt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(SolutionDir)\oss\fmt\src\*.cc" />
<ClCompile Include="..\..\..\oss\fmt\src\format.cc" />
<ClCompile Include="..\..\..\oss\fmt\src\os.cc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SolutionDir)\oss\fmt\include\fmt\*.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\chrono.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\color.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\compile.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\core.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\format-inl.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\format.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\locale.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\os.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\ostream.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\posix.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\printf.h" />
<ClInclude Include="..\..\..\oss\fmt\include\fmt\ranges.h" />
</ItemGroup>
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" />
</Project>
</Project>

1 comment on commit ad69e3f

@github-actions

This comment was marked as outdated.

Please sign in to comment.