mirror of
https://github.com/microsoft/terminal.git
synced 2026-11-16 09:10:27 +00:00
This pull request replaces all of HwndTerminal, which used to be a thin layer on top of TerminalCore.lib, with a new implementation that relies on the Interactivity and Core layers in TerminalControl.lib. We used to spend a lot of time reimplementing interactivity components for HwndTerminal or--if I'm being honest--letting it rot and never giving it the improvements the rest of the application got. Among those improvements: - Automatic scrolling finally works (as of #20710) - Selection works the same way as it does in Terminal proper (starts on the half-cell, uses an exclusive range) - Consistent double- and triple-click behavior without having to reimplement word- and line-wise expansion - Scroll wheel behavior - Shift+Click to suppress VT mouse mode - Scrolling and focus handling move down into the Win32 message loop from WPF This pull request seeks to get HwndTerminal back to where it was (plus the things we naturally get from switching over). In the future, we can more easily add: - title reporting (surprised we didn't have this) - clickable URLs - automatic copy-to-clipboard - right-click menu support - DTTERM window manipulation - shaders - Ctrl+Scroll zoom Implementation Details ---------------------- The WPF control is backed by a flat "C" API, which takes in a `void*` and does some stuff to it. We call that a `PTERM`. References to "Flat C" in this commit body describe the body of work below WPF. X-macros are used to fill out the definintions of every C API and bridge it to a properly typed C++ member function. Ugh. No more crap where we split the implementation into half C export and half C++ member. ControlCore and ControlInteractivity require something that looks like TerminalSettings. The WPF control only supports the most basic settings, in `struct TerminalTheme`, and so I've added a bridge WinRT type to adapt TerminalTheme to IXxxSettings. Most of the values it returns are our "defaults", and some of them are overridden. Core requires an `ITerminalConnection`, but the WPF API uses a pair of "write output" and "send input" callbacks. Flat C provides an ITerminalConnection that bridges those callbacks. It does not communicate connection state or anything else. Resizing is probably going to be a problem. Core requires a dispatcher queue to ensure that some operations happen on the UI thread. I have stubbed out an implementation of `IDispatcherQueue` that calls a couple function pointers with a context pointer; the WPF code hooks up to that and bridges it into the WPF dispatcher. Yes, the Core's dispatcher queue _is_ the WPF main UI thread. It has to be, otherwise we'll explode the first time we try to update the scroll bar. Prep work was done in #20713. To make the above easier, I removed all use of DispatcherTimer (see #20711). Attempts to use it will almost certainly cause the WPF control to implode. Core needed to be taught a couple tricks to start up targeting an HWND instead of a composition handle. See #20722 for more. Refs #20710 Refs #20711 Refs #20713 Refs #20722 Required #20721 Refs #20745 Related to #6999