terminal/src/host/globals.h

79 lines
1.8 KiB
C
Raw Normal View History

/*++
Copyright (c) Microsoft Corporation
Licensed under the MIT license.
Module Name:
- globals.h
Abstract:
- This module contains the global variables used by the console server DLL.
Author:
- Jerry Shea (jerrysh) 21-Sep-1993
Revision History:
- Modified to reduce globals over Console V2 project (MiNiksa/PaulCam, 2014)
--*/
#pragma once
#include "selection.hpp"
#include "server.h"
#include "ConsoleArguments.hpp"
#include "ApiRoutines.h"
#include "../renderer/inc/IRenderData.hpp"
#include "../renderer/inc/IRenderEngine.hpp"
#include "../renderer/inc/IRenderer.hpp"
#include "../renderer/inc/IFontDefaultList.hpp"
#include "../server/DeviceComm.h"
#include <TraceLoggingProvider.h>
#include <winmeta.h>
TRACELOGGING_DECLARE_PROVIDER(g_hConhostV2EventTraceProvider);
class Globals
{
public:
UINT uiOEMCP = GetOEMCP();
UINT uiWindowsCP = GetACP();
HINSTANCE hInstance;
UINT uiDialogBoxCount;
ConsoleArguments launchArgs;
CONSOLE_INFORMATION& getConsoleInformation();
DeviceComm* pDeviceComm;
wil::unique_event_nothrow hInputEvent;
SHORT sVerticalScrollSize;
SHORT sHorizontalScrollSize;
int dpi = USER_DEFAULT_SCREEN_DPI;
ULONG cursorPixelWidth = 1;
NTSTATUS ntstatusConsoleInputInitStatus;
wil::unique_event_nothrow hConsoleInputInitEvent;
DWORD dwInputThreadId;
std::vector<wchar_t> WordDelimiters;
Microsoft::Console::Render::IRenderer* pRender;
Microsoft::Console::Render::IFontDefaultList* pFontDefaultList;
bool IsHeadless() const;
ApiRoutines api;
#ifdef UNIT_TESTING
Implement a pair of shims for `cls`, `Clear-Host` in conpty mode (#5627) ## Summary of the Pull Request This PR implements a pair of shims for `cmd` and `powershell`, so that their `cls` and `Clear-Host` functions will clear the entire terminal buffer (like they do in conhost), instead of just the viewport. With the conpty viewport and buffer being the same size, there's effectively no way to know if an application is calling these API's in this way with the intention of clearing the buffer or the viewport. We absolutely have to guess. Each of these shims checks to see if the way that the API is being called exactly matches the way `cmd` or `powershell` would call these APIs. If it does, we manually write a `^[[3J` to the connected terminal, to get he Terminal to clear it's own scrollback. ~~_⚠️ If another application were trying to clear the **viewport** with an exactly similar API call, this would also cause the terminal scrollback to get cleared ⚠️_~~ * [x] Should these shims be restricted to when the process that's calling them is actually `cmd.exe` or `powershell.exe`? Can I even do this? I think we've done such a good job of isolating the client process information from the rest of the host code that I can't figure out how to do this. - YES, this can be done, and I did it. * [ ] **TODO**: _While I'm here_, should I have `DoSrvPrivateEraseAll` (the implementation for `^[[2J`, in `getset.cpp`) also manually trigger a EraseAll in the terminal in conpty mode? ## PR Checklist * [x] Closes #3126 * [x] Actually closes #1305 too, which is really the same thing, but probably deserves a callout * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * ran tests * checked `cls` in the Terminal * checked `Clear-Host` in the Terminal * Checked running `powershell clear-host` from `cmd.exe`
2020-04-30 23:53:31 +02:00
void EnableConptyModeForTests(std::unique_ptr<Microsoft::Console::Render::VtEngine> vtRenderEngine);
#endif
private:
CONSOLE_INFORMATION ciConsoleInformation;
};