Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev/migrie/f/996-zo…
Browse files Browse the repository at this point in the history
…om-zoom
  • Loading branch information
zadjii-msft committed Aug 5, 2020
2 parents 582880e + cd72356 commit 7becdb4
Show file tree
Hide file tree
Showing 62 changed files with 775 additions and 233 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spell-check/dictionary/apis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ IObject
IStorage
llabs
LCID
lround
LSHIFT
NCHITTEST
NCLBUTTONDBLCLK
Expand All @@ -31,6 +32,8 @@ NOAGGREGATION
NOREDIRECTIONBITMAP
oaidl
ocidl
otms
OUTLINETEXTMETRICW
PAGESCROLL
RETURNCMD
rfind
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
author: Mike Griese @zadjii-msft
created on: 2020-07-31
last updated: 2020-08-03
issue id: #1337
---
# Per-Profile Tab Colors

## Abstract

This spec describes a way to specify tab colors in a profile in a way that will
be forward compatible with theming the Terminal. This spec will be largely
dedicated to the design of a single setting, but within the context of theming.

## Inspiration

Following the addition of the Tab Color Picker in [#3789], we've had numerous
requests for the ability to set the color of a tab directly within a profile.
While largely we're tracking theming in [#3327], including the specification of
a tab color, the theming spec ([#5772] )is very large and will take a while to
revise and approve. This spec is intended to pull a single point out from that
spec to make it more easily reviewable, and implement it in a way that will
continue working when we add support for themes in the future.

## Solution Design

To enable per-profile tab colors, we'll add a single setting: `tabColor`. For
now<sup>[[1](#user-content-footnote-1)]</sup>, this setting will accept any
`#rrggbb` color string.

Since each profile creates a `Pane` with a `TermControl`, we'll need to store
this color not in the `Tab`, but somewhere below `Pane`, so that when you switch
between Panes in a tab with different `tabColor`s, the color will update
automatically. When a new `TermControl` is created, we'll store this color in the
`TermControl`'s `Terminal` core. This is to support the future possibility of
setting the tab color via VT sequences.

A Tab's color will be the result of layering a variety of sources, from the bottom up:

Color | | Set by
-- | -- | --
Runtime Color | _optional_ |Color Picker / `setTabColor` action
Control Tab Color | _optional_ | Profile's `tabColor`, or a color set by VT
Theme Tab Background | _optional_ | `tab.backgroundColor` in the theme
Tab Default Color | **default** | TabView in XAML

Some examples:
* **Scenario 1**: The user has set `"tabColor": "#ff0000"` in their profile.
When they create tabs with that profile, instead of appearing in the default
color for the TabView, they'll be `#ff0000`.
* **Scenario 2**: The user has set `"tabColor": "#ff0000"` in their profile.
When they try to set the color for that tab (with the color picker) to
`#0000ff`, the tab's color is updated to reflect this new blue color. When
they clear the runtime color (with the color picker), the tab will return to
`#ff0000`.
* **Scenario 3**: The user has two profiles with colors set, one to `"tabColor":
"#ff0000"`, and the other with `"tabColor": "#00ff00"`. If they open these
profiles in two panes side-by side, the tab's color will update to reflect the
color from the currently-focused control.
* **Scenario 4**: The user has two profiles with colors set, one to `"tabColor":
"#ff0000"`, and the other with `"tabColor": "#00ff00"`. If they open these
profiles in two panes side-by side, and try to set the color for that tab
(with the color picker) to `#0000ff`, the tab's color is updated to reflect
this new blue color. Regardless of which pane is focused, the tab will be
blue.
* **Scenario 5**: The user has set `"tabColor": "#ff0000"` in their profile
("Profile A"), and `"tab.backgroundColor": "#00ff00"`in their theme. When they
create tabs with "Profile A", the tabs will appear red. Other tabs (for
profiles without `tabColor` set) will appear green, using the color from the
theme.


## UI/UX Design

In general, this is going to look exactly like the colored tabs look now.

![preview](profile-tabColor-000.gif)

## Capabilities

<table>
<tr>
<td><strong>Accessibility</strong></td>
<td>
N/A
</td>
</tr>
<tr>
<td><strong>Security</strong></td>
<td>
N/A
</td>
</tr>
<tr>
<td><strong>Reliability</strong></td>
<td>
No expected change
</td>
</tr>
<tr>
<td><strong>Compatibility</strong></td>
<td>
This entire spec outlines how this feature is designed with a emphasis on future
compatibility. As such, there are no expected regressions in the future when we
do add support for themes.
</td>
</tr>
<tr>
<td><strong>Performance, Power, and Efficiency</strong></td>
<td>
No expected change
</td>
</tr>
</table>

## Potential Issues

None expected.

## Footnotes

<a id="footnote-1"><a>[1]: When full theming support is added, themes will
provide support for setting colors as one of a variety of values:

* An `#rrggbb` string
* The system accent color
* The current background color of the Terminal
* A value from a given resource key from XAML

When support for these other types of "smart" colors is added, then the profile
`tabColor` setting will also gracefully accept these values.

## Future considerations

* It's not out of the realm of possibility that someone might want to color each
_pane_'s color at runtime. In that case, the runtime color would be stored in
the `Pane`, not the `Tab`.



<!-- Footnotes -->

[#1337]: https://github.com/microsoft/terminal/issues/1337
[#3789]: https://github.com/microsoft/terminal/issues/3789
[#3327]: https://github.com/microsoft/terminal/issues/3327
[#5772]: https://github.com/microsoft/terminal/pull/5772
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions src/buffer/out/TextAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ bool TextAttribute::IsCrossedOut() const noexcept

bool TextAttribute::IsUnderlined() const noexcept
{
// TODO:GH#2915 Treat underline separately from LVB_UNDERSCORE
return WI_IsFlagSet(_wAttrLegacy, COMMON_LVB_UNDERSCORE);
return WI_IsFlagSet(_extendedAttrs, ExtendedAttributes::Underlined);
}

bool TextAttribute::IsOverlined() const noexcept
Expand Down Expand Up @@ -292,8 +291,7 @@ void TextAttribute::SetCrossedOut(bool isCrossedOut) noexcept

void TextAttribute::SetUnderlined(bool isUnderlined) noexcept
{
// TODO:GH#2915 Treat underline separately from LVB_UNDERSCORE
WI_UpdateFlag(_wAttrLegacy, COMMON_LVB_UNDERSCORE, isUnderlined);
WI_UpdateFlag(_extendedAttrs, ExtendedAttributes::Underlined, isUnderlined);
}

void TextAttribute::SetOverlined(bool isOverlined) noexcept
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace TerminalAppLocalTests

void SettingsTests::TryCreateWinRTType()
{
winrt::Microsoft::Terminal::Settings::TerminalSettings settings;
TerminalSettings settings;
VERIFY_IS_NOT_NULL(settings);
auto oldFontSize = settings.FontSize();
settings.FontSize(oldFontSize + 5);
Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/LocalTests_TerminalApp/TabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace TerminalAppLocalTests
{
// Verify we can create a WinRT type we authored
// Just creating it is enough to know that everything is working.
winrt::Microsoft::Terminal::Settings::TerminalSettings settings;
TerminalSettings settings;
VERIFY_IS_NOT_NULL(settings);
auto oldFontSize = settings.FontSize();
settings.FontSize(oldFontSize + 5);
Expand Down Expand Up @@ -140,7 +140,7 @@ namespace TerminalAppLocalTests
// 4. one of our types that uses MUX/Xaml in this dll (Tab).
// Just creating all of them is enough to know that everything is working.
const auto profileGuid{ Utils::CreateGuid() };
winrt::Microsoft::Terminal::Settings::TerminalSettings settings{};
TerminalSettings settings{};
VERIFY_IS_NOT_NULL(settings);
winrt::Microsoft::Terminal::TerminalConnection::EchoConnection conn{};
VERIFY_IS_NOT_NULL(conn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestExecutor.WinRTCore">
<HintPath>$(OpenConsoleDir)\packages\Taef.Redist.Wlk.10.51.200127004\lib\Microsoft.VisualStudio.TestPlatform.TestExecutor.WinRTCore.winmd</HintPath>
<HintPath>$(OpenConsoleDir)\packages\Taef.Redist.Wlk.10.57.200731005-develop\lib\Microsoft.VisualStudio.TestPlatform.TestExecutor.WinRTCore.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>

<!-- This path is _relative to the .winmd_ -->
Expand Down
Loading

1 comment on commit 7becdb4

@github-actions

This comment was marked as resolved.

Please sign in to comment.