mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-21 21:51:51 +00:00
Next in the popular series of minor refactorings: Out with the old, in with the new! This PR removes all of the existing TSF code, both for conhost and Windows Terminal. conhost's TSF implementation was awful: It allocated an entire text buffer _per line_ of input. Additionally, its implementation spanned a whopping 40 files and almost 5000 lines of code. Windows Terminal's implementation was absolutely fine in comparison, but it was user unfriendly due to two reasons: Its usage of the `CoreTextServices` WinRT API indirectly meant that it used a non-transitory TSF document, which is not the right choice for a terminal. A `TF_SS_TRANSITORY` document (-context) indicates to TSF that it cannot undo a previously completed composition which is exactly what we need: Once composition has completed we send the result to the shell and we cannot undo this later on. The WinRT API does not allow us to use `TF_SS_TRANSITORY` and so it's unsuitable for our application. Additionally, the implementation used XAML to render the composition instead of being part of our text renderer, which resulted in the text looking weird and hard to read. The new implementation spans just 8 files and is ~1000 lines which should make it significantly easier to maintain. The architecture is not particularly great, but it's certainly better than what we had. The implementation is almost entirely identical between both conhost and Windows Terminal and thus they both also behave identical. It fixes an uncountable number of subtle bugs in the conhost TSF implementation, as it failed to check for status codes after calls. It also adds several new features, like support for wavy underlines (as used by the Japanese IME), dashed underlines (the default for various languages now, like Vietnamese), colored underlines, colored foreground/background controlled by the IME, and more! I have tried to replicate the following issues and have a high confidence that they're resolved now: Closes #1304 Closes #3730 Closes #4052 Closes #5007 (as it is not applicable anymore) Closes #5110 Closes #6186 Closes #6192 Closes #13805 Closes #14349 Closes #14407 Closes #16180 For the following issues I'm not entirely sure if it'll fix it, but I suspect it's somewhat likely: #13681 #16305 #16817 Lastly, there's one remaining bug that I don't know how to resolve. However, that issue also plagues conhost and Windows Terminal right now, so it's at least not a regression: * Press Win+. (emoji picker) and close it * Move the window around * Press Win+. This will open the emoji picker at the old window location. It also occurs when the cursor moves within the window. While this is super annoying, I could not find a way to fix it. ## Validation Steps Performed * See the above closed issues * Use Vietnamese Telex and type "xin choaf" Results in "xin chào" ✅ * Use the MS Japanese IME and press Alt+` Toggles between the last 2 modes ✅ * Use the MS Japanese IME, type "kyouhaishaheiku", and press Space * The text is converted, underlined and the first part is doubly underlined ✅ * Left/Right moves between the 3 segments ✅ * Home/End moves between start/end ✅ * Esc puts a wavy line under the current segment ✅ * Use the Korean IME, type "gksgks" This results in "한한" ✅ * Use the Korean IME, type "gks", and press Right Ctrl Opens a popup which allows you to navigate with Arrow/Tab keys ✅
92 lines
2.4 KiB
C
92 lines
2.4 KiB
C
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
Licensed under the MIT license.
|
|
|
|
Module Name:
|
|
- precomp.h
|
|
|
|
Abstract:
|
|
- Contains external headers to include in the precompile phase of console build process.
|
|
- Avoid including internal project headers. Instead include them only in the classes that need them (helps with test project building).
|
|
--*/
|
|
|
|
#pragma once
|
|
|
|
#define DEFINE_CONSOLEV2_PROPERTIES
|
|
|
|
// Ignore checked iterators warning from VC compiler.
|
|
#define _SCL_SECURE_NO_WARNINGS
|
|
|
|
// Block minwindef.h min/max macros to prevent <algorithm> conflict
|
|
#define NOMINMAX
|
|
|
|
// This includes a lot of common headers needed by both the host and the propsheet
|
|
// including: windows.h, winuser, ntstatus, assert, and the DDK
|
|
#include "HostAndPropsheetIncludes.h"
|
|
|
|
// This includes support libraries from the CRT, STL, WIL, and GSL
|
|
#include "LibraryIncludes.h"
|
|
|
|
#define SCREEN_BUFFER_POINTER(X, Y, XSIZE, CELLSIZE) (((XSIZE * (Y)) + (X)) * (ULONG)CELLSIZE)
|
|
#include <shellapi.h>
|
|
|
|
#include <securityappcontainer.h>
|
|
|
|
#include <condrv.h>
|
|
|
|
#include <conmsgl1.h>
|
|
#include <conmsgl2.h>
|
|
#include <conmsgl3.h>
|
|
|
|
#include <propvarutil.h>
|
|
#include <UIAutomation.h>
|
|
|
|
#include <winuser.h>
|
|
#include <winconp.h>
|
|
#include <ntcon.h>
|
|
#include <windowsx.h>
|
|
#include <dde.h>
|
|
#include "conserv.h"
|
|
|
|
#pragma prefast(push)
|
|
#pragma prefast(disable : 26071, "Range violation in Intsafe. Not ours.")
|
|
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS // Only unsigned intsafe math/casts available without this def
|
|
#include <intsafe.h>
|
|
#pragma prefast(pop)
|
|
#include <strsafe.h>
|
|
#include <cwchar>
|
|
#include <mmsystem.h>
|
|
#include "utils.hpp"
|
|
|
|
// Including TraceLogging essentials for the binary
|
|
#include <TraceLoggingProvider.h>
|
|
#include <winmeta.h>
|
|
TRACELOGGING_DECLARE_PROVIDER(g_hConhostV2EventTraceProvider);
|
|
#include <telemetry/ProjectTelemetry.h>
|
|
#include <TraceLoggingActivity.h>
|
|
|
|
#include "tracing.hpp"
|
|
|
|
#ifdef BUILDING_INSIDE_WINIDE
|
|
#define DbgRaiseAssertionFailure() __int2c()
|
|
#endif
|
|
|
|
#include <ShellScalingApi.h>
|
|
#include "../propslib/conpropsp.hpp"
|
|
|
|
// Comment to build against the private SDK.
|
|
#define CON_BUILD_PUBLIC
|
|
|
|
#ifdef CON_BUILD_PUBLIC
|
|
#define CON_USERPRIVAPI_INDIRECT
|
|
#define CON_DPIAPI_INDIRECT
|
|
#endif
|
|
|
|
#include "../inc/conattrs.hpp"
|
|
|
|
// TODO: MSFT 9355094 Find a better way of doing this. http://osgvsowi/9355094
|
|
[[nodiscard]] constexpr NTSTATUS NTSTATUS_FROM_HRESULT(HRESULT hr) noexcept
|
|
{
|
|
return NTSTATUS_FROM_WIN32(HRESULT_CODE(hr));
|
|
}
|