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

Remove more serializers missed in 6394e5d70 #6321

Merged
1 commit merged into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 0 additions & 85 deletions src/cascadia/TerminalApp/GlobalAppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,26 +376,6 @@ ElementTheme GlobalAppSettings::_ParseTheme(const std::wstring& themeString) noe
return ElementTheme::Default;
}

// Method Description:
// - Helper function for converting a CursorStyle to its corresponding string
// value.
// Arguments:
// - theme: The enum value to convert to a string.
// Return Value:
// - The string value for the given CursorStyle
std::wstring_view GlobalAppSettings::_SerializeTheme(const ElementTheme theme) noexcept
{
switch (theme)
{
case ElementTheme::Light:
return LightThemeValue;
case ElementTheme::Dark:
return DarkThemeValue;
default:
return SystemThemeValue;
}
}

// Method Description:
// - Helper function for converting the initial position string into
// 2 coordinate values. We allow users to only provide one coordinate,
Expand Down Expand Up @@ -445,33 +425,6 @@ void GlobalAppSettings::_ParseInitialPosition(const std::wstring& initialPositio
}
}

// Method Description:
// - Helper function for converting X/Y initial positions to a string
// value.
// Arguments:
// - initialX: reference to the _initialX member
// initialY: reference to the _initialY member
// Return Value:
// - The concatenated string for the the current initialX and initialY
std::string GlobalAppSettings::_SerializeInitialPosition(const std::optional<int32_t>& initialX,
const std::optional<int32_t>& initialY) noexcept
{
std::string serializedInitialPos = "";
if (initialX.has_value())
{
serializedInitialPos += std::to_string(initialX.value());
}

serializedInitialPos += ", ";

if (initialY.has_value())
{
serializedInitialPos += std::to_string(initialY.value());
}

return serializedInitialPos;
}

// Method Description:
// - Helper function for converting the user-specified launch mode
// to a LaunchMode enum value
Expand All @@ -493,26 +446,6 @@ LaunchMode GlobalAppSettings::_ParseLaunchMode(const std::wstring& launchModeStr
return LaunchMode::DefaultMode;
}

// Method Description:
// - Helper function for converting a LaunchMode to its corresponding string
// value.
// Arguments:
// - launchMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given LaunchMode
std::wstring_view GlobalAppSettings::_SerializeLaunchMode(const LaunchMode launchMode) noexcept
{
switch (launchMode)
{
case LaunchMode::MaximizedMode:
return MaximizedLaunchModeValue;
case LaunchMode::FullscreenMode:
return FullscreenLaunchModeValue;
default:
return DefaultLaunchModeValue;
}
}

// Method Description:
// - Helper function for converting the user-specified tab width
// to a TabViewWidthMode enum value
Expand All @@ -530,24 +463,6 @@ TabViewWidthMode GlobalAppSettings::_ParseTabWidthMode(const std::wstring& tabWi
return TabViewWidthMode::Equal;
}

// Method Description:
// - Helper function for converting a TabViewWidthMode to its corresponding string
// value.
// Arguments:
// - tabWidthMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given TabWidthMode
std::wstring_view GlobalAppSettings::_SerializeTabWidthMode(const TabViewWidthMode tabWidthMode) noexcept
{
switch (tabWidthMode)
{
case TabViewWidthMode::SizeToContent:
return TitleLengthTabWidthModeValue;
default:
return EqualTabWidthModeValue;
}
}

// Method Description:
// - Adds the given colorscheme to our map of schemes, using its name as the key.
// Arguments:
Expand Down
6 changes: 0 additions & 6 deletions src/cascadia/TerminalApp/GlobalAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,13 @@ class TerminalApp::GlobalAppSettings final
bool _debugFeatures;

static winrt::Windows::UI::Xaml::ElementTheme _ParseTheme(const std::wstring& themeString) noexcept;
static std::wstring_view _SerializeTheme(const winrt::Windows::UI::Xaml::ElementTheme theme) noexcept;

static std::wstring_view _SerializeTabWidthMode(const winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode tabWidthMode) noexcept;
static winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode _ParseTabWidthMode(const std::wstring& tabWidthModeString) noexcept;

static void _ParseInitialPosition(const std::wstring& initialPosition,
std::optional<int32_t>& initialX,
std::optional<int32_t>& initialY) noexcept;

static std::string _SerializeInitialPosition(const std::optional<int32_t>& initialX,
const std::optional<int32_t>& initialY) noexcept;

static std::wstring_view _SerializeLaunchMode(const winrt::TerminalApp::LaunchMode launchMode) noexcept;
static winrt::TerminalApp::LaunchMode _ParseLaunchMode(const std::wstring& launchModeString) noexcept;

friend class TerminalAppLocalTests::SettingsTests;
Expand Down
142 changes: 0 additions & 142 deletions src/cascadia/TerminalApp/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,27 +870,6 @@ CloseOnExitMode Profile::ParseCloseOnExitMode(const Json::Value& json)
return CloseOnExitMode::Graceful;
}

// Method Description:
// - Helper function for converting a CloseOnExitMode to its corresponding string
// value.
// Arguments:
// - closeOnExitMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given CloseOnExitMode
std::string_view Profile::_SerializeCloseOnExitMode(const CloseOnExitMode closeOnExitMode)
{
switch (closeOnExitMode)
{
case CloseOnExitMode::Always:
return CloseOnExitAlways;
case CloseOnExitMode::Never:
return CloseOnExitNever;
case CloseOnExitMode::Graceful:
default:
return CloseOnExitGraceful;
}
}

// Method Description:
// - Helper function for converting a user-specified scrollbar state to its corresponding enum
// Arguments:
Expand Down Expand Up @@ -940,29 +919,6 @@ Media::Stretch Profile::ParseImageStretchMode(const std::string_view imageStretc
}
}

// Method Description:
// - Helper function for converting an ImageStretchMode to the
// correct string value.
// Arguments:
// - imageStretchMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given ImageStretchMode
std::string_view Profile::SerializeImageStretchMode(const Media::Stretch imageStretchMode)
{
switch (imageStretchMode)
{
case Media::Stretch::None:
return ImageStretchModeNone;
case Media::Stretch::Fill:
return ImageStretchModeFill;
case Media::Stretch::Uniform:
return ImageStretchModeUniform;
default:
case Media::Stretch::UniformToFill:
return ImageStretchModeUniformTofill;
}
}

// Method Description:
// - Helper function for converting a user-specified image horizontal and vertical
// alignment to the appropriate enum values tuple
Expand Down Expand Up @@ -1019,58 +975,6 @@ std::tuple<HorizontalAlignment, VerticalAlignment> Profile::ParseImageAlignment(
}
}

// Method Description:
// - Helper function for converting the HorizontalAlignment+VerticalAlignment tuple
// to the correct string value.
// Arguments:
// - imageAlignment: The enum values tuple to convert to a string.
// Return Value:
// - The string value for the given ImageAlignment
std::string_view Profile::SerializeImageAlignment(const std::tuple<HorizontalAlignment, VerticalAlignment> imageAlignment)
{
const auto imageHorizontalAlignment = std::get<HorizontalAlignment>(imageAlignment);
const auto imageVerticalAlignment = std::get<VerticalAlignment>(imageAlignment);
switch (imageHorizontalAlignment)
{
case HorizontalAlignment::Left:
switch (imageVerticalAlignment)
{
case VerticalAlignment::Top:
return ImageAlignmentTopLeft;
case VerticalAlignment::Bottom:
return ImageAlignmentBottomLeft;
default:
case VerticalAlignment::Center:
return ImageAlignmentLeft;
}

case HorizontalAlignment::Right:
switch (imageVerticalAlignment)
{
case VerticalAlignment::Top:
return ImageAlignmentTopRight;
case VerticalAlignment::Bottom:
return ImageAlignmentBottomRight;
default:
case VerticalAlignment::Center:
return ImageAlignmentRight;
}

default:
case HorizontalAlignment::Center:
switch (imageVerticalAlignment)
{
case VerticalAlignment::Top:
return ImageAlignmentTop;
case VerticalAlignment::Bottom:
return ImageAlignmentBottom;
default:
case VerticalAlignment::Center:
return ImageAlignmentCenter;
}
}
}

// Method Description:
// - Helper function for converting a user-specified cursor style corresponding
// CursorStyle enum value
Expand Down Expand Up @@ -1104,31 +1008,6 @@ CursorStyle Profile::_ParseCursorShape(const std::wstring& cursorShapeString)
return CursorStyle::Bar;
}

// Method Description:
// - Helper function for converting a CursorStyle to its corresponding string
// value.
// Arguments:
// - cursorShape: The enum value to convert to a string.
// Return Value:
// - The string value for the given CursorStyle
std::wstring_view Profile::_SerializeCursorStyle(const CursorStyle cursorShape)
{
switch (cursorShape)
{
case CursorStyle::Underscore:
return CursorShapeUnderscore;
case CursorStyle::FilledBox:
return CursorShapeFilledbox;
case CursorStyle::EmptyBox:
return CursorShapeEmptybox;
case CursorStyle::Vintage:
return CursorShapeVintage;
default:
case CursorStyle::Bar:
return CursorShapeBar;
}
}

// Method Description:
// - If this profile never had a GUID set for it, generate a runtime GUID for
// the profile. If a profile had their guid manually set to {0}, this method
Expand Down Expand Up @@ -1238,24 +1117,3 @@ TextAntialiasingMode Profile::ParseTextAntialiasingMode(const std::wstring& anti
// default behavior for invalid data
return TextAntialiasingMode::Grayscale;
}

// Method Description:
// - Helper function for converting a TextAntialiasingMode to its corresponding
// string value.
// Arguments:
// - antialiasingMode: The enum value to convert to a string.
// Return Value:
// - The string value for the given TextAntialiasingMode
std::wstring_view Profile::SerializeTextAntialiasingMode(const TextAntialiasingMode antialiasingMode)
{
switch (antialiasingMode)
{
case TextAntialiasingMode::Cleartype:
return AntialiasingModeCleartype;
case TextAntialiasingMode::Aliased:
return AntialiasingModeAliased;
default:
case TextAntialiasingMode::Grayscale:
return AntialiasingModeGrayscale;
}
}
5 changes: 0 additions & 5 deletions src/cascadia/TerminalApp/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,16 @@ class TerminalApp::Profile final
static winrt::Microsoft::Terminal::Settings::ScrollbarState ParseScrollbarState(const std::wstring& scrollbarState);
static winrt::Windows::UI::Xaml::Media::Stretch ParseImageStretchMode(const std::string_view imageStretchMode);
static winrt::Windows::UI::Xaml::Media::Stretch _ConvertJsonToStretchMode(const Json::Value& json);
static std::string_view SerializeImageStretchMode(const winrt::Windows::UI::Xaml::Media::Stretch imageStretchMode);
static std::tuple<winrt::Windows::UI::Xaml::HorizontalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment> ParseImageAlignment(const std::string_view imageAlignment);
static std::tuple<winrt::Windows::UI::Xaml::HorizontalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment> _ConvertJsonToAlignment(const Json::Value& json);

static winrt::Windows::UI::Text::FontWeight _ParseFontWeight(const Json::Value& json);

static CloseOnExitMode ParseCloseOnExitMode(const Json::Value& json);
static std::string_view _SerializeCloseOnExitMode(const CloseOnExitMode closeOnExitMode);

static std::string_view SerializeImageAlignment(const std::tuple<winrt::Windows::UI::Xaml::HorizontalAlignment, winrt::Windows::UI::Xaml::VerticalAlignment> imageAlignment);
static winrt::Microsoft::Terminal::Settings::CursorStyle _ParseCursorShape(const std::wstring& cursorShapeString);
static std::wstring_view _SerializeCursorStyle(const winrt::Microsoft::Terminal::Settings::CursorStyle cursorShape);

static winrt::Microsoft::Terminal::Settings::TextAntialiasingMode ParseTextAntialiasingMode(const std::wstring& antialiasingMode);
static std::wstring_view SerializeTextAntialiasingMode(const winrt::Microsoft::Terminal::Settings::TextAntialiasingMode antialiasingMode);

static GUID _GenerateGuidForProfile(const std::wstring& name, const std::optional<std::wstring>& source) noexcept;

Expand Down