2020-10-06 18:56:59 +02:00
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets= "Build" ToolsVersion= "15.0" xmlns= "http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup Label= "Globals" >
<ProjectGuid > {CA5CAD1A-082C-4476-9F33-94B339494076}</ProjectGuid>
<ProjectName > Microsoft.Terminal.Settings.Model</ProjectName>
<RootNamespace > Microsoft.Terminal.Settings.Model</RootNamespace>
<!-- cppwinrt.build.pre.props depends on these settings: -->
<!-- build a dll, not exe (Application) -->
<ConfigurationType > DynamicLibrary</ConfigurationType>
<SubSystem > Console</SubSystem>
<!-- sets a bunch of Windows Universal properties -->
<OpenConsoleUniversalApp > true</OpenConsoleUniversalApp>
2021-05-13 23:12:30 +02:00
<PgoTarget > true</PgoTarget>
2020-10-06 18:56:59 +02:00
</PropertyGroup>
<Import Project= "..\..\..\..\common.openconsole.props" Condition= "'$(OpenConsoleDir)'==''" />
<Import Project= "$(OpenConsoleDir)src\cppwinrt.build.pre.props" />
<!-- ========================= XAML files ======================== -->
<ItemGroup >
<!-- DON'T PUT XAML FILES HERE! Put them in TerminalAppLib.vcxproj -->
</ItemGroup>
<!-- ========================= Headers ======================== -->
<ItemGroup >
<!-- Only put headers for winrt types in here. Don't put other header files
in here - put them in the lib's vcxproj instead! -->
<ClInclude Include= "../ActionArgs.h" />
Introduce ActionMap to Terminal Settings Model (#9621)
This entirely removes `KeyMapping` from the settings model, and builds on the work done in #9543 to consolidate all actions (key bindings and commands) into a unified data structure (`ActionMap`).
## References
#9428 - Spec
#6900 - Actions page
Closes #7441
## Detailed Description of the Pull Request / Additional comments
The important thing here is to remember that we're shifting our philosophy of how to interact/represent actions. Prior to this, the actions arrays in the JSON would be deserialized twice: once for key bindings, and again for commands. By thinking of every entry in the relevant JSON as a `Command`, we can remove a lot of the context switching between working with a key binding vs a command palette item.
#9543 allows us to make that shift. Given the work in that PR, we can now deserialize all of the relevant information from each JSON action item. This allows us to simplify `ActionMap::FromJson` to simply iterate over each JSON action item, deserialize it, and add it to our `ActionMap`.
Internally, our `ActionMap` operates as discussed in #9428 by maintaining a `_KeyMap` that points to an action ID, and using that action ID to retrieve the `Command` from the `_ActionMap`. Adding actions to the `ActionMap` automatically accounts for name/key-chord collisions. A `NameMap` can be constructed when requested; this is for the Command Palette.
Querying the `ActionMap` is fairly straightforward. Helper functions were needed to be able to distinguish an explicit unbinding vs the command not being found in the current layer. Internally, we store explicitly unbound names/key-chords as `ShortcutAction::Invalid` commands. However, we return `nullptr` when a query points to an unbound command. This is done to hide this complexity away from any caller.
The command palette still needs special handling for nested and iterable commands. Thankfully, the expansion of iterable commands is performed on an `IMapView`, so we can just expose `NameMap` as a consolidation of `ActionMap`'s `NameMap` with its parents. The same can be said for exposing key chords in nested commands.
## Validation Steps Performed
All local tests pass.
2021-05-05 06:50:13 +02:00
<ClInclude Include= "../ActionMap.h" />
2020-10-06 18:56:59 +02:00
<ClInclude Include= "../CascadiaSettings.h" />
<ClInclude Include= "../ColorScheme.h" />
<ClInclude Include= "../Command.h" />
<ClInclude Include= "../GlobalAppSettings.h" />
<ClInclude Include= "../KeyChordSerialization.h" />
<ClInclude Include= "../KeyMapping.h" />
<ClInclude Include= "../Profile.h" />
<ClInclude Include= "../TerminalWarnings.h" />
2020-11-05 01:55:16 +01:00
<ClInclude Include= "../IconPathConverter.h" />
2020-10-06 18:56:59 +02:00
</ItemGroup>
<!-- ========================= Cpp Files ======================== -->
<!-- Don't put source files in here - put them in the lib's vcxproj instead! -->
<!-- ========================= idl Files ======================== -->
<ItemGroup >
<!-- DON'T PUT IDL FILES HERE! Put them in the lib's vcxproj -->
</ItemGroup>
<!-- ========================= Misc Files ======================== -->
<ItemGroup >
Fix build break where Microsoft.Terminal.Control.dll is empty (#9537)
TIL that the `<None Include="Foo.def" />` line in our projects is
actually totally meaningless. The important line is the one that's in
`cppwinrt.build.pre.props`, where we declare
```xml
<ModuleDefinitionFile Condition="Exists('$(ProjectName).def')">$(ProjectName).def</ModuleDefinitionFile>
```
So if you change a project's name, and not the `.def` file, then the
linker will just _not use the `.def` file at all_.
More importantly, this seemingly doesn't matter in debug builds. In a
Debug build, the linker will happily still include `WINRT_CanUnloadNow`
and `WINRT_GetActivationFactory` in the exports from the dll, even
without the `.def`. But in a Release build, the linker is much more
agressive about pruning symbols that aren't referenced, and without
those two, NONE of the symbols are eventually referenced.
This PR fixes `Microsoft.Terminal.Control` by renaming the `.def`, and
makes it marginally harder for someone to make the same mistake in the
future.
## References
* Regressed in #9472
## PR Checklist
* [x] Closes #9529
* [x] I work here
2021-03-18 17:14:21 +01:00
<None Include= "$(ProjectName).def" />
2020-10-06 18:56:59 +02:00
</ItemGroup>
<!-- ========================= Project References ======================== -->
<ItemGroup >
<!--
the packaging project won't recurse through our dependencies, you have to
make sure that if you add a cppwinrt dependency to any of these projects,
you also update all the consumers
-->
<ProjectReference Include= "$(OpenConsoleDir)src\types\lib\types.vcxproj" >
<Project > {18D09A24-8240-42D6-8CB6-236EEE820263}</Project>
</ProjectReference>
2021-04-28 12:43:30 +02:00
<ProjectReference Include= "$(OpenConsoleDir)src\propslib\propslib.vcxproj" >
<Project > {345FD5A4-B32B-4F29-BD1C-B033BD2C35CC}</Project>
</ProjectReference>
2020-10-06 18:56:59 +02:00
<!-- The midl compiler however, _will_ aggregate our winmd dependencies
somehow. So make sure to only include top-level dependencies here (don't
include Settings and Connection, since Control will include them for us) -->
<ProjectReference Include= "$(OpenConsoleDir)src\cascadia\TerminalConnection\TerminalConnection.vcxproj" >
<Private > false</Private>
</ProjectReference>
2021-01-13 02:23:17 +01:00
2021-03-17 21:47:24 +01:00
<ProjectReference Include= "$(OpenConsoleDir)src\cascadia\TerminalControl\dll\TerminalControl.vcxproj" >
2021-01-13 02:23:17 +01:00
<!-- Private:false and ReferenceOutputAssembly:false, in combination with
the manual reference to TerminalControl.winmd below make sure that this
project will compile correct, and that we won't roll up the TermControl
xbf's into the packaging project twice. -->
<Private > true</Private>
<ReferenceOutputAssembly > false</ReferenceOutputAssembly>
2020-10-06 18:56:59 +02:00
</ProjectReference>
2021-01-13 02:23:17 +01:00
2020-10-06 18:56:59 +02:00
<!-- Reference Microsoft.Terminal.Settings.ModelLib here, so we can use it's winmd as
our winmd. This didn't work correctly in VS2017, you'd need to
manually reference the lib -->
<ProjectReference Include= "$(OpenConsoleDir)src\cascadia\TerminalSettingsModel\Microsoft.Terminal.Settings.ModelLib.vcxproj" >
<Private > true</Private>
</ProjectReference>
</ItemGroup>
2021-01-13 02:23:17 +01:00
<ItemGroup >
<!-- Manually add a reference to TerminalControl here. We need this so
MDMERGE will know where the TermControl types are defined. However, we need
to do it exactly like this so the packaging project won't roll up
TermControl's .xbf's from both the TermControl project and this one. -->
2021-03-17 21:47:24 +01:00
<Reference Include= "Microsoft.Terminal.Control" >
<HintPath > $(OpenConsoleCommonOutDir)Microsoft.Terminal.Control\Microsoft.Terminal.Control.winmd</HintPath>
<IsWinMDFile > true</IsWinMDFile>
<Private > false</Private>
<CopyLocalSatelliteAssemblies > false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include= "Microsoft.Terminal.Core" >
<HintPath > $(OpenConsoleCommonOutDir)TerminalCore\Microsoft.Terminal.Core.winmd</HintPath>
2021-01-13 02:23:17 +01:00
<IsWinMDFile > true</IsWinMDFile>
<Private > false</Private>
<CopyLocalSatelliteAssemblies > false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
2021-09-21 00:08:55 +02:00
<Import Project= "$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets" Condition= "Exists('$(OpenConsoleDir)packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets')" />
2020-10-06 18:56:59 +02:00
<Target Name= "EnsureNuGetPackageBuildImports" BeforeTargets= "PrepareForBuild" >
<PropertyGroup >
<ErrorText > This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
2021-09-21 00:08:55 +02:00
<Error Condition= "!Exists('$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets')" Text= "$([System.String]::Format('$(ErrorText)', '$(OpenConsoleDir)\packages\Microsoft.UI.Xaml.2.7.0-prerelease.210913003\build\native\Microsoft.UI.Xaml.targets'))" />
2020-10-06 18:56:59 +02:00
</Target>
<ItemDefinitionGroup >
<ClCompile >
<AdditionalIncludeDirectories > $(OpenConsoleDir)\dep\jsoncpp\json;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
</ClCompile>
<Link >
<AdditionalDependencies > User32.lib;WindowsApp.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<!-- TSM Lib contains a DllMain that we need to force the use of. -->
2021-05-13 23:12:30 +02:00
<AdditionalOptions Condition= "'$(Platform)'=='Win32'" > /INCLUDE:_DllMain@12 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition= "'$(Platform)'!='Win32'" > /INCLUDE:DllMain %(AdditionalOptions)</AdditionalOptions>
2020-10-06 18:56:59 +02:00
</Link>
<Reference >
<!-- Do not propagate microsoft.ui.xaml upwards as a private dependency. -->
<Private > false</Private>
</Reference>
</ItemDefinitionGroup>
<Import Project= "$(OpenConsoleDir)src\cppwinrt.build.post.props" />
</Project>