diff --git a/src/renderer/base/renderer.cpp b/src/renderer/base/renderer.cpp index 7d7a4b356eb..8939d6b03b6 100644 --- a/src/renderer/base/renderer.cpp +++ b/src/renderer/base/renderer.cpp @@ -733,7 +733,7 @@ void Renderer::_PaintBufferOutput(_In_ IRenderEngine* const pEngine) auto resetLineTransform = wil::scope_exit([&]() { LOG_IF_FAILED(pEngine->ResetLineTransform()); }); - + for (const auto& dirtyRect : dirtyAreas) { if (!dirtyRect) diff --git a/src/renderer/vt/state.cpp b/src/renderer/vt/state.cpp index f192536e3e6..a9905d88032 100644 --- a/src/renderer/vt/state.cpp +++ b/src/renderer/vt/state.cpp @@ -269,8 +269,8 @@ void VtEngine::Cork(bool corked) noexcept // Method Description: // - This method will modify the DPI we're using for scaling calculations. -// Does nothing for vt, the dpi is handed by the terminal. // Arguments: +// Does nothing for vt, the dpi is handed by the terminal. // - iDpi - The Dots Per Inch to use for scaling. We will use this relative to // the system default DPI defined in Windows headers as a constant. // Return Value: diff --git a/src/terminal/adapter/ITermDispatch.hpp b/src/terminal/adapter/ITermDispatch.hpp index e3976996433..c597b53657b 100644 --- a/src/terminal/adapter/ITermDispatch.hpp +++ b/src/terminal/adapter/ITermDispatch.hpp @@ -143,6 +143,12 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch virtual bool DoITerm2Action(const std::wstring_view string) = 0; + virtual bool DoWarpInBandGeneratorAction() = 0; + + virtual bool DoWarpAction() = 0; + + virtual bool DoWarpResetGridAction() = 0; + virtual bool DoFinalTermAction(const std::wstring_view string) = 0; virtual bool DoVsCodeAction(const std::wstring_view string) = 0; diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index 74ede69b53f..05ed9c6a453 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -3253,6 +3253,7 @@ bool AdaptDispatch::HardReset() // Routine Description: // - DECALN - Fills the entire screen with a test pattern of uppercase Es, +// // resets the margins and rendition attributes, and moves the cursor to // the home position. // Arguments: @@ -3756,6 +3757,73 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) return false; } +// Method Description: +// - Performs a iTerm2 action +// - Ascribes to the ITermDispatch interface +// - Currently, the actions we support are: +// * `OSC1337;SetMark`: mark a line as a prompt line +// - Not actually used in conhost +// Arguments: +// - string: contains the parameters that define which action we do +// Return Value: +// - false in conhost, true for the SetMark action, otherwise false. +bool AdaptDispatch::DoWarpAction() +{ + const auto isConPty = _api.IsConsolePty(); + if (isConPty) + { + // Flush the frame manually, to make sure marks end up on the right + // line, like the alt buffer sequence. + _renderer.TriggerFlush(false); + //CursorPosition(1, 1); + } + + return !isConPty; +} + +// Method Description: +// - Performs a iTerm2 action +// - Ascribes to the ITermDispatch interface +// - Currently, the actions we support are: +// * `OSC1337;SetMark`: mark a line as a prompt line +// - Not actually used in conhost +// Arguments: +// - string: contains the parameters that define which action we do +// Return Value: +// - false in conhost, true for the SetMark action, otherwise false. +bool AdaptDispatch::DoWarpInBandGeneratorAction() +{ + const auto isConPty = _api.IsConsolePty(); + if (isConPty) + { + // Flush the frame manually, to make sure marks end up on the right + // line, like the alt buffer sequence. + _renderer.TriggerFlush(false); + } + + return !isConPty; +} + +bool AdaptDispatch::DoWarpResetGridAction() +{ + const auto isConPty = _api.IsConsolePty(); + if (isConPty) + { + // Flush the frame manually, to make sure marks end up on the right + // line, like the alt buffer sequence. + _renderer.TriggerFlush(false); + + // Clear grid without painting. + // ATODO: Anything else we need to reset here? + CursorPosition(1, 1); + _pages.ActivePage().Buffer().Reset(); + _renderer.TriggerFlush(false); + //_pages.ActivePage().Buffer().Reset(); + } + + return !isConPty; +} + // Method Description: // - Performs a iTerm2 action // - Ascribes to the ITermDispatch interface diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index 76e32d0fdd5..d6b8c747436 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -146,6 +146,12 @@ namespace Microsoft::Console::VirtualTerminal bool DoITerm2Action(const std::wstring_view string) override; + bool DoWarpInBandGeneratorAction() override; + + bool DoWarpAction() override; + + bool DoWarpResetGridAction() override; + bool DoFinalTermAction(const std::wstring_view string) override; bool DoVsCodeAction(const std::wstring_view string) override; diff --git a/src/terminal/adapter/termDispatch.hpp b/src/terminal/adapter/termDispatch.hpp index 3a1d19a0964..422f80043bd 100644 --- a/src/terminal/adapter/termDispatch.hpp +++ b/src/terminal/adapter/termDispatch.hpp @@ -138,6 +138,11 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons bool DoFinalTermAction(const std::wstring_view /*string*/) override { return false; } + bool DoWarpInBandGeneratorAction() override { return false; } + bool DoWarpAction() override { return false; } + + bool DoWarpResetGridAction() override { return false; } + bool DoVsCodeAction(const std::wstring_view /*string*/) override { return false; } StringHandler DownloadDRCS(const VTInt /*fontNumber*/, diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp index 7568f154677..62a774df673 100644 --- a/src/terminal/parser/OutputStateMachineEngine.cpp +++ b/src/terminal/parser/OutputStateMachineEngine.cpp @@ -742,6 +742,10 @@ IStateMachineEngine::StringHandler OutputStateMachineEngine::ActionDcsDispatch(c case DcsActionCodes::DECRQSS_RequestSetting: handler = _dispatch->RequestSetting(); break; + case DcsActionCodes::DCS_WARP: + _dispatch->DoWarpAction(); + handler = nullptr; + break; case DcsActionCodes::DECRSPS_RestorePresentationState: handler = _dispatch->RestorePresentationState(parameters.at(0)); break; @@ -750,6 +754,13 @@ IStateMachineEngine::StringHandler OutputStateMachineEngine::ActionDcsDispatch(c break; } + // If we were unable to process the string, and there's a TTY attached to us, + // trigger the state machine to flush the string to the terminal. + if (_pfnFlushToTerminal != nullptr && handler == nullptr) + { + _pfnFlushToTerminal(); + } + _ClearLastChar(); return handler; @@ -903,6 +914,22 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s success = _dispatch->DoITerm2Action(string); break; } + + case OscActionCodes::WarpInBandGeneratorAction: + { + success = _dispatch->DoWarpInBandGeneratorAction(); + break; + } + case OscActionCodes::WarpAction: + { + success = _dispatch->DoWarpAction(); + break; + } + case OscActionCodes::WarpResetGridAction: + { + success = _dispatch->DoWarpResetGridAction(); + break; + } case OscActionCodes::FinalTermAction: { success = _dispatch->DoFinalTermAction(string); diff --git a/src/terminal/parser/OutputStateMachineEngine.hpp b/src/terminal/parser/OutputStateMachineEngine.hpp index 0970e45dee2..e9783d130a8 100644 --- a/src/terminal/parser/OutputStateMachineEngine.hpp +++ b/src/terminal/parser/OutputStateMachineEngine.hpp @@ -188,6 +188,7 @@ namespace Microsoft::Console::VirtualTerminal DECRSTS_RestoreTerminalState = VTID("$p"), DECRQSS_RequestSetting = VTID("$q"), DECRSPS_RestorePresentationState = VTID("$t"), + DCS_WARP = VTID("d"), }; enum Vt52ActionCodes : uint64_t @@ -229,6 +230,9 @@ namespace Microsoft::Console::VirtualTerminal FinalTermAction = 133, VsCodeAction = 633, ITerm2Action = 1337, + WarpInBandGeneratorAction = 9277, + WarpAction = 9278, + WarpResetGridAction = 9279, }; bool _GetOscSetColorTable(const std::wstring_view string,