Remove VtApiRoutines (#16954)

This removes `VtApiRoutines` and the VT passthrough mode.
Why? While VT passthrough mode has a clear advantage (doesn't corrupt
VT sequences) it fails to address other pain points (performance,
out-of-sync issues after resize, etc.). Alternative options are
available which have less restrictions.
Why now? It's spring! Spring cleanup!
This commit is contained in:
Leonard Hecker
2024-03-28 19:22:39 +01:00
committed by GitHub
parent 8349fd2728
commit 2050416997
34 changed files with 78 additions and 1464 deletions

View File

@@ -2777,10 +2777,6 @@
"description": "When set to true, prompts will automatically be marked.",
"type": "boolean"
},
"experimental.connection.passthroughMode": {
"description": "When set to true, directs the PTY for this connection to use pass-through mode instead of the original Conhost PTY simulation engine. This is an experimental feature, and its continued existence is not guaranteed.",
"type": "boolean"
},
"experimental.retroTerminalEffect": {
"description": "When set to true, enable retro terminal effects. This is an experimental feature, and its continued existence is not guaranteed.",
"type": "boolean"

View File

@@ -1277,11 +1277,6 @@ namespace winrt::TerminalApp::implementation
}
}
if constexpr (Feature_VtPassthroughMode::IsEnabled())
{
valueSet.Insert(L"passthroughMode", Windows::Foundation::PropertyValue::CreateBoolean(settings.VtPassthrough()));
}
connection.Initialize(valueSet);
TraceLoggingWrite(

View File

@@ -257,10 +257,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
_cols = unbox_prop_or<uint32_t>(settings, L"initialCols", _cols);
_sessionId = unbox_prop_or<winrt::guid>(settings, L"sessionId", _sessionId);
_environment = settings.TryLookup(L"environment").try_as<Windows::Foundation::Collections::ValueSet>();
if constexpr (Feature_VtPassthroughMode::IsEnabled())
{
_passthroughMode = unbox_prop_or<bool>(settings, L"passthroughMode", _passthroughMode);
}
_inheritCursor = unbox_prop_or<bool>(settings, L"inheritCursor", _inheritCursor);
_profileGuid = unbox_prop_or<winrt::guid>(settings, L"profileGuid", _profileGuid);
@@ -332,14 +328,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
flags |= PSEUDOCONSOLE_INHERIT_CURSOR;
}
if constexpr (Feature_VtPassthroughMode::IsEnabled())
{
if (_passthroughMode)
{
WI_SetFlag(flags, PSEUDOCONSOLE_PASSTHROUGH_MODE);
}
}
THROW_IF_FAILED(_CreatePseudoConsoleAndPipes(til::unwrap_coord_size(dimensions), flags, &_inPipe, &_outPipe, &_hPC));
if (_initialParentHwnd != 0)

View File

@@ -90,7 +90,6 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
til::u8state _u8State{};
std::wstring _u16Str{};
std::array<char, 4096> _buffer{};
bool _passthroughMode{};
bool _inheritCursor{ false };
til::env _initialEnv{};

View File

@@ -22,7 +22,6 @@ namespace Microsoft.Terminal.Core
Boolean ForceVTInput;
Boolean TrimBlockSelection;
Boolean DetectURLs;
Boolean VtPassthrough;
Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> TabColor;
Windows.Foundation.IReference<Microsoft.Terminal.Core.Color> StartingTabColor;

View File

@@ -298,10 +298,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return _unfocusedAppearanceViewModel;
}
bool ProfileViewModel::VtPassthroughAvailable() const noexcept
{
return Feature_VtPassthroughMode::IsEnabled() && Feature_VtPassthroughModeSettingInUI::IsEnabled();
}
bool ProfileViewModel::ShowMarksAvailable() const noexcept
{
return Feature_ScrollbarMarks::IsEnabled();

View File

@@ -82,7 +82,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void CreateUnfocusedAppearance();
void DeleteUnfocusedAppearance();
bool VtPassthroughAvailable() const noexcept;
bool ShowMarksAvailable() const noexcept;
bool AutoMarkPromptsAvailable() const noexcept;
bool RepositionCursorWithMouseAvailable() const noexcept;
@@ -117,7 +116,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
OBSERVABLE_PROJECTED_SETTING(_profile, AltGrAliasing);
OBSERVABLE_PROJECTED_SETTING(_profile, BellStyle);
OBSERVABLE_PROJECTED_SETTING(_profile, Elevate);
OBSERVABLE_PROJECTED_SETTING(_profile, VtPassthrough);
OBSERVABLE_PROJECTED_SETTING(_profile, ReloadEnvironmentVariables);
OBSERVABLE_PROJECTED_SETTING(_profile, RightClickContextMenu);
OBSERVABLE_PROJECTED_SETTING(_profile, ShowMarks);

View File

@@ -75,7 +75,6 @@ namespace Microsoft.Terminal.Settings.Editor
Boolean ShowUnfocusedAppearance { get; };
AppearanceViewModel UnfocusedAppearance { get; };
Boolean VtPassthroughAvailable { get; };
Boolean ShowMarksAvailable { get; };
Boolean AutoMarkPromptsAvailable { get; };
Boolean RepositionCursorWithMouseAvailable { get; };
@@ -111,7 +110,6 @@ namespace Microsoft.Terminal.Settings.Editor
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, AltGrAliasing);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Microsoft.Terminal.Settings.Model.BellStyle, BellStyle);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, Elevate);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, VtPassthrough);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ReloadEnvironmentVariables);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, RightClickContextMenu);
OBSERVABLE_PROJECTED_PROFILE_SETTING(Boolean, ShowMarks);

View File

@@ -117,16 +117,6 @@
</StackPanel>
</local:SettingContainer>
<!-- VtPassthrough -->
<local:SettingContainer x:Uid="Profile_VtPassthrough"
ClearSettingValue="{x:Bind Profile.ClearVtPassthrough}"
HasSettingValue="{x:Bind Profile.HasVtPassthrough, Mode=OneWay}"
SettingOverrideSource="{x:Bind Profile.VtPassthroughOverrideSource, Mode=OneWay}"
Visibility="{x:Bind Profile.VtPassthroughAvailable}">
<ToggleSwitch IsOn="{x:Bind Profile.VtPassthrough, Mode=TwoWay}"
Style="{StaticResource ToggleSwitchInExpanderStyle}" />
</local:SettingContainer>
<!-- RightClickContextMenu -->
<local:SettingContainer x:Uid="Profile_RightClickContextMenu"
ClearSettingValue="{x:Bind Profile.ClearRightClickContextMenu}"

View File

@@ -1225,10 +1225,6 @@
<value>When enabled, the Terminal will generate a new environment block when creating new tabs or panes with this profile. When disabled, the tab/pane will instead inherit the variables the Terminal was started with.</value>
<comment>A description for what the "Reload environment variables" setting does. Presented near "Profile_ReloadEnvVars".</comment>
</data>
<data name="Profile_VtPassthrough.Header" xml:space="preserve">
<value>Enable experimental virtual terminal passthrough</value>
<comment>An option to enable experimental virtual terminal passthrough connectivity option with the underlying ConPTY</comment>
</data>
<data name="Profile_RightClickContextMenu.Header" xml:space="preserve">
<value>Display a menu on right-click</value>
<comment>This controls how a right-click behaves in the terminal</comment>

View File

@@ -93,7 +93,6 @@ Author(s):
X(bool, RightClickContextMenu, "experimental.rightClickContextMenu", false) \
X(Windows::Foundation::Collections::IVector<winrt::hstring>, BellSound, "bellSound", nullptr) \
X(bool, Elevate, "elevate", false) \
X(bool, VtPassthrough, "experimental.connection.passthroughMode", false) \
X(bool, AutoMarkPrompts, "experimental.autoMarkPrompts", false) \
X(bool, ShowMarks, "experimental.showMarksOnScrollbar", false) \
X(bool, RepositionCursorWithMouse, "experimental.repositionCursorWithMouse", false) \

View File

@@ -59,7 +59,6 @@ namespace Microsoft.Terminal.Settings.Model
INHERITABLE_PROFILE_SETTING(Microsoft.Terminal.Control.ScrollbarState, ScrollState);
INHERITABLE_PROFILE_SETTING(String, Padding);
INHERITABLE_PROFILE_SETTING(String, Commandline);
INHERITABLE_PROFILE_SETTING(Boolean, VtPassthrough);
INHERITABLE_PROFILE_SETTING(String, StartingDirectory);
String EvaluatedStartingDirectory { get; };

View File

@@ -297,7 +297,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
_Padding = profile.Padding();
_Commandline = profile.Commandline();
_VtPassthrough = profile.VtPassthrough();
_StartingDirectory = profile.EvaluatedStartingDirectory();

View File

@@ -95,7 +95,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
INHERITABLE_SETTING(Model::TerminalSettings, bool, FocusFollowMouse, false);
INHERITABLE_SETTING(Model::TerminalSettings, bool, TrimBlockSelection, true);
INHERITABLE_SETTING(Model::TerminalSettings, bool, DetectURLs, true);
INHERITABLE_SETTING(Model::TerminalSettings, bool, VtPassthrough, false);
INHERITABLE_SETTING(Model::TerminalSettings, Windows::Foundation::IReference<Microsoft::Terminal::Core::Color>, TabColor, nullptr);

View File

@@ -48,7 +48,6 @@
X(bool, ForceVTInput, false) \
X(winrt::hstring, StartingTitle) \
X(bool, DetectURLs, true) \
X(bool, VtPassthrough, false) \
X(bool, AutoMarkPrompts) \
X(bool, RepositionCursorWithMouse, false)

View File

@@ -86,28 +86,6 @@
</alwaysDisabledBrandingTokens>
</feature>
<feature>
<name>Feature_VtPassthroughMode</name>
<description>Enables passthrough option per profile in Terminal and ConPTY ability to use passthrough API dispatch engine</description>
<stage>AlwaysDisabled</stage>
<!-- Did it this way instead of "release tokens" to ensure it won't go into Windows Inbox either... -->
<alwaysEnabledBrandingTokens>
<brandingToken>Dev</brandingToken>
<brandingToken>Canary</brandingToken>
<brandingToken>Preview</brandingToken>
</alwaysEnabledBrandingTokens>
</feature>
<feature>
<name>Feature_VtPassthroughModeSettingInUI</name>
<description>Enables the setting gated by Feature_VtPassthroughMode to appear in the UI</description>
<stage>AlwaysDisabled</stage>
<alwaysEnabledBrandingTokens>
<brandingToken>Dev</brandingToken>
<!-- Unlike Feature_VtPassthroughMode, this is not enabled in Preview -->
</alwaysEnabledBrandingTokens>
</feature>
<feature>
<name>Feature_ScrollbarMarks</name>
<description>Enables the experimental scrollbar marks feature.</description>

View File

@@ -23,7 +23,6 @@ const std::wstring_view ConsoleArguments::RESIZE_QUIRK = L"--resizeQuirk";
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";
const std::wstring_view ConsoleArguments::PASSTHROUGH_ARG = L"--passthrough";
// 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
@@ -467,12 +466,6 @@ void ConsoleArguments::s_ConsumeArg(_Inout_ std::vector<std::wstring>& args, _In
s_ConsumeArg(args, i);
hr = S_OK;
}
else if (arg == PASSTHROUGH_ARG)
{
_passthroughMode = true;
s_ConsumeArg(args, i);
hr = S_OK;
}
else if (arg.substr(0, FILEPATH_LEADER_PREFIX.length()) == FILEPATH_LEADER_PREFIX)
{
// beginning of command line -- includes file path
@@ -602,11 +595,6 @@ bool ConsoleArguments::ShouldRunAsComServer() const
return _runAsComServer;
}
bool ConsoleArguments::IsPassthroughMode() const noexcept
{
return _passthroughMode;
}
HANDLE ConsoleArguments::GetServerHandle() const
{
return ULongToHandle(_serverHandle);

View File

@@ -36,7 +36,6 @@ public:
bool IsHeadless() const;
bool ShouldCreateServerHandle() const;
bool ShouldRunAsComServer() const;
bool IsPassthroughMode() const noexcept;
HANDLE GetServerHandle() const;
HANDLE GetVtInHandle() const;
@@ -76,7 +75,6 @@ public:
static const std::wstring_view FEATURE_ARG;
static const std::wstring_view FEATURE_PTY_ARG;
static const std::wstring_view COM_SERVER_ARG;
static const std::wstring_view PASSTHROUGH_ARG;
private:
#ifdef UNIT_TESTING
@@ -95,8 +93,7 @@ private:
const DWORD serverHandle,
const DWORD signalHandle,
const bool inheritCursor,
const bool runAsComServer,
const bool passthroughMode) :
const bool runAsComServer) :
_commandline(commandline),
_clientCommandline(clientCommandline),
_vtInHandle(vtInHandle),
@@ -112,8 +109,7 @@ private:
_signalHandle(signalHandle),
_inheritCursor(inheritCursor),
_resizeQuirk(false),
_runAsComServer{ runAsComServer },
_passthroughMode{ passthroughMode }
_runAsComServer{ runAsComServer }
{
}
#endif
@@ -135,7 +131,6 @@ private:
short _width;
short _height;
bool _passthroughMode{ false };
bool _runAsComServer;
bool _createServerHandle;
DWORD _serverHandle;
@@ -191,7 +186,6 @@ namespace WEX
L"Signal Handle: '0x%x'\r\n",
L"Inherit Cursor: '%ws'\r\n",
L"Run As Com Server: '%ws'\r\n",
L"Passthrough Mode: '%ws'\r\n",
ci.GetClientCommandline().c_str(),
s_ToBoolString(ci.HasVtHandles()),
ci.GetVtInHandle(),
@@ -206,8 +200,7 @@ namespace WEX
s_ToBoolString(ci.HasSignalHandle()),
ci.GetSignalHandle(),
s_ToBoolString(ci.GetInheritCursor()),
s_ToBoolString(ci.ShouldRunAsComServer()),
s_ToBoolString(ci.IsPassthroughMode()));
s_ToBoolString(ci.ShouldRunAsComServer()));
}
private:
@@ -237,8 +230,7 @@ namespace WEX
expected.HasSignalHandle() == actual.HasSignalHandle() &&
expected.GetSignalHandle() == actual.GetSignalHandle() &&
expected.GetInheritCursor() == actual.GetInheritCursor() &&
expected.ShouldRunAsComServer() == actual.ShouldRunAsComServer() &&
expected.IsPassthroughMode() == actual.IsPassthroughMode();
expected.ShouldRunAsComServer() == actual.ShouldRunAsComServer();
}
static bool AreSame(const ConsoleArguments& expected, const ConsoleArguments& actual)
@@ -264,8 +256,7 @@ namespace WEX
object.GetServerHandle() == 0 &&
(object.GetSignalHandle() == 0 || object.GetSignalHandle() == INVALID_HANDLE_VALUE) &&
!object.GetInheritCursor() &&
!object.ShouldRunAsComServer() &&
!object.IsPassthroughMode();
!object.ShouldRunAsComServer();
}
};
}

View File

@@ -1,810 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "precomp.h"
#include "VtApiRoutines.h"
#include "../interactivity/inc/ServiceLocator.hpp"
#include "../types/inc/convert.hpp"
using namespace Microsoft::Console::Interactivity;
// When someone attempts to use the console APIs to do a "read back"
// of the console buffer, we have to give them **something**.
// These two structures are just some gaudy-colored replacement character
// text to give them data but represent they've done something that cannot
// be supported under VT passthrough mode.
// ----
// They can't be supported because in passthrough we maintain no internal
// buffer to answer these questions, and there is no VT sequence that lets
// us query the final terminal's buffer state. Even if a VT sequence did exist
// (and we personally believe it shouldn't), there's a possibility that it would
// read a massive amount of data and cause severe perf issues as applications coded
// to this old API are likely leaning on it heavily and asking for this data in a
// loop via VT would be a nightmare of parsing and formatting and over-the-wire transmission.
static constexpr CHAR_INFO s_readBackUnicode{
{ UNICODE_REPLACEMENT },
FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_GREEN
};
static constexpr CHAR_INFO s_readBackAscii{
{ L'?' },
FOREGROUND_INTENSITY | FOREGROUND_RED | BACKGROUND_GREEN
};
VtApiRoutines::VtApiRoutines() :
m_inputCodepage(ServiceLocator::LocateGlobals().getConsoleInformation().CP),
m_outputCodepage(ServiceLocator::LocateGlobals().getConsoleInformation().OutputCP),
m_inputMode(),
m_outputMode(),
m_pUsualRoutines(),
m_pVtEngine(),
m_listeningForDSR(false)
{
}
#pragma warning(push)
#pragma warning(disable : 4100) // unreferenced param
void VtApiRoutines::GetConsoleInputCodePageImpl(ULONG& codepage) noexcept
{
codepage = m_inputCodepage;
return;
}
void VtApiRoutines::GetConsoleOutputCodePageImpl(ULONG& codepage) noexcept
{
codepage = m_outputCodepage;
return;
}
void VtApiRoutines::GetConsoleInputModeImpl(InputBuffer& context,
ULONG& mode) noexcept
{
mode = m_inputMode;
return;
}
void VtApiRoutines::GetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
ULONG& mode) noexcept
{
mode = m_outputMode;
return;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleInputModeImpl(InputBuffer& context,
const ULONG mode) noexcept
{
m_inputMode = mode;
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
const ULONG Mode) noexcept
{
m_outputMode = Mode;
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetNumberOfConsoleInputEventsImpl(const InputBuffer& context,
ULONG& events) noexcept
{
return m_pUsualRoutines->GetNumberOfConsoleInputEventsImpl(context, events);
}
void VtApiRoutines::_SynchronizeCursor(std::unique_ptr<IWaitRoutine>& waiter) noexcept
{
// If we're about to tell the caller to wait, let's synchronize the cursor we have with what
// the terminal is presenting in case there's a cooked read going on.
// TODO GH#10001: we only need to do this in cooked read mode.
if (waiter)
{
m_listeningForDSR = true;
(void)m_pVtEngine->_ListenForDSR();
(void)m_pVtEngine->RequestCursor();
}
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleInputImpl(
IConsoleInputObject& context,
InputEventQueue& outEvents,
const size_t eventReadCount,
INPUT_READ_HANDLE_DATA& readHandleState,
const bool IsUnicode,
const bool IsPeek,
std::unique_ptr<IWaitRoutine>& waiter) noexcept
{
const auto hr = m_pUsualRoutines->GetConsoleInputImpl(context, outEvents, eventReadCount, readHandleState, IsUnicode, IsPeek, waiter);
_SynchronizeCursor(waiter);
return hr;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleImpl(IConsoleInputObject& context,
std::span<char> buffer,
size_t& written,
std::unique_ptr<IWaitRoutine>& waiter,
const std::wstring_view initialData,
const std::wstring_view exeName,
INPUT_READ_HANDLE_DATA& readHandleState,
const bool IsUnicode,
const HANDLE clientHandle,
const DWORD controlWakeupMask,
DWORD& controlKeyState) noexcept
{
const auto hr = m_pUsualRoutines->ReadConsoleImpl(context, buffer, written, waiter, initialData, exeName, readHandleState, IsUnicode, clientHandle, controlWakeupMask, controlKeyState);
// If we're about to tell the caller to wait, let's synchronize the cursor we have with what
// the terminal is presenting in case there's a cooked read going on.
// TODO GH10001: we only need to do this in cooked read mode.
if (clientHandle)
{
m_listeningForDSR = true;
(void)m_pVtEngine->_ListenForDSR();
(void)m_pVtEngine->RequestCursor();
}
return hr;
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleAImpl(IConsoleOutputObject& context,
const std::string_view buffer,
size_t& read,
bool requiresVtQuirk,
std::unique_ptr<IWaitRoutine>& waiter) noexcept
{
if (CP_UTF8 == m_outputCodepage)
{
(void)m_pVtEngine->WriteTerminalUtf8(buffer);
}
else
{
(void)m_pVtEngine->WriteTerminalW(ConvertToW(m_outputCodepage, buffer));
}
(void)m_pVtEngine->_Flush();
read = buffer.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleWImpl(IConsoleOutputObject& context,
const std::wstring_view buffer,
size_t& read,
bool requiresVtQuirk,
std::unique_ptr<IWaitRoutine>& waiter) noexcept
{
(void)m_pVtEngine->WriteTerminalW(buffer);
(void)m_pVtEngine->_Flush();
read = buffer.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleLangIdImpl(LANGID& langId) noexcept
{
return m_pUsualRoutines->GetConsoleLangIdImpl(langId);
}
[[nodiscard]] HRESULT VtApiRoutines::FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const WORD attribute,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified) noexcept
{
(void)m_pVtEngine->_CursorPosition(startingCoordinate);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attribute), true);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attribute >> 4), false);
(void)m_pVtEngine->_WriteFill(lengthToWrite, s_readBackAscii.Char.AsciiChar);
(void)m_pVtEngine->_Flush();
cellsModified = lengthToWrite;
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const char character,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified) noexcept
{
// I mean... if you get your jollies by using UTF8 for single byte codepoints...
// we may as well skip a lot of conversion work and just write it out.
if (m_outputCodepage == CP_UTF8 && character <= 0x7F)
{
(void)m_pVtEngine->_CursorPosition(startingCoordinate);
(void)m_pVtEngine->_WriteFill(lengthToWrite, character);
(void)m_pVtEngine->_Flush();
cellsModified = lengthToWrite;
return S_OK;
}
else
{
const auto wstr = ConvertToW(m_outputCodepage, std::string_view{ &character, 1 });
return FillConsoleOutputCharacterWImpl(OutContext, wstr.front(), lengthToWrite, startingCoordinate, cellsModified);
}
}
[[nodiscard]] HRESULT VtApiRoutines::FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const wchar_t character,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified,
const bool enablePowershellShim) noexcept
{
(void)m_pVtEngine->_CursorPosition(startingCoordinate);
const std::wstring_view sv{ &character, 1 };
// TODO GH10001: horrible. it'll WC2MB over and over...we should do that once then emit... and then rep...
// TODO GH10001: there's probably an optimization for if ((character & 0x7F) == character) --> call the UTF8 one.
for (size_t i = 0; i < lengthToWrite; ++i)
{
(void)m_pVtEngine->WriteTerminalW(sv);
}
(void)m_pVtEngine->_Flush();
cellsModified = lengthToWrite;
return S_OK;
}
//// Process based. Restrict in protocol side?
//HRESULT GenerateConsoleCtrlEventImpl(const ULONG ProcessGroupFilter,
// const ULONG ControlEvent);
void VtApiRoutines::SetConsoleActiveScreenBufferImpl(SCREEN_INFORMATION& newContext) noexcept
{
return;
}
void VtApiRoutines::FlushConsoleInputBuffer(InputBuffer& context) noexcept
{
m_pUsualRoutines->FlushConsoleInputBuffer(context);
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleInputCodePageImpl(const ULONG codepage) noexcept
{
m_inputCodepage = codepage;
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleOutputCodePageImpl(const ULONG codepage) noexcept
{
m_outputCodepage = codepage;
return S_OK;
}
void VtApiRoutines::GetConsoleCursorInfoImpl(const SCREEN_INFORMATION& context,
ULONG& size,
bool& isVisible) noexcept
{
// TODO GH10001: good luck capturing this out of the input buffer when it comes back in.
//m_pVtEngine->RequestCursor();
return;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleCursorInfoImpl(SCREEN_INFORMATION& context,
const ULONG size,
const bool isVisible) noexcept
{
isVisible ? (void)m_pVtEngine->_ShowCursor() : (void)m_pVtEngine->_HideCursor();
(void)m_pVtEngine->_Flush();
return S_OK;
}
//// driver will pare down for non-Ex method
void VtApiRoutines::GetConsoleScreenBufferInfoExImpl(const SCREEN_INFORMATION& context,
CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept
{
// TODO GH10001: this is technically full of potentially incorrect data. do we care? should we store it in here with set?
return m_pUsualRoutines->GetConsoleScreenBufferInfoExImpl(context, data);
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleScreenBufferInfoExImpl(SCREEN_INFORMATION& context,
const CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept
{
(void)m_pVtEngine->_ResizeWindow(data.srWindow.Right - data.srWindow.Left, data.srWindow.Bottom - data.srWindow.Top);
(void)m_pVtEngine->_CursorPosition(til::wrap_coord(data.dwCursorPosition));
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(data.wAttributes), true);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(data.wAttributes >> 4), false);
//color table?
// popup attributes... hold internally?
// TODO GH10001: popups are gonna erase the stuff behind them... deal with that somehow.
(void)m_pVtEngine->_Flush();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleScreenBufferSizeImpl(SCREEN_INFORMATION& context,
const til::size size) noexcept
{
// Don't transmit. The terminal figures out its own buffer size.
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleCursorPositionImpl(SCREEN_INFORMATION& context,
const til::point position) noexcept
{
if (m_listeningForDSR)
{
context.GetActiveBuffer().GetTextBuffer().GetCursor().SetPosition(position);
m_pVtEngine->SetTerminalCursorTextPosition(position);
}
else
{
(void)m_pVtEngine->_CursorPosition(position);
(void)m_pVtEngine->_Flush();
}
return S_OK;
}
void VtApiRoutines::GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& context,
til::size& size) noexcept
{
m_pUsualRoutines->GetLargestConsoleWindowSizeImpl(context, size); // This is likely super weird but not weirder than existing ConPTY answers.
return;
}
[[nodiscard]] HRESULT VtApiRoutines::ScrollConsoleScreenBufferAImpl(SCREEN_INFORMATION& context,
const til::inclusive_rect& source,
const til::point target,
std::optional<til::inclusive_rect> clip,
const char fillCharacter,
const WORD fillAttribute) noexcept
{
// TODO GH10001: Use DECCRA
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
const til::inclusive_rect& source,
const til::point target,
std::optional<til::inclusive_rect> clip,
const wchar_t fillCharacter,
const WORD fillAttribute,
const bool enableCmdShim) noexcept
{
// TODO GH10001: Use DECCRA
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleTextAttributeImpl(SCREEN_INFORMATION& context,
const WORD attribute) noexcept
{
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attribute), true);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attribute >> 4), false);
(void)m_pVtEngine->_Flush();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleWindowInfoImpl(SCREEN_INFORMATION& context,
const bool isAbsolute,
const til::inclusive_rect& windowRect) noexcept
{
(void)m_pVtEngine->_ResizeWindow(windowRect.right - windowRect.left + 1, windowRect.bottom - windowRect.top + 1);
(void)m_pVtEngine->_Flush();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<WORD> buffer,
size_t& written) noexcept
{
std::fill_n(buffer.data(), buffer.size(), s_readBackUnicode.Attributes); // should be same as the ascii one.
written = buffer.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<char> buffer,
size_t& written) noexcept
{
std::fill_n(buffer.data(), buffer.size(), s_readBackAscii.Char.AsciiChar);
written = buffer.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<wchar_t> buffer,
size_t& written) noexcept
{
std::fill_n(buffer.data(), buffer.size(), s_readBackUnicode.Char.UnicodeChar);
written = buffer.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleInputAImpl(InputBuffer& context,
const std::span<const INPUT_RECORD> buffer,
size_t& written,
const bool append) noexcept
{
return m_pUsualRoutines->WriteConsoleInputAImpl(context, buffer, written, append);
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleInputWImpl(InputBuffer& context,
const std::span<const INPUT_RECORD> buffer,
size_t& written,
const bool append) noexcept
{
return m_pUsualRoutines->WriteConsoleInputWImpl(context, buffer, written, append);
}
extern HRESULT _ConvertCellsToWInplace(const UINT codepage,
std::span<CHAR_INFO> buffer,
const Viewport& rectangle) noexcept;
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleOutputAImpl(SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept
{
// No UTF8 optimization because the entire `CHAR_INFO` grid system doesn't make sense for UTF-8
// with up to 4 bytes per cell...or more!
RETURN_IF_FAILED(_ConvertCellsToWInplace(m_outputCodepage, buffer, requestRectangle));
return WriteConsoleOutputWImpl(context, buffer, requestRectangle, writtenRectangle);
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleOutputWImpl(SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept
{
auto cursor = requestRectangle.Origin();
const size_t width = requestRectangle.Width();
size_t pos = 0;
while (pos < buffer.size())
{
(void)m_pVtEngine->_CursorPosition(cursor);
const auto subspan = buffer.subspan(pos, width);
for (const auto& ci : subspan)
{
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(ci.Attributes), true);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(ci.Attributes >> 4), false);
(void)m_pVtEngine->WriteTerminalW(std::wstring_view{ &ci.Char.UnicodeChar, 1 });
}
++cursor.y;
pos += width;
}
(void)m_pVtEngine->_Flush();
//TODO GH10001: trim to buffer size?
writtenRectangle = requestRectangle;
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const std::span<const WORD> attrs,
const til::point target,
size_t& used) noexcept
{
(void)m_pVtEngine->_CursorPosition(target);
for (const auto& attr : attrs)
{
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attr), true);
(void)m_pVtEngine->_SetGraphicsRendition16Color(static_cast<BYTE>(attr >> 4), false);
(void)m_pVtEngine->WriteTerminalUtf8(std::string_view{ &s_readBackAscii.Char.AsciiChar, 1 });
}
(void)m_pVtEngine->_Flush();
used = attrs.size();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const std::string_view text,
const til::point target,
size_t& used) noexcept
{
if (m_outputCodepage == CP_UTF8)
{
(void)m_pVtEngine->_CursorPosition(target);
(void)m_pVtEngine->WriteTerminalUtf8(text);
(void)m_pVtEngine->_Flush();
return S_OK;
}
else
{
return WriteConsoleOutputCharacterWImpl(OutContext, ConvertToW(m_outputCodepage, text), target, used);
}
}
[[nodiscard]] HRESULT VtApiRoutines::WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const std::wstring_view text,
const til::point target,
size_t& used) noexcept
{
(void)m_pVtEngine->_CursorPosition(target);
(void)m_pVtEngine->WriteTerminalW(text);
(void)m_pVtEngine->_Flush();
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleOutputAImpl(const SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept
{
std::fill_n(buffer.data(), buffer.size(), s_readBackAscii);
// TODO GH10001: do we need to constrict readRectangle to within the known buffer size... probably.
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::ReadConsoleOutputWImpl(const SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept
{
std::fill_n(buffer.data(), buffer.size(), s_readBackUnicode);
// TODO GH10001: do we need to constrict readRectangle to within the known buffer size... probably.
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleTitleAImpl(std::span<char> title,
size_t& written,
size_t& needed) noexcept
{
written = 0;
needed = 0;
if (!title.empty())
{
title.front() = ANSI_NULL;
}
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleTitleWImpl(std::span<wchar_t> title,
size_t& written,
size_t& needed) noexcept
{
written = 0;
needed = 0;
if (!title.empty())
{
title.front() = UNICODE_NULL;
}
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleOriginalTitleAImpl(std::span<char> title,
size_t& written,
size_t& needed) noexcept
{
written = 0;
needed = 0;
if (!title.empty())
{
title.front() = ANSI_NULL;
}
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleOriginalTitleWImpl(std::span<wchar_t> title,
size_t& written,
size_t& needed) noexcept
{
written = 0;
needed = 0;
if (!title.empty())
{
title.front() = UNICODE_NULL;
}
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleTitleAImpl(const std::string_view title) noexcept
{
return SetConsoleTitleWImpl(ConvertToW(m_inputCodepage, title));
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleTitleWImpl(const std::wstring_view title) noexcept
{
(void)m_pVtEngine->UpdateTitle(title);
(void)m_pVtEngine->_Flush();
return S_OK;
}
void VtApiRoutines::GetNumberOfConsoleMouseButtonsImpl(ULONG& buttons) noexcept
{
buttons = 2;
return;
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleFontSizeImpl(const SCREEN_INFORMATION& context,
const DWORD index,
til::size& size) noexcept
{
size.width = 8;
size.height = 12;
return S_OK;
}
//// driver will pare down for non-Ex method
[[nodiscard]] HRESULT VtApiRoutines::GetCurrentConsoleFontExImpl(const SCREEN_INFORMATION& context,
const bool isForMaximumWindowSize,
CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept
{
return S_OK;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleDisplayModeImpl(SCREEN_INFORMATION& context,
const ULONG flags,
til::size& newSize) noexcept
{
return S_OK;
}
void VtApiRoutines::GetConsoleDisplayModeImpl(ULONG& flags) noexcept
{
flags = 0;
return;
}
[[nodiscard]] HRESULT VtApiRoutines::AddConsoleAliasAImpl(const std::string_view source,
const std::string_view target,
const std::string_view exeName) noexcept
{
return m_pUsualRoutines->AddConsoleAliasAImpl(source, target, exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::AddConsoleAliasWImpl(const std::wstring_view source,
const std::wstring_view target,
const std::wstring_view exeName) noexcept
{
return m_pUsualRoutines->AddConsoleAliasWImpl(source, target, exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasAImpl(const std::string_view source,
std::span<char> target,
size_t& written,
const std::string_view exeName) noexcept
{
return m_pUsualRoutines->GetConsoleAliasAImpl(source, target, written, exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasWImpl(const std::wstring_view source,
std::span<wchar_t> target,
size_t& written,
const std::wstring_view exeName) noexcept
{
return m_pUsualRoutines->GetConsoleAliasWImpl(source, target, written, exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasesLengthAImpl(const std::string_view exeName,
size_t& bufferRequired) noexcept
{
return m_pUsualRoutines->GetConsoleAliasesLengthAImpl(exeName, bufferRequired);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
size_t& bufferRequired) noexcept
{
return m_pUsualRoutines->GetConsoleAliasesLengthWImpl(exeName, bufferRequired);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept
{
return m_pUsualRoutines->GetConsoleAliasExesLengthAImpl(bufferRequired);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept
{
return m_pUsualRoutines->GetConsoleAliasExesLengthWImpl(bufferRequired);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasesAImpl(const std::string_view exeName,
std::span<char> alias,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleAliasesAImpl(exeName, alias, written);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasesWImpl(const std::wstring_view exeName,
std::span<wchar_t> alias,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleAliasesWImpl(exeName, alias, written);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasExesAImpl(std::span<char> aliasExes,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleAliasExesAImpl(aliasExes, written);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleAliasExesWImpl(std::span<wchar_t> aliasExes,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleAliasExesWImpl(aliasExes, written);
}
[[nodiscard]] HRESULT VtApiRoutines::ExpungeConsoleCommandHistoryAImpl(const std::string_view exeName) noexcept
{
return m_pUsualRoutines->ExpungeConsoleCommandHistoryAImpl(exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::ExpungeConsoleCommandHistoryWImpl(const std::wstring_view exeName) noexcept
{
return m_pUsualRoutines->ExpungeConsoleCommandHistoryWImpl(exeName);
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleNumberOfCommandsAImpl(const std::string_view exeName,
const size_t numberOfCommands) noexcept
{
return m_pUsualRoutines->SetConsoleNumberOfCommandsAImpl(exeName, numberOfCommands);
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleNumberOfCommandsWImpl(const std::wstring_view exeName,
const size_t numberOfCommands) noexcept
{
return m_pUsualRoutines->SetConsoleNumberOfCommandsWImpl(exeName, numberOfCommands);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleCommandHistoryLengthAImpl(const std::string_view exeName,
size_t& length) noexcept
{
return m_pUsualRoutines->GetConsoleCommandHistoryLengthAImpl(exeName, length);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleCommandHistoryLengthWImpl(const std::wstring_view exeName,
size_t& length) noexcept
{
return m_pUsualRoutines->GetConsoleCommandHistoryLengthWImpl(exeName, length);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleCommandHistoryAImpl(const std::string_view exeName,
std::span<char> commandHistory,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleCommandHistoryAImpl(exeName, commandHistory, written);
}
[[nodiscard]] HRESULT VtApiRoutines::GetConsoleCommandHistoryWImpl(const std::wstring_view exeName,
std::span<wchar_t> commandHistory,
size_t& written) noexcept
{
return m_pUsualRoutines->GetConsoleCommandHistoryWImpl(exeName, commandHistory, written);
}
void VtApiRoutines::GetConsoleWindowImpl(HWND& hwnd) noexcept
{
hwnd = ServiceLocator::LocatePseudoWindow();
return;
}
void VtApiRoutines::GetConsoleSelectionInfoImpl(CONSOLE_SELECTION_INFO& consoleSelectionInfo) noexcept
{
consoleSelectionInfo = { 0 };
return;
}
void VtApiRoutines::GetConsoleHistoryInfoImpl(CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept
{
m_pUsualRoutines->GetConsoleHistoryInfoImpl(consoleHistoryInfo);
return;
}
[[nodiscard]] HRESULT VtApiRoutines::SetConsoleHistoryInfoImpl(const CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept
{
return m_pUsualRoutines->SetConsoleHistoryInfoImpl(consoleHistoryInfo);
}
[[nodiscard]] HRESULT VtApiRoutines::SetCurrentConsoleFontExImpl(IConsoleOutputObject& context,
const bool isForMaximumWindowSize,
const CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept
{
return S_OK;
}
#pragma warning(pop)

View File

@@ -1,366 +0,0 @@
/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- VtApiRoutines.h
Abstract:
- This file defines the interface to respond to all API calls by using VT on behalf of the client
Author:
- Michael Niksa (miniksa) 26-Jul-2021
Revision History:
- Adapted from original items in srvinit.cpp, getset.cpp, directio.cpp, stream.cpp
--*/
#pragma once
#include "../server/IApiRoutines.h"
#include "../renderer/vt/Xterm256Engine.hpp"
class VtApiRoutines : public IApiRoutines
{
public:
VtApiRoutines();
#pragma region ObjectManagement
/*HRESULT CreateInitialObjects(_Out_ InputBuffer** const ppInputObject,
_Out_ SCREEN_INFORMATION** const ppOutputObject);
*/
#pragma endregion
#pragma region L1
void GetConsoleInputCodePageImpl(ULONG& codepage) noexcept override;
void GetConsoleOutputCodePageImpl(ULONG& codepage) noexcept override;
void GetConsoleInputModeImpl(InputBuffer& context,
ULONG& mode) noexcept override;
void GetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
ULONG& mode) noexcept override;
[[nodiscard]] HRESULT SetConsoleInputModeImpl(InputBuffer& context,
const ULONG mode) noexcept override;
[[nodiscard]] HRESULT SetConsoleOutputModeImpl(SCREEN_INFORMATION& context,
const ULONG Mode) noexcept override;
[[nodiscard]] HRESULT GetNumberOfConsoleInputEventsImpl(const InputBuffer& context,
ULONG& events) noexcept override;
[[nodiscard]] HRESULT GetConsoleInputImpl(IConsoleInputObject& context,
InputEventQueue& outEvents,
const size_t eventReadCount,
INPUT_READ_HANDLE_DATA& readHandleState,
const bool IsUnicode,
const bool IsPeek,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] HRESULT ReadConsoleImpl(IConsoleInputObject& context,
std::span<char> buffer,
size_t& written,
std::unique_ptr<IWaitRoutine>& waiter,
const std::wstring_view initialData,
const std::wstring_view exeName,
INPUT_READ_HANDLE_DATA& readHandleState,
const bool IsUnicode,
const HANDLE clientHandle,
const DWORD controlWakeupMask,
DWORD& controlKeyState) noexcept override;
[[nodiscard]] HRESULT WriteConsoleAImpl(IConsoleOutputObject& context,
const std::string_view buffer,
size_t& read,
bool requiresVtQuirk,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
[[nodiscard]] HRESULT WriteConsoleWImpl(IConsoleOutputObject& context,
const std::wstring_view buffer,
size_t& read,
bool requiresVtQuirk,
std::unique_ptr<IWaitRoutine>& waiter) noexcept override;
#pragma region ThreadCreationInfo
[[nodiscard]] HRESULT GetConsoleLangIdImpl(LANGID& langId) noexcept override;
#pragma endregion
#pragma endregion
#pragma region L2
[[nodiscard]] HRESULT FillConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const WORD attribute,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified) noexcept override;
[[nodiscard]] HRESULT FillConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const char character,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified) noexcept override;
[[nodiscard]] HRESULT FillConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const wchar_t character,
const size_t lengthToWrite,
const til::point startingCoordinate,
size_t& cellsModified,
const bool enablePowershellShim = false) noexcept override;
//// Process based. Restrict in protocol side?
//HRESULT GenerateConsoleCtrlEventImpl(const ULONG ProcessGroupFilter,
// const ULONG ControlEvent);
void SetConsoleActiveScreenBufferImpl(SCREEN_INFORMATION& newContext) noexcept override;
void FlushConsoleInputBuffer(InputBuffer& context) noexcept override;
[[nodiscard]] HRESULT SetConsoleInputCodePageImpl(const ULONG codepage) noexcept override;
[[nodiscard]] HRESULT SetConsoleOutputCodePageImpl(const ULONG codepage) noexcept override;
void GetConsoleCursorInfoImpl(const SCREEN_INFORMATION& context,
ULONG& size,
bool& isVisible) noexcept override;
[[nodiscard]] HRESULT SetConsoleCursorInfoImpl(SCREEN_INFORMATION& context,
const ULONG size,
const bool isVisible) noexcept override;
//// driver will pare down for non-Ex method
void GetConsoleScreenBufferInfoExImpl(const SCREEN_INFORMATION& context,
CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override;
[[nodiscard]] HRESULT SetConsoleScreenBufferInfoExImpl(SCREEN_INFORMATION& context,
const CONSOLE_SCREEN_BUFFER_INFOEX& data) noexcept override;
[[nodiscard]] HRESULT SetConsoleScreenBufferSizeImpl(SCREEN_INFORMATION& context,
const til::size size) noexcept override;
[[nodiscard]] HRESULT SetConsoleCursorPositionImpl(SCREEN_INFORMATION& context,
const til::point position) noexcept override;
void GetLargestConsoleWindowSizeImpl(const SCREEN_INFORMATION& context,
til::size& size) noexcept override;
[[nodiscard]] HRESULT ScrollConsoleScreenBufferAImpl(SCREEN_INFORMATION& context,
const til::inclusive_rect& source,
const til::point target,
std::optional<til::inclusive_rect> clip,
const char fillCharacter,
const WORD fillAttribute) noexcept override;
[[nodiscard]] HRESULT ScrollConsoleScreenBufferWImpl(SCREEN_INFORMATION& context,
const til::inclusive_rect& source,
const til::point target,
std::optional<til::inclusive_rect> clip,
const wchar_t fillCharacter,
const WORD fillAttribute,
const bool enableCmdShim = false) noexcept override;
[[nodiscard]] HRESULT SetConsoleTextAttributeImpl(SCREEN_INFORMATION& context,
const WORD attribute) noexcept override;
[[nodiscard]] HRESULT SetConsoleWindowInfoImpl(SCREEN_INFORMATION& context,
const bool isAbsolute,
const til::inclusive_rect& windowRect) noexcept override;
[[nodiscard]] HRESULT ReadConsoleOutputAttributeImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<WORD> buffer,
size_t& written) noexcept override;
[[nodiscard]] HRESULT ReadConsoleOutputCharacterAImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<char> buffer,
size_t& written) noexcept override;
[[nodiscard]] HRESULT ReadConsoleOutputCharacterWImpl(const SCREEN_INFORMATION& context,
const til::point origin,
std::span<wchar_t> buffer,
size_t& written) noexcept override;
[[nodiscard]] HRESULT WriteConsoleInputAImpl(InputBuffer& context,
const std::span<const INPUT_RECORD> buffer,
size_t& written,
const bool append) noexcept override;
[[nodiscard]] HRESULT WriteConsoleInputWImpl(InputBuffer& context,
const std::span<const INPUT_RECORD> buffer,
size_t& written,
const bool append) noexcept override;
[[nodiscard]] HRESULT WriteConsoleOutputAImpl(SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override;
[[nodiscard]] HRESULT WriteConsoleOutputWImpl(SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& requestRectangle,
Microsoft::Console::Types::Viewport& writtenRectangle) noexcept override;
[[nodiscard]] HRESULT WriteConsoleOutputAttributeImpl(IConsoleOutputObject& OutContext,
const std::span<const WORD> attrs,
const til::point target,
size_t& used) noexcept override;
[[nodiscard]] HRESULT WriteConsoleOutputCharacterAImpl(IConsoleOutputObject& OutContext,
const std::string_view text,
const til::point target,
size_t& used) noexcept override;
[[nodiscard]] HRESULT WriteConsoleOutputCharacterWImpl(IConsoleOutputObject& OutContext,
const std::wstring_view text,
const til::point target,
size_t& used) noexcept override;
[[nodiscard]] HRESULT ReadConsoleOutputAImpl(const SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept override;
[[nodiscard]] HRESULT ReadConsoleOutputWImpl(const SCREEN_INFORMATION& context,
std::span<CHAR_INFO> buffer,
const Microsoft::Console::Types::Viewport& sourceRectangle,
Microsoft::Console::Types::Viewport& readRectangle) noexcept override;
[[nodiscard]] HRESULT GetConsoleTitleAImpl(std::span<char> title,
size_t& written,
size_t& needed) noexcept override;
[[nodiscard]] HRESULT GetConsoleTitleWImpl(std::span<wchar_t> title,
size_t& written,
size_t& needed) noexcept override;
[[nodiscard]] HRESULT GetConsoleOriginalTitleAImpl(std::span<char> title,
size_t& written,
size_t& needed) noexcept override;
[[nodiscard]] HRESULT GetConsoleOriginalTitleWImpl(std::span<wchar_t> title,
size_t& written,
size_t& needed) noexcept override;
[[nodiscard]] HRESULT SetConsoleTitleAImpl(const std::string_view title) noexcept override;
[[nodiscard]] HRESULT SetConsoleTitleWImpl(const std::wstring_view title) noexcept override;
#pragma endregion
#pragma region L3
void GetNumberOfConsoleMouseButtonsImpl(ULONG& buttons) noexcept override;
[[nodiscard]] HRESULT GetConsoleFontSizeImpl(const SCREEN_INFORMATION& context,
const DWORD index,
til::size& size) noexcept override;
//// driver will pare down for non-Ex method
[[nodiscard]] HRESULT GetCurrentConsoleFontExImpl(const SCREEN_INFORMATION& context,
const bool isForMaximumWindowSize,
CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override;
[[nodiscard]] HRESULT SetConsoleDisplayModeImpl(SCREEN_INFORMATION& context,
const ULONG flags,
til::size& newSize) noexcept override;
void GetConsoleDisplayModeImpl(ULONG& flags) noexcept override;
[[nodiscard]] HRESULT AddConsoleAliasAImpl(const std::string_view source,
const std::string_view target,
const std::string_view exeName) noexcept override;
[[nodiscard]] HRESULT AddConsoleAliasWImpl(const std::wstring_view source,
const std::wstring_view target,
const std::wstring_view exeName) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasAImpl(const std::string_view source,
std::span<char> target,
size_t& written,
const std::string_view exeName) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasWImpl(const std::wstring_view source,
std::span<wchar_t> target,
size_t& written,
const std::wstring_view exeName) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasesLengthAImpl(const std::string_view exeName,
size_t& bufferRequired) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasesLengthWImpl(const std::wstring_view exeName,
size_t& bufferRequired) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasExesLengthAImpl(size_t& bufferRequired) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasExesLengthWImpl(size_t& bufferRequired) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasesAImpl(const std::string_view exeName,
std::span<char> alias,
size_t& written) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasesWImpl(const std::wstring_view exeName,
std::span<wchar_t> alias,
size_t& written) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasExesAImpl(std::span<char> aliasExes,
size_t& written) noexcept override;
[[nodiscard]] HRESULT GetConsoleAliasExesWImpl(std::span<wchar_t> aliasExes,
size_t& written) noexcept override;
#pragma region CMDext Private API
[[nodiscard]] HRESULT ExpungeConsoleCommandHistoryAImpl(const std::string_view exeName) noexcept override;
[[nodiscard]] HRESULT ExpungeConsoleCommandHistoryWImpl(const std::wstring_view exeName) noexcept override;
[[nodiscard]] HRESULT SetConsoleNumberOfCommandsAImpl(const std::string_view exeName,
const size_t numberOfCommands) noexcept override;
[[nodiscard]] HRESULT SetConsoleNumberOfCommandsWImpl(const std::wstring_view exeName,
const size_t numberOfCommands) noexcept override;
[[nodiscard]] HRESULT GetConsoleCommandHistoryLengthAImpl(const std::string_view exeName,
size_t& length) noexcept override;
[[nodiscard]] HRESULT GetConsoleCommandHistoryLengthWImpl(const std::wstring_view exeName,
size_t& length) noexcept override;
[[nodiscard]] HRESULT GetConsoleCommandHistoryAImpl(const std::string_view exeName,
std::span<char> commandHistory,
size_t& written) noexcept override;
[[nodiscard]] HRESULT GetConsoleCommandHistoryWImpl(const std::wstring_view exeName,
std::span<wchar_t> commandHistory,
size_t& written) noexcept override;
#pragma endregion
void GetConsoleWindowImpl(HWND& hwnd) noexcept override;
void GetConsoleSelectionInfoImpl(CONSOLE_SELECTION_INFO& consoleSelectionInfo) noexcept override;
void GetConsoleHistoryInfoImpl(CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override;
[[nodiscard]] HRESULT SetConsoleHistoryInfoImpl(const CONSOLE_HISTORY_INFO& consoleHistoryInfo) noexcept override;
[[nodiscard]] HRESULT SetCurrentConsoleFontExImpl(IConsoleOutputObject& context,
const bool isForMaximumWindowSize,
const CONSOLE_FONT_INFOEX& consoleFontInfoEx) noexcept override;
#pragma endregion
IApiRoutines* m_pUsualRoutines;
UINT& m_inputCodepage;
UINT& m_outputCodepage;
ULONG m_inputMode;
ULONG m_outputMode;
bool m_listeningForDSR;
Microsoft::Console::Render::Xterm256Engine* m_pVtEngine;
private:
void _SynchronizeCursor(std::unique_ptr<IWaitRoutine>& waiter) noexcept;
};

View File

@@ -14,8 +14,6 @@
#include "input.h" // ProcessCtrlEvents
#include "output.h" // CloseConsoleProcessState
#include "VtApiRoutines.h"
using namespace Microsoft::Console;
using namespace Microsoft::Console::Render;
using namespace Microsoft::Console::VirtualTerminal;
@@ -71,7 +69,6 @@ VtIo::VtIo() :
{
_lookingForCursorPosition = pArgs->GetInheritCursor();
_resizeQuirk = pArgs->IsResizeQuirkEnabled();
_passthroughMode = pArgs->IsPassthroughMode();
// If we were already given VT handles, set up the VT IO engine to use those.
if (pArgs->InConptyMode())
@@ -162,26 +159,6 @@ VtIo::VtIo() :
{
auto xterm256Engine = std::make_unique<Xterm256Engine>(std::move(_hOutput),
initialViewport);
if constexpr (Feature_VtPassthroughMode::IsEnabled())
{
if (_passthroughMode)
{
auto vtapi = new VtApiRoutines();
vtapi->m_pVtEngine = xterm256Engine.get();
vtapi->m_pUsualRoutines = globals.api;
xterm256Engine->SetPassthroughMode(true);
if (_pVtInputThread)
{
auto pfnSetListenForDSR = std::bind(&VtInputThread::SetLookingForDSR, _pVtInputThread.get(), std::placeholders::_1);
xterm256Engine->SetLookingForDSRCallback(pfnSetListenForDSR);
}
globals.api = vtapi;
}
}
_pVtRenderEngine = std::move(xterm256Engine);
break;
}
@@ -190,10 +167,6 @@ VtIo::VtIo() :
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput),
initialViewport,
false);
if (_passthroughMode)
{
return E_NOTIMPL;
}
break;
}
case VtIoMode::XTERM_ASCII:
@@ -201,11 +174,6 @@ VtIo::VtIo() :
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput),
initialViewport,
true);
if (_passthroughMode)
{
return E_NOTIMPL;
}
break;
}
default:

View File

@@ -67,7 +67,6 @@ namespace Microsoft::Console::VirtualTerminal
bool _lookingForCursorPosition;
bool _resizeQuirk{ false };
bool _passthroughMode{ false };
bool _closeEventSent{ false };
std::unique_ptr<Microsoft::Console::Render::VtEngine> _pVtRenderEngine;

View File

@@ -45,7 +45,6 @@
<ClCompile Include="..\stream.cpp" />
<ClCompile Include="..\tracing.cpp" />
<ClCompile Include="..\utils.cpp" />
<ClCompile Include="..\VtApiRoutines.cpp" />
<ClCompile Include="..\VtInputThread.cpp" />
<ClCompile Include="..\VtIo.cpp" />
<ClCompile Include="..\writeData.cpp" />
@@ -97,7 +96,6 @@
<ClInclude Include="..\stream.h" />
<ClInclude Include="..\tracing.hpp" />
<ClInclude Include="..\utils.hpp" />
<ClInclude Include="..\VtApiRoutines.h" />
<ClInclude Include="..\VtInputThread.hpp" />
<ClInclude Include="..\VtIo.hpp" />
<ClInclude Include="..\writeData.hpp" />

View File

@@ -156,9 +156,6 @@
<ClCompile Include="..\CursorBlinker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\VtApiRoutines.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\precomp.h">
@@ -311,9 +308,6 @@
<ClInclude Include="..\IIoProvider.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\VtApiRoutines.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />

View File

@@ -86,7 +86,6 @@ SOURCES = \
..\conareainfo.cpp \
..\conimeinfo.cpp \
..\ConsoleArguments.cpp \
..\VtApiRoutines.cpp \
# -------------------------------------

View File

@@ -83,8 +83,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe \"this is the commandline\"";
@@ -106,8 +105,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless \"--vtmode bar this is the commandline\"";
@@ -129,8 +127,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless --server 0x4 this is the commandline";
@@ -152,8 +149,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0x4, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless\t--vtmode\txterm\tthis\tis\tthe\tcommandline";
@@ -175,8 +171,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless\\ foo\\ --outpipe\\ bar\\ this\\ is\\ the\\ commandline";
@@ -198,8 +193,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless\\\tfoo\\\t--outpipe\\\tbar\\\tthis\\\tis\\\tthe\\\tcommandline";
@@ -221,8 +215,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --vtmode a\\\\\\\\\"b c\" d e";
@@ -244,8 +237,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe this is the commandline";
@@ -267,8 +259,7 @@ void ConsoleArgumentsTests::ArgSplittingTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
}
@@ -295,8 +286,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe foo";
@@ -318,8 +308,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe foo -- bar";
@@ -341,8 +330,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --vtmode foo foo -- bar";
@@ -364,8 +352,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe console --vtmode foo foo -- bar";
@@ -387,8 +374,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe console --vtmode foo --outpipe foo -- bar";
@@ -410,8 +396,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --vtmode foo -- --outpipe foo bar";
@@ -433,8 +418,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --vtmode -- --headless bar";
@@ -456,8 +440,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --";
@@ -479,8 +462,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe";
@@ -502,8 +484,7 @@ void ConsoleArgumentsTests::ClientCommandlineTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
}
@@ -530,8 +511,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --server 0x4";
@@ -553,8 +533,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe 0x4 0x8";
@@ -576,8 +555,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --server 0x4 0x8";
@@ -599,8 +577,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe 0x4 --server 0x8";
@@ -622,8 +599,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --server 0x4 --server 0x8";
@@ -645,8 +621,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe 0x4 -ForceV1";
@@ -668,8 +643,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe -ForceV1";
@@ -691,8 +665,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe 0x4 -ForceNoHandoff";
@@ -714,8 +687,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe -ForceNoHandoff";
@@ -737,8 +709,7 @@ void ConsoleArgumentsTests::LegacyFormatsTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
}
@@ -789,8 +760,7 @@ void ConsoleArgumentsTests::CombineVtPipeHandleTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --vtmode xterm-256color";
@@ -812,8 +782,7 @@ void ConsoleArgumentsTests::CombineVtPipeHandleTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
}
@@ -850,8 +819,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --width 120";
@@ -873,8 +841,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --height 30";
@@ -896,8 +863,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --width 0";
@@ -919,8 +885,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --width -1";
@@ -942,8 +907,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --width foo";
@@ -965,8 +929,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --width 2foo";
@@ -988,8 +951,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --width 65535";
@@ -1011,8 +973,7 @@ void ConsoleArgumentsTests::InitialSizeTests()
0ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
}
@@ -1039,8 +1000,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless 0x4";
@@ -1062,8 +1022,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
4ul, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --headless --headless";
@@ -1085,8 +1044,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe -- foo.exe --headless";
@@ -1108,8 +1066,7 @@ void ConsoleArgumentsTests::HeadlessArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
}
@@ -1140,8 +1097,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
4ul, // serverHandle
8ul, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --server 0x4 --signal ASDF";
@@ -1163,8 +1119,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
4ul, // serverHandle
0ul, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --signal --server 0x4";
@@ -1186,8 +1141,7 @@ void ConsoleArgumentsTests::SignalHandleTests()
0ul, // serverHandle
0ul, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
}
@@ -1218,8 +1172,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --feature tty";
ArgTestsRunner(L"#2 Error case, pass an unsupported feature",
@@ -1240,8 +1193,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --feature pty --feature pty";
@@ -1263,8 +1215,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
true); // successful parse?
commandline = L"conhost.exe --feature pty --feature tty";
@@ -1286,8 +1237,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --feature pty --feature";
@@ -1309,8 +1259,7 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
commandline = L"conhost.exe --feature pty --feature --signal foo";
@@ -1332,7 +1281,6 @@ void ConsoleArgumentsTests::FeatureArgTests()
0, // serverHandle
0, // signalHandle
false, // inheritCursor
false, // runAsComServer
false), // passthroughMode
false), // runAsComServer
false); // successful parse?
}

View File

@@ -24,7 +24,6 @@
#endif
#define PSEUDOCONSOLE_RESIZE_QUIRK (2u)
#define PSEUDOCONSOLE_PASSTHROUGH_MODE (8u)
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);

View File

@@ -18,8 +18,6 @@ Author(s):
#include "XtermEngine.hpp"
class VtApiRoutines;
namespace Microsoft::Console::Render
{
class Xterm256Engine : public XtermEngine
@@ -38,8 +36,6 @@ namespace Microsoft::Console::Render
[[nodiscard]] HRESULT ManuallyClearScrollback() noexcept override;
friend class ::VtApiRoutines;
private:
[[nodiscard]] HRESULT _UpdateExtendedAttrs(const TextAttribute& textAttributes) noexcept;
[[nodiscard]] HRESULT _UpdateHyperlinkAttr(const TextAttribute& textAttributes,

View File

@@ -475,19 +475,6 @@ void VtEngine::SetResizeQuirk(const bool resizeQuirk)
_resizeQuirk = resizeQuirk;
}
// Method Description:
// - Configure the renderer to understand that we're operating in limited-draw
// passthrough mode. We do not need to handle full responsibility for replicating
// buffer state to the attached terminal.
// Arguments:
// - passthrough - True to turn on passthrough mode. False otherwise.
// Return Value:
// - true iff we were started with an output mode for passthrough. false otherwise.
void VtEngine::SetPassthroughMode(const bool passthrough) noexcept
{
_passthrough = passthrough;
}
void VtEngine::SetLookingForDSRCallback(std::function<void(bool)> pfnLooking) noexcept
{
_pfnSetLookingForDSR = pfnLooking;

View File

@@ -82,7 +82,6 @@ namespace Microsoft::Console::Render
[[nodiscard]] virtual HRESULT WriteTerminalW(const std::wstring_view str) noexcept = 0;
void SetTerminalOwner(Microsoft::Console::VirtualTerminal::VtIo* const terminalOwner);
void SetResizeQuirk(const bool resizeQuirk);
void SetPassthroughMode(const bool passthrough) noexcept;
void SetLookingForDSRCallback(std::function<void(bool)> pfnLooking) noexcept;
void SetTerminalCursorTextPosition(const til::point coordCursor) noexcept;
[[nodiscard]] virtual HRESULT ManuallyClearScrollback() noexcept;

View File

@@ -168,14 +168,25 @@ PCONSOLE_API_MSG ApiSorter::ConsoleDispatchRequest(_Inout_ PCONSOLE_API_MSG Mess
Message->State.WriteOffset = Message->msgHeader.ApiDescriptorSize;
Message->State.ReadOffset = Message->msgHeader.ApiDescriptorSize + sizeof(CONSOLE_MSG_HEADER);
HRESULT hr = S_OK;
try
{
hr = (*Descriptor->Routine)(Message, &ReplyPending);
}
catch (const wil::ResultException& e)
{
hr = e.GetStatusCode();
}
catch (...)
{
hr = E_UNEXPECTED;
}
// Unfortunately, we can't be as clear-cut with our error codes as we'd like since we have some callers that take
// hard dependencies on NTSTATUS codes that aren't readily expressible as an HRESULT. There's currently only one
// such known code -- STATUS_BUFFER_TOO_SMALL. There's a conlibk dependency on this being returned from the console
// alias API.
NTSTATUS Status = S_OK;
{
Status = (*Descriptor->Routine)(Message, &ReplyPending);
}
NTSTATUS Status = hr;
if (Status != STATUS_BUFFER_TOO_SMALL)
{
Status = NTSTATUS_FROM_HRESULT(Status);

View File

@@ -28,22 +28,13 @@ typedef InputBuffer IConsoleInputObject;
class INPUT_READ_HANDLE_DATA;
#include "IWaitRoutine.h"
#include <deque>
#include <memory>
#include "../types/inc/IInputEvent.hpp"
#include "../types/inc/viewport.hpp"
class IApiRoutines
class __declspec(novtable) IApiRoutines
{
public:
#pragma region ObjectManagement
// TODO: 9115192 - We will need to make the objects via an interface eventually. This represents that idea.
/*virtual HRESULT CreateInitialObjects(_Out_ IConsoleInputObject** const ppInputObject,
_Out_ IConsoleOutputObject** const ppOutputObject);
*/
#pragma endregion
#pragma warning(suppress : 26432) // If you define or delete any default operation in the type '...', define or delete them all (c.21).
virtual ~IApiRoutines() = default;
#pragma region L1

View File

@@ -133,23 +133,20 @@ HRESULT _CreatePseudoConsole(const HANDLE hToken,
RETURN_IF_WIN32_BOOL_FALSE(SetHandleInformation(signalPipeConhostSide.get(), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT));
// GH4061: Ensure that the path to executable in the format is escaped so C:\Program.exe cannot collide with C:\Program Files
auto pwszFormat = L"\"%s\" --headless %s%s%s--width %hu --height %hu --signal 0x%x --server 0x%x";
// This is plenty of space to hold the formatted string
wchar_t cmd[MAX_PATH]{};
const BOOL bInheritCursor = (dwFlags & PSEUDOCONSOLE_INHERIT_CURSOR) == PSEUDOCONSOLE_INHERIT_CURSOR;
const BOOL bResizeQuirk = (dwFlags & PSEUDOCONSOLE_RESIZE_QUIRK) == PSEUDOCONSOLE_RESIZE_QUIRK;
const BOOL bPassthroughMode = (dwFlags & PSEUDOCONSOLE_PASSTHROUGH_MODE) == PSEUDOCONSOLE_PASSTHROUGH_MODE;
swprintf_s(cmd,
MAX_PATH,
pwszFormat,
L"\"%s\" --headless %s%s--width %hd --height %hd --signal 0x%tx --server 0x%tx",
_ConsoleHostPath(),
bInheritCursor ? L"--inheritcursor " : L"",
bResizeQuirk ? L"--resizeQuirk " : L"",
bPassthroughMode ? L"--passthrough " : L"",
size.X,
size.Y,
signalPipeConhostSide.get(),
serverHandle.get());
std::bit_cast<uintptr_t>(signalPipeConhostSide.get()),
std::bit_cast<uintptr_t>(serverHandle.get()));
STARTUPINFOEXW siEx{ 0 };
siEx.StartupInfo.cb = sizeof(STARTUPINFOEXW);

View File

@@ -58,9 +58,6 @@ typedef struct _PseudoConsole
#ifndef PSEUDOCONSOLE_WIN32_INPUT_MODE
#define PSEUDOCONSOLE_WIN32_INPUT_MODE (0x4)
#endif
#ifndef PSEUDOCONSOLE_PASSTHROUGH_MODE
#define PSEUDOCONSOLE_PASSTHROUGH_MODE (0x8)
#endif
// Implementations of the various PseudoConsole functions.
HRESULT _CreatePseudoConsole(const HANDLE hToken,