Skip to content

Commit bb4c73c

Browse files
authored
Add support for compact tab sizing (#5787)
## Summary of the Pull Request Really couldn't be more starightforward. MUX 2.4 added support for "compact" sized tabs. This PR (targeting the 2.4 PR currently, will move to `master` when that merges) enables users to specify `"tabWidthMode": "compact"` in their global settings to get this behavior. ## References * #5778 - PR to move to MUX 2.4 * [microsoft-ui-xaml#2016](microsoft/microsoft-ui-xaml#2016) - the MUX PR for compact tab sizing. * #597 - Tab sizing options? ## PR Checklist * [x] I don't think we have an issue for this, though I could be wrong. * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments In this screenshot, I'm hovering over tab 2, but the ubuntu tab is focused: ![image](https://user-images.githubusercontent.com/18356694/81302365-e6ef4000-903f-11ea-9ce3-5f5ce92e5ba4.png) In this screenshot, tab 2 is focused: ![image](https://user-images.githubusercontent.com/18356694/81302383-ea82c700-903f-11ea-9820-92348d5adc64.png)
1 parent c3ea731 commit bb4c73c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

doc/cascadia/SettingsSchema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Properties listed below affect the entire window, regardless of the profile sett
1919
| `showTerminalTitleInTitlebar` | _Required_ | Boolean | `true` | When set to `true`, titlebar displays the title of the selected tab. When set to `false`, titlebar displays "Windows Terminal". |
2020
| `showTabsInTitlebar` | Optional | Boolean | `true` | When set to `true`, the tabs are moved into the titlebar and the titlebar disappears. When set to `false`, the titlebar sits above the tabs. |
2121
| `snapToGridOnResize` | Optional | Boolean | `false` | When set to `true`, the window will snap to the nearest character boundary on resize. When `false`, the window will resize "smoothly" |
22-
| `tabWidthMode` | Optional | String | `equal` | Sets the width of the tabs. Possible values: `"equal"`, `"titleLength"` |
22+
| `tabWidthMode` | Optional | String | `equal` | Sets the width of the tabs. Possible values: <br><ul><li>`"equal"`: sizes each tab to the same width</li><li>`"titleLength"`: sizes each tab to the length of its title</li><li>`"compact"`: sizes each tab to the length of its title when focused, and shrinks to the size of only the icon when the tab is unfocused.</li></ul> |
2323
| `wordDelimiters` | Optional | String | <code>&nbsp;&#x2f;&#x5c;&#x28;&#x29;&#x22;&#x27;&#x2d;&#x3a;&#x2c;&#x2e;&#x3b;&#x3c;&#x3e;&#x7e;&#x21;&#x40;&#x23;&#x24;&#x25;&#x5e;&#x26;&#x2a;&#x7c;&#x2b;&#x3d;&#x5b;&#x5d;&#x7b;&#x7d;&#x7e;&#x3f;│</code><br>_(`` is `U+2502 BOX DRAWINGS LIGHT VERTICAL`)_ | Determines the delimiters used in a double click selection. |
2424
| `confirmCloseAllTabs` | Optional | Boolean | `true` | When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation. |
2525
| `startOnUserLogin` | Optional | Boolean | `false` | When set to `true` enables the launch of Windows Terminal at startup. Setting to `false` will disable the startup task entry. Note: if the Windows Terminal startup task entry is disabled either by org policy or by user action this setting will have no effect. |

doc/cascadia/profiles.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,9 @@
376376
},
377377
"tabWidthMode": {
378378
"default": "equal",
379-
"description": "Sets the width of the tabs. Possible values include:\n -\"equal\" sizes each tab to the same width\n -\"titleLength\" sizes each tab to the length of its title",
379+
"description": "Sets the width of the tabs. Possible values include:\n -\"equal\" sizes each tab to the same width\n -\"titleLength\" sizes each tab to the length of its title\n -\"compact\" sizes each tab to the length of its title when focused, and shrinks to the size of only the icon when the tab is unfocused.",
380380
"enum": [
381+
"compact",
381382
"equal",
382383
"titleLength"
383384
],

src/cascadia/TerminalApp/GlobalAppSettings.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,34 @@ static constexpr std::string_view InitialPositionKey{ "initialPosition" };
2727
static constexpr std::string_view ShowTitleInTitlebarKey{ "showTerminalTitleInTitlebar" };
2828
static constexpr std::string_view ThemeKey{ "theme" };
2929
static constexpr std::string_view TabWidthModeKey{ "tabWidthMode" };
30-
static constexpr std::wstring_view EqualTabWidthModeValue{ L"equal" };
31-
static constexpr std::wstring_view TitleLengthTabWidthModeValue{ L"titleLength" };
3230
static constexpr std::string_view ShowTabsInTitlebarKey{ "showTabsInTitlebar" };
3331
static constexpr std::string_view WordDelimitersKey{ "wordDelimiters" };
3432
static constexpr std::string_view CopyOnSelectKey{ "copyOnSelect" };
3533
static constexpr std::string_view CopyFormattingKey{ "copyFormatting" };
3634
static constexpr std::string_view LaunchModeKey{ "launchMode" };
3735
static constexpr std::string_view ConfirmCloseAllKey{ "confirmCloseAllTabs" };
3836
static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" };
37+
38+
static constexpr std::string_view DebugFeaturesKey{ "debugFeatures" };
39+
40+
static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.rendering.forceFullRepaint" };
41+
static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" };
42+
static constexpr std::string_view EnableStartupTaskKey{ "startOnUserLogin" };
43+
44+
// Launch mode values
3945
static constexpr std::wstring_view DefaultLaunchModeValue{ L"default" };
4046
static constexpr std::wstring_view MaximizedLaunchModeValue{ L"maximized" };
4147
static constexpr std::wstring_view FullscreenLaunchModeValue{ L"fullscreen" };
48+
49+
// Tab Width Mode values
50+
static constexpr std::wstring_view EqualTabWidthModeValue{ L"equal" };
51+
static constexpr std::wstring_view TitleLengthTabWidthModeValue{ L"titleLength" };
52+
static constexpr std::wstring_view TitleLengthCompactModeValue{ L"compact" };
53+
54+
// Theme values
4255
static constexpr std::wstring_view LightThemeValue{ L"light" };
4356
static constexpr std::wstring_view DarkThemeValue{ L"dark" };
4457
static constexpr std::wstring_view SystemThemeValue{ L"system" };
45-
static constexpr std::string_view EnableStartupTaskKey{ "startOnUserLogin" };
46-
47-
static constexpr std::string_view ForceFullRepaintRenderingKey{ "experimental.rendering.forceFullRepaint" };
48-
static constexpr std::string_view SoftwareRenderingKey{ "experimental.rendering.software" };
49-
50-
static constexpr std::string_view DebugFeaturesKey{ "debugFeatures" };
5158

5259
#ifdef _DEBUG
5360
static constexpr bool debugFeaturesDefault{ true };
@@ -322,6 +329,10 @@ TabViewWidthMode GlobalAppSettings::_ParseTabWidthMode(const std::wstring& tabWi
322329
{
323330
return TabViewWidthMode::SizeToContent;
324331
}
332+
else if (tabWidthModeString == TitleLengthCompactModeValue)
333+
{
334+
return TabViewWidthMode::Compact;
335+
}
325336
// default behavior for invalid data or EqualTabWidthValue
326337
return TabViewWidthMode::Equal;
327338
}

0 commit comments

Comments
 (0)