mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-15 16:40:12 -06:00
## Summary of the Pull Request This PR adds full support for the `DECSCNM` reverse screen mode in the Windows Terminal to align with the implementation in conhost. ## References * The conhost implementation of `DECSCNM` was in PR #3817. * WT originally inherited that functionality via the colors being passed through, but that behaviour was lost in PR #6506. ## PR Checklist * [x] Closes #6622 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #6622 ## Detailed Description of the Pull Request / Additional comments The `AdaptDispatch::SetScreenMode` now checks if it's in conpty mode and simply returns false to force a pass-through of the mode change. And the `TerminalDispatch` now has its own `SetScreenMode` implementation that tracks any changes to the reversed state, and triggers a redraw in the renderer. To make the renderer work, we just needed to update the `GetForegroundColor` and `GetBackgroundColor` methods of the terminal's `IRenderData` implementation to check the reversed state, and switch the colors being calculated, the same way the `LookupForegroundColor` and `LookupBackgroundColor` methods work in the conhost `Settings` class. ## Validation Steps Performed I've manually tested the `DECSCNM` functionality for Windows Terminal in Vttest, and also with some of my own test scripts.
75 lines
4.2 KiB
C++
75 lines
4.2 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 SetClipboard(std::wstring_view content) 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 SetScreenMode(const bool reverseMode) noexcept override; // DECSCNM
|
|
|
|
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;
|
|
|
|
size_t _SetRgbColorsHelper(const std::basic_string_view<::Microsoft::Console::VirtualTerminal::DispatchTypes::GraphicsOptions> options,
|
|
TextAttribute& attr,
|
|
const bool isForeground) 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;
|
|
};
|