Adds support for `win32-input-mode` to conhost, conpty, and the Windows Terminal. * The shared `terminalInput` class supports sending these sequences when a VT client application requests this mode. * ConPTY supports synthesizing `INPUT_RECORD`s from the input sent to it from a terminal * ConPTY requests this mode immediately on startup (if started with a new flag, `PSEUDOCONSOLE_WIN32_INPUT_MODE`) * The Terminal now supports sending this input as well, when conpty asks for it. Also adds a new ConPTY flag `PSEUDOCONSOLE_WIN32_INPUT_MODE` which requests this functionality from conpty, and the Terminal requests this by default. Also adds `experimental.input.forceVT` as a global setting to let a user opt-out of this behavior, if they don't want it / this ends up breaking horribly. ## Validation Steps Performed * played with this mode in vtpipeterm * played with this mode in Terminal * checked a bunch of scenarios, as outlined in a [comment] on #4999 [comment]: https://github.com/microsoft/terminal/issues/4999#issuecomment-628718631 References #4999: The megathread References #5887: The spec Closes #879 Closes #2865 Closes #530 Closes #3079 Closes #1119 Closes #1694 Closes #3608 Closes #4334 Closes #4446
74 lines
4.3 KiB
C++
74 lines
4.3 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include "../../terminal/adapter/termDispatch.hpp"
|
|
#include "ITerminalApi.hpp"
|
|
|
|
class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatch
|
|
{
|
|
public:
|
|
TerminalDispatch(::Microsoft::Terminal::Core::ITerminalApi& terminalApi) noexcept;
|
|
|
|
void Execute(const wchar_t wchControl) noexcept override;
|
|
void Print(const wchar_t wchPrintable) noexcept override;
|
|
void PrintString(const std::wstring_view string) noexcept override;
|
|
|
|
bool SetGraphicsRendition(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions> options) noexcept override;
|
|
|
|
bool CursorPosition(const size_t line,
|
|
const size_t column) noexcept override; // CUP
|
|
|
|
bool EnableWin32InputMode(const bool win32InputMode) noexcept override; // win32-input-mode
|
|
|
|
bool CursorVisibility(const bool isVisible) noexcept override; // DECTCEM
|
|
bool EnableCursorBlinking(const bool enable) noexcept override; // ATT610
|
|
|
|
bool CursorForward(const size_t distance) noexcept override;
|
|
bool CursorBackward(const size_t distance) noexcept override;
|
|
bool CursorUp(const size_t distance) noexcept override;
|
|
|
|
bool LineFeed(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::LineFeedType lineFeedType) noexcept override;
|
|
|
|
bool EraseCharacters(const size_t numChars) noexcept override;
|
|
bool CarriageReturn() noexcept override;
|
|
bool SetWindowTitle(std::wstring_view title) noexcept override;
|
|
|
|
bool SetColorTableEntry(const size_t tableIndex, const DWORD color) noexcept override;
|
|
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) noexcept override;
|
|
|
|
bool SetDefaultForeground(const DWORD color) noexcept override;
|
|
bool SetDefaultBackground(const DWORD color) noexcept override;
|
|
bool EraseInLine(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override; // ED
|
|
bool DeleteCharacter(const size_t count) noexcept override;
|
|
bool InsertCharacter(const size_t count) noexcept override;
|
|
bool EraseInDisplay(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::EraseType eraseType) noexcept override;
|
|
|
|
bool SetCursorKeysMode(const bool applicationMode) noexcept override; // DECCKM
|
|
bool SetKeypadMode(const bool applicationMode) noexcept override; // DECKPAM, DECKPNM
|
|
|
|
bool SoftReset() noexcept override; // DECSTR
|
|
bool HardReset() noexcept override; // RIS
|
|
|
|
bool EnableVT200MouseMode(const bool enabled) noexcept override; // ?1000
|
|
bool EnableUTF8ExtendedMouseMode(const bool enabled) noexcept override; // ?1005
|
|
bool EnableSGRExtendedMouseMode(const bool enabled) noexcept override; // ?1006
|
|
bool EnableButtonEventMouseMode(const bool enabled) noexcept override; // ?1002
|
|
bool EnableAnyEventMouseMode(const bool enabled) noexcept override; // ?1003
|
|
bool EnableAlternateScroll(const bool enabled) noexcept override; // ?1007
|
|
|
|
bool SetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> /*params*/) noexcept override; // DECSET
|
|
bool ResetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> /*params*/) noexcept override; // DECRST
|
|
|
|
private:
|
|
::Microsoft::Terminal::Core::ITerminalApi& _terminalApi;
|
|
|
|
bool _SetRgbColorsHelper(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions> options,
|
|
size_t& optionsConsumed) noexcept;
|
|
bool _SetBoldColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions opt) noexcept;
|
|
bool _SetDefaultColorHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions opt) noexcept;
|
|
void _SetGraphicsOptionHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions opt) noexcept;
|
|
|
|
bool _SetResetPrivateModes(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams> params, const bool enable) noexcept;
|
|
bool _PrivateModeParamsHelper(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::PrivateModeParams param, const bool enable) noexcept;
|
|
};
|