mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-11 13:56:33 -06:00
## Summary of the Pull Request This PR adds a global "language" setting, which may be set to any supported BCP 47 tag. Additionally a ComboBox is added to the settings UI under "Appearance", listing all languages with their localized names. This PR introduces one new issue: If you change the language while the app is running, the UI will be in a torn state, as not all UI elements refresh automatically if the `PrimaryLanguageOverride` is changed. ## PR Checklist * [x] Closes #5497 * [x] I work here * [x] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated ## Validation Steps Performed * UI language changes when changing the "language" in settings.json before starting WT / while WT is running. ✔️ * "language" field is removed from settings.json if "Use system default" is selected. ✔️ * "language" field is added or updated in settings.json if any other language is selected. ✔️ * Removes qps- languages if debugFeatures is false. ✔️ * Correctly refreshes all UI elements with the new language. ❌
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
|
|
namespace til // Terminal Implementation Library. Also: "Today I Learned"
|
|
{
|
|
_TIL_INLINEPREFIX std::wstring visualize_control_codes(std::wstring str) noexcept
|
|
{
|
|
for (auto& ch : str)
|
|
{
|
|
if (ch < 0x20)
|
|
{
|
|
ch += 0x2400;
|
|
}
|
|
else if (ch == 0x20)
|
|
{
|
|
ch = 0x2423; // replace space with ␣
|
|
}
|
|
else if (ch == 0x7f)
|
|
{
|
|
ch = 0x2421; // replace del with ␡
|
|
}
|
|
}
|
|
return str;
|
|
}
|
|
|
|
_TIL_INLINEPREFIX std::wstring visualize_control_codes(std::wstring_view str)
|
|
{
|
|
return visualize_control_codes(std::wstring{ str });
|
|
}
|
|
|
|
template<typename T, typename Traits>
|
|
constexpr bool starts_with(const std::basic_string_view<T, Traits> str, const std::basic_string_view<T, Traits> prefix) noexcept
|
|
{
|
|
#ifdef __cpp_lib_starts_ends_with
|
|
#error This code can be replaced in C++20, which natively supports .starts_with().
|
|
#endif
|
|
return str.size() >= prefix.size() && Traits::compare(str.data(), prefix.data(), prefix.size()) == 0;
|
|
};
|
|
|
|
constexpr bool starts_with(const std::string_view str, const std::string_view prefix) noexcept
|
|
{
|
|
return starts_with<>(str, prefix);
|
|
};
|
|
|
|
constexpr bool starts_with(const std::wstring_view str, const std::wstring_view prefix) noexcept
|
|
{
|
|
return starts_with<>(str, prefix);
|
|
};
|
|
}
|