Introduce KeyMapping and Move TerminalSettings construction (#7537)
`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
This commit is contained in:
parent
c17f448d73
commit
abf8805e00
|
@ -195,7 +195,7 @@ 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));
|
||||
|
@ -203,15 +203,15 @@ namespace TerminalAppLocalTests
|
|||
|
||||
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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "../TerminalApp/ColorScheme.h"
|
||||
#include "../TerminalApp/CascadiaSettings.h"
|
||||
#include "../KeyMapping.h"
|
||||
#include "JsonTestClass.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
|
@ -66,18 +67,18 @@ namespace TerminalAppLocalTests
|
|||
const auto bindings1Json = VerifyParseSucceeded(bindings1String);
|
||||
const auto bindings2Json = VerifyParseSucceeded(bindings2String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<winrt::TerminalApp::implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(2u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(2u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(4u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(4u, keymap->_keyShortcuts.size());
|
||||
}
|
||||
|
||||
void KeyBindingsTests::LayerKeybindings()
|
||||
|
@ -90,18 +91,18 @@ namespace TerminalAppLocalTests
|
|||
const auto bindings1Json = VerifyParseSucceeded(bindings1String);
|
||||
const auto bindings2Json = VerifyParseSucceeded(bindings2String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<winrt::TerminalApp::implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(2u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(2u, keymap->_keyShortcuts.size());
|
||||
}
|
||||
|
||||
void KeyBindingsTests::UnbindKeybindings()
|
||||
|
@ -120,52 +121,52 @@ namespace TerminalAppLocalTests
|
|||
const auto bindings4Json = VerifyParseSucceeded(bindings4String);
|
||||
const auto bindings5Json = VerifyParseSucceeded(bindings5String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<winrt::TerminalApp::implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
appKeyBindings->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings1Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Try unbinding a key using `\"unbound\"` to unbind the key"));
|
||||
appKeyBindings->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Try unbinding a key using `null` to unbind the key"));
|
||||
// First add back a good binding
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
// Then try layering in the bad setting
|
||||
appKeyBindings->LayerJson(bindings3Json);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings3Json);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Try unbinding a key using an unrecognized command to unbind the key"));
|
||||
// First add back a good binding
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
// Then try layering in the bad setting
|
||||
appKeyBindings->LayerJson(bindings4Json);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings4Json);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Try unbinding a key using a straight up invalid value to unbind the key"));
|
||||
// First add back a good binding
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
// Then try layering in the bad setting
|
||||
appKeyBindings->LayerJson(bindings5Json);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings5Json);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Try unbinding a key that wasn't bound at all"));
|
||||
appKeyBindings->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings2Json);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
}
|
||||
|
||||
void KeyBindingsTests::TestArbitraryArgs()
|
||||
|
@ -189,17 +190,17 @@ namespace TerminalAppLocalTests
|
|||
|
||||
const auto bindings0Json = VerifyParseSucceeded(bindings0String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(10u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(10u, keymap->_keyShortcuts.size());
|
||||
|
||||
{
|
||||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `copy` without args parses as Copy(SingleLine=false)"));
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
// Verify the args have the expected value
|
||||
|
@ -210,7 +211,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `copy` with args parses them correctly"));
|
||||
KeyChord kc{ true, false, true, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
// Verify the args have the expected value
|
||||
|
@ -221,7 +222,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `copy` with args parses them correctly"));
|
||||
KeyChord kc{ false, true, true, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
// Verify the args have the expected value
|
||||
|
@ -232,7 +233,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `newTab` without args parses as NewTab(Index=null)"));
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('T') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -244,7 +245,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `newTab` parses args correctly"));
|
||||
KeyChord kc{ true, false, true, static_cast<int32_t>('T') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -258,7 +259,7 @@ namespace TerminalAppLocalTests
|
|||
L"Verify that `newTab` with an index greater than the legacy "
|
||||
L"args afforded parses correctly"));
|
||||
KeyChord kc{ true, false, true, static_cast<int32_t>('Y') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -272,7 +273,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `copy` ignores args it doesn't understand"));
|
||||
KeyChord kc{ true, false, true, static_cast<int32_t>('B') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::CopyText, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -284,7 +285,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `copy` null as it's `args` parses as the default option"));
|
||||
KeyChord kc{ true, false, true, static_cast<int32_t>('B') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::CopyText, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -296,7 +297,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `adjustFontSize` with a positive delta parses args correctly"));
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('F') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::AdjustFontSize, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<AdjustFontSizeArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -308,7 +309,7 @@ namespace TerminalAppLocalTests
|
|||
Log::Comment(NoThrowString().Format(
|
||||
L"Verify that `adjustFontSize` with a negative delta parses args correctly"));
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('G') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::AdjustFontSize, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<AdjustFontSizeArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -329,15 +330,15 @@ namespace TerminalAppLocalTests
|
|||
|
||||
const auto bindings0Json = VerifyParseSucceeded(bindings0String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(5u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(5u, keymap->_keyShortcuts.size());
|
||||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -346,7 +347,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('D') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -355,7 +356,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('E') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -364,7 +365,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('G') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -373,7 +374,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('H') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -392,15 +393,15 @@ namespace TerminalAppLocalTests
|
|||
|
||||
const auto bindings0Json = VerifyParseSucceeded(bindings0String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(3u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(3u, keymap->_keyShortcuts.size());
|
||||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SetTabColor, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SetTabColorArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -409,7 +410,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('D') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SetTabColor, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SetTabColorArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -420,7 +421,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('F') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SetTabColor, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SetTabColorArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -437,15 +438,15 @@ namespace TerminalAppLocalTests
|
|||
|
||||
const auto bindings0Json = VerifyParseSucceeded(bindings0String);
|
||||
|
||||
auto appKeyBindings = winrt::make_self<implementation::AppKeyBindings>();
|
||||
VERIFY_IS_NOT_NULL(appKeyBindings);
|
||||
VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size());
|
||||
appKeyBindings->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::make_self<winrt::TerminalApp::implementation::KeyMapping>();
|
||||
VERIFY_IS_NOT_NULL(keymap);
|
||||
VERIFY_ARE_EQUAL(0u, keymap->_keyShortcuts.size());
|
||||
keymap->LayerJson(bindings0Json);
|
||||
VERIFY_ARE_EQUAL(1u, keymap->_keyShortcuts.size());
|
||||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
// Verify the args have the expected value
|
||||
|
|
|
@ -119,13 +119,13 @@ namespace TerminalAppLocalTests
|
|||
|
||||
auto profile0 = implementation::Profile::FromJson(profile0Json);
|
||||
VERIFY_IS_NOT_NULL(profile0->Foreground());
|
||||
VERIFY_ARE_EQUAL(til::color(0, 0, 0, 0), til::color{ profile0->Foreground().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(0, 0, 0), til::color{ profile0->Foreground().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Background());
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1, 0), til::color{ profile0->Background().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1), til::color{ profile0->Background().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->SelectionBackground());
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1, 0), til::color{ profile0->SelectionBackground().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1), til::color{ profile0->SelectionBackground().Value() });
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile0", profile0->Name());
|
||||
|
||||
|
@ -136,13 +136,13 @@ namespace TerminalAppLocalTests
|
|||
profile0->LayerJson(profile1Json);
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Foreground());
|
||||
VERIFY_ARE_EQUAL(til::color(2, 2, 2, 0), til::color{ profile0->Foreground().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(2, 2, 2), til::color{ profile0->Foreground().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Background());
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1, 0), til::color{ profile0->Background().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1), til::color{ profile0->Background().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Background());
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1, 0), til::color{ profile0->Background().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1), til::color{ profile0->Background().Value() });
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile1", profile0->Name());
|
||||
|
||||
|
@ -154,13 +154,13 @@ namespace TerminalAppLocalTests
|
|||
profile0->LayerJson(profile2Json);
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Foreground());
|
||||
VERIFY_ARE_EQUAL(til::color(3, 3, 3, 0), til::color{ profile0->Foreground().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(3, 3, 3), til::color{ profile0->Foreground().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->Background());
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1, 0), til::color{ profile0->Background().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(1, 1, 1), til::color{ profile0->Background().Value() });
|
||||
|
||||
VERIFY_IS_NOT_NULL(profile0->SelectionBackground());
|
||||
VERIFY_ARE_EQUAL(til::color(2, 2, 2, 0), til::color{ profile0->SelectionBackground().Value() });
|
||||
VERIFY_ARE_EQUAL(til::color(2, 2, 2), til::color{ profile0->SelectionBackground().Value() });
|
||||
|
||||
VERIFY_ARE_EQUAL(L"profile2", profile0->Name());
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../TerminalApp/ColorScheme.h"
|
||||
#include "../TerminalApp/CascadiaSettings.h"
|
||||
#include "../TerminalApp/TerminalPage.h"
|
||||
#include "../TerminalApp/TerminalSettings.h"
|
||||
#include "JsonTestClass.h"
|
||||
#include "TestUtils.h"
|
||||
#include <defaults.h>
|
||||
|
@ -1329,7 +1330,7 @@ namespace TerminalAppLocalTests
|
|||
settings->LayerJson(settings->_userSettings);
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->GetColorSchemes().Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->ColorSchemes().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"schemeOne", settings->_profiles.GetAt(0).ColorSchemeName());
|
||||
VERIFY_ARE_EQUAL(L"InvalidSchemeName", settings->_profiles.GetAt(1).ColorSchemeName());
|
||||
|
@ -1341,7 +1342,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(winrt::TerminalApp::SettingsLoadWarnings::UnknownColorScheme, settings->_warnings.GetAt(0));
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->GetColorSchemes().Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->ColorSchemes().Size());
|
||||
|
||||
VERIFY_ARE_EQUAL(L"schemeOne", settings->_profiles.GetAt(0).ColorSchemeName());
|
||||
VERIFY_ARE_EQUAL(L"Campbell", settings->_profiles.GetAt(1).ColorSchemeName());
|
||||
|
@ -1428,7 +1429,7 @@ namespace TerminalAppLocalTests
|
|||
settings->_ParseJsonString(settingsJson, false);
|
||||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_NOT_EQUAL(0u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(expectedPath, settings->_profiles.GetAt(0).GetExpandedIconPath());
|
||||
VERIFY_ARE_EQUAL(expectedPath, settings->_profiles.GetAt(0).ExpandedIconPath());
|
||||
}
|
||||
void SettingsTests::TestProfileBackgroundImageWithEnvVar()
|
||||
{
|
||||
|
@ -1451,10 +1452,11 @@ namespace TerminalAppLocalTests
|
|||
settings->LayerJson(settings->_userSettings);
|
||||
VERIFY_ARE_NOT_EQUAL(0u, settings->_profiles.Size());
|
||||
|
||||
auto globalSettings{ winrt::make<implementation::GlobalAppSettings>() };
|
||||
const auto profileImpl = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(0));
|
||||
auto terminalSettings = profileImpl->CreateTerminalSettings(globalSettings.GetColorSchemes());
|
||||
VERIFY_ARE_EQUAL(expectedPath, terminalSettings.BackgroundImage());
|
||||
const auto globalSettings{ winrt::make<implementation::GlobalAppSettings>() };
|
||||
const auto profile = settings->_profiles.GetAt(0);
|
||||
const auto terminalSettings{ winrt::make_self<implementation::TerminalSettings>() };
|
||||
terminalSettings->_ApplyProfileSettings(profile, globalSettings.ColorSchemes());
|
||||
VERIFY_ARE_EQUAL(expectedPath, terminalSettings->BackgroundImage());
|
||||
}
|
||||
void SettingsTests::TestCloseOnExitParsing()
|
||||
{
|
||||
|
@ -1798,18 +1800,18 @@ namespace TerminalAppLocalTests
|
|||
settings->LayerJson(settings->_userSettings);
|
||||
settings->_ValidateSettings();
|
||||
|
||||
auto appKeyBindingsProj = settings->_globals->GetKeybindings();
|
||||
auto keymapProj = settings->_globals->KeyMap();
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
const auto profile2Guid = settings->_profiles.GetAt(2).Guid();
|
||||
VERIFY_ARE_NOT_EQUAL(winrt::guid{}, profile2Guid);
|
||||
|
||||
const auto appKeyBindings = winrt::get_self<implementation::AppKeyBindings>(appKeyBindingsProj);
|
||||
VERIFY_ARE_EQUAL(12u, appKeyBindings->_keyShortcuts.size());
|
||||
const auto keymap = winrt::get_self<implementation::KeyMapping>(keymapProj);
|
||||
VERIFY_ARE_EQUAL(12u, keymap->_keyShortcuts.size());
|
||||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('A') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1821,14 +1823,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(realArgs.TerminalArgs().TabTitle().empty());
|
||||
VERIFY_IS_TRUE(realArgs.TerminalArgs().Profile().empty());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid0, guid);
|
||||
VERIFY_ARE_EQUAL(L"cmd.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('B') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1841,14 +1843,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_FALSE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"{6239a42c-1111-49a3-80bd-e8fdd045185c}", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid1, guid);
|
||||
VERIFY_ARE_EQUAL(L"pwsh.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(2, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1861,14 +1863,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_FALSE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile1", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid1, guid);
|
||||
VERIFY_ARE_EQUAL(L"pwsh.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(2, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('D') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1881,14 +1883,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_FALSE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"profile2", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(profile2Guid, guid);
|
||||
VERIFY_ARE_EQUAL(L"wsl.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(3, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('E') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1901,14 +1903,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"foo.exe", realArgs.TerminalArgs().Commandline());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid0, guid);
|
||||
VERIFY_ARE_EQUAL(L"foo.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('F') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1922,14 +1924,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"profile1", realArgs.TerminalArgs().Profile());
|
||||
VERIFY_ARE_EQUAL(L"foo.exe", realArgs.TerminalArgs().Commandline());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid1, guid);
|
||||
VERIFY_ARE_EQUAL(L"foo.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(2, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('G') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1940,14 +1942,14 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(realArgs.TerminalArgs().TabTitle().empty());
|
||||
VERIFY_IS_TRUE(realArgs.TerminalArgs().Profile().empty());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid0, guid);
|
||||
VERIFY_ARE_EQUAL(L"cmd.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
|
||||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('H') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1959,7 +1961,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"c:\\foo", realArgs.TerminalArgs().StartingDirectory());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid0, guid);
|
||||
VERIFY_ARE_EQUAL(L"cmd.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(L"c:\\foo", termSettings.StartingDirectory());
|
||||
|
@ -1967,7 +1969,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('I') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -1980,7 +1982,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"c:\\foo", realArgs.TerminalArgs().StartingDirectory());
|
||||
VERIFY_ARE_EQUAL(L"profile2", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(profile2Guid, guid);
|
||||
VERIFY_ARE_EQUAL(L"wsl.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(L"c:\\foo", termSettings.StartingDirectory());
|
||||
|
@ -1988,7 +1990,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('J') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2000,7 +2002,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(realArgs.TerminalArgs().Profile().empty());
|
||||
VERIFY_ARE_EQUAL(L"bar", realArgs.TerminalArgs().TabTitle());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid0, guid);
|
||||
VERIFY_ARE_EQUAL(L"cmd.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(L"bar", termSettings.StartingTitle());
|
||||
|
@ -2008,7 +2010,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('K') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2021,7 +2023,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"bar", realArgs.TerminalArgs().TabTitle());
|
||||
VERIFY_ARE_EQUAL(L"profile2", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(profile2Guid, guid);
|
||||
VERIFY_ARE_EQUAL(L"wsl.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(L"bar", termSettings.StartingTitle());
|
||||
|
@ -2029,7 +2031,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('L') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<NewTabArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2044,7 +2046,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"bar", realArgs.TerminalArgs().TabTitle());
|
||||
VERIFY_ARE_EQUAL(L"profile1", realArgs.TerminalArgs().Profile());
|
||||
|
||||
const auto [guid, termSettings] = settings->BuildSettings(realArgs.TerminalArgs());
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, realArgs.TerminalArgs(), nullptr);
|
||||
VERIFY_ARE_EQUAL(guid1, guid);
|
||||
VERIFY_ARE_EQUAL(L"foo.exe", termSettings.Commandline());
|
||||
VERIFY_ARE_EQUAL(L"bar", termSettings.StartingTitle());
|
||||
|
@ -2119,7 +2121,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
try
|
||||
{
|
||||
auto terminalSettings = settings->BuildSettings(guid1);
|
||||
auto terminalSettings = winrt::make<implementation::TerminalSettings>(*settings, guid1, nullptr);
|
||||
VERIFY_ARE_NOT_EQUAL(nullptr, terminalSettings);
|
||||
VERIFY_ARE_EQUAL(1, terminalSettings.HistorySize());
|
||||
}
|
||||
|
@ -2130,7 +2132,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
try
|
||||
{
|
||||
auto terminalSettings = settings->BuildSettings(guid2);
|
||||
auto terminalSettings = winrt::make<implementation::TerminalSettings>(*settings, guid2, nullptr);
|
||||
VERIFY_ARE_NOT_EQUAL(nullptr, terminalSettings);
|
||||
VERIFY_ARE_EQUAL(2, terminalSettings.HistorySize());
|
||||
}
|
||||
|
@ -2139,11 +2141,11 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_IS_TRUE(false, L"This call to BuildSettings should succeed");
|
||||
}
|
||||
|
||||
VERIFY_THROWS(auto terminalSettings = settings->BuildSettings(guid3), wil::ResultException, L"This call to BuildSettings should fail");
|
||||
VERIFY_THROWS(auto terminalSettings = winrt::make<implementation::TerminalSettings>(*settings, guid3, nullptr), wil::ResultException, L"This call to BuildSettings should fail");
|
||||
|
||||
try
|
||||
{
|
||||
const auto [guid, termSettings] = settings->BuildSettings(nullptr);
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, nullptr, nullptr);
|
||||
VERIFY_ARE_NOT_EQUAL(nullptr, termSettings);
|
||||
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
|
||||
}
|
||||
|
@ -2184,7 +2186,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(settings->_globals->DefaultProfile(), settings->_profiles.GetAt(0).Guid());
|
||||
try
|
||||
{
|
||||
const auto [guid, termSettings] = settings->BuildSettings(nullptr);
|
||||
const auto [guid, termSettings] = implementation::TerminalSettings::BuildSettings(*settings, nullptr, nullptr);
|
||||
VERIFY_ARE_NOT_EQUAL(nullptr, termSettings);
|
||||
VERIFY_ARE_EQUAL(1, termSettings.HistorySize());
|
||||
}
|
||||
|
@ -2246,21 +2248,27 @@ namespace TerminalAppLocalTests
|
|||
settings->LayerJson(settings->_userSettings);
|
||||
|
||||
VERIFY_ARE_EQUAL(6u, settings->_profiles.Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->GetColorSchemes().Size());
|
||||
VERIFY_ARE_EQUAL(2u, settings->_globals->ColorSchemes().Size());
|
||||
|
||||
auto terminalSettings0 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(0))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto terminalSettings1 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(1))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto terminalSettings2 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(2))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto terminalSettings3 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(3))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto terminalSettings4 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(4))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto terminalSettings5 = winrt::get_self<implementation::Profile>(settings->_profiles.GetAt(5))->CreateTerminalSettings(settings->_globals->GetColorSchemes());
|
||||
auto createTerminalSettings = [&](const auto& profile, const auto& schemes) {
|
||||
auto terminalSettings{ winrt::make_self<implementation::TerminalSettings>() };
|
||||
terminalSettings->_ApplyProfileSettings(profile, schemes);
|
||||
return terminalSettings;
|
||||
};
|
||||
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x12, 0x34, 0x56), terminalSettings0.CursorColor()); // from color scheme
|
||||
VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1.CursorColor()); // default
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x23, 0x45, 0x67), terminalSettings2.CursorColor()); // from profile (trumps color scheme)
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x34, 0x56, 0x78), terminalSettings3.CursorColor()); // from profile (not set in color scheme)
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x45, 0x67, 0x89), terminalSettings4.CursorColor()); // from profile (no color scheme)
|
||||
VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings5.CursorColor()); // default
|
||||
auto terminalSettings0 = createTerminalSettings(settings->_profiles.GetAt(0), settings->_globals->ColorSchemes());
|
||||
auto terminalSettings1 = createTerminalSettings(settings->_profiles.GetAt(1), settings->_globals->ColorSchemes());
|
||||
auto terminalSettings2 = createTerminalSettings(settings->_profiles.GetAt(2), settings->_globals->ColorSchemes());
|
||||
auto terminalSettings3 = createTerminalSettings(settings->_profiles.GetAt(3), settings->_globals->ColorSchemes());
|
||||
auto terminalSettings4 = createTerminalSettings(settings->_profiles.GetAt(4), settings->_globals->ColorSchemes());
|
||||
auto terminalSettings5 = createTerminalSettings(settings->_profiles.GetAt(5), settings->_globals->ColorSchemes());
|
||||
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x12, 0x34, 0x56), terminalSettings0->CursorColor()); // from color scheme
|
||||
VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings1->CursorColor()); // default
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x23, 0x45, 0x67), terminalSettings2->CursorColor()); // from profile (trumps color scheme)
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x34, 0x56, 0x78), terminalSettings3->CursorColor()); // from profile (not set in color scheme)
|
||||
VERIFY_ARE_EQUAL(ARGB(0, 0x45, 0x67, 0x89), terminalSettings4->CursorColor()); // from profile (no color scheme)
|
||||
VERIFY_ARE_EQUAL(DEFAULT_CURSOR_COLOR, terminalSettings5->CursorColor()); // default
|
||||
}
|
||||
|
||||
void SettingsTests::ValidateKeybindingsWarnings()
|
||||
|
@ -2288,7 +2296,7 @@ namespace TerminalAppLocalTests
|
|||
const auto settingsObject = VerifyParseSucceeded(badSettings);
|
||||
auto settings = implementation::CascadiaSettings::FromJson(settingsObject);
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_globals->_keybindings->_keyShortcuts.size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_globals->_keymap->_keyShortcuts.size());
|
||||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_globals->_keybindingsWarnings.size());
|
||||
VERIFY_ARE_EQUAL(winrt::TerminalApp::SettingsLoadWarnings::TooManyKeysForChord, settings->_globals->_keybindingsWarnings.at(0));
|
||||
|
@ -2330,7 +2338,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
auto settings = implementation::CascadiaSettings::FromJson(settingsObject);
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_globals->_keybindings->_keyShortcuts.size());
|
||||
VERIFY_ARE_EQUAL(0u, settings->_globals->_keymap->_keyShortcuts.size());
|
||||
|
||||
for (const auto& warning : settings->_globals->_keybindingsWarnings)
|
||||
{
|
||||
|
@ -2471,18 +2479,18 @@ namespace TerminalAppLocalTests
|
|||
const auto profile2Guid = settings->_profiles.GetAt(2).Guid();
|
||||
VERIFY_ARE_NOT_EQUAL(winrt::guid{}, profile2Guid);
|
||||
|
||||
auto appKeyBindings = winrt::get_self<implementation::AppKeyBindings>(settings->_globals->GetKeybindings());
|
||||
VERIFY_ARE_EQUAL(5u, appKeyBindings->_keyShortcuts.size());
|
||||
auto keymap = winrt::get_self<implementation::KeyMapping>(settings->_globals->KeyMap());
|
||||
VERIFY_ARE_EQUAL(5u, keymap->_keyShortcuts.size());
|
||||
|
||||
// A/D, B, C, E will be in the list of commands, for 4 total.
|
||||
// * A and D share the same name, so they'll only generate a single action.
|
||||
// * F's name is set manually to `null`
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
VERIFY_ARE_EQUAL(4u, commands.Size());
|
||||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('A') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2499,7 +2507,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2513,7 +2521,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('D') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2527,7 +2535,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('E') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2541,7 +2549,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
{
|
||||
KeyChord kc{ true, false, false, static_cast<int32_t>('F') };
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc);
|
||||
auto actionAndArgs = TestUtils::GetActionAndArgs(*keymap, kc);
|
||||
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action());
|
||||
const auto& realArgs = actionAndArgs.Args().try_as<SplitPaneArgs>();
|
||||
VERIFY_IS_NOT_NULL(realArgs);
|
||||
|
@ -2672,7 +2680,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
||||
{
|
||||
|
@ -2693,7 +2701,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -2803,7 +2811,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
||||
{
|
||||
|
@ -2824,7 +2832,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${profile.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -2936,7 +2944,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
||||
{
|
||||
|
@ -2958,7 +2966,7 @@ namespace TerminalAppLocalTests
|
|||
}
|
||||
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3078,9 +3086,9 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3187,9 +3195,9 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3327,9 +3335,9 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3481,9 +3489,9 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3595,9 +3603,9 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
@ -3757,7 +3765,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
_logCommandNames(commands);
|
||||
|
||||
|
@ -3834,7 +3842,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
_logCommandNames(commands);
|
||||
|
||||
|
@ -3917,7 +3925,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
settings->_ValidateSettings();
|
||||
_logCommandNames(commands);
|
||||
|
||||
|
@ -3995,7 +4003,7 @@ namespace TerminalAppLocalTests
|
|||
{ "name": "scheme_1" },
|
||||
{ "name": "scheme_2" },
|
||||
],
|
||||
"bindings": [
|
||||
"actions": [
|
||||
{
|
||||
"name": "iterable command ${scheme.name}",
|
||||
"iterateOn": "schemes",
|
||||
|
@ -4014,7 +4022,7 @@ namespace TerminalAppLocalTests
|
|||
|
||||
VERIFY_ARE_EQUAL(3u, settings->_profiles.Size());
|
||||
|
||||
auto commands = settings->_globals->GetCommands();
|
||||
auto commands = settings->_globals->Commands();
|
||||
VERIFY_ARE_EQUAL(1u, commands.Size());
|
||||
|
||||
{
|
||||
|
@ -4035,7 +4043,7 @@ namespace TerminalAppLocalTests
|
|||
VERIFY_ARE_EQUAL(L"${scheme.name}", realArgs.TerminalArgs().Profile());
|
||||
}
|
||||
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->GetColorSchemes());
|
||||
auto expandedCommands = implementation::TerminalPage::_ExpandCommands(commands, settings->Profiles().GetView(), settings->_globals->ColorSchemes());
|
||||
_logCommandNames(expandedCommands.GetView());
|
||||
|
||||
VERIFY_ARE_EQUAL(0u, settings->_warnings.Size());
|
||||
|
|
|
@ -19,11 +19,11 @@ public:
|
|||
// - This is a helper to retrieve the ActionAndArgs from the keybindings
|
||||
// for a given chord.
|
||||
// Arguments:
|
||||
// - bindings: The AppKeyBindings to lookup the ActionAndArgs from.
|
||||
// - keymap: The AppKeyBindings to lookup the ActionAndArgs from.
|
||||
// - kc: The key chord to look up the bound ActionAndArgs for.
|
||||
// Return Value:
|
||||
// - The ActionAndArgs bound to the given key, or nullptr if nothing is bound to it.
|
||||
static const winrt::TerminalApp::ActionAndArgs GetActionAndArgs(const winrt::TerminalApp::implementation::AppKeyBindings& bindings,
|
||||
static const winrt::TerminalApp::ActionAndArgs GetActionAndArgs(const winrt::TerminalApp::implementation::KeyMapping& keymap,
|
||||
const winrt::Microsoft::Terminal::TerminalControl::KeyChord& kc)
|
||||
{
|
||||
std::wstring buffer{ L"" };
|
||||
|
@ -42,12 +42,8 @@ public:
|
|||
buffer += static_cast<wchar_t>(MapVirtualKeyW(kc.Vkey(), MAPVK_VK_TO_CHAR));
|
||||
WEX::Logging::Log::Comment(WEX::Common::NoThrowString().Format(L"Looking for key:%s", buffer.c_str()));
|
||||
|
||||
const auto keyIter = bindings._keyShortcuts.find(kc);
|
||||
VERIFY_IS_TRUE(keyIter != bindings._keyShortcuts.end(), L"Expected to find an action bound to the given KeyChord");
|
||||
if (keyIter != bindings._keyShortcuts.end())
|
||||
{
|
||||
return keyIter->second;
|
||||
}
|
||||
return nullptr;
|
||||
const auto action = keymap.TryLookup(kc);
|
||||
VERIFY_IS_NOT_NULL(action, L"Expected to find an action bound to the given KeyChord");
|
||||
return action;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -319,11 +319,11 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
if (auto activeControl = activeTab->GetActiveTerminalControl())
|
||||
{
|
||||
auto controlSettings = activeControl.Settings();
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
if (settingsImpl->ApplyColorScheme(controlSettings, realArgs.SchemeName()))
|
||||
if (const auto scheme = _settings.GlobalSettings().ColorSchemes().TryLookup(realArgs.SchemeName()))
|
||||
{
|
||||
activeControl.UpdateSettings(controlSettings);
|
||||
auto controlSettings = activeControl.Settings().as<TerminalSettings>();
|
||||
controlSettings->ApplyColorScheme(scheme);
|
||||
activeControl.UpdateSettings(*controlSettings);
|
||||
args.Handled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include "pch.h"
|
||||
#include "AppKeyBindings.h"
|
||||
#include "KeyChordSerialization.h"
|
||||
|
||||
#include "AppKeyBindings.g.cpp"
|
||||
|
||||
|
@ -13,71 +12,11 @@ using namespace winrt::Microsoft::Terminal::TerminalControl;
|
|||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
void AppKeyBindings::SetKeyBinding(const TerminalApp::ActionAndArgs& actionAndArgs,
|
||||
const KeyChord& chord)
|
||||
{
|
||||
_keyShortcuts[chord] = actionAndArgs;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Remove the action that's bound to a particular KeyChord.
|
||||
// Arguments:
|
||||
// - chord: the keystroke to remove the action for.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void AppKeyBindings::ClearKeyBinding(const KeyChord& chord)
|
||||
{
|
||||
_keyShortcuts.erase(chord);
|
||||
}
|
||||
|
||||
KeyChord AppKeyBindings::GetKeyBindingForAction(TerminalApp::ShortcutAction const& action)
|
||||
{
|
||||
for (auto& kv : _keyShortcuts)
|
||||
{
|
||||
if (kv.second.Action() == action)
|
||||
{
|
||||
return kv.first;
|
||||
}
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Lookup the keychord bound to a particular combination of ShortcutAction
|
||||
// and IActionArgs. This enables searching no only for the binding of a
|
||||
// particular ShortcutAction, but also a particular set of values for
|
||||
// arguments to that action.
|
||||
// Arguments:
|
||||
// - actionAndArgs: The ActionAndArgs to lookup the keybinding for.
|
||||
// Return Value:
|
||||
// - The bound keychord, if this ActionAndArgs is bound to a key, otherwise nullptr.
|
||||
KeyChord AppKeyBindings::GetKeyBindingForActionWithArgs(TerminalApp::ActionAndArgs const& actionAndArgs)
|
||||
{
|
||||
if (actionAndArgs == nullptr)
|
||||
{
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
for (auto& kv : _keyShortcuts)
|
||||
{
|
||||
const auto action = kv.second.Action();
|
||||
const auto args = kv.second.Args();
|
||||
const auto actionMatched = action == actionAndArgs.Action();
|
||||
const auto argsMatched = args ? args.Equals(actionAndArgs.Args()) : args == actionAndArgs.Args();
|
||||
if (actionMatched && argsMatched)
|
||||
{
|
||||
return kv.first;
|
||||
}
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
bool AppKeyBindings::TryKeyChord(const KeyChord& kc)
|
||||
{
|
||||
const auto keyIter = _keyShortcuts.find(kc);
|
||||
if (keyIter != _keyShortcuts.end())
|
||||
const auto actionAndArgs = _keymap.TryLookup(kc);
|
||||
if (actionAndArgs)
|
||||
{
|
||||
const auto actionAndArgs = keyIter->second;
|
||||
return _dispatch.DoAction(actionAndArgs);
|
||||
}
|
||||
return false;
|
||||
|
@ -88,28 +27,8 @@ namespace winrt::TerminalApp::implementation
|
|||
_dispatch = dispatch;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Takes the KeyModifier flags from Terminal and maps them to the WinRT types which are used by XAML
|
||||
// Return Value:
|
||||
// - a Windows::System::VirtualKeyModifiers object with the flags of which modifiers used.
|
||||
Windows::System::VirtualKeyModifiers AppKeyBindings::ConvertVKModifiers(KeyModifiers modifiers)
|
||||
void AppKeyBindings::SetKeyMapping(const winrt::TerminalApp::KeyMapping& keymap)
|
||||
{
|
||||
Windows::System::VirtualKeyModifiers keyModifiers = Windows::System::VirtualKeyModifiers::None;
|
||||
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Ctrl))
|
||||
{
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Control;
|
||||
}
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Shift))
|
||||
{
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Shift;
|
||||
}
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Alt))
|
||||
{
|
||||
// note: Menu is the Alt VK_MENU
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Menu;
|
||||
}
|
||||
|
||||
return keyModifiers;
|
||||
_keymap = keymap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,48 +18,17 @@ namespace TerminalAppLocalTests
|
|||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct KeyChordHash
|
||||
{
|
||||
std::size_t operator()(const winrt::Microsoft::Terminal::TerminalControl::KeyChord& key) const
|
||||
{
|
||||
std::hash<int32_t> keyHash;
|
||||
std::hash<winrt::Microsoft::Terminal::TerminalControl::KeyModifiers> modifiersHash;
|
||||
std::size_t hashedKey = keyHash(key.Vkey());
|
||||
std::size_t hashedMods = modifiersHash(key.Modifiers());
|
||||
return hashedKey ^ hashedMods;
|
||||
}
|
||||
};
|
||||
|
||||
struct KeyChordEquality
|
||||
{
|
||||
bool operator()(const winrt::Microsoft::Terminal::TerminalControl::KeyChord& lhs, const winrt::Microsoft::Terminal::TerminalControl::KeyChord& rhs) const
|
||||
{
|
||||
return lhs.Modifiers() == rhs.Modifiers() && lhs.Vkey() == rhs.Vkey();
|
||||
}
|
||||
};
|
||||
|
||||
struct AppKeyBindings : AppKeyBindingsT<AppKeyBindings>
|
||||
{
|
||||
AppKeyBindings() = default;
|
||||
|
||||
bool TryKeyChord(winrt::Microsoft::Terminal::TerminalControl::KeyChord const& kc);
|
||||
|
||||
void SetKeyBinding(TerminalApp::ActionAndArgs const& actionAndArgs,
|
||||
winrt::Microsoft::Terminal::TerminalControl::KeyChord const& chord);
|
||||
void ClearKeyBinding(winrt::Microsoft::Terminal::TerminalControl::KeyChord const& chord);
|
||||
Microsoft::Terminal::TerminalControl::KeyChord GetKeyBindingForAction(TerminalApp::ShortcutAction const& action);
|
||||
Microsoft::Terminal::TerminalControl::KeyChord GetKeyBindingForActionWithArgs(TerminalApp::ActionAndArgs const& actionAndArgs);
|
||||
|
||||
static Windows::System::VirtualKeyModifiers ConvertVKModifiers(winrt::Microsoft::Terminal::TerminalControl::KeyModifiers modifiers);
|
||||
|
||||
// Defined in AppKeyBindingsSerialization.cpp
|
||||
std::vector<TerminalApp::SettingsLoadWarnings> LayerJson(const Json::Value& json);
|
||||
Json::Value ToJson();
|
||||
|
||||
void SetDispatch(const winrt::TerminalApp::ShortcutActionDispatch& dispatch);
|
||||
void SetKeyMapping(const winrt::TerminalApp::KeyMapping& keymap);
|
||||
|
||||
private:
|
||||
std::unordered_map<winrt::Microsoft::Terminal::TerminalControl::KeyChord, TerminalApp::ActionAndArgs, KeyChordHash, KeyChordEquality> _keyShortcuts;
|
||||
winrt::TerminalApp::KeyMapping _keymap{ nullptr };
|
||||
|
||||
winrt::TerminalApp::ShortcutActionDispatch _dispatch{ nullptr };
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import "ActionArgs.idl";
|
||||
import "ShortcutActionDispatch.idl";
|
||||
import "KeyMapping.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
|
@ -9,12 +9,7 @@ namespace TerminalApp
|
|||
{
|
||||
AppKeyBindings();
|
||||
|
||||
void SetKeyBinding(ActionAndArgs actionAndArgs, Microsoft.Terminal.TerminalControl.KeyChord chord);
|
||||
void ClearKeyBinding(Microsoft.Terminal.TerminalControl.KeyChord chord);
|
||||
|
||||
Microsoft.Terminal.TerminalControl.KeyChord GetKeyBindingForAction(ShortcutAction action);
|
||||
Microsoft.Terminal.TerminalControl.KeyChord GetKeyBindingForActionWithArgs(ActionAndArgs actionAndArgs);
|
||||
|
||||
void SetDispatch(ShortcutActionDispatch dispatch);
|
||||
void SetKeyMapping(KeyMapping keymap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -494,8 +494,7 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
|
||||
// Use the default profile to determine how big of a window we need.
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
const auto [_, settings] = settingsImpl->BuildSettings(nullptr);
|
||||
const auto [_, settings] = TerminalSettings::BuildSettings(_settings, nullptr, nullptr);
|
||||
|
||||
auto proposedSize = TermControl::GetProposedDimensions(settings, dpi);
|
||||
|
||||
|
|
|
@ -100,9 +100,9 @@ IObservableVector<winrt::TerminalApp::Profile> CascadiaSettings::Profiles() cons
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - the globally configured keybindings
|
||||
winrt::TerminalApp::AppKeyBindings CascadiaSettings::Keybindings() const noexcept
|
||||
winrt::TerminalApp::KeyMapping CascadiaSettings::KeyMap() const noexcept
|
||||
{
|
||||
return _globals->GetKeybindings();
|
||||
return _globals->KeyMap();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -111,7 +111,7 @@ winrt::TerminalApp::AppKeyBindings CascadiaSettings::Keybindings() const noexcep
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - a reference to our global settings
|
||||
winrt::TerminalApp::GlobalAppSettings CascadiaSettings::GlobalSettings()
|
||||
winrt::TerminalApp::GlobalAppSettings CascadiaSettings::GlobalSettings() const
|
||||
{
|
||||
return *_globals;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ void CascadiaSettings::_ValidateAllSchemesExist()
|
|||
for (auto profile : _profiles)
|
||||
{
|
||||
const auto schemeName = profile.ColorSchemeName();
|
||||
if (!_globals->GetColorSchemes().HasKey(schemeName))
|
||||
if (!_globals->ColorSchemes().HasKey(schemeName))
|
||||
{
|
||||
profile.ColorSchemeName({ L"Campbell" });
|
||||
foundInvalidScheme = true;
|
||||
|
@ -453,7 +453,7 @@ void CascadiaSettings::_ValidateMediaResources()
|
|||
// This covers file paths on the machine, app data, URLs, and other resource paths.
|
||||
try
|
||||
{
|
||||
winrt::Windows::Foundation::Uri imagePath{ profile.GetExpandedBackgroundImagePath() };
|
||||
winrt::Windows::Foundation::Uri imagePath{ profile.ExpandedBackgroundImagePath() };
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ void CascadiaSettings::_ValidateMediaResources()
|
|||
{
|
||||
try
|
||||
{
|
||||
winrt::Windows::Foundation::Uri imagePath{ profile.GetExpandedIconPath() };
|
||||
winrt::Windows::Foundation::Uri imagePath{ profile.ExpandedIconPath() };
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
@ -489,68 +489,6 @@ void CascadiaSettings::_ValidateMediaResources()
|
|||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Create a TerminalSettings object for the provided newTerminalArgs. We'll
|
||||
// use the newTerminalArgs to look up the profile that should be used to
|
||||
// create these TerminalSettings. Then, we'll apply settings contained in the
|
||||
// newTerminalArgs to the profile's settings, to enable customization on top
|
||||
// of the profile's default values.
|
||||
// Arguments:
|
||||
// - newTerminalArgs: An object that may contain a profile name or GUID to
|
||||
// actually use. If the Profile value is not a guid, we'll treat it as a name,
|
||||
// and attempt to look the profile up by name instead.
|
||||
// * Additionally, we'll use other values (such as Commandline,
|
||||
// StartingDirectory) in this object to override the settings directly from
|
||||
// the profile.
|
||||
// Return Value:
|
||||
// - the GUID of the created profile, and a fully initialized TerminalSettings object
|
||||
std::tuple<winrt::guid, winrt::TerminalApp::TerminalSettings> CascadiaSettings::BuildSettings(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const
|
||||
{
|
||||
const winrt::guid profileGuid = _GetProfileForArgs(newTerminalArgs);
|
||||
auto settings = BuildSettings(profileGuid);
|
||||
|
||||
if (newTerminalArgs)
|
||||
{
|
||||
// Override commandline, starting directory if they exist in newTerminalArgs
|
||||
if (!newTerminalArgs.Commandline().empty())
|
||||
{
|
||||
settings.Commandline(newTerminalArgs.Commandline());
|
||||
}
|
||||
if (!newTerminalArgs.StartingDirectory().empty())
|
||||
{
|
||||
settings.StartingDirectory(newTerminalArgs.StartingDirectory());
|
||||
}
|
||||
if (!newTerminalArgs.TabTitle().empty())
|
||||
{
|
||||
settings.StartingTitle(newTerminalArgs.TabTitle());
|
||||
}
|
||||
}
|
||||
|
||||
return { profileGuid, settings };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Create a TerminalSettings object for the profile with a GUID matching the
|
||||
// provided GUID. If no profile matches this GUID, then this method will
|
||||
// throw.
|
||||
// Arguments:
|
||||
// - profileGuid: The GUID of a profile to use to create a settings object for.
|
||||
// Return Value:
|
||||
// - a fully initialized TerminalSettings object
|
||||
winrt::TerminalApp::TerminalSettings CascadiaSettings::BuildSettings(winrt::guid profileGuid) const
|
||||
{
|
||||
const auto profile = FindProfile(profileGuid);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, profile);
|
||||
|
||||
const auto profileImpl = winrt::get_self<Profile>(profile);
|
||||
auto result = profileImpl->CreateTerminalSettings(_globals->GetColorSchemes());
|
||||
|
||||
// Place our appropriate global settings into the Terminal Settings
|
||||
_globals->ApplyToSettings(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper to get the GUID of a profile, given an optional index and a possible
|
||||
// "profile" value to override that.
|
||||
|
@ -567,7 +505,7 @@ winrt::TerminalApp::TerminalSettings CascadiaSettings::BuildSettings(winrt::guid
|
|||
// and attempt to look the profile up by name instead.
|
||||
// Return Value:
|
||||
// - the GUID of the profile corresponding to this combination of index and NewTerminalArgs
|
||||
winrt::guid CascadiaSettings::_GetProfileForArgs(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const
|
||||
winrt::guid CascadiaSettings::GetProfileForArgs(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const
|
||||
{
|
||||
std::optional<winrt::guid> profileByIndex, profileByName;
|
||||
if (newTerminalArgs)
|
||||
|
@ -667,7 +605,7 @@ std::optional<winrt::guid> CascadiaSettings::_GetProfileGuidByIndex(std::optiona
|
|||
// - <none>
|
||||
void CascadiaSettings::_ValidateKeybindings()
|
||||
{
|
||||
auto keybindingWarnings = _globals->GetKeybindingsWarnings();
|
||||
auto keybindingWarnings = _globals->KeybindingsWarnings();
|
||||
|
||||
if (!keybindingWarnings.empty())
|
||||
{
|
||||
|
@ -756,25 +694,5 @@ winrt::TerminalApp::ColorScheme CascadiaSettings::GetColorSchemeForProfile(const
|
|||
return nullptr;
|
||||
}
|
||||
const auto schemeName = profile.ColorSchemeName();
|
||||
return _globals->GetColorSchemes().TryLookup(schemeName);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Apply the color scheme (provided by name) to the given IControlSettings.
|
||||
// The settings are modified in-place.
|
||||
// - If the name doesn't correspond to any of our schemes, this does nothing.
|
||||
// Arguments:
|
||||
// - settings: the IControlSettings object to modify
|
||||
// - name: the name of the scheme to apply
|
||||
// Return Value:
|
||||
// - true iff we found a matching scheme for the name schemeName
|
||||
bool CascadiaSettings::ApplyColorScheme(winrt::Microsoft::Terminal::TerminalControl::IControlSettings settings,
|
||||
winrt::hstring schemeName)
|
||||
{
|
||||
if (auto scheme{ _globals->GetColorSchemes().TryLookup(schemeName) })
|
||||
{
|
||||
scheme.ApplyScheme(settings);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return _globals->ColorSchemes().TryLookup(schemeName);
|
||||
}
|
||||
|
|
|
@ -66,14 +66,11 @@ namespace winrt::TerminalApp::implementation
|
|||
static TerminalApp::CascadiaSettings LoadAll();
|
||||
static TerminalApp::CascadiaSettings LoadUniversal();
|
||||
|
||||
std::tuple<guid, TerminalApp::TerminalSettings> BuildSettings(const TerminalApp::NewTerminalArgs& newTerminalArgs) const;
|
||||
TerminalApp::TerminalSettings BuildSettings(guid profileGuid) const;
|
||||
|
||||
TerminalApp::GlobalAppSettings GlobalSettings();
|
||||
TerminalApp::GlobalAppSettings GlobalSettings() const;
|
||||
|
||||
Windows::Foundation::Collections::IObservableVector<winrt::TerminalApp::Profile> Profiles() const noexcept;
|
||||
|
||||
TerminalApp::AppKeyBindings Keybindings() const noexcept;
|
||||
TerminalApp::KeyMapping KeyMap() const noexcept;
|
||||
|
||||
static std::unique_ptr<CascadiaSettings> FromJson(const Json::Value& json);
|
||||
void LayerJson(const Json::Value& json);
|
||||
|
@ -88,7 +85,7 @@ namespace winrt::TerminalApp::implementation
|
|||
Windows::Foundation::IReference<SettingsLoadErrors> GetLoadingError();
|
||||
hstring GetSerializationErrorMessage();
|
||||
|
||||
bool ApplyColorScheme(Microsoft::Terminal::TerminalControl::IControlSettings settings, hstring schemeName);
|
||||
winrt::guid GetProfileForArgs(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const;
|
||||
|
||||
private:
|
||||
com_ptr<GlobalAppSettings> _globals;
|
||||
|
@ -126,7 +123,6 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
std::optional<guid> _GetProfileGuidByName(const hstring) const;
|
||||
std::optional<guid> _GetProfileGuidByIndex(std::optional<int> index) const;
|
||||
guid _GetProfileForArgs(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs) const;
|
||||
|
||||
void _ValidateSettings();
|
||||
void _ValidateProfilesExist();
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace TerminalApp
|
|||
|
||||
Windows.Foundation.Collections.IObservableVector<Profile> Profiles { get; };
|
||||
|
||||
AppKeyBindings Keybindings { get; };
|
||||
KeyMapping KeyMap { get; };
|
||||
|
||||
Windows.Foundation.Collections.IVectorView<SettingsLoadWarnings> Warnings { get; };
|
||||
Windows.Foundation.IReference<SettingsLoadErrors> GetLoadingError { get; };
|
||||
|
@ -24,5 +24,7 @@ namespace TerminalApp
|
|||
|
||||
Profile FindProfile(Guid profileGuid);
|
||||
ColorScheme GetColorSchemeForProfile(Guid profileGuid);
|
||||
|
||||
Guid GetProfileForArgs(NewTerminalArgs newTerminalArgs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,9 +220,9 @@ winrt::TerminalApp::CascadiaSettings CascadiaSettings::LoadAll()
|
|||
|
||||
// Run it through the object so we can parse it apart and then only serialize the fields we're interested in
|
||||
// and avoid extraneous data.
|
||||
auto akb = winrt::make_self<AppKeyBindings>();
|
||||
akb->LayerJson(userKeybindings);
|
||||
auto value = akb->ToJson();
|
||||
auto km = winrt::make_self<implementation::KeyMapping>();
|
||||
km->LayerJson(userKeybindings);
|
||||
auto value = km->ToJson();
|
||||
|
||||
// Reserialize the keybindings
|
||||
Json::StreamWriterBuilder wbuilder;
|
||||
|
@ -760,7 +760,7 @@ winrt::com_ptr<ColorScheme> CascadiaSettings::_FindMatchingColorScheme(const Jso
|
|||
{
|
||||
if (auto schemeName = ColorScheme::GetNameFromJson(schemeJson))
|
||||
{
|
||||
if (auto scheme{ _globals->GetColorSchemes().TryLookup(*schemeName) })
|
||||
if (auto scheme{ _globals->ColorSchemes().TryLookup(*schemeName) })
|
||||
{
|
||||
return winrt::get_self<ColorScheme>(scheme)->get_strong();
|
||||
}
|
||||
|
|
|
@ -63,27 +63,6 @@ ColorScheme::~ColorScheme()
|
|||
{
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Apply our values to the given TerminalSettings object. Sets the foreground,
|
||||
// background, and color table of the settings object.
|
||||
// Arguments:
|
||||
// - terminalSettings: the object to apply our settings to.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void ColorScheme::ApplyScheme(const winrt::Microsoft::Terminal::TerminalControl::IControlSettings& terminalSettings) const
|
||||
{
|
||||
terminalSettings.DefaultForeground(static_cast<COLORREF>(_defaultForeground));
|
||||
terminalSettings.DefaultBackground(static_cast<COLORREF>(_defaultBackground));
|
||||
terminalSettings.SelectionBackground(static_cast<COLORREF>(_selectionBackground));
|
||||
terminalSettings.CursorColor(static_cast<COLORREF>(_cursorColor));
|
||||
|
||||
auto const tableCount = gsl::narrow_cast<int>(_table.size());
|
||||
for (int i = 0; i < tableCount; i++)
|
||||
{
|
||||
terminalSettings.SetColorTableEntry(i, static_cast<COLORREF>(_table[i]));
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Create a new instance of this class from a serialized JsonObject.
|
||||
// Arguments:
|
||||
|
|
|
@ -15,8 +15,8 @@ Author(s):
|
|||
|
||||
--*/
|
||||
#pragma once
|
||||
#include "TerminalSettings.h"
|
||||
#include "../../inc/conattrs.hpp"
|
||||
#include "inc/cppwinrt_utils.h"
|
||||
|
||||
#include "ColorScheme.g.h"
|
||||
|
||||
|
@ -36,8 +36,6 @@ namespace winrt::TerminalApp::implementation
|
|||
ColorScheme(hstring name, Windows::UI::Color defaultFg, Windows::UI::Color defaultBg, Windows::UI::Color cursorColor);
|
||||
~ColorScheme();
|
||||
|
||||
void ApplyScheme(const winrt::Microsoft::Terminal::TerminalControl::IControlSettings& terminalSettings) const;
|
||||
|
||||
static com_ptr<ColorScheme> FromJson(const Json::Value& json);
|
||||
bool ShouldBeLayered(const Json::Value& json) const;
|
||||
void LayerJson(const Json::Value& json);
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace TerminalApp
|
|||
ColorScheme();
|
||||
ColorScheme(String name, Windows.UI.Color defaultFg, Windows.UI.Color defaultBg, Windows.UI.Color cursorColor);
|
||||
|
||||
void ApplyScheme(Microsoft.Terminal.TerminalControl.IControlSettings terminalSettings);
|
||||
|
||||
String Name { get; };
|
||||
|
||||
Windows.UI.Color Foreground { get; };
|
||||
|
|
|
@ -467,7 +467,7 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
// - Escape the profile name for JSON appropriately
|
||||
auto escapedProfileName = _escapeForJson(til::u16u8(p.Name()));
|
||||
auto escapedProfileIcon = _escapeForJson(til::u16u8(p.GetExpandedIconPath()));
|
||||
auto escapedProfileIcon = _escapeForJson(til::u16u8(p.ExpandedIconPath()));
|
||||
auto newJsonString = til::replace_needle_in_haystack(oldJsonString,
|
||||
ProfileNameToken,
|
||||
escapedProfileName);
|
||||
|
|
|
@ -53,7 +53,7 @@ static constexpr bool debugFeaturesDefault{ false };
|
|||
#endif
|
||||
|
||||
GlobalAppSettings::GlobalAppSettings() :
|
||||
_keybindings{ winrt::make_self<AppKeyBindings>() },
|
||||
_keymap{ winrt::make_self<KeyMapping>() },
|
||||
_keybindingsWarnings{},
|
||||
_unparsedDefaultProfile{},
|
||||
_defaultProfile{},
|
||||
|
@ -63,7 +63,7 @@ GlobalAppSettings::GlobalAppSettings() :
|
|||
_colorSchemes = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::ColorScheme>();
|
||||
}
|
||||
|
||||
winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, winrt::TerminalApp::ColorScheme> GlobalAppSettings::GetColorSchemes() noexcept
|
||||
winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, winrt::TerminalApp::ColorScheme> GlobalAppSettings::ColorSchemes() noexcept
|
||||
{
|
||||
return _colorSchemes.GetView();
|
||||
}
|
||||
|
@ -86,28 +86,9 @@ winrt::hstring GlobalAppSettings::UnparsedDefaultProfile() const
|
|||
return _unparsedDefaultProfile;
|
||||
}
|
||||
|
||||
winrt::TerminalApp::AppKeyBindings GlobalAppSettings::GetKeybindings() const noexcept
|
||||
winrt::TerminalApp::KeyMapping GlobalAppSettings::KeyMap() const noexcept
|
||||
{
|
||||
return *_keybindings;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Applies appropriate settings from the globals into the given TerminalSettings.
|
||||
// Arguments:
|
||||
// - settings: a TerminalSettings object to add global property values to.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void GlobalAppSettings::ApplyToSettings(const TerminalApp::TerminalSettings& settings) const noexcept
|
||||
{
|
||||
settings.KeyBindings(GetKeybindings());
|
||||
settings.InitialRows(_InitialRows);
|
||||
settings.InitialCols(_InitialCols);
|
||||
|
||||
settings.WordDelimiters(_WordDelimiters);
|
||||
settings.CopyOnSelect(_CopyOnSelect);
|
||||
settings.ForceFullRepaintRendering(_ForceFullRepaintRendering);
|
||||
settings.SoftwareRendering(_SoftwareRendering);
|
||||
settings.ForceVTInput(_ForceVTInput);
|
||||
return *_keymap;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -179,7 +160,7 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
|
|||
auto parseBindings = [this, &json](auto jsonKey) {
|
||||
if (auto bindings{ json[JsonKey(jsonKey)] })
|
||||
{
|
||||
auto warnings = _keybindings->LayerJson(bindings);
|
||||
auto warnings = _keymap->LayerJson(bindings);
|
||||
// It's possible that the user provided keybindings have some warnings
|
||||
// in them - problems that we should alert the user to, but we can
|
||||
// recover from. Most of these warnings cannot be detected later in the
|
||||
|
@ -190,8 +171,6 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
|
|||
|
||||
// Now parse the array again, but this time as a list of commands.
|
||||
warnings = winrt::TerminalApp::implementation::Command::LayerJson(_commands, bindings);
|
||||
// It's possible that the user provided commands have some warnings
|
||||
// in them, similar to the keybindings.
|
||||
}
|
||||
};
|
||||
parseBindings(LegacyKeybindingsKey);
|
||||
|
@ -218,12 +197,12 @@ void GlobalAppSettings::AddColorScheme(const winrt::TerminalApp::ColorScheme& sc
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
std::vector<winrt::TerminalApp::SettingsLoadWarnings> GlobalAppSettings::GetKeybindingsWarnings() const
|
||||
std::vector<winrt::TerminalApp::SettingsLoadWarnings> GlobalAppSettings::KeybindingsWarnings() const
|
||||
{
|
||||
return _keybindingsWarnings;
|
||||
}
|
||||
|
||||
winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, winrt::TerminalApp::Command> GlobalAppSettings::GetCommands() noexcept
|
||||
winrt::Windows::Foundation::Collections::IMapView<winrt::hstring, winrt::TerminalApp::Command> GlobalAppSettings::Commands() noexcept
|
||||
{
|
||||
return _commands.GetView();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ Author(s):
|
|||
|
||||
#include "GlobalAppSettings.g.h"
|
||||
|
||||
#include "AppKeyBindings.h"
|
||||
#include "KeyMapping.h"
|
||||
#include "Command.h"
|
||||
#include "ColorScheme.h"
|
||||
|
||||
|
@ -35,19 +35,17 @@ namespace winrt::TerminalApp::implementation
|
|||
public:
|
||||
GlobalAppSettings();
|
||||
|
||||
Windows::Foundation::Collections::IMapView<hstring, TerminalApp::ColorScheme> GetColorSchemes() noexcept;
|
||||
Windows::Foundation::Collections::IMapView<hstring, TerminalApp::ColorScheme> ColorSchemes() noexcept;
|
||||
void AddColorScheme(const TerminalApp::ColorScheme& scheme);
|
||||
|
||||
TerminalApp::AppKeyBindings GetKeybindings() const noexcept;
|
||||
TerminalApp::KeyMapping KeyMap() const noexcept;
|
||||
|
||||
static com_ptr<GlobalAppSettings> FromJson(const Json::Value& json);
|
||||
void LayerJson(const Json::Value& json);
|
||||
|
||||
void ApplyToSettings(const TerminalApp::TerminalSettings& settings) const noexcept;
|
||||
std::vector<TerminalApp::SettingsLoadWarnings> KeybindingsWarnings() const;
|
||||
|
||||
std::vector<TerminalApp::SettingsLoadWarnings> GetKeybindingsWarnings() const;
|
||||
|
||||
Windows::Foundation::Collections::IMapView<hstring, TerminalApp::Command> GetCommands() noexcept;
|
||||
Windows::Foundation::Collections::IMapView<hstring, TerminalApp::Command> Commands() noexcept;
|
||||
|
||||
// These are implemented manually to handle the string/GUID exchange
|
||||
// by higher layers in the app.
|
||||
|
@ -83,7 +81,7 @@ namespace winrt::TerminalApp::implementation
|
|||
hstring _unparsedDefaultProfile;
|
||||
guid _defaultProfile;
|
||||
|
||||
com_ptr<AppKeyBindings> _keybindings;
|
||||
com_ptr<KeyMapping> _keymap;
|
||||
std::vector<TerminalApp::SettingsLoadWarnings> _keybindingsWarnings;
|
||||
|
||||
Windows::Foundation::Collections::IMap<hstring, TerminalApp::ColorScheme> _colorSchemes;
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
import "AppLogic.idl";
|
||||
import "ColorScheme.idl";
|
||||
import "AppKeybindings.idl";
|
||||
import "KeyMapping.idl";
|
||||
import "Command.idl";
|
||||
import "TerminalSettings.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
|
@ -47,13 +46,11 @@ namespace TerminalApp
|
|||
Boolean AlwaysOnTop;
|
||||
Boolean UseTabSwitcher;
|
||||
|
||||
Windows.Foundation.Collections.IMapView<String, ColorScheme> GetColorSchemes();
|
||||
Windows.Foundation.Collections.IMapView<String, ColorScheme> ColorSchemes();
|
||||
void AddColorScheme(ColorScheme scheme);
|
||||
|
||||
AppKeyBindings GetKeybindings();
|
||||
KeyMapping KeyMap();
|
||||
|
||||
Windows.Foundation.Collections.IMapView<String, Command> GetCommands();
|
||||
|
||||
void ApplyToSettings(TerminalSettings settings);
|
||||
Windows.Foundation.Collections.IMapView<String, Command> Commands();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ HRESULT Jumplist::UpdateJumplist(const CascadiaSettings& settings) noexcept
|
|||
|
||||
// Create the shell link object for the profile
|
||||
winrt::com_ptr<IShellLinkW> shLink;
|
||||
RETURN_IF_FAILED(_createShellLink(profile.Name(), profile.GetExpandedIconPath(), args, shLink.put()));
|
||||
RETURN_IF_FAILED(_createShellLink(profile.Name(), profile.ExpandedIconPath(), args, shLink.put()));
|
||||
|
||||
RETURN_IF_FAILED(jumplistItems->AddObject(shLink.get()));
|
||||
}
|
||||
|
|
108
src/cascadia/TerminalApp/KeyMapping.cpp
Normal file
108
src/cascadia/TerminalApp/KeyMapping.cpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include "pch.h"
|
||||
#include "KeyMapping.h"
|
||||
#include "KeyChordSerialization.h"
|
||||
|
||||
#include "KeyMapping.g.cpp"
|
||||
|
||||
using namespace winrt::TerminalApp;
|
||||
using namespace winrt::Microsoft::Terminal::TerminalControl;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
TerminalApp::ActionAndArgs KeyMapping::TryLookup(KeyChord const& chord) const
|
||||
{
|
||||
const auto result = _keyShortcuts.find(chord);
|
||||
if (result != _keyShortcuts.end())
|
||||
{
|
||||
return result->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void KeyMapping::SetKeyBinding(const TerminalApp::ActionAndArgs& actionAndArgs,
|
||||
const KeyChord& chord)
|
||||
{
|
||||
_keyShortcuts[chord] = actionAndArgs;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Remove the action that's bound to a particular KeyChord.
|
||||
// Arguments:
|
||||
// - chord: the keystroke to remove the action for.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void KeyMapping::ClearKeyBinding(const KeyChord& chord)
|
||||
{
|
||||
_keyShortcuts.erase(chord);
|
||||
}
|
||||
|
||||
KeyChord KeyMapping::GetKeyBindingForAction(TerminalApp::ShortcutAction const& action)
|
||||
{
|
||||
for (auto& kv : _keyShortcuts)
|
||||
{
|
||||
if (kv.second.Action() == action)
|
||||
{
|
||||
return kv.first;
|
||||
}
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Lookup the keychord bound to a particular combination of ShortcutAction
|
||||
// and IActionArgs. This enables searching no only for the binding of a
|
||||
// particular ShortcutAction, but also a particular set of values for
|
||||
// arguments to that action.
|
||||
// Arguments:
|
||||
// - actionAndArgs: The ActionAndArgs to lookup the keybinding for.
|
||||
// Return Value:
|
||||
// - The bound keychord, if this ActionAndArgs is bound to a key, otherwise nullptr.
|
||||
KeyChord KeyMapping::GetKeyBindingForActionWithArgs(TerminalApp::ActionAndArgs const& actionAndArgs)
|
||||
{
|
||||
if (actionAndArgs == nullptr)
|
||||
{
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
for (auto& kv : _keyShortcuts)
|
||||
{
|
||||
const auto action = kv.second.Action();
|
||||
const auto args = kv.second.Args();
|
||||
const auto actionMatched = action == actionAndArgs.Action();
|
||||
const auto argsMatched = args ? args.Equals(actionAndArgs.Args()) : args == actionAndArgs.Args();
|
||||
if (actionMatched && argsMatched)
|
||||
{
|
||||
return kv.first;
|
||||
}
|
||||
}
|
||||
return { nullptr };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Takes the KeyModifier flags from Terminal and maps them to the WinRT types which are used by XAML
|
||||
// Return Value:
|
||||
// - a Windows::System::VirtualKeyModifiers object with the flags of which modifiers used.
|
||||
Windows::System::VirtualKeyModifiers KeyMapping::ConvertVKModifiers(KeyModifiers modifiers)
|
||||
{
|
||||
Windows::System::VirtualKeyModifiers keyModifiers = Windows::System::VirtualKeyModifiers::None;
|
||||
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Ctrl))
|
||||
{
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Control;
|
||||
}
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Shift))
|
||||
{
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Shift;
|
||||
}
|
||||
if (WI_IsFlagSet(modifiers, KeyModifiers::Alt))
|
||||
{
|
||||
// note: Menu is the Alt VK_MENU
|
||||
keyModifiers |= Windows::System::VirtualKeyModifiers::Menu;
|
||||
}
|
||||
|
||||
return keyModifiers;
|
||||
}
|
||||
}
|
77
src/cascadia/TerminalApp/KeyMapping.h
Normal file
77
src/cascadia/TerminalApp/KeyMapping.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*++
|
||||
Copyright (c) Microsoft Corporation
|
||||
Licensed under the MIT license.
|
||||
|
||||
Module Name:
|
||||
- KeyMapping.h
|
||||
|
||||
Abstract:
|
||||
- A mapping of key chords to actions. Includes (de)serialization logic.
|
||||
|
||||
Author(s):
|
||||
- Carlos Zamora - September 2020
|
||||
|
||||
--*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "KeyMapping.g.h"
|
||||
#include "ActionArgs.h"
|
||||
#include "..\inc\cppwinrt_utils.h"
|
||||
|
||||
// fwdecl unittest classes
|
||||
namespace TerminalAppLocalTests
|
||||
{
|
||||
class SettingsTests;
|
||||
class KeyBindingsTests;
|
||||
class TestUtils;
|
||||
}
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct KeyChordHash
|
||||
{
|
||||
std::size_t operator()(const winrt::Microsoft::Terminal::TerminalControl::KeyChord& key) const
|
||||
{
|
||||
std::hash<int32_t> keyHash;
|
||||
std::hash<winrt::Microsoft::Terminal::TerminalControl::KeyModifiers> modifiersHash;
|
||||
std::size_t hashedKey = keyHash(key.Vkey());
|
||||
std::size_t hashedMods = modifiersHash(key.Modifiers());
|
||||
return hashedKey ^ hashedMods;
|
||||
}
|
||||
};
|
||||
|
||||
struct KeyChordEquality
|
||||
{
|
||||
bool operator()(const winrt::Microsoft::Terminal::TerminalControl::KeyChord& lhs, const winrt::Microsoft::Terminal::TerminalControl::KeyChord& rhs) const
|
||||
{
|
||||
return lhs.Modifiers() == rhs.Modifiers() && lhs.Vkey() == rhs.Vkey();
|
||||
}
|
||||
};
|
||||
|
||||
struct KeyMapping : KeyMappingT<KeyMapping>
|
||||
{
|
||||
KeyMapping() = default;
|
||||
|
||||
TerminalApp::ActionAndArgs TryLookup(winrt::Microsoft::Terminal::TerminalControl::KeyChord const& chord) const;
|
||||
|
||||
void SetKeyBinding(TerminalApp::ActionAndArgs const& actionAndArgs,
|
||||
winrt::Microsoft::Terminal::TerminalControl::KeyChord const& chord);
|
||||
void ClearKeyBinding(winrt::Microsoft::Terminal::TerminalControl::KeyChord const& chord);
|
||||
Microsoft::Terminal::TerminalControl::KeyChord GetKeyBindingForAction(TerminalApp::ShortcutAction const& action);
|
||||
Microsoft::Terminal::TerminalControl::KeyChord GetKeyBindingForActionWithArgs(TerminalApp::ActionAndArgs const& actionAndArgs);
|
||||
|
||||
static Windows::System::VirtualKeyModifiers ConvertVKModifiers(winrt::Microsoft::Terminal::TerminalControl::KeyModifiers modifiers);
|
||||
|
||||
// Defined in KeyMappingSerialization.cpp
|
||||
std::vector<TerminalApp::SettingsLoadWarnings> LayerJson(const Json::Value& json);
|
||||
Json::Value ToJson();
|
||||
|
||||
private:
|
||||
std::unordered_map<winrt::Microsoft::Terminal::TerminalControl::KeyChord, TerminalApp::ActionAndArgs, KeyChordHash, KeyChordEquality> _keyShortcuts;
|
||||
|
||||
friend class TerminalAppLocalTests::SettingsTests;
|
||||
friend class TerminalAppLocalTests::KeyBindingsTests;
|
||||
friend class TerminalAppLocalTests::TestUtils;
|
||||
};
|
||||
}
|
68
src/cascadia/TerminalApp/KeyMapping.idl
Normal file
68
src/cascadia/TerminalApp/KeyMapping.idl
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import "ActionArgs.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
enum ShortcutAction
|
||||
{
|
||||
Invalid = 0,
|
||||
CopyText,
|
||||
PasteText,
|
||||
OpenNewTabDropdown,
|
||||
DuplicateTab,
|
||||
NewTab,
|
||||
NewWindow,
|
||||
CloseWindow,
|
||||
CloseTab,
|
||||
ClosePane,
|
||||
NextTab,
|
||||
PrevTab,
|
||||
SplitVertical,
|
||||
SplitHorizontal,
|
||||
SendInput,
|
||||
SplitPane,
|
||||
TogglePaneZoom,
|
||||
SwitchToTab,
|
||||
AdjustFontSize,
|
||||
ResetFontSize,
|
||||
ScrollUp,
|
||||
ScrollDown,
|
||||
ScrollUpPage,
|
||||
ScrollDownPage,
|
||||
ResizePane,
|
||||
MoveFocus,
|
||||
Find,
|
||||
ToggleRetroEffect,
|
||||
ToggleFocusMode,
|
||||
ToggleFullscreen,
|
||||
ToggleAlwaysOnTop,
|
||||
OpenSettings,
|
||||
SetColorScheme,
|
||||
SetTabColor,
|
||||
OpenTabColorPicker,
|
||||
RenameTab,
|
||||
ExecuteCommandline,
|
||||
ToggleCommandPalette,
|
||||
CloseOtherTabs,
|
||||
CloseTabsAfter,
|
||||
TabSearch
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass ActionAndArgs {
|
||||
ActionAndArgs();
|
||||
IActionArgs Args;
|
||||
ShortcutAction Action;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass KeyMapping
|
||||
{
|
||||
ActionAndArgs TryLookup(Microsoft.Terminal.TerminalControl.KeyChord chord);
|
||||
|
||||
void SetKeyBinding(ActionAndArgs actionAndArgs, Microsoft.Terminal.TerminalControl.KeyChord chord);
|
||||
void ClearKeyBinding(Microsoft.Terminal.TerminalControl.KeyChord chord);
|
||||
|
||||
Microsoft.Terminal.TerminalControl.KeyChord GetKeyBindingForAction(ShortcutAction action);
|
||||
Microsoft.Terminal.TerminalControl.KeyChord GetKeyBindingForActionWithArgs(ActionAndArgs actionAndArgs);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
// - A couple helper functions for serializing/deserializing an AppKeyBindings
|
||||
// - A couple helper functions for serializing/deserializing a KeyMapping
|
||||
// to/from json.
|
||||
//
|
||||
// Author(s):
|
||||
// - Mike Griese - May 2019
|
||||
|
||||
#include "pch.h"
|
||||
#include "AppKeyBindings.h"
|
||||
#include "KeyMapping.h"
|
||||
#include "ActionAndArgs.h"
|
||||
#include "KeyChordSerialization.h"
|
||||
#include "Utils.h"
|
||||
|
@ -52,12 +52,12 @@ static Json::Value _ShortcutAsJsonObject(const KeyChord& chord,
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// - Serialize this AppKeyBindings to a json array of objects. Each object in
|
||||
// - Serialize this KeyMapping to a json array of objects. Each object in
|
||||
// the array represents a single keybinding, mapping a KeyChord to a
|
||||
// ShortcutAction.
|
||||
// Return Value:
|
||||
// - a Json::Value which is an equivalent serialization of this object.
|
||||
Json::Value winrt::TerminalApp::implementation::AppKeyBindings::ToJson()
|
||||
Json::Value winrt::TerminalApp::implementation::KeyMapping::ToJson()
|
||||
{
|
||||
Json::Value bindingsArray;
|
||||
|
||||
|
@ -81,7 +81,7 @@ Json::Value winrt::TerminalApp::implementation::AppKeyBindings::ToJson()
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// - Deserialize an AppKeyBindings from the key mappings that are in the array
|
||||
// - Deserialize a KeyMapping from the key mappings that are in the array
|
||||
// `json`. The json array should contain an array of objects with both a
|
||||
// `command` string and a `keys` array, where `command` is one of the names
|
||||
// listed in `ActionAndArgs::ActionKeyNamesMap`, and `keys` is an array of
|
||||
|
@ -93,7 +93,7 @@ Json::Value winrt::TerminalApp::implementation::AppKeyBindings::ToJson()
|
|||
// `"unbound"`, then we'll clear the keybinding from the existing keybindings.
|
||||
// Arguments:
|
||||
// - json: an array of Json::Value's to deserialize into our _keyShortcuts mapping.
|
||||
std::vector<SettingsLoadWarnings> winrt::TerminalApp::implementation::AppKeyBindings::LayerJson(const Json::Value& json)
|
||||
std::vector<SettingsLoadWarnings> winrt::TerminalApp::implementation::KeyMapping::LayerJson(const Json::Value& json)
|
||||
{
|
||||
// It's possible that the user provided keybindings have some warnings in
|
||||
// them - problems that we should alert the user to, but we can recover
|
|
@ -68,108 +68,6 @@ Profile::Profile(guid guid) :
|
|||
{
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Create a TerminalSettings from this object. Apply our settings, as well as
|
||||
// any colors from our color scheme, if we have one.
|
||||
// Arguments:
|
||||
// - schemes: a list of schemes to look for our color scheme in, if we have one.
|
||||
// Return Value:
|
||||
// - a new TerminalSettings object with our settings in it.
|
||||
winrt::TerminalApp::TerminalSettings Profile::CreateTerminalSettings(const Collections::IMapView<winrt::hstring, TerminalApp::ColorScheme>& schemes) const
|
||||
{
|
||||
auto terminalSettings = winrt::make<TerminalSettings>();
|
||||
|
||||
// Fill in the Terminal Setting's CoreSettings from the profile
|
||||
terminalSettings.HistorySize(_HistorySize);
|
||||
terminalSettings.SnapOnInput(_SnapOnInput);
|
||||
terminalSettings.AltGrAliasing(_AltGrAliasing);
|
||||
terminalSettings.CursorHeight(_CursorHeight);
|
||||
terminalSettings.CursorShape(_CursorShape);
|
||||
|
||||
// Fill in the remaining properties from the profile
|
||||
terminalSettings.ProfileName(_Name);
|
||||
terminalSettings.UseAcrylic(_UseAcrylic);
|
||||
terminalSettings.TintOpacity(_AcrylicOpacity);
|
||||
|
||||
terminalSettings.FontFace(_FontFace);
|
||||
terminalSettings.FontSize(_FontSize);
|
||||
terminalSettings.FontWeight(_FontWeight);
|
||||
terminalSettings.Padding(_Padding);
|
||||
|
||||
terminalSettings.Commandline(_Commandline);
|
||||
|
||||
if (!_StartingDirectory.empty())
|
||||
{
|
||||
const auto evaluatedDirectory = Profile::EvaluateStartingDirectory(_StartingDirectory.c_str());
|
||||
terminalSettings.StartingDirectory(evaluatedDirectory);
|
||||
}
|
||||
|
||||
// GH#2373: Use the tabTitle as the starting title if it exists, otherwise
|
||||
// use the profile name
|
||||
terminalSettings.StartingTitle(!_TabTitle.empty() ? _TabTitle : _Name);
|
||||
|
||||
if (_SuppressApplicationTitle)
|
||||
{
|
||||
terminalSettings.SuppressApplicationTitle(_SuppressApplicationTitle);
|
||||
}
|
||||
|
||||
if (!_ColorSchemeName.empty())
|
||||
{
|
||||
if (const auto found{ schemes.TryLookup(_ColorSchemeName) })
|
||||
{
|
||||
found.ApplyScheme(terminalSettings);
|
||||
}
|
||||
}
|
||||
if (_Foreground)
|
||||
{
|
||||
const til::color colorRef{ _Foreground.Value() };
|
||||
terminalSettings.DefaultForeground(static_cast<uint32_t>(colorRef));
|
||||
}
|
||||
if (_Background)
|
||||
{
|
||||
const til::color colorRef{ _Background.Value() };
|
||||
terminalSettings.DefaultBackground(static_cast<uint32_t>(colorRef));
|
||||
}
|
||||
if (_SelectionBackground)
|
||||
{
|
||||
const til::color colorRef{ _SelectionBackground.Value() };
|
||||
terminalSettings.SelectionBackground(static_cast<uint32_t>(colorRef));
|
||||
}
|
||||
if (_CursorColor)
|
||||
{
|
||||
const til::color colorRef{ _CursorColor.Value() };
|
||||
terminalSettings.CursorColor(static_cast<uint32_t>(colorRef));
|
||||
}
|
||||
|
||||
terminalSettings.ScrollState(_ScrollState);
|
||||
|
||||
if (!_BackgroundImagePath.empty())
|
||||
{
|
||||
terminalSettings.BackgroundImage(GetExpandedBackgroundImagePath());
|
||||
}
|
||||
|
||||
terminalSettings.BackgroundImageOpacity(_BackgroundImageOpacity);
|
||||
terminalSettings.BackgroundImageStretchMode(_BackgroundImageStretchMode);
|
||||
|
||||
const auto imageHorizontalAlignment = std::get<HorizontalAlignment>(_BackgroundImageAlignment);
|
||||
terminalSettings.BackgroundImageHorizontalAlignment(imageHorizontalAlignment);
|
||||
|
||||
const auto imageVerticalAlignment = std::get<VerticalAlignment>(_BackgroundImageAlignment);
|
||||
terminalSettings.BackgroundImageVerticalAlignment(imageVerticalAlignment);
|
||||
|
||||
terminalSettings.RetroTerminalEffect(_RetroTerminalEffect);
|
||||
|
||||
terminalSettings.AntialiasingMode(_AntialiasingMode);
|
||||
|
||||
if (_TabColor)
|
||||
{
|
||||
const til::color colorRef{ _TabColor.Value() };
|
||||
terminalSettings.TabColor(static_cast<uint32_t>(colorRef));
|
||||
}
|
||||
|
||||
return terminalSettings;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Generates a Json::Value which is a "stub" of this profile. This stub will
|
||||
// have enough information that it could be layered with this profile.
|
||||
|
@ -352,7 +250,7 @@ void Profile::LayerJson(const Json::Value& json)
|
|||
// path, if there are any.
|
||||
// Return Value:
|
||||
// - this profile's icon path, if one is set. Otherwise returns the empty string.
|
||||
winrt::hstring Profile::GetExpandedIconPath() const
|
||||
winrt::hstring Profile::ExpandedIconPath() const
|
||||
{
|
||||
if (_IconPath.empty())
|
||||
{
|
||||
|
@ -367,7 +265,7 @@ winrt::hstring Profile::GetExpandedIconPath() const
|
|||
// any environment variables in the path, if there are any.
|
||||
// Return Value:
|
||||
// - This profile's expanded background image path / the empty string.
|
||||
winrt::hstring Profile::GetExpandedBackgroundImagePath() const
|
||||
winrt::hstring Profile::ExpandedBackgroundImagePath() const
|
||||
{
|
||||
if (_BackgroundImagePath.empty())
|
||||
{
|
||||
|
@ -376,6 +274,11 @@ winrt::hstring Profile::GetExpandedBackgroundImagePath() const
|
|||
return winrt::hstring{ wil::ExpandEnvironmentStringsW<std::wstring>(_BackgroundImagePath.c_str()) };
|
||||
}
|
||||
|
||||
winrt::hstring Profile::EvaluatedStartingDirectory() const
|
||||
{
|
||||
return winrt::hstring{ Profile::EvaluateStartingDirectory(_StartingDirectory.c_str()) };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Helper function for expanding any environment variables in a user-supplied starting directory and validating the resulting path
|
||||
// Arguments:
|
||||
|
|
|
@ -16,7 +16,6 @@ Author(s):
|
|||
#pragma once
|
||||
|
||||
#include "Profile.g.h"
|
||||
#include "TerminalSettings.h"
|
||||
|
||||
#include "../inc/cppwinrt_utils.h"
|
||||
#include "JsonUtils.h"
|
||||
|
@ -46,16 +45,15 @@ namespace winrt::TerminalApp::implementation
|
|||
Profile();
|
||||
Profile(guid guid);
|
||||
|
||||
TerminalApp::TerminalSettings CreateTerminalSettings(const Windows::Foundation::Collections::IMapView<hstring, TerminalApp::ColorScheme>& schemes) const;
|
||||
|
||||
Json::Value GenerateStub() const;
|
||||
static com_ptr<Profile> FromJson(const Json::Value& json);
|
||||
bool ShouldBeLayered(const Json::Value& json) const;
|
||||
void LayerJson(const Json::Value& json);
|
||||
static bool IsDynamicProfileObject(const Json::Value& json);
|
||||
|
||||
hstring GetExpandedIconPath() const;
|
||||
hstring GetExpandedBackgroundImagePath() const;
|
||||
hstring EvaluatedStartingDirectory() const;
|
||||
hstring ExpandedIconPath() const;
|
||||
hstring ExpandedBackgroundImagePath() const;
|
||||
void GenerateGuidIfNecessary() noexcept;
|
||||
static guid GetGuidOrGenerateForJson(const Json::Value& json) noexcept;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace TerminalApp
|
|||
Boolean Hidden;
|
||||
|
||||
String IconPath;
|
||||
String GetExpandedIconPath();
|
||||
String ExpandedIconPath { get; };
|
||||
|
||||
CloseOnExitMode CloseOnExit;
|
||||
String TabTitle;
|
||||
|
@ -41,9 +41,10 @@ namespace TerminalApp
|
|||
|
||||
String Commandline;
|
||||
String StartingDirectory;
|
||||
String EvaluatedStartingDirectory { get; };
|
||||
|
||||
String BackgroundImagePath;
|
||||
String GetExpandedBackgroundImagePath();
|
||||
String ExpandedBackgroundImagePath { get; };
|
||||
Double BackgroundImageOpacity;
|
||||
Windows.UI.Xaml.Media.Stretch BackgroundImageStretchMode;
|
||||
Windows.UI.Xaml.HorizontalAlignment BackgroundImageHorizontalAlignment;
|
||||
|
|
|
@ -1,60 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
import "ActionArgs.idl";
|
||||
import "KeyMapping.idl";
|
||||
|
||||
namespace TerminalApp
|
||||
{
|
||||
enum ShortcutAction
|
||||
{
|
||||
Invalid = 0,
|
||||
CopyText,
|
||||
PasteText,
|
||||
OpenNewTabDropdown,
|
||||
DuplicateTab,
|
||||
NewTab,
|
||||
NewWindow,
|
||||
CloseWindow,
|
||||
CloseTab,
|
||||
ClosePane,
|
||||
NextTab,
|
||||
PrevTab,
|
||||
SplitVertical,
|
||||
SplitHorizontal,
|
||||
SendInput,
|
||||
SplitPane,
|
||||
TogglePaneZoom,
|
||||
SwitchToTab,
|
||||
AdjustFontSize,
|
||||
ResetFontSize,
|
||||
ScrollUp,
|
||||
ScrollDown,
|
||||
ScrollUpPage,
|
||||
ScrollDownPage,
|
||||
ResizePane,
|
||||
MoveFocus,
|
||||
Find,
|
||||
ToggleRetroEffect,
|
||||
ToggleFocusMode,
|
||||
ToggleFullscreen,
|
||||
ToggleAlwaysOnTop,
|
||||
OpenSettings,
|
||||
SetColorScheme,
|
||||
SetTabColor,
|
||||
OpenTabColorPicker,
|
||||
RenameTab,
|
||||
ExecuteCommandline,
|
||||
ToggleCommandPalette,
|
||||
CloseOtherTabs,
|
||||
CloseTabsAfter,
|
||||
TabSearch
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass ActionAndArgs {
|
||||
ActionAndArgs();
|
||||
IActionArgs Args;
|
||||
ShortcutAction Action;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass ShortcutActionDispatch {
|
||||
ShortcutActionDispatch();
|
||||
|
||||
|
|
|
@ -148,6 +148,9 @@
|
|||
<ClInclude Include="AppKeyBindings.h">
|
||||
<DependentUpon>AppKeyBindings.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="KeyMapping.h">
|
||||
<DependentUpon>KeyMapping.idl</DependentUpon>
|
||||
</ClInclude>
|
||||
<ClInclude Include="App.h">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</ClInclude>
|
||||
|
@ -208,7 +211,9 @@
|
|||
<ClCompile Include="CascadiaSettingsSerialization.cpp">
|
||||
<DependentUpon>CascadiaSettings.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AppKeyBindingsSerialization.cpp" />
|
||||
<ClCompile Include="KeyMappingSerialization.cpp">
|
||||
<DependentUpon>KeyMapping.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="KeyChordSerialization.cpp" />
|
||||
<ClCompile Include="DefaultProfileUtils.cpp" />
|
||||
<ClCompile Include="PowershellCoreProfileGenerator.cpp" />
|
||||
|
@ -227,6 +232,9 @@
|
|||
<ClCompile Include="AppKeyBindings.cpp">
|
||||
<DependentUpon>AppKeyBindings.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="KeyMapping.cpp">
|
||||
<DependentUpon>KeyMapping.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ShortcutActionDispatch.cpp">
|
||||
<DependentUpon>ShortcutActionDispatch.idl</DependentUpon>
|
||||
</ClCompile>
|
||||
|
@ -262,6 +270,7 @@
|
|||
</Midl>
|
||||
<Midl Include="ShortcutActionDispatch.idl" />
|
||||
<Midl Include="AppKeyBindings.idl" />
|
||||
<Midl Include="KeyMapping.idl" />
|
||||
<Midl Include="AppLogic.idl" />
|
||||
<Midl Include="ActionArgs.idl" />
|
||||
<Midl Include="MinMaxCloseControl.idl">
|
||||
|
|
|
@ -4,180 +4,183 @@
|
|||
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PRIResource Include="..\Resources\en-US\Resources.resw" />
|
||||
<PRIResource Include="Resources\en-US\Resources.resw" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="../init.cpp" />
|
||||
<ClCompile Include="init.cpp" />
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
|
||||
<ClCompile Include="../AzureCloudShellGenerator.cpp">
|
||||
<ClCompile Include="AzureCloudShellGenerator.cpp">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../PowershellCoreProfileGenerator.cpp">
|
||||
<ClCompile Include="PowershellCoreProfileGenerator.cpp">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../WslDistroGenerator.cpp">
|
||||
<ClCompile Include="WslDistroGenerator.cpp">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../AppKeyBindingsSerialization.cpp">
|
||||
<ClCompile Include="KeyMappingSerialization.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../CascadiaSettings.cpp">
|
||||
<ClCompile Include="CascadiaSettings.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../CascadiaSettingsSerialization.cpp">
|
||||
<ClCompile Include="CascadiaSettingsSerialization.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../GlobalAppSettings.cpp">
|
||||
<ClCompile Include="GlobalAppSettings.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../KeyChordSerialization.cpp">
|
||||
<ClCompile Include="KeyChordSerialization.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../Profile.cpp">
|
||||
<ClCompile Include="Profile.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../ColorScheme.cpp">
|
||||
<ClCompile Include="ColorScheme.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../Pane.cpp">
|
||||
<ClCompile Include="Pane.cpp">
|
||||
<Filter>pane</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../DefaultProfileUtils.cpp">
|
||||
<ClCompile Include="DefaultProfileUtils.cpp">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(OpenConsoleDir)\dep\jsoncpp\jsoncpp.cpp">
|
||||
<Filter>json</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../Tab.cpp">
|
||||
<ClCompile Include="Tab.cpp">
|
||||
<Filter>tab</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../Pane.LayoutSizeNode.cpp">
|
||||
<ClCompile Include="Pane.LayoutSizeNode.cpp">
|
||||
<Filter>pane</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="../AppCommandlineArgs.cpp" />
|
||||
<ClCompile Include="../Commandline.cpp" />
|
||||
<ClCompile Include="../ColorHelper.cpp" />
|
||||
<ClCompile Include="../DebugTapConnection.cpp" />
|
||||
<ClCompile Include="../Utils.cpp" />
|
||||
<ClCompile Include="../TerminalSettings.cpp">
|
||||
<ClCompile Include="AppCommandlineArgs.cpp" />
|
||||
<ClCompile Include="Commandline.cpp" />
|
||||
<ClCompile Include="ColorHelper.cpp" />
|
||||
<ClCompile Include="DebugTapConnection.cpp" />
|
||||
<ClCompile Include="Utils.cpp" />
|
||||
<ClCompile Include="TerminalSettings.cpp">
|
||||
<Filter>settings</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="../Utils.h" />
|
||||
<ClInclude Include="../TerminalWarnings.h" />
|
||||
<ClInclude Include="Utils.h" />
|
||||
<ClInclude Include="TerminalWarnings.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="../App.base.h">
|
||||
<ClInclude Include="App.base.h">
|
||||
<Filter>app</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../AzureCloudShellGenerator.h">
|
||||
<ClInclude Include="AzureCloudShellGenerator.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../IDynamicProfileGenerator.h">
|
||||
<ClInclude Include="IDynamicProfileGenerator.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../PowershellCoreProfileGenerator.h">
|
||||
<ClInclude Include="PowershellCoreProfileGenerator.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../WslDistroGenerator.h">
|
||||
<ClInclude Include="WslDistroGenerator.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../CascadiaSettings.h">
|
||||
<ClInclude Include="CascadiaSettings.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../GlobalAppSettings.h">
|
||||
<ClInclude Include="GlobalAppSettings.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../TerminalSettingsSerializationHelpers.h">
|
||||
<ClInclude Include="TerminalSettingsSerializationHelpers.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../KeyChordSerialization.h">
|
||||
<ClInclude Include="KeyChordSerialization.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../Profile.h">
|
||||
<ClInclude Include="Profile.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../ColorScheme.h">
|
||||
<ClInclude Include="ColorScheme.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../Pane.h">
|
||||
<ClInclude Include="Pane.h">
|
||||
<Filter>pane</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../DefaultProfileUtils.h">
|
||||
<ClInclude Include="DefaultProfileUtils.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../JsonUtils.h">
|
||||
<ClInclude Include="JsonUtils.h">
|
||||
<Filter>json</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../Tab.h">
|
||||
<ClInclude Include="Tab.h">
|
||||
<Filter>tab</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../AppCommandlineArgs.h" />
|
||||
<ClInclude Include="../Commandline.h" />
|
||||
<ClInclude Include="../DebugTapConnection.h" />
|
||||
<ClInclude Include="../ColorHelper.h" />
|
||||
<ClInclude Include="../TelnetGenerator.h">
|
||||
<ClInclude Include="AppCommandlineArgs.h" />
|
||||
<ClInclude Include="Commandline.h" />
|
||||
<ClInclude Include="DebugTapConnection.h" />
|
||||
<ClInclude Include="ColorHelper.h" />
|
||||
<ClInclude Include="TelnetGenerator.h">
|
||||
<Filter>profileGeneration</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="../TerminalSettings.h">
|
||||
<ClInclude Include="TerminalSettings.h">
|
||||
<Filter>settings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Midl Include="../AppLogic.idl">
|
||||
<Midl Include="AppLogic.idl">
|
||||
<Filter>app</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../ActionArgs.idl">
|
||||
<Midl Include="ActionArgs.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../AppKeyBindings.idl">
|
||||
<Midl Include="AppKeyBindings.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../ShortcutActionDispatch.idl">
|
||||
<Midl Include="KeyMapping.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../Tab.idl">
|
||||
<Midl Include="ShortcutActionDispatch.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="Tab.idl">
|
||||
<Filter>tab</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../Command.idl">
|
||||
<Midl Include="Command.idl">
|
||||
<Filter>commandPalette</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../IDirectKeyListener.idl" />
|
||||
<Midl Include="../CommandKeyChordVisibilityConverter.idl" />
|
||||
<Midl Include="../TerminalSettings.idl">
|
||||
<Midl Include="IDirectKeyListener.idl" />
|
||||
<Midl Include="CommandKeyChordVisibilityConverter.idl" />
|
||||
<Midl Include="TerminalSettings.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../ColorScheme.idl">
|
||||
<Midl Include="ColorScheme.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../Profile.idl">
|
||||
<Midl Include="Profile.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
<Midl Include="../GlobalAppSettings.idl">
|
||||
<Midl Include="GlobalAppSettings.idl">
|
||||
<Filter>settings</Filter>
|
||||
</Midl>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="../packages.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="../MinMaxCloseControl.xaml">
|
||||
<Page Include="MinMaxCloseControl.xaml">
|
||||
<Filter>controls</Filter>
|
||||
</Page>
|
||||
<Page Include="../TabRowControl.xaml">
|
||||
<Page Include="TabRowControl.xaml">
|
||||
<Filter>controls</Filter>
|
||||
</Page>
|
||||
<Page Include="../TerminalPage.xaml">
|
||||
<Page Include="TerminalPage.xaml">
|
||||
<Filter>controls</Filter>
|
||||
</Page>
|
||||
<Page Include="../TitlebarControl.xaml">
|
||||
<Page Include="TitlebarControl.xaml">
|
||||
<Filter>controls</Filter>
|
||||
</Page>
|
||||
<Page Include="../ColorPickupFlyout.xaml">
|
||||
<Page Include="ColorPickupFlyout.xaml">
|
||||
<Filter>controls</Filter>
|
||||
</Page>
|
||||
<Page Include="../CommandPalette.xaml">
|
||||
<Page Include="CommandPalette.xaml">
|
||||
<Filter>commandPalette</Filter>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
|
@ -208,7 +211,7 @@
|
|||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="..\App.xaml">
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Filter>app</Filter>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace winrt::TerminalApp::implementation
|
|||
// part of the command in the UI. Each Command's KeyChordText is
|
||||
// unset by default, so we don't need to worry about clearing it
|
||||
// if there isn't a key associated with it.
|
||||
auto keyChord{ settings.Keybindings().GetKeyBindingForActionWithArgs(command.Action()) };
|
||||
auto keyChord{ settings.KeyMap().GetKeyBindingForActionWithArgs(command.Action()) };
|
||||
|
||||
if (keyChord)
|
||||
{
|
||||
|
@ -114,14 +114,14 @@ namespace winrt::TerminalApp::implementation
|
|||
if (auto page{ weakThis.get() })
|
||||
{
|
||||
_UpdateCommandsForPalette();
|
||||
CommandPalette().SetKeyBindings(_settings.Keybindings());
|
||||
CommandPalette().SetKeyBindings(*_bindings);
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPage::Create()
|
||||
{
|
||||
// Hookup the key bindings
|
||||
_HookupKeyBindings(_settings.Keybindings());
|
||||
_HookupKeyBindings(_settings.KeyMap());
|
||||
|
||||
_tabContent = this->TabContent();
|
||||
_tabRow = this->TabRow();
|
||||
|
@ -448,7 +448,7 @@ namespace winrt::TerminalApp::implementation
|
|||
void TerminalPage::_CreateNewTabFlyout()
|
||||
{
|
||||
auto newTabFlyout = WUX::Controls::MenuFlyout{};
|
||||
auto keyBindings = _settings.Keybindings();
|
||||
auto keyBindings = _settings.KeyMap();
|
||||
|
||||
const auto defaultProfileGuid = _settings.GlobalSettings().DefaultProfile();
|
||||
// the number of profiles should not change in the loop for this to work
|
||||
|
@ -483,7 +483,7 @@ namespace winrt::TerminalApp::implementation
|
|||
// this flyout item.
|
||||
if (!profile.IconPath().empty())
|
||||
{
|
||||
auto iconSource = GetColoredIcon<WUX::Controls::IconSource>(profile.GetExpandedIconPath());
|
||||
auto iconSource = GetColoredIcon<WUX::Controls::IconSource>(profile.ExpandedIconPath());
|
||||
|
||||
WUX::Controls::IconSourceElement iconElement;
|
||||
iconElement.IconSource(iconSource);
|
||||
|
@ -612,12 +612,11 @@ namespace winrt::TerminalApp::implementation
|
|||
// Arguments:
|
||||
// - newTerminalArgs: An object that may contain a blob of parameters to
|
||||
// control which profile is created and with possible other
|
||||
// configurations. See CascadiaSettings::BuildSettings for more details.
|
||||
// configurations. See TerminalSettings::BuildSettings for more details.
|
||||
void TerminalPage::_OpenNewTab(const winrt::TerminalApp::NewTerminalArgs& newTerminalArgs)
|
||||
try
|
||||
{
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
const auto [profileGuid, settings] = settingsImpl->BuildSettings(newTerminalArgs);
|
||||
auto [profileGuid, settings] = TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings);
|
||||
|
||||
_CreateNewTabFromSettings(profileGuid, settings);
|
||||
|
||||
|
@ -728,7 +727,7 @@ namespace winrt::TerminalApp::implementation
|
|||
const auto profile = _settings.FindProfile(profileGuid);
|
||||
if (profile != nullptr && !profile.IconPath().empty())
|
||||
{
|
||||
newTabImpl->UpdateIcon(profile.GetExpandedIconPath());
|
||||
newTabImpl->UpdateIcon(profile.ExpandedIconPath());
|
||||
}
|
||||
|
||||
tabViewItem.PointerPressed({ this, &TerminalPage::_OnTabClick });
|
||||
|
@ -878,13 +877,14 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
|
||||
// Method Description:
|
||||
// - Configure the AppKeyBindings to use our ShortcutActionDispatch as the
|
||||
// object to handle dispatching ShortcutAction events.
|
||||
// - Configure the AppKeyBindings to use our ShortcutActionDispatch and the updated KeyMapping
|
||||
// as the object to handle dispatching ShortcutAction events.
|
||||
// Arguments:
|
||||
// - bindings: A AppKeyBindings object to wire up with our event handlers
|
||||
void TerminalPage::_HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept
|
||||
void TerminalPage::_HookupKeyBindings(const TerminalApp::KeyMapping& keymap) noexcept
|
||||
{
|
||||
bindings.SetDispatch(*_actionDispatch);
|
||||
_bindings->SetDispatch(*_actionDispatch);
|
||||
_bindings->SetKeyMapping(keymap);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -969,7 +969,7 @@ namespace winrt::TerminalApp::implementation
|
|||
const auto matchingProfile = _settings.FindProfile(lastFocusedProfile);
|
||||
if (matchingProfile)
|
||||
{
|
||||
tab.UpdateIcon(matchingProfile.GetExpandedIconPath());
|
||||
tab.UpdateIcon(matchingProfile.ExpandedIconPath());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1030,8 +1030,7 @@ namespace winrt::TerminalApp::implementation
|
|||
const auto& profileGuid = focusedTab->GetFocusedProfile();
|
||||
if (profileGuid.has_value())
|
||||
{
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
const auto settings = settingsImpl->BuildSettings(profileGuid.value());
|
||||
const auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid.value(), *_bindings) };
|
||||
_CreateNewTabFromSettings(profileGuid.value(), settings);
|
||||
}
|
||||
}
|
||||
|
@ -1466,8 +1465,7 @@ namespace winrt::TerminalApp::implementation
|
|||
if (current_guid)
|
||||
{
|
||||
profileFound = true;
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
controlSettings = settingsImpl->BuildSettings(current_guid.value());
|
||||
controlSettings = { winrt::make<TerminalSettings>(_settings, current_guid.value(), *_bindings) };
|
||||
realGuid = current_guid.value();
|
||||
}
|
||||
// TODO: GH#5047 - In the future, we should get the Profile of
|
||||
|
@ -1485,8 +1483,7 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
if (!profileFound)
|
||||
{
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
std::tie(realGuid, controlSettings) = settingsImpl->BuildSettings(newTerminalArgs);
|
||||
std::tie(realGuid, controlSettings) = TerminalSettings::BuildSettings(_settings, newTerminalArgs, *_bindings);
|
||||
}
|
||||
|
||||
const auto controlConnection = _CreateConnectionFromSettings(realGuid, controlSettings);
|
||||
|
@ -2045,7 +2042,7 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
// Re-wire the keybindings to their handlers, as we'll have created a
|
||||
// new AppKeyBindings object.
|
||||
_HookupKeyBindings(_settings.Keybindings());
|
||||
_HookupKeyBindings(_settings.KeyMap());
|
||||
|
||||
// Refresh UI elements
|
||||
auto profiles = _settings.Profiles();
|
||||
|
@ -2055,10 +2052,9 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
try
|
||||
{
|
||||
// BuildSettings can throw an exception if the profileGuid does
|
||||
// This can throw an exception if the profileGuid does
|
||||
// not belong to an actual profile in the list of profiles.
|
||||
const auto settingsImpl{ winrt::get_self<implementation::CascadiaSettings>(_settings) };
|
||||
const auto settings = settingsImpl->BuildSettings(profileGuid);
|
||||
auto settings{ winrt::make<TerminalSettings>(_settings, profileGuid, *_bindings) };
|
||||
|
||||
for (auto tab : _tabs)
|
||||
{
|
||||
|
@ -2156,9 +2152,9 @@ namespace winrt::TerminalApp::implementation
|
|||
// - <none>
|
||||
void TerminalPage::_UpdateCommandsForPalette()
|
||||
{
|
||||
IMap<winrt::hstring, winrt::TerminalApp::Command> copyOfCommands = _ExpandCommands(_settings.GlobalSettings().GetCommands(),
|
||||
IMap<winrt::hstring, winrt::TerminalApp::Command> copyOfCommands = _ExpandCommands(_settings.GlobalSettings().Commands(),
|
||||
_settings.Profiles().GetView(),
|
||||
_settings.GlobalSettings().GetColorSchemes());
|
||||
_settings.GlobalSettings().ColorSchemes());
|
||||
|
||||
_recursiveUpdateCommandKeybindingLabels(_settings, copyOfCommands.GetView());
|
||||
_recursiveUpdateCommandIcons(copyOfCommands.GetView());
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "Tab.h"
|
||||
#include "CascadiaSettings.h"
|
||||
#include "Profile.h"
|
||||
#include "AppKeyBindings.h"
|
||||
#include "TerminalSettings.h"
|
||||
|
||||
#include <winrt/Microsoft.Terminal.TerminalControl.h>
|
||||
|
||||
|
@ -103,7 +105,8 @@ namespace winrt::TerminalApp::implementation
|
|||
// use a weak reference to prevent circular dependency with AppLogic
|
||||
winrt::weak_ref<winrt::TerminalApp::IDialogPresenter> _dialogPresenter;
|
||||
|
||||
winrt::com_ptr<ShortcutActionDispatch> _actionDispatch{ winrt::make_self<ShortcutActionDispatch>() };
|
||||
winrt::com_ptr<AppKeyBindings> _bindings{ winrt::make_self<implementation::AppKeyBindings>() };
|
||||
winrt::com_ptr<ShortcutActionDispatch> _actionDispatch{ winrt::make_self<implementation::ShortcutActionDispatch>() };
|
||||
|
||||
winrt::Windows::UI::Xaml::Controls::Grid::LayoutUpdated_revoker _layoutUpdatedRevoker;
|
||||
StartupState _startupState{ StartupState::NotInitialized };
|
||||
|
@ -128,7 +131,7 @@ namespace winrt::TerminalApp::implementation
|
|||
void _CloseWarningPrimaryButtonOnClick(Windows::UI::Xaml::Controls::ContentDialog sender, Windows::UI::Xaml::Controls::ContentDialogButtonClickEventArgs eventArgs);
|
||||
void _ThirdPartyNoticesOnClick(const IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& eventArgs);
|
||||
|
||||
void _HookupKeyBindings(TerminalApp::AppKeyBindings bindings) noexcept;
|
||||
void _HookupKeyBindings(const TerminalApp::KeyMapping& keymap) noexcept;
|
||||
void _RegisterActionCallbacks();
|
||||
|
||||
void _UpdateTitle(const Tab& tab);
|
||||
|
|
|
@ -6,17 +6,195 @@
|
|||
|
||||
#include "TerminalSettings.g.cpp"
|
||||
|
||||
using namespace winrt::Microsoft::Terminal::TerminalControl;
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
TerminalSettings::TerminalSettings(const TerminalApp::CascadiaSettings& appSettings, winrt::guid profileGuid, const IKeyBindings& keybindings) :
|
||||
_KeyBindings{ keybindings }
|
||||
{
|
||||
const auto profile = appSettings.FindProfile(profileGuid);
|
||||
THROW_HR_IF_NULL(E_INVALIDARG, profile);
|
||||
|
||||
const auto globals = appSettings.GlobalSettings();
|
||||
_ApplyProfileSettings(profile, globals.ColorSchemes());
|
||||
_ApplyGlobalSettings(globals);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Create a TerminalSettings object for the provided newTerminalArgs. We'll
|
||||
// use the newTerminalArgs to look up the profile that should be used to
|
||||
// create these TerminalSettings. Then, we'll apply settings contained in the
|
||||
// newTerminalArgs to the profile's settings, to enable customization on top
|
||||
// of the profile's default values.
|
||||
// Arguments:
|
||||
// - appSettings: the set of settings being used to construct the new terminal
|
||||
// - newTerminalArgs: An object that may contain a profile name or GUID to
|
||||
// actually use. If the Profile value is not a guid, we'll treat it as a name,
|
||||
// and attempt to look the profile up by name instead.
|
||||
// * Additionally, we'll use other values (such as Commandline,
|
||||
// StartingDirectory) in this object to override the settings directly from
|
||||
// the profile.
|
||||
// - keybindings: the keybinding handler
|
||||
// Return Value:
|
||||
// - the GUID of the created profile, and a fully initialized TerminalSettings object
|
||||
std::tuple<guid, TerminalApp::TerminalSettings> TerminalSettings::BuildSettings(const TerminalApp::CascadiaSettings& appSettings,
|
||||
const TerminalApp::NewTerminalArgs& newTerminalArgs,
|
||||
const IKeyBindings& keybindings)
|
||||
{
|
||||
const guid profileGuid = appSettings.GetProfileForArgs(newTerminalArgs);
|
||||
auto settings{ winrt::make<TerminalSettings>(appSettings, profileGuid, keybindings) };
|
||||
|
||||
if (newTerminalArgs)
|
||||
{
|
||||
// Override commandline, starting directory if they exist in newTerminalArgs
|
||||
if (!newTerminalArgs.Commandline().empty())
|
||||
{
|
||||
settings.Commandline(newTerminalArgs.Commandline());
|
||||
}
|
||||
if (!newTerminalArgs.StartingDirectory().empty())
|
||||
{
|
||||
settings.StartingDirectory(newTerminalArgs.StartingDirectory());
|
||||
}
|
||||
if (!newTerminalArgs.TabTitle().empty())
|
||||
{
|
||||
settings.StartingTitle(newTerminalArgs.TabTitle());
|
||||
}
|
||||
}
|
||||
|
||||
return { profileGuid, settings };
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Apply Profile settings, as well as any colors from our color scheme, if we have one.
|
||||
// Arguments:
|
||||
// - profile: the profile settings we're applying
|
||||
// - schemes: a map of schemes to look for our color scheme in, if we have one.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalSettings::_ApplyProfileSettings(const TerminalApp::Profile& profile, const Windows::Foundation::Collections::IMapView<winrt::hstring, TerminalApp::ColorScheme>& schemes)
|
||||
{
|
||||
// Fill in the Terminal Setting's CoreSettings from the profile
|
||||
_HistorySize = profile.HistorySize();
|
||||
_SnapOnInput = profile.SnapOnInput();
|
||||
_AltGrAliasing = profile.AltGrAliasing();
|
||||
_CursorHeight = profile.CursorHeight();
|
||||
_CursorShape = profile.CursorShape();
|
||||
|
||||
// Fill in the remaining properties from the profile
|
||||
_ProfileName = profile.Name();
|
||||
_UseAcrylic = profile.UseAcrylic();
|
||||
_TintOpacity = profile.AcrylicOpacity();
|
||||
|
||||
_FontFace = profile.FontFace();
|
||||
_FontSize = profile.FontSize();
|
||||
_FontWeight = profile.FontWeight();
|
||||
_Padding = profile.Padding();
|
||||
|
||||
_Commandline = profile.Commandline();
|
||||
|
||||
if (!profile.StartingDirectory().empty())
|
||||
{
|
||||
_StartingDirectory = profile.EvaluatedStartingDirectory();
|
||||
}
|
||||
|
||||
// GH#2373: Use the tabTitle as the starting title if it exists, otherwise
|
||||
// use the profile name
|
||||
_StartingTitle = !profile.TabTitle().empty() ? profile.TabTitle() : profile.Name();
|
||||
|
||||
if (profile.SuppressApplicationTitle())
|
||||
{
|
||||
_SuppressApplicationTitle = profile.SuppressApplicationTitle();
|
||||
}
|
||||
|
||||
if (!profile.ColorSchemeName().empty())
|
||||
{
|
||||
if (const auto scheme = schemes.TryLookup(profile.ColorSchemeName()))
|
||||
{
|
||||
ApplyColorScheme(scheme);
|
||||
}
|
||||
}
|
||||
if (profile.Foreground())
|
||||
{
|
||||
_DefaultForeground = til::color{ profile.Foreground().Value() };
|
||||
}
|
||||
if (profile.Background())
|
||||
{
|
||||
_DefaultBackground = til::color{ profile.Background().Value() };
|
||||
}
|
||||
if (profile.SelectionBackground())
|
||||
{
|
||||
_SelectionBackground = til::color{ profile.SelectionBackground().Value() };
|
||||
}
|
||||
if (profile.CursorColor())
|
||||
{
|
||||
_CursorColor = til::color{ profile.CursorColor().Value() };
|
||||
}
|
||||
|
||||
_ScrollState = profile.ScrollState();
|
||||
|
||||
if (!profile.BackgroundImagePath().empty())
|
||||
{
|
||||
_BackgroundImage = profile.ExpandedBackgroundImagePath();
|
||||
}
|
||||
|
||||
_BackgroundImageOpacity = profile.BackgroundImageOpacity();
|
||||
_BackgroundImageStretchMode = profile.BackgroundImageStretchMode();
|
||||
|
||||
_BackgroundImageHorizontalAlignment = profile.BackgroundImageHorizontalAlignment();
|
||||
_BackgroundImageVerticalAlignment = profile.BackgroundImageVerticalAlignment();
|
||||
|
||||
_RetroTerminalEffect = profile.RetroTerminalEffect();
|
||||
|
||||
_AntialiasingMode = profile.AntialiasingMode();
|
||||
|
||||
if (profile.TabColor())
|
||||
{
|
||||
const til::color colorRef{ profile.TabColor().Value() };
|
||||
_TabColor = static_cast<uint32_t>(colorRef);
|
||||
}
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Applies appropriate settings from the globals into the TerminalSettings object.
|
||||
// Arguments:
|
||||
// - globalSettings: the global property values we're applying.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalSettings::_ApplyGlobalSettings(const TerminalApp::GlobalAppSettings& globalSettings) noexcept
|
||||
{
|
||||
_InitialRows = globalSettings.InitialRows();
|
||||
_InitialCols = globalSettings.InitialCols();
|
||||
|
||||
_WordDelimiters = globalSettings.WordDelimiters();
|
||||
_CopyOnSelect = globalSettings.CopyOnSelect();
|
||||
_ForceFullRepaintRendering = globalSettings.ForceFullRepaintRendering();
|
||||
_SoftwareRendering = globalSettings.SoftwareRendering();
|
||||
_ForceVTInput = globalSettings.ForceVTInput();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Apply a given ColorScheme's values to the TerminalSettings object.
|
||||
// Sets the foreground, background, and color table of the settings object.
|
||||
// Arguments:
|
||||
// - scheme: the ColorScheme we are applying to the TerminalSettings object
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalSettings::ApplyColorScheme(const TerminalApp::ColorScheme& scheme)
|
||||
{
|
||||
_DefaultForeground = til::color{ scheme.Foreground() };
|
||||
_DefaultBackground = til::color{ scheme.Background() };
|
||||
_SelectionBackground = til::color{ scheme.SelectionBackground() };
|
||||
_CursorColor = til::color{ scheme.CursorColor() };
|
||||
|
||||
const auto table = scheme.Table();
|
||||
std::transform(table.cbegin(), table.cend(), _colorTable.begin(), [](auto&& color) {
|
||||
return static_cast<uint32_t>(til::color{ color });
|
||||
});
|
||||
}
|
||||
|
||||
uint32_t TerminalSettings::GetColorTableEntry(int32_t index) const noexcept
|
||||
{
|
||||
return _colorTable.at(index);
|
||||
}
|
||||
|
||||
void TerminalSettings::SetColorTableEntry(int32_t index, uint32_t value)
|
||||
{
|
||||
auto const colorTableCount = gsl::narrow_cast<decltype(index)>(_colorTable.size());
|
||||
THROW_HR_IF(E_INVALIDARG, index >= colorTableCount);
|
||||
_colorTable.at(index) = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,28 @@ Author(s):
|
|||
#include <DefaultSettings.h>
|
||||
#include <conattrs.hpp>
|
||||
|
||||
#include "CascadiaSettings.h"
|
||||
|
||||
// fwdecl unittest classes
|
||||
namespace TerminalAppLocalTests
|
||||
{
|
||||
class SettingsTests;
|
||||
}
|
||||
|
||||
namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
struct TerminalSettings : TerminalSettingsT<TerminalSettings>
|
||||
{
|
||||
TerminalSettings() = default;
|
||||
TerminalSettings(const TerminalApp::CascadiaSettings& appSettings,
|
||||
guid profileGuid,
|
||||
const Microsoft::Terminal::TerminalControl::IKeyBindings& keybindings);
|
||||
|
||||
static std::tuple<guid, TerminalApp::TerminalSettings> BuildSettings(const TerminalApp::CascadiaSettings& appSettings,
|
||||
const TerminalApp::NewTerminalArgs& newTerminalArgs,
|
||||
const Microsoft::Terminal::TerminalControl::IKeyBindings& keybindings);
|
||||
|
||||
void ApplyColorScheme(const TerminalApp::ColorScheme& scheme);
|
||||
|
||||
// TECHNICALLY, the hstring copy assignment can throw, but the GETSET_PROPERTY
|
||||
// macro defines the operator as `noexcept`. We're not really worried about it,
|
||||
|
@ -34,10 +51,9 @@ namespace winrt::TerminalApp::implementation
|
|||
// --------------------------- Core Settings ---------------------------
|
||||
// All of these settings are defined in ICoreSettings.
|
||||
|
||||
// Get/Set ColorTableEntry needs to be implemented manually, to get a
|
||||
// GetColorTableEntry needs to be implemented manually, to get a
|
||||
// particular value from the array.
|
||||
uint32_t GetColorTableEntry(int32_t index) const noexcept;
|
||||
void SetColorTableEntry(int32_t index, uint32_t value);
|
||||
|
||||
GETSET_PROPERTY(uint32_t, DefaultForeground, DEFAULT_FOREGROUND_WITH_ALPHA);
|
||||
GETSET_PROPERTY(uint32_t, DefaultBackground, DEFAULT_BACKGROUND_WITH_ALPHA);
|
||||
|
@ -101,6 +117,11 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
private:
|
||||
std::array<uint32_t, COLOR_TABLE_SIZE> _colorTable{};
|
||||
|
||||
void _ApplyProfileSettings(const TerminalApp::Profile& profile, const Windows::Foundation::Collections::IMapView<hstring, TerminalApp::ColorScheme>& schemes);
|
||||
void _ApplyGlobalSettings(const TerminalApp::GlobalAppSettings& globalSettings) noexcept;
|
||||
|
||||
friend class TerminalAppLocalTests::SettingsTests;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace Microsoft.Terminal.TerminalControl
|
|||
UInt32 DefaultForeground;
|
||||
UInt32 DefaultBackground;
|
||||
UInt32 GetColorTableEntry(Int32 index);
|
||||
void SetColorTableEntry(Int32 index, UInt32 value);
|
||||
// TODO:MSFT:20642297 - define a sentinel for Infinite Scrollback
|
||||
Int32 HistorySize;
|
||||
Int32 InitialRows;
|
||||
|
|
|
@ -61,9 +61,6 @@ namespace TerminalCoreUnitTests
|
|||
void SelectionBackground(uint32_t) {}
|
||||
void ForceVTInput(bool) {}
|
||||
|
||||
// other unimplemented methods
|
||||
void SetColorTableEntry(int32_t /* index */, uint32_t /* value */) {}
|
||||
|
||||
GETSET_PROPERTY(winrt::Windows::Foundation::IReference<uint32_t>, TabColor, nullptr);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue