@@ -15,6 +15,7 @@ using namespace winrt::TerminalApp;
1515using namespace winrt ::Windows::Data::Json;
1616using namespace winrt ::Windows::UI::Xaml;
1717using namespace ::Microsoft::Console;
18+ using namespace winrt ::Microsoft::UI::Xaml::Controls;
1819
1920static constexpr std::string_view KeybindingsKey{ " keybindings" };
2021static constexpr std::string_view DefaultProfileKey{ " defaultProfile" };
@@ -25,6 +26,9 @@ static constexpr std::string_view RowsToScrollKey{ "rowsToScroll" };
2526static constexpr std::string_view InitialPositionKey{ " initialPosition" };
2627static constexpr std::string_view ShowTitleInTitlebarKey{ " showTerminalTitleInTitlebar" };
2728static 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" };
2832static constexpr std::string_view ShowTabsInTitlebarKey{ " showTabsInTitlebar" };
2933static constexpr std::string_view WordDelimitersKey{ " wordDelimiters" };
3034static constexpr std::string_view CopyOnSelectKey{ " copyOnSelect" };
@@ -49,6 +53,7 @@ GlobalAppSettings::GlobalAppSettings() :
4953 _showTitleInTitlebar{ true },
5054 _showTabsInTitlebar{ true },
5155 _requestedTheme{ ElementTheme::Default },
56+ _tabWidthMode{ TabViewWidthMode::Equal },
5257 _wordDelimiters{ DEFAULT_WORD_DELIMITERS },
5358 _copyOnSelect{ false },
5459 _launchMode{ LaunchMode::DefaultMode }
@@ -114,6 +119,16 @@ void GlobalAppSettings::SetRequestedTheme(const ElementTheme requestedTheme) noe
114119 _requestedTheme = requestedTheme;
115120}
116121
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+
117132std::wstring GlobalAppSettings::GetWordDelimiters () const noexcept
118133{
119134 return _wordDelimiters;
@@ -206,6 +221,7 @@ Json::Value GlobalAppSettings::ToJson() const
206221 jsonObject[JsonKey (CopyOnSelectKey)] = _copyOnSelect;
207222 jsonObject[JsonKey (LaunchModeKey)] = winrt::to_string (_SerializeLaunchMode (_launchMode));
208223 jsonObject[JsonKey (RequestedThemeKey)] = winrt::to_string (_SerializeTheme (_requestedTheme));
224+ jsonObject[JsonKey (TabWidthModeKey)] = winrt::to_string (_SerializeTabWidthMode (_tabWidthMode));
209225 jsonObject[JsonKey (KeybindingsKey)] = _keybindings->ToJson ();
210226 jsonObject[JsonKey (SnapToGridOnResizeKey)] = _SnapToGridOnResize;
211227
@@ -291,6 +307,11 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
291307 _requestedTheme = _ParseTheme (GetWstringFromJson (requestedTheme));
292308 }
293309
310+ if (auto tabWidthMode{ json[JsonKey (TabWidthModeKey)] })
311+ {
312+ _tabWidthMode = _ParseTabWidthMode (GetWstringFromJson (tabWidthMode));
313+ }
314+
294315 if (auto keybindings{ json[JsonKey (KeybindingsKey)] })
295316 {
296317 _keybindings->LayerJson (keybindings);
@@ -454,6 +475,41 @@ std::wstring_view GlobalAppSettings::_SerializeLaunchMode(const LaunchMode launc
454475 }
455476}
456477
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+
457513// Method Description:
458514// - Adds the given colorscheme to our map of schemes, using its name as the key.
459515// Arguments:
0 commit comments