diff --git a/.github/actions/spell-check/dictionary/apis.txt b/.github/actions/spell-check/dictionary/apis.txt index fdb6a2dcd05..88494b86f64 100644 --- a/.github/actions/spell-check/dictionary/apis.txt +++ b/.github/actions/spell-check/dictionary/apis.txt @@ -1,11 +1,13 @@ ACCEPTFILES ACCESSDENIED +alignof bitfield bitfields CLASSNOTAVAILABLE EXPCMDFLAGS EXPCMDSTATE fullkbd +futex href IAsync IBind @@ -33,5 +35,10 @@ RETURNCMD rfind roundf RSHIFT +rx SIZENS +spsc +STDCPP +syscall tmp +tx diff --git a/.github/actions/spell-check/dictionary/microsoft.txt b/.github/actions/spell-check/dictionary/microsoft.txt index 5e5d2ee3164..ef2c23c5ab6 100644 --- a/.github/actions/spell-check/dictionary/microsoft.txt +++ b/.github/actions/spell-check/dictionary/microsoft.txt @@ -1,4 +1,5 @@ ACLs +altform backplating DACL DACLs @@ -9,7 +10,9 @@ microsoftonline osgvsowi powerrename powershell +pscustomobject SACLs tdbuildteamid vcruntime visualstudio +wslpath diff --git a/.github/actions/spell-check/expect/expect.txt b/.github/actions/spell-check/expect/expect.txt index 4774abf99a2..01b64c42d78 100644 --- a/.github/actions/spell-check/expect/expect.txt +++ b/.github/actions/spell-check/expect/expect.txt @@ -1083,6 +1083,8 @@ INITCOMMONCONTROLSEX INITDIALOG initguid INITMENU +imagemagick +inkscape inl INLINEPREFIX Inlines @@ -1530,6 +1532,7 @@ nothrow NOTICKS NOTIMPL notin +NOTOPMOST NOTNULL NOTRACK NOTSUPPORTED @@ -2265,6 +2268,7 @@ targetentrypoint TARGETLIBS TARGETNAME targetnametoken +targetsize targetver taskbar tbar diff --git a/NuGet.Config b/NuGet.Config index de105e187bc..00b1de60c4f 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -8,7 +8,7 @@ - + + + + + + + + + + + + diff --git a/res/terminal/Terminal_HC.svg b/res/terminal/Terminal_HC.svg new file mode 100644 index 00000000000..e5e3a5434f9 --- /dev/null +++ b/res/terminal/Terminal_HC.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/res/terminal/Terminal_Pre_HC.svg b/res/terminal/Terminal_Pre_HC.svg new file mode 100644 index 00000000000..c08c3747a5e --- /dev/null +++ b/res/terminal/Terminal_Pre_HC.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/res/terminal/images-Dev/LargeTile.scale-100_contrast-black.png b/res/terminal/images-Dev/LargeTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..4f9f6ceeec5 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-100_contrast-white.png b/res/terminal/images-Dev/LargeTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..3dba00e203b Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-125_contrast-black.png b/res/terminal/images-Dev/LargeTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..43fe337ac29 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-125_contrast-white.png b/res/terminal/images-Dev/LargeTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..893a64f8ec5 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-150_contrast-black.png b/res/terminal/images-Dev/LargeTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..2b51fefb028 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-150_contrast-white.png b/res/terminal/images-Dev/LargeTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..602efd44f01 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-200_contrast-black.png b/res/terminal/images-Dev/LargeTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..07c342a30c5 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-200_contrast-white.png b/res/terminal/images-Dev/LargeTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..1ef86a82225 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-400_contrast-black.png b/res/terminal/images-Dev/LargeTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..dcbc2dfec17 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/LargeTile.scale-400_contrast-white.png b/res/terminal/images-Dev/LargeTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..bc6097de8b4 Binary files /dev/null and b/res/terminal/images-Dev/LargeTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-black.png b/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-white.png b/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-black.png b/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-white.png b/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-black.png b/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-white.png b/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-black.png b/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-white.png b/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-black.png b/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-white.png b/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images-Dev/LockScreenLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-100_contrast-black.png b/res/terminal/images-Dev/SmallTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..3b4d5619397 Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-100_contrast-white.png b/res/terminal/images-Dev/SmallTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..110e3de75f0 Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-125_contrast-black.png b/res/terminal/images-Dev/SmallTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..473ec5122af Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-125_contrast-white.png b/res/terminal/images-Dev/SmallTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..d864ab7131c Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-150_contrast-black.png b/res/terminal/images-Dev/SmallTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..c9f872090e0 Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-150_contrast-white.png b/res/terminal/images-Dev/SmallTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..6f029a17a15 Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-200_contrast-black.png b/res/terminal/images-Dev/SmallTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..ee72b0ec3ee Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-200_contrast-white.png b/res/terminal/images-Dev/SmallTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..af58357987f Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-400_contrast-black.png b/res/terminal/images-Dev/SmallTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..c636747380b Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/SmallTile.scale-400_contrast-white.png b/res/terminal/images-Dev/SmallTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..cfa8ce7e4c7 Binary files /dev/null and b/res/terminal/images-Dev/SmallTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-100_contrast-black.png b/res/terminal/images-Dev/SplashScreen.scale-100_contrast-black.png new file mode 100644 index 00000000000..a4480138b64 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-100_contrast-white.png b/res/terminal/images-Dev/SplashScreen.scale-100_contrast-white.png new file mode 100644 index 00000000000..09b65238b44 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-125_contrast-black.png b/res/terminal/images-Dev/SplashScreen.scale-125_contrast-black.png new file mode 100644 index 00000000000..d827b3a621c Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-125_contrast-white.png b/res/terminal/images-Dev/SplashScreen.scale-125_contrast-white.png new file mode 100644 index 00000000000..53057953a8f Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-150_contrast-black.png b/res/terminal/images-Dev/SplashScreen.scale-150_contrast-black.png new file mode 100644 index 00000000000..9137cacbf18 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-150_contrast-white.png b/res/terminal/images-Dev/SplashScreen.scale-150_contrast-white.png new file mode 100644 index 00000000000..06a70ddc7dd Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-200_contrast-black.png b/res/terminal/images-Dev/SplashScreen.scale-200_contrast-black.png new file mode 100644 index 00000000000..38ad367e109 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-200_contrast-white.png b/res/terminal/images-Dev/SplashScreen.scale-200_contrast-white.png new file mode 100644 index 00000000000..e910cabe62c Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-400_contrast-black.png b/res/terminal/images-Dev/SplashScreen.scale-400_contrast-black.png new file mode 100644 index 00000000000..40c8b3d2429 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/SplashScreen.scale-400_contrast-white.png b/res/terminal/images-Dev/SplashScreen.scale-400_contrast-white.png new file mode 100644 index 00000000000..bdf7b5b7cb8 Binary files /dev/null and b/res/terminal/images-Dev/SplashScreen.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-black.png b/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..a94e09558d5 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-white.png b/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..8b15f746632 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-black.png b/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..52a0961f9c1 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-white.png b/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..1f2b02d1b32 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-black.png b/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..e709c17c3b7 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-white.png b/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..00fb42558e0 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-black.png b/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..da75c53210c Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-white.png b/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..f56a69cf10f Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-black.png b/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..3bb828ac8d5 Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-white.png b/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..99fc2a7ff4d Binary files /dev/null and b/res/terminal/images-Dev/Square150x150Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..9f13cded565 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..7786af596e0 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..eed2b33a67a Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..86948693b8a Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..085efc7b6af Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..c6ef1dafa8e Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..16469eb5bd3 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..f9a6ae53359 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..0b8ca35feb0 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..fa3109e7e22 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..26ae28f2a0b Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..d1a2951126a Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-black.png new file mode 100644 index 00000000000..26ae28f2a0b Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-white.png new file mode 100644 index 00000000000..d1a2951126a Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-16_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..a036a06ee23 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..42d68e5f6f5 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-black.png new file mode 100644 index 00000000000..a036a06ee23 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-white.png new file mode 100644 index 00000000000..42d68e5f6f5 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-20_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-24_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..f89467e7320 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..665dfbe3a37 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-black.png new file mode 100644 index 00000000000..f89467e7320 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-white.png new file mode 100644 index 00000000000..665dfbe3a37 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-256_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-30_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..e195a888f5f Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..efc56018094 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-black.png new file mode 100644 index 00000000000..e195a888f5f Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-white.png new file mode 100644 index 00000000000..efc56018094 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-32_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-36_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..65b26da3965 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..5869c620465 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-black.png new file mode 100644 index 00000000000..65b26da3965 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-white.png new file mode 100644 index 00000000000..5869c620465 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-40_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-48_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..acc3310df63 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..aecda0f11e3 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-black.png new file mode 100644 index 00000000000..acc3310df63 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-white.png new file mode 100644 index 00000000000..aecda0f11e3 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-60_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..01686eaccf7 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..63fb5b06cd7 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-black.png new file mode 100644 index 00000000000..01686eaccf7 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-white.png new file mode 100644 index 00000000000..63fb5b06cd7 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-64_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..110249863df Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..fa7c0bb9cf5 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-black.png new file mode 100644 index 00000000000..110249863df Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-white.png new file mode 100644 index 00000000000..fa7c0bb9cf5 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-72_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..81f6b28749e Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..e5e2dacc31d Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-black.png new file mode 100644 index 00000000000..81f6b28749e Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-white.png new file mode 100644 index 00000000000..e5e2dacc31d Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-80_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-black.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-black.png differ diff --git a/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-white.png b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images-Dev/Square44x44Logo.targetsize-96_contrast-white.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-100_contrast-black.png b/res/terminal/images-Dev/StoreLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..c52aafcc5dd Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-100_contrast-white.png b/res/terminal/images-Dev/StoreLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..f3c68fb688c Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-125_contrast-black.png b/res/terminal/images-Dev/StoreLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..a84d1ff188e Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-125_contrast-white.png b/res/terminal/images-Dev/StoreLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..5e741ef242f Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-150_contrast-black.png b/res/terminal/images-Dev/StoreLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..d843bd16ae1 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-150_contrast-white.png b/res/terminal/images-Dev/StoreLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..8dac64a4fe8 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-200_contrast-black.png b/res/terminal/images-Dev/StoreLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..4fb88aad7d1 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-200_contrast-white.png b/res/terminal/images-Dev/StoreLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..5a1b5727e69 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-400_contrast-black.png b/res/terminal/images-Dev/StoreLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..d6616c8ab55 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/StoreLogo.scale-400_contrast-white.png b/res/terminal/images-Dev/StoreLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..8c622de1d48 Binary files /dev/null and b/res/terminal/images-Dev/StoreLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-black.png b/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..e001af83cd8 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-white.png b/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..0ce5b040316 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-black.png b/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..33010325e98 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-white.png b/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..b5745ff70f6 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-black.png b/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..7844cda30cf Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-white.png b/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..9f62ef7fd38 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-black.png b/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..a4480138b64 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-white.png b/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..09b65238b44 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-black.png b/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..38ad367e109 Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-white.png b/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..e910cabe62c Binary files /dev/null and b/res/terminal/images-Dev/Wide310x150Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-100_contrast-black.png b/res/terminal/images-Pre/LargeTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..bbcfc696a9e Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-100_contrast-white.png b/res/terminal/images-Pre/LargeTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..9b6b05881de Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-125_contrast-black.png b/res/terminal/images-Pre/LargeTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..daa163d30e5 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-125_contrast-white.png b/res/terminal/images-Pre/LargeTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..e675b860dc3 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-150_contrast-black.png b/res/terminal/images-Pre/LargeTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..9de6e5ae4ef Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-150_contrast-white.png b/res/terminal/images-Pre/LargeTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..f3c3a8d6ce3 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-200_contrast-black.png b/res/terminal/images-Pre/LargeTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..ac9b19f44ee Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-200_contrast-white.png b/res/terminal/images-Pre/LargeTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..57e420e9974 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-400_contrast-black.png b/res/terminal/images-Pre/LargeTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..dcb433a1084 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/LargeTile.scale-400_contrast-white.png b/res/terminal/images-Pre/LargeTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..0e6aefd75a6 Binary files /dev/null and b/res/terminal/images-Pre/LargeTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-black.png b/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..ce51243c628 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-white.png b/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..2b9d1a06b62 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-black.png b/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..f7094e3374b Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-white.png b/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..788d405f453 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-black.png b/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..62f84ba9aab Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-white.png b/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..61be432569a Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-black.png b/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..8427e96d130 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-white.png b/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..f490a9aa080 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-black.png b/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..217ea2d31a0 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-white.png b/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..b2f0a14d558 Binary files /dev/null and b/res/terminal/images-Pre/LockScreenLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-100_contrast-black.png b/res/terminal/images-Pre/SmallTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..0d2591b8a46 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-100_contrast-white.png b/res/terminal/images-Pre/SmallTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..66a16a331f9 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-125_contrast-black.png b/res/terminal/images-Pre/SmallTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..be14cbfa973 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-125_contrast-white.png b/res/terminal/images-Pre/SmallTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..5f8bfad946f Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-150_contrast-black.png b/res/terminal/images-Pre/SmallTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..3d9acb361c3 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-150_contrast-white.png b/res/terminal/images-Pre/SmallTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..caf834d6c22 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-200_contrast-black.png b/res/terminal/images-Pre/SmallTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..0f7481d481b Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-200_contrast-white.png b/res/terminal/images-Pre/SmallTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..b321705e93c Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-400_contrast-black.png b/res/terminal/images-Pre/SmallTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..27dca17f1d1 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/SmallTile.scale-400_contrast-white.png b/res/terminal/images-Pre/SmallTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..de3c606cda7 Binary files /dev/null and b/res/terminal/images-Pre/SmallTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-100_contrast-black.png b/res/terminal/images-Pre/SplashScreen.scale-100_contrast-black.png new file mode 100644 index 00000000000..c33de15b3ba Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-100_contrast-white.png b/res/terminal/images-Pre/SplashScreen.scale-100_contrast-white.png new file mode 100644 index 00000000000..26ebbbf09e7 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-125_contrast-black.png b/res/terminal/images-Pre/SplashScreen.scale-125_contrast-black.png new file mode 100644 index 00000000000..1c1f57c92bb Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-125_contrast-white.png b/res/terminal/images-Pre/SplashScreen.scale-125_contrast-white.png new file mode 100644 index 00000000000..dd4d19a7cc9 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-150_contrast-black.png b/res/terminal/images-Pre/SplashScreen.scale-150_contrast-black.png new file mode 100644 index 00000000000..12a8a36a798 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-150_contrast-white.png b/res/terminal/images-Pre/SplashScreen.scale-150_contrast-white.png new file mode 100644 index 00000000000..093903c8ad0 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-200_contrast-black.png b/res/terminal/images-Pre/SplashScreen.scale-200_contrast-black.png new file mode 100644 index 00000000000..3f8fc2d06f5 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-200_contrast-white.png b/res/terminal/images-Pre/SplashScreen.scale-200_contrast-white.png new file mode 100644 index 00000000000..357a83f1325 Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-400_contrast-black.png b/res/terminal/images-Pre/SplashScreen.scale-400_contrast-black.png new file mode 100644 index 00000000000..24ea7722a7d Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/SplashScreen.scale-400_contrast-white.png b/res/terminal/images-Pre/SplashScreen.scale-400_contrast-white.png new file mode 100644 index 00000000000..5568cc8615d Binary files /dev/null and b/res/terminal/images-Pre/SplashScreen.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-black.png b/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..2a82392f5f6 Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-white.png b/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..3a93c3c213b Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-black.png b/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..f2031a207aa Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-white.png b/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..24caab8deaf Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-black.png b/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..e03041227d9 Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-white.png b/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..6c2e8f38cb2 Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-black.png b/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..4b35315c7ef Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-white.png b/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..47154776d69 Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-black.png b/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..8ad38f6a9e4 Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-white.png b/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..9f5c525348d Binary files /dev/null and b/res/terminal/images-Pre/Square150x150Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..a9a5b046d86 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..a7550ffadf2 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..ce820d9be4d Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..d05e4bd2a68 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..b4a2e6cc928 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..2df02c39299 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..07bb68ba944 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..b71dd10ecb5 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..52b835c05b8 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..451c5d8a5be Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..3640ec3fa32 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..f068d41135d Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-black.png new file mode 100644 index 00000000000..3640ec3fa32 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-white.png new file mode 100644 index 00000000000..f068d41135d Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-16_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..5ea768ed4a0 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..59f4b0be724 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-black.png new file mode 100644 index 00000000000..5ea768ed4a0 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-white.png new file mode 100644 index 00000000000..59f4b0be724 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-20_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..ce51243c628 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..2b9d1a06b62 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-black.png new file mode 100644 index 00000000000..ce51243c628 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-white.png new file mode 100644 index 00000000000..2b9d1a06b62 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-24_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..1ecd842894d Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..55fe0139f27 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-black.png new file mode 100644 index 00000000000..1ecd842894d Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-white.png new file mode 100644 index 00000000000..55fe0139f27 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-256_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..f7094e3374b Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..788d405f453 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-black.png new file mode 100644 index 00000000000..f7094e3374b Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-white.png new file mode 100644 index 00000000000..788d405f453 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-30_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..7363adf4cf4 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..80df0b81f93 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-black.png new file mode 100644 index 00000000000..7363adf4cf4 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-white.png new file mode 100644 index 00000000000..80df0b81f93 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-32_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..62f84ba9aab Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..61be432569a Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-black.png new file mode 100644 index 00000000000..62f84ba9aab Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-white.png new file mode 100644 index 00000000000..61be432569a Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-36_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..93ef2fac9c5 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..59cef34ed0b Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-black.png new file mode 100644 index 00000000000..93ef2fac9c5 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-white.png new file mode 100644 index 00000000000..59cef34ed0b Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-40_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..8427e96d130 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..f490a9aa080 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-black.png new file mode 100644 index 00000000000..8427e96d130 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-white.png new file mode 100644 index 00000000000..f490a9aa080 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-48_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..d742b734893 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..edb9d45d24e Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-black.png new file mode 100644 index 00000000000..d742b734893 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-white.png new file mode 100644 index 00000000000..edb9d45d24e Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-60_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..4d97ed69bd3 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..833f8150167 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-black.png new file mode 100644 index 00000000000..4d97ed69bd3 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-white.png new file mode 100644 index 00000000000..833f8150167 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-64_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..bb27466d5a1 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..c337b4be5ee Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-black.png new file mode 100644 index 00000000000..bb27466d5a1 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-white.png new file mode 100644 index 00000000000..c337b4be5ee Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-72_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..e636f00d75c Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..d687f9d73d1 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-black.png new file mode 100644 index 00000000000..e636f00d75c Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-white.png new file mode 100644 index 00000000000..d687f9d73d1 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-80_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..217ea2d31a0 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..b2f0a14d558 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-black.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-black.png new file mode 100644 index 00000000000..217ea2d31a0 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-black.png differ diff --git a/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-white.png b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-white.png new file mode 100644 index 00000000000..b2f0a14d558 Binary files /dev/null and b/res/terminal/images-Pre/Square44x44Logo.targetsize-96_contrast-white.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-100_contrast-black.png b/res/terminal/images-Pre/StoreLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..26f94d563de Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-100_contrast-white.png b/res/terminal/images-Pre/StoreLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..59318f1e47d Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-125_contrast-black.png b/res/terminal/images-Pre/StoreLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..f6c85246064 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-125_contrast-white.png b/res/terminal/images-Pre/StoreLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..fc296cb2f9a Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-150_contrast-black.png b/res/terminal/images-Pre/StoreLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..fd6c20ce317 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-150_contrast-white.png b/res/terminal/images-Pre/StoreLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..66fd5655058 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-200_contrast-black.png b/res/terminal/images-Pre/StoreLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..60eb894b35a Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-200_contrast-white.png b/res/terminal/images-Pre/StoreLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..93713970ec5 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-400_contrast-black.png b/res/terminal/images-Pre/StoreLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..b1d9835eb78 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/StoreLogo.scale-400_contrast-white.png b/res/terminal/images-Pre/StoreLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..e2025f22550 Binary files /dev/null and b/res/terminal/images-Pre/StoreLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-black.png b/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..b1efc07df3a Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-white.png b/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..066fceb3401 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-black.png b/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..f1b0c364f9d Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-white.png b/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..6671495b6c0 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-black.png b/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..2729e37f318 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-white.png b/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..7dc7b1a55c2 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-black.png b/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..c33de15b3ba Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-white.png b/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..26ebbbf09e7 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-black.png b/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..3f8fc2d06f5 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-white.png b/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..357a83f1325 Binary files /dev/null and b/res/terminal/images-Pre/Wide310x150Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images/LargeTile.scale-100_contrast-black.png b/res/terminal/images/LargeTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..4f9f6ceeec5 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images/LargeTile.scale-100_contrast-white.png b/res/terminal/images/LargeTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..3dba00e203b Binary files /dev/null and b/res/terminal/images/LargeTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images/LargeTile.scale-125_contrast-black.png b/res/terminal/images/LargeTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..43fe337ac29 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images/LargeTile.scale-125_contrast-white.png b/res/terminal/images/LargeTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..893a64f8ec5 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images/LargeTile.scale-150_contrast-black.png b/res/terminal/images/LargeTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..2b51fefb028 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images/LargeTile.scale-150_contrast-white.png b/res/terminal/images/LargeTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..602efd44f01 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images/LargeTile.scale-200_contrast-black.png b/res/terminal/images/LargeTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..07c342a30c5 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images/LargeTile.scale-200_contrast-white.png b/res/terminal/images/LargeTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..1ef86a82225 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images/LargeTile.scale-400_contrast-black.png b/res/terminal/images/LargeTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..dcbc2dfec17 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images/LargeTile.scale-400_contrast-white.png b/res/terminal/images/LargeTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..bc6097de8b4 Binary files /dev/null and b/res/terminal/images/LargeTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-100_contrast-black.png b/res/terminal/images/LockScreenLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-100_contrast-white.png b/res/terminal/images/LockScreenLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-125_contrast-black.png b/res/terminal/images/LockScreenLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-125_contrast-white.png b/res/terminal/images/LockScreenLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-150_contrast-black.png b/res/terminal/images/LockScreenLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-150_contrast-white.png b/res/terminal/images/LockScreenLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-200_contrast-black.png b/res/terminal/images/LockScreenLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-200_contrast-white.png b/res/terminal/images/LockScreenLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-400_contrast-black.png b/res/terminal/images/LockScreenLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images/LockScreenLogo.scale-400_contrast-white.png b/res/terminal/images/LockScreenLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images/LockScreenLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images/SmallTile.scale-100_contrast-black.png b/res/terminal/images/SmallTile.scale-100_contrast-black.png new file mode 100644 index 00000000000..3b4d5619397 Binary files /dev/null and b/res/terminal/images/SmallTile.scale-100_contrast-black.png differ diff --git a/res/terminal/images/SmallTile.scale-100_contrast-white.png b/res/terminal/images/SmallTile.scale-100_contrast-white.png new file mode 100644 index 00000000000..110e3de75f0 Binary files /dev/null and b/res/terminal/images/SmallTile.scale-100_contrast-white.png differ diff --git a/res/terminal/images/SmallTile.scale-125_contrast-black.png b/res/terminal/images/SmallTile.scale-125_contrast-black.png new file mode 100644 index 00000000000..473ec5122af Binary files /dev/null and b/res/terminal/images/SmallTile.scale-125_contrast-black.png differ diff --git a/res/terminal/images/SmallTile.scale-125_contrast-white.png b/res/terminal/images/SmallTile.scale-125_contrast-white.png new file mode 100644 index 00000000000..d864ab7131c Binary files /dev/null and b/res/terminal/images/SmallTile.scale-125_contrast-white.png differ diff --git a/res/terminal/images/SmallTile.scale-150_contrast-black.png b/res/terminal/images/SmallTile.scale-150_contrast-black.png new file mode 100644 index 00000000000..c9f872090e0 Binary files /dev/null and b/res/terminal/images/SmallTile.scale-150_contrast-black.png differ diff --git a/res/terminal/images/SmallTile.scale-150_contrast-white.png b/res/terminal/images/SmallTile.scale-150_contrast-white.png new file mode 100644 index 00000000000..6f029a17a15 Binary files /dev/null and b/res/terminal/images/SmallTile.scale-150_contrast-white.png differ diff --git a/res/terminal/images/SmallTile.scale-200_contrast-black.png b/res/terminal/images/SmallTile.scale-200_contrast-black.png new file mode 100644 index 00000000000..ee72b0ec3ee Binary files /dev/null and b/res/terminal/images/SmallTile.scale-200_contrast-black.png differ diff --git a/res/terminal/images/SmallTile.scale-200_contrast-white.png b/res/terminal/images/SmallTile.scale-200_contrast-white.png new file mode 100644 index 00000000000..af58357987f Binary files /dev/null and b/res/terminal/images/SmallTile.scale-200_contrast-white.png differ diff --git a/res/terminal/images/SmallTile.scale-400_contrast-black.png b/res/terminal/images/SmallTile.scale-400_contrast-black.png new file mode 100644 index 00000000000..c636747380b Binary files /dev/null and b/res/terminal/images/SmallTile.scale-400_contrast-black.png differ diff --git a/res/terminal/images/SmallTile.scale-400_contrast-white.png b/res/terminal/images/SmallTile.scale-400_contrast-white.png new file mode 100644 index 00000000000..cfa8ce7e4c7 Binary files /dev/null and b/res/terminal/images/SmallTile.scale-400_contrast-white.png differ diff --git a/res/terminal/images/SplashScreen.scale-100_contrast-black.png b/res/terminal/images/SplashScreen.scale-100_contrast-black.png new file mode 100644 index 00000000000..a4480138b64 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-100_contrast-black.png differ diff --git a/res/terminal/images/SplashScreen.scale-100_contrast-white.png b/res/terminal/images/SplashScreen.scale-100_contrast-white.png new file mode 100644 index 00000000000..09b65238b44 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-100_contrast-white.png differ diff --git a/res/terminal/images/SplashScreen.scale-125_contrast-black.png b/res/terminal/images/SplashScreen.scale-125_contrast-black.png new file mode 100644 index 00000000000..d827b3a621c Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-125_contrast-black.png differ diff --git a/res/terminal/images/SplashScreen.scale-125_contrast-white.png b/res/terminal/images/SplashScreen.scale-125_contrast-white.png new file mode 100644 index 00000000000..53057953a8f Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-125_contrast-white.png differ diff --git a/res/terminal/images/SplashScreen.scale-150_contrast-black.png b/res/terminal/images/SplashScreen.scale-150_contrast-black.png new file mode 100644 index 00000000000..9137cacbf18 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-150_contrast-black.png differ diff --git a/res/terminal/images/SplashScreen.scale-150_contrast-white.png b/res/terminal/images/SplashScreen.scale-150_contrast-white.png new file mode 100644 index 00000000000..06a70ddc7dd Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-150_contrast-white.png differ diff --git a/res/terminal/images/SplashScreen.scale-200_contrast-black.png b/res/terminal/images/SplashScreen.scale-200_contrast-black.png new file mode 100644 index 00000000000..38ad367e109 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-200_contrast-black.png differ diff --git a/res/terminal/images/SplashScreen.scale-200_contrast-white.png b/res/terminal/images/SplashScreen.scale-200_contrast-white.png new file mode 100644 index 00000000000..e910cabe62c Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-200_contrast-white.png differ diff --git a/res/terminal/images/SplashScreen.scale-400_contrast-black.png b/res/terminal/images/SplashScreen.scale-400_contrast-black.png new file mode 100644 index 00000000000..40c8b3d2429 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-400_contrast-black.png differ diff --git a/res/terminal/images/SplashScreen.scale-400_contrast-white.png b/res/terminal/images/SplashScreen.scale-400_contrast-white.png new file mode 100644 index 00000000000..bdf7b5b7cb8 Binary files /dev/null and b/res/terminal/images/SplashScreen.scale-400_contrast-white.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-100_contrast-black.png b/res/terminal/images/Square150x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..a94e09558d5 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-100_contrast-white.png b/res/terminal/images/Square150x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..8b15f746632 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-125_contrast-black.png b/res/terminal/images/Square150x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..52a0961f9c1 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-125_contrast-white.png b/res/terminal/images/Square150x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..1f2b02d1b32 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-150_contrast-black.png b/res/terminal/images/Square150x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..e709c17c3b7 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-150_contrast-white.png b/res/terminal/images/Square150x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..00fb42558e0 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-200_contrast-black.png b/res/terminal/images/Square150x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..da75c53210c Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-200_contrast-white.png b/res/terminal/images/Square150x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..f56a69cf10f Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-400_contrast-black.png b/res/terminal/images/Square150x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..3bb828ac8d5 Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images/Square150x150Logo.scale-400_contrast-white.png b/res/terminal/images/Square150x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..99fc2a7ff4d Binary files /dev/null and b/res/terminal/images/Square150x150Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-100_contrast-black.png b/res/terminal/images/Square44x44Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..9f13cded565 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-100_contrast-white.png b/res/terminal/images/Square44x44Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..7786af596e0 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-125_contrast-black.png b/res/terminal/images/Square44x44Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..eed2b33a67a Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-125_contrast-white.png b/res/terminal/images/Square44x44Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..86948693b8a Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-150_contrast-black.png b/res/terminal/images/Square44x44Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..085efc7b6af Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-150_contrast-white.png b/res/terminal/images/Square44x44Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..c6ef1dafa8e Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-200_contrast-black.png b/res/terminal/images/Square44x44Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..16469eb5bd3 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-200_contrast-white.png b/res/terminal/images/Square44x44Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..f9a6ae53359 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-400_contrast-black.png b/res/terminal/images/Square44x44Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..0b8ca35feb0 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.scale-400_contrast-white.png b/res/terminal/images/Square44x44Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..fa3109e7e22 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.scale-400_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..26ae28f2a0b Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..d1a2951126a Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-16_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-16_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-16_contrast-black.png new file mode 100644 index 00000000000..26ae28f2a0b Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-16_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-16_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-16_contrast-white.png new file mode 100644 index 00000000000..d1a2951126a Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-16_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..a036a06ee23 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..42d68e5f6f5 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-20_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-20_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-20_contrast-black.png new file mode 100644 index 00000000000..a036a06ee23 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-20_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-20_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-20_contrast-white.png new file mode 100644 index 00000000000..42d68e5f6f5 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-20_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-24_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-24_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-24_contrast-black.png new file mode 100644 index 00000000000..931b46f2318 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-24_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-24_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-24_contrast-white.png new file mode 100644 index 00000000000..41c3aee3502 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-24_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..f89467e7320 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..665dfbe3a37 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-256_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-256_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-256_contrast-black.png new file mode 100644 index 00000000000..f89467e7320 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-256_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-256_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-256_contrast-white.png new file mode 100644 index 00000000000..665dfbe3a37 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-256_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-30_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-30_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-30_contrast-black.png new file mode 100644 index 00000000000..d0c78011e6c Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-30_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-30_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-30_contrast-white.png new file mode 100644 index 00000000000..1788b2253da Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-30_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..e195a888f5f Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..efc56018094 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-32_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-32_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-32_contrast-black.png new file mode 100644 index 00000000000..e195a888f5f Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-32_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-32_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-32_contrast-white.png new file mode 100644 index 00000000000..efc56018094 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-32_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-36_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-36_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-36_contrast-black.png new file mode 100644 index 00000000000..153e67c4ebb Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-36_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-36_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-36_contrast-white.png new file mode 100644 index 00000000000..79ee49b96db Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-36_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..65b26da3965 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..5869c620465 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-40_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-40_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-40_contrast-black.png new file mode 100644 index 00000000000..65b26da3965 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-40_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-40_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-40_contrast-white.png new file mode 100644 index 00000000000..5869c620465 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-40_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-48_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-48_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-48_contrast-black.png new file mode 100644 index 00000000000..03201095aec Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-48_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-48_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-48_contrast-white.png new file mode 100644 index 00000000000..9c5b7161150 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-48_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..acc3310df63 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..aecda0f11e3 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-60_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-60_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-60_contrast-black.png new file mode 100644 index 00000000000..acc3310df63 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-60_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-60_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-60_contrast-white.png new file mode 100644 index 00000000000..aecda0f11e3 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-60_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..01686eaccf7 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..63fb5b06cd7 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-64_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-64_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-64_contrast-black.png new file mode 100644 index 00000000000..01686eaccf7 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-64_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-64_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-64_contrast-white.png new file mode 100644 index 00000000000..63fb5b06cd7 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-64_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..110249863df Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..fa7c0bb9cf5 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-72_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-72_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-72_contrast-black.png new file mode 100644 index 00000000000..110249863df Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-72_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-72_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-72_contrast-white.png new file mode 100644 index 00000000000..fa7c0bb9cf5 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-72_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..81f6b28749e Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..e5e2dacc31d Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-80_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-80_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-80_contrast-black.png new file mode 100644 index 00000000000..81f6b28749e Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-80_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-80_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-80_contrast-white.png new file mode 100644 index 00000000000..e5e2dacc31d Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-80_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-96_altform-unplated_contrast-white.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-96_contrast-black.png b/res/terminal/images/Square44x44Logo.targetsize-96_contrast-black.png new file mode 100644 index 00000000000..563108e90e9 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-96_contrast-black.png differ diff --git a/res/terminal/images/Square44x44Logo.targetsize-96_contrast-white.png b/res/terminal/images/Square44x44Logo.targetsize-96_contrast-white.png new file mode 100644 index 00000000000..0f9c7950c71 Binary files /dev/null and b/res/terminal/images/Square44x44Logo.targetsize-96_contrast-white.png differ diff --git a/res/terminal/images/StoreLogo.scale-100_contrast-black.png b/res/terminal/images/StoreLogo.scale-100_contrast-black.png new file mode 100644 index 00000000000..c52aafcc5dd Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-100_contrast-black.png differ diff --git a/res/terminal/images/StoreLogo.scale-100_contrast-white.png b/res/terminal/images/StoreLogo.scale-100_contrast-white.png new file mode 100644 index 00000000000..f3c68fb688c Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-100_contrast-white.png differ diff --git a/res/terminal/images/StoreLogo.scale-125_contrast-black.png b/res/terminal/images/StoreLogo.scale-125_contrast-black.png new file mode 100644 index 00000000000..a84d1ff188e Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-125_contrast-black.png differ diff --git a/res/terminal/images/StoreLogo.scale-125_contrast-white.png b/res/terminal/images/StoreLogo.scale-125_contrast-white.png new file mode 100644 index 00000000000..5e741ef242f Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-125_contrast-white.png differ diff --git a/res/terminal/images/StoreLogo.scale-150_contrast-black.png b/res/terminal/images/StoreLogo.scale-150_contrast-black.png new file mode 100644 index 00000000000..d843bd16ae1 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-150_contrast-black.png differ diff --git a/res/terminal/images/StoreLogo.scale-150_contrast-white.png b/res/terminal/images/StoreLogo.scale-150_contrast-white.png new file mode 100644 index 00000000000..8dac64a4fe8 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-150_contrast-white.png differ diff --git a/res/terminal/images/StoreLogo.scale-200_contrast-black.png b/res/terminal/images/StoreLogo.scale-200_contrast-black.png new file mode 100644 index 00000000000..4fb88aad7d1 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-200_contrast-black.png differ diff --git a/res/terminal/images/StoreLogo.scale-200_contrast-white.png b/res/terminal/images/StoreLogo.scale-200_contrast-white.png new file mode 100644 index 00000000000..5a1b5727e69 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-200_contrast-white.png differ diff --git a/res/terminal/images/StoreLogo.scale-400_contrast-black.png b/res/terminal/images/StoreLogo.scale-400_contrast-black.png new file mode 100644 index 00000000000..d6616c8ab55 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-400_contrast-black.png differ diff --git a/res/terminal/images/StoreLogo.scale-400_contrast-white.png b/res/terminal/images/StoreLogo.scale-400_contrast-white.png new file mode 100644 index 00000000000..8c622de1d48 Binary files /dev/null and b/res/terminal/images/StoreLogo.scale-400_contrast-white.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-100_contrast-black.png b/res/terminal/images/Wide310x150Logo.scale-100_contrast-black.png new file mode 100644 index 00000000000..e001af83cd8 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-100_contrast-black.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-100_contrast-white.png b/res/terminal/images/Wide310x150Logo.scale-100_contrast-white.png new file mode 100644 index 00000000000..0ce5b040316 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-100_contrast-white.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-125_contrast-black.png b/res/terminal/images/Wide310x150Logo.scale-125_contrast-black.png new file mode 100644 index 00000000000..33010325e98 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-125_contrast-black.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-125_contrast-white.png b/res/terminal/images/Wide310x150Logo.scale-125_contrast-white.png new file mode 100644 index 00000000000..b5745ff70f6 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-125_contrast-white.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-150_contrast-black.png b/res/terminal/images/Wide310x150Logo.scale-150_contrast-black.png new file mode 100644 index 00000000000..7844cda30cf Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-150_contrast-black.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-150_contrast-white.png b/res/terminal/images/Wide310x150Logo.scale-150_contrast-white.png new file mode 100644 index 00000000000..9f62ef7fd38 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-150_contrast-white.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-200_contrast-black.png b/res/terminal/images/Wide310x150Logo.scale-200_contrast-black.png new file mode 100644 index 00000000000..a4480138b64 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-200_contrast-black.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-200_contrast-white.png b/res/terminal/images/Wide310x150Logo.scale-200_contrast-white.png new file mode 100644 index 00000000000..09b65238b44 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-200_contrast-white.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-400_contrast-black.png b/res/terminal/images/Wide310x150Logo.scale-400_contrast-black.png new file mode 100644 index 00000000000..38ad367e109 Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-400_contrast-black.png differ diff --git a/res/terminal/images/Wide310x150Logo.scale-400_contrast-white.png b/res/terminal/images/Wide310x150Logo.scale-400_contrast-white.png new file mode 100644 index 00000000000..e910cabe62c Binary files /dev/null and b/res/terminal/images/Wide310x150Logo.scale-400_contrast-white.png differ diff --git a/src/buffer/out/AttrRow.cpp b/src/buffer/out/AttrRow.cpp index 42f1790b261..5df4da3978d 100644 --- a/src/buffer/out/AttrRow.cpp +++ b/src/buffer/out/AttrRow.cpp @@ -223,7 +223,7 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt // Return Value: // - STATUS_NO_MEMORY if there wasn't enough memory to insert the runs // otherwise STATUS_SUCCESS if we were successful. -[[nodiscard]] HRESULT ATTR_ROW::InsertAttrRuns(const std::basic_string_view newAttrs, +[[nodiscard]] HRESULT ATTR_ROW::InsertAttrRuns(const gsl::span newAttrs, const size_t iStart, const size_t iEnd, const size_t cBufferWidth) @@ -250,7 +250,7 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt if (newAttrs.size() == 1) { // Get the new color attribute we're trying to apply - const TextAttribute NewAttr = newAttrs.at(0).GetAttributes(); + const TextAttribute NewAttr = til::at(newAttrs, 0).GetAttributes(); // If the existing run was only 1 element... // ...and the new color is the same as the old, we don't have to do anything and can exit quick. @@ -372,7 +372,7 @@ void ATTR_ROW::ReplaceAttrs(const TextAttribute& toBeReplacedAttr, const TextAtt if (iStart == 0 && iEnd == iLastBufferCol) { // Just dump what we're given over what we have and call it a day. - _list.assign(newAttrs.cbegin(), newAttrs.cend()); + _list.assign(newAttrs.begin(), newAttrs.end()); return S_OK; } diff --git a/src/buffer/out/AttrRow.hpp b/src/buffer/out/AttrRow.hpp index 29f0ee1e470..2f0a07794c3 100644 --- a/src/buffer/out/AttrRow.hpp +++ b/src/buffer/out/AttrRow.hpp @@ -46,7 +46,7 @@ class ATTR_ROW final void Resize(const size_t newWidth); - [[nodiscard]] HRESULT InsertAttrRuns(const std::basic_string_view newAttrs, + [[nodiscard]] HRESULT InsertAttrRuns(const gsl::span newAttrs, const size_t iStart, const size_t iEnd, const size_t cBufferWidth); diff --git a/src/buffer/out/OutputCellIterator.cpp b/src/buffer/out/OutputCellIterator.cpp index 9b5437041b5..d32087fe9e6 100644 --- a/src/buffer/out/OutputCellIterator.cpp +++ b/src/buffer/out/OutputCellIterator.cpp @@ -112,9 +112,9 @@ OutputCellIterator::OutputCellIterator(const std::wstring_view utf16Text, const // - This is an iterator over legacy colors only. The text is not modified. // Arguments: // - legacyAttrs - One legacy color item per cell -OutputCellIterator::OutputCellIterator(const std::basic_string_view legacyAttrs) noexcept : +OutputCellIterator::OutputCellIterator(const gsl::span legacyAttrs) noexcept : _mode(Mode::LegacyAttr), - _currentView(s_GenerateViewLegacyAttr(legacyAttrs.at(0))), + _currentView(s_GenerateViewLegacyAttr(til::at(legacyAttrs, 0))), _run(legacyAttrs), _attr(InvalidTextAttribute), _distance(0), @@ -127,9 +127,9 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view legacy // - This is an iterator over legacy cell data. We will use the unicode text and the legacy color attribute. // Arguments: // - charInfos - Multiple cell with unicode text and legacy color data. -OutputCellIterator::OutputCellIterator(const std::basic_string_view charInfos) noexcept : +OutputCellIterator::OutputCellIterator(const gsl::span charInfos) noexcept : _mode(Mode::CharInfo), - _currentView(s_GenerateView(charInfos.at(0))), + _currentView(s_GenerateView(til::at(charInfos, 0))), _run(charInfos), _attr(InvalidTextAttribute), _distance(0), @@ -142,9 +142,9 @@ OutputCellIterator::OutputCellIterator(const std::basic_string_view c // - This is an iterator over existing OutputCells with full text and color data. // Arguments: // - cells - Multiple cells in a run -OutputCellIterator::OutputCellIterator(const std::basic_string_view cells) : +OutputCellIterator::OutputCellIterator(const gsl::span cells) : _mode(Mode::Cell), - _currentView(s_GenerateView(cells.at(0))), + _currentView(s_GenerateView(til::at(cells, 0))), _run(cells), _attr(InvalidTextAttribute), _distance(0), @@ -180,15 +180,15 @@ OutputCellIterator::operator bool() const noexcept } case Mode::Cell: { - return _pos < std::get>(_run).length(); + return _pos < std::get>(_run).size(); } case Mode::CharInfo: { - return _pos < std::get>(_run).length(); + return _pos < std::get>(_run).size(); } case Mode::LegacyAttr: { - return _pos < std::get>(_run).length(); + return _pos < std::get>(_run).size(); } default: FAIL_FAST_HR(E_NOTIMPL); @@ -265,7 +265,7 @@ OutputCellIterator& OutputCellIterator::operator++() _pos++; if (operator bool()) { - _currentView = s_GenerateView(std::get>(_run).at(_pos)); + _currentView = s_GenerateView(til::at(std::get>(_run), _pos)); } break; } @@ -275,7 +275,7 @@ OutputCellIterator& OutputCellIterator::operator++() _pos++; if (operator bool()) { - _currentView = s_GenerateView(std::get>(_run).at(_pos)); + _currentView = s_GenerateView(til::at(std::get>(_run), _pos)); } break; } @@ -285,7 +285,7 @@ OutputCellIterator& OutputCellIterator::operator++() _pos++; if (operator bool()) { - _currentView = s_GenerateViewLegacyAttr(std::get>(_run).at(_pos)); + _currentView = s_GenerateViewLegacyAttr(til::at(std::get>(_run), _pos)); } break; } diff --git a/src/buffer/out/OutputCellIterator.hpp b/src/buffer/out/OutputCellIterator.hpp index 0d4b866e7c5..59c6007aa3a 100644 --- a/src/buffer/out/OutputCellIterator.hpp +++ b/src/buffer/out/OutputCellIterator.hpp @@ -39,9 +39,9 @@ class OutputCellIterator final OutputCellIterator(const CHAR_INFO& charInfo, const size_t fillLimit = 0) noexcept; OutputCellIterator(const std::wstring_view utf16Text); OutputCellIterator(const std::wstring_view utf16Text, const TextAttribute attribute); - OutputCellIterator(const std::basic_string_view legacyAttributes) noexcept; - OutputCellIterator(const std::basic_string_view charInfos) noexcept; - OutputCellIterator(const std::basic_string_view cells); + OutputCellIterator(const gsl::span legacyAttributes) noexcept; + OutputCellIterator(const gsl::span charInfos) noexcept; + OutputCellIterator(const gsl::span cells); ~OutputCellIterator() = default; OutputCellIterator& operator=(const OutputCellIterator& it) = default; @@ -86,13 +86,13 @@ class OutputCellIterator final }; Mode _mode; - std::basic_string_view _legacyAttrs; + gsl::span _legacyAttrs; std::variant< std::wstring_view, - std::basic_string_view, - std::basic_string_view, - std::basic_string_view, + gsl::span, + gsl::span, + gsl::span, std::monostate> _run; diff --git a/src/buffer/out/OutputCellRect.cpp b/src/buffer/out/OutputCellRect.cpp index e9cdc275b98..9dd0f74dfb9 100644 --- a/src/buffer/out/OutputCellRect.cpp +++ b/src/buffer/out/OutputCellRect.cpp @@ -50,7 +50,7 @@ gsl::span OutputCellRect::GetRow(const size_t row) // - Read-only iterator of OutputCells OutputCellIterator OutputCellRect::GetRowIter(const size_t row) const { - const std::basic_string_view view(_FindRowOffset(row), _cols); + const gsl::span view(_FindRowOffset(row), _cols); return OutputCellIterator(view); } diff --git a/src/buffer/out/TextAttribute.cpp b/src/buffer/out/TextAttribute.cpp index dd4ef450316..b58975f9a85 100644 --- a/src/buffer/out/TextAttribute.cpp +++ b/src/buffer/out/TextAttribute.cpp @@ -90,7 +90,7 @@ bool TextAttribute::IsLegacy() const noexcept // - reverseScreenMode: true if the screen mode is reversed. // Return Value: // - the foreground and background colors that should be displayed. -std::pair TextAttribute::CalculateRgbColors(const std::basic_string_view colorTable, +std::pair TextAttribute::CalculateRgbColors(const gsl::span colorTable, const COLORREF defaultFgColor, const COLORREF defaultBgColor, const bool reverseScreenMode) const noexcept diff --git a/src/buffer/out/TextAttribute.hpp b/src/buffer/out/TextAttribute.hpp index f33a92ea1bb..cccd9aaff7c 100644 --- a/src/buffer/out/TextAttribute.hpp +++ b/src/buffer/out/TextAttribute.hpp @@ -63,7 +63,7 @@ class TextAttribute final static TextAttribute StripErroneousVT16VersionsOfLegacyDefaults(const TextAttribute& attribute) noexcept; WORD GetLegacyAttributes() const noexcept; - std::pair CalculateRgbColors(const std::basic_string_view colorTable, + std::pair CalculateRgbColors(const gsl::span colorTable, const COLORREF defaultFgColor, const COLORREF defaultBgColor, const bool reverseScreenMode = false) const noexcept; diff --git a/src/buffer/out/TextColor.cpp b/src/buffer/out/TextColor.cpp index 3a664dff316..20405022984 100644 --- a/src/buffer/out/TextColor.cpp +++ b/src/buffer/out/TextColor.cpp @@ -138,7 +138,7 @@ void TextColor::SetDefault() noexcept // - brighten: if true, we'll brighten a dark color table index. // Return Value: // - a COLORREF containing the real value of this TextColor. -COLORREF TextColor::GetColor(std::basic_string_view colorTable, +COLORREF TextColor::GetColor(gsl::span colorTable, const COLORREF defaultColor, bool brighten) const noexcept { @@ -158,9 +158,9 @@ COLORREF TextColor::GetColor(std::basic_string_view colorTable, // If we find a match, return instead the bright version of this color for (size_t i = 0; i < 8; i++) { - if (colorTable.at(i) == defaultColor) + if (til::at(colorTable, i) == defaultColor) { - return colorTable.at(i + 8); + return til::at(colorTable, i + 8); } } } @@ -173,11 +173,11 @@ COLORREF TextColor::GetColor(std::basic_string_view colorTable, } else if (IsIndex16() && brighten) { - return colorTable.at(_index | 8); + return til::at(colorTable, _index | 8); } else { - return colorTable.at(_index); + return til::at(colorTable, _index); } } diff --git a/src/buffer/out/TextColor.h b/src/buffer/out/TextColor.h index 6085dbd3381..d0186f62219 100644 --- a/src/buffer/out/TextColor.h +++ b/src/buffer/out/TextColor.h @@ -88,7 +88,7 @@ struct TextColor void SetIndex(const BYTE index, const bool isIndex256) noexcept; void SetDefault() noexcept; - COLORREF GetColor(std::basic_string_view colorTable, + COLORREF GetColor(gsl::span colorTable, const COLORREF defaultColor, const bool brighten = false) const noexcept; diff --git a/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp b/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp index 13472d4437d..44acc35519d 100644 --- a/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp +++ b/src/buffer/out/ut_textbuffer/TextAttributeTests.cpp @@ -27,7 +27,7 @@ class TextAttributeTests COLORREF _colorTable[COLOR_TABLE_SIZE]; COLORREF _defaultFg = RGB(1, 2, 3); COLORREF _defaultBg = RGB(4, 5, 6); - std::basic_string_view _GetTableView(); + gsl::span _GetTableView(); }; bool TextAttributeTests::ClassSetup() @@ -51,9 +51,9 @@ bool TextAttributeTests::ClassSetup() return true; } -std::basic_string_view TextAttributeTests::_GetTableView() +gsl::span TextAttributeTests::_GetTableView() { - return std::basic_string_view(&_colorTable[0], COLOR_TABLE_SIZE); + return gsl::span(&_colorTable[0], COLOR_TABLE_SIZE); } void TextAttributeTests::TestRoundtripLegacy() diff --git a/src/buffer/out/ut_textbuffer/TextColorTests.cpp b/src/buffer/out/ut_textbuffer/TextColorTests.cpp index 794331fee3d..8d068658b8e 100644 --- a/src/buffer/out/ut_textbuffer/TextColorTests.cpp +++ b/src/buffer/out/ut_textbuffer/TextColorTests.cpp @@ -27,7 +27,7 @@ class TextColorTests COLORREF _colorTable[COLOR_TABLE_SIZE]; COLORREF _defaultFg = RGB(1, 2, 3); COLORREF _defaultBg = RGB(4, 5, 6); - std::basic_string_view _GetTableView(); + gsl::span _GetTableView(); }; bool TextColorTests::ClassSetup() @@ -51,9 +51,9 @@ bool TextColorTests::ClassSetup() return true; } -std::basic_string_view TextColorTests::_GetTableView() +gsl::span TextColorTests::_GetTableView() { - return std::basic_string_view(&_colorTable[0], COLOR_TABLE_SIZE); + return gsl::span(&_colorTable[0], COLOR_TABLE_SIZE); } void TextColorTests::TestDefaultColor() diff --git a/src/cascadia/LocalTests_TerminalApp/CommandTests.cpp b/src/cascadia/LocalTests_TerminalApp/CommandTests.cpp index 129e2469182..1babcf6a2c8 100644 --- a/src/cascadia/LocalTests_TerminalApp/CommandTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/CommandTests.cpp @@ -147,10 +147,8 @@ namespace TerminalAppLocalTests { "name": "command0", "command": { "action": "splitPane", "split": null } }, { "name": "command1", "command": { "action": "splitPane", "split": "vertical" } }, { "name": "command2", "command": { "action": "splitPane", "split": "horizontal" } }, - { "name": "command3", "command": { "action": "splitPane", "split": "none" } }, { "name": "command4", "command": { "action": "splitPane" } }, - { "name": "command5", "command": { "action": "splitPane", "split": "auto" } }, - { "name": "command6", "command": { "action": "splitPane", "split": "foo" } } + { "name": "command5", "command": { "action": "splitPane", "split": "auto" } } ])" }; const auto commands0Json = VerifyParseSucceeded(commands0String); @@ -159,7 +157,7 @@ namespace TerminalAppLocalTests VERIFY_ARE_EQUAL(0u, commands.size()); auto warnings = implementation::Command::LayerJson(commands, commands0Json); VERIFY_ARE_EQUAL(0u, warnings.size()); - VERIFY_ARE_EQUAL(7u, commands.size()); + VERIFY_ARE_EQUAL(5u, commands.size()); { auto command = commands.at(L"command0"); @@ -191,16 +189,6 @@ namespace TerminalAppLocalTests // Verify the args have the expected value VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Horizontal, realArgs.SplitStyle()); } - { - auto command = commands.at(L"command3"); - VERIFY_IS_NOT_NULL(command); - VERIFY_IS_NOT_NULL(command.Action()); - VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action()); - const auto& realArgs = command.Action().Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); - } { auto command = commands.at(L"command4"); VERIFY_IS_NOT_NULL(command); @@ -221,16 +209,6 @@ namespace TerminalAppLocalTests // Verify the args have the expected value VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); } - { - auto command = commands.at(L"command6"); - VERIFY_IS_NOT_NULL(command); - VERIFY_IS_NOT_NULL(command.Action()); - VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action()); - const auto& realArgs = command.Action().Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); - } } void CommandTests::TestResourceKeyName() { diff --git a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp index 760bfd94c8a..ad51cf8269b 100644 --- a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp @@ -323,10 +323,8 @@ namespace TerminalAppLocalTests { "keys": ["ctrl+c"], "command": { "action": "splitPane", "split": null } }, { "keys": ["ctrl+d"], "command": { "action": "splitPane", "split": "vertical" } }, { "keys": ["ctrl+e"], "command": { "action": "splitPane", "split": "horizontal" } }, - { "keys": ["ctrl+f"], "command": { "action": "splitPane", "split": "none" } }, { "keys": ["ctrl+g"], "command": { "action": "splitPane" } }, - { "keys": ["ctrl+h"], "command": { "action": "splitPane", "split": "auto" } }, - { "keys": ["ctrl+i"], "command": { "action": "splitPane", "split": "foo" } } + { "keys": ["ctrl+h"], "command": { "action": "splitPane", "split": "auto" } } ])" }; const auto bindings0Json = VerifyParseSucceeded(bindings0String); @@ -335,7 +333,7 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(appKeyBindings); VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size()); appKeyBindings->LayerJson(bindings0Json); - VERIFY_ARE_EQUAL(7u, appKeyBindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(5u, appKeyBindings->_keyShortcuts.size()); { KeyChord kc{ true, false, false, static_cast('C') }; @@ -364,15 +362,6 @@ namespace TerminalAppLocalTests // Verify the args have the expected value VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Horizontal, realArgs.SplitStyle()); } - { - KeyChord kc{ true, false, false, static_cast('F') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); - } { KeyChord kc{ true, false, false, static_cast('G') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); @@ -391,15 +380,6 @@ namespace TerminalAppLocalTests // Verify the args have the expected value VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); } - { - KeyChord kc{ true, false, false, static_cast('I') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, actionAndArgs.Action()); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle()); - } } void KeyBindingsTests::TestSetTabColorArgs() @@ -407,7 +387,6 @@ namespace TerminalAppLocalTests const std::string bindings0String{ R"([ { "keys": ["ctrl+c"], "command": { "action": "setTabColor", "color": null } }, { "keys": ["ctrl+d"], "command": { "action": "setTabColor", "color": "#123456" } }, - { "keys": ["ctrl+e"], "command": { "action": "setTabColor", "color": "thisStringObviouslyWontWork" } }, { "keys": ["ctrl+f"], "command": "setTabColor" }, ])" }; @@ -417,7 +396,7 @@ namespace TerminalAppLocalTests VERIFY_IS_NOT_NULL(appKeyBindings); VERIFY_ARE_EQUAL(0u, appKeyBindings->_keyShortcuts.size()); appKeyBindings->LayerJson(bindings0Json); - VERIFY_ARE_EQUAL(4u, appKeyBindings->_keyShortcuts.size()); + VERIFY_ARE_EQUAL(3u, appKeyBindings->_keyShortcuts.size()); { KeyChord kc{ true, false, false, static_cast('C') }; @@ -439,15 +418,6 @@ namespace TerminalAppLocalTests // Remember that COLORREFs are actually BBGGRR order, while the string is in #RRGGBB order VERIFY_ARE_EQUAL(static_cast(til::color(0x563412)), realArgs.TabColor().Value()); } - { - KeyChord kc{ true, false, false, static_cast('E') }; - auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); - VERIFY_ARE_EQUAL(ShortcutAction::SetTabColor, actionAndArgs.Action()); - const auto& realArgs = actionAndArgs.Args().try_as(); - VERIFY_IS_NOT_NULL(realArgs); - // Verify the args have the expected value - VERIFY_IS_NULL(realArgs.TabColor()); - } { KeyChord kc{ true, false, false, static_cast('F') }; auto actionAndArgs = TestUtils::GetActionAndArgs(*appKeyBindings, kc); diff --git a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp index 8aed7e4525d..ecd58743f56 100644 --- a/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp @@ -1431,10 +1431,6 @@ namespace TerminalAppLocalTests { "name": "profile3", "closeOnExit": null - }, - { - "name": "profile4", - "closeOnExit": { "clearly": "not a string" } } ] })" }; @@ -1449,7 +1445,6 @@ namespace TerminalAppLocalTests // Unknown modes parse as "Graceful" VERIFY_ARE_EQUAL(CloseOnExitMode::Graceful, settings._profiles[3].GetCloseOnExitMode()); - VERIFY_ARE_EQUAL(CloseOnExitMode::Graceful, settings._profiles[4].GetCloseOnExitMode()); } void SettingsTests::TestCloseOnExitCompatibilityShim() { diff --git a/src/cascadia/TerminalApp/ActionAndArgs.cpp b/src/cascadia/TerminalApp/ActionAndArgs.cpp index cdb7c61eaa5..a5d98e89bd2 100644 --- a/src/cascadia/TerminalApp/ActionAndArgs.cpp +++ b/src/cascadia/TerminalApp/ActionAndArgs.cpp @@ -2,6 +2,9 @@ #include "ActionArgs.h" #include "ActionAndArgs.h" #include "ActionAndArgs.g.cpp" + +#include "JsonUtils.h" + #include static constexpr std::string_view CopyTextKey{ "copy" }; @@ -31,6 +34,7 @@ static constexpr std::string_view FindKey{ "find" }; static constexpr std::string_view ToggleRetroEffectKey{ "toggleRetroEffect" }; static constexpr std::string_view ToggleFocusModeKey{ "toggleFocusMode" }; static constexpr std::string_view ToggleFullscreenKey{ "toggleFullscreen" }; +static constexpr std::string_view ToggleAlwaysOnTopKey{ "toggleAlwaysOnTop" }; static constexpr std::string_view SetTabColorKey{ "setTabColor" }; static constexpr std::string_view OpenTabColorPickerKey{ "openTabColorPicker" }; static constexpr std::string_view RenameTabKey{ "renameTab" }; @@ -43,6 +47,8 @@ static constexpr std::string_view UnboundKey{ "unbound" }; namespace winrt::TerminalApp::implementation { + using namespace ::TerminalApp; + // Specifically use a map here over an unordered_map. We want to be able to // iterate over these entries in-order when we're serializing the keybindings. // HERE BE DRAGONS: @@ -76,6 +82,7 @@ namespace winrt::TerminalApp::implementation { ToggleRetroEffectKey, ShortcutAction::ToggleRetroEffect }, { ToggleFocusModeKey, ShortcutAction::ToggleFocusMode }, { ToggleFullscreenKey, ShortcutAction::ToggleFullscreen }, + { ToggleAlwaysOnTopKey, ShortcutAction::ToggleAlwaysOnTop }, { SplitPaneKey, ShortcutAction::SplitPane }, { SetTabColorKey, ShortcutAction::SetTabColor }, { OpenTabColorPickerKey, ShortcutAction::OpenTabColorPicker }, @@ -181,11 +188,9 @@ namespace winrt::TerminalApp::implementation } else if (json.isObject()) { - const auto actionVal = json[JsonKey(ActionKey)]; - if (actionVal.isString()) + if (const auto actionString{ JsonUtils::GetValueForKey>(json, ActionKey) }) { - auto actionString = actionVal.asString(); - action = GetActionFromString(actionString); + action = GetActionFromString(*actionString); argsVal = json; } } @@ -256,6 +261,7 @@ namespace winrt::TerminalApp::implementation { ShortcutAction::ToggleRetroEffect, RS_(L"ToggleRetroEffectCommandKey") }, { ShortcutAction::ToggleFocusMode, RS_(L"ToggleFocusModeCommandKey") }, { ShortcutAction::ToggleFullscreen, RS_(L"ToggleFullscreenCommandKey") }, + { ShortcutAction::ToggleAlwaysOnTop, RS_(L"ToggleAlwaysOnTopCommandKey") }, { ShortcutAction::SplitPane, RS_(L"SplitPaneCommandKey") }, { ShortcutAction::Invalid, L"" }, { ShortcutAction::Find, RS_(L"FindCommandKey") }, @@ -278,5 +284,4 @@ namespace winrt::TerminalApp::implementation const auto found = GeneratedActionNames.find(_Action); return found != GeneratedActionNames.end() ? found->second : L""; } - } diff --git a/src/cascadia/TerminalApp/ActionArgs.h b/src/cascadia/TerminalApp/ActionArgs.h index eb233b5967a..93e2b5baf3e 100644 --- a/src/cascadia/TerminalApp/ActionArgs.h +++ b/src/cascadia/TerminalApp/ActionArgs.h @@ -23,6 +23,8 @@ #include "JsonUtils.h" #include "TerminalWarnings.h" +#include "TerminalSettingsSerializationHelpers.h" + // Notes on defining ActionArgs and ActionEventArgs: // * All properties specific to an action should be defined as an ActionArgs // class that implements IActionArgs @@ -31,6 +33,7 @@ namespace winrt::TerminalApp::implementation { + using namespace ::TerminalApp; using FromJsonResult = std::tuple>; struct ActionEventArgs : public ActionEventArgsT @@ -73,26 +76,11 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto commandline{ json[JsonKey(CommandlineKey)] }) - { - args->_Commandline = winrt::to_hstring(commandline.asString()); - } - if (auto startingDirectory{ json[JsonKey(StartingDirectoryKey)] }) - { - args->_StartingDirectory = winrt::to_hstring(startingDirectory.asString()); - } - if (auto tabTitle{ json[JsonKey(TabTitleKey)] }) - { - args->_TabTitle = winrt::to_hstring(tabTitle.asString()); - } - if (auto index{ json[JsonKey(ProfileIndexKey)] }) - { - args->_ProfileIndex = index.asInt(); - } - if (auto profile{ json[JsonKey(ProfileKey)] }) - { - args->_Profile = winrt::to_hstring(profile.asString()); - } + JsonUtils::GetValueForKey(json, CommandlineKey, args->_Commandline); + JsonUtils::GetValueForKey(json, StartingDirectoryKey, args->_StartingDirectory); + JsonUtils::GetValueForKey(json, TabTitleKey, args->_TabTitle); + JsonUtils::GetValueForKey(json, ProfileIndexKey, args->_ProfileIndex); + JsonUtils::GetValueForKey(json, ProfileKey, args->_Profile); return *args; } }; @@ -120,10 +108,7 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto singleLine{ json[JsonKey(SingleLineKey)] }) - { - args->_SingleLine = singleLine.asBool(); - } + JsonUtils::GetValueForKey(json, SingleLineKey, args->_SingleLine); return { *args, {} }; } }; @@ -177,49 +162,11 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto tabIndex{ json[JsonKey(TabIndexKey)] }) - { - args->_TabIndex = tabIndex.asUInt(); - } + JsonUtils::GetValueForKey(json, TabIndexKey, args->_TabIndex); return { *args, {} }; } }; - // Possible Direction values - // TODO:GH#2550/#3475 - move these to a centralized deserializing place - static constexpr std::string_view LeftString{ "left" }; - static constexpr std::string_view RightString{ "right" }; - static constexpr std::string_view UpString{ "up" }; - static constexpr std::string_view DownString{ "down" }; - - // Function Description: - // - Helper function for parsing a Direction from a string - // Arguments: - // - directionString: the string to attempt to parse - // Return Value: - // - The encoded Direction value, or Direction::None if it was an invalid string - static TerminalApp::Direction ParseDirection(const std::string& directionString) - { - if (directionString == LeftString) - { - return TerminalApp::Direction::Left; - } - else if (directionString == RightString) - { - return TerminalApp::Direction::Right; - } - else if (directionString == UpString) - { - return TerminalApp::Direction::Up; - } - else if (directionString == DownString) - { - return TerminalApp::Direction::Down; - } - // default behavior for invalid data - return TerminalApp::Direction::None; - }; - struct ResizePaneArgs : public ResizePaneArgsT { ResizePaneArgs() = default; @@ -243,10 +190,7 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto directionString{ json[JsonKey(DirectionKey)] }) - { - args->_Direction = ParseDirection(directionString.asString()); - } + JsonUtils::GetValueForKey(json, DirectionKey, args->_Direction); if (args->_Direction == TerminalApp::Direction::None) { return { nullptr, { ::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter } }; @@ -281,10 +225,7 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto directionString{ json[JsonKey(DirectionKey)] }) - { - args->_Direction = ParseDirection(directionString.asString()); - } + JsonUtils::GetValueForKey(json, DirectionKey, args->_Direction); if (args->_Direction == TerminalApp::Direction::None) { return { nullptr, { ::TerminalApp::SettingsLoadWarnings::MissingRequiredParameter } }; @@ -319,48 +260,11 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto jsonDelta{ json[JsonKey(AdjustFontSizeDelta)] }) - { - args->_Delta = jsonDelta.asInt(); - } + JsonUtils::GetValueForKey(json, AdjustFontSizeDelta, args->_Delta); return { *args, {} }; } }; - // Possible SplitState values - // TODO:GH#2550/#3475 - move these to a centralized deserializing place - static constexpr std::string_view VerticalKey{ "vertical" }; - static constexpr std::string_view HorizontalKey{ "horizontal" }; - static constexpr std::string_view AutomaticKey{ "auto" }; - static TerminalApp::SplitState ParseSplitState(const std::string& stateString) - { - if (stateString == VerticalKey) - { - return TerminalApp::SplitState::Vertical; - } - else if (stateString == HorizontalKey) - { - return TerminalApp::SplitState::Horizontal; - } - else if (stateString == AutomaticKey) - { - return TerminalApp::SplitState::Automatic; - } - // default behavior for invalid data - return TerminalApp::SplitState::Automatic; - }; - - // Possible SplitType values - static constexpr std::string_view DuplicateKey{ "duplicate" }; - static TerminalApp::SplitType ParseSplitModeState(const std::string& stateString) - { - if (stateString == DuplicateKey) - { - return TerminalApp::SplitType::Duplicate; - } - return TerminalApp::SplitType::Manual; - } - struct SplitPaneArgs : public SplitPaneArgsT { SplitPaneArgs() = default; @@ -391,48 +295,12 @@ namespace winrt::TerminalApp::implementation // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); args->_TerminalArgs = NewTerminalArgs::FromJson(json); - if (auto jsonStyle{ json[JsonKey(SplitKey)] }) - { - args->_SplitStyle = ParseSplitState(jsonStyle.asString()); - } - if (auto jsonStyle{ json[JsonKey(SplitModeKey)] }) - { - args->_SplitMode = ParseSplitModeState(jsonStyle.asString()); - } + JsonUtils::GetValueForKey(json, SplitKey, args->_SplitStyle); + JsonUtils::GetValueForKey(json, SplitModeKey, args->_SplitMode); return { *args, {} }; } }; - // Possible SettingsTarget values - // TODO:GH#2550/#3475 - move these to a centralized deserializing place - static constexpr std::string_view SettingsFileString{ "settingsFile" }; - static constexpr std::string_view DefaultsFileString{ "defaultsFile" }; - static constexpr std::string_view AllFilesString{ "allFiles" }; - - // Function Description: - // - Helper function for parsing a SettingsTarget from a string - // Arguments: - // - targetString: the string to attempt to parse - // Return Value: - // - The encoded SettingsTarget value, or SettingsTarget::SettingsFile if it was an invalid string - static TerminalApp::SettingsTarget ParseSettingsTarget(const std::string& targetString) - { - if (targetString == SettingsFileString) - { - return TerminalApp::SettingsTarget::SettingsFile; - } - else if (targetString == DefaultsFileString) - { - return TerminalApp::SettingsTarget::DefaultsFile; - } - else if (targetString == AllFilesString) - { - return TerminalApp::SettingsTarget::AllFiles; - } - // default behavior for invalid data - return TerminalApp::SettingsTarget::SettingsFile; - }; - struct OpenSettingsArgs : public OpenSettingsArgsT { OpenSettingsArgs() = default; @@ -456,10 +324,7 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto targetString{ json[JsonKey(TargetKey)] }) - { - args->_Target = ParseSettingsTarget(targetString.asString()); - } + JsonUtils::GetValueForKey(json, TargetKey, args->_Target); return { *args, {} }; } }; @@ -487,16 +352,10 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - std::optional temp; - try + if (const auto temp{ JsonUtils::GetValueForKey>(json, ColorKey) }) { - ::TerminalApp::JsonUtils::GetOptionalColor(json, ColorKey, temp); - if (temp.has_value()) - { - args->_TabColor = static_cast(temp.value()); - } + args->_TabColor = static_cast(*temp); } - CATCH_LOG(); return { *args, {} }; } }; @@ -524,10 +383,7 @@ namespace winrt::TerminalApp::implementation { // LOAD BEARING: Not using make_self here _will_ break you in the future! auto args = winrt::make_self(); - if (auto title{ json[JsonKey(TitleKey)] }) - { - args->_Title = winrt::to_hstring(title.asString()); - } + JsonUtils::GetValueForKey(json, TitleKey, args->_Title); return { *args, {} }; } }; diff --git a/src/cascadia/TerminalApp/AppActionHandlers.cpp b/src/cascadia/TerminalApp/AppActionHandlers.cpp index 06f00892500..271513d4e58 100644 --- a/src/cascadia/TerminalApp/AppActionHandlers.cpp +++ b/src/cascadia/TerminalApp/AppActionHandlers.cpp @@ -253,6 +253,13 @@ namespace winrt::TerminalApp::implementation args.Handled(true); } + void TerminalPage::_HandleToggleAlwaysOnTop(const IInspectable& /*sender*/, + const TerminalApp::ActionEventArgs& args) + { + ToggleAlwaysOnTop(); + args.Handled(true); + } + void TerminalPage::_HandleToggleCommandPalette(const IInspectable& /*sender*/, const TerminalApp::ActionEventArgs& args) { diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index 77f4e4aefef..e036bd9ee2c 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -1121,6 +1121,21 @@ namespace winrt::TerminalApp::implementation return RS_(L"ApplicationVersionUnknown"); } + bool AppLogic::FocusMode() const + { + return _root ? _root->FocusMode() : false; + } + + bool AppLogic::Fullscreen() const + { + return _root ? _root->Fullscreen() : false; + } + + bool AppLogic::AlwaysOnTop() const + { + return _root ? _root->AlwaysOnTop() : false; + } + // -------------------------------- WinRT Events --------------------------------- // Winrt events need a method for adding a callback to the event and removing the callback. // These macros will define them both for you. diff --git a/src/cascadia/TerminalApp/AppLogic.h b/src/cascadia/TerminalApp/AppLogic.h index 9c030b20051..c879a6f1876 100644 --- a/src/cascadia/TerminalApp/AppLogic.h +++ b/src/cascadia/TerminalApp/AppLogic.h @@ -33,6 +33,9 @@ namespace winrt::TerminalApp::implementation winrt::hstring ApplicationDisplayName() const; winrt::hstring ApplicationVersion() const; + bool FocusMode() const; + bool Fullscreen() const; + bool AlwaysOnTop() const; Windows::Foundation::Point GetLaunchDimensions(uint32_t dpi); winrt::Windows::Foundation::Point GetLaunchInitialPositions(int32_t defaultInitialX, int32_t defaultInitialY); @@ -104,8 +107,9 @@ namespace winrt::TerminalApp::implementation FORWARDED_TYPED_EVENT(SetTitleBarContent, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement, _root, SetTitleBarContent); FORWARDED_TYPED_EVENT(TitleChanged, winrt::Windows::Foundation::IInspectable, winrt::hstring, _root, TitleChanged); FORWARDED_TYPED_EVENT(LastTabClosed, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs, _root, LastTabClosed); - FORWARDED_TYPED_EVENT(ToggleFocusMode, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFocusModeEventArgs, _root, ToggleFocusMode); - FORWARDED_TYPED_EVENT(ToggleFullscreen, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFullscreenEventArgs, _root, ToggleFullscreen); + FORWARDED_TYPED_EVENT(FocusModeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FocusModeChanged); + FORWARDED_TYPED_EVENT(FullscreenChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, FullscreenChanged); + FORWARDED_TYPED_EVENT(AlwaysOnTopChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, _root, AlwaysOnTopChanged); }; } diff --git a/src/cascadia/TerminalApp/AppLogic.idl b/src/cascadia/TerminalApp/AppLogic.idl index 63441984f97..071a5ce84cc 100644 --- a/src/cascadia/TerminalApp/AppLogic.idl +++ b/src/cascadia/TerminalApp/AppLogic.idl @@ -41,6 +41,10 @@ namespace TerminalApp String ApplicationDisplayName { get; }; String ApplicationVersion { get; }; + Boolean FocusMode { get; }; + Boolean Fullscreen { get; }; + Boolean AlwaysOnTop { get; }; + Windows.Foundation.Point GetLaunchDimensions(UInt32 dpi); Windows.Foundation.Point GetLaunchInitialPositions(Int32 defaultInitialX, Int32 defaultInitialY); Windows.UI.Xaml.ElementTheme GetRequestedTheme(); @@ -58,7 +62,8 @@ namespace TerminalApp event Windows.Foundation.TypedEventHandler TitleChanged; event Windows.Foundation.TypedEventHandler LastTabClosed; event Windows.Foundation.TypedEventHandler RequestedThemeChanged; - event Windows.Foundation.TypedEventHandler ToggleFullscreen; - event Windows.Foundation.TypedEventHandler ToggleFocusMode; + event Windows.Foundation.TypedEventHandler FocusModeChanged; + event Windows.Foundation.TypedEventHandler FullscreenChanged; + event Windows.Foundation.TypedEventHandler AlwaysOnTopChanged; } } diff --git a/src/cascadia/TerminalApp/CascadiaSettings.cpp b/src/cascadia/TerminalApp/CascadiaSettings.cpp index 6a38214c478..96e947e952d 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettings.cpp @@ -93,7 +93,7 @@ const Profile* CascadiaSettings::FindProfile(GUID profileGuid) const noexcept // - // Return Value: // - an iterable collection of all of our Profiles. -std::basic_string_view CascadiaSettings::GetProfiles() const noexcept +gsl::span CascadiaSettings::GetProfiles() const noexcept { return { &_profiles[0], _profiles.size() }; } diff --git a/src/cascadia/TerminalApp/CascadiaSettings.h b/src/cascadia/TerminalApp/CascadiaSettings.h index bed41c0d623..004f3809423 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.h +++ b/src/cascadia/TerminalApp/CascadiaSettings.h @@ -59,7 +59,7 @@ class TerminalApp::CascadiaSettings final GlobalAppSettings& GlobalSettings(); - std::basic_string_view GetProfiles() const noexcept; + gsl::span GetProfiles() const noexcept; winrt::TerminalApp::AppKeyBindings GetKeybindings() const noexcept; diff --git a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp index 2ed23f8c770..1a8f2b6e71f 100644 --- a/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettingsSerialization.cpp @@ -249,9 +249,9 @@ void CascadiaSettings::_LoadDynamicProfiles() const auto disabledProfileSources = CascadiaSettings::_GetDisabledProfileSourcesJsonObject(_userSettings); if (disabledProfileSources.isArray()) { - for (const auto& ns : disabledProfileSources) + for (const auto& json : disabledProfileSources) { - ignoredNamespaces.emplace(GetWstringFromJson(ns)); + ignoredNamespaces.emplace(JsonUtils::GetValue(json)); } } diff --git a/src/cascadia/TerminalApp/ColorScheme.cpp b/src/cascadia/TerminalApp/ColorScheme.cpp index 45d4e7748e4..525d8ec95cd 100644 --- a/src/cascadia/TerminalApp/ColorScheme.cpp +++ b/src/cascadia/TerminalApp/ColorScheme.cpp @@ -105,9 +105,9 @@ ColorScheme ColorScheme::FromJson(const Json::Value& json) // - true iff the json object has the same `name` as we do. bool ColorScheme::ShouldBeLayered(const Json::Value& json) const { - if (const auto name{ json[JsonKey(NameKey)] }) + std::wstring nameFromJson{}; + if (JsonUtils::GetValueForKey(json, NameKey, nameFromJson)) { - const auto nameFromJson = GetWstringFromJson(name); return nameFromJson == _schemeName; } return false; @@ -125,39 +125,16 @@ bool ColorScheme::ShouldBeLayered(const Json::Value& json) const // void ColorScheme::LayerJson(const Json::Value& json) { - if (auto name{ json[JsonKey(NameKey)] }) - { - _schemeName = winrt::to_hstring(name.asString()); - } - if (auto fgString{ json[JsonKey(ForegroundKey)] }) - { - const auto color = Utils::ColorFromHexString(fgString.asString()); - _defaultForeground = color; - } - if (auto bgString{ json[JsonKey(BackgroundKey)] }) - { - const auto color = Utils::ColorFromHexString(bgString.asString()); - _defaultBackground = color; - } - if (auto sbString{ json[JsonKey(SelectionBackgroundKey)] }) - { - const auto color = Utils::ColorFromHexString(sbString.asString()); - _selectionBackground = color; - } - if (auto sbString{ json[JsonKey(CursorColorKey)] }) - { - const auto color = Utils::ColorFromHexString(sbString.asString()); - _cursorColor = color; - } + JsonUtils::GetValueForKey(json, NameKey, _schemeName); + JsonUtils::GetValueForKey(json, ForegroundKey, _defaultForeground); + JsonUtils::GetValueForKey(json, BackgroundKey, _defaultBackground); + JsonUtils::GetValueForKey(json, SelectionBackgroundKey, _selectionBackground); + JsonUtils::GetValueForKey(json, CursorColorKey, _cursorColor); int i = 0; for (const auto& current : TableColors) { - if (auto str{ json[JsonKey(current)] }) - { - const auto color = Utils::ColorFromHexString(str.asString()); - _table.at(i) = color; - } + JsonUtils::GetValueForKey(json, current, _table.at(i)); i++; } } @@ -200,11 +177,7 @@ til::color ColorScheme::GetCursorColor() const noexcept // - the name of the color scheme represented by `json` as a std::wstring optional // i.e. the value of the `name` property. // - returns std::nullopt if `json` doesn't have the `name` property -std::optional TerminalApp::ColorScheme::GetNameFromJson(const Json::Value& json) +std::optional ColorScheme::GetNameFromJson(const Json::Value& json) { - if (const auto name{ json[JsonKey(NameKey)] }) - { - return GetWstringFromJson(name); - } - return std::nullopt; + return JsonUtils::GetValueForKey>(json, NameKey); } diff --git a/src/cascadia/TerminalApp/Command.cpp b/src/cascadia/TerminalApp/Command.cpp index a8e72ec6a84..f3fe1219126 100644 --- a/src/cascadia/TerminalApp/Command.cpp +++ b/src/cascadia/TerminalApp/Command.cpp @@ -7,10 +7,12 @@ #include "Utils.h" #include "ActionAndArgs.h" +#include "JsonUtils.h" #include using namespace winrt::Microsoft::Terminal::Settings; using namespace winrt::TerminalApp; +using namespace ::TerminalApp; static constexpr std::string_view NameKey{ "name" }; static constexpr std::string_view IconPathKey{ "iconPath" }; @@ -35,25 +37,17 @@ namespace winrt::TerminalApp::implementation { if (name.isObject()) { - try + if (const auto resourceKey{ JsonUtils::GetValueForKey>(name, "key") }) { - if (const auto keyJson{ name[JsonKey("key")] }) + if (HasLibraryResourceWithName(*resourceKey)) { - // Make sure the key is present before we try - // loading it. Otherwise we'll crash - const auto resourceKey = GetWstringFromJson(keyJson); - if (HasLibraryResourceWithName(resourceKey)) - { - return GetLibraryResourceString(resourceKey); - } + return GetLibraryResourceString(*resourceKey); } } - CATCH_LOG(); } else if (name.isString()) { - auto nameStr = name.asString(); - return winrt::to_hstring(nameStr); + return JsonUtils::GetValue(name); } } diff --git a/src/cascadia/TerminalApp/CommandPalette.cpp b/src/cascadia/TerminalApp/CommandPalette.cpp index 6fac2d35d62..33d32defe7e 100644 --- a/src/cascadia/TerminalApp/CommandPalette.cpp +++ b/src/cascadia/TerminalApp/CommandPalette.cpp @@ -271,16 +271,17 @@ namespace winrt::TerminalApp::implementation }; // Method Description: - // - Update our list of filtered actions to reflect the current contents of + // - Produce a list of filtered actions to reflect the current contents of // the input box. For more details on which commands will be displayed, // see `_getWeight`. // Arguments: - // - + // - A collection that will receive the filtered actions // Return Value: // - - void CommandPalette::_updateFilteredActions() + std::vector CommandPalette::_collectFilteredActions() { - _filteredActions.Clear(); + std::vector actions; + auto searchText = _searchBox().Text(); const bool addAll = searchText.empty(); @@ -303,10 +304,10 @@ namespace winrt::TerminalApp::implementation for (auto action : sortedCommands) { - _filteredActions.Append(action); + actions.push_back(action); } - return; + return actions; } // Here, there was some filter text. @@ -343,7 +344,56 @@ namespace winrt::TerminalApp::implementation { auto top = heap.top(); heap.pop(); - _filteredActions.Append(top.command); + actions.push_back(top.command); + } + + return actions; + } + + // Method Description: + // - Update our list of filtered actions to reflect the current contents of + // the input box. For more details on which commands will be displayed, + // see `_getWeight`. + // Arguments: + // - + // Return Value: + // - + void CommandPalette::_updateFilteredActions() + { + auto actions = _collectFilteredActions(); + + // Make _filteredActions look identical to actions, using only Insert and Remove. + // This allows WinUI to nicely animate the ListView as it changes. + for (uint32_t i = 0; i < _filteredActions.Size() && i < actions.size(); i++) + { + for (uint32_t j = i; j < _filteredActions.Size(); j++) + { + if (_filteredActions.GetAt(j) == actions[i]) + { + for (uint32_t k = i; k < j; k++) + { + _filteredActions.RemoveAt(i); + } + break; + } + } + + if (_filteredActions.GetAt(i) != actions[i]) + { + _filteredActions.InsertAt(i, actions[i]); + } + } + + // Remove any extra trailing items from the destination + while (_filteredActions.Size() > actions.size()) + { + _filteredActions.RemoveAtEnd(); + } + + // Add any extra trailing items from the source + while (_filteredActions.Size() < actions.size()) + { + _filteredActions.Append(actions[_filteredActions.Size()]); } } diff --git a/src/cascadia/TerminalApp/CommandPalette.h b/src/cascadia/TerminalApp/CommandPalette.h index 2d396070518..a14466f4f36 100644 --- a/src/cascadia/TerminalApp/CommandPalette.h +++ b/src/cascadia/TerminalApp/CommandPalette.h @@ -37,6 +37,7 @@ namespace winrt::TerminalApp::implementation void _selectNextItem(const bool moveDown); void _updateFilteredActions(); + std::vector _collectFilteredActions(); static int _getWeight(const winrt::hstring& searchText, const winrt::hstring& name); void _close(); diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.cpp b/src/cascadia/TerminalApp/GlobalAppSettings.cpp index e623634ae7f..c214c04896d 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalApp/GlobalAppSettings.cpp @@ -7,11 +7,11 @@ #include "../../inc/DefaultSettings.h" #include "Utils.h" #include "JsonUtils.h" +#include "TerminalSettingsSerializationHelpers.h" using namespace TerminalApp; using namespace winrt::Microsoft::Terminal::Settings; using namespace winrt::TerminalApp; -using namespace winrt::Windows::Data::Json; using namespace winrt::Windows::UI::Xaml; using namespace ::Microsoft::Console; using namespace winrt::Microsoft::UI::Xaml::Controls; @@ -36,6 +36,7 @@ static constexpr std::string_view LaunchModeKey{ "launchMode" }; static constexpr std::string_view ConfirmCloseAllKey{ "confirmCloseAllTabs" }; static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" }; static constexpr std::string_view EnableStartupTaskKey{ "startOnUserLogin" }; +static constexpr std::string_view AlwaysOnTopKey{ "alwaysOnTop" }; static constexpr std::string_view DebugFeaturesKey{ "debugFeatures" }; @@ -43,21 +44,6 @@ static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.re static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" }; static constexpr std::string_view ForceVTInputKey{ "experimental.input.forceVT" }; -// Launch mode values -static constexpr std::wstring_view DefaultLaunchModeValue{ L"default" }; -static constexpr std::wstring_view MaximizedLaunchModeValue{ L"maximized" }; -static constexpr std::wstring_view FullscreenLaunchModeValue{ L"fullscreen" }; - -// Tab Width Mode values -static constexpr std::wstring_view EqualTabWidthModeValue{ L"equal" }; -static constexpr std::wstring_view TitleLengthTabWidthModeValue{ L"titleLength" }; -static constexpr std::wstring_view TitleLengthCompactModeValue{ L"compact" }; - -// Theme values -static constexpr std::wstring_view LightThemeValue{ L"light" }; -static constexpr std::wstring_view DarkThemeValue{ L"dark" }; -static constexpr std::wstring_view SystemThemeValue{ L"system" }; - #ifdef _DEBUG static constexpr bool debugFeaturesDefault{ true }; #else @@ -148,64 +134,51 @@ GlobalAppSettings GlobalAppSettings::FromJson(const Json::Value& json) void GlobalAppSettings::LayerJson(const Json::Value& json) { - if (auto defaultProfile{ json[JsonKey(DefaultProfileKey)] }) - { - _unparsedDefaultProfile.emplace(GetWstringFromJson(defaultProfile)); - } + JsonUtils::GetValueForKey(json, DefaultProfileKey, _unparsedDefaultProfile); + + JsonUtils::GetValueForKey(json, AlwaysShowTabsKey, _AlwaysShowTabs); - JsonUtils::GetBool(json, AlwaysShowTabsKey, _AlwaysShowTabs); + JsonUtils::GetValueForKey(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); - JsonUtils::GetBool(json, ConfirmCloseAllKey, _ConfirmCloseAllTabs); + JsonUtils::GetValueForKey(json, InitialRowsKey, _InitialRows); - JsonUtils::GetInt(json, InitialRowsKey, _InitialRows); + JsonUtils::GetValueForKey(json, InitialColsKey, _InitialCols); - JsonUtils::GetInt(json, InitialColsKey, _InitialCols); + JsonUtils::GetValueForKey(json, InitialPositionKey, _InitialPosition); - if (auto initialPosition{ json[JsonKey(InitialPositionKey)] }) - { - _ParseInitialPosition(initialPosition.asString(), _InitialPosition); - } + JsonUtils::GetValueForKey(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); - JsonUtils::GetBool(json, ShowTitleInTitlebarKey, _ShowTitleInTitlebar); + JsonUtils::GetValueForKey(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); - JsonUtils::GetBool(json, ShowTabsInTitlebarKey, _ShowTabsInTitlebar); + JsonUtils::GetValueForKey(json, WordDelimitersKey, _WordDelimiters); - JsonUtils::GetWstring(json, WordDelimitersKey, _WordDelimiters); + JsonUtils::GetValueForKey(json, CopyOnSelectKey, _CopyOnSelect); - JsonUtils::GetBool(json, CopyOnSelectKey, _CopyOnSelect); + JsonUtils::GetValueForKey(json, CopyFormattingKey, _CopyFormatting); - JsonUtils::GetBool(json, CopyFormattingKey, _CopyFormatting); + JsonUtils::GetValueForKey(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); - JsonUtils::GetBool(json, WarnAboutLargePasteKey, _WarnAboutLargePaste); + JsonUtils::GetValueForKey(json, WarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste); - JsonUtils::GetBool(json, WarnAboutMultiLinePasteKey, _WarnAboutMultiLinePaste); + JsonUtils::GetValueForKey(json, LaunchModeKey, _LaunchMode); - if (auto launchMode{ json[JsonKey(LaunchModeKey)] }) - { - _LaunchMode = _ParseLaunchMode(GetWstringFromJson(launchMode)); - } + JsonUtils::GetValueForKey(json, ThemeKey, _Theme); - if (auto theme{ json[JsonKey(ThemeKey)] }) - { - _Theme = _ParseTheme(GetWstringFromJson(theme)); - } + JsonUtils::GetValueForKey(json, TabWidthModeKey, _TabWidthMode); - if (auto tabWidthMode{ json[JsonKey(TabWidthModeKey)] }) - { - _TabWidthMode = _ParseTabWidthMode(GetWstringFromJson(tabWidthMode)); - } + JsonUtils::GetValueForKey(json, SnapToGridOnResizeKey, _SnapToGridOnResize); - JsonUtils::GetBool(json, SnapToGridOnResizeKey, _SnapToGridOnResize); + // GetValueForKey will only override the current value if the key exists + JsonUtils::GetValueForKey(json, DebugFeaturesKey, _DebugFeaturesEnabled); - JsonUtils::GetBool(json, ForceFullRepaintRenderingKey, _ForceFullRepaintRendering); + JsonUtils::GetValueForKey(json, ForceFullRepaintRenderingKey, _ForceFullRepaintRendering); - JsonUtils::GetBool(json, SoftwareRenderingKey, _SoftwareRendering); - JsonUtils::GetBool(json, ForceVTInputKey, _ForceVTInput); + JsonUtils::GetValueForKey(json, SoftwareRenderingKey, _SoftwareRendering); + JsonUtils::GetValueForKey(json, ForceVTInputKey, _ForceVTInput); - // GetBool will only override the current value if the key exists - JsonUtils::GetBool(json, DebugFeaturesKey, _DebugFeaturesEnabled); + JsonUtils::GetValueForKey(json, EnableStartupTaskKey, _StartOnUserLogin); - JsonUtils::GetBool(json, EnableStartupTaskKey, _StartOnUserLogin); + JsonUtils::GetValueForKey(json, AlwaysOnTopKey, _AlwaysOnTop); // This is a helper lambda to get the keybindings and commands out of both // and array of objects. We'll use this twice, once on the legacy @@ -233,116 +206,6 @@ void GlobalAppSettings::LayerJson(const Json::Value& json) parseBindings(BindingsKey); } -// Method Description: -// - Helper function for converting a user-specified cursor style corresponding -// CursorStyle enum value -// Arguments: -// - themeString: The string value from the settings file to parse -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -ElementTheme GlobalAppSettings::_ParseTheme(const std::wstring& themeString) noexcept -{ - if (themeString == LightThemeValue) - { - return ElementTheme::Light; - } - else if (themeString == DarkThemeValue) - { - return ElementTheme::Dark; - } - // default behavior for invalid data or SystemThemeValue - return ElementTheme::Default; -} - -// Method Description: -// - Helper function for converting the initial position string into -// 2 coordinate values. We allow users to only provide one coordinate, -// thus, we use comma as the separator: -// (100, 100): standard input string -// (, 100), (100, ): if a value is missing, we set this value as a default -// (,): both x and y are set to default -// (abc, 100): if a value is not valid, we treat it as default -// (100, 100, 100): we only read the first two values, this is equivalent to (100, 100) -// Arguments: -// - initialPosition: the initial position string from json -// ret: reference to a struct whose optionals will be populated -// Return Value: -// - None -void GlobalAppSettings::_ParseInitialPosition(const std::string& initialPosition, - LaunchPosition& ret) noexcept -{ - static constexpr char singleCharDelim = ','; - std::stringstream tokenStream(initialPosition); - std::string token; - uint8_t initialPosIndex = 0; - - // Get initial position values till we run out of delimiter separated values in the stream - // or we hit max number of allowable values (= 2) - // Non-numeral values or empty string will be caught as exception and we do not assign them - for (; std::getline(tokenStream, token, singleCharDelim) && (initialPosIndex < 2); initialPosIndex++) - { - try - { - int32_t position = std::stoi(token); - if (initialPosIndex == 0) - { - ret.x.emplace(position); - } - - if (initialPosIndex == 1) - { - ret.y.emplace(position); - } - } - catch (...) - { - // Do nothing - } - } -} - -// Method Description: -// - Helper function for converting the user-specified launch mode -// to a LaunchMode enum value -// Arguments: -// - launchModeString: The string value from the settings file to parse -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -LaunchMode GlobalAppSettings::_ParseLaunchMode(const std::wstring& launchModeString) noexcept -{ - if (launchModeString == MaximizedLaunchModeValue) - { - return LaunchMode::MaximizedMode; - } - else if (launchModeString == FullscreenLaunchModeValue) - { - return LaunchMode::FullscreenMode; - } - - return LaunchMode::DefaultMode; -} - -// Method Description: -// - Helper function for converting the user-specified tab width -// to a TabViewWidthMode enum value -// Arguments: -// - tabWidthModeString: The string value from the settings file to parse -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -TabViewWidthMode GlobalAppSettings::_ParseTabWidthMode(const std::wstring& tabWidthModeString) noexcept -{ - if (tabWidthModeString == TitleLengthTabWidthModeValue) - { - return TabViewWidthMode::SizeToContent; - } - else if (tabWidthModeString == TitleLengthCompactModeValue) - { - return TabViewWidthMode::Compact; - } - // default behavior for invalid data or EqualTabWidthValue - return TabViewWidthMode::Equal; -} - // Method Description: // - Adds the given colorscheme to our map of schemes, using its name as the key. // Arguments: diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.h b/src/cascadia/TerminalApp/GlobalAppSettings.h index 58f8ea5a469..7491b433f41 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.h +++ b/src/cascadia/TerminalApp/GlobalAppSettings.h @@ -17,6 +17,7 @@ Author(s): #include "AppKeyBindings.h" #include "ColorScheme.h" #include "Command.h" +#include "SettingsTypes.h" // fwdecl unittest classes namespace TerminalAppLocalTests @@ -28,12 +29,6 @@ namespace TerminalAppLocalTests namespace TerminalApp { class GlobalAppSettings; - - struct LaunchPosition - { - std::optional x; - std::optional y; - }; }; class TerminalApp::GlobalAppSettings final @@ -84,6 +79,7 @@ class TerminalApp::GlobalAppSettings final GETSET_PROPERTY(bool, ForceVTInput, false); GETSET_PROPERTY(bool, DebugFeaturesEnabled); // default value set in constructor GETSET_PROPERTY(bool, StartOnUserLogin, false); + GETSET_PROPERTY(bool, AlwaysOnTop, false); private: std::optional _unparsedDefaultProfile; @@ -95,15 +91,6 @@ class TerminalApp::GlobalAppSettings final std::unordered_map _colorSchemes; std::unordered_map _commands; - static winrt::Windows::UI::Xaml::ElementTheme _ParseTheme(const std::wstring& themeString) noexcept; - - static winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode _ParseTabWidthMode(const std::wstring& tabWidthModeString) noexcept; - - static void _ParseInitialPosition(const std::string& initialPosition, - LaunchPosition& ret) noexcept; - - static winrt::TerminalApp::LaunchMode _ParseLaunchMode(const std::wstring& launchModeString) noexcept; - friend class TerminalAppLocalTests::SettingsTests; friend class TerminalAppLocalTests::ColorSchemeTests; }; diff --git a/src/cascadia/TerminalApp/JsonUtils.cpp b/src/cascadia/TerminalApp/JsonUtils.cpp deleted file mode 100644 index f4282097b83..00000000000 --- a/src/cascadia/TerminalApp/JsonUtils.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include "Utils.h" -#include "JsonUtils.h" -#include "../../types/inc/Utils.hpp" - -void TerminalApp::JsonUtils::GetOptionalColor(const Json::Value& json, - std::string_view key, - std::optional& target) -{ - const auto conversionFn = [](const Json::Value& value) -> til::color { - return ::Microsoft::Console::Utils::ColorFromHexString(value.asString()); - }; - GetOptionalValue(json, - key, - target, - conversionFn); -} - -void TerminalApp::JsonUtils::GetOptionalString(const Json::Value& json, - std::string_view key, - std::optional& target) -{ - const auto conversionFn = [](const Json::Value& value) -> std::wstring { - return GetWstringFromJson(value); - }; - GetOptionalValue(json, - key, - target, - conversionFn); -} - -void TerminalApp::JsonUtils::GetOptionalGuid(const Json::Value& json, - std::string_view key, - std::optional& target) -{ - const auto conversionFn = [](const Json::Value& value) -> GUID { - return ::Microsoft::Console::Utils::GuidFromString(GetWstringFromJson(value)); - }; - GetOptionalValue(json, - key, - target, - conversionFn); -} - -void TerminalApp::JsonUtils::GetOptionalDouble(const Json::Value& json, - std::string_view key, - std::optional& target) -{ - const auto conversionFn = [](const Json::Value& value) -> double { - return value.asFloat(); - }; - const auto validationFn = [](const Json::Value& value) -> bool { - return value.isNumeric(); - }; - GetOptionalValue(json, - key, - target, - conversionFn, - validationFn); -} - -void TerminalApp::JsonUtils::GetInt(const Json::Value& json, - std::string_view key, - int& target) -{ - const auto conversionFn = [](const Json::Value& value) -> int { - return value.asInt(); - }; - const auto validationFn = [](const Json::Value& value) -> bool { - return value.isInt(); - }; - GetValue(json, key, target, conversionFn, validationFn); -} - -void TerminalApp::JsonUtils::GetUInt(const Json::Value& json, - std::string_view key, - uint32_t& target) -{ - const auto conversionFn = [](const Json::Value& value) -> uint32_t { - return value.asUInt(); - }; - const auto validationFn = [](const Json::Value& value) -> bool { - return value.isUInt(); - }; - GetValue(json, key, target, conversionFn, validationFn); -} - -void TerminalApp::JsonUtils::GetDouble(const Json::Value& json, - std::string_view key, - double& target) -{ - const auto conversionFn = [](const Json::Value& value) -> double { - return value.asFloat(); - }; - const auto validationFn = [](const Json::Value& value) -> bool { - return value.isNumeric(); - }; - GetValue(json, key, target, conversionFn, validationFn); -} - -void TerminalApp::JsonUtils::GetBool(const Json::Value& json, - std::string_view key, - bool& target) -{ - const auto conversionFn = [](const Json::Value& value) -> bool { - return value.asBool(); - }; - const auto validationFn = [](const Json::Value& value) -> bool { - return value.isBool(); - }; - GetValue(json, key, target, conversionFn, validationFn); -} - -void TerminalApp::JsonUtils::GetWstring(const Json::Value& json, - std::string_view key, - std::wstring& target) -{ - const auto conversionFn = [](const Json::Value& value) -> std::wstring { - return GetWstringFromJson(value); - }; - GetValue(json, key, target, conversionFn, nullptr); -} diff --git a/src/cascadia/TerminalApp/JsonUtils.h b/src/cascadia/TerminalApp/JsonUtils.h index 1845a9d6524..b98ade1da9d 100644 --- a/src/cascadia/TerminalApp/JsonUtils.h +++ b/src/cascadia/TerminalApp/JsonUtils.h @@ -9,136 +9,483 @@ Module Name: - Helpers for the TerminalApp project Author(s): - Mike Griese - August 2019 - +- Dustin Howett - January 2020 --*/ + #pragma once +#include + +#include "../types/inc/utils.hpp" + +namespace winrt +{ + // If we don't use winrt, nobody will include the ConversionTraits for winrt stuff. + // If nobody includes it, these forward declarations will suffice. + struct guid; + struct hstring; + namespace Windows::Foundation + { + template + struct IReference; + } +} + namespace TerminalApp::JsonUtils { - void GetOptionalColor(const Json::Value& json, - std::string_view key, - std::optional& target); + namespace Detail + { + // Function Description: + // - Returns a string_view to a Json::Value's internal string storage, + // hopefully without copying it. + __declspec(noinline) inline const std::string_view GetStringView(const Json::Value& json) + { + const char* begin{ nullptr }; + const char* end{ nullptr }; + json.getString(&begin, &end); + const std::string_view zeroCopyString{ begin, gsl::narrow_cast(end - begin) }; + return zeroCopyString; + } - void GetOptionalString(const Json::Value& json, - std::string_view key, - std::optional& target); + template + struct DeduceOptional + { + using Type = typename std::decay::type; + static constexpr bool IsOptional = false; + }; - void GetOptionalGuid(const Json::Value& json, - std::string_view key, - std::optional& target); + template + struct DeduceOptional> + { + using Type = typename std::decay::type; + static constexpr bool IsOptional = true; + }; - void GetOptionalDouble(const Json::Value& json, - std::string_view key, - std::optional& target); + template + struct DeduceOptional<::winrt::Windows::Foundation::IReference> + { + using Type = typename std::decay::type; + static constexpr bool IsOptional = true; + }; + } - // Method Description: - // - Helper that can be used for retrieving an optional value from a json - // object, and parsing it's value to layer on a given target object. - // - If the key we're looking for _doesn't_ exist in the json object, - // we'll leave the target object unmodified. - // - If the key exists in the json object, but is set to `null`, then - // we'll instead set the target back to nullopt. - // - Each caller should provide a conversion function that takes a - // Json::Value and returns an object of the same type as target. - // Arguments: - // - json: The json object to search for the given key - // - key: The key to look for in the json object - // - target: the optional object to receive the value from json - // - conversion: a std::function which can be used to - // convert the Json::Value to the appropriate type. - // - validation: optional, if provided, will be called first to ensure that - // the json::value is of the correct type before attempting to call - // `conversion`. - // Return Value: - // - - template - void GetOptionalValue(const Json::Value& json, - std::string_view key, - std::optional& target, - F&& conversion, - const std::function& validation = nullptr) + // These exceptions cannot use localized messages, as we do not have + // guaranteed access to the resource loader. + class TypeMismatchException : public std::runtime_error + { + public: + TypeMismatchException() : + runtime_error("unexpected data type") {} + }; + + class KeyedException : public std::runtime_error + { + public: + KeyedException(const std::string_view key, std::exception_ptr exception) : + runtime_error(fmt::format("error parsing \"{0}\"", key).c_str()), + _key{ key }, + _innerException{ std::move(exception) } {} + + std::string GetKey() const + { + return _key; + } + + [[noreturn]] void RethrowInner() const + { + std::rethrow_exception(_innerException); + } + + private: + std::string _key; + std::exception_ptr _innerException; + }; + + class UnexpectedValueException : public std::runtime_error + { + public: + UnexpectedValueException(const std::string_view value) : + runtime_error(fmt::format("unexpected value \"{0}\"", value).c_str()), + _value{ value } {} + + std::string GetValue() const + { + return _value; + } + + private: + std::string _value; + }; + + template + struct ConversionTrait + { + // Forward-declare these so the linker can pick up specializations from elsewhere! + T FromJson(const Json::Value&); + bool CanConvert(const Json::Value& json); + }; + + template<> + struct ConversionTrait + { + std::string FromJson(const Json::Value& json) + { + return json.asString(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isString(); + } + }; + + template<> + struct ConversionTrait + { + std::wstring FromJson(const Json::Value& json) + { + return til::u8u16(Detail::GetStringView(json)); + } + + bool CanConvert(const Json::Value& json) + { + return json.isString(); + } + }; + +#ifdef WINRT_BASE_H + template<> + struct ConversionTrait : public ConversionTrait + { + // Leverage the wstring converter's validation + winrt::hstring FromJson(const Json::Value& json) + { + return winrt::hstring{ til::u8u16(Detail::GetStringView(json)) }; + } + }; +#endif + + template<> + struct ConversionTrait + { + bool FromJson(const Json::Value& json) + { + return json.asBool(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isBool(); + } + }; + + template<> + struct ConversionTrait + { + int FromJson(const Json::Value& json) + { + return json.asInt(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isInt(); + } + }; + + template<> + struct ConversionTrait + { + unsigned int FromJson(const Json::Value& json) + { + return json.asUInt(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isUInt(); + } + }; + + template<> + struct ConversionTrait + { + float FromJson(const Json::Value& json) + { + return json.asFloat(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isNumeric(); + } + }; + + template<> + struct ConversionTrait + { + double FromJson(const Json::Value& json) + { + return json.asDouble(); + } + + bool CanConvert(const Json::Value& json) + { + return json.isNumeric(); + } + }; + + template<> + struct ConversionTrait + { + GUID FromJson(const Json::Value& json) + { + return ::Microsoft::Console::Utils::GuidFromString(til::u8u16(Detail::GetStringView(json))); + } + + bool CanConvert(const Json::Value& json) + { + if (!json.isString()) + { + return false; + } + + const auto string{ Detail::GetStringView(json) }; + return string.length() == 38 && string.front() == '{' && string.back() == '}'; + } + }; + + // (GUID and winrt::guid are mutually convertible!) + template<> + struct ConversionTrait : public ConversionTrait + { + }; + + template<> + struct ConversionTrait + { + til::color FromJson(const Json::Value& json) + { + return ::Microsoft::Console::Utils::ColorFromHexString(Detail::GetStringView(json)); + } + + bool CanConvert(const Json::Value& json) + { + if (!json.isString()) + { + return false; + } + + const auto string{ Detail::GetStringView(json) }; + return (string.length() == 7 || string.length() == 4) && string.front() == '#'; + } + }; + + template + struct EnumMapper { - if (json.isMember(JsonKey(key))) + using BaseEnumMapper = EnumMapper; + using ValueType = T; + using pair_type = std::pair; + T FromJson(const Json::Value& json) { - if (auto jsonVal{ json[JsonKey(key)] }) + const auto name{ Detail::GetStringView(json) }; + for (const auto& pair : TBase::mappings) { - if (validation == nullptr || validation(jsonVal)) + if (pair.first == name) { - target = conversion(jsonVal); + return pair.second; } } - else + + throw UnexpectedValueException{ name }; + } + + bool CanConvert(const Json::Value& json) + { + return json.isString(); + } + }; + + // FlagMapper is EnumMapper, but it works for bitfields. + // It supports a string (single flag) or an array of strings. + // Does an O(n*m) search; meant for small search spaces! + // + // Cleverly leverage EnumMapper to do the heavy lifting. + template + struct FlagMapper : public EnumMapper + { + private: + // Hide BaseEnumMapper so FlagMapper's consumers cannot see + // it. + using BaseEnumMapper = EnumMapper::BaseEnumMapper; + + public: + using BaseFlagMapper = FlagMapper; + static constexpr T AllSet{ static_cast(~0u) }; + static constexpr T AllClear{ static_cast(0u) }; + + T FromJson(const Json::Value& json) + { + if (json.isString()) + { + return BaseEnumMapper::FromJson(json); + } + else if (json.isArray()) { - // This branch is hit when the json object contained the key, - // but the key was set to `null`. In this case, explicitly clear - // the target. - target = std::nullopt; + unsigned int seen{ 0 }; + T value{}; + for (const auto& element : json) + { + const auto newFlag{ BaseEnumMapper::FromJson(element) }; + if (++seen > 1 && + ((newFlag == AllClear && value != AllClear) || + (value == AllClear && newFlag != AllClear))) + { + // attempt to combine AllClear (explicitly) with anything else + throw UnexpectedValueException{ element.asString() }; + } + value |= newFlag; + } + return value; } + + // We'll only get here if CanConvert has failed us. + return AllClear; } - } + + bool CanConvert(const Json::Value& json) + { + return BaseEnumMapper::CanConvert(json) || json.isArray(); + } + }; // Method Description: - // - Helper that can be used for retrieving a value from a json - // object, and parsing it's value to set on a given target object. - // - If the key we're looking for _doesn't_ exist in the json object, - // we'll leave the target object unmodified. - // - If the key exists in the json object, we'll use the provided - // `validation` function to ensure that the json value is of the - // correct type. - // - If we successfully validate the json value type (or no validation - // function was provided), then we'll use `conversion` to parse the - // value and place the result into `target` - // - Each caller should provide a conversion function that takes a - // Json::Value and returns an object of the same type as target. - // - Unlike GetOptionalValue, if the key exists but is set to `null`, we'll - // just ignore it. + // - Helper that will populate a reference with a value converted from a json object. // Arguments: - // - json: The json object to search for the given key - // - key: The key to look for in the json object - // - target: the optional object to receive the value from json - // - conversion: a std::function which can be used to - // convert the Json::Value to the appropriate type. - // - validation: optional, if provided, will be called first to ensure that - // the json::value is of the correct type before attempting to call - // `conversion`. + // - json: the json object to convert + // - target: the value to populate with the converted result // Return Value: - // - - template - void GetValue(const Json::Value& json, - std::string_view key, - T& target, - F&& conversion, - const std::function& validation = nullptr) + // - a boolean indicating whether the value existed (in this case, was non-null) + // + // GetValue, type-deduced, manual converter + template + bool GetValue(const Json::Value& json, T& target, Converter&& conv) { - if (json.isMember(JsonKey(key))) + if constexpr (Detail::DeduceOptional::IsOptional) { - if (auto jsonVal{ json[JsonKey(key)] }) + // FOR OPTION TYPES + // - If the json object is set to `null`, then + // we'll instead set the target back to the empty optional. + if (json.isNull()) { - if (validation == nullptr || validation(jsonVal)) - { - target = conversion(jsonVal); - } + target = T{}; // zero-construct an empty optional + return true; + } + } + + if (json) + { + if (!conv.CanConvert(json)) + { + throw TypeMismatchException{}; + } + + target = conv.FromJson(json); + return true; + } + return false; + } + + // GetValue, forced return type, manual converter + template + std::decay_t GetValue(const Json::Value& json, Converter&& conv) + { + std::decay_t local{}; + GetValue(json, local, std::forward(conv)); + return local; // returns zero-initialized or value + } + + // GetValueForKey, type-deduced, manual converter + template + bool GetValueForKey(const Json::Value& json, std::string_view key, T& target, Converter&& conv) + { + if (auto found{ json.find(&*key.cbegin(), (&*key.cbegin()) + key.size()) }) + { + try + { + return GetValue(*found, target, std::forward(conv)); + } + catch (...) + { + // Wrap any caught exceptions in one that preserves context. + throw KeyedException(key, std::current_exception()); } } + return false; } - void GetInt(const Json::Value& json, - std::string_view key, - int& target); + // GetValueForKey, forced return type, manual converter + template + std::decay_t GetValueForKey(const Json::Value& json, std::string_view key, Converter&& conv) + { + std::decay_t local{}; + GetValueForKey(json, key, local, std::forward(conv)); + return local; // returns zero-initialized? + } - void GetUInt(const Json::Value& json, - std::string_view key, - uint32_t& target); + // GetValue, type-deduced, with automatic converter + template + bool GetValue(const Json::Value& json, T& target) + { + return GetValue(json, target, ConversionTrait::Type>{}); + } - void GetDouble(const Json::Value& json, - std::string_view key, - double& target); + // GetValue, forced return type, with automatic converter + template + std::decay_t GetValue(const Json::Value& json) + { + std::decay_t local{}; + GetValue(json, local, ConversionTrait::Type>{}); + return local; // returns zero-initialized or value + } - void GetBool(const Json::Value& json, - std::string_view key, - bool& target); + // GetValueForKey, type-deduced, with automatic converter + template + bool GetValueForKey(const Json::Value& json, std::string_view key, T& target) + { + return GetValueForKey(json, key, target, ConversionTrait::Type>{}); + } + + // GetValueForKey, forced return type, with automatic converter + template + std::decay_t GetValueForKey(const Json::Value& json, std::string_view key) + { + return GetValueForKey(json, key, ConversionTrait::Type>{}); + } + + // Get multiple values for keys (json, k, &v, k, &v, k, &v, ...). + // Uses the default converter for each v. + // Careful: this can cause a template explosion. + constexpr void GetValuesForKeys(const Json::Value& /*json*/) {} - void GetWstring(const Json::Value& json, - std::string_view key, - std::wstring& target); + template + void GetValuesForKeys(const Json::Value& json, std::string_view key1, T&& val1, Args&&... args) + { + GetValueForKey(json, key1, val1); + GetValuesForKeys(json, std::forward(args)...); + } }; + +#define JSON_ENUM_MAPPER(...) \ + template<> \ + struct ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__> : \ + public ::TerminalApp::JsonUtils::EnumMapper<__VA_ARGS__, ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__>> + +#define JSON_FLAG_MAPPER(...) \ + template<> \ + struct ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__> : \ + public ::TerminalApp::JsonUtils::FlagMapper<__VA_ARGS__, ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__>> + +#define JSON_MAPPINGS(Count) \ + static constexpr std::array mappings diff --git a/src/cascadia/TerminalApp/JsonUtilsNew.h b/src/cascadia/TerminalApp/JsonUtilsNew.h deleted file mode 100644 index 03e9826f4b2..00000000000 --- a/src/cascadia/TerminalApp/JsonUtilsNew.h +++ /dev/null @@ -1,490 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- JsonUtils.h - -Abstract: -- Helpers for the TerminalApp project -Author(s): -- Mike Griese - August 2019 -- Dustin Howett - January 2020 ---*/ - -#pragma once - -#include - -#include "../types/inc/utils.hpp" - -namespace winrt -{ - // If we don't use winrt, nobody will include the ConversionTraits for winrt stuff. - // If nobody includes it, these forward declarations will suffice. - struct guid; - struct hstring; - namespace Windows::Foundation - { - template - struct IReference; - } -} - -namespace TerminalApp::JsonUtils -{ - namespace Detail - { - // Function Description: - // - Returns a string_view to a Json::Value's internal string storage, - // hopefully without copying it. - __declspec(noinline) inline const std::string_view GetStringView(const Json::Value& json) - { - const char* begin{ nullptr }; - const char* end{ nullptr }; - json.getString(&begin, &end); - const std::string_view zeroCopyString{ begin, gsl::narrow_cast(end - begin) }; - return zeroCopyString; - } - - template - struct DeduceOptional - { - using Type = typename std::decay::type; - static constexpr bool IsOptional = false; - }; - - template - struct DeduceOptional> - { - using Type = typename std::decay::type; - static constexpr bool IsOptional = true; - }; - - template - struct DeduceOptional<::winrt::Windows::Foundation::IReference> - { - using Type = typename std::decay::type; - static constexpr bool IsOptional = true; - }; - } - - // These exceptions cannot use localized messages, as we do not have - // guaranteed access to the resource loader. - class TypeMismatchException : public std::runtime_error - { - public: - TypeMismatchException() : - runtime_error("unexpected data type") {} - }; - - class KeyedException : public std::runtime_error - { - public: - KeyedException(const std::string_view key, std::exception_ptr exception) : - runtime_error(fmt::format("error parsing \"{0}\"", key).c_str()), - _key{ key }, - _innerException{ std::move(exception) } {} - - std::string GetKey() const - { - return _key; - } - - [[noreturn]] void RethrowInner() const - { - std::rethrow_exception(_innerException); - } - - private: - std::string _key; - std::exception_ptr _innerException; - }; - - class UnexpectedValueException : public std::runtime_error - { - public: - UnexpectedValueException(const std::string_view value) : - runtime_error(fmt::format("unexpected value \"{0}\"", value).c_str()), - _value{ value } {} - - std::string GetValue() const - { - return _value; - } - - private: - std::string _value; - }; - - template - struct ConversionTrait - { - // Forward-declare these so the linker can pick up specializations from elsewhere! - T FromJson(const Json::Value&); - bool CanConvert(const Json::Value& json); - }; - - template<> - struct ConversionTrait - { - std::string FromJson(const Json::Value& json) - { - return json.asString(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isString(); - } - }; - - template<> - struct ConversionTrait - { - std::wstring FromJson(const Json::Value& json) - { - return til::u8u16(Detail::GetStringView(json)); - } - - bool CanConvert(const Json::Value& json) - { - return json.isString(); - } - }; - -#ifdef WINRT_BASE_H - template<> - struct ConversionTrait : public ConversionTrait - { - // Leverage the wstring converter's validation - winrt::hstring FromJson(const Json::Value& json) - { - return winrt::hstring{ til::u8u16(Detail::GetStringView(json)) }; - } - }; -#endif - - template<> - struct ConversionTrait - { - bool FromJson(const Json::Value& json) - { - return json.asBool(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isBool(); - } - }; - - template<> - struct ConversionTrait - { - int FromJson(const Json::Value& json) - { - return json.asInt(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isInt(); - } - }; - - template<> - struct ConversionTrait - { - unsigned int FromJson(const Json::Value& json) - { - return json.asUInt(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isUInt(); - } - }; - - template<> - struct ConversionTrait - { - float FromJson(const Json::Value& json) - { - return json.asFloat(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isNumeric(); - } - }; - - template<> - struct ConversionTrait - { - double FromJson(const Json::Value& json) - { - return json.asDouble(); - } - - bool CanConvert(const Json::Value& json) - { - return json.isNumeric(); - } - }; - - template<> - struct ConversionTrait - { - GUID FromJson(const Json::Value& json) - { - return ::Microsoft::Console::Utils::GuidFromString(til::u8u16(Detail::GetStringView(json))); - } - - bool CanConvert(const Json::Value& json) - { - if (!json.isString()) - { - return false; - } - - const auto string{ Detail::GetStringView(json) }; - return string.length() == 38 && string.front() == '{' && string.back() == '}'; - } - }; - - // (GUID and winrt::guid are mutually convertible!) - template<> - struct ConversionTrait : public ConversionTrait - { - }; - - template<> - struct ConversionTrait - { - til::color FromJson(const Json::Value& json) - { - return ::Microsoft::Console::Utils::ColorFromHexString(Detail::GetStringView(json)); - } - - bool CanConvert(const Json::Value& json) - { - if (!json.isString()) - { - return false; - } - - const auto string{ Detail::GetStringView(json) }; - return (string.length() == 7 || string.length() == 4) && string.front() == '#'; - } - }; - - template - struct EnumMapper - { - using BaseEnumMapper = EnumMapper; - using pair_type = std::pair; - T FromJson(const Json::Value& json) - { - const auto name{ Detail::GetStringView(json) }; - for (const auto& pair : TBase::mappings) - { - if (pair.first == name) - { - return pair.second; - } - } - - throw UnexpectedValueException{ name }; - } - - bool CanConvert(const Json::Value& json) - { - return json.isString(); - } - }; - - // FlagMapper is EnumMapper, but it works for bitfields. - // It supports a string (single flag) or an array of strings. - // Does an O(n*m) search; meant for small search spaces! - // - // Cleverly leverage EnumMapper to do the heavy lifting. - template - struct FlagMapper : public EnumMapper - { - private: - // Hide BaseEnumMapper so FlagMapper's consumers cannot see - // it. - using BaseEnumMapper = EnumMapper::BaseEnumMapper; - - public: - using BaseFlagMapper = FlagMapper; - static constexpr T AllSet{ static_cast(~0u) }; - static constexpr T AllClear{ static_cast(0u) }; - - T FromJson(const Json::Value& json) - { - if (json.isString()) - { - return BaseEnumMapper::FromJson(json); - } - else if (json.isArray()) - { - unsigned int seen{ 0 }; - T value{}; - for (const auto& element : json) - { - const auto newFlag{ BaseEnumMapper::FromJson(element) }; - if (++seen > 1 && - ((newFlag == AllClear && value != AllClear) || - (value == AllClear && newFlag != AllClear))) - { - // attempt to combine AllClear (explicitly) with anything else - throw UnexpectedValueException{ element.asString() }; - } - value |= newFlag; - } - return value; - } - - // We'll only get here if CanConvert has failed us. - return AllClear; - } - - bool CanConvert(const Json::Value& json) - { - return BaseEnumMapper::CanConvert(json) || json.isArray(); - } - }; - - // Method Description: - // - Helper that will populate a reference with a value converted from a json object. - // Arguments: - // - json: the json object to convert - // - target: the value to populate with the converted result - // Return Value: - // - a boolean indicating whether the value existed (in this case, was non-null) - // - // GetValue, type-deduced, manual converter - template - bool GetValue(const Json::Value& json, T& target, Converter&& conv) - { - if constexpr (Detail::DeduceOptional::IsOptional) - { - // FOR OPTION TYPES - // - If the json object is set to `null`, then - // we'll instead set the target back to the empty optional. - if (json.isNull()) - { - target = T{}; // zero-construct an empty optional - return true; - } - } - - if (json) - { - if (!conv.CanConvert(json)) - { - throw TypeMismatchException{}; - } - - target = conv.FromJson(json); - return true; - } - return false; - } - - // GetValue, forced return type, manual converter - template - std::decay_t GetValue(const Json::Value& json, Converter&& conv) - { - std::decay_t local{}; - GetValue(json, local, std::forward(conv)); - return local; // returns zero-initialized or value - } - - // GetValueForKey, type-deduced, manual converter - template - bool GetValueForKey(const Json::Value& json, std::string_view key, T& target, Converter&& conv) - { - if (auto found{ json.find(&*key.cbegin(), (&*key.cbegin()) + key.size()) }) - { - try - { - return GetValue(*found, target, std::forward(conv)); - } - catch (...) - { - // Wrap any caught exceptions in one that preserves context. - throw KeyedException(key, std::current_exception()); - } - } - return false; - } - - // GetValueForKey, forced return type, manual converter - template - std::decay_t GetValueForKey(const Json::Value& json, std::string_view key, Converter&& conv) - { - std::decay_t local{}; - GetValueForKey(json, key, local, std::forward(conv)); - return local; // returns zero-initialized? - } - - // GetValue, type-deduced, with automatic converter - template - bool GetValue(const Json::Value& json, T& target) - { - return GetValue(json, target, ConversionTrait::Type>{}); - } - - // GetValue, forced return type, with automatic converter - template - std::decay_t GetValue(const Json::Value& json) - { - std::decay_t local{}; - GetValue(json, local, ConversionTrait::Type>{}); - return local; // returns zero-initialized or value - } - - // GetValueForKey, type-deduced, with automatic converter - template - bool GetValueForKey(const Json::Value& json, std::string_view key, T& target) - { - return GetValueForKey(json, key, target, ConversionTrait::Type>{}); - } - - // GetValueForKey, forced return type, with automatic converter - template - std::decay_t GetValueForKey(const Json::Value& json, std::string_view key) - { - return GetValueForKey(json, key, ConversionTrait::Type>{}); - } - - // Get multiple values for keys (json, k, &v, k, &v, k, &v, ...). - // Uses the default converter for each v. - // Careful: this can cause a template explosion. - constexpr void GetValuesForKeys(const Json::Value& /*json*/) {} - - template - void GetValuesForKeys(const Json::Value& json, std::string_view key1, T&& val1, Args&&... args) - { - GetValueForKey(json, key1, val1); - GetValuesForKeys(json, std::forward(args)...); - } -}; - -#define JSON_ENUM_MAPPER(...) \ - template<> \ - struct ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__> : \ - public ::TerminalApp::JsonUtils::EnumMapper<__VA_ARGS__, ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__>> - -#define JSON_FLAG_MAPPER(...) \ - template<> \ - struct ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__> : \ - public ::TerminalApp::JsonUtils::FlagMapper<__VA_ARGS__, ::TerminalApp::JsonUtils::ConversionTrait<__VA_ARGS__>> - -#define JSON_MAPPINGS(Count) \ - static constexpr std::array mappings diff --git a/src/cascadia/TerminalApp/Profile.cpp b/src/cascadia/TerminalApp/Profile.cpp index 5ee40fd27a2..7cd80a65b11 100644 --- a/src/cascadia/TerminalApp/Profile.cpp +++ b/src/cascadia/TerminalApp/Profile.cpp @@ -9,6 +9,7 @@ #include #include "LegacyProfileGeneratorNamespaces.h" +#include "TerminalSettingsSerializationHelpers.h" using namespace TerminalApp; using namespace winrt::Microsoft::Terminal::Settings; @@ -52,57 +53,6 @@ static constexpr std::string_view BackgroundImageAlignmentKey{ "backgroundImageA static constexpr std::string_view RetroTerminalEffectKey{ "experimental.retroTerminalEffect" }; static constexpr std::string_view AntialiasingModeKey{ "antialiasingMode" }; -// Possible values for closeOnExit -static constexpr std::string_view CloseOnExitAlways{ "always" }; -static constexpr std::string_view CloseOnExitGraceful{ "graceful" }; -static constexpr std::string_view CloseOnExitNever{ "never" }; - -// Possible values for Scrollbar state -static constexpr std::wstring_view AlwaysVisible{ L"visible" }; -static constexpr std::wstring_view AlwaysHide{ L"hidden" }; - -// Possible values for Cursor Shape -static constexpr std::wstring_view CursorShapeVintage{ L"vintage" }; -static constexpr std::wstring_view CursorShapeBar{ L"bar" }; -static constexpr std::wstring_view CursorShapeUnderscore{ L"underscore" }; -static constexpr std::wstring_view CursorShapeFilledbox{ L"filledBox" }; -static constexpr std::wstring_view CursorShapeEmptybox{ L"emptyBox" }; - -// Possible values for Font Weight -static constexpr std::string_view FontWeightThin{ "thin" }; -static constexpr std::string_view FontWeightExtraLight{ "extra-light" }; -static constexpr std::string_view FontWeightLight{ "light" }; -static constexpr std::string_view FontWeightSemiLight{ "semi-light" }; -static constexpr std::string_view FontWeightNormal{ "normal" }; -static constexpr std::string_view FontWeightMedium{ "medium" }; -static constexpr std::string_view FontWeightSemiBold{ "semi-bold" }; -static constexpr std::string_view FontWeightBold{ "bold" }; -static constexpr std::string_view FontWeightExtraBold{ "extra-bold" }; -static constexpr std::string_view FontWeightBlack{ "black" }; -static constexpr std::string_view FontWeightExtraBlack{ "extra-black" }; - -// Possible values for Image Stretch Mode -static constexpr std::string_view ImageStretchModeNone{ "none" }; -static constexpr std::string_view ImageStretchModeFill{ "fill" }; -static constexpr std::string_view ImageStretchModeUniform{ "uniform" }; -static constexpr std::string_view ImageStretchModeUniformTofill{ "uniformToFill" }; - -// Possible values for Image Alignment -static constexpr std::string_view ImageAlignmentCenter{ "center" }; -static constexpr std::string_view ImageAlignmentLeft{ "left" }; -static constexpr std::string_view ImageAlignmentTop{ "top" }; -static constexpr std::string_view ImageAlignmentRight{ "right" }; -static constexpr std::string_view ImageAlignmentBottom{ "bottom" }; -static constexpr std::string_view ImageAlignmentTopLeft{ "topLeft" }; -static constexpr std::string_view ImageAlignmentTopRight{ "topRight" }; -static constexpr std::string_view ImageAlignmentBottomLeft{ "bottomLeft" }; -static constexpr std::string_view ImageAlignmentBottomRight{ "bottomRight" }; - -// Possible values for TextAntialiasingMode -static constexpr std::wstring_view AntialiasingModeGrayscale{ L"grayscale" }; -static constexpr std::wstring_view AntialiasingModeCleartype{ L"cleartype" }; -static constexpr std::wstring_view AntialiasingModeAliased{ L"aliased" }; - Profile::Profile() : Profile(std::nullopt) { @@ -248,8 +198,7 @@ TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map>(json, GuidKey) }) { - const auto guid{ json[JsonKey(GuidKey)] }; - const auto otherGuid = Utils::GuidFromString(GetWstringFromJson(guid)); - if (_guid.value() != otherGuid) + if (otherGuid != _guid) // optional compare takes care of this { return false; } @@ -368,16 +315,17 @@ bool Profile::ShouldBeLayered(const Json::Value& json) const return false; } - const auto& otherSource = json.isMember(JsonKey(SourceKey)) ? json[JsonKey(SourceKey)] : Json::Value::null; + std::optional otherSource; + bool otherHadSource = JsonUtils::GetValueForKey(json, SourceKey, otherSource); // For profiles with a `source`, also check the `source` property. bool sourceMatches = false; if (_source.has_value()) { - if (json.isMember(JsonKey(SourceKey))) + if (otherHadSource) { - const auto otherSourceString = GetWstringFromJson(otherSource); - sourceMatches = otherSourceString == _source.value(); + // If we have a source and the other has a source, compare them! + sourceMatches = otherSource == _source; } else { @@ -395,52 +343,13 @@ bool Profile::ShouldBeLayered(const Json::Value& json) const } else { - // We do not have a source. The only way we match is if source is set to null or "". - if (otherSource.isNull() || (otherSource.isString() && otherSource == "")) - { - sourceMatches = true; - } + // We do not have a source. The only way we match is if source is unset or set to "". + sourceMatches = (!otherSource.has_value() || otherSource.value() == L""); } return sourceMatches; } -// Method Description: -// - Helper function to convert a json value into a value of the Stretch enum. -// Calls into ParseImageStretchMode. Used with JsonUtils::GetOptionalValue. -// Arguments: -// - json: the Json::Value object to parse. -// Return Value: -// - An appropriate value from Windows.UI.Xaml.Media.Stretch -Media::Stretch Profile::_ConvertJsonToStretchMode(const Json::Value& json) -{ - return Profile::ParseImageStretchMode(json.asString()); -} - -// Method Description: -// - Helper function to convert a json value into a value of the Stretch enum. -// Calls into ParseImageAlignment. Used with JsonUtils::GetOptionalValue. -// Arguments: -// - json: the Json::Value object to parse. -// Return Value: -// - A pair of HorizontalAlignment and VerticalAlignment -std::tuple Profile::_ConvertJsonToAlignment(const Json::Value& json) -{ - return Profile::ParseImageAlignment(json.asString()); -} - -// Method Description: -// - Helper function to convert a json value into a bool. -// Used with JsonUtils::GetOptionalValue. -// Arguments: -// - json: the Json::Value object to parse. -// Return Value: -// - A bool -bool Profile::_ConvertJsonToBool(const Json::Value& json) -{ - return json.asBool(); -} - // Method Description: // - Layer values from the given json object on top of the existing properties // of this object. For any keys we're expecting to be able to parse in the @@ -456,89 +365,45 @@ bool Profile::_ConvertJsonToBool(const Json::Value& json) void Profile::LayerJson(const Json::Value& json) { // Profile-specific Settings - JsonUtils::GetWstring(json, NameKey, _name); - - JsonUtils::GetOptionalGuid(json, GuidKey, _guid); - - JsonUtils::GetBool(json, HiddenKey, _hidden); + JsonUtils::GetValueForKey(json, NameKey, _name); + JsonUtils::GetValueForKey(json, GuidKey, _guid); + JsonUtils::GetValueForKey(json, HiddenKey, _hidden); // Core Settings - JsonUtils::GetOptionalColor(json, ForegroundKey, _defaultForeground); - - JsonUtils::GetOptionalColor(json, BackgroundKey, _defaultBackground); - - JsonUtils::GetOptionalColor(json, SelectionBackgroundKey, _selectionBackground); - - JsonUtils::GetOptionalColor(json, CursorColorKey, _cursorColor); - - JsonUtils::GetOptionalString(json, ColorSchemeKey, _schemeName); + JsonUtils::GetValueForKey(json, ForegroundKey, _defaultForeground); + JsonUtils::GetValueForKey(json, BackgroundKey, _defaultBackground); + JsonUtils::GetValueForKey(json, SelectionBackgroundKey, _selectionBackground); + JsonUtils::GetValueForKey(json, CursorColorKey, _cursorColor); + JsonUtils::GetValueForKey(json, ColorSchemeKey, _schemeName); // TODO:MSFT:20642297 - Use a sentinel value (-1) for "Infinite scrollback" - JsonUtils::GetInt(json, HistorySizeKey, _historySize); - - JsonUtils::GetBool(json, SnapOnInputKey, _snapOnInput); - - JsonUtils::GetBool(json, AltGrAliasingKey, _altGrAliasing); - - JsonUtils::GetUInt(json, CursorHeightKey, _cursorHeight); - - if (json.isMember(JsonKey(CursorShapeKey))) - { - auto cursorShape{ json[JsonKey(CursorShapeKey)] }; - _cursorShape = _ParseCursorShape(GetWstringFromJson(cursorShape)); - } - JsonUtils::GetOptionalString(json, TabTitleKey, _tabTitle); + JsonUtils::GetValueForKey(json, HistorySizeKey, _historySize); + JsonUtils::GetValueForKey(json, SnapOnInputKey, _snapOnInput); + JsonUtils::GetValueForKey(json, AltGrAliasingKey, _altGrAliasing); + JsonUtils::GetValueForKey(json, CursorHeightKey, _cursorHeight); + JsonUtils::GetValueForKey(json, CursorShapeKey, _cursorShape); + JsonUtils::GetValueForKey(json, TabTitleKey, _tabTitle); // Control Settings - JsonUtils::GetOptionalGuid(json, ConnectionTypeKey, _connectionType); - - JsonUtils::GetWstring(json, CommandlineKey, _commandline); - - JsonUtils::GetWstring(json, FontFaceKey, _fontFace); - - JsonUtils::GetInt(json, FontSizeKey, _fontSize); - - if (json.isMember(JsonKey(FontWeightKey))) - { - auto fontWeight{ json[JsonKey(FontWeightKey)] }; - _fontWeight = _ParseFontWeight(fontWeight); - } - - JsonUtils::GetDouble(json, AcrylicTransparencyKey, _acrylicTransparency); - - JsonUtils::GetBool(json, UseAcrylicKey, _useAcrylic); - - JsonUtils::GetBool(json, SuppressApplicationTitleKey, _suppressApplicationTitle); - - if (json.isMember(JsonKey(CloseOnExitKey))) - { - auto closeOnExit{ json[JsonKey(CloseOnExitKey)] }; - _closeOnExitMode = ParseCloseOnExitMode(closeOnExit); - } - - JsonUtils::GetWstring(json, PaddingKey, _padding); - - JsonUtils::GetOptionalString(json, ScrollbarStateKey, _scrollbarState); - - JsonUtils::GetOptionalString(json, StartingDirectoryKey, _startingDirectory); - - JsonUtils::GetOptionalString(json, IconKey, _icon); - - JsonUtils::GetOptionalString(json, BackgroundImageKey, _backgroundImage); - - JsonUtils::GetOptionalDouble(json, BackgroundImageOpacityKey, _backgroundImageOpacity); - - JsonUtils::GetOptionalValue(json, BackgroundImageStretchModeKey, _backgroundImageStretchMode, &Profile::_ConvertJsonToStretchMode); - - JsonUtils::GetOptionalValue(json, BackgroundImageAlignmentKey, _backgroundImageAlignment, &Profile::_ConvertJsonToAlignment); - - JsonUtils::GetOptionalValue(json, RetroTerminalEffectKey, _retroTerminalEffect, Profile::_ConvertJsonToBool); - - if (json.isMember(JsonKey(AntialiasingModeKey))) - { - auto antialiasingMode{ json[JsonKey(AntialiasingModeKey)] }; - _antialiasingMode = ParseTextAntialiasingMode(GetWstringFromJson(antialiasingMode)); - } + JsonUtils::GetValueForKey(json, FontWeightKey, _fontWeight); + JsonUtils::GetValueForKey(json, ConnectionTypeKey, _connectionType); + JsonUtils::GetValueForKey(json, CommandlineKey, _commandline); + JsonUtils::GetValueForKey(json, FontFaceKey, _fontFace); + JsonUtils::GetValueForKey(json, FontSizeKey, _fontSize); + JsonUtils::GetValueForKey(json, AcrylicTransparencyKey, _acrylicTransparency); + JsonUtils::GetValueForKey(json, UseAcrylicKey, _useAcrylic); + JsonUtils::GetValueForKey(json, SuppressApplicationTitleKey, _suppressApplicationTitle); + JsonUtils::GetValueForKey(json, CloseOnExitKey, _closeOnExitMode); + JsonUtils::GetValueForKey(json, PaddingKey, _padding); + JsonUtils::GetValueForKey(json, ScrollbarStateKey, _scrollbarState); + JsonUtils::GetValueForKey(json, StartingDirectoryKey, _startingDirectory); + JsonUtils::GetValueForKey(json, IconKey, _icon); + JsonUtils::GetValueForKey(json, BackgroundImageKey, _backgroundImage); + JsonUtils::GetValueForKey(json, BackgroundImageOpacityKey, _backgroundImageOpacity); + JsonUtils::GetValueForKey(json, BackgroundImageStretchModeKey, _backgroundImageStretchMode); + JsonUtils::GetValueForKey(json, BackgroundImageAlignmentKey, _backgroundImageAlignment); + JsonUtils::GetValueForKey(json, RetroTerminalEffectKey, _retroTerminalEffect); + JsonUtils::GetValueForKey(json, AntialiasingModeKey, _antialiasingMode); } void Profile::SetFontFace(std::wstring fontFace) noexcept @@ -770,249 +635,6 @@ std::wstring Profile::EvaluateStartingDirectory(const std::wstring& directory) } } -// Method Description: -// - Helper function for converting a user-specified font weight value to its corresponding enum -// Arguments: -// - The value from the settings.json file -// Return Value: -// - The corresponding value which maps to the string provided by the user -winrt::Windows::UI::Text::FontWeight Profile::_ParseFontWeight(const Json::Value& json) -{ - if (json.isUInt()) - { - winrt::Windows::UI::Text::FontWeight weight; - weight.Weight = static_cast(json.asUInt()); - - // We're only accepting variable values between 100 and 990 so we don't go too crazy. - if (weight.Weight >= 100 && weight.Weight <= 990) - { - return weight; - } - } - - if (json.isString()) - { - auto fontWeight = json.asString(); - if (fontWeight == FontWeightThin) - { - return winrt::Windows::UI::Text::FontWeights::Thin(); - } - else if (fontWeight == FontWeightExtraLight) - { - return winrt::Windows::UI::Text::FontWeights::ExtraLight(); - } - else if (fontWeight == FontWeightLight) - { - return winrt::Windows::UI::Text::FontWeights::Light(); - } - else if (fontWeight == FontWeightSemiLight) - { - return winrt::Windows::UI::Text::FontWeights::SemiLight(); - } - else if (fontWeight == FontWeightNormal) - { - return winrt::Windows::UI::Text::FontWeights::Normal(); - } - else if (fontWeight == FontWeightMedium) - { - return winrt::Windows::UI::Text::FontWeights::Medium(); - } - else if (fontWeight == FontWeightSemiBold) - { - return winrt::Windows::UI::Text::FontWeights::SemiBold(); - } - else if (fontWeight == FontWeightBold) - { - return winrt::Windows::UI::Text::FontWeights::Bold(); - } - else if (fontWeight == FontWeightExtraBold) - { - return winrt::Windows::UI::Text::FontWeights::ExtraBold(); - } - else if (fontWeight == FontWeightBlack) - { - return winrt::Windows::UI::Text::FontWeights::Black(); - } - else if (fontWeight == FontWeightExtraBlack) - { - return winrt::Windows::UI::Text::FontWeights::ExtraBlack(); - } - } - - return winrt::Windows::UI::Text::FontWeights::Normal(); -} - -// Method Description: -// - Helper function for converting a user-specified closeOnExit value to its corresponding enum -// Arguments: -// - The value from the settings.json file -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -CloseOnExitMode Profile::ParseCloseOnExitMode(const Json::Value& json) -{ - if (json.isBool()) - { - return json.asBool() ? CloseOnExitMode::Graceful : CloseOnExitMode::Never; - } - - if (json.isString()) - { - auto closeOnExit = json.asString(); - if (closeOnExit == CloseOnExitAlways) - { - return CloseOnExitMode::Always; - } - else if (closeOnExit == CloseOnExitGraceful) - { - return CloseOnExitMode::Graceful; - } - else if (closeOnExit == CloseOnExitNever) - { - return CloseOnExitMode::Never; - } - } - - return CloseOnExitMode::Graceful; -} - -// Method Description: -// - Helper function for converting a user-specified scrollbar state to its corresponding enum -// Arguments: -// - The value from the settings.json file -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -ScrollbarState Profile::ParseScrollbarState(const std::wstring& scrollbarState) -{ - if (scrollbarState == AlwaysVisible) - { - return ScrollbarState::Visible; - } - else if (scrollbarState == AlwaysHide) - { - return ScrollbarState::Hidden; - } - else - { - return ScrollbarState::Visible; - } -} - -// Method Description: -// - Helper function for converting a user-specified image stretch mode -// to the appropriate enum value -// Arguments: -// - The value from the settings.json file -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -Media::Stretch Profile::ParseImageStretchMode(const std::string_view imageStretchMode) -{ - if (imageStretchMode == ImageStretchModeNone) - { - return Media::Stretch::None; - } - else if (imageStretchMode == ImageStretchModeFill) - { - return Media::Stretch::Fill; - } - else if (imageStretchMode == ImageStretchModeUniform) - { - return Media::Stretch::Uniform; - } - else // Fall through to default behavior - { - return Media::Stretch::UniformToFill; - } -} - -// Method Description: -// - Helper function for converting a user-specified image horizontal and vertical -// alignment to the appropriate enum values tuple -// Arguments: -// - The value from the settings.json file -// Return Value: -// - The corresponding enum values tuple which maps to the string provided by the user -std::tuple Profile::ParseImageAlignment(const std::string_view imageAlignment) -{ - if (imageAlignment == ImageAlignmentTopLeft) - { - return std::make_tuple(HorizontalAlignment::Left, - VerticalAlignment::Top); - } - else if (imageAlignment == ImageAlignmentBottomLeft) - { - return std::make_tuple(HorizontalAlignment::Left, - VerticalAlignment::Bottom); - } - else if (imageAlignment == ImageAlignmentLeft) - { - return std::make_tuple(HorizontalAlignment::Left, - VerticalAlignment::Center); - } - else if (imageAlignment == ImageAlignmentTopRight) - { - return std::make_tuple(HorizontalAlignment::Right, - VerticalAlignment::Top); - } - else if (imageAlignment == ImageAlignmentBottomRight) - { - return std::make_tuple(HorizontalAlignment::Right, - VerticalAlignment::Bottom); - } - else if (imageAlignment == ImageAlignmentRight) - { - return std::make_tuple(HorizontalAlignment::Right, - VerticalAlignment::Center); - } - else if (imageAlignment == ImageAlignmentTop) - { - return std::make_tuple(HorizontalAlignment::Center, - VerticalAlignment::Top); - } - else if (imageAlignment == ImageAlignmentBottom) - { - return std::make_tuple(HorizontalAlignment::Center, - VerticalAlignment::Bottom); - } - else // Fall through to default alignment - { - return std::make_tuple(HorizontalAlignment::Center, - VerticalAlignment::Center); - } -} - -// Method Description: -// - Helper function for converting a user-specified cursor style corresponding -// CursorStyle enum value -// Arguments: -// - cursorShapeString: The string value from the settings file to parse -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -CursorStyle Profile::_ParseCursorShape(const std::wstring& cursorShapeString) -{ - if (cursorShapeString == CursorShapeVintage) - { - return CursorStyle::Vintage; - } - else if (cursorShapeString == CursorShapeBar) - { - return CursorStyle::Bar; - } - else if (cursorShapeString == CursorShapeUnderscore) - { - return CursorStyle::Underscore; - } - else if (cursorShapeString == CursorShapeFilledbox) - { - return CursorStyle::FilledBox; - } - else if (cursorShapeString == CursorShapeEmptybox) - { - return CursorStyle::EmptyBox; - } - // default behavior for invalid data - return CursorStyle::Bar; -} - // Method Description: // - If this profile never had a GUID set for it, generate a runtime GUID for // the profile. If a profile had their guid manually set to {0}, this method @@ -1078,17 +700,13 @@ GUID Profile::_GenerateGuidForProfile(const std::wstring& name, const std::optio // - The json's `guid`, or a guid synthesized for it. GUID Profile::GetGuidOrGenerateForJson(const Json::Value& json) noexcept { - std::optional guid{ std::nullopt }; - - JsonUtils::GetOptionalGuid(json, GuidKey, guid); - if (guid) + if (const auto guid{ JsonUtils::GetValueForKey>(json, GuidKey) }) { return guid.value(); } - const auto name = GetWstringFromJson(json[JsonKey(NameKey)]); - std::optional source{ std::nullopt }; - JsonUtils::GetOptionalString(json, SourceKey, source); + const auto name{ JsonUtils::GetValueForKey(json, NameKey) }; + const auto source{ JsonUtils::GetValueForKey>(json, SourceKey) }; return Profile::_GenerateGuidForProfile(name, source); } @@ -1097,28 +715,3 @@ void Profile::SetRetroTerminalEffect(bool value) noexcept { _retroTerminalEffect = value; } - -// Method Description: -// - Helper function for converting a user-specified antialiasing mode -// corresponding TextAntialiasingMode enum value -// Arguments: -// - antialiasingMode: The string value from the settings file to parse -// Return Value: -// - The corresponding enum value which maps to the string provided by the user -TextAntialiasingMode Profile::ParseTextAntialiasingMode(const std::wstring& antialiasingMode) -{ - if (antialiasingMode == AntialiasingModeCleartype) - { - return TextAntialiasingMode::Cleartype; - } - else if (antialiasingMode == AntialiasingModeAliased) - { - return TextAntialiasingMode::Aliased; - } - else if (antialiasingMode == AntialiasingModeGrayscale) - { - return TextAntialiasingMode::Grayscale; - } - // default behavior for invalid data - return TextAntialiasingMode::Grayscale; -} diff --git a/src/cascadia/TerminalApp/Profile.h b/src/cascadia/TerminalApp/Profile.h index bd48592157c..17edad98bb6 100644 --- a/src/cascadia/TerminalApp/Profile.h +++ b/src/cascadia/TerminalApp/Profile.h @@ -15,6 +15,7 @@ Author(s): --*/ #pragma once #include "ColorScheme.h" +#include "SettingsTypes.h" // fwdecl unittest classes namespace TerminalAppLocalTests @@ -35,14 +36,7 @@ constexpr GUID RUNTIME_GENERATED_PROFILE_NAMESPACE_GUID = { 0xf65ddb7e, 0x706b, namespace TerminalApp { class Profile; - - enum class CloseOnExitMode - { - Never = 0, - Graceful, - Always - }; -}; +} class TerminalApp::Profile final { @@ -107,24 +101,8 @@ class TerminalApp::Profile final private: static std::wstring EvaluateStartingDirectory(const std::wstring& directory); - static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState); - static winrt::Windows::UI::Xaml::Media::Stretch ParseImageStretchMode(const std::string_view imageStretchMode); - static winrt::Windows::UI::Xaml::Media::Stretch _ConvertJsonToStretchMode(const Json::Value& json); - static std::tuple ParseImageAlignment(const std::string_view imageAlignment); - static std::tuple _ConvertJsonToAlignment(const Json::Value& json); - - static winrt::Windows::UI::Text::FontWeight _ParseFontWeight(const Json::Value& json); - - static CloseOnExitMode ParseCloseOnExitMode(const Json::Value& json); - - static winrt::Microsoft::Terminal::Settings::CursorStyle _ParseCursorShape(const std::wstring& cursorShapeString); - - static winrt::Microsoft::Terminal::Settings::TextAntialiasingMode ParseTextAntialiasingMode(const std::wstring& antialiasingMode); - static GUID _GenerateGuidForProfile(const std::wstring& name, const std::optional& source) noexcept; - static bool _ConvertJsonToBool(const Json::Value& json); - std::optional _guid{ std::nullopt }; std::optional _source{ std::nullopt }; std::wstring _name; @@ -159,7 +137,7 @@ class TerminalApp::Profile final std::optional _backgroundImageStretchMode; std::optional> _backgroundImageAlignment; - std::optional _scrollbarState; + std::optional<::winrt::Microsoft::Terminal::Settings::ScrollbarState> _scrollbarState; CloseOnExitMode _closeOnExitMode; std::wstring _padding; diff --git a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw index 1f810d4de76..09283b55c6d 100644 --- a/src/cascadia/TerminalApp/Resources/en-US/Resources.resw +++ b/src/cascadia/TerminalApp/Resources/en-US/Resources.resw @@ -399,6 +399,9 @@ Toggle fullscreen + + Toggle always on top mode + Open new tab dropdown diff --git a/src/cascadia/TerminalApp/SettingsTypes.h b/src/cascadia/TerminalApp/SettingsTypes.h new file mode 100644 index 00000000000..66903ab41a4 --- /dev/null +++ b/src/cascadia/TerminalApp/SettingsTypes.h @@ -0,0 +1,28 @@ +/*++ +Copyright (c) Microsoft Corporation +Licensed under the MIT license. + +Module Name: +- SettingsTypes.h + +Abstract: +- Types used in the settings model (non-exported) +--*/ + +#pragma once + +namespace TerminalApp +{ + enum class CloseOnExitMode + { + Never = 0, + Graceful, + Always + }; + + struct LaunchPosition + { + std::optional x; + std::optional y; + }; +}; diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp index 8248d453aa8..a040106e24c 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.cpp @@ -169,6 +169,11 @@ namespace winrt::TerminalApp::implementation _ToggleFullscreenHandlers(*this, *eventArgs); break; } + case ShortcutAction::ToggleAlwaysOnTop: + { + _ToggleAlwaysOnTopHandlers(*this, *eventArgs); + break; + } case ShortcutAction::ToggleCommandPalette: { _ToggleCommandPaletteHandlers(*this, *eventArgs); diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.h b/src/cascadia/TerminalApp/ShortcutActionDispatch.h index e59c8ce47cb..9b930db980d 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.h +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.h @@ -49,6 +49,7 @@ namespace winrt::TerminalApp::implementation TYPED_EVENT(ToggleRetroEffect, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(ToggleFocusMode, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(ToggleFullscreen, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); + TYPED_EVENT(ToggleAlwaysOnTop, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(ToggleCommandPalette, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(SetTabColor, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); TYPED_EVENT(OpenTabColorPicker, TerminalApp::ShortcutActionDispatch, TerminalApp::ActionEventArgs); diff --git a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl index 50f1bc7cd7f..2588c3258b2 100644 --- a/src/cascadia/TerminalApp/ShortcutActionDispatch.idl +++ b/src/cascadia/TerminalApp/ShortcutActionDispatch.idl @@ -34,6 +34,7 @@ namespace TerminalApp ToggleRetroEffect, ToggleFocusMode, ToggleFullscreen, + ToggleAlwaysOnTop, SetTabColor, OpenTabColorPicker, OpenSettings, @@ -78,6 +79,7 @@ namespace TerminalApp event Windows.Foundation.TypedEventHandler ToggleRetroEffect; event Windows.Foundation.TypedEventHandler ToggleFocusMode; event Windows.Foundation.TypedEventHandler ToggleFullscreen; + event Windows.Foundation.TypedEventHandler ToggleAlwaysOnTop; event Windows.Foundation.TypedEventHandler ToggleCommandPalette; event Windows.Foundation.TypedEventHandler SetTabColor; event Windows.Foundation.TypedEventHandler OpenTabColorPicker; diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index deecd34850e..6ed6d8e9716 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -852,6 +852,7 @@ namespace winrt::TerminalApp::implementation _actionDispatch->ToggleRetroEffect({ this, &TerminalPage::_HandleToggleRetroEffect }); _actionDispatch->ToggleFocusMode({ this, &TerminalPage::_HandleToggleFocusMode }); _actionDispatch->ToggleFullscreen({ this, &TerminalPage::_HandleToggleFullscreen }); + _actionDispatch->ToggleAlwaysOnTop({ this, &TerminalPage::_HandleToggleAlwaysOnTop }); _actionDispatch->ToggleCommandPalette({ this, &TerminalPage::_HandleToggleCommandPalette }); _actionDispatch->SetTabColor({ this, &TerminalPage::_HandleSetTabColor }); _actionDispatch->OpenTabColorPicker({ this, &TerminalPage::_HandleOpenTabColorPicker }); @@ -1913,6 +1914,12 @@ namespace winrt::TerminalApp::implementation _UpdateTabWidthMode(); _CreateNewTabFlyout(); } + + // Reload the current value of alwaysOnTop from the settings file. This + // will let the user hot-reload this setting, but any runtime changes to + // the alwaysOnTop setting will be lost. + _isAlwaysOnTop = _settings->GlobalSettings().AlwaysOnTop(); + _alwaysOnTopChangedHandlers(*this, nullptr); } // Method Description: @@ -1969,34 +1976,42 @@ namespace winrt::TerminalApp::implementation // Method Description: // - Toggles borderless mode. Hides the tab row, and raises our - // ToggleFocusMode event. + // FocusModeChanged event. // Arguments: // - // Return Value: // - void TerminalPage::ToggleFocusMode() { - _toggleFocusModeHandlers(*this, nullptr); - _isInFocusMode = !_isInFocusMode; - _UpdateTabView(); + _focusModeChangedHandlers(*this, nullptr); } // Method Description: // - Toggles fullscreen mode. Hides the tab row, and raises our - // ToggleFullscreen event. + // FullscreenChanged event. // Arguments: // - // Return Value: // - void TerminalPage::ToggleFullscreen() { - _toggleFullscreenHandlers(*this, nullptr); - _isFullscreen = !_isFullscreen; - _UpdateTabView(); + _fullscreenChangedHandlers(*this, nullptr); + } + + // Method Description: + // - Toggles always on top mode. Raises our AlwaysOnTopChanged event. + // Arguments: + // - + // Return Value: + // - + void TerminalPage::ToggleAlwaysOnTop() + { + _isAlwaysOnTop = !_isAlwaysOnTop; + _alwaysOnTopChangedHandlers(*this, nullptr); } // Method Description: @@ -2187,12 +2202,36 @@ namespace winrt::TerminalApp::implementation } } + bool TerminalPage::FocusMode() const + { + return _isInFocusMode; + } + + bool TerminalPage::Fullscreen() const + { + return _isFullscreen; + } + // Method Description: + // - Returns true if we're currently in "Always on top" mode. When we're in + // always on top mode, the window should be on top of all other windows. + // If multiple windows are all "always on top", they'll maintain their own + // z-order, with all the windows on top of all other non-topmost windows. + // Arguments: + // - + // Return Value: + // - true if we should be in "always on top" mode + bool TerminalPage::AlwaysOnTop() const + { + return _isAlwaysOnTop; + } + // -------------------------------- WinRT Events --------------------------------- // Winrt events need a method for adding a callback to the event and removing the callback. // These macros will define them both for you. DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring); DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs); DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, UIElement); - DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, ToggleFocusMode, _toggleFocusModeHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFocusModeEventArgs); - DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, ToggleFullscreen, _toggleFullscreenHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFullscreenEventArgs); + DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + DEFINE_EVENT_WITH_TYPED_EVENT_HANDLER(TerminalPage, AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); } diff --git a/src/cascadia/TerminalApp/TerminalPage.h b/src/cascadia/TerminalApp/TerminalPage.h index b5536b8371f..2aa717cfacd 100644 --- a/src/cascadia/TerminalApp/TerminalPage.h +++ b/src/cascadia/TerminalApp/TerminalPage.h @@ -51,6 +51,10 @@ namespace winrt::TerminalApp::implementation void ToggleFocusMode(); void ToggleFullscreen(); + void ToggleAlwaysOnTop(); + bool FocusMode() const; + bool Fullscreen() const; + bool AlwaysOnTop() const; void SetStartupActions(std::deque& actions); @@ -61,8 +65,9 @@ namespace winrt::TerminalApp::implementation DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(TitleChanged, _titleChangeHandlers, winrt::Windows::Foundation::IInspectable, winrt::hstring); DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(LastTabClosed, _lastTabClosedHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::LastTabClosedEventArgs); DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(SetTitleBarContent, _setTitleBarContentHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::UIElement); - DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(ToggleFocusMode, _toggleFocusModeHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFocusModeEventArgs); - DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(ToggleFullscreen, _toggleFullscreenHandlers, winrt::Windows::Foundation::IInspectable, winrt::TerminalApp::ToggleFullscreenEventArgs); + DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FocusModeChanged, _focusModeChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(FullscreenChanged, _fullscreenChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); + DECLARE_EVENT_WITH_TYPED_EVENT_HANDLER(AlwaysOnTopChanged, _alwaysOnTopChangedHandlers, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable); TYPED_EVENT(Initialized, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::RoutedEventArgs); private: @@ -87,6 +92,7 @@ namespace winrt::TerminalApp::implementation bool _isInFocusMode{ false }; bool _isFullscreen{ false }; + bool _isAlwaysOnTop{ false }; bool _rearranging; std::optional _rearrangeFrom; @@ -211,6 +217,7 @@ namespace winrt::TerminalApp::implementation void _HandleToggleRetroEffect(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleToggleFocusMode(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleToggleFullscreen(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); + void _HandleToggleAlwaysOnTop(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleSetTabColor(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleOpenTabColorPicker(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); void _HandleRenameTab(const IInspectable& sender, const TerminalApp::ActionEventArgs& args); diff --git a/src/cascadia/TerminalApp/TerminalPage.idl b/src/cascadia/TerminalApp/TerminalPage.idl index 9d5bd0aa83e..7fb5cb29ac1 100644 --- a/src/cascadia/TerminalApp/TerminalPage.idl +++ b/src/cascadia/TerminalApp/TerminalPage.idl @@ -4,8 +4,6 @@ namespace TerminalApp { delegate void LastTabClosedEventArgs(); - delegate void ToggleFullscreenEventArgs(); - delegate void ToggleFocusModeEventArgs(); interface IDialogPresenter { @@ -20,6 +18,10 @@ namespace TerminalApp String ApplicationDisplayName { get; }; String ApplicationVersion { get; }; + Boolean FocusMode { get; }; + Boolean Fullscreen { get; }; + Boolean AlwaysOnTop { get; }; + // We cannot use the default XAML APIs because we want to make sure // that there's only one application-global dialog visible at a time, // and because of GH#5224. @@ -28,8 +30,9 @@ namespace TerminalApp event Windows.Foundation.TypedEventHandler TitleChanged; event Windows.Foundation.TypedEventHandler LastTabClosed; event Windows.Foundation.TypedEventHandler SetTitleBarContent; - event Windows.Foundation.TypedEventHandler ToggleFullscreen; - event Windows.Foundation.TypedEventHandler ToggleFocusMode; + event Windows.Foundation.TypedEventHandler FocusModeChanged; + event Windows.Foundation.TypedEventHandler FullscreenChanged; + event Windows.Foundation.TypedEventHandler AlwaysOnTopChanged; event Windows.Foundation.TypedEventHandler Initialized; } } diff --git a/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h new file mode 100644 index 00000000000..40de89d2258 --- /dev/null +++ b/src/cascadia/TerminalApp/TerminalSettingsSerializationHelpers.h @@ -0,0 +1,272 @@ +/*++ +Copyright (c) Microsoft Corporation +Licensed under the MIT license. + +Module Name: +- TerminalSettingsSerializationHelpers.h + +Abstract: +- Specializations of the JsonUtils helpers for things that might end up in a + settings document. + +--*/ + +#pragma once + +#include "pch.h" + +#include "JsonUtils.h" +#include "SettingsTypes.h" + +#include +#include + +JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::CursorStyle) +{ + static constexpr std::array mappings = { + pair_type{ "bar", ValueType::Bar }, + pair_type{ "vintage", ValueType::Vintage }, + pair_type{ "underscore", ValueType::Underscore }, + pair_type{ "filledBox", ValueType::FilledBox }, + pair_type{ "emptyBox", ValueType::EmptyBox } + }; +}; + +JSON_ENUM_MAPPER(::winrt::Windows::UI::Xaml::Media::Stretch) +{ + static constexpr std::array mappings = { + pair_type{ "uniformToFill", ValueType::UniformToFill }, + pair_type{ "none", ValueType::None }, + pair_type{ "fill", ValueType::Fill }, + pair_type{ "uniform", ValueType::Uniform } + }; +}; + +JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::ScrollbarState) +{ + static constexpr std::array mappings = { + pair_type{ "visible", ValueType::Visible }, + pair_type{ "hidden", ValueType::Hidden } + }; +}; + +JSON_ENUM_MAPPER(std::tuple<::winrt::Windows::UI::Xaml::HorizontalAlignment, ::winrt::Windows::UI::Xaml::VerticalAlignment>) +{ + // reduce repetition + using HA = ::winrt::Windows::UI::Xaml::HorizontalAlignment; + using VA = ::winrt::Windows::UI::Xaml::VerticalAlignment; + static constexpr std::array mappings = { + pair_type{ "center", std::make_tuple(HA::Center, VA::Center) }, + pair_type{ "topLeft", std::make_tuple(HA::Left, VA::Top) }, + pair_type{ "bottomLeft", std::make_tuple(HA::Left, VA::Bottom) }, + pair_type{ "left", std::make_tuple(HA::Left, VA::Center) }, + pair_type{ "topRight", std::make_tuple(HA::Right, VA::Top) }, + pair_type{ "bottomRight", std::make_tuple(HA::Right, VA::Bottom) }, + pair_type{ "right", std::make_tuple(HA::Right, VA::Center) }, + pair_type{ "top", std::make_tuple(HA::Center, VA::Top) }, + pair_type{ "bottom", std::make_tuple(HA::Center, VA::Bottom) } + }; +}; + +JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::TextAntialiasingMode) +{ + static constexpr std::array mappings = { + pair_type{ "grayscale", ValueType::Grayscale }, + pair_type{ "cleartype", ValueType::Cleartype }, + pair_type{ "aliased", ValueType::Aliased } + }; +}; + +// Type Description: +// - Helper for converting a user-specified closeOnExit value to its corresponding enum +JSON_ENUM_MAPPER(::TerminalApp::CloseOnExitMode) +{ + JSON_MAPPINGS(3) = { + pair_type{ "always", ValueType::Always }, + pair_type{ "graceful", ValueType::Graceful }, + pair_type{ "never", ValueType::Never }, + }; + + // Override mapping parser to add boolean parsing + CloseOnExitMode FromJson(const Json::Value& json) + { + if (json.isBool()) + { + return json.asBool() ? ValueType::Graceful : ValueType::Never; + } + return EnumMapper::FromJson(json); + } + + bool CanConvert(const Json::Value& json) + { + return EnumMapper::CanConvert(json) || json.isBool(); + } +}; + +// This specialization isn't using JSON_ENUM_MAPPER because we need to have a different +// value type (unsinged int) and return type (FontWeight struct). JSON_ENUM_MAPPER +// expects that the value type _is_ the return type. +template<> +struct ::TerminalApp::JsonUtils::ConversionTrait<::winrt::Windows::UI::Text::FontWeight> : + public ::TerminalApp::JsonUtils::EnumMapper< + unsigned int, + ::TerminalApp::JsonUtils::ConversionTrait<::winrt::Windows::UI::Text::FontWeight>> +{ + // The original parser used the font weight getters Bold(), Normal(), etc. + // They were both cumbersome and *not constant expressions* + JSON_MAPPINGS(11) = { + pair_type{ "thin", 100u }, + pair_type{ "extra-light", 200u }, + pair_type{ "light", 300u }, + pair_type{ "semi-light", 350u }, + pair_type{ "normal", 400u }, + pair_type{ "medium", 500u }, + pair_type{ "semi-bold", 600u }, + pair_type{ "bold", 700u }, + pair_type{ "extra-bold", 800u }, + pair_type{ "black", 900u }, + pair_type{ "extra-black", 950u }, + }; + + // Override mapping parser to add boolean parsing + auto FromJson(const Json::Value& json) + { + unsigned int value{ 400 }; + if (json.isUInt()) + { + value = json.asUInt(); + } + else + { + value = BaseEnumMapper::FromJson(json); + } + + ::winrt::Windows::UI::Text::FontWeight weight{ + static_cast(std::clamp(value, 100u, 990u)) + }; + return weight; + } + + bool CanConvert(const Json::Value& json) + { + return BaseEnumMapper::CanConvert(json) || json.isUInt(); + } +}; + +JSON_ENUM_MAPPER(::winrt::Windows::UI::Xaml::ElementTheme) +{ + JSON_MAPPINGS(3) = { + pair_type{ "system", ValueType::Default }, + pair_type{ "light", ValueType::Light }, + pair_type{ "dark", ValueType::Dark }, + }; +}; + +JSON_ENUM_MAPPER(::winrt::TerminalApp::LaunchMode) +{ + JSON_MAPPINGS(3) = { + pair_type{ "default", ValueType::DefaultMode }, + pair_type{ "maximized", ValueType::MaximizedMode }, + pair_type{ "fullscreen", ValueType::FullscreenMode }, + }; +}; + +JSON_ENUM_MAPPER(::winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode) +{ + JSON_MAPPINGS(3) = { + pair_type{ "equal", ValueType::Equal }, + pair_type{ "titleLength", ValueType::SizeToContent }, + pair_type{ "compact", ValueType::Compact }, + }; +}; + +// Type Description: +// - Helper for converting the initial position string into +// 2 coordinate values. We allow users to only provide one coordinate, +// thus, we use comma as the separator: +// (100, 100): standard input string +// (, 100), (100, ): if a value is missing, we set this value as a default +// (,): both x and y are set to default +// (abc, 100): if a value is not valid, we treat it as default +// (100, 100, 100): we only read the first two values, this is equivalent to (100, 100) +template<> +struct ::TerminalApp::JsonUtils::ConversionTrait<::TerminalApp::LaunchPosition> +{ + ::TerminalApp::LaunchPosition FromJson(const Json::Value& json) + { + ::TerminalApp::LaunchPosition ret; + std::string initialPosition{ json.asString() }; + static constexpr char singleCharDelim = ','; + std::stringstream tokenStream(initialPosition); + std::string token; + uint8_t initialPosIndex = 0; + + // Get initial position values till we run out of delimiter separated values in the stream + // or we hit max number of allowable values (= 2) + // Non-numeral values or empty string will be caught as exception and we do not assign them + for (; std::getline(tokenStream, token, singleCharDelim) && (initialPosIndex < 2); initialPosIndex++) + { + try + { + int32_t position = std::stoi(token); + if (initialPosIndex == 0) + { + ret.x.emplace(position); + } + + if (initialPosIndex == 1) + { + ret.y.emplace(position); + } + } + catch (...) + { + // Do nothing + } + } + return ret; + } + + bool CanConvert(const Json::Value& json) + { + return json.isString(); + } +}; + +// Possible Direction values +JSON_ENUM_MAPPER(::winrt::TerminalApp::Direction) +{ + JSON_MAPPINGS(4) = { + pair_type{ "left", ValueType::Left }, + pair_type{ "right", ValueType::Right }, + pair_type{ "up", ValueType::Up }, + pair_type{ "down", ValueType::Down }, + }; +}; + +// Possible SplitState values +JSON_ENUM_MAPPER(::winrt::TerminalApp::SplitState) +{ + JSON_MAPPINGS(3) = { + pair_type{ "vertical", ValueType::Vertical }, + pair_type{ "horizontal", ValueType::Horizontal }, + pair_type{ "auto", ValueType::Automatic }, + }; +}; + +// Possible SplitType values +JSON_ENUM_MAPPER(::winrt::TerminalApp::SplitType) +{ + JSON_MAPPINGS(1) = { + pair_type{ "duplicate", ValueType::Duplicate }, + }; +}; + +JSON_ENUM_MAPPER(::winrt::TerminalApp::SettingsTarget) +{ + JSON_MAPPINGS(3) = { + pair_type{ "settingsFile", ValueType::SettingsFile }, + pair_type{ "defaultsFile", ValueType::DefaultsFile }, + pair_type{ "allFiles", ValueType::AllFiles }, + }; +}; diff --git a/src/cascadia/TerminalApp/Utils.cpp b/src/cascadia/TerminalApp/Utils.cpp deleted file mode 100644 index 01fa28dfdd1..00000000000 --- a/src/cascadia/TerminalApp/Utils.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#include "pch.h" -#include "Utils.h" - -// Method Description: -// - Constructs a wstring from a given Json::Value object. Reads the object as -// a std::string using asString, then builds an hstring from that std::string, -// then converts that hstring into a std::wstring. -// Arguments: -// - json: the Json::Value to parse as a string -// Return Value: -// - the wstring equivalent of the value in json -std::wstring GetWstringFromJson(const Json::Value& json) -{ - return winrt::to_hstring(json.asString()).c_str(); -} diff --git a/src/cascadia/TerminalApp/Utils.h b/src/cascadia/TerminalApp/Utils.h index bba97694282..cb23bac450d 100644 --- a/src/cascadia/TerminalApp/Utils.h +++ b/src/cascadia/TerminalApp/Utils.h @@ -13,8 +13,6 @@ Author(s): --*/ #pragma once -std::wstring GetWstringFromJson(const Json::Value& json); - // Method Description: // - Create a std::string from a string_view. We do this because we can't look // up a key in a Json::Value with a string_view directly, so instead we'll use diff --git a/src/cascadia/TerminalApp/defaults.json b/src/cascadia/TerminalApp/defaults.json index 531c1724427..b4167968f79 100644 --- a/src/cascadia/TerminalApp/defaults.json +++ b/src/cascadia/TerminalApp/defaults.json @@ -6,6 +6,7 @@ "initialCols": 120, "initialRows": 30, "launchMode": "default", + "alwaysOnTop": false, // Selection "copyOnSelect": false, @@ -277,6 +278,7 @@ { "command": "toggleFullscreen", "keys": "alt+enter" }, { "command": "toggleFullscreen", "keys": "f11" }, { "command": "toggleFocusMode" }, + { "command": "toggleAlwaysOnTop" }, { "command": "openNewTabDropdown", "keys": "ctrl+shift+space" }, { "command": "openSettings", "keys": "ctrl+," }, { "command": { "action": "openSettings", "target": "defaultsFile" }, "keys": "ctrl+alt+," }, diff --git a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj index 6c9dc3323b7..0fb6b823c4c 100644 --- a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj +++ b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj @@ -109,6 +109,7 @@ + @@ -178,8 +179,6 @@ - - diff --git a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj.filters b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj.filters index 5f856a6d4a8..d716860a4af 100644 --- a/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj.filters +++ b/src/cascadia/TerminalApp/lib/TerminalAppLib.vcxproj.filters @@ -8,7 +8,6 @@ - @@ -50,9 +49,6 @@ json - - json - tab @@ -92,6 +88,9 @@ settings + + settings + settings @@ -199,4 +198,4 @@ app - \ No newline at end of file + diff --git a/src/cascadia/TerminalCore/TerminalDispatch.cpp b/src/cascadia/TerminalCore/TerminalDispatch.cpp index 26826ddf34e..cf79384f70c 100644 --- a/src/cascadia/TerminalCore/TerminalDispatch.cpp +++ b/src/cascadia/TerminalCore/TerminalDispatch.cpp @@ -354,12 +354,12 @@ bool TerminalDispatch::EnableAlternateScroll(const bool enabled) noexcept return true; } -bool TerminalDispatch::SetPrivateModes(const std::basic_string_view params) noexcept +bool TerminalDispatch::SetPrivateModes(const gsl::span params) noexcept { return _SetResetPrivateModes(params, true); } -bool TerminalDispatch::ResetPrivateModes(const std::basic_string_view params) noexcept +bool TerminalDispatch::ResetPrivateModes(const gsl::span params) noexcept { return _SetResetPrivateModes(params, false); } @@ -374,7 +374,7 @@ bool TerminalDispatch::ResetPrivateModes(const std::basic_string_view params, const bool enable) noexcept +bool TerminalDispatch::_SetResetPrivateModes(const gsl::span params, const bool enable) noexcept { // because the user might chain together params we don't support with params we DO support, execute all // params in the sequence, and only return failure if we failed at least one of them diff --git a/src/cascadia/TerminalCore/TerminalDispatch.hpp b/src/cascadia/TerminalCore/TerminalDispatch.hpp index c916bb35895..640f8eb242f 100644 --- a/src/cascadia/TerminalCore/TerminalDispatch.hpp +++ b/src/cascadia/TerminalCore/TerminalDispatch.hpp @@ -13,7 +13,7 @@ class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatc void Print(const wchar_t wchPrintable) noexcept override; void PrintString(const std::wstring_view string) noexcept override; - bool SetGraphicsRendition(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions> options) noexcept override; + bool SetGraphicsRendition(const gsl::span options) noexcept override; bool CursorPosition(const size_t line, const size_t column) noexcept override; // CUP @@ -59,16 +59,16 @@ class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatc bool EnableAnyEventMouseMode(const bool enabled) noexcept override; // ?1003 bool EnableAlternateScroll(const bool enabled) noexcept override; // ?1007 - bool SetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> /*params*/) noexcept override; // DECSET - bool ResetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> /*params*/) noexcept override; // DECRST + bool SetPrivateModes(const gsl::span /*params*/) noexcept override; // DECSET + bool ResetPrivateModes(const gsl::span /*params*/) noexcept override; // DECRST private: ::Microsoft::Terminal::Core::ITerminalApi& _terminalApi; - size_t _SetRgbColorsHelper(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions> options, + size_t _SetRgbColorsHelper(const gsl::span options, TextAttribute& attr, const bool isForeground) noexcept; - bool _SetResetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> params, const bool enable) noexcept; + bool _SetResetPrivateModes(const gsl::span params, const bool enable) noexcept; bool _PrivateModeParamsHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams param, const bool enable) noexcept; }; diff --git a/src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp b/src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp index 195b68bf126..b03cae1c7b8 100644 --- a/src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp +++ b/src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp @@ -41,7 +41,7 @@ const BYTE BRIGHT_WHITE = BRIGHT_ATTR | RED_ATTR | GREEN_ATTR | BLUE_ATTR; // - isForeground - Whether or not the parsed color is for the foreground. // Return Value: // - The number of options consumed, not including the initial 38/48. -size_t TerminalDispatch::_SetRgbColorsHelper(const std::basic_string_view options, +size_t TerminalDispatch::_SetRgbColorsHelper(const gsl::span options, TextAttribute& attr, const bool isForeground) noexcept { @@ -94,7 +94,7 @@ size_t TerminalDispatch::_SetRgbColorsHelper(const std::basic_string_view options) noexcept +bool TerminalDispatch::SetGraphicsRendition(const gsl::span options) noexcept { TextAttribute attr = _terminalApi.GetTextAttributes(); @@ -264,10 +264,10 @@ bool TerminalDispatch::SetGraphicsRendition(const std::basic_string_viewMouseScrolled({ this, &AppHost::_WindowMouseWheeled }); + _window->SetAlwaysOnTop(_logic.AlwaysOnTop()); _window->MakeWindow(); } @@ -156,8 +157,9 @@ void AppHost::Initialize() _window->DragRegionClicked([this]() { _logic.TitlebarClicked(); }); _logic.RequestedThemeChanged({ this, &AppHost::_UpdateTheme }); - _logic.ToggleFullscreen({ this, &AppHost::_ToggleFullscreen }); - _logic.ToggleFocusMode({ this, &AppHost::_ToggleFocusMode }); + _logic.FullscreenChanged({ this, &AppHost::_FullscreenChanged }); + _logic.FocusModeChanged({ this, &AppHost::_FocusModeChanged }); + _logic.AlwaysOnTopChanged({ this, &AppHost::_AlwaysOnTopChanged }); _logic.Create(); @@ -353,16 +355,22 @@ void AppHost::_UpdateTheme(const winrt::Windows::Foundation::IInspectable&, cons _window->OnApplicationThemeChanged(arg); } -void AppHost::_ToggleFocusMode(const winrt::Windows::Foundation::IInspectable&, - const winrt::TerminalApp::ToggleFocusModeEventArgs&) +void AppHost::_FocusModeChanged(const winrt::Windows::Foundation::IInspectable&, + const winrt::Windows::Foundation::IInspectable&) { - _window->ToggleFocusMode(); + _window->FocusModeChanged(_logic.FocusMode()); } -void AppHost::_ToggleFullscreen(const winrt::Windows::Foundation::IInspectable&, - const winrt::TerminalApp::ToggleFullscreenEventArgs&) +void AppHost::_FullscreenChanged(const winrt::Windows::Foundation::IInspectable&, + const winrt::Windows::Foundation::IInspectable&) { - _window->ToggleFullscreen(); + _window->FullscreenChanged(_logic.Fullscreen()); +} + +void AppHost::_AlwaysOnTopChanged(const winrt::Windows::Foundation::IInspectable&, + const winrt::Windows::Foundation::IInspectable&) +{ + _window->SetAlwaysOnTop(_logic.AlwaysOnTop()); } // Method Description: diff --git a/src/cascadia/WindowsTerminal/AppHost.h b/src/cascadia/WindowsTerminal/AppHost.h index 842f8c19bba..4e072411de8 100644 --- a/src/cascadia/WindowsTerminal/AppHost.h +++ b/src/cascadia/WindowsTerminal/AppHost.h @@ -33,9 +33,11 @@ class AppHost const winrt::Windows::UI::Xaml::UIElement& arg); void _UpdateTheme(const winrt::Windows::Foundation::IInspectable&, const winrt::Windows::UI::Xaml::ElementTheme& arg); - void _ToggleFocusMode(const winrt::Windows::Foundation::IInspectable& sender, - const winrt::TerminalApp::ToggleFocusModeEventArgs& arg); - void _ToggleFullscreen(const winrt::Windows::Foundation::IInspectable& sender, - const winrt::TerminalApp::ToggleFullscreenEventArgs& arg); + void _FocusModeChanged(const winrt::Windows::Foundation::IInspectable& sender, + const winrt::Windows::Foundation::IInspectable& arg); + void _FullscreenChanged(const winrt::Windows::Foundation::IInspectable& sender, + const winrt::Windows::Foundation::IInspectable& arg); + void _AlwaysOnTopChanged(const winrt::Windows::Foundation::IInspectable& sender, + const winrt::Windows::Foundation::IInspectable& arg); void _WindowMouseWheeled(const til::point coord, const int32_t delta); }; diff --git a/src/cascadia/WindowsTerminal/IslandWindow.cpp b/src/cascadia/WindowsTerminal/IslandWindow.cpp index 3e78181d6bb..e6497d1d48b 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/IslandWindow.cpp @@ -51,17 +51,18 @@ void IslandWindow::MakeWindow() noexcept // Create the window with the default size here - During the creation of the // window, the system will give us a chance to set its size in WM_CREATE. // WM_CREATE will be handled synchronously, before CreateWindow returns. - WINRT_VERIFY(CreateWindow(wc.lpszClassName, - L"Windows Terminal", - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - CW_USEDEFAULT, - nullptr, - nullptr, - wc.hInstance, - this)); + WINRT_VERIFY(CreateWindowEx(_alwaysOnTop ? WS_EX_TOPMOST : 0, + wc.lpszClassName, + L"Windows Terminal", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + nullptr, + nullptr, + wc.hInstance, + this)); WINRT_ASSERT(_window); } @@ -442,25 +443,63 @@ void IslandWindow::OnApplicationThemeChanged(const winrt::Windows::UI::Xaml::Ele } // Method Description: -// - Toggles our focus mode state. See _SetIsBorderless for more details. +// - Updates our focus mode state. See _SetIsBorderless for more details. // Arguments: // - // Return Value: // - -void IslandWindow::ToggleFocusMode() +void IslandWindow::FocusModeChanged(const bool focusMode) { - _SetIsBorderless(!_borderless); + // Do nothing if the value was unchanged. + if (focusMode == _borderless) + { + return; + } + + _SetIsBorderless(focusMode); } // Method Description: -// - Toggles our fullscreen state. See _SetIsFullscreen for more details. +// - Updates our fullscreen state. See _SetIsFullscreen for more details. // Arguments: // - // Return Value: // - -void IslandWindow::ToggleFullscreen() +void IslandWindow::FullscreenChanged(const bool fullscreen) +{ + // Do nothing if the value was unchanged. + if (fullscreen == _fullscreen) + { + return; + } + + _SetIsFullscreen(fullscreen); +} + +// Method Description: +// - Enter or exit the "always on top" state. Before the window is created, this +// value will later be used when we create the window to create the window on +// top of all others. After the window is created, it will either enter the +// group of topmost windows, or exit the group of topmost windows. +// Arguments: +// - alwaysOnTop: whether we should be entering or exiting always on top mode. +// Return Value: +// - +void IslandWindow::SetAlwaysOnTop(const bool alwaysOnTop) { - _SetIsFullscreen(!_fullscreen); + _alwaysOnTop = alwaysOnTop; + + const auto hwnd = GetHandle(); + if (hwnd) + { + SetWindowPos(hwnd, + _alwaysOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, + 0, // the window dimensions are unused, because we're passing SWP_NOSIZE + 0, + 0, + 0, + SWP_NOMOVE | SWP_NOSIZE); + } } // From GdiEngine::s_SetWindowLongWHelper diff --git a/src/cascadia/WindowsTerminal/IslandWindow.h b/src/cascadia/WindowsTerminal/IslandWindow.h index eff8f7724a9..cd593e6663f 100644 --- a/src/cascadia/WindowsTerminal/IslandWindow.h +++ b/src/cascadia/WindowsTerminal/IslandWindow.h @@ -32,8 +32,9 @@ class IslandWindow : void SetCreateCallback(std::function pfn) noexcept; void SetSnapDimensionCallback(std::function pfn) noexcept; - void ToggleFocusMode(); - void ToggleFullscreen(); + void FocusModeChanged(const bool focusMode); + void FullscreenChanged(const bool fullscreen); + void SetAlwaysOnTop(const bool alwaysOnTop); #pragma endregion @@ -63,6 +64,7 @@ class IslandWindow : bool _borderless{ false }; bool _fullscreen{ false }; + bool _alwaysOnTop{ false }; RECT _fullscreenWindowSize; RECT _nonFullscreenWindowSize; diff --git a/src/cascadia/ut_app/JsonTests.cpp b/src/cascadia/ut_app/JsonTests.cpp index 9fd573134f7..1afbeaeddff 100644 --- a/src/cascadia/ut_app/JsonTests.cpp +++ b/src/cascadia/ut_app/JsonTests.cpp @@ -28,8 +28,6 @@ namespace TerminalAppUnitTests TEST_METHOD(ParseSimpleColorScheme); TEST_METHOD(ProfileGeneratesGuid); - TEST_METHOD(TestWrongValueType); - TEST_CLASS_SETUP(ClassSetup) { InitializeJsonReader(); @@ -169,58 +167,4 @@ namespace TerminalAppUnitTests VERIFY_ARE_EQUAL(profile3.GetGuid(), nullGuid); VERIFY_ARE_EQUAL(profile4.GetGuid(), cmdGuid); } - - void JsonTests::TestWrongValueType() - { - // This json blob has a whole bunch of settings with the wrong value - // types - strings for int values, ints for strings, floats for ints, - // etc. When we encounter data that's the wrong data type, we should - // gracefully ignore it, as opposed to throwing an exception, causing us - // to fail to load the settings at all. - - const std::string settings0String{ R"( - { - "defaultProfile" : "{00000000-1111-0000-0000-000000000000}", - "profiles": [ - { - "guid" : "{00000000-1111-0000-0000-000000000000}", - "acrylicOpacity" : "0.5", - "closeOnExit" : "true", - "fontSize" : "10", - "historySize" : 1234.5678, - "padding" : 20, - "snapOnInput" : "false", - "icon" : 4, - "backgroundImageOpacity": false, - "useAcrylic" : 14 - } - ] - })" }; - - const auto settings0Json = VerifyParseSucceeded(settings0String); - - CascadiaSettings settings; - - settings._ParseJsonString(settings0String, false); - // We should not throw an exception trying to parse the settings here. - settings.LayerJson(settings._userSettings); - - VERIFY_ARE_EQUAL(1u, settings._profiles.size()); - auto& profile = settings._profiles.at(0); - Profile defaults{}; - - VERIFY_ARE_EQUAL(defaults._acrylicTransparency, profile._acrylicTransparency); - VERIFY_ARE_EQUAL(defaults._closeOnExitMode, profile._closeOnExitMode); - VERIFY_ARE_EQUAL(defaults._fontSize, profile._fontSize); - VERIFY_ARE_EQUAL(defaults._historySize, profile._historySize); - // A 20 as an int can still be treated as a json string - VERIFY_ARE_EQUAL(L"20", profile._padding); - VERIFY_ARE_EQUAL(defaults._snapOnInput, profile._snapOnInput); - // 4 is a valid string value - VERIFY_ARE_EQUAL(L"4", profile._icon); - // false is not a valid optional - VERIFY_IS_FALSE(profile._backgroundImageOpacity.has_value()); - VERIFY_ARE_EQUAL(defaults._useAcrylic, profile._useAcrylic); - } - } diff --git a/src/cascadia/ut_app/JsonUtilsTests.cpp b/src/cascadia/ut_app/JsonUtilsTests.cpp index 1016fb282a1..f3f3c7c5b2c 100644 --- a/src/cascadia/ut_app/JsonUtilsTests.cpp +++ b/src/cascadia/ut_app/JsonUtilsTests.cpp @@ -3,7 +3,7 @@ #include "precomp.h" -#include "../TerminalApp/JsonUtilsNew.h" +#include "../TerminalApp/JsonUtils.h" using namespace Microsoft::Console; using namespace WEX::Logging; diff --git a/src/host/ApiRoutines.h b/src/host/ApiRoutines.h index 3bd93f76c66..13a06ce72e9 100644 --- a/src/host/ApiRoutines.h +++ b/src/host/ApiRoutines.h @@ -208,12 +208,12 @@ class ApiRoutines : public IApiRoutines size_t& written) noexcept override; [[nodiscard]] HRESULT WriteConsoleInputAImpl(InputBuffer& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept override; [[nodiscard]] HRESULT WriteConsoleInputWImpl(InputBuffer& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept override; @@ -228,7 +228,7 @@ class ApiRoutines : public IApiRoutines Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override; [[nodiscard]] HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext, - const std::basic_string_view attrs, + const gsl::span attrs, const COORD target, size_t& used) noexcept override; diff --git a/src/host/_output.cpp b/src/host/_output.cpp index 65413033a48..28f82dad861 100644 --- a/src/host/_output.cpp +++ b/src/host/_output.cpp @@ -69,7 +69,7 @@ void WriteToScreen(SCREEN_INFORMATION& screenInfo, const Viewport& region) // Return Value: // - S_OK, E_INVALIDARG or similar HRESULT error. [[nodiscard]] HRESULT ApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext, - const std::basic_string_view attrs, + const gsl::span attrs, const COORD target, size_t& used) noexcept { diff --git a/src/host/alias.cpp b/src/host/alias.cpp index 5c44a843ab4..e58fbdb0e91 100644 --- a/src/host/alias.cpp +++ b/src/host/alias.cpp @@ -149,7 +149,7 @@ std::unordered_mapsize() > 0) { - gsl::at(*target, 0) = UNICODE_NULL; + til::at(*target, 0) = UNICODE_NULL; } std::wstring exeNameString(exeName); @@ -211,7 +211,7 @@ std::unordered_map 0) { - gsl::at(target, 0) = ANSI_NULL; + til::at(target, 0) = ANSI_NULL; } LockConsole(); @@ -451,7 +451,7 @@ void Alias::s_ClearCmdExeAliases() if (aliasBuffer.has_value() && aliasBuffer->size() > 0) { - gsl::at(*aliasBuffer, 0) = UNICODE_NULL; + til::at(*aliasBuffer, 0) = UNICODE_NULL; } std::wstring exeNameString(exeName); @@ -543,7 +543,7 @@ void Alias::s_ClearCmdExeAliases() { if (alias.size() > 0) { - gsl::at(alias, 0) = '\0'; + til::at(alias, 0) = '\0'; } LockConsole(); @@ -698,7 +698,7 @@ void Alias::s_ClearCmdExeAliases() writtenOrNeeded = 0; if (aliasExesBuffer.has_value() && aliasExesBuffer->size() > 0) { - gsl::at(*aliasExesBuffer, 0) = UNICODE_NULL; + til::at(*aliasExesBuffer, 0) = UNICODE_NULL; } LPWSTR AliasExesBufferPtrW = aliasExesBuffer.has_value() ? aliasExesBuffer->data() : nullptr; @@ -761,7 +761,7 @@ void Alias::s_ClearCmdExeAliases() { if (aliasExes.size() > 0) { - gsl::at(aliasExes, 0) = '\0'; + til::at(aliasExes, 0) = '\0'; } LockConsole(); diff --git a/src/host/conareainfo.cpp b/src/host/conareainfo.cpp index 5be0b5edb7f..b336c0d782c 100644 --- a/src/host/conareainfo.cpp +++ b/src/host/conareainfo.cpp @@ -112,7 +112,7 @@ void ConversionAreaInfo::SetAttributes(const TextAttribute& attr) void ConversionAreaInfo::WriteText(const std::vector& text, const SHORT column) { - std::basic_string_view view(text.data(), text.size()); + gsl::span view(text.data(), text.size()); _screenBuffer->Write(view, { column, 0 }); } diff --git a/src/host/conimeinfo.cpp b/src/host/conimeinfo.cpp index 56b3891c2fa..5a9012d2ae6 100644 --- a/src/host/conimeinfo.cpp +++ b/src/host/conimeinfo.cpp @@ -57,15 +57,15 @@ void ConsoleImeInfo::RedrawCompMessage() // - attributes - Encoded attributes including the cursor position and the color index (to the array) // - colorArray - An array of colors to use for the text void ConsoleImeInfo::WriteCompMessage(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray) + const gsl::span attributes, + const gsl::span colorArray) { ClearAllAreas(); // Save copies of the composition message in case we need to redraw it as things scroll/resize _text = text; - _attributes = attributes; - _colorArray = colorArray; + _attributes.assign(attributes.begin(), attributes.end()); + _colorArray.assign(colorArray.begin(), colorArray.end()); _WriteUndeterminedChars(text, attributes, colorArray); } @@ -177,8 +177,8 @@ void ConsoleImeInfo::ClearAllAreas() // Return Value: // - TextAttribute object with color and cursor and line drawing data. TextAttribute ConsoleImeInfo::s_RetrieveAttributeAt(const size_t pos, - const std::basic_string_view attributes, - const std::basic_string_view colorArray) + const gsl::span attributes, + const gsl::span colorArray) { // Encoded attribute is the shorthand information passed from the IME // that contains a cursor position packed in along with which color in the @@ -214,8 +214,8 @@ TextAttribute ConsoleImeInfo::s_RetrieveAttributeAt(const size_t pos, // Return Value: // - Vector of OutputCells where each one represents one cell of the output buffer. std::vector ConsoleImeInfo::s_ConvertToCells(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray) + const gsl::span attributes, + const gsl::span colorArray) { std::vector cells; @@ -389,8 +389,8 @@ std::vector::const_iterator ConsoleImeInfo::_WriteConversionArea(con // each text character. This view must be the same size as the text view. // - colorArray - 8 colors to be used to format the text for display void ConsoleImeInfo::_WriteUndeterminedChars(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray) + const gsl::span attributes, + const gsl::span colorArray) { CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); SCREEN_INFORMATION& screenInfo = gci.GetActiveOutputBuffer(); diff --git a/src/host/conimeinfo.h b/src/host/conimeinfo.h index 7caec15be9d..2a3016ff0f6 100644 --- a/src/host/conimeinfo.h +++ b/src/host/conimeinfo.h @@ -48,8 +48,8 @@ class ConsoleImeInfo final [[nodiscard]] HRESULT ResizeAllAreas(const COORD newSize); void WriteCompMessage(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray); + const gsl::span attributes, + const gsl::span colorArray); void WriteResultMessage(const std::wstring_view text); @@ -64,18 +64,18 @@ class ConsoleImeInfo final void _ClearComposition(); void _WriteUndeterminedChars(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray); + const gsl::span attributes, + const gsl::span colorArray); void _InsertConvertedString(const std::wstring_view text); static TextAttribute s_RetrieveAttributeAt(const size_t pos, - const std::basic_string_view attributes, - const std::basic_string_view colorArray); + const gsl::span attributes, + const gsl::span colorArray); static std::vector s_ConvertToCells(const std::wstring_view text, - const std::basic_string_view attributes, - const std::basic_string_view colorArray); + const gsl::span attributes, + const gsl::span colorArray); std::vector::const_iterator _WriteConversionArea(const std::vector::const_iterator begin, const std::vector::const_iterator end, @@ -86,6 +86,6 @@ class ConsoleImeInfo final bool _isSavedCursorVisible; std::wstring _text; - std::basic_string _attributes; - std::basic_string _colorArray; + std::vector _attributes; + std::vector _colorArray; }; diff --git a/src/host/convarea.cpp b/src/host/convarea.cpp index face646ebf0..98546d8babf 100644 --- a/src/host/convarea.cpp +++ b/src/host/convarea.cpp @@ -125,8 +125,8 @@ void WriteConvRegionToScreen(const SCREEN_INFORMATION& ScreenInfo, } [[nodiscard]] HRESULT ImeComposeData(std::wstring_view text, - std::basic_string_view attributes, - std::basic_string_view colorArray) + gsl::span attributes, + gsl::span colorArray) { try { diff --git a/src/host/dbcs.cpp b/src/host/dbcs.cpp index fc4fd4586c0..eebfcf52a7e 100644 --- a/src/host/dbcs.cpp +++ b/src/host/dbcs.cpp @@ -67,10 +67,10 @@ DWORD UnicodeRasterFontCellMungeOnRead(const gsl::span buffer) for (DWORD iSrc = 0; iSrc < buffer.size(); iSrc++) { // If it's not a trailing byte, copy it straight over, stripping out the Leading/Trailing flags from the attributes field. - auto& src{ gsl::at(buffer, iSrc) }; + auto& src{ til::at(buffer, iSrc) }; if (!WI_IsFlagSet(src.Attributes, COMMON_LVB_TRAILING_BYTE)) { - auto& dst{ gsl::at(buffer, iDst) }; + auto& dst{ til::at(buffer, iDst) }; dst = src; WI_ClearAllFlags(dst.Attributes, COMMON_LVB_SBCSDBCS); iDst++; diff --git a/src/host/directio.cpp b/src/host/directio.cpp index 9216f755a03..2ff831c2971 100644 --- a/src/host/directio.cpp +++ b/src/host/directio.cpp @@ -472,7 +472,7 @@ void EventsToUnicode(_Inout_ std::deque>& inEvents, // Return Value: // - HRESULT indicating success or failure [[nodiscard]] HRESULT ApiRoutines::WriteConsoleInputAImpl(InputBuffer& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept { @@ -516,7 +516,7 @@ void EventsToUnicode(_Inout_ std::deque>& inEvents, // Return Value: // - HRESULT indicating success or failure [[nodiscard]] HRESULT ApiRoutines::WriteConsoleInputWImpl(InputBuffer& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept { @@ -1042,7 +1042,7 @@ void EventsToUnicode(_Inout_ std::deque>& inEvents, const auto subspan = buffer.subspan(totalOffset, writeRectangle.Width()); // Convert to a CHAR_INFO view to fit into the iterator - const auto charInfos = std::basic_string_view(subspan.data(), subspan.size()); + const auto charInfos = gsl::span(subspan.data(), subspan.size()); // Make the iterator and write to the target position. OutputCellIterator it(charInfos); diff --git a/src/host/getset.cpp b/src/host/getset.cpp index 77c830aedfe..9c2d0e26494 100644 --- a/src/host/getset.cpp +++ b/src/host/getset.cpp @@ -1604,7 +1604,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo) if (title.has_value() && title->size() > 0) { - gsl::at(*title, 0) = ANSI_NULL; + til::at(*title, 0) = ANSI_NULL; } // Get the appropriate title and length depending on the mode. @@ -1667,7 +1667,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo) if (title.size() > 0) { - gsl::at(title, 0) = ANSI_NULL; + til::at(title, 0) = ANSI_NULL; } // Figure out how big our temporary Unicode buffer must be to get the title. @@ -1722,7 +1722,7 @@ void DoSrvPrivateRefreshWindow(_In_ const SCREEN_INFORMATION& screenInfo) // If we didn't copy anything back and there is space, null terminate the given buffer and return. if (title.size() > 0) { - gsl::at(title, 0) = ANSI_NULL; + til::at(title, 0) = ANSI_NULL; written = 1; } } diff --git a/src/host/history.cpp b/src/host/history.cpp index 74752131260..e9da38a2a28 100644 --- a/src/host/history.cpp +++ b/src/host/history.cpp @@ -782,7 +782,7 @@ HRESULT GetConsoleCommandHistoryWImplHelper(const std::wstring_view exeName, writtenOrNeeded = 0; if (historyBuffer.size() > 0) { - gsl::at(historyBuffer, 0) = UNICODE_NULL; + til::at(historyBuffer, 0) = UNICODE_NULL; } CommandHistory* const CommandHistory = CommandHistory::s_FindByExe(exeName); @@ -859,7 +859,7 @@ HRESULT ApiRoutines::GetConsoleCommandHistoryAImpl(const std::string_view exeNam { if (commandHistory.size() > 0) { - gsl::at(commandHistory, 0) = ANSI_NULL; + til::at(commandHistory, 0) = ANSI_NULL; } LockConsole(); diff --git a/src/host/settings.cpp b/src/host/settings.cpp index f5ff47f6328..13faafa4933 100644 --- a/src/host/settings.cpp +++ b/src/host/settings.cpp @@ -726,12 +726,12 @@ void Settings::SetHistoryNoDup(const bool bHistoryNoDup) _bHistoryNoDup = bHistoryNoDup; } -std::basic_string_view Settings::Get16ColorTable() const +gsl::span Settings::Get16ColorTable() const { - return Get256ColorTable().substr(0, 16); + return Get256ColorTable().subspan(0, 16); } -std::basic_string_view Settings::Get256ColorTable() const +gsl::span Settings::Get256ColorTable() const { return { _colorTable.data(), _colorTable.size() }; } diff --git a/src/host/settings.hpp b/src/host/settings.hpp index ed13b65f6e6..decd30d72c1 100644 --- a/src/host/settings.hpp +++ b/src/host/settings.hpp @@ -159,8 +159,8 @@ class Settings bool GetHistoryNoDup() const; void SetHistoryNoDup(const bool fHistoryNoDup); - std::basic_string_view Get16ColorTable() const; - std::basic_string_view Get256ColorTable() const; + gsl::span Get16ColorTable() const; + gsl::span Get256ColorTable() const; void SetColorTableEntry(const size_t index, const COLORREF ColorValue); COLORREF GetColorTableEntry(const size_t index) const; diff --git a/src/host/ut_host/OutputCellIteratorTests.cpp b/src/host/ut_host/OutputCellIteratorTests.cpp index 4d22fabb17b..a71eca8eb77 100644 --- a/src/host/ut_host/OutputCellIteratorTests.cpp +++ b/src/host/ut_host/OutputCellIteratorTests.cpp @@ -367,7 +367,7 @@ class OutputCellIteratorTests SetVerifyOutput settings(VerifyOutputSettings::LogOnlyFailures); const std::vector colors{ FOREGROUND_GREEN, FOREGROUND_RED | BACKGROUND_BLUE, FOREGROUND_BLUE | FOREGROUND_INTENSITY, BACKGROUND_GREEN }; - const std::basic_string_view view{ colors.data(), colors.size() }; + const gsl::span view{ colors.data(), colors.size() }; OutputCellIterator it(view); @@ -401,7 +401,7 @@ class OutputCellIteratorTests charInfos.push_back(ci); } - const std::basic_string_view view{ charInfos.data(), charInfos.size() }; + const gsl::span view{ charInfos.data(), charInfos.size() }; OutputCellIterator it(view); @@ -433,7 +433,7 @@ class OutputCellIteratorTests cells.push_back(cell); } - const std::basic_string_view view{ cells.data(), cells.size() }; + const gsl::span view{ cells.data(), cells.size() }; OutputCellIterator it(view); diff --git a/src/host/ut_host/VtIoTests.cpp b/src/host/ut_host/VtIoTests.cpp index 6ef1113b86b..599a29caec4 100644 --- a/src/host/ut_host/VtIoTests.cpp +++ b/src/host/ut_host/VtIoTests.cpp @@ -254,6 +254,145 @@ void VtIoTests::DtorTestStackAllocMany() } } +class MockRenderData : public IRenderData, IUiaData +{ +public: + Microsoft::Console::Types::Viewport GetViewport() noexcept override + { + return Microsoft::Console::Types::Viewport{}; + } + + COORD GetTextBufferEndPosition() const noexcept override + { + return COORD{}; + } + + const TextBuffer& GetTextBuffer() noexcept override + { + FAIL_FAST_HR(E_NOTIMPL); + } + + const FontInfo& GetFontInfo() noexcept override + { + FAIL_FAST_HR(E_NOTIMPL); + } + + std::vector GetSelectionRects() noexcept override + { + return std::vector{}; + } + + void LockConsole() noexcept override + { + } + + void UnlockConsole() noexcept override + { + } + + const TextAttribute GetDefaultBrushColors() noexcept override + { + return TextAttribute{}; + } + + std::pair GetAttributeColors(const TextAttribute& /*attr*/) const noexcept override + { + return std::make_pair(COLORREF{}, COLORREF{}); + } + + COORD GetCursorPosition() const noexcept override + { + return COORD{}; + } + + bool IsCursorVisible() const noexcept override + { + return false; + } + + bool IsCursorOn() const noexcept override + { + return false; + } + + ULONG GetCursorHeight() const noexcept override + { + return 42ul; + } + + CursorType GetCursorStyle() const noexcept override + { + return CursorType::FullBox; + } + + ULONG GetCursorPixelWidth() const noexcept override + { + return 12ul; + } + + COLORREF GetCursorColor() const noexcept override + { + return COLORREF{}; + } + + bool IsCursorDoubleWidth() const override + { + return false; + } + + bool IsScreenReversed() const noexcept override + { + return false; + } + + const std::vector GetOverlays() const noexcept override + { + return std::vector{}; + } + + const bool IsGridLineDrawingAllowed() noexcept override + { + return false; + } + + const std::wstring GetConsoleTitle() const noexcept override + { + return std::wstring{}; + } + + const bool IsSelectionActive() const override + { + return false; + } + + const bool IsBlockSelection() const noexcept override + { + return false; + } + + void ClearSelection() override + { + } + + void SelectNewRegion(const COORD /*coordStart*/, const COORD /*coordEnd*/) override + { + } + + const COORD GetSelectionAnchor() const noexcept + { + return COORD{}; + } + + const COORD GetSelectionEnd() const noexcept + { + return COORD{}; + } + + void ColorSelection(const COORD /*coordSelectionStart*/, const COORD /*coordSelectionEnd*/, const TextAttribute /*attr*/) + { + } +}; + void VtIoTests::RendererDtorAndThread() { Log::Comment(NoThrowString().Format( @@ -261,9 +400,10 @@ void VtIoTests::RendererDtorAndThread() for (int i = 0; i < 16; ++i) { + auto data = std::make_unique(); auto thread = std::make_unique(); auto* pThread = thread.get(); - auto pRenderer = std::make_unique(nullptr, nullptr, 0, std::move(thread)); + auto pRenderer = std::make_unique(data.get(), nullptr, 0, std::move(thread)); VERIFY_SUCCEEDED(pThread->Initialize(pRenderer.get())); // Sleep for a hot sec to make sure the thread starts before we enable painting // If you don't, the thread might wait on the paint enabled event AFTER @@ -286,9 +426,10 @@ void VtIoTests::RendererDtorAndThreadAndDx() for (int i = 0; i < 16; ++i) { + auto data = std::make_unique(); auto thread = std::make_unique(); auto* pThread = thread.get(); - auto pRenderer = std::make_unique(nullptr, nullptr, 0, std::move(thread)); + auto pRenderer = std::make_unique(data.get(), nullptr, 0, std::move(thread)); VERIFY_SUCCEEDED(pThread->Initialize(pRenderer.get())); auto dxEngine = std::make_unique<::Microsoft::Console::Render::DxEngine>(); diff --git a/src/inc/conime.h b/src/inc/conime.h index 16f66808f5a..18ebf245f00 100644 --- a/src/inc/conime.h +++ b/src/inc/conime.h @@ -32,8 +32,8 @@ constexpr BYTE CONIME_CURSOR_LEFT = 0x20; [[nodiscard]] HRESULT ImeEndComposition(); [[nodiscard]] HRESULT ImeComposeData(std::wstring_view text, - std::basic_string_view attributes, - std::basic_string_view colorArray); + gsl::span attributes, + gsl::span colorArray); [[nodiscard]] HRESULT ImeClearComposeData(); diff --git a/src/inc/til.h b/src/inc/til.h index b1773062cbc..e9504535708 100644 --- a/src/inc/til.h +++ b/src/inc/til.h @@ -15,6 +15,7 @@ #include "til/rectangle.h" #include "til/bitmap.h" #include "til/u8u16convert.h" +#include "til/spsc.h" namespace til // Terminal Implementation Library. Also: "Today I Learned" { diff --git a/src/inc/til/at.h b/src/inc/til/at.h index 56001dfe879..f08f7bb08bb 100644 --- a/src/inc/til/at.h +++ b/src/inc/til/at.h @@ -5,17 +5,52 @@ namespace til { + namespace details + { + // This was lifted from gsl::details::is_span. + template + struct is_span_oracle : std::false_type + { + }; + +#ifdef GSL_SPAN_H + template + struct is_span_oracle> : std::true_type + { + }; +#endif + + template + struct is_span : public is_span_oracle> + { + }; + } + // The at function declares that you've already sufficiently checked that your array access // is in range before retrieving an item inside it at an offset. // This is to save double/triple/quadruple testing in circumstances where you are already // pivoting on the length of a set and now want to pull elements out of it by offset // without checking again. // gsl::at will do the check again. As will .at(). And using [] will have a warning in audit. - template + // This template is explicitly disabled if T is of type gsl::span, as it would interfere with + // the overload below. + template::value, int> = 0> constexpr auto at(T& cont, const size_t i) -> decltype(cont[cont.size()]) { #pragma warning(suppress : 26482) // Suppress bounds.2 check for indexing with constant expressions #pragma warning(suppress : 26446) // Suppress bounds.4 check for subscript operator. return cont[i]; } + +#ifdef GSL_SPAN_H + // This is an overload of til::at for span that access its backing buffer directly (UNCHECKED) + template + constexpr auto at(gsl::span span, const std::ptrdiff_t i) -> decltype(span[span.size()]) + { +#pragma warning(suppress : 26481) // Suppress bounds.1 check for doing pointer arithmetic +#pragma warning(suppress : 26482) // Suppress bounds.2 check for indexing with constant expressions +#pragma warning(suppress : 26446) // Suppress bounds.4 check for subscript operator. + return span.data()[i]; + } +#endif } diff --git a/src/inc/til/spsc.h b/src/inc/til/spsc.h new file mode 100644 index 00000000000..374306637fb --- /dev/null +++ b/src/inc/til/spsc.h @@ -0,0 +1,643 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#pragma once + +// til::spsc::details::arc requires std::atomic::wait() and ::notify_one() and at the time of writing no +// STL supports these. Since both Windows and Linux offer a Futex implementation we can easily implement this though. +// On other platforms we fall back to using a std::condition_variable. +#if __cpp_lib_atomic_wait >= 201907 +#define _TIL_SPSC_DETAIL_POSITION_IMPL_NATIVE 1 +#elif defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN8 +#define _TIL_SPSC_DETAIL_POSITION_IMPL_WIN 1 +#elif __linux__ +#define _TIL_SPSC_DETAIL_POSITION_IMPL_LINUX 1 +#else +#define _TIL_SPSC_DETAIL_POSITION_IMPL_FALLBACK 1 +#endif + +// til: Terminal Implementation Library. Also: "Today I Learned". +// spsc: Single Producer Single Consumer. A SPSC queue/channel sends data from exactly one sender to one receiver. +namespace til::spsc +{ + using size_type = uint32_t; + + namespace details + { + static constexpr size_type position_mask = std::numeric_limits::max() >> 2u; // 0b00111.... + static constexpr size_type revolution_flag = 1u << (std::numeric_limits::digits - 2u); // 0b01000.... + static constexpr size_type drop_flag = 1u << (std::numeric_limits::digits - 1u); // 0b10000.... + + struct block_initially_policy + { + using _spsc_policy = int; + static constexpr bool _block_forever = false; + }; + + struct block_forever_policy + { + using _spsc_policy = int; + static constexpr bool _block_forever = true; + }; + + template + using enable_if_wait_policy_t = typename std::remove_reference_t::_spsc_policy; + +#if _TIL_SPSC_DETAIL_POSITION_IMPL_NATIVE + using atomic_size_type = std::atomic; +#else + // atomic_size_type is a fallback if native std::atomic::wait() + // and ::notify_one() methods are unavailable in the STL. + struct atomic_size_type + { + size_type load(std::memory_order order) const noexcept + { + return _value.load(order); + } + + void store(size_type desired, std::memory_order order) noexcept + { +#if _TIL_SPSC_DETAIL_POSITION_IMPL_FALLBACK + // We must use a lock here to prevent us from modifying the value + // in between wait() reading the value and the thread being suspended. + std::lock_guard lock{ _m }; +#endif + _value.store(desired, order); + } + + void wait(size_type old, [[maybe_unused]] std::memory_order order) const noexcept + { +#if _TIL_SPSC_DETAIL_POSITION_IMPL_WIN +#pragma warning(suppress : 26492) // Don't use const_cast to cast away const or volatile + WaitOnAddress(const_cast*>(&_value), &old, sizeof(_value), INFINITE); +#elif _TIL_SPSC_DETAIL_POSITION_IMPL_LINUX + futex(FUTEX_WAIT_PRIVATE, old); +#elif _TIL_SPSC_DETAIL_POSITION_IMPL_FALLBACK + std::unique_lock lock{ _m }; + _cv.wait(lock, [&]() { return _value.load(order) != old; }); +#endif + } + + void notify_one() noexcept + { +#if _TIL_SPSC_DETAIL_POSITION_IMPL_WIN + WakeByAddressSingle(&_value); +#elif _TIL_SPSC_DETAIL_POSITION_IMPL_LINUX + futex(FUTEX_WAKE_PRIVATE, 1); +#elif _TIL_SPSC_DETAIL_POSITION_IMPL_FALLBACK + _cv.notify_one(); +#endif + } + + private: +#if _TIL_SPSC_DETAIL_POSITION_IMPL_LINUX + inline void futex(int futex_op, size_type val) const noexcept + { + // See: https://man7.org/linux/man-pages/man2/futex.2.html + static_assert(sizeof(std::atomic) == 4); + syscall(SYS_futex, &_value, futex_op, val, nullptr, nullptr, 0); + } +#endif + + std::atomic _value{ 0 }; + +#if _TIL_SPSC_DETAIL_POSITION_IMPL_FALLBACK + private: + std::mutex _m; + std::condition_variable _cv; +#endif + }; +#endif + + template + inline T* alloc_raw_memory(size_t size) + { + constexpr auto alignment = alignof(T); + if constexpr (alignment <= __STDCPP_DEFAULT_NEW_ALIGNMENT__) + { + return static_cast(::operator new(size)); + } + else + { + return static_cast(::operator new(size, std::align_val_t(alignment))); + } + } + + template + inline void free_raw_memory(T* ptr) noexcept + { + constexpr auto alignment = alignof(T); + if constexpr (alignment <= __STDCPP_DEFAULT_NEW_ALIGNMENT__) + { + ::operator delete(ptr); + } + else + { + ::operator delete(ptr, std::align_val_t(alignment)); + } + } + + struct acquisition + { + // The index range [begin, end) is the range of slots in the array returned by + // arc::data() that may be written to / read from respectively. + // If a range has been successfully acquired "end > begin" is true. end thus can't be 0. + size_type begin; + size_type end; + + // Upon release() of an acquisition, next is the value that's written to the consumer/producer position. + // It's basically the same as end, but with the revolution flag mixed in. + // If end is equal to capacity, next will be 0 (mixed with the next revolution flag). + size_type next; + + // If the other side of the queue hasn't been destroyed yet, alive will be true. + bool alive; + + constexpr acquisition(size_type begin, size_type end, size_type next, bool alive) : + begin(begin), + end(end), + next(next), + alive(alive) + { + } + }; + + // The following assumes you know what ring/circular buffers are. You can read about them here: + // https://en.wikipedia.org/wiki/Circular_buffer + // + // Furthermore the implementation solves a problem known as the producer-consumer problem: + // https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem + // + // arc follows the classic spsc design and manages a ring buffer with two positions: _producer and _consumer. + // They contain the position the producer / consumer will next write to / read from respectively. + // As usual with ring buffers, these positions are modulo to the _capacity of the underlying buffer. + // The producer's writable range is [_producer, _consumer) and the consumer's readable is [_consumer, _producer). + // + // After you wrote the numbers 0 to 6 into a queue of size 10, a typical state of the ring buffer might be: + // [ 0 | 1 | 2 | 3 | 4 | 5 | 6 | _ | _ | _ | _ ] + // ^ ^ ^ + // _consumer = 0 _producer = 7 _capacity = 10 + // + // As you can see the readable range currently is [_consumer, _producer) = [0, 7). + // The remaining writable range on the other hand is [_producer, _consumer) = [7, 0). + // Wait, what? [7, 0)? How does that work? As all positions are modulo _capacity, 0 mod 10 is the same as 10 mod 10. + // If we only want to read forward in the buffer [7, 0) is thus the same as [7, 10). + // + // If we read 3 items from the queue the contents will be: + // [ _ | _ | _ | 3 | 4 | 5 | 6 | _ | _ | _ | _ ] + // ^ ^ + // _consumer = 3 _producer = 7 + // + // Now the writable range is still [_producer, _consumer), but it wraps around the end of the ring buffer. + // In this case arc will split the range in two and return each separately in acquire(). + // The first returned range will be [_producer, _capacity) and the second [0, _consumer). + // The same logic applies if the readable range wraps around the end of the ring buffer. + // + // As these are symmetric, the logic for acquiring and releasing ranges is the same for both sides. + // The producer will acquire() and release() ranges with its own position as "mine" and the consumer's + // position as "theirs". These arguments are correspondingly flipped for the consumer. + // + // As part of the producer-consumer problem, the producer cannot write more values ahead of the + // consumer than the buffer's capacity. Since both positions are modulo to the capacity we can only + // determine positional differences smaller than the capacity. Due to that both producer and + // consumer store a "revolution_flag" as the second highest bit within their positions. + // This bit is flipped each time the producer/consumer wrap around the end of the ring buffer. + // If the positions are identical, except for their "revolution_flag" value, the producer thus must + // be capacity-many positions ahead of the consumer and must wait until items have been consumed. + // + // Inversely the consumer must wait until the producer has written at least one value ahead. + // This can be detected by checking whether the positions are identical including the revolution_flag. + template + struct arc + { + explicit arc(size_type capacity) noexcept : + _data(alloc_raw_memory(size_t(capacity) * sizeof(T))), + _capacity(capacity) + { + } + + ~arc() + { + auto beg = _consumer.load(std::memory_order_acquire); + auto end = _producer.load(std::memory_order_acquire); + auto differentRevolution = ((beg ^ end) & revolution_flag) != 0; + + beg &= position_mask; + end &= position_mask; + + // The producer position will always be ahead of the consumer, but since we're dealing + // with a ring buffer the producer may be wrapped around the end of the buffer. + // We thus need to deal with 3 potential cases: + // * No valid data. + // If both positions including their revolution bits are identical. + // * Valid data in the middle of the ring buffer. + // If _producer > _consumer. + // * Valid data at both ends of the ring buffer. + // If the revolution bits differ, even if the positions are otherwise identical, + // which they might be if the channel contains exactly as many values as its capacity. + if (end > beg) + { + std::destroy(_data + beg, _data + end); + } + else if (differentRevolution) + { + std::destroy(_data, _data + end); + std::destroy(_data + beg, _data + _capacity); + } + + free_raw_memory(_data); + } + + void drop_producer() + { + drop(_producer); + } + + void drop_consumer() + { + drop(_consumer); + } + + acquisition producer_acquire(size_type slots, bool blocking) noexcept + { + return acquire(_producer, _consumer, revolution_flag, slots, blocking); + } + + void producer_release(acquisition acquisition) noexcept + { + release(_producer, acquisition); + } + + acquisition consumer_acquire(size_type slots, bool blocking) noexcept + { + return acquire(_consumer, _producer, 0, slots, blocking); + } + + void consumer_release(acquisition acquisition) noexcept + { + release(_consumer, acquisition); + } + + T* data() const noexcept + { + return _data; + } + + private: + void drop(atomic_size_type& mine) + { + // Signal the other side we're dropped. See acquire() for the handling of the drop_flag. + // We don't need to use release ordering like release() does as each call to + // any of the producer/consumer methods already results in a call to release(). + // Another release ordered write can't possibly synchronize any more data anyways at this point. + const auto myPos = mine.load(std::memory_order_relaxed); + mine.store(myPos | drop_flag, std::memory_order_relaxed); + mine.notify_one(); + + // The first time SPSCBase is dropped (destroyed) we'll set + // the flag to true and get false, causing us to return early. + // Only the second time we'll get true. + // --> The contents are only deleted when both sides have been dropped. + if (_eitherSideDropped.exchange(true, std::memory_order_relaxed)) + { + delete this; + } + } + + // NOTE: waitMask MUST be either 0 (consumer) or revolution_flag (producer). + acquisition acquire(atomic_size_type& mine, atomic_size_type& theirs, size_type waitMask, size_type slots, bool blocking) noexcept + { + size_type myPos = mine.load(std::memory_order_relaxed); + size_type theirPos; + + while (true) + { + // This acquire read synchronizes with the release write in release(). + theirPos = theirs.load(std::memory_order_acquire); + if ((myPos ^ theirPos) != waitMask) + { + break; + } + if (!blocking) + { + return { + 0, + 0, + 0, + true, + }; + } + + theirs.wait(theirPos, std::memory_order_relaxed); + } + + // If the other side's position contains a drop flag, as a X -> we need to... + // * producer -> stop immediately + // FYI: isProducer == (waitMask != 0). + // * consumer -> finish consuming all values and then stop + // We're finished if the only difference between our + // and the other side's position is the drop flag. + if ((theirPos & drop_flag) != 0 && (waitMask != 0 || (myPos ^ theirPos) == drop_flag)) + { + return { + 0, + 0, + 0, + false, + }; + } + + auto begin = myPos & position_mask; + auto end = theirPos & position_mask; + + // [begin, end) is the writable/readable range for the producer/consumer. + // The following detects whether we'd be wrapping around the end of the ring buffer + // and splits the range into the first half [mine, _capacity). + // If acquire() is called again it'll return [0, theirs). + end = end > begin ? end : _capacity; + + // Of course we also need to ensure to not return more than we've been asked for. + end = std::min(end, begin + slots); + + // "next" will contain the value that's stored into "mine" when release() is called. + // It's basically the same as "end", but with the revolution flag spliced in. + // If we acquired the range [mine, _capacity) "end" will equal _capacity + // and thus wrap around the ring buffer. The next value for "mine" is thus the + // position zero | the flipped "revolution" (and 0 | x == x). + auto revolution = myPos & revolution_flag; + auto next = end != _capacity ? end | revolution : revolution ^ revolution_flag; + + return { + begin, + end, + next, + true, + }; + } + + void release(atomic_size_type& mine, acquisition acquisition) noexcept + { + // This release write synchronizes with the acquire read in acquire(). + mine.store(acquisition.next, std::memory_order_release); + mine.notify_one(); + } + + T* const _data; + const size_type _capacity; + + std::atomic _eitherSideDropped{ false }; + + atomic_size_type _producer; + atomic_size_type _consumer; + }; + + inline void validate_size(size_t v) + { + if (v > static_cast(position_mask)) + { + throw std::overflow_error{ "size too large for spsc" }; + } + } + } + + // Block until at least one item has been written into the sender / read from the receiver. + inline constexpr details::block_initially_policy block_initially{}; + + // Block until all items have been written into the sender / read from the receiver. + inline constexpr details::block_forever_policy block_forever{}; + + template + struct producer + { + explicit producer(details::arc* arc) noexcept : + _arc(arc) {} + + producer(const producer&) = delete; + producer& operator=(const producer&) = delete; + + producer(producer&& other) noexcept + { + drop(); + _arc = std::exchange(other._arc, nullptr); + } + + producer& operator=(producer&& other) noexcept + { + drop(); + _arc = std::exchange(other._arc, nullptr); + } + + ~producer() + { + drop(); + } + + // emplace constructs an item in-place at the end of the queue. + // It returns true, if the item was successfully placed within the queue. + // The return value will be false, if the consumer is gone. + template + bool emplace(Args&&... args) const + { + auto acquisition = _arc->producer_acquire(1, true); + if (!acquisition.end) + { + return false; + } + + auto data = _arc->data(); + auto begin = data + acquisition.begin; + new (begin) T(std::forward(args)...); + + _arc->producer_release(acquisition); + return true; + } + + template + std::pair push(InputIt first, InputIt last) const + { + return push_n(block_forever, first, std::distance(first, last)); + } + + // push writes the items between first and last into the queue. + // The amount of successfully written items is returned as the first pair field. + // The second pair field will be false if the consumer is gone. + template = 0> + std::pair push(WaitPolicy&& policy, InputIt first, InputIt last) const + { + return push_n(std::forward(policy), first, std::distance(first, last)); + } + + template + std::pair push_n(InputIt first, size_t count) const + { + return push_n(block_forever, first, count); + } + + // push_n writes count items from first into the queue. + // The amount of successfully written items is returned as the first pair field. + // The second pair field will be false if the consumer is gone. + template = 0> + std::pair push_n(WaitPolicy&&, InputIt first, size_t count) const + { + details::validate_size(count); + + const auto data = _arc->data(); + auto remaining = static_cast(count); + auto blocking = true; + auto ok = true; + + while (remaining != 0) + { + auto acquisition = _arc->producer_acquire(remaining, blocking); + if (!acquisition.end) + { + ok = acquisition.alive; + break; + } + + const auto begin = data + acquisition.begin; + const auto got = acquisition.end - acquisition.begin; + std::uninitialized_copy_n(first, got, begin); + first += got; + remaining -= got; + + _arc->producer_release(acquisition); + + if constexpr (!std::remove_reference_t::_block_forever) + { + blocking = false; + } + } + + return { count - remaining, ok }; + } + + private: + void drop() + { + if (_arc) + { + _arc->drop_producer(); + } + } + + details::arc* _arc = nullptr; + }; + + template + struct consumer + { + explicit consumer(details::arc* arc) noexcept : + _arc(arc) {} + + consumer(const consumer&) = delete; + consumer& operator=(const consumer&) = delete; + + consumer(consumer&& other) noexcept + { + drop(); + _arc = std::exchange(other._arc, nullptr); + } + + consumer& operator=(consumer&& other) noexcept + { + drop(); + _arc = std::exchange(other._arc, nullptr); + } + + ~consumer() + { + drop(); + } + + // pop returns the next item in the queue, or std::nullopt if the producer is gone. + std::optional pop() const + { + auto acquisition = _arc->consumer_acquire(1, true); + if (!acquisition.end) + { + return std::nullopt; + } + + auto data = _arc->data(); + auto begin = data + acquisition.begin; + + auto item = std::move(*begin); + std::destroy_at(begin); + + _arc->consumer_release(acquisition); + return item; + } + + template + std::pair pop_n(OutputIt first, size_t count) const + { + return pop_n(block_forever, first, count); + } + + // pop_n reads up to count items into first. + // The amount of successfully read items is returned as the first pair field. + // The second pair field will be false if the consumer is gone. + template = 0> + std::pair pop_n(WaitPolicy&&, OutputIt first, size_t count) const + { + details::validate_size(count); + + const auto data = _arc->data(); + auto remaining = static_cast(count); + auto blocking = true; + auto ok = true; + + while (remaining != 0) + { + auto acquisition = _arc->consumer_acquire(remaining, blocking); + if (!acquisition.end) + { + ok = acquisition.alive; + break; + } + + auto beg = data + acquisition.begin; + auto end = data + acquisition.end; + auto got = acquisition.end - acquisition.begin; + first = std::move(beg, end, first); + std::destroy(beg, end); + remaining -= got; + + _arc->consumer_release(acquisition); + + if constexpr (!std::remove_reference_t::_block_forever) + { + blocking = false; + } + } + + return { count - remaining, ok }; + } + + private: + void drop() + { + if (_arc) + { + _arc->drop_consumer(); + } + } + + details::arc* _arc = nullptr; + }; + + // channel returns a bounded, lock-free, single-producer, single-consumer + // FIFO queue ("channel") with the given maximum capacity. + template + std::pair, consumer> channel(uint32_t capacity) + { + if (capacity == 0) + { + throw std::invalid_argument{ "invalid capacity" }; + } + + const auto arc = new details::arc(capacity); + return { std::piecewise_construct, std::forward_as_tuple(arc), std::forward_as_tuple(arc) }; + } +} diff --git a/src/interactivity/onecore/BgfxEngine.cpp b/src/interactivity/onecore/BgfxEngine.cpp index 8480540a65f..a800e2c2a0b 100644 --- a/src/interactivity/onecore/BgfxEngine.cpp +++ b/src/interactivity/onecore/BgfxEngine.cpp @@ -145,7 +145,7 @@ BgfxEngine::BgfxEngine(PVOID SharedViewBase, LONG DisplayHeight, LONG DisplayWid return S_OK; } -[[nodiscard]] HRESULT BgfxEngine::PaintBufferLine(const std::basic_string_view clusters, +[[nodiscard]] HRESULT BgfxEngine::PaintBufferLine(const gsl::span clusters, const COORD coord, const bool /*trimLeft*/, const bool /*lineWrapped*/) noexcept diff --git a/src/interactivity/onecore/BgfxEngine.hpp b/src/interactivity/onecore/BgfxEngine.hpp index d68be91470c..cebedfbda41 100644 --- a/src/interactivity/onecore/BgfxEngine.hpp +++ b/src/interactivity/onecore/BgfxEngine.hpp @@ -49,7 +49,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT ScrollFrame() noexcept override; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(const std::basic_string_view clusters, + [[nodiscard]] HRESULT PaintBufferLine(const gsl::span clusters, const COORD coord, const bool trimLeft, const bool lineWrapped) noexcept override; diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp index f382dbd7c07..bdda98bc3cf 100644 --- a/src/renderer/base/renderer.cpp +++ b/src/renderer/base/renderer.cpp @@ -26,13 +26,12 @@ Renderer::Renderer(IRenderData* pData, _In_reads_(cEngines) IRenderEngine** const rgpEngines, const size_t cEngines, std::unique_ptr thread) : - _pData(pData), + _pData(THROW_HR_IF_NULL(E_INVALIDARG, pData)), _pThread{ std::move(thread) }, _destructing{ false }, - _clusterBuffer{} + _clusterBuffer{}, + _viewport{ pData->GetViewport() } { - _srViewportPrevious = { 0 }; - for (size_t i = 0; i < cEngines; i++) { IRenderEngine* engine = rgpEngines[i]; @@ -208,7 +207,7 @@ void Renderer::TriggerSystemRedraw(const RECT* const prcDirtyClient) // - void Renderer::TriggerRedraw(const Viewport& region) { - Viewport view = _pData->GetViewport(); + Viewport view = _viewport; SMALL_RECT srUpdateRegion = region.ToExclusive(); if (view.TrimToViewport(&srUpdateRegion)) @@ -357,7 +356,7 @@ void Renderer::TriggerSelection() // - True if something changed and we scrolled. False otherwise. bool Renderer::_CheckViewportAndScroll() { - SMALL_RECT const srOldViewport = _srViewportPrevious; + SMALL_RECT const srOldViewport = _viewport.ToInclusive(); SMALL_RECT const srNewViewport = _pData->GetViewport().ToInclusive(); COORD coordDelta; @@ -369,7 +368,7 @@ bool Renderer::_CheckViewportAndScroll() LOG_IF_FAILED(engine->UpdateViewport(srNewViewport)); } - _srViewportPrevious = srNewViewport; + _viewport = Viewport::FromInclusive(srNewViewport); // If we're keeping some buffers between calls, let them know about the viewport size // so they can prepare the buffers for changes to either preallocate memory at once diff --git a/src/renderer/base/renderer.hpp b/src/renderer/base/renderer.hpp index 6c30e0f4ee6..db6dc6d3875 100644 --- a/src/renderer/base/renderer.hpp +++ b/src/renderer/base/renderer.hpp @@ -120,7 +120,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT _PerformScrolling(_In_ IRenderEngine* const pEngine); - SMALL_RECT _srViewportPrevious; + Microsoft::Console::Types::Viewport _viewport; static constexpr float _shrinkThreshold = 0.8f; std::vector _clusterBuffer; diff --git a/src/renderer/dx/CustomTextLayout.cpp b/src/renderer/dx/CustomTextLayout.cpp index 7c14d646134..c9f30c039a7 100644 --- a/src/renderer/dx/CustomTextLayout.cpp +++ b/src/renderer/dx/CustomTextLayout.cpp @@ -78,7 +78,7 @@ CATCH_RETURN() // - clusters - From the backing buffer, the text to be displayed clustered by the columns it should consume. // Return Value: // - S_OK or suitable memory management issue. -[[nodiscard]] HRESULT STDMETHODCALLTYPE CustomTextLayout::AppendClusters(const std::basic_string_view<::Microsoft::Console::Render::Cluster> clusters) +[[nodiscard]] HRESULT STDMETHODCALLTYPE CustomTextLayout::AppendClusters(const gsl::span clusters) try { _textClusterColumns.reserve(_textClusterColumns.size() + clusters.size()); diff --git a/src/renderer/dx/CustomTextLayout.h b/src/renderer/dx/CustomTextLayout.h index dac30b06c12..cf2a63b574b 100644 --- a/src/renderer/dx/CustomTextLayout.h +++ b/src/renderer/dx/CustomTextLayout.h @@ -27,7 +27,7 @@ namespace Microsoft::Console::Render size_t const width, IBoxDrawingEffect* const boxEffect); - [[nodiscard]] HRESULT STDMETHODCALLTYPE AppendClusters(const std::basic_string_view<::Microsoft::Console::Render::Cluster> clusters); + [[nodiscard]] HRESULT STDMETHODCALLTYPE AppendClusters(const gsl::span clusters); [[nodiscard]] HRESULT STDMETHODCALLTYPE Reset() noexcept; diff --git a/src/renderer/dx/DxRenderer.cpp b/src/renderer/dx/DxRenderer.cpp index 5d36ff3527c..1714b6e10bd 100644 --- a/src/renderer/dx/DxRenderer.cpp +++ b/src/renderer/dx/DxRenderer.cpp @@ -1419,7 +1419,7 @@ CATCH_RETURN() // - fTrimLeft - Whether or not to trim off the left half of a double wide character // Return Value: // - S_OK or relevant DirectX error -[[nodiscard]] HRESULT DxEngine::PaintBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT DxEngine::PaintBufferLine(gsl::span const clusters, COORD const coord, const bool /*trimLeft*/, const bool /*lineWrapped*/) noexcept diff --git a/src/renderer/dx/DxRenderer.hpp b/src/renderer/dx/DxRenderer.hpp index 5bd24df1cfb..708f3418e87 100644 --- a/src/renderer/dx/DxRenderer.hpp +++ b/src/renderer/dx/DxRenderer.hpp @@ -86,7 +86,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT PrepareRenderInfo(const RenderFrameInfo& info) noexcept override; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT PaintBufferLine(gsl::span const clusters, COORD const coord, bool const fTrimLeft, const bool lineWrapped) noexcept override; diff --git a/src/renderer/gdi/gdirenderer.hpp b/src/renderer/gdi/gdirenderer.hpp index bae4ea2eda2..c375f8b764a 100644 --- a/src/renderer/gdi/gdirenderer.hpp +++ b/src/renderer/gdi/gdirenderer.hpp @@ -42,7 +42,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT ScrollFrame() noexcept override; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT PaintBufferLine(gsl::span const clusters, const COORD coord, const bool trimLeft, const bool lineWrapped) noexcept override; diff --git a/src/renderer/gdi/paint.cpp b/src/renderer/gdi/paint.cpp index 7654790df09..b416510f99e 100644 --- a/src/renderer/gdi/paint.cpp +++ b/src/renderer/gdi/paint.cpp @@ -284,7 +284,7 @@ using namespace Microsoft::Console::Render; // See: Win7: 390673, 447839 and then superseded by http://osgvsowi/638274 when FE/non-FE rendering condensed. //#define CONSOLE_EXTTEXTOUT_FLAGS ETO_OPAQUE | ETO_CLIPPED //#define MAX_POLY_LINES 80 -[[nodiscard]] HRESULT GdiEngine::PaintBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT GdiEngine::PaintBufferLine(gsl::span const clusters, const COORD coord, const bool trimLeft, const bool /*lineWrapped*/) noexcept @@ -316,7 +316,7 @@ using namespace Microsoft::Console::Render; // Convert data from clusters into the text array and the widths array. for (size_t i = 0; i < cchLine; i++) { - const auto& cluster = clusters.at(i); + const auto& cluster = til::at(clusters, i); // Our GDI renderer hasn't and isn't going to handle things above U+FFFF or sequences. // So replace anything complicated with a replacement character for drawing purposes. diff --git a/src/renderer/inc/IRenderEngine.hpp b/src/renderer/inc/IRenderEngine.hpp index 8df30a60035..a70960754c0 100644 --- a/src/renderer/inc/IRenderEngine.hpp +++ b/src/renderer/inc/IRenderEngine.hpp @@ -71,7 +71,7 @@ namespace Microsoft::Console::Render [[nodiscard]] virtual HRESULT PrepareRenderInfo(const RenderFrameInfo& info) noexcept = 0; [[nodiscard]] virtual HRESULT PaintBackground() noexcept = 0; - [[nodiscard]] virtual HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] virtual HRESULT PaintBufferLine(gsl::span const clusters, const COORD coord, const bool fTrimLeft, const bool lineWrapped) noexcept = 0; diff --git a/src/renderer/uia/UiaRenderer.cpp b/src/renderer/uia/UiaRenderer.cpp index e6bdbe19e4f..124fb5307c4 100644 --- a/src/renderer/uia/UiaRenderer.cpp +++ b/src/renderer/uia/UiaRenderer.cpp @@ -305,7 +305,7 @@ CATCH_RETURN(); // - fTrimLeft - Whether or not to trim off the left half of a double wide character // Return Value: // - S_FALSE -[[nodiscard]] HRESULT UiaEngine::PaintBufferLine(std::basic_string_view const /*clusters*/, +[[nodiscard]] HRESULT UiaEngine::PaintBufferLine(gsl::span const /*clusters*/, COORD const /*coord*/, const bool /*trimLeft*/, const bool /*lineWrapped*/) noexcept diff --git a/src/renderer/uia/UiaRenderer.hpp b/src/renderer/uia/UiaRenderer.hpp index 1bc595510cb..68c2308504c 100644 --- a/src/renderer/uia/UiaRenderer.hpp +++ b/src/renderer/uia/UiaRenderer.hpp @@ -51,7 +51,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT InvalidateCircling(_Out_ bool* const pForcePaint) noexcept override; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT PaintBufferLine(gsl::span const clusters, COORD const coord, bool const fTrimLeft, const bool lineWrapped) noexcept override; diff --git a/src/renderer/vt/XtermEngine.cpp b/src/renderer/vt/XtermEngine.cpp index a67568a4836..64a29f26e82 100644 --- a/src/renderer/vt/XtermEngine.cpp +++ b/src/renderer/vt/XtermEngine.cpp @@ -498,7 +498,7 @@ CATCH_RETURN(); // will be false. // Return Value: // - S_OK or suitable HRESULT error from writing pipe. -[[nodiscard]] HRESULT XtermEngine::PaintBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT XtermEngine::PaintBufferLine(gsl::span const clusters, const COORD coord, const bool /*trimLeft*/, const bool lineWrapped) noexcept diff --git a/src/renderer/vt/XtermEngine.hpp b/src/renderer/vt/XtermEngine.hpp index cfcbbaef6d2..9e4680fe642 100644 --- a/src/renderer/vt/XtermEngine.hpp +++ b/src/renderer/vt/XtermEngine.hpp @@ -41,7 +41,7 @@ namespace Microsoft::Console::Render [[nodiscard]] virtual HRESULT UpdateDrawingBrushes(const TextAttribute& textAttributes, const gsl::not_null pData, const bool isSettingDefaultBrushes) noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT PaintBufferLine(gsl::span const clusters, const COORD coord, const bool trimLeft, const bool lineWrapped) noexcept override; diff --git a/src/renderer/vt/paint.cpp b/src/renderer/vt/paint.cpp index cf345211e97..1604d48131c 100644 --- a/src/renderer/vt/paint.cpp +++ b/src/renderer/vt/paint.cpp @@ -125,7 +125,7 @@ using namespace Microsoft::Console::Types; // will be false. // Return Value: // - S_OK or suitable HRESULT error from writing pipe. -[[nodiscard]] HRESULT VtEngine::PaintBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT VtEngine::PaintBufferLine(gsl::span const clusters, const COORD coord, const bool /*trimLeft*/, const bool /*lineWrapped*/) noexcept @@ -327,7 +327,7 @@ using namespace Microsoft::Console::Types; // - coord - character coordinate target to render within viewport // Return Value: // - S_OK or suitable HRESULT error from writing pipe. -[[nodiscard]] HRESULT VtEngine::_PaintAsciiBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT VtEngine::_PaintAsciiBufferLine(gsl::span const clusters, const COORD coord) noexcept { try @@ -362,7 +362,7 @@ using namespace Microsoft::Console::Types; // - coord - character coordinate target to render within viewport // Return Value: // - S_OK or suitable HRESULT error from writing pipe. -[[nodiscard]] HRESULT VtEngine::_PaintUtf8BufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT VtEngine::_PaintUtf8BufferLine(gsl::span const clusters, const COORD coord, const bool lineWrapped) noexcept { diff --git a/src/renderer/vt/vtrenderer.hpp b/src/renderer/vt/vtrenderer.hpp index cb6739d702d..952be678925 100644 --- a/src/renderer/vt/vtrenderer.hpp +++ b/src/renderer/vt/vtrenderer.hpp @@ -61,7 +61,7 @@ namespace Microsoft::Console::Render [[nodiscard]] virtual HRESULT ScrollFrame() noexcept = 0; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] virtual HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] virtual HRESULT PaintBufferLine(gsl::span const clusters, const COORD coord, const bool trimLeft, const bool lineWrapped) noexcept override; @@ -208,11 +208,11 @@ namespace Microsoft::Console::Render // buffer space for these two functions to build their lines // so they don't have to alloc/free in a tight loop std::wstring _bufferLine; - [[nodiscard]] HRESULT _PaintUtf8BufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT _PaintUtf8BufferLine(gsl::span const clusters, const COORD coord, const bool lineWrapped) noexcept; - [[nodiscard]] HRESULT _PaintAsciiBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT _PaintAsciiBufferLine(gsl::span const clusters, const COORD coord) noexcept; [[nodiscard]] HRESULT _WriteTerminalUtf8(const std::wstring_view str) noexcept; diff --git a/src/renderer/wddmcon/WddmConRenderer.cpp b/src/renderer/wddmcon/WddmConRenderer.cpp index 77409bb6b03..277dd2bcf39 100644 --- a/src/renderer/wddmcon/WddmConRenderer.cpp +++ b/src/renderer/wddmcon/WddmConRenderer.cpp @@ -258,7 +258,7 @@ bool WddmConEngine::IsInitialized() return S_OK; } -[[nodiscard]] HRESULT WddmConEngine::PaintBufferLine(std::basic_string_view const clusters, +[[nodiscard]] HRESULT WddmConEngine::PaintBufferLine(gsl::span const clusters, const COORD coord, const bool /*trimLeft*/, const bool /*lineWrapped*/) noexcept diff --git a/src/renderer/wddmcon/WddmConRenderer.hpp b/src/renderer/wddmcon/WddmConRenderer.hpp index e4acac3fc96..370a03acb6e 100644 --- a/src/renderer/wddmcon/WddmConRenderer.hpp +++ b/src/renderer/wddmcon/WddmConRenderer.hpp @@ -41,7 +41,7 @@ namespace Microsoft::Console::Render [[nodiscard]] HRESULT ScrollFrame() noexcept override; [[nodiscard]] HRESULT PaintBackground() noexcept override; - [[nodiscard]] HRESULT PaintBufferLine(std::basic_string_view const clusters, + [[nodiscard]] HRESULT PaintBufferLine(gsl::span const clusters, const COORD coord, const bool trimLeft, const bool lineWrapped) noexcept override; diff --git a/src/server/ApiDispatchers.cpp b/src/server/ApiDispatchers.cpp index 5ba2d547014..db0134d482f 100644 --- a/src/server/ApiDispatchers.cpp +++ b/src/server/ApiDispatchers.cpp @@ -881,7 +881,7 @@ RETURN_IF_FAILED(pObjectHandle->GetInputBuffer(GENERIC_WRITE, &pInputBuffer)); size_t written; - std::basic_string_view buffer(reinterpret_cast(pvBuffer), cbSize / sizeof(INPUT_RECORD)); + gsl::span buffer(reinterpret_cast(pvBuffer), cbSize / sizeof(INPUT_RECORD)); if (!a->Unicode) { RETURN_IF_FAILED(m->_pApiRoutines->WriteConsoleInputAImpl(*pInputBuffer, buffer, written, !!a->Append)); @@ -1008,7 +1008,7 @@ } case CONSOLE_ATTRIBUTE: { - const std::basic_string_view text(reinterpret_cast(pvBuffer), cbBufferSize / sizeof(WORD)); + const gsl::span text(reinterpret_cast(pvBuffer), cbBufferSize / sizeof(WORD)); hr = m->_pApiRoutines->WriteConsoleOutputAttributeImpl(*pScreenInfo, text, diff --git a/src/server/IApiRoutines.h b/src/server/IApiRoutines.h index 7b32a727223..996227f0636 100644 --- a/src/server/IApiRoutines.h +++ b/src/server/IApiRoutines.h @@ -219,12 +219,12 @@ class IApiRoutines size_t& written) noexcept = 0; [[nodiscard]] virtual HRESULT WriteConsoleInputAImpl(IConsoleInputObject& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept = 0; [[nodiscard]] virtual HRESULT WriteConsoleInputWImpl(IConsoleInputObject& context, - const std::basic_string_view buffer, + const gsl::span buffer, size_t& written, const bool append) noexcept = 0; @@ -239,7 +239,7 @@ class IApiRoutines Microsoft::Console::Types::Viewport& writtenRectangle) noexcept = 0; [[nodiscard]] virtual HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext, - const std::basic_string_view attrs, + const gsl::span attrs, const COORD target, size_t& used) noexcept = 0; diff --git a/src/terminal/adapter/IInteractDispatch.hpp b/src/terminal/adapter/IInteractDispatch.hpp index d8551042a60..a7a936ad58e 100644 --- a/src/terminal/adapter/IInteractDispatch.hpp +++ b/src/terminal/adapter/IInteractDispatch.hpp @@ -35,7 +35,7 @@ namespace Microsoft::Console::VirtualTerminal virtual bool WriteString(const std::wstring_view string) = 0; virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) = 0; + const gsl::span parameters) = 0; virtual bool MoveCursor(const size_t row, const size_t col) = 0; diff --git a/src/terminal/adapter/ITermDispatch.hpp b/src/terminal/adapter/ITermDispatch.hpp index 22cd9725d47..93f1dffeccd 100644 --- a/src/terminal/adapter/ITermDispatch.hpp +++ b/src/terminal/adapter/ITermDispatch.hpp @@ -86,11 +86,11 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch virtual bool EraseInLine(const DispatchTypes::EraseType eraseType) = 0; // EL virtual bool EraseCharacters(const size_t numChars) = 0; // ECH - virtual bool SetGraphicsRendition(const std::basic_string_view options) = 0; // SGR + virtual bool SetGraphicsRendition(const gsl::span options) = 0; // SGR - virtual bool SetPrivateModes(const std::basic_string_view params) = 0; // DECSET + virtual bool SetPrivateModes(const gsl::span params) = 0; // DECSET - virtual bool ResetPrivateModes(const std::basic_string_view params) = 0; // DECRST + virtual bool ResetPrivateModes(const gsl::span params) = 0; // DECRST virtual bool DeviceStatusReport(const DispatchTypes::AnsiStatusType statusType) = 0; // DSR, DSR-OS, DSR-CPR virtual bool DeviceAttributes() = 0; // DA1 @@ -116,7 +116,7 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch // DTTERM_WindowManipulation virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) = 0; + const gsl::span parameters) = 0; }; inline Microsoft::Console::VirtualTerminal::ITermDispatch::~ITermDispatch() {} #pragma warning(pop) diff --git a/src/terminal/adapter/InteractDispatch.cpp b/src/terminal/adapter/InteractDispatch.cpp index 51f176164c9..8a89cba04d7 100644 --- a/src/terminal/adapter/InteractDispatch.cpp +++ b/src/terminal/adapter/InteractDispatch.cpp @@ -96,7 +96,7 @@ bool InteractDispatch::WriteString(const std::wstring_view string) // Return value: // True if handled successfully. False otherwise. bool InteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) + const gsl::span parameters) { bool success = false; // Other Window Manipulation functions: diff --git a/src/terminal/adapter/InteractDispatch.hpp b/src/terminal/adapter/InteractDispatch.hpp index da00c2374c7..c8fa8a02a76 100644 --- a/src/terminal/adapter/InteractDispatch.hpp +++ b/src/terminal/adapter/InteractDispatch.hpp @@ -29,7 +29,7 @@ namespace Microsoft::Console::VirtualTerminal bool WriteCtrlKey(const KeyEvent& event) override; bool WriteString(const std::wstring_view string) override; bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) override; // DTTERM_WindowManipulation + const gsl::span parameters) override; // DTTERM_WindowManipulation bool MoveCursor(const size_t row, const size_t col) override; bool IsVtInputEnabled() const override; diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index e34b8bd2a96..7578e4fbc9a 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -1078,7 +1078,7 @@ bool AdaptDispatch::_PrivateModeParamsHelper(const DispatchTypes::PrivateModePar // - enable - True for set, false for unset. // Return Value: // - True if ALL params were handled successfully. False otherwise. -bool AdaptDispatch::_SetResetPrivateModes(const std::basic_string_view params, const bool enable) +bool AdaptDispatch::_SetResetPrivateModes(const gsl::span params, const bool enable) { // because the user might chain together params we don't support with params we DO support, execute all // params in the sequence, and only return failure if we failed at least one of them @@ -1096,7 +1096,7 @@ bool AdaptDispatch::_SetResetPrivateModes(const std::basic_string_view params) +bool AdaptDispatch::SetPrivateModes(const gsl::span params) { return _SetResetPrivateModes(params, true); } @@ -1107,7 +1107,7 @@ bool AdaptDispatch::SetPrivateModes(const std::basic_string_view params) +bool AdaptDispatch::ResetPrivateModes(const gsl::span params) { return _SetResetPrivateModes(params, false); } @@ -2308,7 +2308,7 @@ bool Microsoft::Console::VirtualTerminal::AdaptDispatch::SetDefaultBackground(co // Return value: // True if handled successfully. False otherwise. bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) + const gsl::span parameters) { bool success = false; // Other Window Manipulation functions: diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index 85621f389eb..12a0c902104 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -55,7 +55,7 @@ namespace Microsoft::Console::VirtualTerminal bool EraseCharacters(const size_t numChars) override; // ECH bool InsertCharacter(const size_t count) override; // ICH bool DeleteCharacter(const size_t count) override; // DCH - bool SetGraphicsRendition(const std::basic_string_view options) override; // SGR + bool SetGraphicsRendition(const gsl::span options) override; // SGR bool DeviceStatusReport(const DispatchTypes::AnsiStatusType statusType) override; // DSR, DSR-OS, DSR-CPR bool DeviceAttributes() override; // DA1 bool SecondaryDeviceAttributes() override; // DA2 @@ -66,8 +66,8 @@ namespace Microsoft::Console::VirtualTerminal bool InsertLine(const size_t distance) override; // IL bool DeleteLine(const size_t distance) override; // DL bool SetColumns(const size_t columns) override; // DECCOLM - bool SetPrivateModes(const std::basic_string_view params) override; // DECSET - bool ResetPrivateModes(const std::basic_string_view params) override; // DECRST + bool SetPrivateModes(const gsl::span params) override; // DECSET + bool ResetPrivateModes(const gsl::span params) override; // DECRST bool SetCursorKeysMode(const bool applicationMode) override; // DECCKM bool SetKeypadMode(const bool applicationMode) override; // DECKPAM, DECKPNM bool EnableWin32InputMode(const bool win32InputMode) override; // win32-input-mode @@ -116,7 +116,7 @@ namespace Microsoft::Console::VirtualTerminal bool SetDefaultBackground(const DWORD color) override; // OSCDefaultBackground bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) override; // DTTERM_WindowManipulation + const gsl::span parameters) override; // DTTERM_WindowManipulation private: enum class ScrollDirection @@ -159,7 +159,7 @@ namespace Microsoft::Console::VirtualTerminal bool _CursorPositionReport() const; bool _WriteResponse(const std::wstring_view reply) const; - bool _SetResetPrivateModes(const std::basic_string_view params, const bool enable); + bool _SetResetPrivateModes(const gsl::span params, const bool enable); bool _PrivateModeParamsHelper(const DispatchTypes::PrivateModeParams param, const bool enable); bool _DoDECCOLMHelper(const size_t columns); @@ -192,7 +192,7 @@ namespace Microsoft::Console::VirtualTerminal bool _isDECCOLMAllowed; - size_t _SetRgbColorsHelper(const std::basic_string_view options, + size_t _SetRgbColorsHelper(const gsl::span options, TextAttribute& attr, const bool isForeground) noexcept; }; diff --git a/src/terminal/adapter/adaptDispatchGraphics.cpp b/src/terminal/adapter/adaptDispatchGraphics.cpp index 9216eeebe08..ada5924cc8e 100644 --- a/src/terminal/adapter/adaptDispatchGraphics.cpp +++ b/src/terminal/adapter/adaptDispatchGraphics.cpp @@ -47,7 +47,7 @@ const BYTE BRIGHT_WHITE = BRIGHT_ATTR | RED_ATTR | GREEN_ATTR | BLUE_ATTR; // - isForeground - Whether or not the parsed color is for the foreground. // Return Value: // - The number of options consumed, not including the initial 38/48. -size_t AdaptDispatch::_SetRgbColorsHelper(const std::basic_string_view options, +size_t AdaptDispatch::_SetRgbColorsHelper(const gsl::span options, TextAttribute& attr, const bool isForeground) noexcept { @@ -100,7 +100,7 @@ size_t AdaptDispatch::_SetRgbColorsHelper(const std::basic_string_view options) +bool AdaptDispatch::SetGraphicsRendition(const gsl::span options) { TextAttribute attr; bool success = _pConApi->PrivateGetTextAttributes(attr); @@ -273,10 +273,10 @@ bool AdaptDispatch::SetGraphicsRendition(const std::basic_string_view /*options*/) noexcept override { return false; } // SGR + bool SetGraphicsRendition(const gsl::span /*options*/) noexcept override { return false; } // SGR - bool SetPrivateModes(const std::basic_string_view /*params*/) noexcept override { return false; } // DECSET + bool SetPrivateModes(const gsl::span /*params*/) noexcept override { return false; } // DECSET - bool ResetPrivateModes(const std::basic_string_view /*params*/) noexcept override { return false; } // DECRST + bool ResetPrivateModes(const gsl::span /*params*/) noexcept override { return false; } // DECRST bool DeviceStatusReport(const DispatchTypes::AnsiStatusType /*statusType*/) noexcept override { return false; } // DSR, DSR-OS, DSR-CPR bool DeviceAttributes() noexcept override { return false; } // DA1 @@ -110,5 +110,5 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons // DTTERM_WindowManipulation bool WindowManipulation(const DispatchTypes::WindowManipulationType /*function*/, - const std::basic_string_view /*params*/) noexcept override { return false; } + const gsl::span /*params*/) noexcept override { return false; } }; diff --git a/src/terminal/input/terminalInput.cpp b/src/terminal/input/terminalInput.cpp index 7ebabde1a6c..54a99a925cd 100644 --- a/src/terminal/input/terminalInput.cpp +++ b/src/terminal/input/terminalInput.cpp @@ -276,10 +276,10 @@ void TerminalInput::ForceDisableWin32InputMode(const bool win32InputMode) noexce _forceDisableWin32InputMode = win32InputMode; } -static const std::basic_string_view _getKeyMapping(const KeyEvent& keyEvent, - const bool ansiMode, - const bool cursorApplicationMode, - const bool keypadApplicationMode) noexcept +static const gsl::span _getKeyMapping(const KeyEvent& keyEvent, + const bool ansiMode, + const bool cursorApplicationMode, + const bool keypadApplicationMode) noexcept { if (ansiMode) { @@ -327,7 +327,7 @@ static const std::basic_string_view _getKeyMapping(const KeyEvent& k // Return Value: // - Has value if there was a match to a key translation. static std::optional _searchKeyMapping(const KeyEvent& keyEvent, - std::basic_string_view keyMapping) noexcept + gsl::span keyMapping) noexcept { for (auto& map : keyMapping) { @@ -490,7 +490,7 @@ static bool _searchWithModifier(const KeyEvent& keyEvent, InputSender sender) // Return Value: // - True if there was a match to a key translation, and we successfully sent it to the input static bool _translateDefaultMapping(const KeyEvent& keyEvent, - const std::basic_string_view keyMapping, + const gsl::span keyMapping, InputSender sender) { const auto match = _searchKeyMapping(keyEvent, keyMapping); diff --git a/src/terminal/parser/IStateMachineEngine.hpp b/src/terminal/parser/IStateMachineEngine.hpp index 9b024438d63..c1a668fb72c 100644 --- a/src/terminal/parser/IStateMachineEngine.hpp +++ b/src/terminal/parser/IStateMachineEngine.hpp @@ -31,13 +31,13 @@ namespace Microsoft::Console::VirtualTerminal virtual bool ActionPassThroughString(const std::wstring_view string) = 0; virtual bool ActionEscDispatch(const wchar_t wch, - const std::basic_string_view intermediates) = 0; + const gsl::span intermediates) = 0; virtual bool ActionVt52EscDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) = 0; + const gsl::span intermediates, + const gsl::span parameters) = 0; virtual bool ActionCsiDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) = 0; + const gsl::span intermediates, + const gsl::span parameters) = 0; virtual bool ActionClear() = 0; @@ -48,7 +48,7 @@ namespace Microsoft::Console::VirtualTerminal const std::wstring_view string) = 0; virtual bool ActionSs3Dispatch(const wchar_t wch, - const std::basic_string_view parameters) = 0; + const gsl::span parameters) = 0; virtual bool ParseControlSequenceAfterSs3() const = 0; virtual bool FlushAtEndOfString() const = 0; diff --git a/src/terminal/parser/InputStateMachineEngine.cpp b/src/terminal/parser/InputStateMachineEngine.cpp index c364f95654f..59f34e20ab9 100644 --- a/src/terminal/parser/InputStateMachineEngine.cpp +++ b/src/terminal/parser/InputStateMachineEngine.cpp @@ -303,7 +303,7 @@ bool InputStateMachineEngine::ActionPassThroughString(const std::wstring_view st // Return Value: // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionEscDispatch(const wchar_t wch, - const std::basic_string_view /*intermediates*/) + const gsl::span /*intermediates*/) { if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue) { @@ -345,8 +345,8 @@ bool InputStateMachineEngine::ActionEscDispatch(const wchar_t wch, // Return Value: // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionVt52EscDispatch(const wchar_t /*wch*/, - const std::basic_string_view /*intermediates*/, - const std::basic_string_view /*parameters*/) noexcept + const gsl::span /*intermediates*/, + const gsl::span /*parameters*/) noexcept { // VT52 escape sequences are not used in the input state machine. return false; @@ -363,8 +363,8 @@ bool InputStateMachineEngine::ActionVt52EscDispatch(const wchar_t /*wch*/, // Return Value: // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) + const gsl::span intermediates, + const gsl::span parameters) { const auto actionCode = static_cast(wch); @@ -389,13 +389,13 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, KeyEvent key; // This is all the args after the first arg, and the count of args not including the first one. - const auto remainingArgs = parameters.size() > 1 ? parameters.substr(1) : std::basic_string_view{}; + const auto remainingArgs = parameters.size() > 1 ? parameters.subspan(1) : gsl::span{}; bool success = false; // Handle intermediate characters, if any if (!intermediates.empty()) { - switch (static_cast(intermediates.at(0))) + switch (static_cast(til::at(intermediates, 0))) { case CsiIntermediateCodes::MOUSE_SGR: { @@ -522,7 +522,7 @@ bool InputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, // Return Value: // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionSs3Dispatch(const wchar_t wch, - const std::basic_string_view /*parameters*/) + const gsl::span /*parameters*/) { if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue) { @@ -800,12 +800,12 @@ bool InputStateMachineEngine::_WriteMouseEvent(const size_t column, const size_t // - actionCode - the actionCode for the sequence we're operating on. // Return Value: // - the INPUT_RECORD compatible modifier state. -DWORD InputStateMachineEngine::_GetCursorKeysModifierState(const std::basic_string_view parameters, const CsiActionCodes actionCode) noexcept +DWORD InputStateMachineEngine::_GetCursorKeysModifierState(const gsl::span parameters, const CsiActionCodes actionCode) noexcept { DWORD modifiers = 0; if (_IsModified(parameters.size()) && parameters.size() >= 2) { - modifiers = _GetModifier(parameters.at(1)); + modifiers = _GetModifier(til::at(parameters, 1)); } // Enhanced Keys (from https://docs.microsoft.com/en-us/windows/console/key-event-record-str): @@ -829,12 +829,12 @@ DWORD InputStateMachineEngine::_GetCursorKeysModifierState(const std::basic_stri // - parameters - the set of parameters to get the modifier state from. // Return Value: // - the INPUT_RECORD compatible modifier state. -DWORD InputStateMachineEngine::_GetGenericKeysModifierState(const std::basic_string_view parameters) noexcept +DWORD InputStateMachineEngine::_GetGenericKeysModifierState(const gsl::span parameters) noexcept { DWORD modifiers = 0; if (_IsModified(parameters.size()) && parameters.size() >= 2) { - modifiers = _GetModifier(parameters.at(1)); + modifiers = _GetModifier(til::at(parameters, 1)); } // Enhanced Keys (from https://docs.microsoft.com/en-us/windows/console/key-event-record-str): @@ -858,7 +858,7 @@ DWORD InputStateMachineEngine::_GetGenericKeysModifierState(const std::basic_str // - parameters - the set of parameters to get the modifier state from. // Return Value: // - the INPUT_RECORD compatible modifier state. -DWORD InputStateMachineEngine::_GetSGRMouseModifierState(const std::basic_string_view parameters) noexcept +DWORD InputStateMachineEngine::_GetSGRMouseModifierState(const gsl::span parameters) noexcept { DWORD modifiers = 0; if (parameters.size() == 3) @@ -922,7 +922,7 @@ DWORD InputStateMachineEngine::_GetModifier(const size_t modifierParam) noexcept // Return Value: // true iff we were able to synthesize buttonState bool InputStateMachineEngine::_UpdateSGRMouseButtonState(const wchar_t wch, - const std::basic_string_view parameters, + const gsl::span parameters, DWORD& buttonState, DWORD& eventFlags) noexcept { @@ -1024,7 +1024,7 @@ bool InputStateMachineEngine::_UpdateSGRMouseButtonState(const wchar_t wch, // - vkey: Receives the vkey // Return Value: // true iff we found the key -bool InputStateMachineEngine::_GetGenericVkey(const std::basic_string_view parameters, short& vkey) const +bool InputStateMachineEngine::_GetGenericVkey(const gsl::span parameters, short& vkey) const { vkey = 0; if (parameters.empty()) @@ -1200,7 +1200,7 @@ void InputStateMachineEngine::SetFlushToInputQueueCallback(std::function // - function - Receives the function type // Return Value: // - True iff we successfully pulled the function type from the parameters -bool InputStateMachineEngine::_GetWindowManipulationType(const std::basic_string_view parameters, +bool InputStateMachineEngine::_GetWindowManipulationType(const gsl::span parameters, unsigned int& function) const noexcept { bool success = false; @@ -1234,7 +1234,7 @@ bool InputStateMachineEngine::_GetWindowManipulationType(const std::basic_string // - column - Receives the X/Column position // Return Value: // - True if we successfully pulled the cursor coordinates from the parameters we've stored. False otherwise. -bool InputStateMachineEngine::_GetXYPosition(const std::basic_string_view parameters, +bool InputStateMachineEngine::_GetXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept { @@ -1283,7 +1283,7 @@ bool InputStateMachineEngine::_GetXYPosition(const std::basic_string_view parameters, +bool InputStateMachineEngine::_GetSGRXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept { @@ -1322,7 +1322,7 @@ bool InputStateMachineEngine::_GetSGRXYPosition(const std::basic_string_view parameters, +bool InputStateMachineEngine::_GenerateWin32Key(const gsl::span parameters, KeyEvent& key) { // Sequences are formatted as follows: @@ -1347,22 +1347,22 @@ bool InputStateMachineEngine::_GenerateWin32Key(const std::basic_string_view(parameters.at(5))); + key.SetRepeatCount(::base::saturated_cast(til::at(parameters, 5))); [[fallthrough]]; case 5: - key.SetActiveModifierKeys(::base::saturated_cast(parameters.at(4))); + key.SetActiveModifierKeys(::base::saturated_cast(til::at(parameters, 4))); [[fallthrough]]; case 4: - key.SetKeyDown(static_cast(parameters.at(3))); + key.SetKeyDown(static_cast(til::at(parameters, 3))); [[fallthrough]]; case 3: - key.SetCharData(static_cast(parameters.at(2))); + key.SetCharData(static_cast(til::at(parameters, 2))); [[fallthrough]]; case 2: - key.SetVirtualScanCode(::base::saturated_cast(parameters.at(1))); + key.SetVirtualScanCode(::base::saturated_cast(til::at(parameters, 1))); [[fallthrough]]; case 1: - key.SetVirtualKeyCode(::base::saturated_cast(parameters.at(0))); + key.SetVirtualKeyCode(::base::saturated_cast(til::at(parameters, 0))); break; } diff --git a/src/terminal/parser/InputStateMachineEngine.hpp b/src/terminal/parser/InputStateMachineEngine.hpp index 922b3623613..14f6cedc188 100644 --- a/src/terminal/parser/InputStateMachineEngine.hpp +++ b/src/terminal/parser/InputStateMachineEngine.hpp @@ -146,15 +146,15 @@ namespace Microsoft::Console::VirtualTerminal bool ActionPassThroughString(const std::wstring_view string) override; bool ActionEscDispatch(const wchar_t wch, - const std::basic_string_view intermediates) override; + const gsl::span intermediates) override; bool ActionVt52EscDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) noexcept override; + const gsl::span intermediates, + const gsl::span parameters) noexcept override; bool ActionCsiDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) override; + const gsl::span intermediates, + const gsl::span parameters) override; bool ActionClear() noexcept override; @@ -165,7 +165,7 @@ namespace Microsoft::Console::VirtualTerminal const std::wstring_view string) noexcept override; bool ActionSs3Dispatch(const wchar_t wch, - const std::basic_string_view parameters) override; + const gsl::span parameters) override; bool ParseControlSequenceAfterSs3() const noexcept override; bool FlushAtEndOfString() const noexcept override; @@ -180,19 +180,19 @@ namespace Microsoft::Console::VirtualTerminal bool _lookingForDSR; DWORD _mouseButtonState = 0; - DWORD _GetCursorKeysModifierState(const std::basic_string_view parameters, const CsiActionCodes actionCode) noexcept; - DWORD _GetGenericKeysModifierState(const std::basic_string_view parameters) noexcept; - DWORD _GetSGRMouseModifierState(const std::basic_string_view parameters) noexcept; + DWORD _GetCursorKeysModifierState(const gsl::span parameters, const CsiActionCodes actionCode) noexcept; + DWORD _GetGenericKeysModifierState(const gsl::span parameters) noexcept; + DWORD _GetSGRMouseModifierState(const gsl::span parameters) noexcept; bool _GenerateKeyFromChar(const wchar_t wch, short& vkey, DWORD& modifierState) noexcept; bool _IsModified(const size_t paramCount) noexcept; DWORD _GetModifier(const size_t parameter) noexcept; bool _UpdateSGRMouseButtonState(const wchar_t wch, - const std::basic_string_view parameters, + const gsl::span parameters, DWORD& buttonState, DWORD& eventFlags) noexcept; - bool _GetGenericVkey(const std::basic_string_view parameters, + bool _GetGenericVkey(const gsl::span parameters, short& vkey) const; bool _GetCursorKeysVkey(const wchar_t wch, short& vkey) const; bool _GetSs3KeysVkey(const wchar_t wch, short& vkey) const; @@ -212,17 +212,17 @@ namespace Microsoft::Console::VirtualTerminal const DWORD modifierState, std::vector& input); - bool _GetWindowManipulationType(const std::basic_string_view parameters, + bool _GetWindowManipulationType(const gsl::span parameters, unsigned int& function) const noexcept; - bool _GenerateWin32Key(const std::basic_string_view parameters, KeyEvent& key); + bool _GenerateWin32Key(const gsl::span parameters, KeyEvent& key); static constexpr size_t DefaultLine = 1; static constexpr size_t DefaultColumn = 1; - bool _GetXYPosition(const std::basic_string_view parameters, + bool _GetXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept; - bool _GetSGRXYPosition(const std::basic_string_view parameters, + bool _GetSGRXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept; diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp index 584548199cf..4d5b4d0c8ac 100644 --- a/src/terminal/parser/OutputStateMachineEngine.cpp +++ b/src/terminal/parser/OutputStateMachineEngine.cpp @@ -184,7 +184,7 @@ bool OutputStateMachineEngine::ActionPassThroughString(const std::wstring_view s // Return Value: // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionEscDispatch(const wchar_t wch, - const std::basic_string_view intermediates) + const gsl::span intermediates) { bool success = false; @@ -317,8 +317,8 @@ bool OutputStateMachineEngine::ActionEscDispatch(const wchar_t wch, // Return Value: // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionVt52EscDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) + const gsl::span intermediates, + const gsl::span parameters) { bool success = false; @@ -360,7 +360,7 @@ bool OutputStateMachineEngine::ActionVt52EscDispatch(const wchar_t wch, case Vt52ActionCodes::DirectCursorAddress: // VT52 cursor addresses are provided as ASCII characters, with // the lowest value being a space, representing an address of 1. - success = _dispatch->CursorPosition(parameters.at(0) - ' ' + 1, parameters.at(1) - ' ' + 1); + success = _dispatch->CursorPosition(gsl::at(parameters, 0) - ' ' + 1, gsl::at(parameters, 1) - ' ' + 1); break; case Vt52ActionCodes::Identify: success = _dispatch->Vt52DeviceAttributes(); @@ -397,15 +397,15 @@ bool OutputStateMachineEngine::ActionVt52EscDispatch(const wchar_t wch, // Return Value: // - True if handled successfully. False otherwise. bool OutputStateMachineEngine::_IntermediateScsDispatch(const wchar_t wch, - const std::basic_string_view intermediates) + const gsl::span intermediates) { bool success = false; // If we have more than one intermediate, the second intermediate forms part of // the charset identifier. Otherwise it's identified by just the final character. - const auto charset = intermediates.size() > 1 ? std::make_pair(intermediates.at(1), wch) : std::make_pair(wch, L'\0'); + const auto charset = intermediates.size() > 1 ? std::make_pair(til::at(intermediates, 1), wch) : std::make_pair(wch, L'\0'); - switch (intermediates.at(0)) + switch (til::at(intermediates, 0)) { case L'(': success = _dispatch->Designate94Charset(0, charset); @@ -451,8 +451,8 @@ bool OutputStateMachineEngine::_IntermediateScsDispatch(const wchar_t wch, // Return Value: // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - std::basic_string_view parameters) + const gsl::span intermediates, + gsl::span parameters) { bool success = false; size_t distance = 0; @@ -470,7 +470,7 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, DispatchTypes::AnsiStatusType deviceStatusType = static_cast(0); // there is no default status type. size_t repeatCount = 0; // This is all the args after the first arg, and the count of args not including the first one. - const auto remainingParams = parameters.size() > 1 ? parameters.substr(1) : std::basic_string_view{}; + const auto remainingParams = parameters.size() > 1 ? parameters.subspan(1) : gsl::span{}; if (intermediates.empty()) { @@ -737,7 +737,7 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const wchar_t wch, // Return Value: // - True if handled successfully. False otherwise. bool OutputStateMachineEngine::_IntermediateQuestionMarkDispatch(const wchar_t wchAction, - const std::basic_string_view parameters) + const gsl::span parameters) { bool success = false; @@ -787,7 +787,7 @@ bool OutputStateMachineEngine::_IntermediateQuestionMarkDispatch(const wchar_t w // - True if handled successfully. False otherwise. bool OutputStateMachineEngine::_IntermediateGreaterThanOrEqualDispatch(const wchar_t wch, const wchar_t intermediate, - const std::basic_string_view parameters) + const gsl::span parameters) { bool success = false; @@ -846,7 +846,7 @@ bool OutputStateMachineEngine::_IntermediateExclamationDispatch(const wchar_t wc // Return Value: // - True if handled successfully. False otherwise. bool OutputStateMachineEngine::_IntermediateSpaceDispatch(const wchar_t wchAction, - const std::basic_string_view parameters) + const gsl::span parameters) { bool success = false; DispatchTypes::CursorStyle cursorStyle = DefaultCursorStyle; @@ -1022,7 +1022,7 @@ bool OutputStateMachineEngine::ActionOscDispatch(const wchar_t /*wch*/, // Return Value: // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionSs3Dispatch(const wchar_t /*wch*/, - const std::basic_string_view /*parameters*/) noexcept + const gsl::span /*parameters*/) noexcept { // The output engine doesn't handle any SS3 sequences. _ClearLastChar(); @@ -1036,7 +1036,7 @@ bool OutputStateMachineEngine::ActionSs3Dispatch(const wchar_t /*wch*/, // - options - Space that will be filled with valid options from the GraphicsOptions enum // Return Value: // - True if we successfully retrieved an array of valid graphics options from the parameters we've stored. False otherwise. -bool OutputStateMachineEngine::_GetGraphicsOptions(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetGraphicsOptions(const gsl::span parameters, std::vector& options) const { bool success = false; @@ -1072,7 +1072,7 @@ bool OutputStateMachineEngine::_GetGraphicsOptions(const std::basic_string_view< // - eraseType - Receives the erase type parameter // Return Value: // - True if we successfully pulled an erase type from the parameters we've stored. False otherwise. -bool OutputStateMachineEngine::_GetEraseOperation(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetEraseOperation(const gsl::span parameters, DispatchTypes::EraseType& eraseType) const noexcept { bool success = false; // If we have too many parameters or don't know what to do with the given value, return false. @@ -1111,7 +1111,7 @@ bool OutputStateMachineEngine::_GetEraseOperation(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetCursorDistance(const gsl::span parameters, size_t& distance) const noexcept { bool success = false; @@ -1145,7 +1145,7 @@ bool OutputStateMachineEngine::_GetCursorDistance(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetScrollDistance(const gsl::span parameters, size_t& distance) const noexcept { bool success = false; @@ -1179,7 +1179,7 @@ bool OutputStateMachineEngine::_GetScrollDistance(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetConsoleWidth(const gsl::span parameters, size_t& consoleWidth) const noexcept { bool success = false; @@ -1214,7 +1214,7 @@ bool OutputStateMachineEngine::_GetConsoleWidth(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept { @@ -1263,7 +1263,7 @@ bool OutputStateMachineEngine::_GetXYPosition(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetTopBottomMargins(const gsl::span parameters, size_t& topMargin, size_t& bottomMargin) const noexcept { @@ -1308,7 +1308,7 @@ bool OutputStateMachineEngine::_GetTopBottomMargins(const std::basic_string_view // - statusType - Receives the Status Type parameter // Return Value: // - True if we successfully found a device operation in the parameters stored. False otherwise. -bool OutputStateMachineEngine::_GetDeviceStatusOperation(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetDeviceStatusOperation(const gsl::span parameters, DispatchTypes::AnsiStatusType& statusType) const noexcept { bool success = false; @@ -1343,7 +1343,7 @@ bool OutputStateMachineEngine::_GetDeviceStatusOperation(const std::basic_string // - privateModes - Space that will be filled with valid params from the PrivateModeParams enum // Return Value: // - True if we successfully retrieved an array of private mode params from the parameters we've stored. False otherwise. -bool OutputStateMachineEngine::_GetPrivateModeParams(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetPrivateModeParams(const gsl::span parameters, std::vector& privateModes) const { bool success = false; @@ -1364,7 +1364,7 @@ bool OutputStateMachineEngine::_GetPrivateModeParams(const std::basic_string_vie // - parameters - The parameters to parse // Return Value: // - True if there were no parameters. False otherwise. -bool OutputStateMachineEngine::_VerifyHasNoParameters(const std::basic_string_view parameters) const noexcept +bool OutputStateMachineEngine::_VerifyHasNoParameters(const gsl::span parameters) const noexcept { return parameters.empty(); } @@ -1376,7 +1376,7 @@ bool OutputStateMachineEngine::_VerifyHasNoParameters(const std::basic_string_vi // - parameters - The parameters to parse // Return Value: // - True if the DA params were valid. False otherwise. -bool OutputStateMachineEngine::_VerifyDeviceAttributesParams(const std::basic_string_view parameters) const noexcept +bool OutputStateMachineEngine::_VerifyDeviceAttributesParams(const gsl::span parameters) const noexcept { bool success = false; @@ -1417,7 +1417,7 @@ bool OutputStateMachineEngine::_GetOscTitle(const std::wstring_view string, // - distance - Receives the distance // Return Value: // - True if we successfully pulled the tab distance from the parameters we've stored. False otherwise. -bool OutputStateMachineEngine::_GetTabDistance(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetTabDistance(const gsl::span parameters, size_t& distance) const noexcept { bool success = false; @@ -1451,7 +1451,7 @@ bool OutputStateMachineEngine::_GetTabDistance(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetTabClearType(const gsl::span parameters, size_t& clearType) const noexcept { bool success = false; @@ -1628,7 +1628,7 @@ bool OutputStateMachineEngine::s_ParseColorSpec(const std::wstring_view string, for (size_t component = 0; component < 3; component++) { bool foundColor = false; - auto& value = colorValues.at(component); + auto& value = til::at(colorValues, component); for (size_t i = 0; i < 3; i++) { const wchar_t wch = *curr++; @@ -1803,7 +1803,7 @@ bool OutputStateMachineEngine::_GetOscSetColor(const std::wstring_view string, // - function - Receives the function type // Return Value: // - True iff we successfully pulled the function type from the parameters -bool OutputStateMachineEngine::_GetWindowManipulationType(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetWindowManipulationType(const gsl::span parameters, unsigned int& function) const noexcept { bool success = false; @@ -1837,7 +1837,7 @@ bool OutputStateMachineEngine::_GetWindowManipulationType(const std::basic_strin // - cursorStyle - Receives the cursorStyle // Return Value: // - True if we successfully pulled the cursor style from the parameters we've stored. False otherwise. -bool OutputStateMachineEngine::_GetCursorStyle(const std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetCursorStyle(const gsl::span parameters, DispatchTypes::CursorStyle& cursorStyle) const noexcept { bool success = false; @@ -1886,7 +1886,7 @@ void OutputStateMachineEngine::SetTerminalConnection(ITerminalOutputConnection* // Return Value: // - True if we successfully pulled the repeat count from the parameters. // False otherwise. -bool OutputStateMachineEngine::_GetRepeatCount(std::basic_string_view parameters, +bool OutputStateMachineEngine::_GetRepeatCount(gsl::span parameters, size_t& repeatCount) const noexcept { bool success = false; diff --git a/src/terminal/parser/OutputStateMachineEngine.hpp b/src/terminal/parser/OutputStateMachineEngine.hpp index 924239289a6..bce98255e0e 100644 --- a/src/terminal/parser/OutputStateMachineEngine.hpp +++ b/src/terminal/parser/OutputStateMachineEngine.hpp @@ -34,15 +34,15 @@ namespace Microsoft::Console::VirtualTerminal bool ActionPassThroughString(const std::wstring_view string) override; bool ActionEscDispatch(const wchar_t wch, - const std::basic_string_view intermediates) override; + const gsl::span intermediates) override; bool ActionVt52EscDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) override; + const gsl::span intermediates, + const gsl::span parameters) override; bool ActionCsiDispatch(const wchar_t wch, - const std::basic_string_view intermediates, - const std::basic_string_view parameters) override; + const gsl::span intermediates, + const gsl::span parameters) override; bool ActionClear() noexcept override; @@ -53,7 +53,7 @@ namespace Microsoft::Console::VirtualTerminal const std::wstring_view string) override; bool ActionSs3Dispatch(const wchar_t wch, - const std::basic_string_view parameters) noexcept override; + const gsl::span parameters) noexcept override; bool ParseControlSequenceAfterSs3() const noexcept override; bool FlushAtEndOfString() const noexcept override; @@ -74,15 +74,15 @@ namespace Microsoft::Console::VirtualTerminal std::vector _graphicsOptions; bool _IntermediateScsDispatch(const wchar_t wch, - const std::basic_string_view intermediates); + const gsl::span intermediates); bool _IntermediateQuestionMarkDispatch(const wchar_t wchAction, - const std::basic_string_view parameters); + const gsl::span parameters); bool _IntermediateGreaterThanOrEqualDispatch(const wchar_t wch, const wchar_t intermediate, - const std::basic_string_view parameters); + const gsl::span parameters); bool _IntermediateExclamationDispatch(const wchar_t wch); bool _IntermediateSpaceDispatch(const wchar_t wchAction, - const std::basic_string_view parameters); + const gsl::span parameters); enum VTActionCodes : wchar_t { @@ -180,44 +180,44 @@ namespace Microsoft::Console::VirtualTerminal }; static constexpr DispatchTypes::GraphicsOptions DefaultGraphicsOption = DispatchTypes::GraphicsOptions::Off; - bool _GetGraphicsOptions(const std::basic_string_view parameters, + bool _GetGraphicsOptions(const gsl::span parameters, std::vector& options) const; static constexpr DispatchTypes::EraseType DefaultEraseType = DispatchTypes::EraseType::ToEnd; - bool _GetEraseOperation(const std::basic_string_view parameters, + bool _GetEraseOperation(const gsl::span parameters, DispatchTypes::EraseType& eraseType) const noexcept; static constexpr size_t DefaultCursorDistance = 1; - bool _GetCursorDistance(const std::basic_string_view parameters, + bool _GetCursorDistance(const gsl::span parameters, size_t& distance) const noexcept; static constexpr size_t DefaultScrollDistance = 1; - bool _GetScrollDistance(const std::basic_string_view parameters, + bool _GetScrollDistance(const gsl::span parameters, size_t& distance) const noexcept; static constexpr size_t DefaultConsoleWidth = 80; - bool _GetConsoleWidth(const std::basic_string_view parameters, + bool _GetConsoleWidth(const gsl::span parameters, size_t& consoleWidth) const noexcept; static constexpr size_t DefaultLine = 1; static constexpr size_t DefaultColumn = 1; - bool _GetXYPosition(const std::basic_string_view parameters, + bool _GetXYPosition(const gsl::span parameters, size_t& line, size_t& column) const noexcept; - bool _GetDeviceStatusOperation(const std::basic_string_view parameters, + bool _GetDeviceStatusOperation(const gsl::span parameters, DispatchTypes::AnsiStatusType& statusType) const noexcept; - bool _VerifyHasNoParameters(const std::basic_string_view parameters) const noexcept; + bool _VerifyHasNoParameters(const gsl::span parameters) const noexcept; - bool _VerifyDeviceAttributesParams(const std::basic_string_view parameters) const noexcept; + bool _VerifyDeviceAttributesParams(const gsl::span parameters) const noexcept; - bool _GetPrivateModeParams(const std::basic_string_view parameters, + bool _GetPrivateModeParams(const gsl::span parameters, std::vector& privateModes) const; static constexpr size_t DefaultTopMargin = 0; static constexpr size_t DefaultBottomMargin = 0; - bool _GetTopBottomMargins(const std::basic_string_view parameters, + bool _GetTopBottomMargins(const gsl::span parameters, size_t& topMargin, size_t& bottomMargin) const noexcept; @@ -225,15 +225,15 @@ namespace Microsoft::Console::VirtualTerminal std::wstring& title) const; static constexpr size_t DefaultTabDistance = 1; - bool _GetTabDistance(const std::basic_string_view parameters, + bool _GetTabDistance(const gsl::span parameters, size_t& distance) const noexcept; static constexpr size_t DefaultTabClearType = 0; - bool _GetTabClearType(const std::basic_string_view parameters, + bool _GetTabClearType(const gsl::span parameters, size_t& clearType) const noexcept; static constexpr DispatchTypes::WindowManipulationType DefaultWindowManipulationType = DispatchTypes::WindowManipulationType::Invalid; - bool _GetWindowManipulationType(const std::basic_string_view parameters, + bool _GetWindowManipulationType(const gsl::span parameters, unsigned int& function) const noexcept; static bool s_HexToUint(const wchar_t wch, @@ -249,11 +249,11 @@ namespace Microsoft::Console::VirtualTerminal DWORD& rgb) const noexcept; static constexpr DispatchTypes::CursorStyle DefaultCursorStyle = DispatchTypes::CursorStyle::BlinkingBlockDefault; - bool _GetCursorStyle(const std::basic_string_view parameters, + bool _GetCursorStyle(const gsl::span parameters, DispatchTypes::CursorStyle& cursorStyle) const noexcept; static constexpr size_t DefaultRepeatCount = 1; - bool _GetRepeatCount(const std::basic_string_view parameters, + bool _GetRepeatCount(const gsl::span parameters, size_t& repeatCount) const noexcept; bool _GetOscSetClipboard(const std::wstring_view string, diff --git a/src/terminal/parser/ut_parser/InputEngineTest.cpp b/src/terminal/parser/ut_parser/InputEngineTest.cpp index b631dfa4a62..b97fa263c1c 100644 --- a/src/terminal/parser/ut_parser/InputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/InputEngineTest.cpp @@ -327,7 +327,7 @@ class Microsoft::Console::VirtualTerminal::TestInteractDispatch final : public I virtual bool WriteCtrlKey(const KeyEvent& event) override; virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) override; // DTTERM_WindowManipulation + const gsl::span parameters) override; // DTTERM_WindowManipulation virtual bool WriteString(const std::wstring_view string) override; virtual bool MoveCursor(const size_t row, @@ -362,14 +362,14 @@ bool TestInteractDispatch::WriteCtrlKey(const KeyEvent& event) } bool TestInteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, - const std::basic_string_view parameters) + const gsl::span parameters) { VERIFY_ARE_EQUAL(true, _testState->_expectedToCallWindowManipulation); VERIFY_ARE_EQUAL(_testState->_expectedWindowManipulation, function); for (size_t i = 0; i < parameters.size(); i++) { unsigned short actual; - VERIFY_SUCCEEDED(SizeTToUShort(parameters.at(i), &actual)); + VERIFY_SUCCEEDED(SizeTToUShort(til::at(parameters, i), &actual)); VERIFY_ARE_EQUAL(_testState->_expectedParams[i], actual); } return true; diff --git a/src/terminal/parser/ut_parser/OutputEngineTest.cpp b/src/terminal/parser/ut_parser/OutputEngineTest.cpp index 9ad20cddb35..17caebefada 100644 --- a/src/terminal/parser/ut_parser/OutputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/OutputEngineTest.cpp @@ -748,10 +748,10 @@ class StatefulDispatch final : public TermDispatch return true; } - bool SetGraphicsRendition(const std::basic_string_view options) noexcept override + bool SetGraphicsRendition(const gsl::span options) noexcept override try { - _options.assign(options.cbegin(), options.cend()); + _options.assign(options.begin(), options.end()); _setGraphics = true; return true; } @@ -841,7 +841,7 @@ class StatefulDispatch final : public TermDispatch return fSuccess; } - bool _SetResetPrivateModesHelper(const std::basic_string_view params, + bool _SetResetPrivateModesHelper(const gsl::span params, const bool enable) { size_t cFailures = 0; @@ -852,12 +852,12 @@ class StatefulDispatch final : public TermDispatch return cFailures == 0; } - bool SetPrivateModes(const std::basic_string_view params) noexcept override + bool SetPrivateModes(const gsl::span params) noexcept override { return _SetResetPrivateModesHelper(params, true); } - bool ResetPrivateModes(const std::basic_string_view params) noexcept override + bool ResetPrivateModes(const gsl::span params) noexcept override { return _SetResetPrivateModesHelper(params, false); } @@ -1545,7 +1545,7 @@ class StateMachineExternalTest final VERIFY_ARE_EQUAL(expectedDispatchTypes, pDispatch->_eraseType); } - void VerifyDispatchTypes(const std::basic_string_view expectedOptions, + void VerifyDispatchTypes(const gsl::span expectedOptions, const StatefulDispatch& dispatch) { VERIFY_ARE_EQUAL(expectedOptions.size(), dispatch._options.size()); @@ -1557,14 +1557,14 @@ class StateMachineExternalTest final if (i < expectedOptions.size()) { - expectedOption = expectedOptions.at(i); + expectedOption = til::at(expectedOptions, i); } - optionsValid = expectedOption == dispatch._options.at(i); + optionsValid = expectedOption == til::at(dispatch._options, i); if (!optionsValid) { - Log::Comment(NoThrowString().Format(L"Graphics option match failed, index [%zu]. Expected: '%d' Actual: '%d'", i, expectedOption, dispatch._options.at(i))); + Log::Comment(NoThrowString().Format(L"Graphics option match failed, index [%zu]. Expected: '%d' Actual: '%d'", i, expectedOption, til::at(dispatch._options, i))); break; } } diff --git a/src/terminal/parser/ut_parser/StateMachineTest.cpp b/src/terminal/parser/ut_parser/StateMachineTest.cpp index d82a46b87d6..74e29ea72af 100644 --- a/src/terminal/parser/ut_parser/StateMachineTest.cpp +++ b/src/terminal/parser/ut_parser/StateMachineTest.cpp @@ -51,11 +51,11 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat }; bool ActionEscDispatch(const wchar_t /* wch */, - const std::basic_string_view /* intermediates */) override { return true; }; + const gsl::span /* intermediates */) override { return true; }; bool ActionVt52EscDispatch(const wchar_t /*wch*/, - const std::basic_string_view /*intermediates*/, - const std::basic_string_view /*parameters*/) override { return true; }; + const gsl::span /*intermediates*/, + const gsl::span /*parameters*/) override { return true; }; bool ActionClear() override { return true; }; @@ -74,7 +74,7 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat }; bool ActionSs3Dispatch(const wchar_t /* wch */, - const std::basic_string_view /* parameters */) override { return true; }; + const gsl::span /* parameters */) override { return true; }; bool ParseControlSequenceAfterSs3() const override { return false; } bool FlushAtEndOfString() const override { return false; }; @@ -83,8 +83,8 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat // ActionCsiDispatch is the only method that's actually implemented. bool ActionCsiDispatch(const wchar_t /*wch*/, - const std::basic_string_view /*intermediates*/, - const std::basic_string_view parameters) override + const gsl::span /*intermediates*/, + const gsl::span parameters) override { // If flush to terminal is registered for a test, then use it. if (pfnFlushToTerminal) @@ -94,7 +94,7 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat } else { - csiParams.emplace(parameters.cbegin(), parameters.cend()); + csiParams.emplace(parameters.begin(), parameters.end()); return true; } } diff --git a/src/til/ut_til/SPSCTests.cpp b/src/til/ut_til/SPSCTests.cpp new file mode 100644 index 00000000000..77f3d111613 --- /dev/null +++ b/src/til/ut_til/SPSCTests.cpp @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +#include "precomp.h" +#include "WexTestClass.h" + +using namespace WEX::Common; +using namespace WEX::Logging; +using namespace WEX::TestExecution; + +struct drop_indicator +{ + explicit drop_indicator(int& counter) noexcept : + _counter(&counter) {} + + drop_indicator(const drop_indicator&) = delete; + drop_indicator& operator=(const drop_indicator&) = delete; + + drop_indicator(drop_indicator&& other) noexcept + { + _counter = std::exchange(other._counter, nullptr); + } + + drop_indicator& operator=(drop_indicator&& other) noexcept + { + _counter = std::exchange(other._counter, nullptr); + } + + ~drop_indicator() + { + if (_counter) + { + ++*_counter; + } + } + +private: + int* _counter = nullptr; +}; + +template +void drop(T&& val) +{ + auto _ = std::move(val); +} + +class SPSCTests +{ + BEGIN_TEST_CLASS(SPSCTests) + TEST_CLASS_PROPERTY(L"TestTimeout", L"0:0:10") // 10s timeout + END_TEST_CLASS() + + TEST_METHOD(DropEmptyTest); + TEST_METHOD(DropSameRevolutionTest); + TEST_METHOD(DropDifferentRevolutionTest); + TEST_METHOD(IntegrationTest); +}; + +void SPSCTests::DropEmptyTest() +{ + auto [tx, rx] = til::spsc::channel(5); + int counter = 0; + + for (int i = 0; i < 5; ++i) + { + tx.emplace(counter); + } + VERIFY_ARE_EQUAL(counter, 0); + + for (int i = 0; i < 5; ++i) + { + rx.pop(); + } + VERIFY_ARE_EQUAL(counter, 5); + + for (int i = 0; i < 3; ++i) + { + tx.emplace(counter); + } + VERIFY_ARE_EQUAL(counter, 5); + + drop(tx); + VERIFY_ARE_EQUAL(counter, 5); + + for (int i = 0; i < 3; ++i) + { + rx.pop(); + } + VERIFY_ARE_EQUAL(counter, 8); + + drop(rx); + VERIFY_ARE_EQUAL(counter, 8); +} + +void SPSCTests::DropSameRevolutionTest() +{ + auto [tx, rx] = til::spsc::channel(5); + int counter = 0; + + for (int i = 0; i < 5; ++i) + { + tx.emplace(counter); + } + VERIFY_ARE_EQUAL(counter, 0); + + drop(tx); + VERIFY_ARE_EQUAL(counter, 0); + + for (int i = 0; i < 3; ++i) + { + rx.pop(); + } + VERIFY_ARE_EQUAL(counter, 3); + + drop(rx); + VERIFY_ARE_EQUAL(counter, 5); +} + +void SPSCTests::DropDifferentRevolutionTest() +{ + auto [tx, rx] = til::spsc::channel(5); + int counter = 0; + + for (int i = 0; i < 4; ++i) + { + tx.emplace(counter); + } + VERIFY_ARE_EQUAL(counter, 0); + + for (int i = 0; i < 3; ++i) + { + rx.pop(); + } + VERIFY_ARE_EQUAL(counter, 3); + + for (int i = 0; i < 4; ++i) + { + tx.emplace(counter); + } + VERIFY_ARE_EQUAL(counter, 3); + + // At this point we emplace()d 8 items and pop()ed 3 in a channel with a capacity of 5. + // Both producer and consumer positions will be 3 and only differ in their revolution flag. + // This ensures that the arc destructor works even if the + // two positions within the circular buffer are identical (modulo the capacity). + + drop(tx); + VERIFY_ARE_EQUAL(counter, 3); + + drop(rx); + VERIFY_ARE_EQUAL(counter, 8); +} + +void SPSCTests::IntegrationTest() +{ + auto [tx, rx] = til::spsc::channel(7); + + std::thread t([tx = std::move(tx)]() { + std::array buffer{}; + std::generate(buffer.begin(), buffer.end(), [v = 0]() mutable { return v++; }); + + for (int i = 0; i < 37; ++i) + { + tx.emplace(i); + } + for (int i = 0; i < 3; ++i) + { + tx.push(buffer.begin(), buffer.end()); + } + }); + + std::array buffer{}; + + for (int i = 0; i < 3; ++i) + { + rx.pop_n(buffer.data(), buffer.size()); + for (int j = 0; j < 11; ++j) + { + VERIFY_ARE_EQUAL(i * 11 + j, buffer[j]); + } + } + for (int i = 33; i < 37; ++i) + { + auto actual = rx.pop(); + VERIFY_ARE_EQUAL(i, actual); + } + for (int i = 0; i < 33; ++i) + { + auto expected = i % 11; + auto actual = rx.pop(); + VERIFY_ARE_EQUAL(expected, actual); + } + + t.join(); +} diff --git a/src/til/ut_til/til.unit.tests.vcxproj b/src/til/ut_til/til.unit.tests.vcxproj index 84ee72de877..82b7908bb7c 100644 --- a/src/til/ut_til/til.unit.tests.vcxproj +++ b/src/til/ut_til/til.unit.tests.vcxproj @@ -22,6 +22,7 @@ Create + diff --git a/src/til/ut_til/til.unit.tests.vcxproj.filters b/src/til/ut_til/til.unit.tests.vcxproj.filters index 20492e2c64c..5633f453b7d 100644 --- a/src/til/ut_til/til.unit.tests.vcxproj.filters +++ b/src/til/ut_til/til.unit.tests.vcxproj.filters @@ -15,6 +15,7 @@ + diff --git a/src/tsf/TfConvArea.cpp b/src/tsf/TfConvArea.cpp index a9de302ebb4..b9ab24b4f65 100644 --- a/src/tsf/TfConvArea.cpp +++ b/src/tsf/TfConvArea.cpp @@ -45,8 +45,8 @@ Revision History: const auto encodedAttributes = _DisplayAttributesToEncodedAttributes(DisplayAttributes, CompCursorPos); - std::basic_string_view attributes(encodedAttributes.data(), encodedAttributes.size()); - std::basic_string_view colorArray(colors.data(), colors.size()); + gsl::span attributes(encodedAttributes.data(), encodedAttributes.size()); + gsl::span colorArray(colors.data(), colors.size()); return ImeComposeData(CompStr, attributes, colorArray); } diff --git a/src/types/ScreenInfoUiaProviderBase.cpp b/src/types/ScreenInfoUiaProviderBase.cpp index d92bb4b458b..b5cb4d44263 100644 --- a/src/types/ScreenInfoUiaProviderBase.cpp +++ b/src/types/ScreenInfoUiaProviderBase.cpp @@ -9,21 +9,21 @@ using namespace Microsoft::Console::Types; // A helper function to create a SafeArray Version of an int array of a specified length -SAFEARRAY* BuildIntSafeArray(std::basic_string_view data) +SAFEARRAY* BuildIntSafeArray(gsl::span data) { SAFEARRAY* psa = SafeArrayCreateVector(VT_I4, 0, gsl::narrow(data.size())); if (psa != nullptr) { - for (size_t i = 0; i < data.size(); i++) + LONG lIndex{ 0 }; + for (auto val : data) { - LONG lIndex = 0; - if (FAILED(SizeTToLong(i, &lIndex)) || - FAILED(SafeArrayPutElement(psa, &lIndex, (void*)&(data.at(i))))) + if (FAILED(SafeArrayPutElement(psa, &lIndex, (void*)&val))) { SafeArrayDestroy(psa); psa = nullptr; break; } + ++lIndex; } } @@ -191,7 +191,7 @@ IFACEMETHODIMP ScreenInfoUiaProviderBase::GetRuntimeId(_Outptr_result_maybenull_ // AppendRuntimeId is a magic Number that tells UIAutomation to Append its own Runtime ID(From the HWND) const std::array rId{ UiaAppendRuntimeId, -1 }; - const std::basic_string_view span{ rId.data(), rId.size() }; + const gsl::span span{ rId.data(), rId.size() }; // BuildIntSafeArray is a custom function to hide the SafeArray creation *ppRuntimeId = BuildIntSafeArray(span); RETURN_IF_NULL_ALLOC(*ppRuntimeId); diff --git a/src/types/utils.cpp b/src/types/utils.cpp index 5d1fe7d9234..86ff8b522aa 100644 --- a/src/types/utils.cpp +++ b/src/types/utils.cpp @@ -6,6 +6,284 @@ using namespace Microsoft::Console; +static constexpr std::array campbellColorTable{ + til::color{ 0x0C, 0x0C, 0x0C }, + til::color{ 0xC5, 0x0F, 0x1F }, + til::color{ 0x13, 0xA1, 0x0E }, + til::color{ 0xC1, 0x9C, 0x00 }, + til::color{ 0x00, 0x37, 0xDA }, + til::color{ 0x88, 0x17, 0x98 }, + til::color{ 0x3A, 0x96, 0xDD }, + til::color{ 0xCC, 0xCC, 0xCC }, + til::color{ 0x76, 0x76, 0x76 }, + til::color{ 0xE7, 0x48, 0x56 }, + til::color{ 0x16, 0xC6, 0x0C }, + til::color{ 0xF9, 0xF1, 0xA5 }, + til::color{ 0x3B, 0x78, 0xFF }, + til::color{ 0xB4, 0x00, 0x9E }, + til::color{ 0x61, 0xD6, 0xD6 }, + til::color{ 0xF2, 0xF2, 0xF2 }, +}; + +static constexpr std::array standardXterm256ColorTable{ + til::color{ 0x00, 0x00, 0x00 }, + til::color{ 0x80, 0x00, 0x00 }, + til::color{ 0x00, 0x80, 0x00 }, + til::color{ 0x80, 0x80, 0x00 }, + til::color{ 0x00, 0x00, 0x80 }, + til::color{ 0x80, 0x00, 0x80 }, + til::color{ 0x00, 0x80, 0x80 }, + til::color{ 0xC0, 0xC0, 0xC0 }, + til::color{ 0x80, 0x80, 0x80 }, + til::color{ 0xFF, 0x00, 0x00 }, + til::color{ 0x00, 0xFF, 0x00 }, + til::color{ 0xFF, 0xFF, 0x00 }, + til::color{ 0x00, 0x00, 0xFF }, + til::color{ 0xFF, 0x00, 0xFF }, + til::color{ 0x00, 0xFF, 0xFF }, + til::color{ 0xFF, 0xFF, 0xFF }, + til::color{ 0x00, 0x00, 0x00 }, + til::color{ 0x00, 0x00, 0x5F }, + til::color{ 0x00, 0x00, 0x87 }, + til::color{ 0x00, 0x00, 0xAF }, + til::color{ 0x00, 0x00, 0xD7 }, + til::color{ 0x00, 0x00, 0xFF }, + til::color{ 0x00, 0x5F, 0x00 }, + til::color{ 0x00, 0x5F, 0x5F }, + til::color{ 0x00, 0x5F, 0x87 }, + til::color{ 0x00, 0x5F, 0xAF }, + til::color{ 0x00, 0x5F, 0xD7 }, + til::color{ 0x00, 0x5F, 0xFF }, + til::color{ 0x00, 0x87, 0x00 }, + til::color{ 0x00, 0x87, 0x5F }, + til::color{ 0x00, 0x87, 0x87 }, + til::color{ 0x00, 0x87, 0xAF }, + til::color{ 0x00, 0x87, 0xD7 }, + til::color{ 0x00, 0x87, 0xFF }, + til::color{ 0x00, 0xAF, 0x00 }, + til::color{ 0x00, 0xAF, 0x5F }, + til::color{ 0x00, 0xAF, 0x87 }, + til::color{ 0x00, 0xAF, 0xAF }, + til::color{ 0x00, 0xAF, 0xD7 }, + til::color{ 0x00, 0xAF, 0xFF }, + til::color{ 0x00, 0xD7, 0x00 }, + til::color{ 0x00, 0xD7, 0x5F }, + til::color{ 0x00, 0xD7, 0x87 }, + til::color{ 0x00, 0xD7, 0xAF }, + til::color{ 0x00, 0xD7, 0xD7 }, + til::color{ 0x00, 0xD7, 0xFF }, + til::color{ 0x00, 0xFF, 0x00 }, + til::color{ 0x00, 0xFF, 0x5F }, + til::color{ 0x00, 0xFF, 0x87 }, + til::color{ 0x00, 0xFF, 0xAF }, + til::color{ 0x00, 0xFF, 0xD7 }, + til::color{ 0x00, 0xFF, 0xFF }, + til::color{ 0x5F, 0x00, 0x00 }, + til::color{ 0x5F, 0x00, 0x5F }, + til::color{ 0x5F, 0x00, 0x87 }, + til::color{ 0x5F, 0x00, 0xAF }, + til::color{ 0x5F, 0x00, 0xD7 }, + til::color{ 0x5F, 0x00, 0xFF }, + til::color{ 0x5F, 0x5F, 0x00 }, + til::color{ 0x5F, 0x5F, 0x5F }, + til::color{ 0x5F, 0x5F, 0x87 }, + til::color{ 0x5F, 0x5F, 0xAF }, + til::color{ 0x5F, 0x5F, 0xD7 }, + til::color{ 0x5F, 0x5F, 0xFF }, + til::color{ 0x5F, 0x87, 0x00 }, + til::color{ 0x5F, 0x87, 0x5F }, + til::color{ 0x5F, 0x87, 0x87 }, + til::color{ 0x5F, 0x87, 0xAF }, + til::color{ 0x5F, 0x87, 0xD7 }, + til::color{ 0x5F, 0x87, 0xFF }, + til::color{ 0x5F, 0xAF, 0x00 }, + til::color{ 0x5F, 0xAF, 0x5F }, + til::color{ 0x5F, 0xAF, 0x87 }, + til::color{ 0x5F, 0xAF, 0xAF }, + til::color{ 0x5F, 0xAF, 0xD7 }, + til::color{ 0x5F, 0xAF, 0xFF }, + til::color{ 0x5F, 0xD7, 0x00 }, + til::color{ 0x5F, 0xD7, 0x5F }, + til::color{ 0x5F, 0xD7, 0x87 }, + til::color{ 0x5F, 0xD7, 0xAF }, + til::color{ 0x5F, 0xD7, 0xD7 }, + til::color{ 0x5F, 0xD7, 0xFF }, + til::color{ 0x5F, 0xFF, 0x00 }, + til::color{ 0x5F, 0xFF, 0x5F }, + til::color{ 0x5F, 0xFF, 0x87 }, + til::color{ 0x5F, 0xFF, 0xAF }, + til::color{ 0x5F, 0xFF, 0xD7 }, + til::color{ 0x5F, 0xFF, 0xFF }, + til::color{ 0x87, 0x00, 0x00 }, + til::color{ 0x87, 0x00, 0x5F }, + til::color{ 0x87, 0x00, 0x87 }, + til::color{ 0x87, 0x00, 0xAF }, + til::color{ 0x87, 0x00, 0xD7 }, + til::color{ 0x87, 0x00, 0xFF }, + til::color{ 0x87, 0x5F, 0x00 }, + til::color{ 0x87, 0x5F, 0x5F }, + til::color{ 0x87, 0x5F, 0x87 }, + til::color{ 0x87, 0x5F, 0xAF }, + til::color{ 0x87, 0x5F, 0xD7 }, + til::color{ 0x87, 0x5F, 0xFF }, + til::color{ 0x87, 0x87, 0x00 }, + til::color{ 0x87, 0x87, 0x5F }, + til::color{ 0x87, 0x87, 0x87 }, + til::color{ 0x87, 0x87, 0xAF }, + til::color{ 0x87, 0x87, 0xD7 }, + til::color{ 0x87, 0x87, 0xFF }, + til::color{ 0x87, 0xAF, 0x00 }, + til::color{ 0x87, 0xAF, 0x5F }, + til::color{ 0x87, 0xAF, 0x87 }, + til::color{ 0x87, 0xAF, 0xAF }, + til::color{ 0x87, 0xAF, 0xD7 }, + til::color{ 0x87, 0xAF, 0xFF }, + til::color{ 0x87, 0xD7, 0x00 }, + til::color{ 0x87, 0xD7, 0x5F }, + til::color{ 0x87, 0xD7, 0x87 }, + til::color{ 0x87, 0xD7, 0xAF }, + til::color{ 0x87, 0xD7, 0xD7 }, + til::color{ 0x87, 0xD7, 0xFF }, + til::color{ 0x87, 0xFF, 0x00 }, + til::color{ 0x87, 0xFF, 0x5F }, + til::color{ 0x87, 0xFF, 0x87 }, + til::color{ 0x87, 0xFF, 0xAF }, + til::color{ 0x87, 0xFF, 0xD7 }, + til::color{ 0x87, 0xFF, 0xFF }, + til::color{ 0xAF, 0x00, 0x00 }, + til::color{ 0xAF, 0x00, 0x5F }, + til::color{ 0xAF, 0x00, 0x87 }, + til::color{ 0xAF, 0x00, 0xAF }, + til::color{ 0xAF, 0x00, 0xD7 }, + til::color{ 0xAF, 0x00, 0xFF }, + til::color{ 0xAF, 0x5F, 0x00 }, + til::color{ 0xAF, 0x5F, 0x5F }, + til::color{ 0xAF, 0x5F, 0x87 }, + til::color{ 0xAF, 0x5F, 0xAF }, + til::color{ 0xAF, 0x5F, 0xD7 }, + til::color{ 0xAF, 0x5F, 0xFF }, + til::color{ 0xAF, 0x87, 0x00 }, + til::color{ 0xAF, 0x87, 0x5F }, + til::color{ 0xAF, 0x87, 0x87 }, + til::color{ 0xAF, 0x87, 0xAF }, + til::color{ 0xAF, 0x87, 0xD7 }, + til::color{ 0xAF, 0x87, 0xFF }, + til::color{ 0xAF, 0xAF, 0x00 }, + til::color{ 0xAF, 0xAF, 0x5F }, + til::color{ 0xAF, 0xAF, 0x87 }, + til::color{ 0xAF, 0xAF, 0xAF }, + til::color{ 0xAF, 0xAF, 0xD7 }, + til::color{ 0xAF, 0xAF, 0xFF }, + til::color{ 0xAF, 0xD7, 0x00 }, + til::color{ 0xAF, 0xD7, 0x5F }, + til::color{ 0xAF, 0xD7, 0x87 }, + til::color{ 0xAF, 0xD7, 0xAF }, + til::color{ 0xAF, 0xD7, 0xD7 }, + til::color{ 0xAF, 0xD7, 0xFF }, + til::color{ 0xAF, 0xFF, 0x00 }, + til::color{ 0xAF, 0xFF, 0x5F }, + til::color{ 0xAF, 0xFF, 0x87 }, + til::color{ 0xAF, 0xFF, 0xAF }, + til::color{ 0xAF, 0xFF, 0xD7 }, + til::color{ 0xAF, 0xFF, 0xFF }, + til::color{ 0xD7, 0x00, 0x00 }, + til::color{ 0xD7, 0x00, 0x5F }, + til::color{ 0xD7, 0x00, 0x87 }, + til::color{ 0xD7, 0x00, 0xAF }, + til::color{ 0xD7, 0x00, 0xD7 }, + til::color{ 0xD7, 0x00, 0xFF }, + til::color{ 0xD7, 0x5F, 0x00 }, + til::color{ 0xD7, 0x5F, 0x5F }, + til::color{ 0xD7, 0x5F, 0x87 }, + til::color{ 0xD7, 0x5F, 0xAF }, + til::color{ 0xD7, 0x5F, 0xD7 }, + til::color{ 0xD7, 0x5F, 0xFF }, + til::color{ 0xD7, 0x87, 0x00 }, + til::color{ 0xD7, 0x87, 0x5F }, + til::color{ 0xD7, 0x87, 0x87 }, + til::color{ 0xD7, 0x87, 0xAF }, + til::color{ 0xD7, 0x87, 0xD7 }, + til::color{ 0xD7, 0x87, 0xFF }, + til::color{ 0xD7, 0xAF, 0x00 }, + til::color{ 0xD7, 0xAF, 0x5F }, + til::color{ 0xD7, 0xAF, 0x87 }, + til::color{ 0xD7, 0xAF, 0xAF }, + til::color{ 0xD7, 0xAF, 0xD7 }, + til::color{ 0xD7, 0xAF, 0xFF }, + til::color{ 0xD7, 0xD7, 0x00 }, + til::color{ 0xD7, 0xD7, 0x5F }, + til::color{ 0xD7, 0xD7, 0x87 }, + til::color{ 0xD7, 0xD7, 0xAF }, + til::color{ 0xD7, 0xD7, 0xD7 }, + til::color{ 0xD7, 0xD7, 0xFF }, + til::color{ 0xD7, 0xFF, 0x00 }, + til::color{ 0xD7, 0xFF, 0x5F }, + til::color{ 0xD7, 0xFF, 0x87 }, + til::color{ 0xD7, 0xFF, 0xAF }, + til::color{ 0xD7, 0xFF, 0xD7 }, + til::color{ 0xD7, 0xFF, 0xFF }, + til::color{ 0xFF, 0x00, 0x00 }, + til::color{ 0xFF, 0x00, 0x5F }, + til::color{ 0xFF, 0x00, 0x87 }, + til::color{ 0xFF, 0x00, 0xAF }, + til::color{ 0xFF, 0x00, 0xD7 }, + til::color{ 0xFF, 0x00, 0xFF }, + til::color{ 0xFF, 0x5F, 0x00 }, + til::color{ 0xFF, 0x5F, 0x5F }, + til::color{ 0xFF, 0x5F, 0x87 }, + til::color{ 0xFF, 0x5F, 0xAF }, + til::color{ 0xFF, 0x5F, 0xD7 }, + til::color{ 0xFF, 0x5F, 0xFF }, + til::color{ 0xFF, 0x87, 0x00 }, + til::color{ 0xFF, 0x87, 0x5F }, + til::color{ 0xFF, 0x87, 0x87 }, + til::color{ 0xFF, 0x87, 0xAF }, + til::color{ 0xFF, 0x87, 0xD7 }, + til::color{ 0xFF, 0x87, 0xFF }, + til::color{ 0xFF, 0xAF, 0x00 }, + til::color{ 0xFF, 0xAF, 0x5F }, + til::color{ 0xFF, 0xAF, 0x87 }, + til::color{ 0xFF, 0xAF, 0xAF }, + til::color{ 0xFF, 0xAF, 0xD7 }, + til::color{ 0xFF, 0xAF, 0xFF }, + til::color{ 0xFF, 0xD7, 0x00 }, + til::color{ 0xFF, 0xD7, 0x5F }, + til::color{ 0xFF, 0xD7, 0x87 }, + til::color{ 0xFF, 0xD7, 0xAF }, + til::color{ 0xFF, 0xD7, 0xD7 }, + til::color{ 0xFF, 0xD7, 0xFF }, + til::color{ 0xFF, 0xFF, 0x00 }, + til::color{ 0xFF, 0xFF, 0x5F }, + til::color{ 0xFF, 0xFF, 0x87 }, + til::color{ 0xFF, 0xFF, 0xAF }, + til::color{ 0xFF, 0xFF, 0xD7 }, + til::color{ 0xFF, 0xFF, 0xFF }, + til::color{ 0x08, 0x08, 0x08 }, + til::color{ 0x12, 0x12, 0x12 }, + til::color{ 0x1C, 0x1C, 0x1C }, + til::color{ 0x26, 0x26, 0x26 }, + til::color{ 0x30, 0x30, 0x30 }, + til::color{ 0x3A, 0x3A, 0x3A }, + til::color{ 0x44, 0x44, 0x44 }, + til::color{ 0x4E, 0x4E, 0x4E }, + til::color{ 0x58, 0x58, 0x58 }, + til::color{ 0x62, 0x62, 0x62 }, + til::color{ 0x6C, 0x6C, 0x6C }, + til::color{ 0x76, 0x76, 0x76 }, + til::color{ 0x80, 0x80, 0x80 }, + til::color{ 0x8A, 0x8A, 0x8A }, + til::color{ 0x94, 0x94, 0x94 }, + til::color{ 0x9E, 0x9E, 0x9E }, + til::color{ 0xA8, 0xA8, 0xA8 }, + til::color{ 0xB2, 0xB2, 0xB2 }, + til::color{ 0xBC, 0xBC, 0xBC }, + til::color{ 0xC6, 0xC6, 0xC6 }, + til::color{ 0xD0, 0xD0, 0xD0 }, + til::color{ 0xDA, 0xDA, 0xDA }, + til::color{ 0xE4, 0xE4, 0xE4 }, + til::color{ 0xEE, 0xEE, 0xEE }, +}; + // Function Description: // - Creates a String representation of a guid, in the format // "{12345678-ABCD-EF12-3456-7890ABCDEF12}" @@ -121,24 +399,7 @@ void Utils::InitializeCampbellColorTable(const gsl::span table) { THROW_HR_IF(E_INVALIDARG, table.size() < 16); - // clang-format off - gsl::at(table, 0) = RGB(12, 12, 12); - gsl::at(table, 1) = RGB(197, 15, 31); - gsl::at(table, 2) = RGB(19, 161, 14); - gsl::at(table, 3) = RGB(193, 156, 0); - gsl::at(table, 4) = RGB(0, 55, 218); - gsl::at(table, 5) = RGB(136, 23, 152); - gsl::at(table, 6) = RGB(58, 150, 221); - gsl::at(table, 7) = RGB(204, 204, 204); - gsl::at(table, 8) = RGB(118, 118, 118); - gsl::at(table, 9) = RGB(231, 72, 86); - gsl::at(table, 10) = RGB(22, 198, 12); - gsl::at(table, 11) = RGB(249, 241, 165); - gsl::at(table, 12) = RGB(59, 120, 255); - gsl::at(table, 13) = RGB(180, 0, 158); - gsl::at(table, 14) = RGB(97, 214, 214); - gsl::at(table, 15) = RGB(242, 242, 242); - // clang-format on + std::copy(campbellColorTable.begin(), campbellColorTable.end(), table.begin()); } // Function Description: @@ -164,10 +425,10 @@ void Utils::InitializeCampbellColorTableForConhost(const gsl::span tab void Utils::SwapANSIColorOrderForConhost(const gsl::span table) { THROW_HR_IF(E_INVALIDARG, table.size() < 16); - std::swap(gsl::at(table, 1), gsl::at(table, 4)); - std::swap(gsl::at(table, 3), gsl::at(table, 6)); - std::swap(gsl::at(table, 9), gsl::at(table, 12)); - std::swap(gsl::at(table, 11), gsl::at(table, 14)); + std::swap(til::at(table, 1), til::at(table, 4)); + std::swap(til::at(table, 3), til::at(table, 6)); + std::swap(til::at(table, 9), til::at(table, 12)); + std::swap(til::at(table, 11), til::at(table, 14)); } // Function Description: @@ -181,264 +442,7 @@ void Utils::Initialize256ColorTable(const gsl::span table) { THROW_HR_IF(E_INVALIDARG, table.size() < 256); - // clang-format off - gsl::at(table, 0) = RGB(0x00, 0x00, 0x00); - gsl::at(table, 1) = RGB(0x80, 0x00, 0x00); - gsl::at(table, 2) = RGB(0x00, 0x80, 0x00); - gsl::at(table, 3) = RGB(0x80, 0x80, 0x00); - gsl::at(table, 4) = RGB(0x00, 0x00, 0x80); - gsl::at(table, 5) = RGB(0x80, 0x00, 0x80); - gsl::at(table, 6) = RGB(0x00, 0x80, 0x80); - gsl::at(table, 7) = RGB(0xc0, 0xc0, 0xc0); - gsl::at(table, 8) = RGB(0x80, 0x80, 0x80); - gsl::at(table, 9) = RGB(0xff, 0x00, 0x00); - gsl::at(table, 10) = RGB(0x00, 0xff, 0x00); - gsl::at(table, 11) = RGB(0xff, 0xff, 0x00); - gsl::at(table, 12) = RGB(0x00, 0x00, 0xff); - gsl::at(table, 13) = RGB(0xff, 0x00, 0xff); - gsl::at(table, 14) = RGB(0x00, 0xff, 0xff); - gsl::at(table, 15) = RGB(0xff, 0xff, 0xff); - gsl::at(table, 16) = RGB(0x00, 0x00, 0x00); - gsl::at(table, 17) = RGB(0x00, 0x00, 0x5f); - gsl::at(table, 18) = RGB(0x00, 0x00, 0x87); - gsl::at(table, 19) = RGB(0x00, 0x00, 0xaf); - gsl::at(table, 20) = RGB(0x00, 0x00, 0xd7); - gsl::at(table, 21) = RGB(0x00, 0x00, 0xff); - gsl::at(table, 22) = RGB(0x00, 0x5f, 0x00); - gsl::at(table, 23) = RGB(0x00, 0x5f, 0x5f); - gsl::at(table, 24) = RGB(0x00, 0x5f, 0x87); - gsl::at(table, 25) = RGB(0x00, 0x5f, 0xaf); - gsl::at(table, 26) = RGB(0x00, 0x5f, 0xd7); - gsl::at(table, 27) = RGB(0x00, 0x5f, 0xff); - gsl::at(table, 28) = RGB(0x00, 0x87, 0x00); - gsl::at(table, 29) = RGB(0x00, 0x87, 0x5f); - gsl::at(table, 30) = RGB(0x00, 0x87, 0x87); - gsl::at(table, 31) = RGB(0x00, 0x87, 0xaf); - gsl::at(table, 32) = RGB(0x00, 0x87, 0xd7); - gsl::at(table, 33) = RGB(0x00, 0x87, 0xff); - gsl::at(table, 34) = RGB(0x00, 0xaf, 0x00); - gsl::at(table, 35) = RGB(0x00, 0xaf, 0x5f); - gsl::at(table, 36) = RGB(0x00, 0xaf, 0x87); - gsl::at(table, 37) = RGB(0x00, 0xaf, 0xaf); - gsl::at(table, 38) = RGB(0x00, 0xaf, 0xd7); - gsl::at(table, 39) = RGB(0x00, 0xaf, 0xff); - gsl::at(table, 40) = RGB(0x00, 0xd7, 0x00); - gsl::at(table, 41) = RGB(0x00, 0xd7, 0x5f); - gsl::at(table, 42) = RGB(0x00, 0xd7, 0x87); - gsl::at(table, 43) = RGB(0x00, 0xd7, 0xaf); - gsl::at(table, 44) = RGB(0x00, 0xd7, 0xd7); - gsl::at(table, 45) = RGB(0x00, 0xd7, 0xff); - gsl::at(table, 46) = RGB(0x00, 0xff, 0x00); - gsl::at(table, 47) = RGB(0x00, 0xff, 0x5f); - gsl::at(table, 48) = RGB(0x00, 0xff, 0x87); - gsl::at(table, 49) = RGB(0x00, 0xff, 0xaf); - gsl::at(table, 50) = RGB(0x00, 0xff, 0xd7); - gsl::at(table, 51) = RGB(0x00, 0xff, 0xff); - gsl::at(table, 52) = RGB(0x5f, 0x00, 0x00); - gsl::at(table, 53) = RGB(0x5f, 0x00, 0x5f); - gsl::at(table, 54) = RGB(0x5f, 0x00, 0x87); - gsl::at(table, 55) = RGB(0x5f, 0x00, 0xaf); - gsl::at(table, 56) = RGB(0x5f, 0x00, 0xd7); - gsl::at(table, 57) = RGB(0x5f, 0x00, 0xff); - gsl::at(table, 58) = RGB(0x5f, 0x5f, 0x00); - gsl::at(table, 59) = RGB(0x5f, 0x5f, 0x5f); - gsl::at(table, 60) = RGB(0x5f, 0x5f, 0x87); - gsl::at(table, 61) = RGB(0x5f, 0x5f, 0xaf); - gsl::at(table, 62) = RGB(0x5f, 0x5f, 0xd7); - gsl::at(table, 63) = RGB(0x5f, 0x5f, 0xff); - gsl::at(table, 64) = RGB(0x5f, 0x87, 0x00); - gsl::at(table, 65) = RGB(0x5f, 0x87, 0x5f); - gsl::at(table, 66) = RGB(0x5f, 0x87, 0x87); - gsl::at(table, 67) = RGB(0x5f, 0x87, 0xaf); - gsl::at(table, 68) = RGB(0x5f, 0x87, 0xd7); - gsl::at(table, 69) = RGB(0x5f, 0x87, 0xff); - gsl::at(table, 70) = RGB(0x5f, 0xaf, 0x00); - gsl::at(table, 71) = RGB(0x5f, 0xaf, 0x5f); - gsl::at(table, 72) = RGB(0x5f, 0xaf, 0x87); - gsl::at(table, 73) = RGB(0x5f, 0xaf, 0xaf); - gsl::at(table, 74) = RGB(0x5f, 0xaf, 0xd7); - gsl::at(table, 75) = RGB(0x5f, 0xaf, 0xff); - gsl::at(table, 76) = RGB(0x5f, 0xd7, 0x00); - gsl::at(table, 77) = RGB(0x5f, 0xd7, 0x5f); - gsl::at(table, 78) = RGB(0x5f, 0xd7, 0x87); - gsl::at(table, 79) = RGB(0x5f, 0xd7, 0xaf); - gsl::at(table, 80) = RGB(0x5f, 0xd7, 0xd7); - gsl::at(table, 81) = RGB(0x5f, 0xd7, 0xff); - gsl::at(table, 82) = RGB(0x5f, 0xff, 0x00); - gsl::at(table, 83) = RGB(0x5f, 0xff, 0x5f); - gsl::at(table, 84) = RGB(0x5f, 0xff, 0x87); - gsl::at(table, 85) = RGB(0x5f, 0xff, 0xaf); - gsl::at(table, 86) = RGB(0x5f, 0xff, 0xd7); - gsl::at(table, 87) = RGB(0x5f, 0xff, 0xff); - gsl::at(table, 88) = RGB(0x87, 0x00, 0x00); - gsl::at(table, 89) = RGB(0x87, 0x00, 0x5f); - gsl::at(table, 90) = RGB(0x87, 0x00, 0x87); - gsl::at(table, 91) = RGB(0x87, 0x00, 0xaf); - gsl::at(table, 92) = RGB(0x87, 0x00, 0xd7); - gsl::at(table, 93) = RGB(0x87, 0x00, 0xff); - gsl::at(table, 94) = RGB(0x87, 0x5f, 0x00); - gsl::at(table, 95) = RGB(0x87, 0x5f, 0x5f); - gsl::at(table, 96) = RGB(0x87, 0x5f, 0x87); - gsl::at(table, 97) = RGB(0x87, 0x5f, 0xaf); - gsl::at(table, 98) = RGB(0x87, 0x5f, 0xd7); - gsl::at(table, 99) = RGB(0x87, 0x5f, 0xff); - gsl::at(table, 100) = RGB(0x87, 0x87, 0x00); - gsl::at(table, 101) = RGB(0x87, 0x87, 0x5f); - gsl::at(table, 102) = RGB(0x87, 0x87, 0x87); - gsl::at(table, 103) = RGB(0x87, 0x87, 0xaf); - gsl::at(table, 104) = RGB(0x87, 0x87, 0xd7); - gsl::at(table, 105) = RGB(0x87, 0x87, 0xff); - gsl::at(table, 106) = RGB(0x87, 0xaf, 0x00); - gsl::at(table, 107) = RGB(0x87, 0xaf, 0x5f); - gsl::at(table, 108) = RGB(0x87, 0xaf, 0x87); - gsl::at(table, 109) = RGB(0x87, 0xaf, 0xaf); - gsl::at(table, 110) = RGB(0x87, 0xaf, 0xd7); - gsl::at(table, 111) = RGB(0x87, 0xaf, 0xff); - gsl::at(table, 112) = RGB(0x87, 0xd7, 0x00); - gsl::at(table, 113) = RGB(0x87, 0xd7, 0x5f); - gsl::at(table, 114) = RGB(0x87, 0xd7, 0x87); - gsl::at(table, 115) = RGB(0x87, 0xd7, 0xaf); - gsl::at(table, 116) = RGB(0x87, 0xd7, 0xd7); - gsl::at(table, 117) = RGB(0x87, 0xd7, 0xff); - gsl::at(table, 118) = RGB(0x87, 0xff, 0x00); - gsl::at(table, 119) = RGB(0x87, 0xff, 0x5f); - gsl::at(table, 120) = RGB(0x87, 0xff, 0x87); - gsl::at(table, 121) = RGB(0x87, 0xff, 0xaf); - gsl::at(table, 122) = RGB(0x87, 0xff, 0xd7); - gsl::at(table, 123) = RGB(0x87, 0xff, 0xff); - gsl::at(table, 124) = RGB(0xaf, 0x00, 0x00); - gsl::at(table, 125) = RGB(0xaf, 0x00, 0x5f); - gsl::at(table, 126) = RGB(0xaf, 0x00, 0x87); - gsl::at(table, 127) = RGB(0xaf, 0x00, 0xaf); - gsl::at(table, 128) = RGB(0xaf, 0x00, 0xd7); - gsl::at(table, 129) = RGB(0xaf, 0x00, 0xff); - gsl::at(table, 130) = RGB(0xaf, 0x5f, 0x00); - gsl::at(table, 131) = RGB(0xaf, 0x5f, 0x5f); - gsl::at(table, 132) = RGB(0xaf, 0x5f, 0x87); - gsl::at(table, 133) = RGB(0xaf, 0x5f, 0xaf); - gsl::at(table, 134) = RGB(0xaf, 0x5f, 0xd7); - gsl::at(table, 135) = RGB(0xaf, 0x5f, 0xff); - gsl::at(table, 136) = RGB(0xaf, 0x87, 0x00); - gsl::at(table, 137) = RGB(0xaf, 0x87, 0x5f); - gsl::at(table, 138) = RGB(0xaf, 0x87, 0x87); - gsl::at(table, 139) = RGB(0xaf, 0x87, 0xaf); - gsl::at(table, 140) = RGB(0xaf, 0x87, 0xd7); - gsl::at(table, 141) = RGB(0xaf, 0x87, 0xff); - gsl::at(table, 142) = RGB(0xaf, 0xaf, 0x00); - gsl::at(table, 143) = RGB(0xaf, 0xaf, 0x5f); - gsl::at(table, 144) = RGB(0xaf, 0xaf, 0x87); - gsl::at(table, 145) = RGB(0xaf, 0xaf, 0xaf); - gsl::at(table, 146) = RGB(0xaf, 0xaf, 0xd7); - gsl::at(table, 147) = RGB(0xaf, 0xaf, 0xff); - gsl::at(table, 148) = RGB(0xaf, 0xd7, 0x00); - gsl::at(table, 149) = RGB(0xaf, 0xd7, 0x5f); - gsl::at(table, 150) = RGB(0xaf, 0xd7, 0x87); - gsl::at(table, 151) = RGB(0xaf, 0xd7, 0xaf); - gsl::at(table, 152) = RGB(0xaf, 0xd7, 0xd7); - gsl::at(table, 153) = RGB(0xaf, 0xd7, 0xff); - gsl::at(table, 154) = RGB(0xaf, 0xff, 0x00); - gsl::at(table, 155) = RGB(0xaf, 0xff, 0x5f); - gsl::at(table, 156) = RGB(0xaf, 0xff, 0x87); - gsl::at(table, 157) = RGB(0xaf, 0xff, 0xaf); - gsl::at(table, 158) = RGB(0xaf, 0xff, 0xd7); - gsl::at(table, 159) = RGB(0xaf, 0xff, 0xff); - gsl::at(table, 160) = RGB(0xd7, 0x00, 0x00); - gsl::at(table, 161) = RGB(0xd7, 0x00, 0x5f); - gsl::at(table, 162) = RGB(0xd7, 0x00, 0x87); - gsl::at(table, 163) = RGB(0xd7, 0x00, 0xaf); - gsl::at(table, 164) = RGB(0xd7, 0x00, 0xd7); - gsl::at(table, 165) = RGB(0xd7, 0x00, 0xff); - gsl::at(table, 166) = RGB(0xd7, 0x5f, 0x00); - gsl::at(table, 167) = RGB(0xd7, 0x5f, 0x5f); - gsl::at(table, 168) = RGB(0xd7, 0x5f, 0x87); - gsl::at(table, 169) = RGB(0xd7, 0x5f, 0xaf); - gsl::at(table, 170) = RGB(0xd7, 0x5f, 0xd7); - gsl::at(table, 171) = RGB(0xd7, 0x5f, 0xff); - gsl::at(table, 172) = RGB(0xd7, 0x87, 0x00); - gsl::at(table, 173) = RGB(0xd7, 0x87, 0x5f); - gsl::at(table, 174) = RGB(0xd7, 0x87, 0x87); - gsl::at(table, 175) = RGB(0xd7, 0x87, 0xaf); - gsl::at(table, 176) = RGB(0xd7, 0x87, 0xd7); - gsl::at(table, 177) = RGB(0xd7, 0x87, 0xff); - gsl::at(table, 178) = RGB(0xd7, 0xaf, 0x00); - gsl::at(table, 179) = RGB(0xd7, 0xaf, 0x5f); - gsl::at(table, 180) = RGB(0xd7, 0xaf, 0x87); - gsl::at(table, 181) = RGB(0xd7, 0xaf, 0xaf); - gsl::at(table, 182) = RGB(0xd7, 0xaf, 0xd7); - gsl::at(table, 183) = RGB(0xd7, 0xaf, 0xff); - gsl::at(table, 184) = RGB(0xd7, 0xd7, 0x00); - gsl::at(table, 185) = RGB(0xd7, 0xd7, 0x5f); - gsl::at(table, 186) = RGB(0xd7, 0xd7, 0x87); - gsl::at(table, 187) = RGB(0xd7, 0xd7, 0xaf); - gsl::at(table, 188) = RGB(0xd7, 0xd7, 0xd7); - gsl::at(table, 189) = RGB(0xd7, 0xd7, 0xff); - gsl::at(table, 190) = RGB(0xd7, 0xff, 0x00); - gsl::at(table, 191) = RGB(0xd7, 0xff, 0x5f); - gsl::at(table, 192) = RGB(0xd7, 0xff, 0x87); - gsl::at(table, 193) = RGB(0xd7, 0xff, 0xaf); - gsl::at(table, 194) = RGB(0xd7, 0xff, 0xd7); - gsl::at(table, 195) = RGB(0xd7, 0xff, 0xff); - gsl::at(table, 196) = RGB(0xff, 0x00, 0x00); - gsl::at(table, 197) = RGB(0xff, 0x00, 0x5f); - gsl::at(table, 198) = RGB(0xff, 0x00, 0x87); - gsl::at(table, 199) = RGB(0xff, 0x00, 0xaf); - gsl::at(table, 200) = RGB(0xff, 0x00, 0xd7); - gsl::at(table, 201) = RGB(0xff, 0x00, 0xff); - gsl::at(table, 202) = RGB(0xff, 0x5f, 0x00); - gsl::at(table, 203) = RGB(0xff, 0x5f, 0x5f); - gsl::at(table, 204) = RGB(0xff, 0x5f, 0x87); - gsl::at(table, 205) = RGB(0xff, 0x5f, 0xaf); - gsl::at(table, 206) = RGB(0xff, 0x5f, 0xd7); - gsl::at(table, 207) = RGB(0xff, 0x5f, 0xff); - gsl::at(table, 208) = RGB(0xff, 0x87, 0x00); - gsl::at(table, 209) = RGB(0xff, 0x87, 0x5f); - gsl::at(table, 210) = RGB(0xff, 0x87, 0x87); - gsl::at(table, 211) = RGB(0xff, 0x87, 0xaf); - gsl::at(table, 212) = RGB(0xff, 0x87, 0xd7); - gsl::at(table, 213) = RGB(0xff, 0x87, 0xff); - gsl::at(table, 214) = RGB(0xff, 0xaf, 0x00); - gsl::at(table, 215) = RGB(0xff, 0xaf, 0x5f); - gsl::at(table, 216) = RGB(0xff, 0xaf, 0x87); - gsl::at(table, 217) = RGB(0xff, 0xaf, 0xaf); - gsl::at(table, 218) = RGB(0xff, 0xaf, 0xd7); - gsl::at(table, 219) = RGB(0xff, 0xaf, 0xff); - gsl::at(table, 220) = RGB(0xff, 0xd7, 0x00); - gsl::at(table, 221) = RGB(0xff, 0xd7, 0x5f); - gsl::at(table, 222) = RGB(0xff, 0xd7, 0x87); - gsl::at(table, 223) = RGB(0xff, 0xd7, 0xaf); - gsl::at(table, 224) = RGB(0xff, 0xd7, 0xd7); - gsl::at(table, 225) = RGB(0xff, 0xd7, 0xff); - gsl::at(table, 226) = RGB(0xff, 0xff, 0x00); - gsl::at(table, 227) = RGB(0xff, 0xff, 0x5f); - gsl::at(table, 228) = RGB(0xff, 0xff, 0x87); - gsl::at(table, 229) = RGB(0xff, 0xff, 0xaf); - gsl::at(table, 230) = RGB(0xff, 0xff, 0xd7); - gsl::at(table, 231) = RGB(0xff, 0xff, 0xff); - gsl::at(table, 232) = RGB(0x08, 0x08, 0x08); - gsl::at(table, 233) = RGB(0x12, 0x12, 0x12); - gsl::at(table, 234) = RGB(0x1c, 0x1c, 0x1c); - gsl::at(table, 235) = RGB(0x26, 0x26, 0x26); - gsl::at(table, 236) = RGB(0x30, 0x30, 0x30); - gsl::at(table, 237) = RGB(0x3a, 0x3a, 0x3a); - gsl::at(table, 238) = RGB(0x44, 0x44, 0x44); - gsl::at(table, 239) = RGB(0x4e, 0x4e, 0x4e); - gsl::at(table, 240) = RGB(0x58, 0x58, 0x58); - gsl::at(table, 241) = RGB(0x62, 0x62, 0x62); - gsl::at(table, 242) = RGB(0x6c, 0x6c, 0x6c); - gsl::at(table, 243) = RGB(0x76, 0x76, 0x76); - gsl::at(table, 244) = RGB(0x80, 0x80, 0x80); - gsl::at(table, 245) = RGB(0x8a, 0x8a, 0x8a); - gsl::at(table, 246) = RGB(0x94, 0x94, 0x94); - gsl::at(table, 247) = RGB(0x9e, 0x9e, 0x9e); - gsl::at(table, 248) = RGB(0xa8, 0xa8, 0xa8); - gsl::at(table, 249) = RGB(0xb2, 0xb2, 0xb2); - gsl::at(table, 250) = RGB(0xbc, 0xbc, 0xbc); - gsl::at(table, 251) = RGB(0xc6, 0xc6, 0xc6); - gsl::at(table, 252) = RGB(0xd0, 0xd0, 0xd0); - gsl::at(table, 253) = RGB(0xda, 0xda, 0xda); - gsl::at(table, 254) = RGB(0xe4, 0xe4, 0xe4); - gsl::at(table, 255) = RGB(0xee, 0xee, 0xee); - // clang-format on + std::copy(standardXterm256ColorTable.begin(), standardXterm256ColorTable.end(), table.begin()); } // Function Description: diff --git a/tools/bcz.cmd b/tools/bcz.cmd index f70269aaf34..3262b0b39e1 100644 --- a/tools/bcz.cmd +++ b/tools/bcz.cmd @@ -116,8 +116,12 @@ set "__PROJECT_NAME=!_OUTPUT!" rem If we're trying to clean build, make sure to update the target here. if "%_MSBUILD_TARGET%" == "Build" ( set __MSBUILD_TARGET=%__PROJECT_NAME% -) else if "%_MSBUILD_TARGET%" == "Clean,Build" ( +) else if "%_MSBUILD_TARGET%" == "Clean;Build" ( set __MSBUILD_TARGET=%__PROJECT_NAME%:Rebuild +) else ( + echo. + echo Oops... build bug in the neighborhood of configuring a build target. + echo. ) rem This statement will propagate our internal variables up to the calling rem scope. Because they're all on one line, the value of our local variables