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

Introduce TerminalSettingsModel project #7667

Merged
merged 11 commits into from
Oct 6, 2020

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Sep 18, 2020

Introduces a new TerminalSettingsModel (TSM) project. This project is
responsible for (de)serializing and exposing Windows Terminal's settings
as WinRT objects.

References

#885: TSM epic
#1564: Settings UI is dependent on this for data binding and settings access
#6904: TSM Spec

In the process of ripping out TSM from TerminalApp, a few other changes
were made to make this possible:

  1. AppLogic's ApplicationDisplayName and ApplicationVersion was
    moved to CascadiaSettings
    • These are defined as static functions. They also no longer check if
      AppLogic::Current() is nullptr.
  2. enum LaunchMode was moved from TerminalApp to TSM
  3. AzureConnectionType and TelnetConnectionType were moved from the
    profile generators to their respective TerminalConnections
  4. CascadiaSettings' SettingsPath and DefaultSettingsPath are
    exposed as hstring instead of std::filesystem::path
  5. Command::ExpandCommands() was exposed via the IDL
    • This required some of the warnings to be saved to an IVector
      instead of std::vector, among some other small changes.
  6. The localization resources had to be split into two halves.
    • Resource file linked in init.cpp. Verified at runtime thanks to the
      StaticResourceLoader.
  7. Added constructors to some ActionArgs
  8. Utils.h/cpp were moved to cascadia/inc. JsonKey() was moved to
    JsonUtils. Both TermApp and TSM need access to Utils.h/cpp.

A large amount of work includes moving to the new namespace
(TerminalApp --> Microsoft::Terminal::Settings::Model).

Fixing the tests had its own complications. Testing required us to split
up TSM into a DLL and LIB, similar to TermApp. Discussion on creating a
non-local test variant can be found in #7743.

Closes #885

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Scenario Product-Terminal The new Windows Terminal. labels Sep 18, 2020
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/terminal-settings-model branch from 183cff4 to 99d3d4c Compare September 18, 2020 05:41
@carlos-zamora
Copy link
Member Author

carlos-zamora commented Sep 18, 2020

Note for Reviewers

This PR is still in draft because I need to fix all of the tests. That shouldn't be too difficult. Aside from that, this PR is ready to go!

EDIT: Since the tests need access to the implementation types, I'll have to break up TSM into 2 projects: TSM and TSMLib.

Copy link
Contributor

@leonMSFT leonMSFT left a comment

Choose a reason for hiding this comment

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

I'm curious about what you said about how the "localization resources had to be split into two halves".

  1. I took a look at init.cpp but wasn't quite sure how it's linking the resource file, could you briefly explain?
  2. What if TerminalSettingsEditor also needed to have its own localization resources, would it have to do something similar?

src/cascadia/TerminalApp/TerminalPage.cpp Show resolved Hide resolved
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{CA5CAD1A-d7ec-4107-b7c6-79cb77ae2907}</ProjectGuid>
Copy link
Member

Choose a reason for hiding this comment

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

i hope this is unique.

Copy link
Member Author

Choose a reason for hiding this comment

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

This used to be TerminalSettings' guid. Is that a problem?

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

96/102

src/cascadia/TerminalSettingsModel/pch.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/init.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/Profile.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/KeyMapping.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/KeyChordSerialization.h Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/ActionArgs.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Tab.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppLogic.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppCommandlineArgs.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 18, 2020
@carlos-zamora carlos-zamora marked this pull request as ready for review September 25, 2020 22:41
@carlos-zamora carlos-zamora force-pushed the dev/cazamor/set/terminal-settings-model branch from 14f405c to 99b126c Compare September 25, 2020 22:43
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.

Okay, I'm done with all 133 in this PR, and my only concern is over the same utils.cpp thing Dustin brought up

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

hitting submit b/c queued comments?

@carlos-zamora
Copy link
Member Author

carlos-zamora commented Sep 29, 2020

Changes for the next commit(s):

  • Try to kill JsonKey (or move to JsonUtils)
  • Move VisualizeControlCodes into TIL
  • Refactor Command to expose icon like Profile does (loading image happens outside of settings model)

@carlos-zamora
Copy link
Member Author

carlos-zamora commented Sep 30, 2020

  • Try to kill JsonKey (or move to JsonUtils)

Oh...I already had it in JsonUtils.

  • Move VisualizeControlCodes into TIL

Moved and added a test. Had to remove a noexcept because of audit mode.

  • Refactor Command to expose icon like Profile does (loading image happens outside of settings model)

CommandPalette data binds itself to the IconSource of Command. Refactoring such that that isn't that case felt a bit more risky than I'd like it to be for this PR. I still moved RefreshIcon() from Command into TerminalPage, which should be good enough tbh. I'll open a follow-up item if you feel strongly about this though.

EDIT: yeah, that needs to happen. Just a bit big for this PR. Filed #7784 as a follow-up.

src/cascadia/LocalTests_TerminalApp/TabTests.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/Profile.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/ColorScheme.h Outdated Show resolved Hide resolved
{
struct KeyChordSerialization
{
KeyChordSerialization() = default;
Copy link
Member

Choose a reason for hiding this comment

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

I don't recall this conversation coming to a close. Did you try it without both the factory and the default ctor? There must be a way to do this.,

src/cascadia/TerminalSettingsModel/dll/pch.h Outdated Show resolved Hide resolved
@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 1, 2020
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 2, 2020
@carlos-zamora
Copy link
Member Author

Urgh. Technically, y'all should be reading/merging #6904 first. So go read that * grumble *

@carlos-zamora carlos-zamora mentioned this pull request Oct 5, 2020
3 tasks
@carlos-zamora carlos-zamora merged commit 2608e94 into master Oct 6, 2020
@carlos-zamora carlos-zamora deleted the dev/cazamor/set/terminal-settings-model branch October 6, 2020 16:57
@carlos-zamora carlos-zamora restored the dev/cazamor/set/terminal-settings-model branch October 6, 2020 16:57
@carlos-zamora carlos-zamora deleted the dev/cazamor/set/terminal-settings-model branch October 6, 2020 16:57
carlos-zamora added a commit that referenced this pull request Oct 8, 2020
#7796 and #7667 were being implemented concurrently. As a part of #7667, Command was moved from TermApp to TSM. This just applies that change to a line we missed in #7796 and fixes the build break.
carlos-zamora added a commit that referenced this pull request Oct 8, 2020
## Summary of the Pull Request
Introduce the `IconPathConverter` to `TerminalApp`. `Command` and `Profile` now both return the unexpanded icon path. `IconPathConverter` is responsible for expanding the icon path and retrieving the appropriate icon source.

This also removes `Profile`'s expanded icon path and uses the `IconPathConverter` when necessary. This allows users to set profile icons to emoji as well. However, emoji do not appear in the jumplist.

## References
Based on #7667 

## PR Checklist
* [X] Closes #7784 
* [x] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [x] Schema updated.

## Validation Steps Performed
Deploy succeeded.
skyline75489 pushed a commit to skyline75489/terminal that referenced this pull request Oct 10, 2020
microsoft#7796 and microsoft#7667 were being implemented concurrently. As a part of microsoft#7667, Command was moved from TermApp to TSM. This just applies that change to a line we missed in microsoft#7796 and fixes the build break.
skyline75489 pushed a commit to skyline75489/terminal that referenced this pull request Oct 10, 2020
## Summary of the Pull Request
Introduce the `IconPathConverter` to `TerminalApp`. `Command` and `Profile` now both return the unexpanded icon path. `IconPathConverter` is responsible for expanding the icon path and retrieving the appropriate icon source.

This also removes `Profile`'s expanded icon path and uses the `IconPathConverter` when necessary. This allows users to set profile icons to emoji as well. However, emoji do not appear in the jumplist.

## References
Based on microsoft#7667 

## PR Checklist
* [X] Closes microsoft#7784 
* [x] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx
* [x] Schema updated.

## Validation Steps Performed
Deploy succeeded.
carlos-zamora added a commit that referenced this pull request Oct 16, 2020
## Summary of the Pull Request
This implements the `Copy` function for `CascadiaSettings`. Copy performs a deep copy of a `CascadiaSettings` object. This is needed for data binding in the Terminal Settings Editor.

The `Copy` function was basically implemented in every settings model object. This was mostly just repetitive work.

## References
#7667 - TSM
#1564 - Settings UI

## PR Checklist
* [X] Tests added/passed
@ghost
Copy link

ghost commented Nov 11, 2020

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

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Scenario Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace TerminalSettings runtimeclasses with interfaces only
4 participants