Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable previewing the color scheme in the command palette #9794

Merged
101 commits merged into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
c6432b6
add object on Core side
PankajBhojwani Nov 20, 2020
f806011
object in settings model side
PankajBhojwani Nov 24, 2020
5aa1e66
applib side object
PankajBhojwani Nov 24, 2020
c423e11
barebones prototype
PankajBhojwani Nov 24, 2020
8f8e6e7
renaming
PankajBhojwani Nov 30, 2020
f4dd69a
cursor shape
PankajBhojwani Nov 30, 2020
235bbd7
background image works now
PankajBhojwani Dec 1, 2020
dc8328d
deduplicate code: UpdateSettings now calls UpdateAppearance
PankajBhojwani Dec 2, 2020
d3ad801
spell, Cl check
PankajBhojwani Dec 2, 2020
43c6204
IAppearanceConfig interface in settings model side, color scheme gets…
PankajBhojwani Dec 2, 2020
2960ba2
background image parameters
PankajBhojwani Dec 2, 2020
bc12378
actually use the image params
PankajBhojwani Dec 2, 2020
34621c1
functions for update settings/appearance from ui settings
PankajBhojwani Dec 2, 2020
45a9718
conflict
PankajBhojwani Dec 2, 2020
d9fbe56
update with the new converged alignment
PankajBhojwani Dec 3, 2020
9e1a9f9
IControl/CoreAppearance
PankajBhojwani Dec 5, 2020
a118fe7
inheritance step 1?
PankajBhojwani Dec 7, 2020
90025ec
placeholder inheritance
PankajBhojwani Dec 9, 2020
e0244d5
friend struct works
PankajBhojwani Dec 9, 2020
95e679c
not experimental
PankajBhojwani Dec 9, 2020
6688c3c
color scheme fix
PankajBhojwani Dec 9, 2020
9eba7ab
dont update appearance if no unfocused config
PankajBhojwani Dec 11, 2020
698cf41
add comments to code
PankajBhojwani Dec 11, 2020
8194aca
update to mock term settings
PankajBhojwani Dec 11, 2020
8b64425
begin
PankajBhojwani Dec 16, 2020
403646f
everything updates except color scheme?
PankajBhojwani Dec 17, 2020
7b5e04e
color scheme fix
PankajBhojwani Dec 17, 2020
21139f5
dead code
PankajBhojwani Dec 17, 2020
7079e60
remove unnecessary comment
PankajBhojwani Dec 17, 2020
1fc3e8b
format
PankajBhojwani Dec 17, 2020
5151a7f
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Dec 18, 2020
25b31d4
conflicts
PankajBhojwani Dec 18, 2020
811f796
changing base branch conflicts
PankajBhojwani Dec 18, 2020
bd6fc9f
updates to get it working again after merge
PankajBhojwani Dec 18, 2020
363307b
AppearanceConfig -> IAppearanceConfig
PankajBhojwani Dec 18, 2020
155f522
pass unfocused appearance as another IControlSettings
PankajBhojwani Dec 19, 2020
d45439f
remove app appearance config
PankajBhojwani Dec 21, 2020
b3aa5dc
remove another reference
PankajBhojwani Dec 21, 2020
e241ade
remove IControlAppearance object from IControlSettings
PankajBhojwani Dec 21, 2020
7509ed0
newline
PankajBhojwani Dec 21, 2020
e27a359
ok
PankajBhojwani Dec 21, 2020
8d2c583
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Jan 4, 2021
a288001
pragma warning
PankajBhojwani Jan 4, 2021
ceb1d00
conflict
PankajBhojwani Jan 4, 2021
b57ee23
color table fix
PankajBhojwani Jan 5, 2021
6ac4249
remove import
PankajBhojwani Jan 8, 2021
ab36124
fix comment
PankajBhojwani Jan 8, 2021
f5974b3
conflict
PankajBhojwani Jan 15, 2021
b9ef9f1
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Jan 22, 2021
fb63251
conflict
PankajBhojwani Jan 22, 2021
ae81a4a
conflicts
PankajBhojwani Feb 8, 2021
422a785
rename unfocusedConfig to unfocusedAppearance
PankajBhojwani Feb 8, 2021
37b219a
update test
PankajBhojwani Feb 9, 2021
d150eda
cursor height
PankajBhojwani Feb 9, 2021
2cbcd75
implement to json and copy appearance
PankajBhojwani Feb 10, 2021
e08fabe
copy settings and tojson
PankajBhojwani Feb 11, 2021
8e5522e
const, has value
PankajBhojwani Feb 12, 2021
4f63f8d
copy appearance works now
PankajBhojwani Feb 12, 2021
e106314
Merge branch 'main' of https://github.com/microsoft/terminal into dev…
PankajBhojwani Feb 17, 2021
4bbc653
fix conflicts
PankajBhojwani Feb 26, 2021
bfabaec
update macro
PankajBhojwani Feb 26, 2021
99132d2
address comments
PankajBhojwani Feb 26, 2021
8d577c0
fix tests
PankajBhojwani Mar 1, 2021
9ca0773
abstract
PankajBhojwani Mar 2, 2021
1d126e8
const
PankajBhojwani Mar 4, 2021
acec746
decltype comment
PankajBhojwani Mar 4, 2021
10641af
first step for default appearance
PankajBhojwani Mar 8, 2021
309f449
aaaa
PankajBhojwani Mar 12, 2021
32dc8c6
okay just some cleanup left I think
PankajBhojwani Mar 12, 2021
77db627
merge main, fix conflict
PankajBhojwani Mar 15, 2021
4d1cdc9
?
PankajBhojwani Mar 15, 2021
b0cbf66
pending discussion
PankajBhojwani Mar 16, 2021
0d62955
build settings does the work
PankajBhojwani Mar 16, 2021
f64646e
fix tests
PankajBhojwani Mar 16, 2021
c7803be
still gotta fix conflicts
PankajBhojwani Mar 17, 2021
79d3d3c
struct added
PankajBhojwani Mar 18, 2021
42ac24c
struct
PankajBhojwani Mar 19, 2021
c6b72b4
fix update settings
PankajBhojwani Mar 19, 2021
45447e1
conflict
PankajBhojwani Mar 19, 2021
521e0f0
naming conflicts
PankajBhojwani Mar 19, 2021
282dfec
retro and pixel to appearance
PankajBhojwani Mar 19, 2021
e857304
format
PankajBhojwani Mar 19, 2021
95ab9af
nits
PankajBhojwani Mar 23, 2021
5c11434
deduplicate
PankajBhojwani Mar 23, 2021
edc0fbe
validate
PankajBhojwani Mar 23, 2021
d1335d1
oops
PankajBhojwani Mar 23, 2021
12f2ff9
cleanup
PankajBhojwani Mar 23, 2021
41f6c7c
Merge remote-tracking branch 'origin/dev/pabhoj/unfocused_pane' into …
zadjii-msft Mar 25, 2021
fe5f3ab
This creates an infinite loop, where the new child is accidentally se…
zadjii-msft Mar 25, 2021
330a8e8
:chef_kiss:
zadjii-msft Mar 25, 2021
13285c2
This makes me a little sad, but very happy that this works so well
zadjii-msft Mar 25, 2021
a038cff
Add comments throughout
zadjii-msft Mar 25, 2021
544b2fd
Merge branch 'main' into dev/migrie/preview-setcolorscheme
zadjii-msft Apr 13, 2021
d4a868e
I'm actually leagally obligated to have a typo in every commit
zadjii-msft Apr 13, 2021
4fcf312
Add the GH link that @miniska wanted
zadjii-msft Apr 14, 2021
c6da925
Smaller nits from the review
zadjii-msft Apr 15, 2021
7848d31
Start writing tests for previewing
zadjii-msft Apr 19, 2021
cf2105c
Merge remote-tracking branch 'origin/main' into dev/migrie/preview-se…
zadjii-msft Apr 19, 2021
d8383e0
Add unit tests
zadjii-msft Apr 19, 2021
af1fb27
spel
zadjii-msft Apr 21, 2021
c2e6172
Merge remote-tracking branch 'origin/main' into dev/migrie/preview-se…
zadjii-msft Apr 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
330 changes: 330 additions & 0 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ namespace TerminalAppLocalTests
TEST_METHOD(TestWindowRenameSuccessful);
TEST_METHOD(TestWindowRenameFailure);

TEST_METHOD(TestControlSettingsHasParent);
TEST_METHOD(TestPreviewCommitScheme);
TEST_METHOD(TestPreviewDismissScheme);
TEST_METHOD(TestPreviewSchemeWhilePreviewing);

TEST_CLASS_SETUP(ClassSetup)
{
return true;
Expand Down Expand Up @@ -578,6 +583,75 @@ namespace TerminalAppLocalTests
"tabTitle" : "Profile 3",
"historySize": 4
}
],
"schemes":
[
{
"name": "Campbell",
"foreground": "#CCCCCC",
"background": "#0C0C0C",
"cursorColor": "#FFFFFF",
"black": "#0C0C0C",
"red": "#C50F1F",
"green": "#13A10E",
"yellow": "#C19C00",
"blue": "#0037DA",
"purple": "#881798",
"cyan": "#3A96DD",
"white": "#CCCCCC",
"brightBlack": "#767676",
"brightRed": "#E74856",
"brightGreen": "#16C60C",
"brightYellow": "#F9F1A5",
"brightBlue": "#3B78FF",
"brightPurple": "#B4009E",
"brightCyan": "#61D6D6",
"brightWhite": "#F2F2F2"
},
{
"name": "Vintage",
"foreground": "#C0C0C0",
"background": "#000000",
"cursorColor": "#FFFFFF",
"black": "#000000",
"red": "#800000",
"green": "#008000",
"yellow": "#808000",
"blue": "#000080",
"purple": "#800080",
"cyan": "#008080",
"white": "#C0C0C0",
"brightBlack": "#808080",
"brightRed": "#FF0000",
"brightGreen": "#00FF00",
"brightYellow": "#FFFF00",
"brightBlue": "#0000FF",
"brightPurple": "#FF00FF",
"brightCyan": "#00FFFF",
"brightWhite": "#FFFFFF"
},
{
"name": "One Half Light",
"foreground": "#383A42",
"background": "#FAFAFA",
"cursorColor": "#4F525D",
"black": "#383A42",
"red": "#E45649",
"green": "#50A14F",
"yellow": "#C18301",
"blue": "#0184BC",
"purple": "#A626A4",
"cyan": "#0997B3",
"white": "#FAFAFA",
"brightBlack": "#4F525D",
"brightRed": "#DF6C75",
"brightGreen": "#98C379",
"brightYellow": "#E4C07A",
"brightBlue": "#61AFEF",
"brightPurple": "#C577DD",
"brightCyan": "#56B5C1",
"brightWhite": "#FFFFFF"
}
]
})" };

Expand Down Expand Up @@ -1012,4 +1086,260 @@ namespace TerminalAppLocalTests
L"The window name should not have changed, we should have rejected the change.");
});
}

void TabTests::TestControlSettingsHasParent()
{
Log::Comment(L"Ensure that when we create a control, it always has a parent TerminalSettings");

auto page = _commonSetup();
VERIFY_IS_NOT_NULL(page);

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);
});
}

void TabTests::TestPreviewCommitScheme()
{
Log::Comment(L"Preview a color scheme. Make sure it's applied, then committed accordingly");

auto page = _commonSetup();
VERIFY_IS_NOT_NULL(page);

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate previewing the SetColorScheme action");
SetColorSchemeArgs args{ L"Vintage" };
page->_PreviewColorScheme(args);
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& previewSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(previewSettings);

const auto& originalSettings = previewSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(originalSettings, page->_originalSettings);
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate committing the SetColorScheme action");

SetColorSchemeArgs args{ L"Vintage" };
page->_EndPreviewColorScheme();
page->_HandleSetColorScheme(nullptr, ActionEventArgs{ args });
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

const auto& grandparentSettings = originalSettings.GetParent();
VERIFY_IS_NULL(grandparentSettings);

Log::Comment(L"Color should be changed");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(nullptr, page->_originalSettings);
});
}

void TabTests::TestPreviewDismissScheme()
{
Log::Comment(L"Preview a color scheme. Make sure it's applied, then dismissed accordingly");

auto page = _commonSetup();
VERIFY_IS_NOT_NULL(page);

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate previewing the SetColorScheme action");
SetColorSchemeArgs args{ L"Vintage" };
page->_PreviewColorScheme(args);
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& previewSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(previewSettings);

const auto& originalSettings = previewSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(originalSettings, page->_originalSettings);
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate dismissing the SetColorScheme action");
page->_EndPreviewColorScheme();
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

const auto& grandparentSettings = originalSettings.GetParent();
VERIFY_IS_NULL(grandparentSettings);

Log::Comment(L"Color should be the same as it originally was");
VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(nullptr, page->_originalSettings);
});
}

void TabTests::TestPreviewSchemeWhilePreviewing()
{
Log::Comment(L"Preview a color scheme, then preview another scheme. ");

Log::Comment(L"Preview a color scheme. Make sure it's applied, then committed accordingly");

auto page = _commonSetup();
VERIFY_IS_NOT_NULL(page);

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

VERIFY_ARE_EQUAL(til::color{ 0xff0c0c0c }, controlSettings.DefaultBackground());
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate previewing the SetColorScheme action");
SetColorSchemeArgs args{ L"Vintage" };
page->_PreviewColorScheme(args);
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& previewSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(previewSettings);

const auto& originalSettings = previewSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xff000000 }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(originalSettings, page->_originalSettings);
});

TestOnUIThread([&page]() {
Log::Comment(L"Now, preview another scheme");
SetColorSchemeArgs args{ L"One Half Light" };
page->_PreviewColorScheme(args);
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& previewSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(previewSettings);

const auto& originalSettings = previewSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

Log::Comment(L"Color should be changed to the preview");
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(originalSettings, page->_originalSettings);
});

TestOnUIThread([&page]() {
Log::Comment(L"Emulate committing the SetColorScheme action");

SetColorSchemeArgs args{ L"One Half Light" };
page->_EndPreviewColorScheme();
page->_HandleSetColorScheme(nullptr, ActionEventArgs{ args });
});

TestOnUIThread([&page]() {
const auto& activeControl{ page->_GetActiveControl() };
VERIFY_IS_NOT_NULL(activeControl);

const auto& controlSettings = activeControl.Settings().as<TerminalSettings>();
VERIFY_IS_NOT_NULL(controlSettings);

const auto& originalSettings = controlSettings.GetParent();
VERIFY_IS_NOT_NULL(originalSettings);

const auto& grandparentSettings = originalSettings.GetParent();
VERIFY_IS_NULL(grandparentSettings);

Log::Comment(L"Color should be changed");
VERIFY_ARE_EQUAL(til::color{ 0xffFAFAFA }, controlSettings.DefaultBackground());
VERIFY_ARE_EQUAL(nullptr, page->_originalSettings);
});
}

}
Loading