From 611173be4c3b8328173bced08023704e99007940 Mon Sep 17 00:00:00 2001 From: James Holderness Date: Tue, 1 Feb 2022 19:47:39 +0000 Subject: [PATCH 1/4] Remove unused Execute(Char) methods. --- src/cascadia/TerminalCore/ITerminalApi.hpp | 1 - src/cascadia/TerminalCore/Terminal.hpp | 1 - src/cascadia/TerminalCore/TerminalApi.cpp | 8 -------- src/cascadia/TerminalCore/TerminalDispatch.cpp | 5 ----- src/cascadia/TerminalCore/TerminalDispatch.hpp | 1 - src/host/outputStream.cpp | 11 ----------- src/host/outputStream.hpp | 1 - src/terminal/adapter/ITermDispatch.hpp | 1 - src/terminal/adapter/adaptDefaults.hpp | 1 - src/terminal/adapter/adaptDispatch.hpp | 5 ----- src/terminal/adapter/termDispatch.hpp | 1 - src/terminal/adapter/ut_adapter/adapterTest.cpp | 4 ---- src/terminal/parser/ft_fuzzwrapper/echoDispatch.cpp | 5 ----- src/terminal/parser/ft_fuzzwrapper/echoDispatch.hpp | 1 - src/terminal/parser/ut_parser/OutputEngineTest.cpp | 8 -------- 15 files changed, 54 deletions(-) diff --git a/src/cascadia/TerminalCore/ITerminalApi.hpp b/src/cascadia/TerminalCore/ITerminalApi.hpp index 4e463c16664..70fc952f991 100644 --- a/src/cascadia/TerminalCore/ITerminalApi.hpp +++ b/src/cascadia/TerminalCore/ITerminalApi.hpp @@ -20,7 +20,6 @@ namespace Microsoft::Terminal::Core ITerminalApi& operator=(ITerminalApi&&) = default; virtual bool PrintString(std::wstring_view string) noexcept = 0; - virtual bool ExecuteChar(wchar_t wch) noexcept = 0; virtual TextAttribute GetTextAttributes() const noexcept = 0; virtual void SetTextAttributes(const TextAttribute& attrs) noexcept = 0; diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index 9fbc4700718..61ec7c570b5 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -96,7 +96,6 @@ class Microsoft::Terminal::Core::Terminal final : #pragma region ITerminalApi // These methods are defined in TerminalApi.cpp bool PrintString(std::wstring_view stringView) noexcept override; - bool ExecuteChar(wchar_t wch) noexcept override; TextAttribute GetTextAttributes() const noexcept override; void SetTextAttributes(const TextAttribute& attrs) noexcept override; Microsoft::Console::Types::Viewport GetBufferSize() noexcept override; diff --git a/src/cascadia/TerminalCore/TerminalApi.cpp b/src/cascadia/TerminalCore/TerminalApi.cpp index e2e5eb35253..c137ce50a43 100644 --- a/src/cascadia/TerminalCore/TerminalApi.cpp +++ b/src/cascadia/TerminalCore/TerminalApi.cpp @@ -19,14 +19,6 @@ try } CATCH_RETURN_FALSE() -bool Terminal::ExecuteChar(wchar_t wch) noexcept -try -{ - _WriteBuffer({ &wch, 1 }); - return true; -} -CATCH_RETURN_FALSE() - TextAttribute Terminal::GetTextAttributes() const noexcept { return _buffer->GetCurrentAttributes(); diff --git a/src/cascadia/TerminalCore/TerminalDispatch.cpp b/src/cascadia/TerminalCore/TerminalDispatch.cpp index 0c3dae74a8a..de3ab95cfb0 100644 --- a/src/cascadia/TerminalCore/TerminalDispatch.cpp +++ b/src/cascadia/TerminalCore/TerminalDispatch.cpp @@ -19,11 +19,6 @@ TerminalDispatch::TerminalDispatch(ITerminalApi& terminalApi) noexcept : { } -void TerminalDispatch::Execute(const wchar_t wchControl) noexcept -{ - _terminalApi.ExecuteChar(wchControl); -} - void TerminalDispatch::Print(const wchar_t wchPrintable) noexcept { _terminalApi.PrintString({ &wchPrintable, 1 }); diff --git a/src/cascadia/TerminalCore/TerminalDispatch.hpp b/src/cascadia/TerminalCore/TerminalDispatch.hpp index 7c0d14b9ce7..36eeec26320 100644 --- a/src/cascadia/TerminalCore/TerminalDispatch.hpp +++ b/src/cascadia/TerminalCore/TerminalDispatch.hpp @@ -12,7 +12,6 @@ class TerminalDispatch : public Microsoft::Console::VirtualTerminal::TermDispatc 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; diff --git a/src/host/outputStream.cpp b/src/host/outputStream.cpp index f82eefe67fb..e6f581312cd 100644 --- a/src/host/outputStream.cpp +++ b/src/host/outputStream.cpp @@ -47,17 +47,6 @@ void WriteBuffer::PrintString(const std::wstring_view string) _DefaultStringCase(string); } -// Routine Description: -// - Handles the execute action from the state machine -// Arguments: -// - wch - The C0 control character to be executed. -// Return Value: -// - -void WriteBuffer::Execute(const wchar_t wch) -{ - _DefaultCase(wch); -} - // Routine Description: // - Default text editing/printing handler for all characters that were not routed elsewhere by other state machine intercepts. // Arguments: diff --git a/src/host/outputStream.hpp b/src/host/outputStream.hpp index 53745669622..a9db258fa8c 100644 --- a/src/host/outputStream.hpp +++ b/src/host/outputStream.hpp @@ -30,7 +30,6 @@ class WriteBuffer : public Microsoft::Console::VirtualTerminal::AdaptDefaults // Implement Adapter callbacks for default cases (non-escape sequences) void Print(const wchar_t wch) override; void PrintString(const std::wstring_view string) override; - void Execute(const wchar_t wch) override; [[nodiscard]] NTSTATUS GetResult() { return _ntstatus; }; diff --git a/src/terminal/adapter/ITermDispatch.hpp b/src/terminal/adapter/ITermDispatch.hpp index e1c7bfdebb0..f0f48fa2d2f 100644 --- a/src/terminal/adapter/ITermDispatch.hpp +++ b/src/terminal/adapter/ITermDispatch.hpp @@ -29,7 +29,6 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch #pragma warning(disable : 26432) // suppress rule of 5 violation on interface because tampering with this is fraught with peril virtual ~ITermDispatch() = 0; - virtual void Execute(const wchar_t wchControl) = 0; virtual void Print(const wchar_t wchPrintable) = 0; virtual void PrintString(const std::wstring_view string) = 0; diff --git a/src/terminal/adapter/adaptDefaults.hpp b/src/terminal/adapter/adaptDefaults.hpp index 239c16d20c6..8597b4eaf05 100644 --- a/src/terminal/adapter/adaptDefaults.hpp +++ b/src/terminal/adapter/adaptDefaults.hpp @@ -25,6 +25,5 @@ namespace Microsoft::Console::VirtualTerminal virtual void Print(const wchar_t wch) = 0; // These characters need to be mutable so that they can be processed by the TerminalInput translater. virtual void PrintString(const std::wstring_view string) = 0; - virtual void Execute(const wchar_t wch) = 0; }; } diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index 97aefa8aebb..e57a01fa160 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -30,11 +30,6 @@ namespace Microsoft::Console::VirtualTerminal AdaptDispatch(std::unique_ptr pConApi, std::unique_ptr pDefaults); - void Execute(const wchar_t wchControl) override - { - _pDefaults->Execute(wchControl); - } - void PrintString(const std::wstring_view string) override; void Print(const wchar_t wchPrintable) override; diff --git a/src/terminal/adapter/termDispatch.hpp b/src/terminal/adapter/termDispatch.hpp index a9e4d830e48..eccde565519 100644 --- a/src/terminal/adapter/termDispatch.hpp +++ b/src/terminal/adapter/termDispatch.hpp @@ -20,7 +20,6 @@ namespace Microsoft::Console::VirtualTerminal class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Console::VirtualTerminal::ITermDispatch { public: - void Execute(const wchar_t wchControl) override = 0; void Print(const wchar_t wchPrintable) override = 0; void PrintString(const std::wstring_view string) override = 0; diff --git a/src/terminal/adapter/ut_adapter/adapterTest.cpp b/src/terminal/adapter/ut_adapter/adapterTest.cpp index 9ef4c7aaaf6..f4e19002843 100644 --- a/src/terminal/adapter/ut_adapter/adapterTest.cpp +++ b/src/terminal/adapter/ut_adapter/adapterTest.cpp @@ -652,10 +652,6 @@ class DummyAdapter : public AdaptDefaults void PrintString(const std::wstring_view /*string*/) override { } - - void Execute(const wchar_t /*wch*/) override - { - } }; class AdapterTest diff --git a/src/terminal/parser/ft_fuzzwrapper/echoDispatch.cpp b/src/terminal/parser/ft_fuzzwrapper/echoDispatch.cpp index a72c7b80fb3..73099ddf2aa 100644 --- a/src/terminal/parser/ft_fuzzwrapper/echoDispatch.cpp +++ b/src/terminal/parser/ft_fuzzwrapper/echoDispatch.cpp @@ -17,8 +17,3 @@ void EchoDispatch::PrintString(const std::wstring_view string) const std::wstring nullTermString(string); // string_view not guaranteed null terminated, but wprintf needs it. wprintf(L"PrintString: \"%s\" (%zd chars)\r\n", nullTermString.data(), nullTermString.size()); } - -void EchoDispatch::Execute(const wchar_t wchControl) -{ - wprintf(L"Execute: 0x%x\r\n", wchControl); -} diff --git a/src/terminal/parser/ft_fuzzwrapper/echoDispatch.hpp b/src/terminal/parser/ft_fuzzwrapper/echoDispatch.hpp index ac144a31ade..f026dfd2373 100644 --- a/src/terminal/parser/ft_fuzzwrapper/echoDispatch.hpp +++ b/src/terminal/parser/ft_fuzzwrapper/echoDispatch.hpp @@ -14,7 +14,6 @@ namespace Microsoft public: void Print(const wchar_t wchPrintable) override; void PrintString(const std::wstring_view string) override; - void Execute(const wchar_t wchControl) override; }; } } diff --git a/src/terminal/parser/ut_parser/OutputEngineTest.cpp b/src/terminal/parser/ut_parser/OutputEngineTest.cpp index 83ba7dfc767..f45b68fde2e 100644 --- a/src/terminal/parser/ut_parser/OutputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/OutputEngineTest.cpp @@ -36,10 +36,6 @@ namespace Microsoft class DummyDispatch final : public TermDispatch { public: - virtual void Execute(const wchar_t /*wchControl*/) override - { - } - virtual void Print(const wchar_t /*wchPrintable*/) override { } @@ -986,10 +982,6 @@ class Microsoft::Console::VirtualTerminal::OutputEngineTest final class StatefulDispatch final : public TermDispatch { public: - virtual void Execute(const wchar_t /*wchControl*/) override - { - } - virtual void Print(const wchar_t wchPrintable) override { _printString += wchPrintable; From 654c7504879089038a5324fed572532a00718ede Mon Sep 17 00:00:00 2001 From: James Holderness Date: Tue, 1 Feb 2022 20:03:21 +0000 Subject: [PATCH 2/4] Remove unneeded AdaptDefaults::Print method. --- src/host/outputStream.cpp | 22 ------------------- src/host/outputStream.hpp | 2 -- src/terminal/adapter/adaptDefaults.hpp | 1 - src/terminal/adapter/adaptDispatch.cpp | 2 +- .../adapter/ut_adapter/adapterTest.cpp | 4 ---- 5 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/host/outputStream.cpp b/src/host/outputStream.cpp index e6f581312cd..3b43f652083 100644 --- a/src/host/outputStream.cpp +++ b/src/host/outputStream.cpp @@ -25,17 +25,6 @@ WriteBuffer::WriteBuffer(_In_ Microsoft::Console::IIoProvider& io) : { } -// Routine Description: -// - Handles the print action from the state machine -// Arguments: -// - wch - The character to be printed. -// Return Value: -// - -void WriteBuffer::Print(const wchar_t wch) -{ - _DefaultCase(wch); -} - // Routine Description: // - Handles the print action from the state machine // Arguments: @@ -47,17 +36,6 @@ void WriteBuffer::PrintString(const std::wstring_view string) _DefaultStringCase(string); } -// Routine Description: -// - Default text editing/printing handler for all characters that were not routed elsewhere by other state machine intercepts. -// Arguments: -// - wch - The character to be processed by our default text editing/printing mechanisms. -// Return Value: -// - -void WriteBuffer::_DefaultCase(const wchar_t wch) -{ - _DefaultStringCase({ &wch, 1 }); -} - // Routine Description: // - Default text editing/printing handler for all characters that were not routed elsewhere by other state machine intercepts. // Arguments: diff --git a/src/host/outputStream.hpp b/src/host/outputStream.hpp index a9db258fa8c..16ca5d775b8 100644 --- a/src/host/outputStream.hpp +++ b/src/host/outputStream.hpp @@ -28,13 +28,11 @@ class WriteBuffer : public Microsoft::Console::VirtualTerminal::AdaptDefaults WriteBuffer(_In_ Microsoft::Console::IIoProvider& io); // Implement Adapter callbacks for default cases (non-escape sequences) - void Print(const wchar_t wch) override; void PrintString(const std::wstring_view string) override; [[nodiscard]] NTSTATUS GetResult() { return _ntstatus; }; private: - void _DefaultCase(const wchar_t wch); void _DefaultStringCase(const std::wstring_view string); Microsoft::Console::IIoProvider& _io; diff --git a/src/terminal/adapter/adaptDefaults.hpp b/src/terminal/adapter/adaptDefaults.hpp index 8597b4eaf05..612262a0a63 100644 --- a/src/terminal/adapter/adaptDefaults.hpp +++ b/src/terminal/adapter/adaptDefaults.hpp @@ -22,7 +22,6 @@ namespace Microsoft::Console::VirtualTerminal { public: virtual ~AdaptDefaults() = default; - virtual void Print(const wchar_t wch) = 0; // These characters need to be mutable so that they can be processed by the TerminalInput translater. virtual void PrintString(const std::wstring_view string) = 0; }; diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index 826233cec84..7eedb8f4db4 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -55,7 +55,7 @@ void AdaptDispatch::Print(const wchar_t wchPrintable) // a character is only output if the DEL is translated to something else. if (wchTranslated != AsciiChars::DEL) { - _pDefaults->Print(wchTranslated); + _pDefaults->PrintString({ &wchTranslated, 1 }); } } diff --git a/src/terminal/adapter/ut_adapter/adapterTest.cpp b/src/terminal/adapter/ut_adapter/adapterTest.cpp index f4e19002843..2b43df5bdd3 100644 --- a/src/terminal/adapter/ut_adapter/adapterTest.cpp +++ b/src/terminal/adapter/ut_adapter/adapterTest.cpp @@ -645,10 +645,6 @@ class TestGetSet final : public ConGetSet class DummyAdapter : public AdaptDefaults { - void Print(const wchar_t /*wch*/) override - { - } - void PrintString(const std::wstring_view /*string*/) override { } From fc5ed8beaa74967ee51fbdf9885de1b2e434a7b6 Mon Sep 17 00:00:00 2001 From: James Holderness Date: Tue, 1 Feb 2022 20:22:15 +0000 Subject: [PATCH 3/4] Move PrintString into ConGetSet. --- src/host/outputStream.cpp | 41 ++++++------------- src/host/outputStream.hpp | 26 ++---------- src/host/screenInfo.cpp | 3 +- src/terminal/adapter/adaptDispatch.cpp | 11 ++--- src/terminal/adapter/adaptDispatch.hpp | 7 +--- src/terminal/adapter/conGetSet.hpp | 3 ++ .../adapter/ut_adapter/adapterTest.cpp | 15 +++---- 7 files changed, 31 insertions(+), 75 deletions(-) diff --git a/src/host/outputStream.cpp b/src/host/outputStream.cpp index 3b43f652083..19773e283ed 100644 --- a/src/host/outputStream.cpp +++ b/src/host/outputStream.cpp @@ -19,9 +19,8 @@ using Microsoft::Console::Interactivity::ServiceLocator; using Microsoft::Console::VirtualTerminal::StateMachine; using Microsoft::Console::VirtualTerminal::TerminalInput; -WriteBuffer::WriteBuffer(_In_ Microsoft::Console::IIoProvider& io) : - _io{ io }, - _ntstatus{ STATUS_INVALID_DEVICE_STATE } +ConhostInternalGetSet::ConhostInternalGetSet(_In_ IIoProvider& io) : + _io{ io } { } @@ -31,18 +30,7 @@ WriteBuffer::WriteBuffer(_In_ Microsoft::Console::IIoProvider& io) : // - string - The string to be printed. // Return Value: // - -void WriteBuffer::PrintString(const std::wstring_view string) -{ - _DefaultStringCase(string); -} - -// Routine Description: -// - Default text editing/printing handler for all characters that were not routed elsewhere by other state machine intercepts. -// Arguments: -// - string - The string to be processed by our default text editing/printing mechanisms. -// Return Value: -// - -void WriteBuffer::_DefaultStringCase(const std::wstring_view string) +void ConhostInternalGetSet::PrintString(const std::wstring_view string) { size_t dwNumBytes = string.size() * sizeof(wchar_t); @@ -55,21 +43,18 @@ void WriteBuffer::_DefaultStringCase(const std::wstring_view string) // Defer the cursor drawing while we are iterating the string, for a better performance. // We can not waste time displaying a cursor event when we know more text is coming right behind it. cursor.StartDeferDrawing(); - _ntstatus = WriteCharsLegacy(_io.GetActiveOutputBuffer(), - string.data(), - string.data(), - string.data(), - &dwNumBytes, - nullptr, - _io.GetActiveOutputBuffer().GetTextBuffer().GetCursor().GetPosition().X, - WC_LIMIT_BACKSPACE | WC_DELAY_EOL_WRAP, - nullptr); + const auto ntstatus = WriteCharsLegacy(_io.GetActiveOutputBuffer(), + string.data(), + string.data(), + string.data(), + &dwNumBytes, + nullptr, + _io.GetActiveOutputBuffer().GetTextBuffer().GetCursor().GetPosition().X, + WC_LIMIT_BACKSPACE | WC_DELAY_EOL_WRAP, + nullptr); cursor.EndDeferDrawing(); -} -ConhostInternalGetSet::ConhostInternalGetSet(_In_ IIoProvider& io) : - _io{ io } -{ + THROW_IF_NTSTATUS_FAILED(ntstatus); } // Routine Description: diff --git a/src/host/outputStream.hpp b/src/host/outputStream.hpp index 16ca5d775b8..cff5a4d36bd 100644 --- a/src/host/outputStream.hpp +++ b/src/host/outputStream.hpp @@ -14,33 +14,11 @@ Module Name: #pragma once -#include "../terminal/adapter/adaptDefaults.hpp" +#include "../terminal/adapter/conGetSet.hpp" #include "../types/inc/IInputEvent.hpp" #include "../inc/conattrs.hpp" #include "IIoProvider.hpp" -class SCREEN_INFORMATION; - -// The WriteBuffer class provides helpers for writing text into the TextBuffer that is backing a particular console screen buffer. -class WriteBuffer : public Microsoft::Console::VirtualTerminal::AdaptDefaults -{ -public: - WriteBuffer(_In_ Microsoft::Console::IIoProvider& io); - - // Implement Adapter callbacks for default cases (non-escape sequences) - void PrintString(const std::wstring_view string) override; - - [[nodiscard]] NTSTATUS GetResult() { return _ntstatus; }; - -private: - void _DefaultStringCase(const std::wstring_view string); - - Microsoft::Console::IIoProvider& _io; - NTSTATUS _ntstatus; -}; - -#include "../terminal/adapter/conGetSet.hpp" - // The ConhostInternalGetSet is for the Conhost process to call the entrypoints for its own Get/Set APIs. // Normally, these APIs are accessible from the outside of the conhost process (like by the process being "hosted") through // the kernelbase/32 exposed public APIs and routed by the console driver (condrv) to this console host. @@ -51,6 +29,8 @@ class ConhostInternalGetSet final : public Microsoft::Console::VirtualTerminal:: public: ConhostInternalGetSet(_In_ Microsoft::Console::IIoProvider& io); + void PrintString(const std::wstring_view string) override; + void GetConsoleScreenBufferInfoEx(CONSOLE_SCREEN_BUFFER_INFOEX& screenBufferInfo) const override; void SetConsoleScreenBufferInfoEx(const CONSOLE_SCREEN_BUFFER_INFOEX& screenBufferInfo) override; diff --git a/src/host/screenInfo.cpp b/src/host/screenInfo.cpp index ee72405103c..f0f3e03710d 100644 --- a/src/host/screenInfo.cpp +++ b/src/host/screenInfo.cpp @@ -255,8 +255,7 @@ void SCREEN_INFORMATION::s_RemoveScreenBuffer(_In_ SCREEN_INFORMATION* const pSc try { auto getset = std::make_unique(*this); - auto defaults = std::make_unique(*this); - auto adapter = std::make_unique(std::move(getset), std::move(defaults)); + auto adapter = std::make_unique(std::move(getset)); auto engine = std::make_unique(std::move(adapter)); // Note that at this point in the setup, we haven't determined if we're // in VtIo mode or not yet. We'll set the OutputStateMachine's diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index 7eedb8f4db4..f360680b4db 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -26,17 +26,14 @@ bool NoOp() noexcept } // Note: AdaptDispatch will take ownership of pConApi and pDefaults -AdaptDispatch::AdaptDispatch(std::unique_ptr pConApi, - std::unique_ptr pDefaults) : +AdaptDispatch::AdaptDispatch(std::unique_ptr pConApi) : _pConApi{ std::move(pConApi) }, - _pDefaults{ std::move(pDefaults) }, _usingAltBuffer(false), _isOriginModeRelative(false), // by default, the DECOM origin mode is absolute. _isDECCOLMAllowed(false), // by default, DECCOLM is not allowed. _termOutput() { THROW_HR_IF_NULL(E_INVALIDARG, _pConApi.get()); - THROW_HR_IF_NULL(E_INVALIDARG, _pDefaults.get()); _scrollMargins = { 0 }; // initially, there are no scroll margins. } @@ -55,7 +52,7 @@ void AdaptDispatch::Print(const wchar_t wchPrintable) // a character is only output if the DEL is translated to something else. if (wchTranslated != AsciiChars::DEL) { - _pDefaults->PrintString({ &wchTranslated, 1 }); + _pConApi->PrintString({ &wchTranslated, 1 }); } } @@ -76,11 +73,11 @@ void AdaptDispatch::PrintString(const std::wstring_view string) { buffer.push_back(_termOutput.TranslateKey(wch)); } - _pDefaults->PrintString(buffer); + _pConApi->PrintString(buffer); } else { - _pDefaults->PrintString(string); + _pConApi->PrintString(string); } } diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index e57a01fa160..5d559f248bb 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -17,7 +17,6 @@ Author(s): #include "termDispatch.hpp" #include "DispatchCommon.hpp" #include "conGetSet.hpp" -#include "adaptDefaults.hpp" #include "FontBuffer.hpp" #include "terminalOutput.hpp" #include "..\..\types\inc\sgrStack.hpp" @@ -27,11 +26,10 @@ namespace Microsoft::Console::VirtualTerminal class AdaptDispatch : public ITermDispatch { public: - AdaptDispatch(std::unique_ptr pConApi, - std::unique_ptr pDefaults); + AdaptDispatch(std::unique_ptr pConApi); - void PrintString(const std::wstring_view string) override; void Print(const wchar_t wchPrintable) override; + void PrintString(const std::wstring_view string) override; bool CursorUp(const size_t distance) override; // CUU bool CursorDown(const size_t distance) override; // CUD @@ -195,7 +193,6 @@ namespace Microsoft::Console::VirtualTerminal bool _initDefaultTabStops = true; std::unique_ptr _pConApi; - std::unique_ptr _pDefaults; TerminalOutput _termOutput; std::unique_ptr _fontBuffer; std::optional _initialCodePage; diff --git a/src/terminal/adapter/conGetSet.hpp b/src/terminal/adapter/conGetSet.hpp index 7eb6e865a45..658b304b726 100644 --- a/src/terminal/adapter/conGetSet.hpp +++ b/src/terminal/adapter/conGetSet.hpp @@ -34,6 +34,9 @@ namespace Microsoft::Console::VirtualTerminal public: virtual ~ConGetSet() = default; + + virtual void PrintString(const std::wstring_view string) = 0; + virtual void GetConsoleScreenBufferInfoEx(CONSOLE_SCREEN_BUFFER_INFOEX& screenBufferInfo) const = 0; virtual void SetConsoleScreenBufferInfoEx(const CONSOLE_SCREEN_BUFFER_INFOEX& screenBufferInfo) = 0; virtual void SetCursorPosition(const COORD position) = 0; diff --git a/src/terminal/adapter/ut_adapter/adapterTest.cpp b/src/terminal/adapter/ut_adapter/adapterTest.cpp index 2b43df5bdd3..96c509f8501 100644 --- a/src/terminal/adapter/ut_adapter/adapterTest.cpp +++ b/src/terminal/adapter/ut_adapter/adapterTest.cpp @@ -58,6 +58,10 @@ using namespace Microsoft::Console::VirtualTerminal; class TestGetSet final : public ConGetSet { public: + void PrintString(const std::wstring_view /*string*/) override + { + } + void GetConsoleScreenBufferInfoEx(CONSOLE_SCREEN_BUFFER_INFOEX& sbiex) const override { Log::Comment(L"GetConsoleScreenBufferInfoEx MOCK returning data..."); @@ -643,13 +647,6 @@ class TestGetSet final : public ConGetSet HANDLE _hCon; }; -class DummyAdapter : public AdaptDefaults -{ - void PrintString(const std::wstring_view /*string*/) override - { - } -}; - class AdapterTest { public: @@ -663,11 +660,9 @@ class AdapterTest fSuccess = api.get() != nullptr; if (fSuccess) { - auto adapter = std::make_unique(); - // give AdaptDispatch ownership of _testGetSet _testGetSet = api.get(); // keep a copy for us but don't manage its lifetime anymore. - _pDispatch = std::make_unique(std::move(api), std::move(adapter)); + _pDispatch = std::make_unique(std::move(api)); fSuccess = _pDispatch != nullptr; } return fSuccess; From 5b28bada0258dc3e003b71834ca106af28dff6f5 Mon Sep 17 00:00:00 2001 From: James Holderness Date: Tue, 1 Feb 2022 20:30:14 +0000 Subject: [PATCH 4/4] Delete remains of AdaptDefaults class. --- src/terminal/adapter/adaptDefaults.hpp | 28 ------------------- src/terminal/adapter/lib/adapter.vcxproj | 1 - .../adapter/lib/adapter.vcxproj.filters | 3 -- 3 files changed, 32 deletions(-) delete mode 100644 src/terminal/adapter/adaptDefaults.hpp diff --git a/src/terminal/adapter/adaptDefaults.hpp b/src/terminal/adapter/adaptDefaults.hpp deleted file mode 100644 index 612262a0a63..00000000000 --- a/src/terminal/adapter/adaptDefaults.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/*++ -Copyright (c) Microsoft Corporation -Licensed under the MIT license. - -Module Name: -- adaptDefaults.hpp - -Abstract: -- This serves as an abstraction for the default cases in the state machine (which is to just print or execute a simple single character. -- This can also handle processing of an entire string of printable characters, as an optimization. -- When using the Windows Console API adapter (AdaptDispatch), this must be passed in to signify where standard actions should go. - -Author(s): -- Michael Niksa (MiNiksa) 30-July-2015 -- Mike Griese (migrie) 07-March-2016 ---*/ -#pragma once - -namespace Microsoft::Console::VirtualTerminal -{ - class AdaptDefaults - { - public: - virtual ~AdaptDefaults() = default; - // These characters need to be mutable so that they can be processed by the TerminalInput translater. - virtual void PrintString(const std::wstring_view string) = 0; - }; -} diff --git a/src/terminal/adapter/lib/adapter.vcxproj b/src/terminal/adapter/lib/adapter.vcxproj index a2c7b78b3ef..034ef8cb345 100644 --- a/src/terminal/adapter/lib/adapter.vcxproj +++ b/src/terminal/adapter/lib/adapter.vcxproj @@ -23,7 +23,6 @@ - diff --git a/src/terminal/adapter/lib/adapter.vcxproj.filters b/src/terminal/adapter/lib/adapter.vcxproj.filters index 1d76cc8d648..b81bef3ac0c 100644 --- a/src/terminal/adapter/lib/adapter.vcxproj.filters +++ b/src/terminal/adapter/lib/adapter.vcxproj.filters @@ -44,9 +44,6 @@ - - Header Files - Header Files