2019-05-03 00:29:04 +02:00
|
|
|
/*++
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Licensed under the MIT license.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
- PtySignalInputThread.hpp
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
- Defines methods that wrap the thread that will wait for Pty Signals
|
|
|
|
if a Pty server (VT server) is running.
|
|
|
|
|
|
|
|
Author(s):
|
|
|
|
- Mike Griese (migrie) 15 Aug 2017
|
|
|
|
- Michael Niksa (miniksa) 19 Jan 2018
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Microsoft::Console
|
|
|
|
{
|
|
|
|
class PtySignalInputThread final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PtySignalInputThread(_In_ wil::unique_hfile hPipe);
|
|
|
|
~PtySignalInputThread();
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT Start() noexcept;
|
2019-05-17 22:32:51 +02:00
|
|
|
static DWORD WINAPI StaticThreadProc(_In_ LPVOID lpParameter);
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
// Prevent copying and assignment.
|
|
|
|
PtySignalInputThread(const PtySignalInputThread&) = delete;
|
|
|
|
PtySignalInputThread& operator=(const PtySignalInputThread&) = delete;
|
|
|
|
|
|
|
|
void ConnectConsole() noexcept;
|
|
|
|
|
|
|
|
private:
|
2021-06-22 21:23:16 +02:00
|
|
|
enum class PtySignal : unsigned short
|
|
|
|
{
|
2021-09-02 16:59:42 +02:00
|
|
|
ClearBuffer = 2,
|
2021-06-22 21:23:16 +02:00
|
|
|
ResizeWindow = 8
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ResizeWindowData
|
|
|
|
{
|
|
|
|
unsigned short sx;
|
|
|
|
unsigned short sy;
|
|
|
|
};
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
[[nodiscard]] HRESULT _InputThread();
|
2019-05-03 00:29:04 +02:00
|
|
|
bool _GetData(_Out_writes_bytes_(cbBuffer) void* const pBuffer, const DWORD cbBuffer);
|
2021-06-22 21:23:16 +02:00
|
|
|
void _DoResizeWindow(const ResizeWindowData& data);
|
2021-09-02 16:59:42 +02:00
|
|
|
void _DoClearBuffer();
|
2019-05-03 00:29:04 +02:00
|
|
|
void _Shutdown();
|
|
|
|
|
|
|
|
wil::unique_hfile _hFile;
|
|
|
|
wil::unique_handle _hThread;
|
|
|
|
DWORD _dwThreadId;
|
|
|
|
bool _consoleConnected;
|
2021-06-22 21:23:16 +02:00
|
|
|
std::optional<ResizeWindowData> _earlyResize;
|
2019-05-03 00:29:04 +02:00
|
|
|
std::unique_ptr<Microsoft::Console::VirtualTerminal::ConGetSet> _pConApi;
|
|
|
|
};
|
|
|
|
}
|