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

Separate runtime TerminalSettings from profile-TerminalSettings #8602

Merged
19 commits merged into from
Feb 8, 2021

Conversation

PankajBhojwani
Copy link
Contributor

Summary of the Pull Request

The TerminalSettings object we create from profiles no longer gets passed into the control, instead, a child of that object gets passed into the control. Any overrides the control makes to the settings then live in the child. So, when we do a settings reload, we simply update the child's parent and the overrides will remain.

PR Checklist

  • Closes #xxx
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I work here

Validation Steps Performed

Manual testing

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really cool!

src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
@DHowett
Copy link
Member

DHowett commented Dec 24, 2020

It's weird -- I'm running a build of this with default settings (like, I cleared my app settings) and all my colors are black. Indicates the color table is all 0s.

@@ -15,6 +15,7 @@ Author(s):
#pragma once

#include "TerminalSettings.g.h"
#include "../TerminalSettingsModel/IInheritable.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is a much larger discussion that doesn't have to be implemented as a part of this PR. So really I'm thinking out loud.)
I'm wondering if we should move TerminalSettings over to TerminalSettingsModel. Hear me out:

  • if we're making TerminalSettings IInheritable, might as well move TerminalSettings over to TSM. It's a bit weird for us to grab this random file from a separate project, right? haha
  • With regards to creating a TermControl preview in Settings UI...
    • I hit a problem today. TSE cannot depend on TermApp because that'd create a circular dependency (TermApp <--> TSE). So I tried making it so that TSE builds a TerminalSettings by firing an event to TermApp, but then TermApp would need to somehow get the synthesized TerminalSettings object down to the profile page and update on each change. Having TerminalSettings be its own project or a part of TSM makes it it so much easier to construct TerminalSettings and just have one readily available for a TermControl preview.

What do you think?

CC @DHowett for thoughts on this matter too. I might just be approaching the two things above completely wrong haha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have a point here (but it should probably be a follow up)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping this thread for @DHowett because this is important for the terminal preview in SUI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Chatted in meeting.)

@PankajBhojwani
Copy link
Contributor Author

PankajBhojwani commented Jan 5, 2021

It's weird -- I'm running a build of this with default settings (like, I cleared my app settings) and all my colors are black. Indicates the color table is all 0s.

Fixed with latest push - I did need to implement a separate macro to implement an array setting though (if you try GETSET_SETTING(std::array<uint32_t, 16>, ColorTable) for example, the macro thinks that "16" is the name of the setting instead of "ColorTable")

@zadjii-msft
Copy link
Member

@msftbot wait 8 hours before merging this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 8, 2021
@ghost
Copy link

ghost commented Jan 8, 2021

Hello @zadjii-msft!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Fri, 08 Jan 2021 21:52:53 GMT, which is in 8 hours

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know, I was about to sign off on this, but now I'm all worried about the copying of the array, and I think it's best if we let Dustin or Michael be the second on it

src/cascadia/TerminalApp/Pane.cpp Show resolved Hide resolved
@@ -15,6 +15,7 @@ Author(s):
#pragma once

#include "TerminalSettings.g.h"
#include "../TerminalSettingsModel/IInheritable.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have a point here (but it should probably be a follow up)

\
private: \
std::optional<std::array<type, size>> _##name{ std::nullopt }; \
std::optional<std::array<type, size>> _get##name##Impl() const \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanna make sure Dustin takes a look at the template magic going on in this macro. An optional<array<T>> seems to make sense to me, but there might be weird template quirks I'm missing.

/*iterate through parents to find a value*/ \
for (auto parent : _parents) \
{ \
if (auto val{ parent->_get##name##Impl() }) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically this bit I'm worried about - are we returning a copy of the parent's result?

@DHowett
Copy link
Member

DHowett commented Feb 5, 2021

Touching to say we had a discussion about doing the array without copies.

@DHowett DHowett assigned PankajBhojwani and unassigned DHowett and miniksa Feb 5, 2021
@@ -12,6 +12,25 @@ using namespace winrt::Microsoft::Terminal::Settings::Model;

namespace winrt::TerminalApp::implementation
{
static constexpr std::array<til::color, 16> campbellColorTable{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use the one from Utils? Is it because it's a filler-style method?

Maybe we can just expose a function that returns it directly... as a gsl::span.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Really don't love the duplication)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't like the duplication either - will add a function to colorTable.hpp to expose the campbell color table

@@ -12,6 +12,25 @@ using namespace winrt::Microsoft::Terminal::Settings::Model;

namespace winrt::TerminalApp::implementation
{
static constexpr std::array<til::color, 16> campbellColorTable{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Really don't love the duplication)

// issues:
// - converting span to array without brute force?
// - campbellColorTable conversion from color to uint32
// - including colortable.cpp causes errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't import cpp files, like... ever. 😄

@ghost ghost merged commit 9047bbb into main Feb 8, 2021
@ghost ghost deleted the dev/pabhoj/terminal_settings branch February 8, 2021 22:01
#include <DefaultSettings.h>
#include <conattrs.hpp>

using namespace Microsoft::Console::Utils;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh can you put out a PR that deletes this? we should never put a using in a header.

/cc @carlos-zamora @zadjii-msft 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, only the cpp file needs to know about colorTable.hpp and the using block, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry my bad, made a PR to fix it

DHowett pushed a commit that referenced this pull request Feb 9, 2021
There was a mistake in #8602, this change fixes that.
(`using` and `include` moved to cpp file)
DHowett pushed a commit that referenced this pull request Feb 25, 2021
In #8602, we started passing a child of the `TerminalSettings` to the
control upon tab initialization, but forgot to do the same when new
controls get created on a pane split. 

## Validation Steps Performed
Settings reload with multiple panes works

Closes #9280
DHowett pushed a commit that referenced this pull request Feb 25, 2021
In #8602, we started passing a child of the `TerminalSettings` to the
control upon tab initialization, but forgot to do the same when new
controls get created on a pane split.

## Validation Steps Performed
Settings reload with multiple panes works

Closes #9280

(cherry picked from commit a930aa3)
@ghost
Copy link

ghost commented Mar 1, 2021

🎉Windows Terminal Preview v1.7.572.0 has been released which incorporates this pull request.:tada:

Handy links:

ghost pushed a commit that referenced this pull request Mar 12, 2021
Since #8602 merged, we need to pass a child of the settings object to
the TermControl upon initializing it. Since this happens in a few places
in `TerminalPage`, its probably best to use a helper. 

Closes #9292
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants