Skip to content

Commit

Permalink
Introduce KeyMapping and Move TerminalSettings construction (#7537)
Browse files Browse the repository at this point in the history
`KeyMapping` was introduced to break up `AppKeyBindings`. `KeyMapping`
records the keybindings from the JSON and lets you query them.
`AppKeyBindings` now just holds a `ShortcutActionDispatcher` to run
actions, and a `KeyMapping` to record/query your existing keybindings.
This refactor allows `KeyMapping` to be moved to the
TerminalSettingsModel, and `ShortcutActionDispatcher` and
`AppKeyBindings` will stay in TerminalApp.

`AppKeyBindings` had to be passed down to a terminal via
`TerminalSettings`. Since each settings object had its own
responsibility to update/create a `TerminalSettings` object, I moved all
of that logic to `TerminalSettings`. This helps with the
TerminalSettingsModel refactor, and makes the construction of
`TerminalSettings` a bit cleaner and more centralized.

## References
#885 - this is all in preparation for the TerminalSettingsModel

## Validation Steps Performed
- [x] Tests passed
- [X] Deployment succeeded
  • Loading branch information
carlos-zamora authored Sep 14, 2020
1 parent c17f448 commit abf8805
Show file tree
Hide file tree
Showing 38 changed files with 848 additions and 786 deletions.
44 changes: 22 additions & 22 deletions src/cascadia/LocalTests_TerminalApp/ColorSchemeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,23 +195,23 @@ namespace TerminalAppLocalTests

auto settings = winrt::make_self<winrt::TerminalApp::implementation::CascadiaSettings>();

VERIFY_ARE_EQUAL(0u, settings->_globals->GetColorSchemes().Size());
VERIFY_ARE_EQUAL(0u, settings->_globals->ColorSchemes().Size());
VERIFY_IS_NULL(settings->_FindMatchingColorScheme(scheme0Json));
VERIFY_IS_NULL(settings->_FindMatchingColorScheme(scheme1Json));
VERIFY_IS_NULL(settings->_FindMatchingColorScheme(scheme2Json));
VERIFY_IS_NULL(settings->_FindMatchingColorScheme(scheme3Json));

settings->_LayerOrCreateColorScheme(scheme0Json);
{
for (auto kv : settings->_globals->GetColorSchemes())
for (auto kv : settings->_globals->ColorSchemes())
{
Log::Comment(NoThrowString().Format(
L"kv:%s->%s", kv.Key().data(), kv.Value().Name().data()));
}
VERIFY_ARE_EQUAL(1u, settings->_globals->GetColorSchemes().Size());
VERIFY_ARE_EQUAL(1u, settings->_globals->ColorSchemes().Size());

VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme0");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->ColorSchemes().Lookup(L"scheme0");
auto scheme0 = winrt::get_self<ColorScheme>(scheme0Proj);

VERIFY_IS_NOT_NULL(settings->_FindMatchingColorScheme(scheme0Json));
Expand All @@ -225,13 +225,13 @@ namespace TerminalAppLocalTests
settings->_LayerOrCreateColorScheme(scheme1Json);

{
VERIFY_ARE_EQUAL(2u, settings->_globals->GetColorSchemes().Size());
VERIFY_ARE_EQUAL(2u, settings->_globals->ColorSchemes().Size());

VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme0");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->ColorSchemes().Lookup(L"scheme0");
auto scheme0 = winrt::get_self<ColorScheme>(scheme0Proj);
VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme1");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->ColorSchemes().Lookup(L"scheme1");
auto scheme1 = winrt::get_self<ColorScheme>(scheme1Proj);

VERIFY_IS_NOT_NULL(settings->_FindMatchingColorScheme(scheme0Json));
Expand All @@ -246,13 +246,13 @@ namespace TerminalAppLocalTests
settings->_LayerOrCreateColorScheme(scheme2Json);

{
VERIFY_ARE_EQUAL(2u, settings->_globals->GetColorSchemes().Size());
VERIFY_ARE_EQUAL(2u, settings->_globals->ColorSchemes().Size());

VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme0");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->ColorSchemes().Lookup(L"scheme0");
auto scheme0 = winrt::get_self<ColorScheme>(scheme0Proj);
VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme1");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->ColorSchemes().Lookup(L"scheme1");
auto scheme1 = winrt::get_self<ColorScheme>(scheme1Proj);

VERIFY_IS_NOT_NULL(settings->_FindMatchingColorScheme(scheme0Json));
Expand All @@ -267,16 +267,16 @@ namespace TerminalAppLocalTests
settings->_LayerOrCreateColorScheme(scheme3Json);

{
VERIFY_ARE_EQUAL(3u, settings->_globals->GetColorSchemes().Size());
VERIFY_ARE_EQUAL(3u, settings->_globals->ColorSchemes().Size());

VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme0");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme0"));
auto scheme0Proj = settings->_globals->ColorSchemes().Lookup(L"scheme0");
auto scheme0 = winrt::get_self<ColorScheme>(scheme0Proj);
VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->GetColorSchemes().Lookup(L"scheme1");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L"scheme1"));
auto scheme1Proj = settings->_globals->ColorSchemes().Lookup(L"scheme1");
auto scheme1 = winrt::get_self<ColorScheme>(scheme1Proj);
VERIFY_IS_TRUE(settings->_globals->GetColorSchemes().HasKey(L""));
auto scheme2Proj = settings->_globals->GetColorSchemes().Lookup(L"");
VERIFY_IS_TRUE(settings->_globals->ColorSchemes().HasKey(L""));
auto scheme2Proj = settings->_globals->ColorSchemes().Lookup(L"");
auto scheme2 = winrt::get_self<ColorScheme>(scheme2Proj);

VERIFY_IS_NOT_NULL(settings->_FindMatchingColorScheme(scheme0Json));
Expand Down
Loading

0 comments on commit abf8805

Please sign in to comment.