diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index be78d1c36c..b8e6c9ab40 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -2407,6 +2407,14 @@ "console" ] }, + "compatibility.ambiguousWidth": { + "default": "narrow", + "description": "Controls the cell width of East Asian Ambiguous characters.", + "enum": [ + "narrow", + "wide" + ] + }, "copyFormatting": { "default": true, "description": "When set to `true`, the color and font formatting of selected text is also copied to your clipboard. When set to `false`, only plain text is copied to your clipboard. An array of specific formats can also be used. Supported array values include `html` and `rtf`. Plain text is always copied.", diff --git a/src/cascadia/TerminalApp/TerminalPage.cpp b/src/cascadia/TerminalApp/TerminalPage.cpp index 6c73b139f7..e98de6b995 100644 --- a/src/cascadia/TerminalApp/TerminalPage.cpp +++ b/src/cascadia/TerminalApp/TerminalPage.cpp @@ -1482,6 +1482,9 @@ namespace winrt::TerminalApp::implementation return {}; } }(); + static const auto ambiguousIsWide = [&]() -> bool { + return _settings.GlobalSettings().AmbiguousWidth() == AmbiguousWidth::Wide; + }(); TerminalConnection::ITerminalConnection connection{ nullptr }; @@ -1547,6 +1550,10 @@ namespace winrt::TerminalApp::implementation { valueSet.Insert(L"textMeasurement", Windows::Foundation::PropertyValue::CreateString(textMeasurement)); } + if (ambiguousIsWide) + { + valueSet.Insert(L"ambiguousIsWide", Windows::Foundation::PropertyValue::CreateBoolean(true)); + } if (const auto id = settings.SessionId(); id != winrt::guid{}) { diff --git a/src/cascadia/TerminalConnection/ConptyConnection.cpp b/src/cascadia/TerminalConnection/ConptyConnection.cpp index e83782ff65..4ee3ae0c3c 100644 --- a/src/cascadia/TerminalConnection/ConptyConnection.cpp +++ b/src/cascadia/TerminalConnection/ConptyConnection.cpp @@ -289,6 +289,11 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation } } + if (unbox_prop_or(settings, L"ambiguousIsWide", false)) + { + _flags |= PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE; + } + const auto& initialEnvironment{ unbox_prop_or(settings, L"initialEnvironment", L"") }; const bool reloadEnvironmentVariables = unbox_prop_or(settings, L"reloadEnvironmentVariables", false); diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index f5232ee1d7..86747d0f8f 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -85,6 +85,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation break; } CodepointWidthDetector::Singleton().Reset(mode); + + if (settings.AmbiguousWidth() == AmbiguousWidth::Wide) + { + CodepointWidthDetector::Singleton().SetAmbiguousWidth(2); + } + return true; }(); diff --git a/src/cascadia/TerminalControl/EventArgs.idl b/src/cascadia/TerminalControl/EventArgs.idl index d6086fd922..5f34e84264 100644 --- a/src/cascadia/TerminalControl/EventArgs.idl +++ b/src/cascadia/TerminalControl/EventArgs.idl @@ -26,6 +26,12 @@ namespace Microsoft.Terminal.Control Console, }; + enum AmbiguousWidth + { + Narrow, + Wide, + }; + enum DefaultInputScope { Default, diff --git a/src/cascadia/TerminalControl/IControlSettings.idl b/src/cascadia/TerminalControl/IControlSettings.idl index d879f57497..19f0d70eca 100644 --- a/src/cascadia/TerminalControl/IControlSettings.idl +++ b/src/cascadia/TerminalControl/IControlSettings.idl @@ -68,6 +68,7 @@ namespace Microsoft.Terminal.Control Boolean DisablePartialInvalidation { get; }; Boolean SoftwareRendering { get; }; Microsoft.Terminal.Control.TextMeasurement TextMeasurement { get; }; + Microsoft.Terminal.Control.AmbiguousWidth AmbiguousWidth { get; }; Microsoft.Terminal.Control.DefaultInputScope DefaultInputScope { get; }; Boolean ShowMarks { get; }; Boolean UseBackgroundImageForWindow { get; }; diff --git a/src/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cpp b/src/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cpp index cba83bb772..71f8695e2a 100644 --- a/src/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cpp +++ b/src/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cpp @@ -376,6 +376,7 @@ namespace winrt::Microsoft::Terminal::Settings _DisablePartialInvalidation = globalSettings.DisablePartialInvalidation(); _SoftwareRendering = globalSettings.SoftwareRendering(); _TextMeasurement = globalSettings.TextMeasurement(); + _AmbiguousWidth = globalSettings.AmbiguousWidth(); _DefaultInputScope = globalSettings.DefaultInputScope(); _UseBackgroundImageForWindow = globalSettings.UseBackgroundImageForWindow(); _TrimBlockSelection = globalSettings.TrimBlockSelection(); diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.cpp b/src/cascadia/TerminalSettingsEditor/Compatibility.cpp index 1cd4f922b7..82e39190c5 100644 --- a/src/cascadia/TerminalSettingsEditor/Compatibility.cpp +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.cpp @@ -16,6 +16,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _settings{ settings } { INITIALIZE_BINDABLE_ENUM_SETTING(TextMeasurement, TextMeasurement, winrt::Microsoft::Terminal::Control::TextMeasurement, L"Globals_TextMeasurement_", L"Text"); + INITIALIZE_BINDABLE_ENUM_SETTING(AmbiguousWidth, AmbiguousWidth, winrt::Microsoft::Terminal::Control::AmbiguousWidth, L"Globals_AmbiguousWidth_", L"Text"); } bool CompatibilityViewModel::DebugFeaturesAvailable() const noexcept diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.h b/src/cascadia/TerminalSettingsEditor/Compatibility.h index 54e81f5252..2fd057758e 100644 --- a/src/cascadia/TerminalSettingsEditor/Compatibility.h +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.h @@ -26,6 +26,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation PERMANENT_OBSERVABLE_PROJECTED_SETTING(_settings.GlobalSettings(), AllowHeadless); PERMANENT_OBSERVABLE_PROJECTED_SETTING(_settings.GlobalSettings(), DebugFeaturesEnabled); GETSET_BINDABLE_ENUM_SETTING(TextMeasurement, winrt::Microsoft::Terminal::Control::TextMeasurement, _settings.GlobalSettings().TextMeasurement); + GETSET_BINDABLE_ENUM_SETTING(AmbiguousWidth, winrt::Microsoft::Terminal::Control::AmbiguousWidth, _settings.GlobalSettings().AmbiguousWidth); private: Model::CascadiaSettings _settings; diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.idl b/src/cascadia/TerminalSettingsEditor/Compatibility.idl index b9f13ffe6e..7f94b780fd 100644 --- a/src/cascadia/TerminalSettingsEditor/Compatibility.idl +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.idl @@ -20,6 +20,9 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable CurrentTextMeasurement; Windows.Foundation.Collections.IObservableVector TextMeasurementList { get; }; + + IInspectable CurrentAmbiguousWidth; + Windows.Foundation.Collections.IObservableVector AmbiguousWidthList { get; }; } [default_interface] runtimeclass Compatibility : Windows.UI.Xaml.Controls.Page diff --git a/src/cascadia/TerminalSettingsEditor/Compatibility.xaml b/src/cascadia/TerminalSettingsEditor/Compatibility.xaml index 54354f3ed4..ebeacba5c8 100644 --- a/src/cascadia/TerminalSettingsEditor/Compatibility.xaml +++ b/src/cascadia/TerminalSettingsEditor/Compatibility.xaml @@ -42,6 +42,15 @@ Style="{StaticResource ComboBoxSettingStyle}" /> + + + + + Windows Console + + Width of ambiguous characters + A label for a drop down selector, referring to the East Asian Ambiguous Width Unicode specification. + + + Sets the width used for East Asian Ambiguous characters. "Narrow" (default) prioritizes compatibility, while "Wide" prioritizes readability with many CJK fonts. In "Wide" mode, some applications may not work correctly and cause erratic cursor movement. Changing this setting requires a restart of Windows Terminal and it only applies to applications launched from within it. + + + Narrow + As in "narrow width". Refers to the East Asian Ambiguous Width Unicode specification. + + + Wide + As in "wide width". Refers to the East Asian Ambiguous Width Unicode specification. + Columns Header for a control to choose the number of columns in the terminal's text grid. diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp index 2e14d443b8..de1bf5185d 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.cpp +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.cpp @@ -41,6 +41,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation DEFINE_ENUM_MAP(Microsoft::Terminal::Core::MatchMode, MatchMode); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::GraphicsAPI, GraphicsAPI); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::TextMeasurement, TextMeasurement); + DEFINE_ENUM_MAP(Microsoft::Terminal::Control::AmbiguousWidth, AmbiguousWidth); DEFINE_ENUM_MAP(Microsoft::Terminal::Control::WarnAboutMultiLinePaste, WarnAboutMultiLinePaste); // Profile Settings diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.h b/src/cascadia/TerminalSettingsModel/EnumMappings.h index cca552546f..160c9a11b1 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.h +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.h @@ -38,6 +38,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation static winrt::Windows::Foundation::Collections::IMap MatchMode(); static winrt::Windows::Foundation::Collections::IMap GraphicsAPI(); static winrt::Windows::Foundation::Collections::IMap TextMeasurement(); + static winrt::Windows::Foundation::Collections::IMap AmbiguousWidth(); static winrt::Windows::Foundation::Collections::IMap WarnAboutMultiLinePaste(); // Profile Settings diff --git a/src/cascadia/TerminalSettingsModel/EnumMappings.idl b/src/cascadia/TerminalSettingsModel/EnumMappings.idl index 7b0ac90e1f..128260a507 100644 --- a/src/cascadia/TerminalSettingsModel/EnumMappings.idl +++ b/src/cascadia/TerminalSettingsModel/EnumMappings.idl @@ -20,6 +20,7 @@ namespace Microsoft.Terminal.Settings.Model static Windows.Foundation.Collections.IMap MatchMode { get; }; static Windows.Foundation.Collections.IMap GraphicsAPI { get; }; static Windows.Foundation.Collections.IMap TextMeasurement { get; }; + static Windows.Foundation.Collections.IMap AmbiguousWidth { get; }; static Windows.Foundation.Collections.IMap WarnAboutMultiLinePaste { get; }; // Profile Settings diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp index ab58450431..254e52bdbc 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.cpp @@ -312,6 +312,10 @@ Json::Value GlobalAppSettings::ToJson() { _TextMeasurement.reset(); } + if (_AmbiguousWidth == Control::AmbiguousWidth::Narrow) + { + _AmbiguousWidth.reset(); + } if (_DefaultInputScope == Control::DefaultInputScope::Default) { _DefaultInputScope.reset(); diff --git a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl index 0ac7b96db8..77bcfc494d 100644 --- a/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl +++ b/src/cascadia/TerminalSettingsModel/GlobalAppSettings.idl @@ -83,6 +83,7 @@ namespace Microsoft.Terminal.Settings.Model INHERITABLE_SETTING(Boolean, DisablePartialInvalidation); INHERITABLE_SETTING(Boolean, SoftwareRendering); INHERITABLE_SETTING(Microsoft.Terminal.Control.TextMeasurement, TextMeasurement); + INHERITABLE_SETTING(Microsoft.Terminal.Control.AmbiguousWidth, AmbiguousWidth); INHERITABLE_SETTING(Boolean, UseBackgroundImageForWindow); INHERITABLE_SETTING(Boolean, DebugFeaturesEnabled); INHERITABLE_SETTING(Boolean, AlwaysOnTop); diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h index c20e49701f..4f99bda187 100644 --- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h +++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h @@ -30,6 +30,7 @@ Author(s): X(bool, DisablePartialInvalidation, "rendering.disablePartialInvalidation", false) \ X(bool, SoftwareRendering, "rendering.software", false) \ X(winrt::Microsoft::Terminal::Control::TextMeasurement, TextMeasurement, "compatibility.textMeasurement") \ + X(winrt::Microsoft::Terminal::Control::AmbiguousWidth, AmbiguousWidth, "compatibility.ambiguousWidth", winrt::Microsoft::Terminal::Control::AmbiguousWidth::Narrow) \ X(winrt::Microsoft::Terminal::Control::DefaultInputScope, DefaultInputScope, "defaultInputScope") \ X(bool, UseBackgroundImageForWindow, "experimental.useBackgroundImageForWindow", false) \ X(bool, TrimBlockSelection, "trimBlockSelection", true) \ diff --git a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h index 92a9828208..9c071945a2 100644 --- a/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h +++ b/src/cascadia/TerminalSettingsModel/TerminalSettingsSerializationHelpers.h @@ -827,6 +827,14 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::TextMeasurement) }; }; +JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::AmbiguousWidth) +{ + JSON_MAPPINGS(2) = { + pair_type{ "narrow", ValueType::Narrow }, + pair_type{ "wide", ValueType::Wide }, + }; +}; + JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Control::DefaultInputScope) { JSON_MAPPINGS(2) = { diff --git a/src/cascadia/inc/ControlProperties.h b/src/cascadia/inc/ControlProperties.h index 383cb6d584..91ae711786 100644 --- a/src/cascadia/inc/ControlProperties.h +++ b/src/cascadia/inc/ControlProperties.h @@ -81,6 +81,7 @@ X(bool, DisablePartialInvalidation, false) \ X(bool, SoftwareRendering, false) \ X(winrt::Microsoft::Terminal::Control::TextMeasurement, TextMeasurement) \ + X(winrt::Microsoft::Terminal::Control::AmbiguousWidth, AmbiguousWidth, winrt::Microsoft::Terminal::Control::AmbiguousWidth::Narrow) \ X(winrt::Microsoft::Terminal::Control::DefaultInputScope, DefaultInputScope, winrt::Microsoft::Terminal::Control::DefaultInputScope::Default) \ X(bool, UseBackgroundImageForWindow, false) \ X(bool, ShowMarks, false) \ diff --git a/src/host/ConsoleArguments.cpp b/src/host/ConsoleArguments.cpp index 8241a62e0b..a0c6fb1837 100644 --- a/src/host/ConsoleArguments.cpp +++ b/src/host/ConsoleArguments.cpp @@ -22,6 +22,7 @@ const std::wstring_view ConsoleArguments::FEATURE_ARG = L"--feature"; const std::wstring_view ConsoleArguments::FEATURE_PTY_ARG = L"pty"; const std::wstring_view ConsoleArguments::COM_SERVER_ARG = L"-Embedding"; static constexpr std::wstring_view GLYPH_WIDTH{ L"--textMeasurement" }; +static constexpr std::wstring_view AMBIGUOUS_IS_WIDE{ L"--ambiguousIsWide" }; // NOTE: Thinking about adding more commandline args that control conpty, for // the Terminal? Make sure you add them to the commandline in // ConsoleEstablishHandoff. We use that to initialize the ConsoleArguments for a @@ -136,6 +137,8 @@ ConsoleArguments& ConsoleArguments::operator=(const ConsoleArguments& other) _vtInHandle = other._vtInHandle; _vtOutHandle = other._vtOutHandle; _headless = other._headless; + _textMeasurement = other._textMeasurement; + _ambiguousIsWide = other._ambiguousIsWide; _createServerHandle = other._createServerHandle; _serverHandle = other._serverHandle; _signalHandle = other._signalHandle; @@ -498,6 +501,12 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector& args, _In { hr = s_GetArgumentValue(args, i, &_textMeasurement); } + else if (arg == AMBIGUOUS_IS_WIDE) + { + _ambiguousIsWide = true; + s_ConsumeArg(args, i); + hr = S_OK; + } else if (arg == CLIENT_COMMANDLINE_ARG) { // Everything after this is the explicit commandline @@ -621,6 +630,11 @@ const std::wstring& ConsoleArguments::GetTextMeasurement() const return _textMeasurement; } +bool ConsoleArguments::GetAmbiguousIsWide() const +{ + return _ambiguousIsWide; +} + bool ConsoleArguments::GetForceV1() const { return _forceV1; diff --git a/src/host/ConsoleArguments.hpp b/src/host/ConsoleArguments.hpp index 902e7f1c66..d203697db0 100644 --- a/src/host/ConsoleArguments.hpp +++ b/src/host/ConsoleArguments.hpp @@ -47,6 +47,7 @@ public: std::wstring GetOriginalCommandLine() const; std::wstring GetClientCommandline() const; const std::wstring& GetTextMeasurement() const; + bool GetAmbiguousIsWide() const; bool GetForceV1() const; bool GetForceNoHandoff() const; @@ -118,6 +119,7 @@ private: HANDLE _vtOutHandle; std::wstring _textMeasurement; + bool _ambiguousIsWide = false; bool _forceNoHandoff; bool _forceV1; diff --git a/src/host/VtIo.cpp b/src/host/VtIo.cpp index a53f61ed99..f5214d3817 100644 --- a/src/host/VtIo.cpp +++ b/src/host/VtIo.cpp @@ -50,6 +50,11 @@ using namespace Microsoft::Console::Interactivity; CodepointWidthDetector::Singleton().Reset(mode); } + if (pArgs->GetAmbiguousIsWide()) + { + CodepointWidthDetector::Singleton().SetAmbiguousWidth(2); + } + return _Initialize(pArgs->GetVtInHandle(), pArgs->GetVtOutHandle(), pArgs->GetSignalHandle()); } // Didn't need to initialize if we didn't have VT stuff. It's still OK, but report we did nothing. diff --git a/src/inc/conpty-static.h b/src/inc/conpty-static.h index 3aca15dba7..cba57ac280 100644 --- a/src/inc/conpty-static.h +++ b/src/inc/conpty-static.h @@ -33,6 +33,9 @@ #define PSEUDOCONSOLE_GLYPH_WIDTH_WCSWIDTH 0x10 #define PSEUDOCONSOLE_GLYPH_WIDTH_CONSOLE 0x18 #endif +#ifndef PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE +#define PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE 0x20 +#endif CONPTY_EXPORT HRESULT WINAPI ConptyCreatePseudoConsole(COORD size, HANDLE hInput, HANDLE hOutput, DWORD dwFlags, HPCON* phPC); CONPTY_EXPORT HRESULT WINAPI ConptyCreatePseudoConsoleAsUser(HANDLE hToken, COORD size, HANDLE hInput, HANDLE hOutput, DWORD dwFlags, HPCON* phPC); diff --git a/src/types/CodepointWidthDetector.cpp b/src/types/CodepointWidthDetector.cpp index 2fd856a62e..c0676ffc8c 100644 --- a/src/types/CodepointWidthDetector.cpp +++ b/src/types/CodepointWidthDetector.cpp @@ -1258,6 +1258,16 @@ TextMeasurementMode CodepointWidthDetector::GetMode() const noexcept return _mode; } +int CodepointWidthDetector::GetAmbiguousWidth() const noexcept +{ + return _ambiguousWidth; +} + +void CodepointWidthDetector::SetAmbiguousWidth(const int width) noexcept +{ + _ambiguousWidth = width; +} + // Method Description: // - Sets a function that should be used as the fallback mechanism for // determining a particular glyph's width, should the glyph be an ambiguous diff --git a/src/types/inc/CodepointWidthDetector.hpp b/src/types/inc/CodepointWidthDetector.hpp index 7429d6a96c..3b18ce2057 100644 --- a/src/types/inc/CodepointWidthDetector.hpp +++ b/src/types/inc/CodepointWidthDetector.hpp @@ -56,6 +56,8 @@ struct CodepointWidthDetector bool GraphemePrev(GraphemeState& s, const std::wstring_view& str) noexcept; TextMeasurementMode GetMode() const noexcept; + int GetAmbiguousWidth() const noexcept; + void SetAmbiguousWidth(int width) noexcept; void SetFallbackMethod(std::function pfnFallback) noexcept; void Reset(TextMeasurementMode mode) noexcept; diff --git a/src/types/ut_types/CodepointWidthDetectorTests.cpp b/src/types/ut_types/CodepointWidthDetectorTests.cpp index 2a112f87c7..58842d8243 100644 --- a/src/types/ut_types/CodepointWidthDetectorTests.cpp +++ b/src/types/ut_types/CodepointWidthDetectorTests.cpp @@ -1335,4 +1335,24 @@ class CodepointWidthDetectorTests VERIFY_ARE_EQUAL(test.widthsPrev, actualWidths); } } + + TEST_METHOD(AmbiguousWidthPolicy) + { + const auto measureWidth = [](CodepointWidthDetector& cwd, const std::wstring_view text) { + GraphemeState state; + cwd.GraphemeNext(state, text); + return state.width; + }; + + CodepointWidthDetector cwd; + + for (const auto mode : { TextMeasurementMode::Graphemes, TextMeasurementMode::Wcswidth }) + { + cwd.Reset(mode); + cwd.SetAmbiguousWidth(1); + VERIFY_ARE_EQUAL(1, measureWidth(cwd, L"→")); + cwd.SetAmbiguousWidth(2); + VERIFY_ARE_EQUAL(2, measureWidth(cwd, L"→")); + } + } }; diff --git a/src/winconpty/winconpty.cpp b/src/winconpty/winconpty.cpp index 4aa64385d1..832b78c11b 100644 --- a/src/winconpty/winconpty.cpp +++ b/src/winconpty/winconpty.cpp @@ -166,7 +166,8 @@ HRESULT _CreatePseudoConsole(HANDLE hToken, RETURN_IF_WIN32_BOOL_FALSE(CreatePipe(signalPipeConhostSide.addressof(), signalPipeOurSide.addressof(), &sa, 0)); RETURN_IF_WIN32_BOOL_FALSE(SetHandleInformation(signalPipeConhostSide.get(), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)); - const BOOL bInheritCursor = (dwFlags & PSEUDOCONSOLE_INHERIT_CURSOR) == PSEUDOCONSOLE_INHERIT_CURSOR; + const auto inheritCursor = (dwFlags & PSEUDOCONSOLE_INHERIT_CURSOR) ? L"--inheritcursor " : L""; + const auto ambiguousIsWide = (dwFlags & PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE) ? L"--ambiguousIsWide " : L""; const wchar_t* textMeasurement; switch (dwFlags & PSEUDOCONSOLE_GLYPH_WIDTH__MASK) @@ -192,9 +193,10 @@ HRESULT _CreatePseudoConsole(HANDLE hToken, wil::unique_process_heap_string cmd; RETURN_IF_FAILED(wil::str_printf_nothrow( cmd, - L"\"%s\" --headless %s%s--width %hd --height %hd --signal 0x%tx --server 0x%tx", + L"\"%s\" --headless %s%s%s--width %hd --height %hd --signal 0x%tx --server 0x%tx", conhostPath, - bInheritCursor ? L"--inheritcursor " : L"", + inheritCursor, + ambiguousIsWide, textMeasurement, size.X, size.Y, diff --git a/src/winconpty/winconpty.h b/src/winconpty/winconpty.h index 8a245226ca..e917a18ad7 100644 --- a/src/winconpty/winconpty.h +++ b/src/winconpty/winconpty.h @@ -58,6 +58,9 @@ typedef struct _PseudoConsole #define PSEUDOCONSOLE_GLYPH_WIDTH_WCSWIDTH 0x10 #define PSEUDOCONSOLE_GLYPH_WIDTH_CONSOLE 0x18 #endif +#ifndef PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE +#define PSEUDOCONSOLE_AMBIGUOUS_IS_WIDE 0x20 +#endif // Implementations of the various PseudoConsole functions. HRESULT _CreatePseudoConsole(const HANDLE hToken,