Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Pass through VT input unmodified #15630

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class Microsoft::Terminal::Core::Terminal final :

CursorType _defaultCursorShape = CursorType::Legacy;

til::enumset<Mode> _systemMode{ Mode::AutoWrap };
til::enumset<Mode> _systemMode{ Mode::AutoWrap, Mode::LineFeed };

bool _snapOnInput = true;
bool _altGrAliasing = true;
Expand Down
Empty file added src/host/PassthroughState.cpp
Empty file.
18 changes: 18 additions & 0 deletions src/host/PassthroughState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

#pragma once

namespace Microsoft::Console
{
struct PassthroughState
{
explicit PassthroughState(wil::unique_hfile output) :
_output{ std::move(output) }
{
}

private:
wil::unique_hfile _output;
};
}
810 changes: 0 additions & 810 deletions src/host/VtApiRoutines.cpp

This file was deleted.

366 changes: 0 additions & 366 deletions src/host/VtApiRoutines.h

This file was deleted.

74 changes: 18 additions & 56 deletions src/host/VtIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -156,65 +154,24 @@ VtIo::VtIo() :
auto initialViewport = Viewport::FromDimensions({ 0, 0 },
gci.GetWindowSize().width,
gci.GetWindowSize().height);
switch (_IoMode)
{
case VtIoMode::XTERM_256:
{
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;
}
case VtIoMode::XTERM:
if (!Feature_VtPassthroughMode::IsEnabled() || !_passthroughMode)
{
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput),
initialViewport,
false);
if (_passthroughMode)
switch (_IoMode)
{
return E_NOTIMPL;
case VtIoMode::XTERM_256:
_pVtRenderEngine = std::make_unique<Xterm256Engine>(std::move(_hOutput), initialViewport);
break;
case VtIoMode::XTERM:
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput), initialViewport, false);
break;
case VtIoMode::XTERM_ASCII:
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput), initialViewport, true);
break;
default:
return E_FAIL;
}
break;
}
case VtIoMode::XTERM_ASCII:
{
_pVtRenderEngine = std::make_unique<XtermEngine>(std::move(_hOutput),
initialViewport,
true);

if (_passthroughMode)
{
return E_NOTIMPL;
}
break;
}
default:
{
return E_FAIL;
}
}
if (_pVtRenderEngine)
{
_pVtRenderEngine->SetTerminalOwner(this);
_pVtRenderEngine->SetResizeQuirk(_resizeQuirk);
}
Expand All @@ -230,6 +187,11 @@ bool VtIo::IsUsingVt() const
return _initialized;
}

PassthroughState* VtIo::GetPassthroughState() const noexcept
{
return _passthroughState.get();
}

// Routine Description:
// Potentially starts this VtIo's input thread and render engine.
// If the VtIo hasn't yet been given pipes, then this function will
Expand Down
5 changes: 4 additions & 1 deletion src/host/VtIo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "../renderer/vt/vtrenderer.hpp"
#include "VtInputThread.hpp"
#include "PtySignalInputThread.hpp"
#include "PassthroughState.h"

class ConsoleArguments;

Expand All @@ -28,6 +29,7 @@ namespace Microsoft::Console::VirtualTerminal
[[nodiscard]] HRESULT CreateIoHandlers() noexcept;

bool IsUsingVt() const;
PassthroughState* GetPassthroughState() const noexcept;

[[nodiscard]] HRESULT StartIfNeeded();

Expand Down Expand Up @@ -69,7 +71,8 @@ namespace Microsoft::Console::VirtualTerminal
bool _resizeQuirk{ false };
bool _passthroughMode{ false };
bool _closeEventSent{ false };


std::unique_ptr<Microsoft::Console::PassthroughState> _passthroughState;
std::unique_ptr<Microsoft::Console::Render::VtEngine> _pVtRenderEngine;
std::unique_ptr<Microsoft::Console::VtInputThread> _pVtInputThread;
std::unique_ptr<Microsoft::Console::PtySignalInputThread> _pPtySignalInputThread;
Expand Down
2 changes: 0 additions & 2 deletions src/host/host-common.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<ClCompile Include="..\tracing.cpp" />
<ClCompile Include="..\utils.cpp" />
<ClCompile Include="..\utf8ToWideCharParser.cpp" />
<ClCompile Include="..\VtApiRoutines.cpp" />
<ClCompile Include="..\VtInputThread.cpp" />
<ClCompile Include="..\VtIo.cpp" />
<ClCompile Include="..\writeData.cpp" />
Expand Down Expand Up @@ -101,7 +100,6 @@
<ClInclude Include="..\tracing.hpp" />
<ClInclude Include="..\utils.hpp" />
<ClInclude Include="..\utf8ToWideCharParser.hpp" />
<ClInclude Include="..\VtApiRoutines.h" />
<ClInclude Include="..\VtInputThread.hpp" />
<ClInclude Include="..\VtIo.hpp" />
<ClInclude Include="..\writeData.hpp" />
Expand Down
8 changes: 7 additions & 1 deletion src/host/lib/hostlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
<TargetName>ConhostV2Lib</TargetName>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<ItemGroup>
<ClInclude Include="..\PassthroughState.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\PassthroughState.cpp" />
</ItemGroup>
<Import Project="$(SolutionDir)src\common.build.pre.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.props" />
<!-- DONT ADD NEW FILES HERE, ADD THEM TO host-common.vcxitems -->
<Import Project="$(SolutionDir)src\host\host-common.vcxitems" />
<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" />
<Import Project="$(SolutionDir)src\common.nugetversions.targets" />
</Project>
</Project>
7 changes: 4 additions & 3 deletions src/host/lib/hostlib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<ClCompile Include="..\CursorBlinker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\VtApiRoutines.cpp">
<ClCompile Include="..\PassthroughState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -320,11 +320,12 @@
<ClInclude Include="..\IIoProvider.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\VtApiRoutines.h">
<ClInclude Include="..\PassthroughState.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Natvis Include="$(SolutionDir)tools\ConsoleTypes.natvis" />
<Natvis Include="$(MSBuildThisFileDirectory)..\..\natvis\wil.natvis" />

Check failure on line 329 in src/host/lib/hostlib.vcxproj.filters

View workflow job for this annotation

GitHub Actions / Spell checking

`atvis` is not a recognized word. (unrecognized-spelling)
</ItemGroup>
</Project>
</Project>
1 change: 0 additions & 1 deletion src/host/sources.inc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ SOURCES = \
..\conareainfo.cpp \
..\conimeinfo.cpp \
..\ConsoleArguments.cpp \
..\VtApiRoutines.cpp \


# -------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/vt/Xterm256Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Xterm256Engine::Xterm256Engine(_In_ wil::unique_hfile hPipe,
const bool usingSoftFont,
const bool isSettingDefaultBrushes) noexcept
{
RETURN_HR_IF(S_FALSE, _passthrough && isSettingDefaultBrushes);

RETURN_IF_FAILED(VtEngine::_RgbUpdateDrawingBrushes(textAttributes));

RETURN_IF_FAILED(_UpdateHyperlinkAttr(textAttributes, pData));
Expand Down
4 changes: 0 additions & 4 deletions src/renderer/vt/Xterm256Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Author(s):

#include "XtermEngine.hpp"

class VtApiRoutines;

namespace Microsoft::Console::Render
{
class Xterm256Engine : public XtermEngine
Expand All @@ -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,
Expand Down
10 changes: 0 additions & 10 deletions src/renderer/vt/XtermEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
// during the frame.
_nextCursorIsVisible = false;

// Do not perform synchronization clearing in passthrough mode.
// In passthrough, the terminal leads and we follow what it is
// handling from the client application.
// (This is in contrast to full PTY mode where WE, the ConPTY, lead and
// it follows our state.)
if (_passthrough)
{
_firstPaint = false;
}

if (_firstPaint)
{
// MSFT:17815688
Expand Down
13 changes: 0 additions & 13 deletions src/renderer/vt/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,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;
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/vt/vtrenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ namespace Microsoft::Console::Render
void BeginResizeRequest();
void EndResizeRequest();
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;
Expand Down Expand Up @@ -138,7 +137,6 @@ namespace Microsoft::Console::Render
bool _delayedEolWrap{ false };

bool _resizeQuirk{ false };
bool _passthrough{ false };
bool _corked{ false };
std::optional<TextColor> _newBottomLineBG{ std::nullopt };

Expand Down
Loading