@@ -15,6 +15,7 @@ using namespace winrt::TerminalApp;
15
15
using namespace winrt ::Windows::Data::Json;
16
16
using namespace winrt ::Windows::UI::Xaml;
17
17
using namespace ::Microsoft::Console;
18
+ using namespace winrt ::Microsoft::UI::Xaml::Controls;
18
19
19
20
static constexpr std::string_view KeybindingsKey{ " keybindings" };
20
21
static constexpr std::string_view DefaultProfileKey{ " defaultProfile" };
@@ -25,6 +26,9 @@ static constexpr std::string_view RowsToScrollKey{ "rowsToScroll" };
25
26
static constexpr std::string_view InitialPositionKey{ " initialPosition" };
26
27
static constexpr std::string_view ShowTitleInTitlebarKey{ " showTerminalTitleInTitlebar" };
27
28
static constexpr std::string_view RequestedThemeKey{ " requestedTheme" };
29
+ 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" };
28
32
static constexpr std::string_view ShowTabsInTitlebarKey{ " showTabsInTitlebar" };
29
33
static constexpr std::string_view WordDelimitersKey{ " wordDelimiters" };
30
34
static constexpr std::string_view CopyOnSelectKey{ " copyOnSelect" };
@@ -49,6 +53,7 @@ GlobalAppSettings::GlobalAppSettings() :
49
53
_showTitleInTitlebar{ true },
50
54
_showTabsInTitlebar{ true },
51
55
_requestedTheme{ ElementTheme::Default },
56
+ _tabWidthMode{ TabViewWidthMode::Equal },
52
57
_wordDelimiters{ DEFAULT_WORD_DELIMITERS },
53
58
_copyOnSelect{ false },
54
59
_launchMode{ LaunchMode::DefaultMode }
@@ -114,6 +119,16 @@ void GlobalAppSettings::SetRequestedTheme(const ElementTheme requestedTheme) noe
114
119
_requestedTheme = requestedTheme;
115
120
}
116
121
122
+ TabViewWidthMode GlobalAppSettings::GetTabWidthMode () const noexcept
123
+ {
124
+ return _tabWidthMode;
125
+ }
126
+
127
+ void GlobalAppSettings::SetTabWidthMode (const TabViewWidthMode tabWidthMode)
128
+ {
129
+ _tabWidthMode = tabWidthMode;
130
+ }
131
+
117
132
std::wstring GlobalAppSettings::GetWordDelimiters () const noexcept
118
133
{
119
134
return _wordDelimiters;
@@ -206,6 +221,7 @@ Json::Value GlobalAppSettings::ToJson() const
206
221
jsonObject[JsonKey (CopyOnSelectKey)] = _copyOnSelect;
207
222
jsonObject[JsonKey (LaunchModeKey)] = winrt::to_string (_SerializeLaunchMode (_launchMode));
208
223
jsonObject[JsonKey (RequestedThemeKey)] = winrt::to_string (_SerializeTheme (_requestedTheme));
224
+ jsonObject[JsonKey (TabWidthModeKey)] = winrt::to_string (_SerializeTabWidthMode (_tabWidthMode));
209
225
jsonObject[JsonKey (KeybindingsKey)] = _keybindings->ToJson ();
210
226
jsonObject[JsonKey (SnapToGridOnResizeKey)] = _SnapToGridOnResize;
211
227
@@ -291,6 +307,11 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
291
307
_requestedTheme = _ParseTheme (GetWstringFromJson (requestedTheme));
292
308
}
293
309
310
+ if (auto tabWidthMode{ json[JsonKey (TabWidthModeKey)] })
311
+ {
312
+ _tabWidthMode = _ParseTabWidthMode (GetWstringFromJson (tabWidthMode));
313
+ }
314
+
294
315
if (auto keybindings{ json[JsonKey (KeybindingsKey)] })
295
316
{
296
317
_keybindings->LayerJson (keybindings);
@@ -454,6 +475,41 @@ std::wstring_view GlobalAppSettings::_SerializeLaunchMode(const LaunchMode launc
454
475
}
455
476
}
456
477
478
+ // Method Description:
479
+ // - Helper function for converting the user-specified tab width
480
+ // to a TabViewWidthMode enum value
481
+ // Arguments:
482
+ // - tabWidthModeString: The string value from the settings file to parse
483
+ // Return Value:
484
+ // - The corresponding enum value which maps to the string provided by the user
485
+ TabViewWidthMode GlobalAppSettings::_ParseTabWidthMode (const std::wstring& tabWidthModeString) noexcept
486
+ {
487
+ if (tabWidthModeString == TitleLengthTabWidthModeValue)
488
+ {
489
+ return TabViewWidthMode::SizeToContent;
490
+ }
491
+ // default behavior for invalid data or EqualTabWidthValue
492
+ return TabViewWidthMode::Equal;
493
+ }
494
+
495
+ // Method Description:
496
+ // - Helper function for converting a TabViewWidthMode to its corresponding string
497
+ // value.
498
+ // Arguments:
499
+ // - tabWidthMode: The enum value to convert to a string.
500
+ // Return Value:
501
+ // - The string value for the given TabWidthMode
502
+ std::wstring_view GlobalAppSettings::_SerializeTabWidthMode (const TabViewWidthMode tabWidthMode) noexcept
503
+ {
504
+ switch (tabWidthMode)
505
+ {
506
+ case TabViewWidthMode::SizeToContent:
507
+ return TitleLengthTabWidthModeValue;
508
+ default :
509
+ return EqualTabWidthModeValue;
510
+ }
511
+ }
512
+
457
513
// Method Description:
458
514
// - Adds the given colorscheme to our map of schemes, using its name as the key.
459
515
// Arguments:
0 commit comments