From 6dd9c468ebc77e0025939b32fb927e85f3172b25 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 23 Aug 2024 00:52:09 +0200 Subject: [PATCH] ConPTY: Flush unhandled sequences to the buffer (#17741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #17510 made it so that VT requests like DA1 are passed through to the hosting terminal and so conhost stopped responding to them on its own. But since our input parser doesn't support proper passthrough (yet), it swallowed the response coming from the terminal. To solve this issue, this PR repurposes the existing boolean return values to indicate to the parser whether the current sequence should be flushed to the dispatcher as-is. The output parser always returns true (success) and leaves its pass-through handler empty, while the input parser returns false for sequences it doesn't expect. ## Validation Steps Performed * Launch cmd * Press `Ctrl+[`, `[`, `c`, `Enter` (= `^[[c` = DA1 request) * DA1 response is visible ✅ --- src/host/VtInputThread.cpp | 4 - src/inc/til.h | 13 - src/terminal/adapter/DispatchTypes.hpp | 6 +- src/terminal/adapter/FontBuffer.cpp | 5 +- src/terminal/adapter/IInteractDispatch.hpp | 20 +- src/terminal/adapter/ITermDispatch.hpp | 224 ++--- src/terminal/adapter/InteractDispatch.cpp | 39 +- src/terminal/adapter/InteractDispatch.hpp | 15 +- src/terminal/adapter/adaptDispatch.cpp | 768 ++++++------------ src/terminal/adapter/adaptDispatch.hpp | 216 ++--- .../adapter/adaptDispatchGraphics.cpp | 20 +- src/terminal/adapter/termDispatch.hpp | 226 +++--- src/terminal/adapter/terminalOutput.cpp | 43 +- src/terminal/adapter/terminalOutput.hpp | 14 +- .../adapter/ut_adapter/adapterTest.cpp | 419 +++++----- src/terminal/parser/IStateMachineEngine.hpp | 8 +- .../parser/InputStateMachineEngine.cpp | 217 ++--- .../parser/InputStateMachineEngine.hpp | 17 +- .../parser/OutputStateMachineEngine.cpp | 395 +++++---- .../parser/OutputStateMachineEngine.hpp | 6 +- src/terminal/parser/stateMachine.cpp | 32 +- src/terminal/parser/stateMachine.hpp | 21 +- .../parser/ut_parser/InputEngineTest.cpp | 89 +- .../parser/ut_parser/OutputEngineTest.cpp | 145 +--- .../parser/ut_parser/StateMachineTest.cpp | 6 +- 25 files changed, 1201 insertions(+), 1767 deletions(-) diff --git a/src/host/VtInputThread.cpp b/src/host/VtInputThread.cpp index 65c62abf25e..efd2fd4e51e 100644 --- a/src/host/VtInputThread.cpp +++ b/src/host/VtInputThread.cpp @@ -28,10 +28,6 @@ VtInputThread::VtInputThread(_In_ wil::unique_hfile hPipe, const bool inheritCur auto dispatch = std::make_unique(); auto engine = std::make_unique(std::move(dispatch), inheritCursor); - - // we need this callback to be able to flush an unknown input sequence to the app - engine->SetFlushToInputQueueCallback([this] { return _pInputStateMachine->FlushToTerminal(); }); - _pInputStateMachine = std::make_unique(std::move(engine)); } diff --git a/src/inc/til.h b/src/inc/til.h index dd60656a90f..c79b0debdc5 100644 --- a/src/inc/til.h +++ b/src/inc/til.h @@ -96,19 +96,6 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned" // These sit outside the namespace because they sit outside for WIL too. -// Inspired from RETURN_IF_WIN32_BOOL_FALSE -// WIL doesn't include a RETURN_BOOL_IF_FALSE, and RETURN_IF_WIN32_BOOL_FALSE -// will actually return the value of GLE. -#define RETURN_BOOL_IF_FALSE(b) \ - do \ - { \ - const bool __boolRet = wil::verify_bool(b); \ - if (!__boolRet) \ - { \ - return __boolRet; \ - } \ - } while (0, 0) - // Due to a bug (DevDiv 441931), Warning 4297 (function marked noexcept throws // exception) is detected even when the throwing code is unreachable, such as // the end of scope after a return, in function-level catch. diff --git a/src/terminal/adapter/DispatchTypes.hpp b/src/terminal/adapter/DispatchTypes.hpp index 4db898d1a83..f1adb1457c8 100644 --- a/src/terminal/adapter/DispatchTypes.hpp +++ b/src/terminal/adapter/DispatchTypes.hpp @@ -280,7 +280,7 @@ namespace Microsoft::Console::VirtualTerminal } template - bool for_each(const T&& predicate) const + void for_each(const T&& predicate) const { auto params = _params; @@ -291,12 +291,10 @@ namespace Microsoft::Console::VirtualTerminal params = defaultParameters; } - auto success = true; for (const auto& v : params) { - success = predicate(v) && success; + predicate(v); } - return success; } private: diff --git a/src/terminal/adapter/FontBuffer.cpp b/src/terminal/adapter/FontBuffer.cpp index c1962b8190d..dabee138f7c 100644 --- a/src/terminal/adapter/FontBuffer.cpp +++ b/src/terminal/adapter/FontBuffer.cpp @@ -198,7 +198,10 @@ void FontBuffer::AddSixelData(const wchar_t ch) bool FontBuffer::FinalizeSixelData() { // If the charset ID hasn't been initialized this isn't a valid update. - RETURN_BOOL_IF_FALSE(_charsetIdInitialized); + if (!_charsetIdInitialized) + { + return false; + } // Flush the current line to make sure we take all the used positions // into account when calculating the font dimensions. diff --git a/src/terminal/adapter/IInteractDispatch.hpp b/src/terminal/adapter/IInteractDispatch.hpp index 36278bd2e1a..4006c4c82a4 100644 --- a/src/terminal/adapter/IInteractDispatch.hpp +++ b/src/terminal/adapter/IInteractDispatch.hpp @@ -28,21 +28,13 @@ namespace Microsoft::Console::VirtualTerminal virtual ~IInteractDispatch() = default; #pragma warning(pop) - virtual bool WriteInput(const std::span& inputEvents) = 0; - - virtual bool WriteCtrlKey(const INPUT_RECORD& event) = 0; - - virtual bool WriteString(const std::wstring_view string) = 0; - - virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const VTParameter parameter1, - const VTParameter parameter2) = 0; - - virtual bool MoveCursor(const VTInt row, - const VTInt col) = 0; - virtual bool IsVtInputEnabled() const = 0; - virtual bool FocusChanged(const bool focused) const = 0; + virtual void WriteInput(const std::span& inputEvents) = 0; + virtual void WriteCtrlKey(const INPUT_RECORD& event) = 0; + virtual void WriteString(std::wstring_view string) = 0; + virtual void WindowManipulation(DispatchTypes::WindowManipulationType function, VTParameter parameter1, VTParameter parameter2) = 0; + virtual void MoveCursor(VTInt row, VTInt col) = 0; + virtual void FocusChanged(bool focused) = 0; }; } diff --git a/src/terminal/adapter/ITermDispatch.hpp b/src/terminal/adapter/ITermDispatch.hpp index 514c8b0c4d9..3df5ef30178 100644 --- a/src/terminal/adapter/ITermDispatch.hpp +++ b/src/terminal/adapter/ITermDispatch.hpp @@ -32,123 +32,123 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch virtual void Print(const wchar_t wchPrintable) = 0; virtual void PrintString(const std::wstring_view string) = 0; - virtual bool CursorUp(const VTInt distance) = 0; // CUU - virtual bool CursorDown(const VTInt distance) = 0; // CUD - virtual bool CursorForward(const VTInt distance) = 0; // CUF - virtual bool CursorBackward(const VTInt distance) = 0; // CUB, BS - virtual bool CursorNextLine(const VTInt distance) = 0; // CNL - virtual bool CursorPrevLine(const VTInt distance) = 0; // CPL - virtual bool CursorHorizontalPositionAbsolute(const VTInt column) = 0; // HPA, CHA - virtual bool VerticalLinePositionAbsolute(const VTInt line) = 0; // VPA - virtual bool HorizontalPositionRelative(const VTInt distance) = 0; // HPR - virtual bool VerticalPositionRelative(const VTInt distance) = 0; // VPR - virtual bool CursorPosition(const VTInt line, const VTInt column) = 0; // CUP, HVP - virtual bool CursorSaveState() = 0; // DECSC - virtual bool CursorRestoreState() = 0; // DECRC - virtual bool InsertCharacter(const VTInt count) = 0; // ICH - virtual bool DeleteCharacter(const VTInt count) = 0; // DCH - virtual bool ScrollUp(const VTInt distance) = 0; // SU - virtual bool ScrollDown(const VTInt distance) = 0; // SD - virtual bool NextPage(const VTInt pageCount) = 0; // NP - virtual bool PrecedingPage(const VTInt pageCount) = 0; // PP - virtual bool PagePositionAbsolute(const VTInt page) = 0; // PPA - virtual bool PagePositionRelative(const VTInt pageCount) = 0; // PPR - virtual bool PagePositionBack(const VTInt pageCount) = 0; // PPB - virtual bool RequestDisplayedExtent() = 0; // DECRQDE - virtual bool InsertLine(const VTInt distance) = 0; // IL - virtual bool DeleteLine(const VTInt distance) = 0; // DL - virtual bool InsertColumn(const VTInt distance) = 0; // DECIC - virtual bool DeleteColumn(const VTInt distance) = 0; // DECDC - virtual bool SetKeypadMode(const bool applicationMode) = 0; // DECKPAM, DECKPNM - virtual bool SetAnsiMode(const bool ansiMode) = 0; // DECANM - virtual bool SetTopBottomScrollingMargins(const VTInt topMargin, const VTInt bottomMargin) = 0; // DECSTBM - virtual bool SetLeftRightScrollingMargins(const VTInt leftMargin, const VTInt rightMargin) = 0; // DECSLRM - virtual bool EnquireAnswerback() = 0; // ENQ - virtual bool WarningBell() = 0; // BEL - virtual bool CarriageReturn() = 0; // CR - virtual bool LineFeed(const DispatchTypes::LineFeedType lineFeedType) = 0; // IND, NEL, LF, FF, VT - virtual bool ReverseLineFeed() = 0; // RI - virtual bool BackIndex() = 0; // DECBI - virtual bool ForwardIndex() = 0; // DECFI - virtual bool SetWindowTitle(std::wstring_view title) = 0; // DECSWT, OscWindowTitle - virtual bool HorizontalTabSet() = 0; // HTS - virtual bool ForwardTab(const VTInt numTabs) = 0; // CHT, HT - virtual bool BackwardsTab(const VTInt numTabs) = 0; // CBT - virtual bool TabClear(const DispatchTypes::TabClearType clearType) = 0; // TBC - virtual bool TabSet(const VTParameter setType) = 0; // DECST8C - virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD color) = 0; // OSCSetColorTable - virtual bool RequestColorTableEntry(const size_t tableIndex) = 0; // OSCGetColorTable - virtual bool SetXtermColorResource(const size_t resource, const DWORD color) = 0; // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor - virtual bool RequestXtermColorResource(const size_t resource) = 0; // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor - virtual bool AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) = 0; // DECAC - - virtual bool EraseInDisplay(const DispatchTypes::EraseType eraseType) = 0; // ED - virtual bool EraseInLine(const DispatchTypes::EraseType eraseType) = 0; // EL - virtual bool EraseCharacters(const VTInt numChars) = 0; // ECH - virtual bool SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) = 0; // DECSED - virtual bool SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) = 0; // DECSEL - - virtual bool ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) = 0; // DECCARA - virtual bool ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) = 0; // DECRARA - virtual bool CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) = 0; // DECCRA - virtual bool FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECFRA - virtual bool EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECERA - virtual bool SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECSERA - virtual bool SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) = 0; // DECSACE - virtual bool RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECRQCRA - - virtual bool SetGraphicsRendition(const VTParameters options) = 0; // SGR - virtual bool SetLineRendition(const LineRendition rendition) = 0; // DECSWL, DECDWL, DECDHL - virtual bool SetCharacterProtectionAttribute(const VTParameters options) = 0; // DECSCA - - virtual bool PushGraphicsRendition(const VTParameters options) = 0; // XTPUSHSGR - virtual bool PopGraphicsRendition() = 0; // XTPOPSGR - - virtual bool SetMode(const DispatchTypes::ModeParams param) = 0; // SM, DECSET - virtual bool ResetMode(const DispatchTypes::ModeParams param) = 0; // RM, DECRST - virtual bool RequestMode(const DispatchTypes::ModeParams param) = 0; // DECRQM - - virtual bool DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) = 0; // DSR - virtual bool DeviceAttributes() = 0; // DA1 - virtual bool SecondaryDeviceAttributes() = 0; // DA2 - virtual bool TertiaryDeviceAttributes() = 0; // DA3 - virtual bool Vt52DeviceAttributes() = 0; // VT52 Identify - virtual bool RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) = 0; // DECREQTPARM - - virtual bool DesignateCodingSystem(const VTID codingSystem) = 0; // DOCS - virtual bool Designate94Charset(const VTInt gsetNumber, const VTID charset) = 0; // SCS - virtual bool Designate96Charset(const VTInt gsetNumber, const VTID charset) = 0; // SCS - virtual bool LockingShift(const VTInt gsetNumber) = 0; // LS0, LS1, LS2, LS3 - virtual bool LockingShiftRight(const VTInt gsetNumber) = 0; // LS1R, LS2R, LS3R - virtual bool SingleShift(const VTInt gsetNumber) = 0; // SS2, SS3 - virtual bool AcceptC1Controls(const bool enabled) = 0; // DECAC1 - virtual bool AnnounceCodeStructure(const VTInt ansiLevel) = 0; // ACS - - virtual bool SoftReset() = 0; // DECSTR - virtual bool HardReset() = 0; // RIS - virtual bool ScreenAlignmentPattern() = 0; // DECALN - - virtual bool SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) = 0; // DECSCUSR - - virtual bool SetClipboard(wil::zwstring_view content) = 0; // OSCSetClipboard + virtual void CursorUp(const VTInt distance) = 0; // CUU + virtual void CursorDown(const VTInt distance) = 0; // CUD + virtual void CursorForward(const VTInt distance) = 0; // CUF + virtual void CursorBackward(const VTInt distance) = 0; // CUB, BS + virtual void CursorNextLine(const VTInt distance) = 0; // CNL + virtual void CursorPrevLine(const VTInt distance) = 0; // CPL + virtual void CursorHorizontalPositionAbsolute(const VTInt column) = 0; // HPA, CHA + virtual void VerticalLinePositionAbsolute(const VTInt line) = 0; // VPA + virtual void HorizontalPositionRelative(const VTInt distance) = 0; // HPR + virtual void VerticalPositionRelative(const VTInt distance) = 0; // VPR + virtual void CursorPosition(const VTInt line, const VTInt column) = 0; // CUP, HVP + virtual void CursorSaveState() = 0; // DECSC + virtual void CursorRestoreState() = 0; // DECRC + virtual void InsertCharacter(const VTInt count) = 0; // ICH + virtual void DeleteCharacter(const VTInt count) = 0; // DCH + virtual void ScrollUp(const VTInt distance) = 0; // SU + virtual void ScrollDown(const VTInt distance) = 0; // SD + virtual void NextPage(const VTInt pageCount) = 0; // NP + virtual void PrecedingPage(const VTInt pageCount) = 0; // PP + virtual void PagePositionAbsolute(const VTInt page) = 0; // PPA + virtual void PagePositionRelative(const VTInt pageCount) = 0; // PPR + virtual void PagePositionBack(const VTInt pageCount) = 0; // PPB + virtual void RequestDisplayedExtent() = 0; // DECRQDE + virtual void InsertLine(const VTInt distance) = 0; // IL + virtual void DeleteLine(const VTInt distance) = 0; // DL + virtual void InsertColumn(const VTInt distance) = 0; // DECIC + virtual void DeleteColumn(const VTInt distance) = 0; // DECDC + virtual void SetKeypadMode(const bool applicationMode) = 0; // DECKPAM, DECKPNM + virtual void SetAnsiMode(const bool ansiMode) = 0; // DECANM + virtual void SetTopBottomScrollingMargins(const VTInt topMargin, const VTInt bottomMargin) = 0; // DECSTBM + virtual void SetLeftRightScrollingMargins(const VTInt leftMargin, const VTInt rightMargin) = 0; // DECSLRM + virtual void EnquireAnswerback() = 0; // ENQ + virtual void WarningBell() = 0; // BEL + virtual void CarriageReturn() = 0; // CR + virtual void LineFeed(const DispatchTypes::LineFeedType lineFeedType) = 0; // IND, NEL, LF, FF, VT + virtual void ReverseLineFeed() = 0; // RI + virtual void BackIndex() = 0; // DECBI + virtual void ForwardIndex() = 0; // DECFI + virtual void SetWindowTitle(std::wstring_view title) = 0; // DECSWT, OscWindowTitle + virtual void HorizontalTabSet() = 0; // HTS + virtual void ForwardTab(const VTInt numTabs) = 0; // CHT, HT + virtual void BackwardsTab(const VTInt numTabs) = 0; // CBT + virtual void TabClear(const DispatchTypes::TabClearType clearType) = 0; // TBC + virtual void TabSet(const VTParameter setType) = 0; // DECST8C + virtual void SetColorTableEntry(const size_t tableIndex, const DWORD color) = 0; // OSCSetColorTable + virtual void RequestColorTableEntry(const size_t tableIndex) = 0; // OSCGetColorTable + virtual void SetXtermColorResource(const size_t resource, const DWORD color) = 0; // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor + virtual void RequestXtermColorResource(const size_t resource) = 0; // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor + virtual void AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) = 0; // DECAC + + virtual void EraseInDisplay(const DispatchTypes::EraseType eraseType) = 0; // ED + virtual void EraseInLine(const DispatchTypes::EraseType eraseType) = 0; // EL + virtual void EraseCharacters(const VTInt numChars) = 0; // ECH + virtual void SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) = 0; // DECSED + virtual void SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) = 0; // DECSEL + + virtual void ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) = 0; // DECCARA + virtual void ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) = 0; // DECRARA + virtual void CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) = 0; // DECCRA + virtual void FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECFRA + virtual void EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECERA + virtual void SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECSERA + virtual void SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) = 0; // DECSACE + virtual void RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) = 0; // DECRQCRA + + virtual void SetGraphicsRendition(const VTParameters options) = 0; // SGR + virtual void SetLineRendition(const LineRendition rendition) = 0; // DECSWL, DECDWL, DECDHL + virtual void SetCharacterProtectionAttribute(const VTParameters options) = 0; // DECSCA + + virtual void PushGraphicsRendition(const VTParameters options) = 0; // XTPUSHSGR + virtual void PopGraphicsRendition() = 0; // XTPOPSGR + + virtual void SetMode(const DispatchTypes::ModeParams param) = 0; // SM, DECSET + virtual void ResetMode(const DispatchTypes::ModeParams param) = 0; // RM, DECRST + virtual void RequestMode(const DispatchTypes::ModeParams param) = 0; // DECRQM + + virtual void DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) = 0; // DSR + virtual void DeviceAttributes() = 0; // DA1 + virtual void SecondaryDeviceAttributes() = 0; // DA2 + virtual void TertiaryDeviceAttributes() = 0; // DA3 + virtual void Vt52DeviceAttributes() = 0; // VT52 Identify + virtual void RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) = 0; // DECREQTPARM + + virtual void DesignateCodingSystem(const VTID codingSystem) = 0; // DOCS + virtual void Designate94Charset(const VTInt gsetNumber, const VTID charset) = 0; // SCS + virtual void Designate96Charset(const VTInt gsetNumber, const VTID charset) = 0; // SCS + virtual void LockingShift(const VTInt gsetNumber) = 0; // LS0, LS1, LS2, LS3 + virtual void LockingShiftRight(const VTInt gsetNumber) = 0; // LS1R, LS2R, LS3R + virtual void SingleShift(const VTInt gsetNumber) = 0; // SS2, SS3 + virtual void AcceptC1Controls(const bool enabled) = 0; // DECAC1 + virtual void AnnounceCodeStructure(const VTInt ansiLevel) = 0; // ACS + + virtual void SoftReset() = 0; // DECSTR + virtual void HardReset() = 0; // RIS + virtual void ScreenAlignmentPattern() = 0; // DECALN + + virtual void SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) = 0; // DECSCUSR + + virtual void SetClipboard(wil::zwstring_view content) = 0; // OSCSetClipboard // DTTERM_WindowManipulation - virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, + virtual void WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) = 0; - virtual bool AddHyperlink(const std::wstring_view uri, const std::wstring_view params) = 0; - virtual bool EndHyperlink() = 0; + virtual void AddHyperlink(const std::wstring_view uri, const std::wstring_view params) = 0; + virtual void EndHyperlink() = 0; - virtual bool DoConEmuAction(const std::wstring_view string) = 0; + virtual void DoConEmuAction(const std::wstring_view string) = 0; - virtual bool DoITerm2Action(const std::wstring_view string) = 0; + virtual void DoITerm2Action(const std::wstring_view string) = 0; - virtual bool DoFinalTermAction(const std::wstring_view string) = 0; + virtual void DoFinalTermAction(const std::wstring_view string) = 0; - virtual bool DoVsCodeAction(const std::wstring_view string) = 0; + virtual void DoVsCodeAction(const std::wstring_view string) = 0; - virtual bool DoWTAction(const std::wstring_view string) = 0; + virtual void DoWTAction(const std::wstring_view string) = 0; virtual StringHandler DefineSixelImage(const VTInt macroParameter, const DispatchTypes::SixelBackground backgroundSelect, @@ -163,23 +163,23 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch const VTParameter cellHeight, const DispatchTypes::CharsetSize charsetSize) = 0; // DECDLD - virtual bool RequestUserPreferenceCharset() = 0; // DECRQUPSS + virtual void RequestUserPreferenceCharset() = 0; // DECRQUPSS virtual StringHandler AssignUserPreferenceCharset(const DispatchTypes::CharsetSize charsetSize) = 0; // DECAUPSS virtual StringHandler DefineMacro(const VTInt macroId, const DispatchTypes::MacroDeleteControl deleteControl, const DispatchTypes::MacroEncoding encoding) = 0; // DECDMAC - virtual bool InvokeMacro(const VTInt macroId) = 0; // DECINVM + virtual void InvokeMacro(const VTInt macroId) = 0; // DECINVM - virtual bool RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) = 0; // DECRQTSR + virtual void RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) = 0; // DECRQTSR virtual StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat format) = 0; // DECRSTS virtual StringHandler RequestSetting() = 0; // DECRQSS - virtual bool RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) = 0; // DECRQPSR + virtual void RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) = 0; // DECRQPSR virtual StringHandler RestorePresentationState(const DispatchTypes::PresentationReportFormat format) = 0; // DECRSPS - virtual bool PlaySounds(const VTParameters parameters) = 0; // DECPS + virtual void PlaySounds(const VTParameters parameters) = 0; // DECPS }; inline Microsoft::Console::VirtualTerminal::ITermDispatch::~ITermDispatch() = default; #pragma warning(pop) diff --git a/src/terminal/adapter/InteractDispatch.cpp b/src/terminal/adapter/InteractDispatch.cpp index 09329eb6647..1f859c6916d 100644 --- a/src/terminal/adapter/InteractDispatch.cpp +++ b/src/terminal/adapter/InteractDispatch.cpp @@ -35,13 +35,10 @@ InteractDispatch::InteractDispatch() : // to be read by the client. // Arguments: // - inputEvents: a collection of IInputEvents -// Return Value: -// - True. -bool InteractDispatch::WriteInput(const std::span& inputEvents) +void InteractDispatch::WriteInput(const std::span& inputEvents) { const auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation(); gci.GetActiveInputBuffer()->Write(inputEvents); - return true; } // Method Description: @@ -51,19 +48,16 @@ bool InteractDispatch::WriteInput(const std::span& inputEven // client application. // Arguments: // - event: The key to send to the host. -bool InteractDispatch::WriteCtrlKey(const INPUT_RECORD& event) +void InteractDispatch::WriteCtrlKey(const INPUT_RECORD& event) { HandleGenericKeyEvent(event, false); - return true; } // Method Description: // - Writes a string of input to the host. // Arguments: // - string : a string to write to the console. -// Return Value: -// - True. -bool InteractDispatch::WriteString(const std::wstring_view string) +void InteractDispatch::WriteString(const std::wstring_view string) { if (!string.empty()) { @@ -77,7 +71,6 @@ bool InteractDispatch::WriteString(const std::wstring_view string) WriteInput(keyEvents); } - return true; } //Method Description: @@ -90,9 +83,7 @@ bool InteractDispatch::WriteString(const std::wstring_view string) // - function - An identifier of the WindowManipulation function to perform // - parameter1 - The first optional parameter for the function // - parameter2 - The second optional parameter for the function -// Return value: -// True if handled successfully. False otherwise. -bool InteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, +void InteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) { @@ -103,20 +94,20 @@ bool InteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulatio { case DispatchTypes::WindowManipulationType::DeIconifyWindow: _api.ShowWindow(true); - return true; + break; case DispatchTypes::WindowManipulationType::IconifyWindow: _api.ShowWindow(false); - return true; + break; case DispatchTypes::WindowManipulationType::RefreshWindow: _api.GetBufferAndViewport().buffer.TriggerRedrawAll(); - return true; + break; case DispatchTypes::WindowManipulationType::ResizeWindowInCharacters: // TODO:GH#1765 We should introduce a better `ResizeConpty` function to // ConhostInternalGetSet, that specifically handles a conpty resize. _api.ResizeWindow(parameter2.value_or(0), parameter1.value_or(0)); - return true; + break; default: - return false; + break; } } @@ -126,9 +117,7 @@ bool InteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulatio //Arguments: // - row: The row to move the cursor to. // - col: The column to move the cursor to. -// Return value: -// - True. -bool InteractDispatch::MoveCursor(const VTInt row, const VTInt col) +void InteractDispatch::MoveCursor(const VTInt row, const VTInt col) { // First retrieve some information about the buffer const auto viewport = _api.GetBufferAndViewport().viewport; @@ -142,7 +131,7 @@ bool InteractDispatch::MoveCursor(const VTInt row, const VTInt col) // Finally, attempt to set the adjusted cursor position back into the console. const auto api = gsl::not_null{ ServiceLocator::LocateGlobals().api }; auto& info = ServiceLocator::LocateGlobals().getConsoleInformation().GetActiveOutputBuffer(); - return SUCCEEDED(api->SetConsoleCursorPositionImpl(info, coordCursor)); + LOG_IF_FAILED(api->SetConsoleCursorPositionImpl(info, coordCursor)); } // Routine Description: @@ -164,9 +153,7 @@ bool InteractDispatch::IsVtInputEnabled() const // - Used to call ConsoleControl(ConsoleSetForeground,...). // Arguments: // - focused: if the terminal is now focused -// Return Value: -// - true always. -bool InteractDispatch::FocusChanged(const bool focused) const +void InteractDispatch::FocusChanged(const bool focused) { auto& g = ServiceLocator::LocateGlobals(); auto& gci = g.getConsoleInformation(); @@ -231,6 +218,4 @@ bool InteractDispatch::FocusChanged(const bool focused) const gci.pInputBuffer->WriteFocusEvent(focused); } // Does nothing outside of ConPTY. If there's a real HWND, then the HWND is solely in charge. - - return true; } diff --git a/src/terminal/adapter/InteractDispatch.hpp b/src/terminal/adapter/InteractDispatch.hpp index 56fd9b2dd80..189d73e2a52 100644 --- a/src/terminal/adapter/InteractDispatch.hpp +++ b/src/terminal/adapter/InteractDispatch.hpp @@ -25,17 +25,14 @@ namespace Microsoft::Console::VirtualTerminal public: InteractDispatch(); - bool WriteInput(const std::span& inputEvents) override; - bool WriteCtrlKey(const INPUT_RECORD& event) override; - bool WriteString(const std::wstring_view string) override; - bool WindowManipulation(const DispatchTypes::WindowManipulationType function, - const VTParameter parameter1, - const VTParameter parameter2) override; // DTTERM_WindowManipulation - bool MoveCursor(const VTInt row, const VTInt col) override; - bool IsVtInputEnabled() const override; - bool FocusChanged(const bool focused) const override; + void WriteInput(const std::span& inputEvents) override; + void WriteCtrlKey(const INPUT_RECORD& event) override; + void WriteString(std::wstring_view string) override; + void WindowManipulation(DispatchTypes::WindowManipulationType function, VTParameter parameter1, VTParameter parameter2) override; + void MoveCursor(VTInt row, VTInt col) override; + void FocusChanged(bool focused) override; private: ConhostInternalGetSet _api; diff --git a/src/terminal/adapter/adaptDispatch.cpp b/src/terminal/adapter/adaptDispatch.cpp index a02895a1993..edbda3f514a 100644 --- a/src/terminal/adapter/adaptDispatch.cpp +++ b/src/terminal/adapter/adaptDispatch.cpp @@ -223,11 +223,9 @@ void AdaptDispatch::_WriteToBuffer(const std::wstring_view string) // margin, then the cursor stops at the top line." // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorUp(const VTInt distance) +void AdaptDispatch::CursorUp(const VTInt distance) { - return _CursorMovePosition(Offset::Backward(distance), Offset::Unchanged(), true); + _CursorMovePosition(Offset::Backward(distance), Offset::Unchanged(), true); } // Routine Description: @@ -239,33 +237,27 @@ bool AdaptDispatch::CursorUp(const VTInt distance) // bottom margin, then the cursor stops at the bottom line." // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorDown(const VTInt distance) +void AdaptDispatch::CursorDown(const VTInt distance) { - return _CursorMovePosition(Offset::Forward(distance), Offset::Unchanged(), true); + _CursorMovePosition(Offset::Forward(distance), Offset::Unchanged(), true); } // Routine Description: // - CUF - Handles cursor forward movement by given distance // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorForward(const VTInt distance) +void AdaptDispatch::CursorForward(const VTInt distance) { - return _CursorMovePosition(Offset::Unchanged(), Offset::Forward(distance), true); + _CursorMovePosition(Offset::Unchanged(), Offset::Forward(distance), true); } // Routine Description: // - CUB - Handles cursor backward movement by given distance // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorBackward(const VTInt distance) +void AdaptDispatch::CursorBackward(const VTInt distance) { - return _CursorMovePosition(Offset::Unchanged(), Offset::Backward(distance), true); + _CursorMovePosition(Offset::Unchanged(), Offset::Backward(distance), true); } // Routine Description: @@ -273,11 +265,9 @@ bool AdaptDispatch::CursorBackward(const VTInt distance) // - Moves to the beginning X/Column position of the line. // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorNextLine(const VTInt distance) +void AdaptDispatch::CursorNextLine(const VTInt distance) { - return _CursorMovePosition(Offset::Forward(distance), Offset::Absolute(1), true); + _CursorMovePosition(Offset::Forward(distance), Offset::Absolute(1), true); } // Routine Description: @@ -285,11 +275,9 @@ bool AdaptDispatch::CursorNextLine(const VTInt distance) // - Moves to the beginning X/Column position of the line. // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::CursorPrevLine(const VTInt distance) +void AdaptDispatch::CursorPrevLine(const VTInt distance) { - return _CursorMovePosition(Offset::Backward(distance), Offset::Absolute(1), true); + _CursorMovePosition(Offset::Backward(distance), Offset::Absolute(1), true); } // Routine Description: @@ -350,9 +338,7 @@ std::pair AdaptDispatch::_GetHorizontalMargins(const til::CoordType pa // - rowOffset - The row to move to // - colOffset - The column to move to // - clampInMargins - Should the position be clamped within the scrolling margins -// Return Value: -// - True. -bool AdaptDispatch::_CursorMovePosition(const Offset rowOffset, const Offset colOffset, const bool clampInMargins) +void AdaptDispatch::_CursorMovePosition(const Offset rowOffset, const Offset colOffset, const bool clampInMargins) { // First retrieve some information about the buffer const auto page = _pages.ActivePage(); @@ -428,8 +414,6 @@ bool AdaptDispatch::_CursorMovePosition(const Offset rowOffset, const Offset col // Finally, attempt to set the adjusted cursor position back into the console. cursor.SetPosition(page.Buffer().ClampPositionWithinLine({ col, row })); _ApplyCursorMovementFlags(cursor); - - return true; } // Routine Description: @@ -453,22 +437,18 @@ void AdaptDispatch::_ApplyCursorMovementFlags(Cursor& cursor) noexcept // - CHA - Moves the cursor to an exact X/Column position on the current line. // Arguments: // - column - Specific X/Column position to move to -// Return Value: -// - True. -bool AdaptDispatch::CursorHorizontalPositionAbsolute(const VTInt column) +void AdaptDispatch::CursorHorizontalPositionAbsolute(const VTInt column) { - return _CursorMovePosition(Offset::Unchanged(), Offset::Absolute(column), false); + _CursorMovePosition(Offset::Unchanged(), Offset::Absolute(column), false); } // Routine Description: // - VPA - Moves the cursor to an exact Y/row position on the current column. // Arguments: // - line - Specific Y/Row position to move to -// Return Value: -// - True. -bool AdaptDispatch::VerticalLinePositionAbsolute(const VTInt line) +void AdaptDispatch::VerticalLinePositionAbsolute(const VTInt line) { - return _CursorMovePosition(Offset::Absolute(line), Offset::Unchanged(), false); + _CursorMovePosition(Offset::Absolute(line), Offset::Unchanged(), false); } // Routine Description: @@ -476,11 +456,9 @@ bool AdaptDispatch::VerticalLinePositionAbsolute(const VTInt line) // - Unlike CUF, this is not constrained by margin settings. // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::HorizontalPositionRelative(const VTInt distance) +void AdaptDispatch::HorizontalPositionRelative(const VTInt distance) { - return _CursorMovePosition(Offset::Unchanged(), Offset::Forward(distance), false); + _CursorMovePosition(Offset::Unchanged(), Offset::Forward(distance), false); } // Routine Description: @@ -488,11 +466,9 @@ bool AdaptDispatch::HorizontalPositionRelative(const VTInt distance) // - Unlike CUD, this is not constrained by margin settings. // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::VerticalPositionRelative(const VTInt distance) +void AdaptDispatch::VerticalPositionRelative(const VTInt distance) { - return _CursorMovePosition(Offset::Forward(distance), Offset::Unchanged(), false); + _CursorMovePosition(Offset::Forward(distance), Offset::Unchanged(), false); } // Routine Description: @@ -500,11 +476,9 @@ bool AdaptDispatch::VerticalPositionRelative(const VTInt distance) // Arguments: // - line - Specific Y/Row/Line position to move to // - column - Specific X/Column position to move to -// Return Value: -// - True. -bool AdaptDispatch::CursorPosition(const VTInt line, const VTInt column) +void AdaptDispatch::CursorPosition(const VTInt line, const VTInt column) { - return _CursorMovePosition(Offset::Absolute(line), Offset::Absolute(column), false); + _CursorMovePosition(Offset::Absolute(line), Offset::Absolute(column), false); } // Routine Description: @@ -513,9 +487,7 @@ bool AdaptDispatch::CursorPosition(const VTInt line, const VTInt column) // active character set. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::CursorSaveState() +void AdaptDispatch::CursorSaveState() { // First retrieve some information about the buffer const auto page = _pages.ActivePage(); @@ -541,8 +513,6 @@ bool AdaptDispatch::CursorSaveState() savedCursorState.IsOriginModeRelative = _modes.test(Mode::Origin); savedCursorState.Attributes = page.Attributes(); savedCursorState.TermOutput = _termOutput; - - return true; } // Routine Description: @@ -551,9 +521,7 @@ bool AdaptDispatch::CursorSaveState() // rendition, and active character set. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::CursorRestoreState() +void AdaptDispatch::CursorRestoreState() { auto& savedCursorState = _savedCursorState.at(_usingAltBuffer); @@ -578,8 +546,6 @@ bool AdaptDispatch::CursorRestoreState() // Restore designated character sets. _termOutput.RestoreFrom(savedCursorState.TermOutput); - - return true; } // Routine Description: @@ -740,12 +706,9 @@ void AdaptDispatch::_InsertDeleteCharacterHelper(const VTInt delta) // - Each inserted character will push all text in the row to the right. // Arguments: // - count - The number of characters to insert -// Return Value: -// - True. -bool AdaptDispatch::InsertCharacter(const VTInt count) +void AdaptDispatch::InsertCharacter(const VTInt count) { _InsertDeleteCharacterHelper(count); - return true; } // Routine Description: @@ -753,12 +716,9 @@ bool AdaptDispatch::InsertCharacter(const VTInt count) // be inserted from the right edge of the current line. // Arguments: // - count - The number of characters to delete -// Return Value: -// - True. -bool AdaptDispatch::DeleteCharacter(const VTInt count) +void AdaptDispatch::DeleteCharacter(const VTInt count) { _InsertDeleteCharacterHelper(-count); - return true; } // Routine Description: @@ -783,9 +743,7 @@ void AdaptDispatch::_FillRect(const Page& page, const til::rect& fillRect, const // receive the currently selected attributes. // Arguments: // - numChars - The number of characters to erase. -// Return Value: -// - True. -bool AdaptDispatch::EraseCharacters(const VTInt numChars) +void AdaptDispatch::EraseCharacters(const VTInt numChars) { const auto page = _pages.ActivePage(); const auto row = page.Cursor().GetPosition().y; @@ -797,8 +755,6 @@ bool AdaptDispatch::EraseCharacters(const VTInt numChars) const auto eraseAttributes = _GetEraseAttributes(page); _FillRect(page, { startCol, row, endCol, row + 1 }, whitespace, eraseAttributes); - - return true; } // Routine Description: @@ -809,11 +765,12 @@ bool AdaptDispatch::EraseCharacters(const VTInt numChars) // From cursor to end (bottom-right corner) // The entire page // The scrollback (outside the page area) -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::EraseInDisplay(const DispatchTypes::EraseType eraseType) +void AdaptDispatch::EraseInDisplay(const DispatchTypes::EraseType eraseType) { - RETURN_BOOL_IF_FALSE(eraseType <= DispatchTypes::EraseType::Scrollback); + if (eraseType > DispatchTypes::EraseType::Scrollback) + { + return; + } // First things first. If this is a "Scrollback" clear, then just do that. // Scrollback clears erase everything in the "scrollback" of a *nix terminal @@ -860,17 +817,13 @@ bool AdaptDispatch::EraseInDisplay(const DispatchTypes::EraseType eraseType) _FillRect(page, { col, row, pageWidth, row + 1 }, whitespace, eraseAttributes); _FillRect(page, { 0, row + 1, pageWidth, page.Bottom() }, whitespace, eraseAttributes); } - - return true; } // Routine Description: // - EL - Erases the line that the cursor is currently on. // Arguments: // - eraseType - Determines whether to erase: From beginning (left edge) to the cursor, from cursor to end (right edge), or the entire line. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::EraseInLine(const DispatchTypes::EraseType eraseType) +void AdaptDispatch::EraseInLine(const DispatchTypes::EraseType eraseType) { const auto page = _pages.ActivePage(); const auto& textBuffer = page.Buffer(); @@ -885,15 +838,15 @@ bool AdaptDispatch::EraseInLine(const DispatchTypes::EraseType eraseType) { case DispatchTypes::EraseType::FromBeginning: _FillRect(page, { 0, row, col + 1, row + 1 }, whitespace, eraseAttributes); - return true; + break; case DispatchTypes::EraseType::ToEnd: _FillRect(page, { col, row, textBuffer.GetLineWidth(row), row + 1 }, whitespace, eraseAttributes); - return true; + break; case DispatchTypes::EraseType::All: _FillRect(page, { 0, row, textBuffer.GetLineWidth(row), row + 1 }, whitespace, eraseAttributes); - return true; + break; default: - return false; + break; } } @@ -935,9 +888,7 @@ void AdaptDispatch::_SelectiveEraseRect(const Page& page, const til::rect& erase // From beginning (top-left corner) to the cursor // From cursor to end (bottom-right corner) // The entire page area -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) +void AdaptDispatch::SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) { const auto page = _pages.ActivePage(); const auto pageWidth = page.Width(); @@ -952,16 +903,16 @@ bool AdaptDispatch::SelectiveEraseInDisplay(const DispatchTypes::EraseType erase case DispatchTypes::EraseType::FromBeginning: _SelectiveEraseRect(page, { 0, page.Top(), pageWidth, row }); _SelectiveEraseRect(page, { 0, row, col + 1, row + 1 }); - return true; + break; case DispatchTypes::EraseType::ToEnd: _SelectiveEraseRect(page, { col, row, pageWidth, row + 1 }); _SelectiveEraseRect(page, { 0, row + 1, pageWidth, page.Bottom() }); - return true; + break; case DispatchTypes::EraseType::All: _SelectiveEraseRect(page, { 0, page.Top(), pageWidth, page.Bottom() }); - return true; + break; default: - return false; + break; } } @@ -972,9 +923,7 @@ bool AdaptDispatch::SelectiveEraseInDisplay(const DispatchTypes::EraseType erase // From beginning (left edge) to the cursor // From cursor to end (right edge) // The entire line. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) +void AdaptDispatch::SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) { const auto page = _pages.ActivePage(); const auto& textBuffer = page.Buffer(); @@ -988,15 +937,15 @@ bool AdaptDispatch::SelectiveEraseInLine(const DispatchTypes::EraseType eraseTyp { case DispatchTypes::EraseType::FromBeginning: _SelectiveEraseRect(page, { 0, row, col + 1, row + 1 }); - return true; + break; case DispatchTypes::EraseType::ToEnd: _SelectiveEraseRect(page, { col, row, textBuffer.GetLineWidth(row), row + 1 }); - return true; + break; case DispatchTypes::EraseType::All: _SelectiveEraseRect(page, { 0, row, textBuffer.GetLineWidth(row), row + 1 }); - return true; + break; default: - return false; + break; } } @@ -1132,9 +1081,7 @@ til::rect AdaptDispatch::_CalculateRectArea(const Page& page, const VTInt top, c // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). // - attrs - The rendition attributes that will be applied to the area. -// Return Value: -// - True. -bool AdaptDispatch::ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) +void AdaptDispatch::ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) { auto changeOps = ChangeOps{}; @@ -1171,8 +1118,6 @@ bool AdaptDispatch::ChangeAttributesRectangularArea(const VTInt top, const VTInt changeOps.underlineColor = underlineColorChanged ? std::optional{ underlineColor } : std::nullopt; _ChangeRectOrStreamAttributes({ left, top, right, bottom }, changeOps); - - return true; } // Routine Description: @@ -1186,9 +1131,7 @@ bool AdaptDispatch::ChangeAttributesRectangularArea(const VTInt top, const VTInt // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). // - attrs - The rendition attributes that will be applied to the area. -// Return Value: -// - True. -bool AdaptDispatch::ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) +void AdaptDispatch::ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) { // In order to create a mask of the attributes that we want to reverse, we // need to go through the options one by one, applying each of them to an @@ -1226,8 +1169,6 @@ bool AdaptDispatch::ReverseAttributesRectangularArea(const VTInt top, const VTIn { _ChangeRectOrStreamAttributes({ left, top, right, bottom }, { .xorAttrMask = reverseMask }); } - - return true; } // Routine Description: @@ -1241,9 +1182,7 @@ bool AdaptDispatch::ReverseAttributesRectangularArea(const VTInt top, const VTIn // - dstTop - The first row of the destination. // - dstLeft - The first column of the destination. // - dstPage - The destination page number. -// Return Value: -// - True. -bool AdaptDispatch::CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) +void AdaptDispatch::CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) { const auto src = _pages.Get(page); const auto dst = _pages.Get(dstPage); @@ -1282,8 +1221,6 @@ bool AdaptDispatch::CopyRectangularArea(const VTInt top, const VTInt left, const ImageSlice::CopyBlock(src.Buffer(), srcView.ToExclusive(), dst.Buffer(), dstView.ToExclusive()); _api.NotifyAccessibilityChange(dstRect); } - - return true; } // Routine Description: @@ -1295,9 +1232,7 @@ bool AdaptDispatch::CopyRectangularArea(const VTInt top, const VTInt left, const // - left - The first column of the area. // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). -// Return Value: -// - True. -bool AdaptDispatch::FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) +void AdaptDispatch::FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) { const auto page = _pages.ActivePage(); const auto fillRect = _CalculateRectArea(page, top, left, bottom, right); @@ -1315,8 +1250,6 @@ bool AdaptDispatch::FillRectangularArea(const VTParameter ch, const VTInt top, c const auto& fillAttributes = page.Attributes(); _FillRect(page, fillRect, { &fillChar, 1 }, fillAttributes); } - - return true; } // Routine Description: @@ -1327,15 +1260,12 @@ bool AdaptDispatch::FillRectangularArea(const VTParameter ch, const VTInt top, c // - left - The first column of the area. // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). -// Return Value: -// - True. -bool AdaptDispatch::EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) +void AdaptDispatch::EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) { const auto page = _pages.ActivePage(); const auto eraseRect = _CalculateRectArea(page, top, left, bottom, right); const auto eraseAttributes = _GetEraseAttributes(page); _FillRect(page, eraseRect, whitespace, eraseAttributes); - return true; } // Routine Description: @@ -1346,14 +1276,11 @@ bool AdaptDispatch::EraseRectangularArea(const VTInt top, const VTInt left, cons // - left - The first column of the area. // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). -// Return Value: -// - True. -bool AdaptDispatch::SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) +void AdaptDispatch::SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) { const auto page = _pages.ActivePage(); const auto eraseRect = _CalculateRectArea(page, top, left, bottom, right); _SelectiveEraseRect(page, eraseRect); - return true; } // Routine Description: @@ -1361,21 +1288,19 @@ bool AdaptDispatch::SelectiveEraseRectangularArea(const VTInt top, const VTInt l // by the DECCARA and DECRARA attribute operations. // Arguments: // - changeExtent - Whether the character range is a stream or a rectangle. -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) noexcept +void AdaptDispatch::SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) noexcept { switch (changeExtent) { case DispatchTypes::ChangeExtent::Default: case DispatchTypes::ChangeExtent::Stream: _modes.reset(Mode::RectangularChangeExtent); - return true; + break; case DispatchTypes::ChangeExtent::Rectangle: _modes.set(Mode::RectangularChangeExtent); - return true; + break; default: - return false; + break; } } @@ -1389,9 +1314,7 @@ bool AdaptDispatch::SelectAttributeChangeExtent(const DispatchTypes::ChangeExten // - left - The first column of the area. // - bottom - The last row of the area (inclusive). // - right - The last column of the area (inclusive). -// Return value: -// - True. -bool AdaptDispatch::RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) +void AdaptDispatch::RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) { uint16_t checksum = 0; // If this feature is not enabled, we'll just report a zero checksum. @@ -1456,7 +1379,6 @@ bool AdaptDispatch::RequestChecksumRectangularArea(const VTInt id, const VTInt p } const auto response = wil::str_printf(L"\033P%d!~%04X\033\\", id, checksum); _api.ReturnResponse(response); - return true; } // Routine Description: @@ -1464,9 +1386,7 @@ bool AdaptDispatch::RequestChecksumRectangularArea(const VTInt id, const VTInt p // Arguments: // - rendition - Determines whether the line will be rendered as single width, double // width, or as one half of a double height line. -// Return Value: -// - True. -bool AdaptDispatch::SetLineRendition(const LineRendition rendition) +void AdaptDispatch::SetLineRendition(const LineRendition rendition) { // The line rendition can't be changed if left/right margins are allowed. if (!_modes.test(Mode::AllowDECSLRM)) @@ -1480,7 +1400,6 @@ bool AdaptDispatch::SetLineRendition(const LineRendition rendition) // line rendition controls were executed. page.Cursor().ResetDelayEOLWrap(); } - return true; } // Routine Description: @@ -1488,9 +1407,7 @@ bool AdaptDispatch::SetLineRendition(const LineRendition rendition) // Arguments: // - statusType - status type indicating what property we should report back // - id - a numeric label used to identify the request in DECCKSR reports -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) +void AdaptDispatch::DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) { constexpr auto GoodCondition = L"0"; constexpr auto PrinterNotConnected = L"?13"; @@ -1505,42 +1422,42 @@ bool AdaptDispatch::DeviceStatusReport(const DispatchTypes::StatusType statusTyp { case DispatchTypes::StatusType::OperatingStatus: _DeviceStatusReport(GoodCondition); - return true; + break; case DispatchTypes::StatusType::CursorPositionReport: _CursorPositionReport(false); - return true; + break; case DispatchTypes::StatusType::ExtendedCursorPositionReport: _CursorPositionReport(true); - return true; + break; case DispatchTypes::StatusType::PrinterStatus: _DeviceStatusReport(PrinterNotConnected); - return true; + break; case DispatchTypes::StatusType::UserDefinedKeys: _DeviceStatusReport(UserDefinedKeysNotSupported); - return true; + break; case DispatchTypes::StatusType::KeyboardStatus: _DeviceStatusReport(UnknownPcKeyboard); - return true; + break; case DispatchTypes::StatusType::LocatorStatus: _DeviceStatusReport(LocatorNotConnected); - return true; + break; case DispatchTypes::StatusType::LocatorIdentity: _DeviceStatusReport(UnknownLocatorDevice); - return true; + break; case DispatchTypes::StatusType::MacroSpaceReport: _MacroSpaceReport(); - return true; + break; case DispatchTypes::StatusType::MemoryChecksum: _MacroChecksumReport(id); - return true; + break; case DispatchTypes::StatusType::DataIntegrity: _DeviceStatusReport(TerminalReady); - return true; + break; case DispatchTypes::StatusType::MultipleSessionStatus: _DeviceStatusReport(MultipleSessionsNotSupported); - return true; + break; default: - return false; + break; } } @@ -1549,9 +1466,7 @@ bool AdaptDispatch::DeviceStatusReport(const DispatchTypes::StatusType statusTyp // supports, and the set of implemented extensions. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::DeviceAttributes() +void AdaptDispatch::DeviceAttributes() { // This first parameter of the response is 61, representing a conformance // level of 1. The subsequent parameters identify the supported feature @@ -1570,7 +1485,6 @@ bool AdaptDispatch::DeviceAttributes() // 42 = ISO Latin-2 character set _api.ReturnResponse(L"\x1b[?61;4;6;7;14;21;22;23;24;28;32;42c"); - return true; } // Routine Description: @@ -1580,12 +1494,9 @@ bool AdaptDispatch::DeviceAttributes() // is set to 1 (indicating a PC Keyboard). // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::SecondaryDeviceAttributes() +void AdaptDispatch::SecondaryDeviceAttributes() { _api.ReturnResponse(L"\x1b[>0;10;1c"); - return true; } // Routine Description: @@ -1593,12 +1504,9 @@ bool AdaptDispatch::SecondaryDeviceAttributes() // typically return a hard-coded value, the most common being all zeros. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::TertiaryDeviceAttributes() +void AdaptDispatch::TertiaryDeviceAttributes() { _api.ReturnResponse(L"\x1bP!|00000000\x1b\\"); - return true; } // Routine Description: @@ -1607,12 +1515,9 @@ bool AdaptDispatch::TertiaryDeviceAttributes() // But for a terminal that is emulating a VT52, the sequence should be ESC / Z. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::Vt52DeviceAttributes() +void AdaptDispatch::Vt52DeviceAttributes() { _api.ReturnResponse(L"\x1b/Z"); - return true; } // Routine Description: @@ -1622,9 +1527,7 @@ bool AdaptDispatch::Vt52DeviceAttributes() // Arguments: // - permission - This would originally have determined whether the terminal // was allowed to send unsolicited reports or not. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) +void AdaptDispatch::RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) { // We don't care whether unsolicited reports are allowed or not, but the // requested permission does determine the value of the first response @@ -1642,12 +1545,12 @@ bool AdaptDispatch::RequestTerminalParameters(const DispatchTypes::ReportingPerm { case DispatchTypes::ReportingPermission::Unsolicited: _api.ReturnResponse(L"\x1b[2;1;1;128;128;1;0x"); - return true; + break; case DispatchTypes::ReportingPermission::Solicited: _api.ReturnResponse(L"\x1b[3;1;1;128;128;1;0x"); - return true; + break; default: - return false; + break; } } @@ -1752,24 +1655,18 @@ void AdaptDispatch::_ScrollMovement(const VTInt delta) // - SU - Pans the window DOWN by given distance (distance new lines appear at the bottom of the screen) // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::ScrollUp(const VTInt uiDistance) +void AdaptDispatch::ScrollUp(const VTInt uiDistance) { _ScrollMovement(-uiDistance); - return true; } // Routine Description: // - SD - Pans the window UP by given distance (distance new lines appear at the top of the screen) // Arguments: // - distance - Distance to move -// Return Value: -// - True. -bool AdaptDispatch::ScrollDown(const VTInt uiDistance) +void AdaptDispatch::ScrollDown(const VTInt uiDistance) { _ScrollMovement(uiDistance); - return true; } // Routine Description: @@ -1777,12 +1674,10 @@ bool AdaptDispatch::ScrollDown(const VTInt uiDistance) // cursor to home. // Arguments: // - pageCount - Number of pages to move -// Return Value: -// - True. -bool AdaptDispatch::NextPage(const VTInt pageCount) +void AdaptDispatch::NextPage(const VTInt pageCount) { PagePositionRelative(pageCount); - return CursorPosition(1, 1); + CursorPosition(1, 1); } // Routine Description: @@ -1790,12 +1685,10 @@ bool AdaptDispatch::NextPage(const VTInt pageCount) // cursor to home. // Arguments: // - pageCount - Number of pages to move -// Return Value: -// - True. -bool AdaptDispatch::PrecedingPage(const VTInt pageCount) +void AdaptDispatch::PrecedingPage(const VTInt pageCount) { PagePositionBack(pageCount); - return CursorPosition(1, 1); + CursorPosition(1, 1); } // Routine Description: @@ -1803,12 +1696,9 @@ bool AdaptDispatch::PrecedingPage(const VTInt pageCount) // altering the cursor coordinates. // Arguments: // - page - Destination page -// Return Value: -// - True. -bool AdaptDispatch::PagePositionAbsolute(const VTInt page) +void AdaptDispatch::PagePositionAbsolute(const VTInt page) { _pages.MoveTo(page, _modes.test(Mode::PageCursorCoupling)); - return true; } // Routine Description: @@ -1816,12 +1706,9 @@ bool AdaptDispatch::PagePositionAbsolute(const VTInt page) // the cursor coordinates. // Arguments: // - pageCount - Number of pages to move -// Return Value: -// - True. -bool AdaptDispatch::PagePositionRelative(const VTInt pageCount) +void AdaptDispatch::PagePositionRelative(const VTInt pageCount) { _pages.MoveRelative(pageCount, _modes.test(Mode::PageCursorCoupling)); - return true; } // Routine Description: @@ -1829,21 +1716,16 @@ bool AdaptDispatch::PagePositionRelative(const VTInt pageCount) // the cursor coordinates. // Arguments: // - pageCount - Number of pages to move -// Return Value: -// - True. -bool AdaptDispatch::PagePositionBack(const VTInt pageCount) +void AdaptDispatch::PagePositionBack(const VTInt pageCount) { _pages.MoveRelative(-pageCount, _modes.test(Mode::PageCursorCoupling)); - return true; } // Routine Description: // - DECRQDE - Requests the area of page memory that is currently visible. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::RequestDisplayedExtent() +void AdaptDispatch::RequestDisplayedExtent() { const auto page = _pages.VisiblePage(); const auto width = page.Viewport().width(); @@ -1851,7 +1733,6 @@ bool AdaptDispatch::RequestDisplayedExtent() const auto left = page.XPanOffset() + 1; const auto top = page.YPanOffset() + 1; _api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033[{};{};{};{};{}\"w"), height, width, left, top, page.Number())); - return true; } // Routine Description: @@ -1909,15 +1790,13 @@ void AdaptDispatch::_SetAlternateScreenBufferMode(const bool enable) // Arguments: // - param - mode parameter to set/reset // - enable - True for set, false for unset. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, const bool enable) +void AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, const bool enable) { switch (param) { case DispatchTypes::ModeParams::IRM_InsertReplaceMode: _modes.set(Mode::InsertReplace, enable); - return true; + break; case DispatchTypes::ModeParams::LNM_LineFeedNewLineMode: // VT apps expect that the system and input modes are the same, so if // they become out of sync, we just act as if LNM mode isn't supported. @@ -1926,27 +1805,27 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con _api.SetSystemMode(ITerminalApi::Mode::LineFeed, enable); _terminalInput.SetInputMode(TerminalInput::Mode::LineFeed, enable); } - return true; + break; case DispatchTypes::ModeParams::DECCKM_CursorKeysMode: _terminalInput.SetInputMode(TerminalInput::Mode::CursorKey, enable); - return true; + break; case DispatchTypes::ModeParams::DECANM_AnsiMode: return SetAnsiMode(enable); case DispatchTypes::ModeParams::DECCOLM_SetNumberOfColumns: _SetColumnMode(enable); - return true; + break; case DispatchTypes::ModeParams::DECSCNM_ScreenMode: _renderSettings.SetRenderMode(RenderSettings::Mode::ScreenReversed, enable); if (_renderer) { _renderer->TriggerRedrawAll(); } - return true; + break; case DispatchTypes::ModeParams::DECOM_OriginMode: _modes.set(Mode::Origin, enable); // The cursor is also moved to the new home position when the origin mode is set or reset. CursorPosition(1, 1); - return true; + break; case DispatchTypes::ModeParams::DECAWM_AutoWrapMode: _api.SetSystemMode(ITerminalApi::Mode::AutoWrap, enable); // Resetting DECAWM should also reset the delayed wrap flag. @@ -1954,32 +1833,32 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con { _pages.ActivePage().Cursor().ResetDelayEOLWrap(); } - return true; + break; case DispatchTypes::ModeParams::DECARM_AutoRepeatMode: _terminalInput.SetInputMode(TerminalInput::Mode::AutoRepeat, enable); - return true; + break; case DispatchTypes::ModeParams::ATT610_StartCursorBlink: _pages.ActivePage().Cursor().SetBlinkingAllowed(enable); - return true; + break; case DispatchTypes::ModeParams::DECTCEM_TextCursorEnableMode: _pages.ActivePage().Cursor().SetIsVisible(enable); - return true; + break; case DispatchTypes::ModeParams::XTERM_EnableDECCOLMSupport: _modes.set(Mode::AllowDECCOLM, enable); - return true; + break; case DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode: _modes.set(Mode::PageCursorCoupling, enable); if (enable) { _pages.MakeActivePageVisible(); } - return true; + break; case DispatchTypes::ModeParams::DECNKM_NumericKeypadMode: _terminalInput.SetInputMode(TerminalInput::Mode::Keypad, enable); - return true; + break; case DispatchTypes::ModeParams::DECBKM_BackarrowKeyMode: _terminalInput.SetInputMode(TerminalInput::Mode::BackarrowKey, enable); - return true; + break; case DispatchTypes::ModeParams::DECLRMM_LeftRightMarginMode: _modes.set(Mode::AllowDECSLRM, enable); _DoSetLeftRightScrollingMargins(0, 0); @@ -1989,32 +1868,32 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con const auto page = _pages.ActivePage(); page.Buffer().ResetLineRenditionRange(page.Top(), page.Bottom()); } - return true; + break; case DispatchTypes::ModeParams::DECSDM_SixelDisplayMode: _modes.set(Mode::SixelDisplay, enable); if (_sixelParser) { _sixelParser->SetDisplayMode(enable); } - return true; + break; case DispatchTypes::ModeParams::DECECM_EraseColorMode: _modes.set(Mode::EraseColor, enable); - return true; + break; case DispatchTypes::ModeParams::VT200_MOUSE_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::DefaultMouseTracking, enable); - return true; + break; case DispatchTypes::ModeParams::BUTTON_EVENT_MOUSE_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::ButtonEventMouseTracking, enable); - return true; + break; case DispatchTypes::ModeParams::ANY_EVENT_MOUSE_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::AnyEventMouseTracking, enable); - return true; + break; case DispatchTypes::ModeParams::UTF8_EXTENDED_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::Utf8MouseEncoding, enable); - return true; + break; case DispatchTypes::ModeParams::SGR_EXTENDED_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::SgrMouseEncoding, enable); - return true; + break; case DispatchTypes::ModeParams::FOCUS_EVENT_MODE: _terminalInput.SetInputMode(TerminalInput::Mode::FocusEvent, enable); // ConPTY always wants to know about focus events, so let it know that it needs to re-enable this mode. @@ -2022,18 +1901,18 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con { _api.GetStateMachine().InjectSequence(InjectionType::DECSET_FOCUS); } - return true; + break; case DispatchTypes::ModeParams::ALTERNATE_SCROLL: _terminalInput.SetInputMode(TerminalInput::Mode::AlternateScroll, enable); - return true; + break; case DispatchTypes::ModeParams::ASB_AlternateScreenBuffer: _SetAlternateScreenBufferMode(enable); - return true; + break; case DispatchTypes::ModeParams::XTERM_BracketedPasteMode: _api.SetSystemMode(ITerminalApi::Mode::BracketedPaste, enable); - return true; + break; case DispatchTypes::ModeParams::GCM_GraphemeClusterMode: - return true; + break; case DispatchTypes::ModeParams::W32IM_Win32InputMode: _terminalInput.SetInputMode(TerminalInput::Mode::Win32, enable); // ConPTY requests the Win32InputMode on startup and disables it on shutdown. When nesting ConPTY inside @@ -2046,10 +1925,9 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con { _api.GetStateMachine().InjectSequence(InjectionType::W32IM); } - return true; + break; default: - // If no functions to call, overall dispatch was a failure. - return false; + break; } } @@ -2057,22 +1935,18 @@ bool AdaptDispatch::_ModeParamsHelper(const DispatchTypes::ModeParams param, con // - SM/DECSET - Enables the given mode parameter (both ANSI and private). // Arguments: // - param - mode parameter to set -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SetMode(const DispatchTypes::ModeParams param) +void AdaptDispatch::SetMode(const DispatchTypes::ModeParams param) { - return _ModeParamsHelper(param, true); + _ModeParamsHelper(param, true); } // Routine Description: // - RM/DECRST - Disables the given mode parameter (both ANSI and private). // Arguments: // - param - mode parameter to reset -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::ResetMode(const DispatchTypes::ModeParams param) +void AdaptDispatch::ResetMode(const DispatchTypes::ModeParams param) { - return _ModeParamsHelper(param, false); + _ModeParamsHelper(param, false); } // Routine Description: @@ -2080,9 +1954,7 @@ bool AdaptDispatch::ResetMode(const DispatchTypes::ModeParams param) // is reported back with a DECRPM escape sequence. // Arguments: // - param - the mode number being queried -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::RequestMode(const DispatchTypes::ModeParams param) +void AdaptDispatch::RequestMode(const DispatchTypes::ModeParams param) { static constexpr auto mapTemp = [](const bool b) { return b ? DispatchTypes::DECRPM_Enabled : DispatchTypes::DECRPM_Disabled; }; static constexpr auto mapPerm = [](const bool b) { return b ? DispatchTypes::DECRPM_PermanentlyEnabled : DispatchTypes::DECRPM_PermanentlyDisabled; }; @@ -2197,18 +2069,14 @@ bool AdaptDispatch::RequestMode(const DispatchTypes::ModeParams param) } _api.ReturnResponse(fmt::format(FMT_COMPILE(L"\x1b[{}{};{}$y"), prefix, mode, state)); - return true; } // - DECKPAM, DECKPNM - Sets the keypad input mode to either Application mode or Numeric mode (true, false respectively) // Arguments: // - applicationMode - set to true to enable Application Mode Input, false for Numeric Mode Input. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SetKeypadMode(const bool fApplicationMode) noexcept +void AdaptDispatch::SetKeypadMode(const bool fApplicationMode) noexcept { _terminalInput.SetInputMode(TerminalInput::Mode::Keypad, fApplicationMode); - return true; } // Routine Description: @@ -2244,12 +2112,9 @@ void AdaptDispatch::_InsertDeleteLineHelper(const VTInt delta) // Lines scrolled off the page are lost. IL has no effect outside the page margins. // Arguments: // - distance - number of lines to insert -// Return Value: -// - True. -bool AdaptDispatch::InsertLine(const VTInt distance) +void AdaptDispatch::InsertLine(const VTInt distance) { _InsertDeleteLineHelper(distance); - return true; } // Routine Description: @@ -2262,12 +2127,9 @@ bool AdaptDispatch::InsertLine(const VTInt distance) // lines. DL has no effect outside the scrolling margins. // Arguments: // - distance - number of lines to delete -// Return Value: -// - True. -bool AdaptDispatch::DeleteLine(const VTInt distance) +void AdaptDispatch::DeleteLine(const VTInt distance) { _InsertDeleteLineHelper(-distance); - return true; } // Routine Description: @@ -2297,12 +2159,9 @@ void AdaptDispatch::_InsertDeleteColumnHelper(const VTInt delta) // scrolling region, starting at the column that has the cursor. // Arguments: // - distance - number of columns to insert -// Return Value: -// - True. -bool AdaptDispatch::InsertColumn(const VTInt distance) +void AdaptDispatch::InsertColumn(const VTInt distance) { _InsertDeleteColumnHelper(distance); - return true; } // Routine Description: @@ -2310,20 +2169,15 @@ bool AdaptDispatch::InsertColumn(const VTInt distance) // region, starting with the column that has the cursor. // Arguments: // - distance - number of columns to delete -// Return Value: -// - True. -bool AdaptDispatch::DeleteColumn(const VTInt distance) +void AdaptDispatch::DeleteColumn(const VTInt distance) { _InsertDeleteColumnHelper(-distance); - return true; } // - DECANM - Sets the terminal emulation mode to either ANSI-compatible or VT52. // Arguments: // - ansiMode - set to true to enable the ANSI mode, false for VT52 mode. -// Return Value: -// - True. -bool AdaptDispatch::SetAnsiMode(const bool ansiMode) +void AdaptDispatch::SetAnsiMode(const bool ansiMode) { // When an attempt is made to update the mode, the designated character sets // need to be reset to defaults, even if the mode doesn't actually change. @@ -2334,7 +2188,6 @@ bool AdaptDispatch::SetAnsiMode(const bool ansiMode) // While input mode changes are often forwarded over conpty, we never want // to do that for the DECANM mode. - return true; } // Routine Description: @@ -2410,13 +2263,10 @@ void AdaptDispatch::_DoSetTopBottomScrollingMargins(const VTInt topMargin, // Arguments: // - topMargin - the line number for the top margin. // - bottomMargin - the line number for the bottom margin. -// Return Value: -// - True. -bool AdaptDispatch::SetTopBottomScrollingMargins(const VTInt topMargin, +void AdaptDispatch::SetTopBottomScrollingMargins(const VTInt topMargin, const VTInt bottomMargin) { _DoSetTopBottomScrollingMargins(topMargin, bottomMargin, true); - return true; } // Routine Description: @@ -2485,9 +2335,7 @@ void AdaptDispatch::_DoSetLeftRightScrollingMargins(const VTInt leftMargin, // Arguments: // - leftMargin - the column number for the left margin. // - rightMargin - the column number for the right margin. -// Return Value: -// - True. -bool AdaptDispatch::SetLeftRightScrollingMargins(const VTInt leftMargin, +void AdaptDispatch::SetLeftRightScrollingMargins(const VTInt leftMargin, const VTInt rightMargin) { if (_modes.test(Mode::AllowDECSLRM)) @@ -2499,19 +2347,15 @@ bool AdaptDispatch::SetLeftRightScrollingMargins(const VTInt leftMargin, // When DECSLRM isn't allowed, `CSI s` is interpreted as ANSISYSSC. CursorSaveState(); } - return true; } // Routine Description: // - ENQ - Directs the terminal to send the answerback message. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::EnquireAnswerback() +void AdaptDispatch::EnquireAnswerback() { _api.ReturnAnswerback(); - return true; } // Routine Description: @@ -2519,12 +2363,9 @@ bool AdaptDispatch::EnquireAnswerback() // Causes the terminal to emit an audible tone of brief duration. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::WarningBell() +void AdaptDispatch::WarningBell() { _api.WarningBell(); - return true; } // Routine Description: @@ -2532,11 +2373,9 @@ bool AdaptDispatch::WarningBell() // Moves the cursor to the leftmost column. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::CarriageReturn() +void AdaptDispatch::CarriageReturn() { - return _CursorMovePosition(Offset::Unchanged(), Offset::Absolute(1), true); + _CursorMovePosition(Offset::Unchanged(), Offset::Absolute(1), true); } // Routine Description: @@ -2544,9 +2383,7 @@ bool AdaptDispatch::CarriageReturn() // Arguments: // - page - Target page on which the line feed is executed. // - withReturn - Set to true if a carriage return should be performed as well. -// - wrapForced - Set to true is the line feed was the result of the line wrapping. -// Return Value: -// - True if the viewport panned down. False if not. +// - wrapForced - Set to true is the line feed was the result of the line wrapping. if the viewport panned down. False if not. bool AdaptDispatch::_DoLineFeed(const Page& page, const bool withReturn, const bool wrapForced) { auto& textBuffer = page.Buffer(); @@ -2645,24 +2482,22 @@ bool AdaptDispatch::_DoLineFeed(const Page& page, const bool withReturn, const b // Moves the cursor down one line, and possibly also to the leftmost column. // Arguments: // - lineFeedType - Specify whether a carriage return should be performed as well. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::LineFeed(const DispatchTypes::LineFeedType lineFeedType) +void AdaptDispatch::LineFeed(const DispatchTypes::LineFeedType lineFeedType) { const auto page = _pages.ActivePage(); switch (lineFeedType) { case DispatchTypes::LineFeedType::DependsOnMode: _DoLineFeed(page, _api.GetSystemMode(ITerminalApi::Mode::LineFeed), false); - return true; + break; case DispatchTypes::LineFeedType::WithoutReturn: _DoLineFeed(page, false, false); - return true; + break; case DispatchTypes::LineFeedType::WithReturn: _DoLineFeed(page, true, false); - return true; + break; default: - return false; + break; } } @@ -2671,9 +2506,7 @@ bool AdaptDispatch::LineFeed(const DispatchTypes::LineFeedType lineFeedType) // Moves the cursor up one line, and tries to keep its position in the line // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::ReverseLineFeed() +void AdaptDispatch::ReverseLineFeed() { const auto page = _pages.ActivePage(); const auto& textBuffer = page.Buffer(); @@ -2694,7 +2527,6 @@ bool AdaptDispatch::ReverseLineFeed() cursor.SetPosition(textBuffer.ClampPositionWithinLine({ cursorPosition.x, cursorPosition.y - 1 })); _ApplyCursorMovementFlags(cursor); } - return true; } // Routine Description: @@ -2702,9 +2534,7 @@ bool AdaptDispatch::ReverseLineFeed() // horizontally if it reaches the left margin. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::BackIndex() +void AdaptDispatch::BackIndex() { const auto page = _pages.ActivePage(); auto& cursor = page.Cursor(); @@ -2723,7 +2553,6 @@ bool AdaptDispatch::BackIndex() cursor.SetXPosition(cursorPosition.x - 1); _ApplyCursorMovementFlags(cursor); } - return true; } // Routine Description: @@ -2731,9 +2560,7 @@ bool AdaptDispatch::BackIndex() // horizontally if it reaches the right margin. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::ForwardIndex() +void AdaptDispatch::ForwardIndex() { const auto page = _pages.ActivePage(); auto& cursor = page.Cursor(); @@ -2752,36 +2579,28 @@ bool AdaptDispatch::ForwardIndex() cursor.SetXPosition(cursorPosition.x + 1); _ApplyCursorMovementFlags(cursor); } - return true; } // Routine Description: // - OSC Set Window Title - Sets the title of the window // Arguments: // - title - The string to set the title to. -// Return Value: -// - True. -bool AdaptDispatch::SetWindowTitle(std::wstring_view title) +void AdaptDispatch::SetWindowTitle(std::wstring_view title) { _api.SetWindowTitle(title); - return true; } //Routine Description: // HTS - sets a VT tab stop in the cursor's current column. //Arguments: // - None -// Return value: -// - True. -bool AdaptDispatch::HorizontalTabSet() +void AdaptDispatch::HorizontalTabSet() { const auto page = _pages.ActivePage(); const auto column = page.Cursor().GetPosition().x; _InitTabStopsForWidth(page.Width()); _tabStopColumns.at(column) = true; - - return true; } //Routine Description: @@ -2791,9 +2610,7 @@ bool AdaptDispatch::HorizontalTabSet() // If it's already in the last column of the row, it will move it to the next line. //Arguments: // - numTabs - the number of tabs to perform -// Return value: -// - True. -bool AdaptDispatch::ForwardTab(const VTInt numTabs) +void AdaptDispatch::ForwardTab(const VTInt numTabs) { const auto page = _pages.ActivePage(); auto& cursor = page.Cursor(); @@ -2830,8 +2647,6 @@ bool AdaptDispatch::ForwardTab(const VTInt numTabs) { cursor.DelayEOLWrap(); } - - return true; } //Routine Description: @@ -2839,9 +2654,7 @@ bool AdaptDispatch::ForwardTab(const VTInt numTabs) // previous to its current location. It will not reverse line feed. //Arguments: // - numTabs - the number of tabs to perform -// Return value: -// - True. -bool AdaptDispatch::BackwardsTab(const VTInt numTabs) +void AdaptDispatch::BackwardsTab(const VTInt numTabs) { const auto page = _pages.ActivePage(); auto& cursor = page.Cursor(); @@ -2867,7 +2680,6 @@ bool AdaptDispatch::BackwardsTab(const VTInt numTabs) cursor.SetXPosition(column); _ApplyCursorMovementFlags(cursor); - return true; } //Routine Description: @@ -2876,20 +2688,18 @@ bool AdaptDispatch::BackwardsTab(const VTInt numTabs) // is one. ClearAllColumns (3) results in resetting all set tab stops. //Arguments: // - clearType - Whether to clear the current column, or all columns, defined in DispatchTypes::TabClearType -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::TabClear(const DispatchTypes::TabClearType clearType) +void AdaptDispatch::TabClear(const DispatchTypes::TabClearType clearType) { switch (clearType) { case DispatchTypes::TabClearType::ClearCurrentColumn: _ClearSingleTabStop(); - return true; + break; case DispatchTypes::TabClearType::ClearAllColumns: _ClearAllTabStops(); - return true; + break; default: - return false; + break; } } @@ -2927,18 +2737,14 @@ void AdaptDispatch::_ClearAllTabStops() noexcept // that the default positions should be reinitialized when needed. // Arguments: // - setType - only SetEvery8Columns is supported -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::TabSet(const VTParameter setType) noexcept +void AdaptDispatch::TabSet(const VTParameter setType) noexcept { constexpr auto SetEvery8Columns = DispatchTypes::TabSetType::SetEvery8Columns; if (setType.value_or(SetEvery8Columns) == SetEvery8Columns) { _tabStopColumns.clear(); _initDefaultTabStops = true; - return true; } - return false; } // Routine Description: @@ -2977,9 +2783,7 @@ void AdaptDispatch::_InitTabStopsForWidth(const VTInt width) // control codes are disabled, and only the GL area can be remapped. //Arguments: // - codingSystem - The coding system that will be selected. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::DesignateCodingSystem(const VTID codingSystem) +void AdaptDispatch::DesignateCodingSystem(const VTID codingSystem) { // If we haven't previously saved the initial code page, do so now. // This will be used to restore the code page in response to a reset. @@ -2994,14 +2798,14 @@ bool AdaptDispatch::DesignateCodingSystem(const VTID codingSystem) _api.SetConsoleOutputCP(28591); AcceptC1Controls(true); _termOutput.EnableGrTranslation(true); - return true; + break; case DispatchTypes::CodingSystem::UTF8: _api.SetConsoleOutputCP(CP_UTF8); AcceptC1Controls(false); _termOutput.EnableGrTranslation(false); - return true; + break; default: - return false; + break; } } @@ -3013,11 +2817,9 @@ bool AdaptDispatch::DesignateCodingSystem(const VTID codingSystem) //Arguments: // - gsetNumber - The G-set into which the charset will be selected. // - charset - The identifier indicating the charset that will be used. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::Designate94Charset(const VTInt gsetNumber, const VTID charset) +void AdaptDispatch::Designate94Charset(const VTInt gsetNumber, const VTID charset) { - return _termOutput.Designate94Charset(gsetNumber, charset); + _termOutput.Designate94Charset(gsetNumber, charset); } //Routine Description: @@ -3028,56 +2830,45 @@ bool AdaptDispatch::Designate94Charset(const VTInt gsetNumber, const VTID charse //Arguments: // - gsetNumber - The G-set into which the charset will be selected. // - charset - The identifier indicating the charset that will be used. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::Designate96Charset(const VTInt gsetNumber, const VTID charset) +void AdaptDispatch::Designate96Charset(const VTInt gsetNumber, const VTID charset) { - return _termOutput.Designate96Charset(gsetNumber, charset); + _termOutput.Designate96Charset(gsetNumber, charset); } //Routine Description: // Locking Shift - Invoke one of the G-sets into the left half of the code table. //Arguments: // - gsetNumber - The G-set that will be invoked. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::LockingShift(const VTInt gsetNumber) +void AdaptDispatch::LockingShift(const VTInt gsetNumber) { - return _termOutput.LockingShift(gsetNumber); + _termOutput.LockingShift(gsetNumber); } //Routine Description: // Locking Shift Right - Invoke one of the G-sets into the right half of the code table. //Arguments: // - gsetNumber - The G-set that will be invoked. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::LockingShiftRight(const VTInt gsetNumber) +void AdaptDispatch::LockingShiftRight(const VTInt gsetNumber) { - return _termOutput.LockingShiftRight(gsetNumber); + _termOutput.LockingShiftRight(gsetNumber); } //Routine Description: // Single Shift - Temporarily invoke one of the G-sets into the code table. //Arguments: // - gsetNumber - The G-set that will be invoked. -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::SingleShift(const VTInt gsetNumber) noexcept +void AdaptDispatch::SingleShift(const VTInt gsetNumber) noexcept { - return _termOutput.SingleShift(gsetNumber); + _termOutput.SingleShift(gsetNumber); } //Routine Description: // DECAC1 - Enable or disable the reception of C1 control codes in the parser. //Arguments: // - enabled - true to allow C1 controls to be used, false to disallow. -// Return value: -// - True. -bool AdaptDispatch::AcceptC1Controls(const bool enabled) +void AdaptDispatch::AcceptC1Controls(const bool enabled) { _api.GetStateMachine().SetParserMode(StateMachine::Mode::AcceptC1, enabled); - return true; } //Routine Description: @@ -3086,9 +2877,7 @@ bool AdaptDispatch::AcceptC1Controls(const bool enabled) // G-sets and in-use tables. //Arguments: // - ansiLevel - the expected conformance level -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::AnnounceCodeStructure(const VTInt ansiLevel) +void AdaptDispatch::AnnounceCodeStructure(const VTInt ansiLevel) { // Levels 1 and 2 require ASCII in G0/GL and Latin-1 in G1/GR. // Level 3 only requires ASCII in G0/GL. @@ -3102,9 +2891,9 @@ bool AdaptDispatch::AnnounceCodeStructure(const VTInt ansiLevel) case 3: Designate94Charset(0, VTID("B")); // ASCII designated as G0 LockingShift(0); // G0 mapped into GL - return true; + break; default: - return false; + break; } } @@ -3137,9 +2926,7 @@ bool AdaptDispatch::AnnounceCodeStructure(const VTInt ansiLevel) // PC Term mode DECPCTERM Always reset. //Arguments: // -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::SoftReset() +void AdaptDispatch::SoftReset() { _pages.ActivePage().Cursor().SetIsVisible(true); // Cursor enabled. @@ -3177,8 +2964,6 @@ bool AdaptDispatch::SoftReset() { _sixelParser->SoftReset(); } - - return true; } //Routine Description: @@ -3201,9 +2986,7 @@ bool AdaptDispatch::SoftReset() // * G0(USASCII) //Arguments: // -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::HardReset() +void AdaptDispatch::HardReset() { // If in the alt buffer, switch back to main before doing anything else. if (_usingAltBuffer) @@ -3283,7 +3066,6 @@ bool AdaptDispatch::HardReset() // A hard reset will disable all the modes that ConPTY relies on, // so let it know that it needs to re-enable those modes. _api.GetStateMachine().InjectSequence(InjectionType::RIS); - return true; } // Routine Description: @@ -3292,9 +3074,7 @@ bool AdaptDispatch::HardReset() // the home position. // Arguments: // - None -// Return Value: -// - True. -bool AdaptDispatch::ScreenAlignmentPattern() +void AdaptDispatch::ScreenAlignmentPattern() { const auto page = _pages.ActivePage(); @@ -3313,8 +3093,6 @@ bool AdaptDispatch::ScreenAlignmentPattern() _DoSetLeftRightScrollingMargins(0, 0); // Set the cursor position to home. CursorPosition(1, 1); - - return true; } //Routine Description: @@ -3327,9 +3105,7 @@ bool AdaptDispatch::ScreenAlignmentPattern() // (There isn't a scroll-forward, only a scrollback) // Arguments: // - -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::_EraseScrollback() +void AdaptDispatch::_EraseScrollback() { const auto page = _pages.VisiblePage(); auto& cursor = page.Cursor(); @@ -3341,8 +3117,6 @@ bool AdaptDispatch::_EraseScrollback() // Move the cursor to the same relative location. cursor.SetYPosition(row - page.Top()); cursor.SetHasMoved(true); - - return true; } //Routine Description: @@ -3355,9 +3129,7 @@ bool AdaptDispatch::_EraseScrollback() // viewport underneath that character. // Arguments: // - -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::_EraseAll() +void AdaptDispatch::_EraseAll() { const auto page = _pages.ActivePage(); const auto pageWidth = page.Width(); @@ -3404,8 +3176,6 @@ bool AdaptDispatch::_EraseAll() // Also reset the line rendition for the erased rows. textBuffer.ResetLineRenditionRange(newPageTop, newPageBottom); - - return true; } //Routine Description: @@ -3413,9 +3183,7 @@ bool AdaptDispatch::_EraseAll() // cursor style. Unix styles are a combination of the shape and the blinking state. //Arguments: // - cursorStyle - The unix-like cursor style to apply to the cursor -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) +void AdaptDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) { auto actualType = CursorType::Legacy; auto fEnableBlinking = false; @@ -3455,26 +3223,21 @@ bool AdaptDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) default: // Invalid argument should be handled by the connected terminal. - return false; + return; } auto& cursor = _pages.ActivePage().Cursor(); cursor.SetType(actualType); cursor.SetBlinkingAllowed(fEnableBlinking); - - return true; } // Routine Description: // - OSC Copy to Clipboard // Arguments: // - content - The content to copy to clipboard. Must be null terminated. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::SetClipboard(const wil::zwstring_view content) +void AdaptDispatch::SetClipboard(const wil::zwstring_view content) { _api.CopyToClipboard(content); - return true; } // Method Description: @@ -3482,9 +3245,7 @@ bool AdaptDispatch::SetClipboard(const wil::zwstring_view content) // Arguments: // - tableIndex: The VT color table index // - dwColor: The new RGB color value to use. -// Return Value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) +void AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) { _renderSettings.SetColorTableEntry(tableIndex, dwColor); @@ -3501,11 +3262,9 @@ bool AdaptDispatch::SetColorTableEntry(const size_t tableIndex, const DWORD dwCo _renderer->TriggerRedrawAll(backgroundChanged, frameChanged); } - - return true; } -bool AdaptDispatch::RequestColorTableEntry(const size_t tableIndex) +void AdaptDispatch::RequestColorTableEntry(const size_t tableIndex) { const auto color = _renderSettings.GetColorTableEntry(tableIndex); if (color != INVALID_COLOR) @@ -3514,15 +3273,11 @@ bool AdaptDispatch::RequestColorTableEntry(const size_t tableIndex) // Scale values up to match xterm's 16-bit color report format. _api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033]4;{};rgb:{:04x}/{:04x}/{:04x}\033\\"), tableIndex, c.r * 0x0101, c.g * 0x0101, c.b * 0x0101)); } - - return true; } // Method Description: // - Sets one Xterm Color Resource such as Default Foreground, Background, Cursor -// Return Value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::SetXtermColorResource(const size_t resource, const DWORD color) +void AdaptDispatch::SetXtermColorResource(const size_t resource, const DWORD color) { assert(resource >= 10); const auto mappingIndex = resource - 10; @@ -3536,15 +3291,13 @@ bool AdaptDispatch::SetXtermColorResource(const size_t resource, const DWORD col } return SetColorTableEntry(oscMapping.ColorTableIndex, color); } - - return true; } // Method Description: // - Reports the value of one Xterm Color Resource, if it is set. // Return Value: // True if handled successfully. False otherwise. -bool AdaptDispatch::RequestXtermColorResource(const size_t resource) +void AdaptDispatch::RequestXtermColorResource(const size_t resource) { assert(resource >= 10); const auto mappingIndex = resource - 10; @@ -3566,8 +3319,6 @@ bool AdaptDispatch::RequestXtermColorResource(const size_t resource) _api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033]{};rgb:{:04x}/{:04x}/{:04x}\033\\"), resource, c.r * 0x0101, c.g * 0x0101, c.b * 0x0101)); } } - - return true; } // Method Description: @@ -3577,9 +3328,7 @@ bool AdaptDispatch::RequestXtermColorResource(const size_t resource) // - item: The aspect of the interface that will have its colors altered. // - fgIndex: The color table index to be used for the foreground. // - bgIndex: The color table index to be used for the background. -// Return Value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) +void AdaptDispatch::AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) { switch (item) { @@ -3592,7 +3341,7 @@ bool AdaptDispatch::AssignColor(const DispatchTypes::ColorItem item, const VTInt _renderSettings.SetColorAliasIndex(ColorAlias::FrameBackground, bgIndex); break; default: - return false; + return; } if (_renderer) @@ -3601,8 +3350,6 @@ bool AdaptDispatch::AssignColor(const DispatchTypes::ColorItem item, const VTInt const auto frameChanged = item == DispatchTypes::ColorItem::WindowFrame; _renderer->TriggerRedrawAll(backgroundChanged, frameChanged); } - - return true; } //Routine Description: @@ -3615,9 +3362,7 @@ bool AdaptDispatch::AssignColor(const DispatchTypes::ColorItem item, const VTInt // - function - An identifier of the WindowManipulation function to perform // - parameter1 - The first optional parameter for the function // - parameter2 - The second optional parameter for the function -// Return value: -// True if handled successfully. False otherwise. -bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, +void AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) { @@ -3634,19 +3379,19 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy { case DispatchTypes::WindowManipulationType::DeIconifyWindow: _api.ShowWindow(true); - return true; + break; case DispatchTypes::WindowManipulationType::IconifyWindow: _api.ShowWindow(false); - return true; + break; case DispatchTypes::WindowManipulationType::RefreshWindow: _pages.VisiblePage().Buffer().TriggerRedrawAll(); - return true; + break; case DispatchTypes::WindowManipulationType::ResizeWindowInCharacters: _api.ResizeWindow(parameter2.value_or(0), parameter1.value_or(0)); - return true; + break; case DispatchTypes::WindowManipulationType::ReportTextSizeInCharacters: reportSize(_pages.VisiblePage().Size()); - return true; + break; case DispatchTypes::WindowManipulationType::ReportTextSizeInPixels: // Prior to the existence of the character cell size query, Sixel applications // that wanted to know the cell size would request the text area in pixels and @@ -3654,12 +3399,12 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy // return the virtual pixel size, as used in the Sixel graphics emulation, and // not the physical pixel size (which should be of no concern to applications). reportSize(_pages.VisiblePage().Size() * SixelParser::CellSizeForLevel()); - return true; + break; case DispatchTypes::WindowManipulationType::ReportCharacterCellSize: reportSize(SixelParser::CellSizeForLevel()); - return true; + break; default: - return false; + break; } } @@ -3667,9 +3412,7 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy // - Starts a hyperlink // Arguments: // - The hyperlink URI, optional additional parameters -// Return Value: -// - true -bool AdaptDispatch::AddHyperlink(const std::wstring_view uri, const std::wstring_view params) +void AdaptDispatch::AddHyperlink(const std::wstring_view uri, const std::wstring_view params) { const auto page = _pages.ActivePage(); auto attr = page.Attributes(); @@ -3677,20 +3420,16 @@ bool AdaptDispatch::AddHyperlink(const std::wstring_view uri, const std::wstring attr.SetHyperlinkId(id); page.SetAttributes(attr); page.Buffer().AddHyperlinkToMap(uri, id); - return true; } // Method Description: // - Ends a hyperlink -// Return Value: -// - true -bool AdaptDispatch::EndHyperlink() +void AdaptDispatch::EndHyperlink() { const auto page = _pages.ActivePage(); auto attr = page.Attributes(); attr.SetHyperlinkId(0); page.SetAttributes(attr); - return true; } // Method Description: @@ -3699,9 +3438,7 @@ bool AdaptDispatch::EndHyperlink() // and setting the working directory. // Arguments: // - string - contains the parameters that define which action we do -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) +void AdaptDispatch::DoConEmuAction(const std::wstring_view string) { constexpr size_t TaskbarMaxState{ 4 }; constexpr size_t TaskbarMaxProgress{ 100 }; @@ -3714,7 +3451,7 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) if (parts.size() < 1 || !Utils::StringToUint(til::at(parts, 0), subParam)) { - return false; + return; } // 4 is SetProgressBar, which sets the taskbar state/progress. @@ -3726,7 +3463,7 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) const auto stateSuccess = Utils::StringToUint(til::at(parts, 1), state); if (!stateSuccess && !til::at(parts, 1).empty()) { - return false; + return; } if (parts.size() >= 3) { @@ -3734,7 +3471,7 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) const auto progressSuccess = Utils::StringToUint(til::at(parts, 2), progress); if (!progressSuccess && !til::at(parts, 2).empty()) { - return false; + return; } } } @@ -3742,7 +3479,7 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) if (state > TaskbarMaxState) { // state is out of bounds, return false - return false; + return; } if (progress > TaskbarMaxProgress) { @@ -3750,7 +3487,6 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) progress = TaskbarMaxProgress; } _api.SetTaskbarProgress(static_cast(state), progress); - return true; } // 9 is SetWorkingDirectory, which informs the terminal about the current working directory. else if (subParam == 9) @@ -3769,11 +3505,10 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) if (!til::is_legal_path(path)) { - return false; + return; } _api.SetWorkingDirectory(path); - return true; } } // 12: "Let ConEmu treat current cursor position as prompt start" @@ -3786,10 +3521,7 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) else if (subParam == 12) { _pages.ActivePage().Buffer().StartCommand(); - return true; } - - return false; } // Method Description: @@ -3800,32 +3532,26 @@ bool AdaptDispatch::DoConEmuAction(const std::wstring_view string) // - 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::DoITerm2Action(const std::wstring_view string) +void AdaptDispatch::DoITerm2Action(const std::wstring_view string) { if constexpr (!Feature_ScrollbarMarks::IsEnabled()) { - return false; + return; } const auto parts = Utils::SplitString(string, L';'); if (parts.size() < 1) { - return false; + return; } const auto action = til::at(parts, 0); - bool handled = false; if (action == L"SetMark") { _pages.ActivePage().Buffer().StartPrompt(); - handled = true; } - - return handled; } // Method Description: @@ -3836,22 +3562,20 @@ bool AdaptDispatch::DoITerm2Action(const std::wstring_view string) // - The remainder of the FTCS prompt sequences are tracked in GH#11000 // 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::DoFinalTermAction(const std::wstring_view string) +void AdaptDispatch::DoFinalTermAction(const std::wstring_view string) { if constexpr (!Feature_ScrollbarMarks::IsEnabled()) { - return false; + return; } const auto parts = Utils::SplitString(string, L';'); if (parts.size() < 1) { - return false; + return; } - bool handled = false; + const auto action = til::at(parts, 0); if (action.size() == 1) { @@ -3860,19 +3584,16 @@ bool AdaptDispatch::DoFinalTermAction(const std::wstring_view string) case L'A': // FTCS_PROMPT { _pages.ActivePage().Buffer().StartPrompt(); - handled = true; break; } case L'B': // FTCS_COMMAND_START { _pages.ActivePage().Buffer().StartCommand(); - handled = true; break; } case L'C': // FTCS_COMMAND_EXECUTED { _pages.ActivePage().Buffer().StartOutput(); - handled = true; break; } case L'D': // FTCS_COMMAND_FINISHED @@ -3894,13 +3615,10 @@ bool AdaptDispatch::DoFinalTermAction(const std::wstring_view string) _pages.ActivePage().Buffer().EndCurrentCommand(error); - handled = true; break; } default: - { - handled = false; - } + break; } } @@ -3908,8 +3626,8 @@ bool AdaptDispatch::DoFinalTermAction(const std::wstring_view string) // simple state machine here to track the most recently emitted mark from // this set of sequences, and which sequence was emitted last, so we can // modify the state of that mark as we go. - return handled; } + // Method Description: // - Performs a VsCode action // - Currently, the actions we support are: @@ -3919,20 +3637,18 @@ bool AdaptDispatch::DoFinalTermAction(const std::wstring_view string) // - 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::DoVsCodeAction(const std::wstring_view string) +void AdaptDispatch::DoVsCodeAction(const std::wstring_view string) { if constexpr (!Feature_ShellCompletions::IsEnabled()) { - return false; + return; } const auto parts = Utils::SplitString(string, L';'); if (parts.size() < 1) { - return false; + return; } const auto action = til::at(parts, 0); @@ -3968,7 +3684,7 @@ bool AdaptDispatch::DoVsCodeAction(const std::wstring_view string) til::at(parts, 3).size() + 1; if (prefixLength > string.size()) { - return true; + return; } // Get the remainder of the string const auto remainder = string.substr(prefixLength); @@ -3978,9 +3694,7 @@ bool AdaptDispatch::DoVsCodeAction(const std::wstring_view string) } // If it's poorly formatted, just eat it - return true; } - return false; } // Method Description: @@ -3993,15 +3707,13 @@ bool AdaptDispatch::DoVsCodeAction(const std::wstring_view string) // - Not actually used in conhost // Arguments: // - string: contains the parameters that define which action we do -// Return Value: -// - false in conhost, true for the CmdNotFound action, otherwise false. -bool AdaptDispatch::DoWTAction(const std::wstring_view string) +void AdaptDispatch::DoWTAction(const std::wstring_view string) { const auto parts = Utils::SplitString(string, L';'); if (parts.size() < 1) { - return false; + return; } const auto action = til::at(parts, 0); @@ -4017,10 +3729,7 @@ bool AdaptDispatch::DoWTAction(const std::wstring_view string) const std::wstring_view missingCmd = til::at(parts, 1); _api.SearchMissingCommand(missingCmd); } - - return true; } - return false; } // Method Description: @@ -4126,14 +3835,11 @@ ITermDispatch::StringHandler AdaptDispatch::DownloadDRCS(const VTInt fontNumber, // - DECRQUPSS - Request the user-preference supplemental character set. // Arguments: // - None -// Return Value: -// - True -bool AdaptDispatch::RequestUserPreferenceCharset() +void AdaptDispatch::RequestUserPreferenceCharset() { const auto size = _termOutput.GetUserPreferenceCharsetSize(); const auto id = _termOutput.GetUserPreferenceCharsetId(); _api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033P{}!u{}\033\\"), (size == 96 ? 1 : 0), id)); - return true; } // Method Description: @@ -4200,9 +3906,7 @@ ITermDispatch::StringHandler AdaptDispatch::DefineMacro(const VTInt macroId, // as if it had been received directly from the host. // Arguments: // - macroId - the id number of the macro to be invoked. -// Return Value: -// - True -bool AdaptDispatch::InvokeMacro(const VTInt macroId) +void AdaptDispatch::InvokeMacro(const VTInt macroId) { if (_macroBuffer) { @@ -4218,7 +3922,6 @@ bool AdaptDispatch::InvokeMacro(const VTInt macroId) macroBuffer->InvokeMacro(macroId, stateMachine); }); } - return true; } // Routine Description: @@ -4228,17 +3931,15 @@ bool AdaptDispatch::InvokeMacro(const VTInt macroId) // Arguments: // - format - the format of the report being requested. // - formatOption - a format-specific option. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) +void AdaptDispatch::RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) { switch (format) { case DispatchTypes::ReportFormat::ColorTableReport: _ReportColorTable(formatOption); - return true; + break; default: - return false; + break; } } @@ -4632,20 +4333,18 @@ void AdaptDispatch::_ReportDECACSetting(const VTInt itemNumber) const // depending on the requested format. // Arguments: // - format - the format of the report being requested. -// Return Value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) +void AdaptDispatch::RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) { switch (format) { case DispatchTypes::PresentationReportFormat::CursorInformationReport: _ReportCursorInformation(); - return true; + break; case DispatchTypes::PresentationReportFormat::TabulationStopReport: _ReportTabStops(); - return true; + break; default: - return false; + break; } } @@ -4985,9 +4684,7 @@ ITermDispatch::StringHandler AdaptDispatch::_RestoreTabStops() // - DECPS - Plays a sequence of musical notes. // Arguments: // - params - The volume, duration, and note values to play. -// Return value: -// - True if handled successfully. False otherwise. -bool AdaptDispatch::PlaySounds(const VTParameters parameters) +void AdaptDispatch::PlaySounds(const VTParameters parameters) { // First parameter is the volume, in the range 0 to 7. We multiply by // 127 / 7 to obtain an equivalent MIDI velocity in the range 0 to 127. @@ -4997,13 +4694,12 @@ bool AdaptDispatch::PlaySounds(const VTParameters parameters) using namespace std::chrono_literals; const auto duration = std::min(parameters.at(1).value_or(0), 255) * 1000000us / 32; // The subsequent parameters are notes, in the range 0 to 25. - return parameters.subspan(2).for_each([=](const auto param) { + parameters.subspan(2).for_each([=](const auto param) { // Values 1 to 25 represent the notes C5 to C7, so we add 71 to // obtain the equivalent MIDI note numbers (72 = C5). const auto noteNumber = std::min(param.value_or(0), 25) + 71; // But value 0 is meant to be silent, so if the note number is 71, // we set the velocity to 0 (i.e. no volume). _api.PlayMidiNote(noteNumber, noteNumber == 71 ? 0 : velocity, duration); - return true; }); } diff --git a/src/terminal/adapter/adaptDispatch.hpp b/src/terminal/adapter/adaptDispatch.hpp index ef5636be1e2..4fc85ebc92a 100644 --- a/src/terminal/adapter/adaptDispatch.hpp +++ b/src/terminal/adapter/adaptDispatch.hpp @@ -41,117 +41,117 @@ namespace Microsoft::Console::VirtualTerminal void Print(const wchar_t wchPrintable) override; void PrintString(const std::wstring_view string) override; - bool CursorUp(const VTInt distance) override; // CUU - bool CursorDown(const VTInt distance) override; // CUD - bool CursorForward(const VTInt distance) override; // CUF - bool CursorBackward(const VTInt distance) override; // CUB, BS - bool CursorNextLine(const VTInt distance) override; // CNL - bool CursorPrevLine(const VTInt distance) override; // CPL - bool CursorHorizontalPositionAbsolute(const VTInt column) override; // HPA, CHA - bool VerticalLinePositionAbsolute(const VTInt line) override; // VPA - bool HorizontalPositionRelative(const VTInt distance) override; // HPR - bool VerticalPositionRelative(const VTInt distance) override; // VPR - bool CursorPosition(const VTInt line, const VTInt column) override; // CUP, HVP - bool CursorSaveState() override; // DECSC - bool CursorRestoreState() override; // DECRC - bool EraseInDisplay(const DispatchTypes::EraseType eraseType) override; // ED - bool EraseInLine(const DispatchTypes::EraseType eraseType) override; // EL - bool EraseCharacters(const VTInt numChars) override; // ECH - bool SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) override; // DECSED - bool SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) override; // DECSEL - bool InsertCharacter(const VTInt count) override; // ICH - bool DeleteCharacter(const VTInt count) override; // DCH - bool ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) override; // DECCARA - bool ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) override; // DECRARA - bool CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) override; // DECCRA - bool FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECFRA - bool EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECERA - bool SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECSERA - bool SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) noexcept override; // DECSACE - bool RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECRQCRA - bool SetGraphicsRendition(const VTParameters options) override; // SGR - bool SetLineRendition(const LineRendition rendition) override; // DECSWL, DECDWL, DECDHL - bool SetCharacterProtectionAttribute(const VTParameters options) override; // DECSCA - bool PushGraphicsRendition(const VTParameters options) override; // XTPUSHSGR - bool PopGraphicsRendition() override; // XTPOPSGR - bool DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) override; // DSR - bool DeviceAttributes() override; // DA1 - bool SecondaryDeviceAttributes() override; // DA2 - bool TertiaryDeviceAttributes() override; // DA3 - bool Vt52DeviceAttributes() override; // VT52 Identify - bool RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) override; // DECREQTPARM - bool ScrollUp(const VTInt distance) override; // SU - bool ScrollDown(const VTInt distance) override; // SD - bool NextPage(const VTInt pageCount) override; // NP - bool PrecedingPage(const VTInt pageCount) override; // PP - bool PagePositionAbsolute(const VTInt page) override; // PPA - bool PagePositionRelative(const VTInt pageCount) override; // PPR - bool PagePositionBack(const VTInt pageCount) override; // PPB - bool RequestDisplayedExtent() override; // DECRQDE - bool InsertLine(const VTInt distance) override; // IL - bool DeleteLine(const VTInt distance) override; // DL - bool InsertColumn(const VTInt distance) override; // DECIC - bool DeleteColumn(const VTInt distance) override; // DECDC - bool SetMode(const DispatchTypes::ModeParams param) override; // SM, DECSET - bool ResetMode(const DispatchTypes::ModeParams param) override; // RM, DECRST - bool RequestMode(const DispatchTypes::ModeParams param) override; // DECRQM - bool SetKeypadMode(const bool applicationMode) noexcept override; // DECKPAM, DECKPNM - bool SetAnsiMode(const bool ansiMode) override; // DECANM - bool SetTopBottomScrollingMargins(const VTInt topMargin, + void CursorUp(const VTInt distance) override; // CUU + void CursorDown(const VTInt distance) override; // CUD + void CursorForward(const VTInt distance) override; // CUF + void CursorBackward(const VTInt distance) override; // CUB, BS + void CursorNextLine(const VTInt distance) override; // CNL + void CursorPrevLine(const VTInt distance) override; // CPL + void CursorHorizontalPositionAbsolute(const VTInt column) override; // HPA, CHA + void VerticalLinePositionAbsolute(const VTInt line) override; // VPA + void HorizontalPositionRelative(const VTInt distance) override; // HPR + void VerticalPositionRelative(const VTInt distance) override; // VPR + void CursorPosition(const VTInt line, const VTInt column) override; // CUP, HVP + void CursorSaveState() override; // DECSC + void CursorRestoreState() override; // DECRC + void EraseInDisplay(const DispatchTypes::EraseType eraseType) override; // ED + void EraseInLine(const DispatchTypes::EraseType eraseType) override; // EL + void EraseCharacters(const VTInt numChars) override; // ECH + void SelectiveEraseInDisplay(const DispatchTypes::EraseType eraseType) override; // DECSED + void SelectiveEraseInLine(const DispatchTypes::EraseType eraseType) override; // DECSEL + void InsertCharacter(const VTInt count) override; // ICH + void DeleteCharacter(const VTInt count) override; // DCH + void ChangeAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) override; // DECCARA + void ReverseAttributesRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTParameters attrs) override; // DECRARA + void CopyRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right, const VTInt page, const VTInt dstTop, const VTInt dstLeft, const VTInt dstPage) override; // DECCRA + void FillRectangularArea(const VTParameter ch, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECFRA + void EraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECERA + void SelectiveEraseRectangularArea(const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECSERA + void SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent changeExtent) noexcept override; // DECSACE + void RequestChecksumRectangularArea(const VTInt id, const VTInt page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right) override; // DECRQCRA + void SetGraphicsRendition(const VTParameters options) override; // SGR + void SetLineRendition(const LineRendition rendition) override; // DECSWL, DECDWL, DECDHL + void SetCharacterProtectionAttribute(const VTParameters options) override; // DECSCA + void PushGraphicsRendition(const VTParameters options) override; // XTPUSHSGR + void PopGraphicsRendition() override; // XTPOPSGR + void DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter id) override; // DSR + void DeviceAttributes() override; // DA1 + void SecondaryDeviceAttributes() override; // DA2 + void TertiaryDeviceAttributes() override; // DA3 + void Vt52DeviceAttributes() override; // VT52 Identify + void RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) override; // DECREQTPARM + void ScrollUp(const VTInt distance) override; // SU + void ScrollDown(const VTInt distance) override; // SD + void NextPage(const VTInt pageCount) override; // NP + void PrecedingPage(const VTInt pageCount) override; // PP + void PagePositionAbsolute(const VTInt page) override; // PPA + void PagePositionRelative(const VTInt pageCount) override; // PPR + void PagePositionBack(const VTInt pageCount) override; // PPB + void RequestDisplayedExtent() override; // DECRQDE + void InsertLine(const VTInt distance) override; // IL + void DeleteLine(const VTInt distance) override; // DL + void InsertColumn(const VTInt distance) override; // DECIC + void DeleteColumn(const VTInt distance) override; // DECDC + void SetMode(const DispatchTypes::ModeParams param) override; // SM, DECSET + void ResetMode(const DispatchTypes::ModeParams param) override; // RM, DECRST + void RequestMode(const DispatchTypes::ModeParams param) override; // DECRQM + void SetKeypadMode(const bool applicationMode) noexcept override; // DECKPAM, DECKPNM + void SetAnsiMode(const bool ansiMode) override; // DECANM + void SetTopBottomScrollingMargins(const VTInt topMargin, const VTInt bottomMargin) override; // DECSTBM - bool SetLeftRightScrollingMargins(const VTInt leftMargin, + void SetLeftRightScrollingMargins(const VTInt leftMargin, const VTInt rightMargin) override; // DECSLRM - bool EnquireAnswerback() override; // ENQ - bool WarningBell() override; // BEL - bool CarriageReturn() override; // CR - bool LineFeed(const DispatchTypes::LineFeedType lineFeedType) override; // IND, NEL, LF, FF, VT - bool ReverseLineFeed() override; // RI - bool BackIndex() override; // DECBI - bool ForwardIndex() override; // DECFI - bool SetWindowTitle(const std::wstring_view title) override; // DECSWT, OSCWindowTitle - bool HorizontalTabSet() override; // HTS - bool ForwardTab(const VTInt numTabs) override; // CHT, HT - bool BackwardsTab(const VTInt numTabs) override; // CBT - bool TabClear(const DispatchTypes::TabClearType clearType) override; // TBC - bool TabSet(const VTParameter setType) noexcept override; // DECST8C - bool DesignateCodingSystem(const VTID codingSystem) override; // DOCS - bool Designate94Charset(const VTInt gsetNumber, const VTID charset) override; // SCS - bool Designate96Charset(const VTInt gsetNumber, const VTID charset) override; // SCS - bool LockingShift(const VTInt gsetNumber) override; // LS0, LS1, LS2, LS3 - bool LockingShiftRight(const VTInt gsetNumber) override; // LS1R, LS2R, LS3R - bool SingleShift(const VTInt gsetNumber) noexcept override; // SS2, SS3 - bool AcceptC1Controls(const bool enabled) override; // DECAC1 - bool AnnounceCodeStructure(const VTInt ansiLevel) override; // ACS - bool SoftReset() override; // DECSTR - bool HardReset() override; // RIS - bool ScreenAlignmentPattern() override; // DECALN - bool SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) override; // DECSCUSR - - bool SetClipboard(const wil::zwstring_view content) override; // OSCSetClipboard - - bool SetColorTableEntry(const size_t tableIndex, + void EnquireAnswerback() override; // ENQ + void WarningBell() override; // BEL + void CarriageReturn() override; // CR + void LineFeed(const DispatchTypes::LineFeedType lineFeedType) override; // IND, NEL, LF, FF, VT + void ReverseLineFeed() override; // RI + void BackIndex() override; // DECBI + void ForwardIndex() override; // DECFI + void SetWindowTitle(const std::wstring_view title) override; // DECSWT, OSCWindowTitle + void HorizontalTabSet() override; // HTS + void ForwardTab(const VTInt numTabs) override; // CHT, HT + void BackwardsTab(const VTInt numTabs) override; // CBT + void TabClear(const DispatchTypes::TabClearType clearType) override; // TBC + void TabSet(const VTParameter setType) noexcept override; // DECST8C + void DesignateCodingSystem(const VTID codingSystem) override; // DOCS + void Designate94Charset(const VTInt gsetNumber, const VTID charset) override; // SCS + void Designate96Charset(const VTInt gsetNumber, const VTID charset) override; // SCS + void LockingShift(const VTInt gsetNumber) override; // LS0, LS1, LS2, LS3 + void LockingShiftRight(const VTInt gsetNumber) override; // LS1R, LS2R, LS3R + void SingleShift(const VTInt gsetNumber) noexcept override; // SS2, SS3 + void AcceptC1Controls(const bool enabled) override; // DECAC1 + void AnnounceCodeStructure(const VTInt ansiLevel) override; // ACS + void SoftReset() override; // DECSTR + void HardReset() override; // RIS + void ScreenAlignmentPattern() override; // DECALN + void SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) override; // DECSCUSR + + void SetClipboard(const wil::zwstring_view content) override; // OSCSetClipboard + + void SetColorTableEntry(const size_t tableIndex, const DWORD color) override; // OSCSetColorTable - bool RequestColorTableEntry(const size_t tableIndex) override; // OSCGetColorTable - bool SetXtermColorResource(const size_t resource, const DWORD color) override; // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor - bool RequestXtermColorResource(const size_t resource) override; // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor - bool AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) override; // DECAC + void RequestColorTableEntry(const size_t tableIndex) override; // OSCGetColorTable + void SetXtermColorResource(const size_t resource, const DWORD color) override; // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor + void RequestXtermColorResource(const size_t resource) override; // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor + void AssignColor(const DispatchTypes::ColorItem item, const VTInt fgIndex, const VTInt bgIndex) override; // DECAC - bool WindowManipulation(const DispatchTypes::WindowManipulationType function, + void WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) override; // DTTERM_WindowManipulation - bool AddHyperlink(const std::wstring_view uri, const std::wstring_view params) override; - bool EndHyperlink() override; + void AddHyperlink(const std::wstring_view uri, const std::wstring_view params) override; + void EndHyperlink() override; - bool DoConEmuAction(const std::wstring_view string) override; + void DoConEmuAction(const std::wstring_view string) override; - bool DoITerm2Action(const std::wstring_view string) override; + void DoITerm2Action(const std::wstring_view string) override; - bool DoFinalTermAction(const std::wstring_view string) override; + void DoFinalTermAction(const std::wstring_view string) override; - bool DoVsCodeAction(const std::wstring_view string) override; + void DoVsCodeAction(const std::wstring_view string) override; - bool DoWTAction(const std::wstring_view string) override; + void DoWTAction(const std::wstring_view string) override; StringHandler DefineSixelImage(const VTInt macroParameter, const DispatchTypes::SixelBackground backgroundSelect, @@ -166,23 +166,23 @@ namespace Microsoft::Console::VirtualTerminal const VTParameter cellHeight, const DispatchTypes::CharsetSize charsetSize) override; // DECDLD - bool RequestUserPreferenceCharset() override; // DECRQUPSS + void RequestUserPreferenceCharset() override; // DECRQUPSS StringHandler AssignUserPreferenceCharset(const DispatchTypes::CharsetSize charsetSize) override; // DECAUPSS StringHandler DefineMacro(const VTInt macroId, const DispatchTypes::MacroDeleteControl deleteControl, const DispatchTypes::MacroEncoding encoding) override; // DECDMAC - bool InvokeMacro(const VTInt macroId) override; // DECINVM + void InvokeMacro(const VTInt macroId) override; // DECINVM - bool RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) override; // DECRQTSR + void RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) override; // DECRQTSR StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat format) override; // DECRSTS StringHandler RequestSetting() override; // DECRQSS - bool RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) override; // DECRQPSR + void RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat format) override; // DECRQPSR StringHandler RestorePresentationState(const DispatchTypes::PresentationReportFormat format) override; // DECRSPS - bool PlaySounds(const VTParameters parameters) override; // DECPS + void PlaySounds(const VTParameters parameters) override; // DECPS private: enum class Mode @@ -234,15 +234,15 @@ namespace Microsoft::Console::VirtualTerminal void _WriteToBuffer(const std::wstring_view string); std::pair _GetVerticalMargins(const Page& page, const bool absolute) noexcept; std::pair _GetHorizontalMargins(const til::CoordType bufferWidth) noexcept; - bool _CursorMovePosition(const Offset rowOffset, const Offset colOffset, const bool clampInMargins); + void _CursorMovePosition(const Offset rowOffset, const Offset colOffset, const bool clampInMargins); void _ApplyCursorMovementFlags(Cursor& cursor) noexcept; void _FillRect(const Page& page, const til::rect& fillRect, const std::wstring_view& fillChar, const TextAttribute& fillAttrs) const; void _SelectiveEraseRect(const Page& page, const til::rect& eraseRect); void _ChangeRectAttributes(const Page& page, const til::rect& changeRect, const ChangeOps& changeOps); void _ChangeRectOrStreamAttributes(const til::rect& changeArea, const ChangeOps& changeOps); til::rect _CalculateRectArea(const Page& page, const VTInt top, const VTInt left, const VTInt bottom, const VTInt right); - bool _EraseScrollback(); - bool _EraseAll(); + void _EraseScrollback(); + void _EraseAll(); TextAttribute _GetEraseAttributes(const Page& page) const noexcept; void _ScrollRectVertically(const Page& page, const til::rect& scrollRect, const VTInt delta); void _ScrollRectHorizontally(const Page& page, const til::rect& scrollRect, const VTInt delta); @@ -267,7 +267,7 @@ namespace Microsoft::Console::VirtualTerminal void _SetColumnMode(const bool enable); void _SetAlternateScreenBufferMode(const bool enable); - bool _ModeParamsHelper(const DispatchTypes::ModeParams param, const bool enable); + void _ModeParamsHelper(const DispatchTypes::ModeParams param, const bool enable); void _ClearSingleTabStop(); void _ClearAllTabStops() noexcept; diff --git a/src/terminal/adapter/adaptDispatchGraphics.cpp b/src/terminal/adapter/adaptDispatchGraphics.cpp index afad6e5141a..6c0666eae6c 100644 --- a/src/terminal/adapter/adaptDispatchGraphics.cpp +++ b/src/terminal/adapter/adaptDispatchGraphics.cpp @@ -418,15 +418,12 @@ void AdaptDispatch::_ApplyGraphicsOptions(const VTParameters options, // Arguments: // - options - An array of options that will be applied from 0 to N, in order, // one at a time by setting or removing flags in the font style properties. -// Return Value: -// - True. -bool AdaptDispatch::SetGraphicsRendition(const VTParameters options) +void AdaptDispatch::SetGraphicsRendition(const VTParameters options) { const auto page = _pages.ActivePage(); auto attr = page.Attributes(); _ApplyGraphicsOptions(options, attr); page.SetAttributes(attr); - return true; } // Routine Description: @@ -435,9 +432,7 @@ bool AdaptDispatch::SetGraphicsRendition(const VTParameters options) // but the protected attribute was the only one ever implemented. // Arguments: // - options - An array of options that will be applied in order. -// Return Value: -// - True. -bool AdaptDispatch::SetCharacterProtectionAttribute(const VTParameters options) +void AdaptDispatch::SetCharacterProtectionAttribute(const VTParameters options) { const auto page = _pages.ActivePage(); auto attr = page.Attributes(); @@ -458,7 +453,6 @@ bool AdaptDispatch::SetCharacterProtectionAttribute(const VTParameters options) } } page.SetAttributes(attr); - return true; } // Method Description: @@ -467,13 +461,10 @@ bool AdaptDispatch::SetCharacterProtectionAttribute(const VTParameters options) // - options: if not empty, specify which portions of the current text attributes should // be saved. Options that are not supported are ignored. If no options are specified, // all attributes are stored. -// Return Value: -// - True. -bool AdaptDispatch::PushGraphicsRendition(const VTParameters options) +void AdaptDispatch::PushGraphicsRendition(const VTParameters options) { const auto& currentAttributes = _pages.ActivePage().Attributes(); _sgrStack.Push(currentAttributes, options); - return true; } // Method Description: @@ -481,12 +472,9 @@ bool AdaptDispatch::PushGraphicsRendition(const VTParameters options) // were saved, combines those with the current attributes. // Arguments: // - -// Return Value: -// - True. -bool AdaptDispatch::PopGraphicsRendition() +void AdaptDispatch::PopGraphicsRendition() { const auto page = _pages.ActivePage(); const auto& currentAttributes = page.Attributes(); page.SetAttributes(_sgrStack.Pop(currentAttributes)); - return true; } diff --git a/src/terminal/adapter/termDispatch.hpp b/src/terminal/adapter/termDispatch.hpp index 5d256928712..bb12dc32880 100644 --- a/src/terminal/adapter/termDispatch.hpp +++ b/src/terminal/adapter/termDispatch.hpp @@ -25,123 +25,123 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons void Print(const wchar_t wchPrintable) override = 0; void PrintString(const std::wstring_view string) override = 0; - bool CursorUp(const VTInt /*distance*/) override { return false; } // CUU - bool CursorDown(const VTInt /*distance*/) override { return false; } // CUD - bool CursorForward(const VTInt /*distance*/) override { return false; } // CUF - bool CursorBackward(const VTInt /*distance*/) override { return false; } // CUB, BS - bool CursorNextLine(const VTInt /*distance*/) override { return false; } // CNL - bool CursorPrevLine(const VTInt /*distance*/) override { return false; } // CPL - bool CursorHorizontalPositionAbsolute(const VTInt /*column*/) override { return false; } // HPA, CHA - bool VerticalLinePositionAbsolute(const VTInt /*line*/) override { return false; } // VPA - bool HorizontalPositionRelative(const VTInt /*distance*/) override { return false; } // HPR - bool VerticalPositionRelative(const VTInt /*distance*/) override { return false; } // VPR - bool CursorPosition(const VTInt /*line*/, const VTInt /*column*/) override { return false; } // CUP, HVP - bool CursorSaveState() override { return false; } // DECSC - bool CursorRestoreState() override { return false; } // DECRC - bool InsertCharacter(const VTInt /*count*/) override { return false; } // ICH - bool DeleteCharacter(const VTInt /*count*/) override { return false; } // DCH - bool ScrollUp(const VTInt /*distance*/) override { return false; } // SU - bool ScrollDown(const VTInt /*distance*/) override { return false; } // SD - bool NextPage(const VTInt /*pageCount*/) override { return false; } // NP - bool PrecedingPage(const VTInt /*pageCount*/) override { return false; } // PP - bool PagePositionAbsolute(const VTInt /*page*/) override { return false; } // PPA - bool PagePositionRelative(const VTInt /*pageCount*/) override { return false; } // PPR - bool PagePositionBack(const VTInt /*pageCount*/) override { return false; } // PPB - bool RequestDisplayedExtent() override { return false; } // DECRQDE - bool InsertLine(const VTInt /*distance*/) override { return false; } // IL - bool DeleteLine(const VTInt /*distance*/) override { return false; } // DL - bool InsertColumn(const VTInt /*distance*/) override { return false; } // DECIC - bool DeleteColumn(const VTInt /*distance*/) override { return false; } // DECDC - bool SetKeypadMode(const bool /*applicationMode*/) override { return false; } // DECKPAM, DECKPNM - bool SetAnsiMode(const bool /*ansiMode*/) override { return false; } // DECANM - bool SetTopBottomScrollingMargins(const VTInt /*topMargin*/, const VTInt /*bottomMargin*/) override { return false; } // DECSTBM - bool SetLeftRightScrollingMargins(const VTInt /*leftMargin*/, const VTInt /*rightMargin*/) override { return false; } // DECSLRM - bool EnquireAnswerback() override { return false; } // ENQ - bool WarningBell() override { return false; } // BEL - bool CarriageReturn() override { return false; } // CR - bool LineFeed(const DispatchTypes::LineFeedType /*lineFeedType*/) override { return false; } // IND, NEL, LF, FF, VT - bool ReverseLineFeed() override { return false; } // RI - bool BackIndex() override { return false; } // DECBI - bool ForwardIndex() override { return false; } // DECFI - bool SetWindowTitle(std::wstring_view /*title*/) override { return false; } // DECSWT, OscWindowTitle - bool HorizontalTabSet() override { return false; } // HTS - bool ForwardTab(const VTInt /*numTabs*/) override { return false; } // CHT, HT - bool BackwardsTab(const VTInt /*numTabs*/) override { return false; } // CBT - bool TabClear(const DispatchTypes::TabClearType /*clearType*/) override { return false; } // TBC - bool TabSet(const VTParameter /*setType*/) override { return false; } // DECST8C - bool SetColorTableEntry(const size_t /*tableIndex*/, const DWORD /*color*/) override { return false; } // OSCSetColorTable - bool RequestColorTableEntry(const size_t /*tableIndex*/) override { return false; } // OSCGetColorTable - bool SetXtermColorResource(const size_t /*resource*/, const DWORD /*color*/) override { return false; } // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor - bool RequestXtermColorResource(const size_t /*resource*/) override { return false; } // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor - bool AssignColor(const DispatchTypes::ColorItem /*item*/, const VTInt /*fgIndex*/, const VTInt /*bgIndex*/) override { return false; } // DECAC - - bool EraseInDisplay(const DispatchTypes::EraseType /* eraseType*/) override { return false; } // ED - bool EraseInLine(const DispatchTypes::EraseType /* eraseType*/) override { return false; } // EL - bool EraseCharacters(const VTInt /*numChars*/) override { return false; } // ECH - bool SelectiveEraseInDisplay(const DispatchTypes::EraseType /*eraseType*/) override { return false; } // DECSED - bool SelectiveEraseInLine(const DispatchTypes::EraseType /*eraseType*/) override { return false; } // DECSEL - - bool ChangeAttributesRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTParameters /*attrs*/) override { return false; } // DECCARA - bool ReverseAttributesRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTParameters /*attrs*/) override { return false; } // DECRARA - bool CopyRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTInt /*page*/, const VTInt /*dstTop*/, const VTInt /*dstLeft*/, const VTInt /*dstPage*/) override { return false; } // DECCRA - bool FillRectangularArea(const VTParameter /*ch*/, const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override { return false; } // DECFRA - bool EraseRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override { return false; } // DECERA - bool SelectiveEraseRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override { return false; } // DECSERA - bool SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent /*changeExtent*/) override { return false; } // DECSACE - bool RequestChecksumRectangularArea(const VTInt /*id*/, const VTInt /*page*/, const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override { return false; } // DECRQCRA - - bool SetGraphicsRendition(const VTParameters /*options*/) override { return false; } // SGR - bool SetLineRendition(const LineRendition /*rendition*/) override { return false; } // DECSWL, DECDWL, DECDHL - bool SetCharacterProtectionAttribute(const VTParameters /*options*/) override { return false; } // DECSCA - - bool PushGraphicsRendition(const VTParameters /*options*/) override { return false; } // XTPUSHSGR - bool PopGraphicsRendition() override { return false; } // XTPOPSGR - - bool SetMode(const DispatchTypes::ModeParams /*param*/) override { return false; } // SM, DECSET - bool ResetMode(const DispatchTypes::ModeParams /*param*/) override { return false; } // RM, DECRST - bool RequestMode(const DispatchTypes::ModeParams /*param*/) override { return false; } // DECRQM - - bool DeviceStatusReport(const DispatchTypes::StatusType /*statusType*/, const VTParameter /*id*/) override { return false; } // DSR - bool DeviceAttributes() override { return false; } // DA1 - bool SecondaryDeviceAttributes() override { return false; } // DA2 - bool TertiaryDeviceAttributes() override { return false; } // DA3 - bool Vt52DeviceAttributes() override { return false; } // VT52 Identify - bool RequestTerminalParameters(const DispatchTypes::ReportingPermission /*permission*/) override { return false; } // DECREQTPARM - - bool DesignateCodingSystem(const VTID /*codingSystem*/) override { return false; } // DOCS - bool Designate94Charset(const VTInt /*gsetNumber*/, const VTID /*charset*/) override { return false; } // SCS - bool Designate96Charset(const VTInt /*gsetNumber*/, const VTID /*charset*/) override { return false; } // SCS - bool LockingShift(const VTInt /*gsetNumber*/) override { return false; } // LS0, LS1, LS2, LS3 - bool LockingShiftRight(const VTInt /*gsetNumber*/) override { return false; } // LS1R, LS2R, LS3R - bool SingleShift(const VTInt /*gsetNumber*/) override { return false; } // SS2, SS3 - bool AcceptC1Controls(const bool /*enabled*/) override { return false; } // DECAC1 - bool AnnounceCodeStructure(const VTInt /*ansiLevel*/) override { return false; } // ACS - - bool SoftReset() override { return false; } // DECSTR - bool HardReset() override { return false; } // RIS - bool ScreenAlignmentPattern() override { return false; } // DECALN - - bool SetCursorStyle(const DispatchTypes::CursorStyle /*cursorStyle*/) override { return false; } // DECSCUSR - - bool SetClipboard(wil::zwstring_view /*content*/) override { return false; } // OscSetClipboard + void CursorUp(const VTInt /*distance*/) override {} // CUU + void CursorDown(const VTInt /*distance*/) override {} // CUD + void CursorForward(const VTInt /*distance*/) override {} // CUF + void CursorBackward(const VTInt /*distance*/) override {} // CUB, BS + void CursorNextLine(const VTInt /*distance*/) override {} // CNL + void CursorPrevLine(const VTInt /*distance*/) override {} // CPL + void CursorHorizontalPositionAbsolute(const VTInt /*column*/) override {} // HPA, CHA + void VerticalLinePositionAbsolute(const VTInt /*line*/) override {} // VPA + void HorizontalPositionRelative(const VTInt /*distance*/) override {} // HPR + void VerticalPositionRelative(const VTInt /*distance*/) override {} // VPR + void CursorPosition(const VTInt /*line*/, const VTInt /*column*/) override {} // CUP, HVP + void CursorSaveState() override {} // DECSC + void CursorRestoreState() override {} // DECRC + void InsertCharacter(const VTInt /*count*/) override {} // ICH + void DeleteCharacter(const VTInt /*count*/) override {} // DCH + void ScrollUp(const VTInt /*distance*/) override {} // SU + void ScrollDown(const VTInt /*distance*/) override {} // SD + void NextPage(const VTInt /*pageCount*/) override {} // NP + void PrecedingPage(const VTInt /*pageCount*/) override {} // PP + void PagePositionAbsolute(const VTInt /*page*/) override {} // PPA + void PagePositionRelative(const VTInt /*pageCount*/) override {} // PPR + void PagePositionBack(const VTInt /*pageCount*/) override {} // PPB + void RequestDisplayedExtent() override {} // DECRQDE + void InsertLine(const VTInt /*distance*/) override {} // IL + void DeleteLine(const VTInt /*distance*/) override {} // DL + void InsertColumn(const VTInt /*distance*/) override {} // DECIC + void DeleteColumn(const VTInt /*distance*/) override {} // DECDC + void SetKeypadMode(const bool /*applicationMode*/) override {} // DECKPAM, DECKPNM + void SetAnsiMode(const bool /*ansiMode*/) override {} // DECANM + void SetTopBottomScrollingMargins(const VTInt /*topMargin*/, const VTInt /*bottomMargin*/) override {} // DECSTBM + void SetLeftRightScrollingMargins(const VTInt /*leftMargin*/, const VTInt /*rightMargin*/) override {} // DECSLRM + void EnquireAnswerback() override {} // ENQ + void WarningBell() override {} // BEL + void CarriageReturn() override {} // CR + void LineFeed(const DispatchTypes::LineFeedType /*lineFeedType*/) override {} // IND, NEL, LF, FF, VT + void ReverseLineFeed() override {} // RI + void BackIndex() override {} // DECBI + void ForwardIndex() override {} // DECFI + void SetWindowTitle(std::wstring_view /*title*/) override {} // DECSWT, OscWindowTitle + void HorizontalTabSet() override {} // HTS + void ForwardTab(const VTInt /*numTabs*/) override {} // CHT, HT + void BackwardsTab(const VTInt /*numTabs*/) override {} // CBT + void TabClear(const DispatchTypes::TabClearType /*clearType*/) override {} // TBC + void TabSet(const VTParameter /*setType*/) override {} // DECST8C + void SetColorTableEntry(const size_t /*tableIndex*/, const DWORD /*color*/) override {} // OSCSetColorTable + void RequestColorTableEntry(const size_t /*tableIndex*/) override {} // OSCGetColorTable + void SetXtermColorResource(const size_t /*resource*/, const DWORD /*color*/) override {} // OSCSetDefaultForeground, OSCSetDefaultBackground, OSCSetCursorColor, OSCResetCursorColor + void RequestXtermColorResource(const size_t /*resource*/) override {} // OSCGetDefaultForeground, OSCGetDefaultBackground, OSCGetCursorColor + void AssignColor(const DispatchTypes::ColorItem /*item*/, const VTInt /*fgIndex*/, const VTInt /*bgIndex*/) override {} // DECAC + + void EraseInDisplay(const DispatchTypes::EraseType /* eraseType*/) override {} // ED + void EraseInLine(const DispatchTypes::EraseType /* eraseType*/) override {} // EL + void EraseCharacters(const VTInt /*numChars*/) override {} // ECH + void SelectiveEraseInDisplay(const DispatchTypes::EraseType /*eraseType*/) override {} // DECSED + void SelectiveEraseInLine(const DispatchTypes::EraseType /*eraseType*/) override {} // DECSEL + + void ChangeAttributesRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTParameters /*attrs*/) override {} // DECCARA + void ReverseAttributesRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTParameters /*attrs*/) override {} // DECRARA + void CopyRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/, const VTInt /*page*/, const VTInt /*dstTop*/, const VTInt /*dstLeft*/, const VTInt /*dstPage*/) override {} // DECCRA + void FillRectangularArea(const VTParameter /*ch*/, const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override {} // DECFRA + void EraseRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override {} // DECERA + void SelectiveEraseRectangularArea(const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override {} // DECSERA + void SelectAttributeChangeExtent(const DispatchTypes::ChangeExtent /*changeExtent*/) override {} // DECSACE + void RequestChecksumRectangularArea(const VTInt /*id*/, const VTInt /*page*/, const VTInt /*top*/, const VTInt /*left*/, const VTInt /*bottom*/, const VTInt /*right*/) override {} // DECRQCRA + + void SetGraphicsRendition(const VTParameters /*options*/) override {} // SGR + void SetLineRendition(const LineRendition /*rendition*/) override {} // DECSWL, DECDWL, DECDHL + void SetCharacterProtectionAttribute(const VTParameters /*options*/) override {} // DECSCA + + void PushGraphicsRendition(const VTParameters /*options*/) override {} // XTPUSHSGR + void PopGraphicsRendition() override {} // XTPOPSGR + + void SetMode(const DispatchTypes::ModeParams /*param*/) override {} // SM, DECSET + void ResetMode(const DispatchTypes::ModeParams /*param*/) override {} // RM, DECRST + void RequestMode(const DispatchTypes::ModeParams /*param*/) override {} // DECRQM + + void DeviceStatusReport(const DispatchTypes::StatusType /*statusType*/, const VTParameter /*id*/) override {} // DSR + void DeviceAttributes() override {} // DA1 + void SecondaryDeviceAttributes() override {} // DA2 + void TertiaryDeviceAttributes() override {} // DA3 + void Vt52DeviceAttributes() override {} // VT52 Identify + void RequestTerminalParameters(const DispatchTypes::ReportingPermission /*permission*/) override {} // DECREQTPARM + + void DesignateCodingSystem(const VTID /*codingSystem*/) override {} // DOCS + void Designate94Charset(const VTInt /*gsetNumber*/, const VTID /*charset*/) override {} // SCS + void Designate96Charset(const VTInt /*gsetNumber*/, const VTID /*charset*/) override {} // SCS + void LockingShift(const VTInt /*gsetNumber*/) override {} // LS0, LS1, LS2, LS3 + void LockingShiftRight(const VTInt /*gsetNumber*/) override {} // LS1R, LS2R, LS3R + void SingleShift(const VTInt /*gsetNumber*/) override {} // SS2, SS3 + void AcceptC1Controls(const bool /*enabled*/) override {} // DECAC1 + void AnnounceCodeStructure(const VTInt /*ansiLevel*/) override {} // ACS + + void SoftReset() override {} // DECSTR + void HardReset() override {} // RIS + void ScreenAlignmentPattern() override {} // DECALN + + void SetCursorStyle(const DispatchTypes::CursorStyle /*cursorStyle*/) override {} // DECSCUSR + + void SetClipboard(wil::zwstring_view /*content*/) override {} // OscSetClipboard // DTTERM_WindowManipulation - bool WindowManipulation(const DispatchTypes::WindowManipulationType /*function*/, + void WindowManipulation(const DispatchTypes::WindowManipulationType /*function*/, const VTParameter /*parameter1*/, - const VTParameter /*parameter2*/) override { return false; } + const VTParameter /*parameter2*/) override {} - bool AddHyperlink(const std::wstring_view /*uri*/, const std::wstring_view /*params*/) override { return false; } - bool EndHyperlink() override { return false; } + void AddHyperlink(const std::wstring_view /*uri*/, const std::wstring_view /*params*/) override {} + void EndHyperlink() override {} - bool DoConEmuAction(const std::wstring_view /*string*/) override { return false; } + void DoConEmuAction(const std::wstring_view /*string*/) override {} - bool DoITerm2Action(const std::wstring_view /*string*/) override { return false; } + void DoITerm2Action(const std::wstring_view /*string*/) override {} - bool DoFinalTermAction(const std::wstring_view /*string*/) override { return false; } + void DoFinalTermAction(const std::wstring_view /*string*/) override {} - bool DoVsCodeAction(const std::wstring_view /*string*/) override { return false; } + void DoVsCodeAction(const std::wstring_view /*string*/) override {} - bool DoWTAction(const std::wstring_view /*string*/) override { return false; } + void DoWTAction(const std::wstring_view /*string*/) override {} StringHandler DefineSixelImage(const VTInt /*macroParameter*/, const DispatchTypes::SixelBackground /*backgroundSelect*/, @@ -156,23 +156,23 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons const VTParameter /*cellHeight*/, const DispatchTypes::CharsetSize /*charsetSize*/) override { return nullptr; } // DECDLD - bool RequestUserPreferenceCharset() override { return false; } // DECRQUPSS + void RequestUserPreferenceCharset() override {} // DECRQUPSS StringHandler AssignUserPreferenceCharset(const DispatchTypes::CharsetSize /*charsetSize*/) override { return nullptr; } // DECAUPSS StringHandler DefineMacro(const VTInt /*macroId*/, const DispatchTypes::MacroDeleteControl /*deleteControl*/, const DispatchTypes::MacroEncoding /*encoding*/) override { return nullptr; } // DECDMAC - bool InvokeMacro(const VTInt /*macroId*/) override { return false; } // DECINVM + void InvokeMacro(const VTInt /*macroId*/) override {} // DECINVM - bool RequestTerminalStateReport(const DispatchTypes::ReportFormat /*format*/, const VTParameter /*formatOption*/) override { return false; } // DECRQTSR + void RequestTerminalStateReport(const DispatchTypes::ReportFormat /*format*/, const VTParameter /*formatOption*/) override {} // DECRQTSR StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat /*format*/) override { return nullptr; }; // DECRSTS StringHandler RequestSetting() override { return nullptr; }; // DECRQSS - bool RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat /*format*/) override { return false; } // DECRQPSR + void RequestPresentationStateReport(const DispatchTypes::PresentationReportFormat /*format*/) override {} // DECRQPSR StringHandler RestorePresentationState(const DispatchTypes::PresentationReportFormat /*format*/) override { return nullptr; } // DECRSPS - bool PlaySounds(const VTParameters /*parameters*/) override { return false; }; // DECPS + void PlaySounds(const VTParameters /*parameters*/) override{}; // DECPS }; #pragma warning(default : 26440) // Restore "can be declared noexcept" warning diff --git a/src/terminal/adapter/terminalOutput.cpp b/src/terminal/adapter/terminalOutput.cpp index 4f39fc3558e..a7f1f2a08ad 100644 --- a/src/terminal/adapter/terminalOutput.cpp +++ b/src/terminal/adapter/terminalOutput.cpp @@ -47,10 +47,14 @@ void TerminalOutput::RestoreFrom(const TerminalOutput& savedState) noexcept _grTranslationEnabled = preserveGrTranslation; } -bool TerminalOutput::AssignUserPreferenceCharset(const VTID charset, const bool size96) +void TerminalOutput::AssignUserPreferenceCharset(const VTID charset, const bool size96) { const auto translationTable = size96 ? _LookupTranslationTable96(charset) : _LookupTranslationTable94(charset); - RETURN_BOOL_IF_FALSE(!translationTable.empty()); + if (translationTable.empty()) + { + return; + } + _upssId = charset; _upssTranslationTable = translationTable; // Any G-set mapped to UPSS will need its translation table updated. @@ -64,7 +68,6 @@ bool TerminalOutput::AssignUserPreferenceCharset(const VTID charset, const bool // We also reapply the locking shifts in case they need to be updated. LockingShift(_glSetNumber); LockingShiftRight(_grSetNumber); - return true; } VTID TerminalOutput::GetUserPreferenceCharsetId() const noexcept @@ -77,20 +80,28 @@ size_t TerminalOutput::GetUserPreferenceCharsetSize() const noexcept return _upssTranslationTable.size() == 96 ? 96 : 94; } -bool TerminalOutput::Designate94Charset(size_t gsetNumber, const VTID charset) +void TerminalOutput::Designate94Charset(size_t gsetNumber, const VTID charset) { const auto translationTable = _LookupTranslationTable94(charset); - RETURN_BOOL_IF_FALSE(!translationTable.empty()); + if (translationTable.empty()) + { + return; + } + _gsetIds.at(gsetNumber) = charset; - return _SetTranslationTable(gsetNumber, translationTable); + _SetTranslationTable(gsetNumber, translationTable); } -bool TerminalOutput::Designate96Charset(size_t gsetNumber, const VTID charset) +void TerminalOutput::Designate96Charset(size_t gsetNumber, const VTID charset) { const auto translationTable = _LookupTranslationTable96(charset); - RETURN_BOOL_IF_FALSE(!translationTable.empty()); + if (translationTable.empty()) + { + return; + } + _gsetIds.at(gsetNumber) = charset; - return _SetTranslationTable(gsetNumber, translationTable); + _SetTranslationTable(gsetNumber, translationTable); } void TerminalOutput::SetDrcs94Designation(const VTID charset) @@ -118,7 +129,7 @@ size_t TerminalOutput::GetCharsetSize(const size_t gsetNumber) const } #pragma warning(suppress : 26440) // Suppress spurious "function can be declared noexcept" warning -bool TerminalOutput::LockingShift(const size_t gsetNumber) +void TerminalOutput::LockingShift(const size_t gsetNumber) { _glSetNumber = gsetNumber; _glTranslationTable = _gsetTranslationTables.at(_glSetNumber); @@ -127,11 +138,10 @@ bool TerminalOutput::LockingShift(const size_t gsetNumber) { _glTranslationTable = {}; } - return true; } #pragma warning(suppress : 26440) // Suppress spurious "function can be declared noexcept" warning -bool TerminalOutput::LockingShiftRight(const size_t gsetNumber) +void TerminalOutput::LockingShiftRight(const size_t gsetNumber) { _grSetNumber = gsetNumber; _grTranslationTable = _gsetTranslationTables.at(_grSetNumber); @@ -140,13 +150,11 @@ bool TerminalOutput::LockingShiftRight(const size_t gsetNumber) { _grTranslationTable = {}; } - return true; } -bool TerminalOutput::SingleShift(const size_t gsetNumber) noexcept +void TerminalOutput::SingleShift(const size_t gsetNumber) noexcept { _ssSetNumber = gsetNumber; - return true; } size_t TerminalOutput::GetLeftSetNumber() const noexcept @@ -325,11 +333,12 @@ const std::wstring_view TerminalOutput::_LookupTranslationTable96(const VTID cha } } -bool TerminalOutput::_SetTranslationTable(const size_t gsetNumber, const std::wstring_view translationTable) +void TerminalOutput::_SetTranslationTable(const size_t gsetNumber, const std::wstring_view translationTable) { _gsetTranslationTables.at(gsetNumber) = translationTable; // We need to reapply the locking shifts in case the underlying G-sets have changed. - return LockingShift(_glSetNumber) && LockingShiftRight(_grSetNumber); + LockingShift(_glSetNumber); + LockingShiftRight(_grSetNumber); } void TerminalOutput::_ReplaceDrcsTable(const std::wstring_view oldTable, const std::wstring_view newTable) diff --git a/src/terminal/adapter/terminalOutput.hpp b/src/terminal/adapter/terminalOutput.hpp index 5e6fff29c71..9143a2dba64 100644 --- a/src/terminal/adapter/terminalOutput.hpp +++ b/src/terminal/adapter/terminalOutput.hpp @@ -27,19 +27,19 @@ namespace Microsoft::Console::VirtualTerminal void SoftReset() noexcept; void RestoreFrom(const TerminalOutput& savedState) noexcept; - bool AssignUserPreferenceCharset(const VTID charset, const bool size96); + void AssignUserPreferenceCharset(const VTID charset, const bool size96); VTID GetUserPreferenceCharsetId() const noexcept; size_t GetUserPreferenceCharsetSize() const noexcept; wchar_t TranslateKey(const wchar_t wch) const noexcept; - bool Designate94Charset(const size_t gsetNumber, const VTID charset); - bool Designate96Charset(const size_t gsetNumber, const VTID charset); + void Designate94Charset(const size_t gsetNumber, const VTID charset); + void Designate96Charset(const size_t gsetNumber, const VTID charset); void SetDrcs94Designation(const VTID charset); void SetDrcs96Designation(const VTID charset); VTID GetCharsetId(const size_t gsetNumber) const; size_t GetCharsetSize(const size_t gsetNumber) const; - bool LockingShift(const size_t gsetNumber); - bool LockingShiftRight(const size_t gsetNumber); - bool SingleShift(const size_t gsetNumber) noexcept; + void LockingShift(const size_t gsetNumber); + void LockingShiftRight(const size_t gsetNumber); + void SingleShift(const size_t gsetNumber) noexcept; size_t GetLeftSetNumber() const noexcept; size_t GetRightSetNumber() const noexcept; bool IsSingleShiftPending(const size_t gsetNumber) const noexcept; @@ -49,7 +49,7 @@ namespace Microsoft::Console::VirtualTerminal private: const std::wstring_view _LookupTranslationTable94(const VTID charset) const; const std::wstring_view _LookupTranslationTable96(const VTID charset) const; - bool _SetTranslationTable(const size_t gsetNumber, const std::wstring_view translationTable); + void _SetTranslationTable(const size_t gsetNumber, const std::wstring_view translationTable); void _ReplaceDrcsTable(const std::wstring_view oldTable, const std::wstring_view newTable); VTID _upssId; diff --git a/src/terminal/adapter/ut_adapter/adapterTest.cpp b/src/terminal/adapter/ut_adapter/adapterTest.cpp index 7d571086edd..ab2e08d3b85 100644 --- a/src/terminal/adapter/ut_adapter/adapterTest.cpp +++ b/src/terminal/adapter/ut_adapter/adapterTest.cpp @@ -435,7 +435,7 @@ class AdapterTest Log::Comment(L"Starting test..."); // Used to switch between the various function options. - typedef bool (AdaptDispatch::*CursorMoveFunc)(VTInt); + typedef void (AdaptDispatch::*CursorMoveFunc)(VTInt); CursorMoveFunc moveFunc = nullptr; // Modify variables based on directionality of this test @@ -483,7 +483,7 @@ class AdapterTest Log::Comment(L"Test 1: Cursor doesn't move when placed in corner of viewport."); _testGetSet->PrepData(direction); - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(1)); + (_pDispatch->*moveFunc)(1); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Test 1b: Cursor moves to left of line with next/prev line command when cursor can't move higher/lower."); @@ -505,7 +505,7 @@ class AdapterTest if (fDoTest1b) { _testGetSet->_expectedCursorPos.x = 0; - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(1)); + (_pDispatch->*moveFunc)(1); _testGetSet->ValidateExpectedCursorPos(); } else @@ -541,7 +541,7 @@ class AdapterTest break; } - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(1)); + (_pDispatch->*moveFunc)(1); _testGetSet->ValidateExpectedCursorPos(); // place cursor and move it up too far. It should get bounded by the viewport. @@ -574,7 +574,7 @@ class AdapterTest break; } - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(100)); + (_pDispatch->*moveFunc)(100); _testGetSet->ValidateExpectedCursorPos(); } @@ -592,7 +592,7 @@ class AdapterTest _testGetSet->_expectedCursorPos.x = sCol - 1; _testGetSet->_expectedCursorPos.y = _testGetSet->_viewport.top + (sRow - 1); - VERIFY_IS_TRUE(_pDispatch->CursorPosition(sRow, sCol)); + _pDispatch->CursorPosition(sRow, sCol); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Test 2: Move to 0, 0 (which is 1,1 in VT speak)"); @@ -602,7 +602,7 @@ class AdapterTest _testGetSet->_expectedCursorPos.x = 0; _testGetSet->_expectedCursorPos.y = _testGetSet->_viewport.top; - VERIFY_IS_TRUE(_pDispatch->CursorPosition(1, 1)); + _pDispatch->CursorPosition(1, 1); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Test 3: Move beyond rectangle (down/right too far). Should be bounded back in."); @@ -614,7 +614,7 @@ class AdapterTest _testGetSet->_expectedCursorPos.x = _testGetSet->_textBuffer->GetSize().Dimensions().width - 1; _testGetSet->_expectedCursorPos.y = _testGetSet->_viewport.bottom - 1; - VERIFY_IS_TRUE(_pDispatch->CursorPosition(sRow, sCol)); + _pDispatch->CursorPosition(sRow, sCol); _testGetSet->ValidateExpectedCursorPos(); } @@ -627,7 +627,7 @@ class AdapterTest Log::Comment(L"Starting test..."); //// Used to switch between the various function options. - typedef bool (AdaptDispatch::*CursorMoveFunc)(VTInt); + typedef void (AdaptDispatch::*CursorMoveFunc)(VTInt); CursorMoveFunc moveFunc = nullptr; auto sRangeEnd = 0; auto sRangeStart = 0; @@ -671,7 +671,7 @@ class AdapterTest *psCursorExpected = sRangeStart + (sVal - 1); - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(sVal)); + (_pDispatch->*moveFunc)(sVal); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Test 2: Move to 0 (which is 1 in VT speak)"); @@ -680,7 +680,7 @@ class AdapterTest *psCursorExpected = sRangeStart; sVal = 1; - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(sVal)); + (_pDispatch->*moveFunc)(sVal); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Test 3: Move beyond rectangle (down/right too far). Should be bounded back in."); @@ -690,7 +690,7 @@ class AdapterTest *psCursorExpected = sRangeEnd - 1; - VERIFY_IS_TRUE((_pDispatch->*(moveFunc))(sVal)); + (_pDispatch->*moveFunc)(sVal); _testGetSet->ValidateExpectedCursorPos(); } @@ -713,13 +713,13 @@ class AdapterTest // Attributes are restored to defaults. _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->CursorRestoreState(), L"By default, restore to top left corner (0,0 offset from viewport)."); + _pDispatch->CursorRestoreState(); _testGetSet->ValidateExpectedCursorPos(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 2: Place cursor in center. Save. Move cursor to corner. Restore. Should come back to center."); _testGetSet->PrepData(CursorX::XCENTER, CursorY::YCENTER); - VERIFY_IS_TRUE(_pDispatch->CursorSaveState(), L"Succeed at saving position."); + _pDispatch->CursorSaveState(); _testGetSet->ValidateExpectedCursorPos(); Log::Comment(L"Backup expected cursor (in the middle). Move cursor to corner. Then re-set expected cursor to middle."); @@ -732,7 +732,7 @@ class AdapterTest // restore expected cursor position to center. _testGetSet->_expectedCursorPos = coordExpected; - VERIFY_IS_TRUE(_pDispatch->CursorRestoreState(), L"Restoring to corner should succeed. API call inside will test that cursor matched expected position."); + _pDispatch->CursorRestoreState(); _testGetSet->ValidateExpectedCursorPos(); _testGetSet->ValidateExpectedAttributes(); } @@ -757,11 +757,11 @@ class AdapterTest _testGetSet->_textBuffer->GetCursor().SetIsVisible(fStart); if (fEnd) { - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::DECTCEM_TextCursorEnableMode)); + _pDispatch->SetMode(DispatchTypes::DECTCEM_TextCursorEnableMode); } else { - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::DECTCEM_TextCursorEnableMode)); + _pDispatch->ResetMode(DispatchTypes::DECTCEM_TextCursorEnableMode); } VERIFY_ARE_EQUAL(fEnd, _testGetSet->_textBuffer->GetCursor().IsVisible()); } @@ -777,7 +777,7 @@ class AdapterTest VTParameter rgOptions[16]; size_t cOptions = 0; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); } @@ -1101,7 +1101,7 @@ class AdapterTest } _testGetSet->_textBuffer->SetCurrentAttributes(startingAttribute); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); } @@ -1162,7 +1162,7 @@ class AdapterTest break; } _testGetSet->_textBuffer->SetCurrentAttributes(startingAttribute); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ std::span{ rgOptions, cOptions }, subParams, subParamRanges })); + _pDispatch->SetGraphicsRendition({ std::span{ rgOptions, cOptions }, subParams, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); } @@ -1182,55 +1182,55 @@ class AdapterTest rgOptions[0] = DispatchTypes::GraphicsOptions::Off; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); cOptions = 0; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 2: Push, change color, pop"); - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundCyan; _testGetSet->_expectedAttribute = {}; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_CYAN); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); cOptions = 0; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 3: two pushes (nested) and pops"); // First push: - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundRed; _testGetSet->_expectedAttribute = {}; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_RED); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // Second push: cOptions = 0; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundGreen; _testGetSet->_expectedAttribute = {}; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // First pop: @@ -1238,13 +1238,13 @@ class AdapterTest _testGetSet->_expectedAttribute = {}; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_RED); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); // Second pop: cOptions = 0; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 4: Save and restore partial attributes"); @@ -1254,7 +1254,7 @@ class AdapterTest _testGetSet->_expectedAttribute = {}; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); cOptions = 1; @@ -1263,7 +1263,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetIntense(true); _testGetSet->_expectedAttribute.SetDefaultBackground(); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); rgOptions[0] = DispatchTypes::GraphicsOptions::BackgroundBlue; @@ -1271,7 +1271,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetIndexedBackground(TextColor::DARK_BLUE); _testGetSet->_expectedAttribute.SetIntense(true); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // Push, specifying that we only want to save the background, the intensity, and double-underline-ness: @@ -1279,7 +1279,7 @@ class AdapterTest rgStackOptions[0] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::Intense; rgStackOptions[1] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::SaveBackgroundColor; rgStackOptions[2] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::DoublyUnderlined; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); // Now change everything... cOptions = 2; @@ -1290,7 +1290,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedBackground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetIntense(true); _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); cOptions = 1; @@ -1300,7 +1300,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedBackground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetIntense(true); _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); rgOptions[0] = DispatchTypes::GraphicsOptions::NotIntenseOrFaint; @@ -1308,7 +1308,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_RED); _testGetSet->_expectedAttribute.SetIndexedBackground(TextColor::DARK_GREEN); _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // And then restore... @@ -1317,7 +1317,7 @@ class AdapterTest _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_RED); _testGetSet->_expectedAttribute.SetIndexedBackground(TextColor::DARK_BLUE); _testGetSet->_expectedAttribute.SetIntense(true); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 5: Save 'no singly underline' state, set singly underlined, and pop. " @@ -1326,24 +1326,24 @@ class AdapterTest cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::NoUnderline; _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::NoUnderline); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // save 'no underlined' state cOptions = 1; rgStackOptions[0] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::Underline; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); // set underlined cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::Underline; _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::SinglyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // restore, expect no underline _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::NoUnderline); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 6: Save 'no singly underlined' state, set doubly underlined, and pop. " @@ -1352,24 +1352,24 @@ class AdapterTest cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::NoUnderline; _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::NoUnderline); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // save no underline state cOptions = 1; rgStackOptions[0] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::Underline; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); // set doubly underlined cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::DoublyUnderlined; _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // restore, expect doubly underlined _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 7: Save 'curly underlined' state, set doubly underlined, and pop. " @@ -1379,24 +1379,24 @@ class AdapterTest rgOptions[0] = DispatchTypes::GraphicsOptions::Underline; _testGetSet->MakeSubParamsAndRanges({ { 3 } }, subParams, subParamRanges); _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::CurlyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ std::span{ rgOptions, cOptions }, subParams, subParamRanges })); + _pDispatch->SetGraphicsRendition({ std::span{ rgOptions, cOptions }, subParams, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); // save curly underlined state cOptions = 1; rgStackOptions[0] = (size_t)DispatchTypes::SgrSaveRestoreStackOptions::Underline; - VERIFY_IS_TRUE(_pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions })); + _pDispatch->PushGraphicsRendition({ rgStackOptions, cOptions }); // set doubly underlined cOptions = 1; rgOptions[0] = DispatchTypes::GraphicsOptions::DoublyUnderlined; _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); // restore, expect curly underlined _testGetSet->_expectedAttribute.SetUnderlineStyle(UnderlineStyle::CurlyUnderlined); - VERIFY_IS_TRUE(_pDispatch->PopGraphicsRendition()); + _pDispatch->PopGraphicsRendition(); _testGetSet->ValidateExpectedAttributes(); } @@ -1413,26 +1413,26 @@ class AdapterTest Log::Comment(L"Resetting graphics options"); rgOptions[0] = DispatchTypes::GraphicsOptions::Off; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Blue'"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Enabling brightness"); rgOptions[0] = DispatchTypes::GraphicsOptions::Intense; _testGetSet->_expectedAttribute.SetIntense(true); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Green, with brightness'"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundGreen; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(WI_IsFlagSet(_testGetSet->_textBuffer->GetCurrentAttributes().GetLegacyAttributes(), FOREGROUND_GREEN)); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); @@ -1441,7 +1441,7 @@ class AdapterTest Log::Comment(L"Resetting graphics options"); rgOptions[0] = DispatchTypes::GraphicsOptions::Off; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(WI_IsFlagClear(_testGetSet->_textBuffer->GetCurrentAttributes().GetLegacyAttributes(), FOREGROUND_INTENSITY)); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); @@ -1449,14 +1449,14 @@ class AdapterTest Log::Comment(L"Testing graphics 'Foreground Color Bright Blue'"); rgOptions[0] = DispatchTypes::GraphicsOptions::BrightForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::BRIGHT_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Blue', brightness of 9x series doesn't persist"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); @@ -1464,62 +1464,53 @@ class AdapterTest Log::Comment(L"Resetting graphics options"); rgOptions[0] = DispatchTypes::GraphicsOptions::Off; _testGetSet->_expectedAttribute = {}; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Blue'"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Enabling brightness"); rgOptions[0] = DispatchTypes::GraphicsOptions::Intense; _testGetSet->_expectedAttribute.SetIntense(true); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Bright Blue'"); rgOptions[0] = DispatchTypes::GraphicsOptions::BrightForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::BRIGHT_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Blue, with brightness', brightness of 9x series doesn't affect brightness"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundBlue; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_BLUE); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Testing graphics 'Foreground Color Green, with brightness'"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundGreen; _testGetSet->_expectedAttribute.SetIndexedForeground(TextColor::DARK_GREEN); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCurrentAttributes().IsIntense()); _testGetSet->ValidateExpectedAttributes(); } - TEST_METHOD(DeviceStatusReportTests) - { - Log::Comment(L"Starting test..."); - - Log::Comment(L"Test 1: Verify failure when using bad status."); - _testGetSet->PrepData(); - VERIFY_IS_FALSE(_pDispatch->DeviceStatusReport((DispatchTypes::StatusType)-1, {})); - } - TEST_METHOD(DeviceStatus_OperatingStatusTests) { Log::Comment(L"Starting test..."); Log::Comment(L"Test 1: Verify good operating condition."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::OperatingStatus, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::OperatingStatus, {}); _testGetSet->ValidateInputEvent(L"\x1b[0n"); } @@ -1542,7 +1533,7 @@ class AdapterTest coordCursorExpected.x++; coordCursorExpected.y++; - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {}); wchar_t pwszBuffer[50]; @@ -1566,7 +1557,7 @@ class AdapterTest // Then note that VT is 1,1 based for the top left, so add 1. (The rest of the console uses 0,0 for array index bases.) coordCursorExpectedFirst += til::point{ 1, 1 }; - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {}); auto cursorPos = _testGetSet->_textBuffer->GetCursor().GetPosition(); cursorPos.x++; @@ -1576,7 +1567,7 @@ class AdapterTest auto coordCursorExpectedSecond{ coordCursorExpectedFirst }; coordCursorExpectedSecond += til::point{ 1, 1 }; - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::CursorPositionReport, {}); wchar_t pwszBuffer[50]; @@ -1605,7 +1596,7 @@ class AdapterTest // By default, the initial page number should be 1. auto pageExpected = 1; - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::ExtendedCursorPositionReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::ExtendedCursorPositionReport, {}); wchar_t pwszBuffer[50]; swprintf_s(pwszBuffer, ARRAYSIZE(pwszBuffer), L"\x1b[?%d;%d;%dR", coordCursorExpected.y, coordCursorExpected.x, pageExpected); @@ -1615,7 +1606,7 @@ class AdapterTest pageExpected = 3; _pDispatch->PagePositionAbsolute(pageExpected); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::ExtendedCursorPositionReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::ExtendedCursorPositionReport, {}); swprintf_s(pwszBuffer, ARRAYSIZE(pwszBuffer), L"\x1b[?%d;%d;%dR", coordCursorExpected.y, coordCursorExpected.x, pageExpected); _testGetSet->ValidateInputEvent(pwszBuffer); @@ -1630,7 +1621,7 @@ class AdapterTest Log::Comment(L"Test 1: Verify maximum space available"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {}); wchar_t pwszBuffer[50]; swprintf_s(pwszBuffer, ARRAYSIZE(pwszBuffer), L"\x1b[%zu*{", availableSpace); @@ -1643,15 +1634,15 @@ class AdapterTest _stateMachine->ProcessString(L"\033P2;0;0!z12345678\033\\"); _stateMachine->ProcessString(L"\033P3;0;0!z12345678\033\\"); _stateMachine->ProcessString(L"\033P4;0;0!z12345678\033\\"); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {}); swprintf_s(pwszBuffer, ARRAYSIZE(pwszBuffer), L"\x1b[%zu*{", availableSpace - 2); _testGetSet->ValidateInputEvent(pwszBuffer); Log::Comment(L"Test 3: Verify space reset"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->HardReset()); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {})); + _pDispatch->HardReset(); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MacroSpaceReport, {}); swprintf_s(pwszBuffer, ARRAYSIZE(pwszBuffer), L"\x1b[%zu*{", availableSpace); _testGetSet->ValidateInputEvent(pwszBuffer); @@ -1663,7 +1654,7 @@ class AdapterTest Log::Comment(L"Test 1: Verify initial checksum is 0"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 12)); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 12); _testGetSet->ValidateInputEvent(L"\033P12!~0000\033\\"); @@ -1672,7 +1663,7 @@ class AdapterTest // Define a couple of text macros _stateMachine->ProcessString(L"\033P1;0;0!zABCD\033\\"); _stateMachine->ProcessString(L"\033P2;0;0!zabcd\033\\"); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 34)); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 34); // Checksum is a 16-bit negated sum of the macro buffer characters. const auto checksum = gsl::narrow_cast(-('A' + 'B' + 'C' + 'D' + 'a' + 'b' + 'c' + 'd')); @@ -1682,8 +1673,8 @@ class AdapterTest Log::Comment(L"Test 3: Verify checksum resets to 0"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->HardReset()); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 56)); + _pDispatch->HardReset(); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MemoryChecksum, 56); _testGetSet->ValidateInputEvent(L"\033P56!~0000\033\\"); } @@ -1694,37 +1685,37 @@ class AdapterTest Log::Comment(L"Test 1: Verify printer is not connected."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::PrinterStatus, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::PrinterStatus, {}); _testGetSet->ValidateInputEvent(L"\x1b[?13n"); Log::Comment(L"Test 2: Verify UDKs are not supported."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::UserDefinedKeys, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::UserDefinedKeys, {}); _testGetSet->ValidateInputEvent(L"\x1b[?23n"); Log::Comment(L"Test 3: Verify PC keyboard with unknown dialect."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::KeyboardStatus, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::KeyboardStatus, {}); _testGetSet->ValidateInputEvent(L"\x1b[?27;0;0;5n"); Log::Comment(L"Test 4: Verify locator is not connected."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::LocatorStatus, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::LocatorStatus, {}); _testGetSet->ValidateInputEvent(L"\x1b[?53n"); Log::Comment(L"Test 5: Verify locator type is unknown."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::LocatorIdentity, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::LocatorIdentity, {}); _testGetSet->ValidateInputEvent(L"\x1b[?57;0n"); Log::Comment(L"Test 6: Verify terminal is ready."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::DataIntegrity, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::DataIntegrity, {}); _testGetSet->ValidateInputEvent(L"\x1b[?70n"); Log::Comment(L"Test 7: Verify multiple sessions are not supported."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MultipleSessionStatus, {})); + _pDispatch->DeviceStatusReport(DispatchTypes::StatusType::MultipleSessionStatus, {}); _testGetSet->ValidateInputEvent(L"\x1b[?83n"); } @@ -1734,7 +1725,7 @@ class AdapterTest Log::Comment(L"Test 1: Verify normal response."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->DeviceAttributes()); + _pDispatch->DeviceAttributes(); auto pwszExpectedResponse = L"\x1b[?61;4;6;7;14;21;22;23;24;28;32;42c"; _testGetSet->ValidateInputEvent(pwszExpectedResponse); @@ -1752,7 +1743,7 @@ class AdapterTest Log::Comment(L"Test 1: Verify normal response."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->SecondaryDeviceAttributes()); + _pDispatch->SecondaryDeviceAttributes(); auto pwszExpectedResponse = L"\x1b[>0;10;1c"; _testGetSet->ValidateInputEvent(pwszExpectedResponse); @@ -1770,7 +1761,7 @@ class AdapterTest Log::Comment(L"Test 1: Verify normal response."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->TertiaryDeviceAttributes()); + _pDispatch->TertiaryDeviceAttributes(); auto pwszExpectedResponse = L"\x1bP!|00000000\x1b\\"; _testGetSet->ValidateInputEvent(pwszExpectedResponse); @@ -1792,29 +1783,29 @@ class AdapterTest _testGetSet->_viewport.right = 80; _testGetSet->_viewport.top = 0; _testGetSet->_viewport.bottom = 24; - VERIFY_IS_TRUE(_pDispatch->RequestDisplayedExtent()); + _pDispatch->RequestDisplayedExtent(); _testGetSet->ValidateInputEvent(L"\x1b[24;80;1;1;1\"w"); Log::Comment(L"Test 2: Verify DECRQDE response when panned horizontally"); _testGetSet->_viewport.left += 5; _testGetSet->_viewport.right += 5; - VERIFY_IS_TRUE(_pDispatch->RequestDisplayedExtent()); + _pDispatch->RequestDisplayedExtent(); _testGetSet->ValidateInputEvent(L"\x1b[24;80;6;1;1\"w"); Log::Comment(L"Test 3: Verify DECRQDE response on page 3"); _pDispatch->PagePositionAbsolute(3); - VERIFY_IS_TRUE(_pDispatch->RequestDisplayedExtent()); + _pDispatch->RequestDisplayedExtent(); _testGetSet->ValidateInputEvent(L"\x1b[24;80;6;1;3\"w"); Log::Comment(L"Test 3: Verify DECRQDE response when active page not visible"); _pDispatch->ResetMode(DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode); _pDispatch->PagePositionAbsolute(1); - VERIFY_IS_TRUE(_pDispatch->RequestDisplayedExtent()); + _pDispatch->RequestDisplayedExtent(); _testGetSet->ValidateInputEvent(L"\x1b[24;80;6;1;3\"w"); Log::Comment(L"Test 4: Verify DECRQDE response when page 1 visible again"); _pDispatch->SetMode(DispatchTypes::ModeParams::DECPCCM_PageCursorCouplingMode); - VERIFY_IS_TRUE(_pDispatch->RequestDisplayedExtent()); + _pDispatch->RequestDisplayedExtent(); _testGetSet->ValidateInputEvent(L"\x1b[24;80;6;1;1\"w"); } @@ -1824,19 +1815,15 @@ class AdapterTest Log::Comment(L"Test 1: Verify response for unsolicited permission."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->RequestTerminalParameters(DispatchTypes::ReportingPermission::Unsolicited)); + _pDispatch->RequestTerminalParameters(DispatchTypes::ReportingPermission::Unsolicited); _testGetSet->ValidateInputEvent(L"\x1b[2;1;1;128;128;1;0x"); Log::Comment(L"Test 2: Verify response for solicited permission."); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->RequestTerminalParameters(DispatchTypes::ReportingPermission::Solicited)); + _pDispatch->RequestTerminalParameters(DispatchTypes::ReportingPermission::Solicited); _testGetSet->ValidateInputEvent(L"\x1b[3;1;1;128;128;1;0x"); - Log::Comment(L"Test 3: Verify failure with invalid parameter."); - _testGetSet->PrepData(); - VERIFY_IS_FALSE(_pDispatch->RequestTerminalParameters((DispatchTypes::ReportingPermission)2)); - - Log::Comment(L"Test 4: Verify failure when ReturnResponse doesn't work."); + Log::Comment(L"Test 3: Verify failure when ReturnResponse doesn't work."); _testGetSet->PrepData(); _testGetSet->_returnResponseResult = FALSE; VERIFY_THROWS(_pDispatch->RequestTerminalParameters(DispatchTypes::ReportingPermission::Unsolicited), std::exception); @@ -2084,8 +2071,8 @@ class AdapterTest // DISABLE_ Log::Comment(NoThrowString().Format(L"Setting standard mode %d", modeNumber)); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->SetMode(mode)); - VERIFY_IS_TRUE(_pDispatch->RequestMode(mode)); + _pDispatch->SetMode(mode); + _pDispatch->RequestMode(mode); wchar_t expectedResponse[20]; swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[%d;1$y", modeNumber); @@ -2093,8 +2080,8 @@ class AdapterTest Log::Comment(NoThrowString().Format(L"Resetting standard mode %d", modeNumber)); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->ResetMode(mode)); - VERIFY_IS_TRUE(_pDispatch->RequestMode(mode)); + _pDispatch->ResetMode(mode); + _pDispatch->RequestMode(mode); swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[%d;2$y", modeNumber); _testGetSet->ValidateInputEvent(expectedResponse); @@ -2118,13 +2105,13 @@ class AdapterTest if (mode == DispatchTypes::DECCOLM_SetNumberOfColumns) { Log::Comment(L"Make sure DECCOLM is allowed"); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::XTERM_EnableDECCOLMSupport)); + _pDispatch->SetMode(DispatchTypes::XTERM_EnableDECCOLMSupport); } Log::Comment(NoThrowString().Format(L"Setting private mode %d", modeNumber)); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->SetMode(mode)); - VERIFY_IS_TRUE(_pDispatch->RequestMode(mode)); + _pDispatch->SetMode(mode); + _pDispatch->RequestMode(mode); wchar_t expectedResponse[20]; swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[?%d;1$y", modeNumber); @@ -2132,8 +2119,8 @@ class AdapterTest Log::Comment(NoThrowString().Format(L"Resetting private mode %d", modeNumber)); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->ResetMode(mode)); - VERIFY_IS_TRUE(_pDispatch->RequestMode(mode)); + _pDispatch->ResetMode(mode); + _pDispatch->RequestMode(mode); swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[?%d;2$y", modeNumber); _testGetSet->ValidateInputEvent(expectedResponse); @@ -2150,8 +2137,8 @@ class AdapterTest const auto mode = DispatchTypes::DECPrivateMode(modeNumber); _testGetSet->PrepData(); - VERIFY_IS_TRUE(_pDispatch->ResetMode(mode)); // as a test to ensure that it stays permanently enabled (= 3) - VERIFY_IS_TRUE(_pDispatch->RequestMode(mode)); + _pDispatch->ResetMode(mode); // as a test to ensure that it stays permanently enabled (= 3) + _pDispatch->RequestMode(mode); wchar_t expectedResponse[20]; swprintf_s(expectedResponse, ARRAYSIZE(expectedResponse), L"\x1b[?%d;3$y", modeNumber); @@ -2840,12 +2827,12 @@ class AdapterTest // success cases // set numeric mode = true Log::Comment(L"Test 1: application mode = false"); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::DECCKM_CursorKeysMode)); + _pDispatch->ResetMode(DispatchTypes::DECCKM_CursorKeysMode); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::CursorKey)); // set numeric mode = false Log::Comment(L"Test 2: application mode = true"); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::DECCKM_CursorKeysMode)); + _pDispatch->SetMode(DispatchTypes::DECCKM_CursorKeysMode); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::CursorKey)); } @@ -2857,12 +2844,12 @@ class AdapterTest // success cases // set numeric mode = true Log::Comment(L"Test 1: application mode = false"); - VERIFY_IS_TRUE(_pDispatch->SetKeypadMode(false)); + _pDispatch->SetKeypadMode(false); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::Keypad)); // set numeric mode = false Log::Comment(L"Test 2: application mode = true"); - VERIFY_IS_TRUE(_pDispatch->SetKeypadMode(true)); + _pDispatch->SetKeypadMode(true); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::Keypad)); } @@ -2874,12 +2861,12 @@ class AdapterTest // success cases // set ansi mode = true Log::Comment(L"Test 1: ansi mode = true"); - VERIFY_IS_TRUE(_pDispatch->SetAnsiMode(true)); + _pDispatch->SetAnsiMode(true); VERIFY_IS_TRUE(_stateMachine->GetParserMode(StateMachine::Mode::Ansi)); // set ansi mode = false Log::Comment(L"Test 2: ansi mode = false."); - VERIFY_IS_TRUE(_pDispatch->SetAnsiMode(false)); + _pDispatch->SetAnsiMode(false); VERIFY_IS_FALSE(_stateMachine->GetParserMode(StateMachine::Mode::Ansi)); } @@ -2893,13 +2880,13 @@ class AdapterTest // set blinking mode = true Log::Comment(L"Test 1: enable blinking = true"); _testGetSet->_textBuffer->GetCursor().SetBlinkingAllowed(false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::ATT610_StartCursorBlink)); + _pDispatch->SetMode(DispatchTypes::ATT610_StartCursorBlink); VERIFY_IS_TRUE(_testGetSet->_textBuffer->GetCursor().IsBlinkingAllowed()); // set blinking mode = false Log::Comment(L"Test 2: enable blinking = false"); _testGetSet->_textBuffer->GetCursor().SetBlinkingAllowed(true); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::ATT610_StartCursorBlink)); + _pDispatch->ResetMode(DispatchTypes::ATT610_StartCursorBlink); VERIFY_IS_FALSE(_testGetSet->_textBuffer->GetCursor().IsBlinkingAllowed()); } @@ -2914,63 +2901,63 @@ class AdapterTest auto sScreenHeight = _testGetSet->_viewport.bottom - _testGetSet->_viewport.top; Log::Comment(L"Test 1: Verify having both values is valid."); - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(2, 6)); + _pDispatch->SetTopBottomScrollingMargins(2, 6); VERIFY_ARE_EQUAL(2, _pDispatch->_scrollMargins.top + 1); VERIFY_ARE_EQUAL(6, _pDispatch->_scrollMargins.bottom + 1); Log::Comment(L"Test 2: Verify having only top is valid."); - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(7, 0)); + _pDispatch->SetTopBottomScrollingMargins(7, 0); VERIFY_ARE_EQUAL(7, _pDispatch->_scrollMargins.top + 1); VERIFY_ARE_EQUAL(sScreenHeight, _pDispatch->_scrollMargins.bottom + 1); Log::Comment(L"Test 3: Verify having only bottom is valid."); - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(0, 7)); + _pDispatch->SetTopBottomScrollingMargins(0, 7); VERIFY_ARE_EQUAL(1, _pDispatch->_scrollMargins.top + 1); VERIFY_ARE_EQUAL(7, _pDispatch->_scrollMargins.bottom + 1); Log::Comment(L"Test 4: Verify having no values is valid."); - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(0, 0)); + _pDispatch->SetTopBottomScrollingMargins(0, 0); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 5: Verify having both values, but bad bounds has no effect."); _pDispatch->_scrollMargins = {}; - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(7, 3)); + _pDispatch->SetTopBottomScrollingMargins(7, 3); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 6: Verify setting margins to (0, height) clears them"); // First set, - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(2, 6)); + _pDispatch->SetTopBottomScrollingMargins(2, 6); // Then clear - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(0, sScreenHeight)); + _pDispatch->SetTopBottomScrollingMargins(0, sScreenHeight); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 7: Verify setting margins to (1, height) clears them"); // First set, - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(2, 6)); + _pDispatch->SetTopBottomScrollingMargins(2, 6); // Then clear - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(1, sScreenHeight)); + _pDispatch->SetTopBottomScrollingMargins(1, sScreenHeight); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 8: Verify setting margins to (1, 0) clears them"); // First set, - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(2, 6)); + _pDispatch->SetTopBottomScrollingMargins(2, 6); // Then clear - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(1, 0)); + _pDispatch->SetTopBottomScrollingMargins(1, 0); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 9: Verify having top and bottom margin the same has no effect."); _pDispatch->_scrollMargins = {}; - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(4, 4)); + _pDispatch->SetTopBottomScrollingMargins(4, 4); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 10: Verify having top margin out of bounds has no effect."); _pDispatch->_scrollMargins = {}; - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(sScreenHeight + 1, sScreenHeight + 10)); + _pDispatch->SetTopBottomScrollingMargins(sScreenHeight + 1, sScreenHeight + 10); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); Log::Comment(L"Test 11: Verify having bottom margin out of bounds has no effect."); _pDispatch->_scrollMargins = {}; - VERIFY_IS_TRUE(_pDispatch->SetTopBottomScrollingMargins(1, sScreenHeight + 1)); + _pDispatch->SetTopBottomScrollingMargins(1, sScreenHeight + 1); VERIFY_ARE_EQUAL(til::inclusive_rect{}, _pDispatch->_scrollMargins); } @@ -2983,24 +2970,24 @@ class AdapterTest Log::Comment(L"Test 1: Line feed without carriage return."); cursor.SetPosition({ 10, 0 }); - VERIFY_IS_TRUE(_pDispatch->LineFeed(DispatchTypes::LineFeedType::WithoutReturn)); + _pDispatch->LineFeed(DispatchTypes::LineFeedType::WithoutReturn); VERIFY_ARE_EQUAL(til::point(10, 1), cursor.GetPosition()); Log::Comment(L"Test 2: Line feed with carriage return."); cursor.SetPosition({ 10, 0 }); - VERIFY_IS_TRUE(_pDispatch->LineFeed(DispatchTypes::LineFeedType::WithReturn)); + _pDispatch->LineFeed(DispatchTypes::LineFeedType::WithReturn); VERIFY_ARE_EQUAL(til::point(0, 1), cursor.GetPosition()); Log::Comment(L"Test 3: Line feed depends on mode, and mode reset."); _testGetSet->_systemMode.reset(ITerminalApi::Mode::LineFeed); cursor.SetPosition({ 10, 0 }); - VERIFY_IS_TRUE(_pDispatch->LineFeed(DispatchTypes::LineFeedType::DependsOnMode)); + _pDispatch->LineFeed(DispatchTypes::LineFeedType::DependsOnMode); VERIFY_ARE_EQUAL(til::point(10, 1), cursor.GetPosition()); Log::Comment(L"Test 4: Line feed depends on mode, and mode set."); _testGetSet->_systemMode.set(ITerminalApi::Mode::LineFeed); cursor.SetPosition({ 10, 0 }); - VERIFY_IS_TRUE(_pDispatch->LineFeed(DispatchTypes::LineFeedType::DependsOnMode)); + _pDispatch->LineFeed(DispatchTypes::LineFeedType::DependsOnMode); VERIFY_ARE_EQUAL(til::point(0, 1), cursor.GetPosition()); } @@ -3012,13 +2999,13 @@ class AdapterTest _testGetSet->_setWindowTitleResult = TRUE; _testGetSet->_expectedWindowTitle = L"Foo bar"; - VERIFY_IS_TRUE(_pDispatch->SetWindowTitle(_testGetSet->_expectedWindowTitle)); + _pDispatch->SetWindowTitle(_testGetSet->_expectedWindowTitle); Log::Comment(L"Test 2: set title to be null"); _testGetSet->_setWindowTitleResult = FALSE; _testGetSet->_expectedWindowTitle = {}; - VERIFY_IS_TRUE(_pDispatch->SetWindowTitle({})); + _pDispatch->SetWindowTitle({}); } TEST_METHOD(TestMouseModes) @@ -3027,44 +3014,44 @@ class AdapterTest Log::Comment(L"Test 1: Test Default Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::DefaultMouseTracking, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::VT200_MOUSE_MODE)); + _pDispatch->SetMode(DispatchTypes::VT200_MOUSE_MODE); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::DefaultMouseTracking)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::VT200_MOUSE_MODE)); + _pDispatch->ResetMode(DispatchTypes::VT200_MOUSE_MODE); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::DefaultMouseTracking)); Log::Comment(L"Test 2: Test UTF-8 Extended Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::Utf8MouseEncoding, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::UTF8_EXTENDED_MODE)); + _pDispatch->SetMode(DispatchTypes::UTF8_EXTENDED_MODE); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::Utf8MouseEncoding)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::UTF8_EXTENDED_MODE)); + _pDispatch->ResetMode(DispatchTypes::UTF8_EXTENDED_MODE); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::Utf8MouseEncoding)); Log::Comment(L"Test 3: Test SGR Extended Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::SgrMouseEncoding, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::SGR_EXTENDED_MODE)); + _pDispatch->SetMode(DispatchTypes::SGR_EXTENDED_MODE); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::SgrMouseEncoding)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::SGR_EXTENDED_MODE)); + _pDispatch->ResetMode(DispatchTypes::SGR_EXTENDED_MODE); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::SgrMouseEncoding)); Log::Comment(L"Test 4: Test Button-Event Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::ButtonEventMouseTracking, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::BUTTON_EVENT_MOUSE_MODE)); + _pDispatch->SetMode(DispatchTypes::BUTTON_EVENT_MOUSE_MODE); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::ButtonEventMouseTracking)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::BUTTON_EVENT_MOUSE_MODE)); + _pDispatch->ResetMode(DispatchTypes::BUTTON_EVENT_MOUSE_MODE); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::ButtonEventMouseTracking)); Log::Comment(L"Test 5: Test Any-Event Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::AnyEventMouseTracking, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::ANY_EVENT_MOUSE_MODE)); + _pDispatch->SetMode(DispatchTypes::ANY_EVENT_MOUSE_MODE); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::AnyEventMouseTracking)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::ANY_EVENT_MOUSE_MODE)); + _pDispatch->ResetMode(DispatchTypes::ANY_EVENT_MOUSE_MODE); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::AnyEventMouseTracking)); Log::Comment(L"Test 6: Test Alt Scroll Mouse Mode"); _terminalInput.SetInputMode(TerminalInput::Mode::AlternateScroll, false); - VERIFY_IS_TRUE(_pDispatch->SetMode(DispatchTypes::ALTERNATE_SCROLL)); + _pDispatch->SetMode(DispatchTypes::ALTERNATE_SCROLL); VERIFY_IS_TRUE(_terminalInput.GetInputMode(TerminalInput::Mode::AlternateScroll)); - VERIFY_IS_TRUE(_pDispatch->ResetMode(DispatchTypes::ALTERNATE_SCROLL)); + _pDispatch->ResetMode(DispatchTypes::ALTERNATE_SCROLL); VERIFY_IS_FALSE(_terminalInput.GetInputMode(TerminalInput::Mode::AlternateScroll)); } @@ -3084,7 +3071,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = (DispatchTypes::GraphicsOptions)2; // Green _testGetSet->_expectedAttribute.SetIndexedForeground256(TextColor::DARK_GREEN); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 2: Change Background"); @@ -3092,7 +3079,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = (DispatchTypes::GraphicsOptions)9; // Bright Red _testGetSet->_expectedAttribute.SetIndexedBackground256(TextColor::BRIGHT_RED); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 3: Change Foreground to RGB color"); @@ -3100,7 +3087,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = (DispatchTypes::GraphicsOptions)42; // Arbitrary Color _testGetSet->_expectedAttribute.SetIndexedForeground256(42); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 4: Change Background to RGB color"); @@ -3108,7 +3095,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = (DispatchTypes::GraphicsOptions)142; // Arbitrary Color _testGetSet->_expectedAttribute.SetIndexedBackground256(142); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 5: Change Foreground to Legacy Attr while BG is RGB color"); @@ -3119,7 +3106,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = (DispatchTypes::GraphicsOptions)9; // Bright Red _testGetSet->_expectedAttribute.SetIndexedForeground256(TextColor::BRIGHT_RED); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, cOptions })); + _pDispatch->SetGraphicsRendition({ rgOptions, cOptions }); _testGetSet->ValidateExpectedAttributes(); } @@ -3137,7 +3124,7 @@ class AdapterTest rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundExtended; rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; _testGetSet->_expectedAttribute.SetIndexedForeground256(TextColor::DARK_BLACK); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 2 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 2 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 2: Change Indexed Background with default index parameter"); @@ -3145,14 +3132,14 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::BlinkOrXterm256Index; rgOptions[2] = {}; _testGetSet->_expectedAttribute.SetIndexedBackground256(TextColor::DARK_BLACK); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 3 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 3 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 3: Change RGB Foreground with all RGB parameters missing"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundExtended; rgOptions[1] = DispatchTypes::GraphicsOptions::RGBColorOrFaint; _testGetSet->_expectedAttribute.SetForeground(RGB(0, 0, 0)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 2 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 2 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 4: Change RGB Background with some missing RGB parameters"); @@ -3160,7 +3147,7 @@ class AdapterTest rgOptions[1] = DispatchTypes::GraphicsOptions::RGBColorOrFaint; rgOptions[2] = 123; _testGetSet->_expectedAttribute.SetBackground(RGB(123, 0, 0)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 3 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 3 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 5: Change RGB Foreground with some default RGB parameters"); @@ -3170,7 +3157,7 @@ class AdapterTest rgOptions[3] = {}; rgOptions[4] = 123; _testGetSet->_expectedAttribute.SetForeground(RGB(0, 0, 123)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 5 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 5 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 6: Ignore Rgb color when R, G or B is out of range (>255)"); @@ -3182,7 +3169,7 @@ class AdapterTest rgOptions[4] = 123; // expect no change _testGetSet->_expectedAttribute = TextAttribute{ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED }; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 5 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 5 }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 7: Ignore indexed color when index is out of range (>255)"); @@ -3192,7 +3179,7 @@ class AdapterTest rgOptions[2] = 283; // expect no change _testGetSet->_expectedAttribute = TextAttribute{ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED }; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, 3 })); + _pDispatch->SetGraphicsRendition({ rgOptions, 3 }); _testGetSet->ValidateExpectedAttributes(); } @@ -3212,35 +3199,35 @@ class AdapterTest rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundExtended; _testGetSet->MakeSubParamsAndRanges({ { 5 } }, rgSubParamOpts, subParamRanges); _testGetSet->_expectedAttribute.SetIndexedForeground256(TextColor::DARK_BLACK); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 2: Change Indexed Background with default index sub parameter"); rgOptions[0] = DispatchTypes::GraphicsOptions::BackgroundExtended; _testGetSet->MakeSubParamsAndRanges({ { 5, {} } }, rgSubParamOpts, subParamRanges); _testGetSet->_expectedAttribute.SetIndexedBackground256(TextColor::DARK_BLACK); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 3: Change RGB Foreground with all RGB sub parameters missing"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundExtended; _testGetSet->MakeSubParamsAndRanges({ { 2 } }, rgSubParamOpts, subParamRanges); _testGetSet->_expectedAttribute.SetForeground(RGB(0, 0, 0)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 4: Change RGB Background with some missing RGB sub parameters"); rgOptions[0] = DispatchTypes::GraphicsOptions::BackgroundExtended; _testGetSet->MakeSubParamsAndRanges({ { 2, {}, 123 } }, rgSubParamOpts, subParamRanges); _testGetSet->_expectedAttribute.SetBackground(RGB(123, 0, 0)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 5: Change RGB Foreground with some default RGB sub parameters"); rgOptions[0] = DispatchTypes::GraphicsOptions::ForegroundExtended; _testGetSet->MakeSubParamsAndRanges({ { 2, {}, {}, {}, 123 } }, rgSubParamOpts, subParamRanges); _testGetSet->_expectedAttribute.SetForeground(RGB(0, 0, 123)); - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 6: Ignore color when ColorSpaceID is not empty"); @@ -3249,7 +3236,7 @@ class AdapterTest _testGetSet->MakeSubParamsAndRanges({ { 2, 7, 182, 182, 123 } }, rgSubParamOpts, subParamRanges); // expect no change _testGetSet->_expectedAttribute = TextAttribute{ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED }; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 7: Ignore Rgb color when R, G or B is out of range (>255)"); @@ -3260,7 +3247,7 @@ class AdapterTest _testGetSet->MakeSubParamsAndRanges({ { 2, {}, 128, 283, 155 } }, rgSubParamOpts, subParamRanges); // expect no change _testGetSet->_expectedAttribute = TextAttribute{ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED }; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); Log::Comment(L"Test 8: Ignore indexed color when index is out of range (>255)"); @@ -3269,7 +3256,7 @@ class AdapterTest _testGetSet->MakeSubParamsAndRanges({ { 5, 283 } }, rgSubParamOpts, subParamRanges); // expect no change _testGetSet->_expectedAttribute = TextAttribute{ FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED }; - VERIFY_IS_TRUE(_pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges })); + _pDispatch->SetGraphicsRendition({ rgOptions, rgSubParamOpts, subParamRanges }); _testGetSet->ValidateExpectedAttributes(); } @@ -3282,7 +3269,7 @@ class AdapterTest for (size_t i = 0; i < 256; i++) { - VERIFY_IS_TRUE(_pDispatch->SetColorTableEntry(i, testColor)); + _pDispatch->SetColorTableEntry(i, testColor); VERIFY_ARE_EQUAL(testColor, renderSettings.GetColorTableEntry(i)); } } @@ -3298,16 +3285,28 @@ class AdapterTest const auto decdld = [&](const auto cmw, const auto cmh, const auto ss, const auto u, const std::wstring_view data = {}) { const auto cellMatrix = static_cast(cmw); - RETURN_BOOL_IF_FALSE(fontBuffer.SetEraseControl(DispatchTypes::DrcsEraseControl::AllChars)); - RETURN_BOOL_IF_FALSE(fontBuffer.SetAttributes(cellMatrix, cmh, ss, u)); - RETURN_BOOL_IF_FALSE(fontBuffer.SetStartChar(0, DispatchTypes::CharsetSize::Size94)); + if (!fontBuffer.SetEraseControl(DispatchTypes::DrcsEraseControl::AllChars)) + { + return false; + } + if (!fontBuffer.SetAttributes(cellMatrix, cmh, ss, u)) + { + return false; + } + if (!fontBuffer.SetStartChar(0, DispatchTypes::CharsetSize::Size94)) + { + return false; + } fontBuffer.AddSixelData(L'B'); // Charset identifier for (auto ch : data) { fontBuffer.AddSixelData(ch); } - RETURN_BOOL_IF_FALSE(fontBuffer.FinalizeSixelData()); + if (!fontBuffer.FinalizeSixelData()) + { + return false; + } const auto cellSize = fontBuffer.GetCellSize(); Log::Comment(NoThrowString().Format(L"Cell size: %dx%d", cellSize.width, cellSize.height)); @@ -3521,25 +3520,25 @@ class AdapterTest _stateMachine->SetParserMode(StateMachine::Mode::AcceptC1, false); Log::Comment(L"1. Accept C1 controls"); - VERIFY_IS_TRUE(_pDispatch->AcceptC1Controls(true)); + _pDispatch->AcceptC1Controls(true); VERIFY_IS_TRUE(_stateMachine->GetParserMode(StateMachine::Mode::AcceptC1)); Log::Comment(L"2. Don't accept C1 controls"); - VERIFY_IS_TRUE(_pDispatch->AcceptC1Controls(false)); + _pDispatch->AcceptC1Controls(false); VERIFY_IS_FALSE(_stateMachine->GetParserMode(StateMachine::Mode::AcceptC1)); Log::Comment(L"3. Designate ISO-2022 coding system"); // Code page should be set to ISO-8859-1 and C1 parsing enabled _testGetSet->_setConsoleOutputCPResult = true; _testGetSet->_expectedOutputCP = 28591; - VERIFY_IS_TRUE(_pDispatch->DesignateCodingSystem(DispatchTypes::CodingSystem::ISO2022)); + _pDispatch->DesignateCodingSystem(DispatchTypes::CodingSystem::ISO2022); VERIFY_IS_TRUE(_stateMachine->GetParserMode(StateMachine::Mode::AcceptC1)); Log::Comment(L"4. Designate UTF-8 coding system"); // Code page should be set to UTF-8 and C1 parsing disabled _testGetSet->_setConsoleOutputCPResult = true; _testGetSet->_expectedOutputCP = CP_UTF8; - VERIFY_IS_TRUE(_pDispatch->DesignateCodingSystem(DispatchTypes::CodingSystem::UTF8)); + _pDispatch->DesignateCodingSystem(DispatchTypes::CodingSystem::UTF8); VERIFY_IS_FALSE(_stateMachine->GetParserMode(StateMachine::Mode::AcceptC1)); } @@ -3618,67 +3617,67 @@ class AdapterTest Log::Comment(L"DECRQUPSS: DEC Supplemental"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("%5"), false)); + termOutput.AssignUserPreferenceCharset(VTID("%5"), false); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P0!u%5\033\\"); Log::Comment(L"DECRQUPSS: DEC Greek"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("\"?"), false)); + termOutput.AssignUserPreferenceCharset(VTID("\"?"), false); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P0!u\"?\033\\"); Log::Comment(L"DECRQUPSS: DEC Hebrew"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("\"4"), false)); + termOutput.AssignUserPreferenceCharset(VTID("\"4"), false); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P0!u\"4\033\\"); Log::Comment(L"DECRQUPSS: DEC Turkish"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("%0"), false)); + termOutput.AssignUserPreferenceCharset(VTID("%0"), false); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P0!u%0\033\\"); Log::Comment(L"DECRQUPSS: DEC Cyrillic"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("&4"), false)); + termOutput.AssignUserPreferenceCharset(VTID("&4"), false); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P0!u&4\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-1"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("A"), true)); + termOutput.AssignUserPreferenceCharset(VTID("A"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uA\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-2"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("B"), true)); + termOutput.AssignUserPreferenceCharset(VTID("B"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uB\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-Greek"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("F"), true)); + termOutput.AssignUserPreferenceCharset(VTID("F"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uF\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-Hebrew"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("H"), true)); + termOutput.AssignUserPreferenceCharset(VTID("H"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uH\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-Cyrillic"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("L"), true)); + termOutput.AssignUserPreferenceCharset(VTID("L"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uL\033\\"); Log::Comment(L"DECRQUPSS: ISO Latin-5"); _testGetSet->PrepData(); - VERIFY_IS_TRUE(termOutput.AssignUserPreferenceCharset(VTID("M"), true)); + termOutput.AssignUserPreferenceCharset(VTID("M"), true); _pDispatch->RequestUserPreferenceCharset(); _testGetSet->ValidateInputEvent(L"\033P1!uM\033\\"); } @@ -3858,26 +3857,26 @@ class AdapterTest _testGetSet->PrepData(); Log::Comment(L"Not enough parameters"); - VERIFY_IS_FALSE(_pDispatch->DoVsCodeAction(LR"(garbage)")); + _pDispatch->DoVsCodeAction(LR"(garbage)"); Log::Comment(L"Not enough parameters"); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions)")); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;)")); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;10;)")); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;10;20)")); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;10;20;)")); + _pDispatch->DoVsCodeAction(LR"(Completions)"); + _pDispatch->DoVsCodeAction(LR"(Completions;)"); + _pDispatch->DoVsCodeAction(LR"(Completions;10;)"); + _pDispatch->DoVsCodeAction(LR"(Completions;10;20)"); + _pDispatch->DoVsCodeAction(LR"(Completions;10;20;)"); Log::Comment(L"No trailing semicolon"); - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;10;20;3)")); + _pDispatch->DoVsCodeAction(LR"(Completions;10;20;3)"); Log::Comment(L"Normal, good case"); _testGetSet->_expectedMenuJson = LR"({ "foo": 1, "bar": 2 })"; _testGetSet->_expectedReplaceLength = 2; - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;1;2;3;{ "foo": 1, "bar": 2 })")); + _pDispatch->DoVsCodeAction(LR"(Completions;1;2;3;{ "foo": 1, "bar": 2 })"); Log::Comment(L"JSON has a semicolon in it"); _testGetSet->_expectedMenuJson = LR"({ "foo": "what;ever", "bar": 2 })"; _testGetSet->_expectedReplaceLength = 20; - VERIFY_IS_TRUE(_pDispatch->DoVsCodeAction(LR"(Completions;10;20;30;{ "foo": "what;ever", "bar": 2 })")); + _pDispatch->DoVsCodeAction(LR"(Completions;10;20;30;{ "foo": "what;ever", "bar": 2 })"); } TEST_METHOD(PageMovementTests) diff --git a/src/terminal/parser/IStateMachineEngine.hpp b/src/terminal/parser/IStateMachineEngine.hpp index d1d838ccc5e..b0b55dc05ed 100644 --- a/src/terminal/parser/IStateMachineEngine.hpp +++ b/src/terminal/parser/IStateMachineEngine.hpp @@ -35,19 +35,13 @@ namespace Microsoft::Console::VirtualTerminal virtual bool ActionPrint(const wchar_t wch) = 0; virtual bool ActionPrintString(const std::wstring_view string) = 0; - virtual bool ActionPassThroughString(const std::wstring_view string, const bool flush = false) = 0; + virtual bool ActionPassThroughString(const std::wstring_view string) = 0; virtual bool ActionEscDispatch(const VTID id) = 0; virtual bool ActionVt52EscDispatch(const VTID id, const VTParameters parameters) = 0; virtual bool ActionCsiDispatch(const VTID id, const VTParameters parameters) = 0; virtual StringHandler ActionDcsDispatch(const VTID id, const VTParameters parameters) = 0; - - virtual bool ActionClear() = 0; - - virtual bool ActionIgnore() = 0; - virtual bool ActionOscDispatch(const size_t parameter, const std::wstring_view string) = 0; - virtual bool ActionSs3Dispatch(const wchar_t wch, const VTParameters parameters) = 0; protected: diff --git a/src/terminal/parser/InputStateMachineEngine.cpp b/src/terminal/parser/InputStateMachineEngine.cpp index d98bfd98de2..1111e74d370 100644 --- a/src/terminal/parser/InputStateMachineEngine.cpp +++ b/src/terminal/parser/InputStateMachineEngine.cpp @@ -97,7 +97,6 @@ InputStateMachineEngine::InputStateMachineEngine(std::unique_ptr pDispatch, const bool lookingForDSR) : _pDispatch(std::move(pDispatch)), _lookingForDSR(lookingForDSR), - _pfnFlushToInputQueue(nullptr), _doubleClickTime(std::chrono::milliseconds(GetDoubleClickTime())) { THROW_HR_IF_NULL(E_INVALIDARG, _pDispatch.get()); @@ -139,7 +138,6 @@ bool InputStateMachineEngine::ActionExecute(const wchar_t wch) // - True if successfully generated and written. False otherwise. bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool writeAlt) { - auto success = false; if (wch == UNICODE_ETX && !writeAlt) { // This is Ctrl+C, which is handled specially by the host. @@ -147,7 +145,6 @@ bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool static constexpr auto keyUp = SynthesizeKeyEvent(false, 1, L'C', 0, UNICODE_ETX, LEFT_CTRL_PRESSED); _pDispatch->WriteCtrlKey(keyDown); _pDispatch->WriteCtrlKey(keyUp); - success = true; } else if (wch >= '\x0' && wch < '\x20') { @@ -155,6 +152,7 @@ bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool // This should be translated as Ctrl+(wch+x40) auto actualChar = wch; auto writeCtrl = true; + auto success = false; short vkey = 0; DWORD modifierState = 0; @@ -200,7 +198,7 @@ bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool WI_SetFlag(modifierState, LEFT_ALT_PRESSED); } - success = _WriteSingleKey(actualChar, vkey, modifierState); + _WriteSingleKey(actualChar, vkey, modifierState); } } else if (wch == '\x7f') @@ -212,13 +210,13 @@ bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool // "delete" any input at all, only backspace. // Because of this, we're treating x7f as backspace, like most // terminals do. - success = _WriteSingleKey('\x8', VK_BACK, writeAlt ? LEFT_ALT_PRESSED : 0); + _WriteSingleKey('\x8', VK_BACK, writeAlt ? LEFT_ALT_PRESSED : 0); } else { - success = ActionPrint(wch); + ActionPrint(wch); } - return success; + return true; } // Routine Description: @@ -234,9 +232,9 @@ bool InputStateMachineEngine::_DoControlCharacter(const wchar_t wch, const bool // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionExecuteFromEscape(const wchar_t wch) { - if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue) + if (_pDispatch->IsVtInputEnabled()) { - return _pfnFlushToInputQueue(); + return false; } return _DoControlCharacter(wch, true); @@ -253,12 +251,11 @@ bool InputStateMachineEngine::ActionPrint(const wchar_t wch) { short vkey = 0; DWORD modifierState = 0; - auto success = _GenerateKeyFromChar(wch, vkey, modifierState); - if (success) + if (_GenerateKeyFromChar(wch, vkey, modifierState)) { - success = _WriteSingleKey(wch, vkey, modifierState); + _WriteSingleKey(wch, vkey, modifierState); } - return success; + return true; } // Method Description: @@ -270,11 +267,11 @@ bool InputStateMachineEngine::ActionPrint(const wchar_t wch) // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionPrintString(const std::wstring_view string) { - if (string.empty()) + if (!string.empty()) { - return true; + _pDispatch->WriteString(string); } - return _pDispatch->WriteString(string); + return true; } // Method Description: @@ -285,23 +282,30 @@ bool InputStateMachineEngine::ActionPrintString(const std::wstring_view string) // - flush - not applicable to the input state machine. // Return Value: // - true iff we successfully dispatched the sequence. -bool InputStateMachineEngine::ActionPassThroughString(const std::wstring_view string, const bool /*flush*/) +bool InputStateMachineEngine::ActionPassThroughString(const std::wstring_view string) { + if (string.empty()) + { + return true; + } + if (_pDispatch->IsVtInputEnabled()) { // Synthesize string into key events that we'll write to the buffer // similar to TerminalInput::_SendInputSequence - if (!string.empty()) + InputEventQueue inputEvents; + for (const auto& wch : string) { - InputEventQueue inputEvents; - for (const auto& wch : string) - { - inputEvents.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0)); - } - return _pDispatch->WriteInput(inputEvents); + inputEvents.push_back(SynthesizeKeyEvent(true, 1, 0, 0, wch, 0)); } + _pDispatch->WriteInput(inputEvents); + } + else + { + _pDispatch->WriteString(string); } - return ActionPrintString(string); + + return true; } // Method Description: @@ -314,36 +318,32 @@ bool InputStateMachineEngine::ActionPassThroughString(const std::wstring_view st // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionEscDispatch(const VTID id) { - if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue) + if (_pDispatch->IsVtInputEnabled()) { - return _pfnFlushToInputQueue(); + return false; } - auto success = false; - // There are no intermediates, so the id is effectively the final char. const auto wch = gsl::narrow_cast(id); // 0x7f is DEL, which we treat effectively the same as a ctrl character. if (wch == 0x7f) { - success = _DoControlCharacter(wch, true); + _DoControlCharacter(wch, true); } else { DWORD modifierState = 0; short vk = 0; - success = _GenerateKeyFromChar(wch, vk, modifierState); - if (success) + if (_GenerateKeyFromChar(wch, vk, modifierState)) { // Alt is definitely pressed in the esc+key case. modifierState = WI_SetFlag(modifierState, LEFT_ALT_PRESSED); - - success = _WriteSingleKey(wch, vk, modifierState); + _WriteSingleKey(wch, vk, modifierState); } } - return success; + return true; } // Method Description: @@ -382,18 +382,13 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter // Focus events in conpty are special, so don't flush those through either. // See GH#12799, GH#12900 for details if (_pDispatch->IsVtInputEnabled() && - _pfnFlushToInputQueue && id != CsiActionCodes::Win32KeyboardInput && id != CsiActionCodes::FocusIn && id != CsiActionCodes::FocusOut) { - return _pfnFlushToInputQueue(); + return false; } - DWORD modifierState = 0; - short vkey = 0; - - auto success = false; switch (id) { case CsiActionCodes::MouseDown: @@ -404,10 +399,12 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter const auto firstParameter = parameters.at(0).value_or(0); const til::point uiPos{ parameters.at(1) - 1, parameters.at(2) - 1 }; - modifierState = _GetSGRMouseModifierState(firstParameter); - success = _UpdateSGRMouseButtonState(id, firstParameter, buttonState, eventFlags, uiPos); - success = success && _WriteMouseEvent(uiPos, buttonState, modifierState, eventFlags); - break; + if (_UpdateSGRMouseButtonState(id, firstParameter, buttonState, eventFlags, uiPos)) + { + const auto modifierState = _GetSGRMouseModifierState(firstParameter); + _WriteMouseEvent(uiPos, buttonState, modifierState, eventFlags); + } + return true; } // case CsiActionCodes::DSR_DeviceStatusReportResponse: case CsiActionCodes::CSI_F3: @@ -416,12 +413,18 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter // Else, fall though to the _GetCursorKeysModifierState handler. if (_lookingForDSR.load(std::memory_order::relaxed)) { - success = _pDispatch->MoveCursor(parameters.at(0), parameters.at(1)); + _pDispatch->MoveCursor(parameters.at(0), parameters.at(1)); // Right now we're only looking for on initial cursor // position response. After that, only look for F3. _lookingForDSR.store(false, std::memory_order::relaxed); til::atomic_notify_all(_lookingForDSR); - break; + return true; + } + // Heuristic: If the hosting terminal used the win32 input mode, chances are high + // that this is a CPR requested by the terminal application as opposed to a F3 key. + if (_encounteredWin32InputModeSequence) + { + return false; } [[fallthrough]]; case CsiActionCodes::ArrowUp: @@ -433,43 +436,47 @@ bool InputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParameter case CsiActionCodes::CSI_F1: case CsiActionCodes::CSI_F2: case CsiActionCodes::CSI_F4: - success = _GetCursorKeysVkey(id, vkey); - modifierState = _GetCursorKeysModifierState(parameters, id); - success = success && _WriteSingleKey(vkey, modifierState); - break; + { + short vkey = 0; + if (_GetCursorKeysVkey(id, vkey)) + { + const auto modifierState = _GetCursorKeysModifierState(parameters, id); + _WriteSingleKey(vkey, modifierState); + } + return true; + } case CsiActionCodes::Generic: - success = _GetGenericVkey(parameters.at(0), vkey); - modifierState = _GetGenericKeysModifierState(parameters); - success = success && _WriteSingleKey(vkey, modifierState); - break; + { + short vkey = 0; + if (_GetGenericVkey(parameters.at(0), vkey)) + { + const auto modifierState = _GetGenericKeysModifierState(parameters); + _WriteSingleKey(vkey, modifierState); + } + return true; + } case CsiActionCodes::CursorBackTab: - success = _WriteSingleKey(VK_TAB, SHIFT_PRESSED); - break; - case CsiActionCodes::DTTERM_WindowManipulation: - success = _pDispatch->WindowManipulation(parameters.at(0), parameters.at(1), parameters.at(2)); - break; + _WriteSingleKey(VK_TAB, SHIFT_PRESSED); + return true; case CsiActionCodes::FocusIn: - success = _pDispatch->FocusChanged(true); - break; + _pDispatch->FocusChanged(true); + return true; case CsiActionCodes::FocusOut: - success = _pDispatch->FocusChanged(false); - break; + _pDispatch->FocusChanged(false); + return true; case CsiActionCodes::Win32KeyboardInput: { // Use WriteCtrlKey here, even for keys that _aren't_ control keys, // because that will take extra steps to make sure things like // Ctrl+C, Ctrl+Break are handled correctly. const auto key = _GenerateWin32Key(parameters); - success = _pDispatch->WriteCtrlKey(key); + _pDispatch->WriteCtrlKey(key); _encounteredWin32InputModeSequence = true; - break; + return true; } default: - success = false; - break; + return false; } - - return success; } // Routine Description: @@ -498,47 +505,19 @@ IStateMachineEngine::StringHandler InputStateMachineEngine::ActionDcsDispatch(co // - true iff we successfully dispatched the sequence. bool InputStateMachineEngine::ActionSs3Dispatch(const wchar_t wch, const VTParameters /*parameters*/) { - if (_pDispatch->IsVtInputEnabled() && _pfnFlushToInputQueue) + if (_pDispatch->IsVtInputEnabled()) { - return _pfnFlushToInputQueue(); + return false; } // Ss3 sequence keys aren't modified. // When F1-F4 *are* modified, they're sent as CSI sequences, not SS3's. - const DWORD modifierState = 0; short vkey = 0; - - auto success = _GetSs3KeysVkey(wch, vkey); - - if (success) + if (_GetSs3KeysVkey(wch, vkey)) { - success = _WriteSingleKey(vkey, modifierState); + _WriteSingleKey(vkey, 0); } - return success; -} - -// Method Description: -// - Triggers the Clear action to indicate that the state machine should erase -// all internal state. -// Arguments: -// - -// Return Value: -// - true iff we successfully dispatched the sequence. -bool InputStateMachineEngine::ActionClear() noexcept -{ - return true; -} - -// Method Description: -// - Triggers the Ignore action to indicate that the state machine should eat -// this character and say nothing. -// Arguments: -// - -// Return Value: -// - true iff we successfully dispatched the sequence. -bool InputStateMachineEngine::ActionIgnore() noexcept -{ return true; } @@ -550,7 +529,7 @@ bool InputStateMachineEngine::ActionIgnore() noexcept // - string - OSC string we've collected. NOT null terminated. // Return Value: // - true if we handled the dispatch. -bool InputStateMachineEngine::ActionOscDispatch(const size_t /*parameter*/, const std::wstring_view /*string*/) +bool InputStateMachineEngine::ActionOscDispatch(const size_t /*parameter*/, const std::wstring_view /*string*/) noexcept { // Unlike ActionCsiDispatch, we are not checking whether the application has requested // VT input. @@ -559,10 +538,6 @@ bool InputStateMachineEngine::ActionOscDispatch(const size_t /*parameter*/, cons // that for CSI reports because we may incidentally pass through non-response VT input; // however, there should be no OSC on the input stream *except* for responses. // It should be safe to pass all OSCs from the input stream through to the application. - if (_pfnFlushToInputQueue) - { - return _pfnFlushToInputQueue(); - } return false; } @@ -693,12 +668,12 @@ void InputStateMachineEngine::_GetSingleKeypress(const wchar_t wch, // - modifierState - the modifier state to write with the key. // Return Value: // - true iff we successfully wrote the keypress to the input callback. -bool InputStateMachineEngine::_WriteSingleKey(const wchar_t wch, const short vkey, const DWORD modifierState) +void InputStateMachineEngine::_WriteSingleKey(const wchar_t wch, const short vkey, const DWORD modifierState) { // At most 8 records - 2 for each of shift,ctrl,alt up and down, and 2 for the actual key up and down. InputEventQueue inputEvents; _GenerateWrappedSequence(wch, vkey, modifierState, inputEvents); - return _pDispatch->WriteInput(inputEvents); + _pDispatch->WriteInput(inputEvents); } // Method Description: @@ -709,10 +684,10 @@ bool InputStateMachineEngine::_WriteSingleKey(const wchar_t wch, const short vke // - modifierState - the modifier state to write with the key. // Return Value: // - true iff we successfully wrote the keypress to the input callback. -bool InputStateMachineEngine::_WriteSingleKey(const short vkey, const DWORD modifierState) +void InputStateMachineEngine::_WriteSingleKey(const short vkey, const DWORD modifierState) { const auto wch = gsl::narrow_cast(OneCoreSafeMapVirtualKeyW(vkey, MAPVK_VK_TO_CHAR)); - return _WriteSingleKey(wch, vkey, modifierState); + _WriteSingleKey(wch, vkey, modifierState); } // Method Description: @@ -725,10 +700,10 @@ bool InputStateMachineEngine::_WriteSingleKey(const short vkey, const DWORD modi // - eventFlags - the type of mouse event to write to the mouse record. // Return Value: // - true iff we successfully wrote the keypress to the input callback. -bool InputStateMachineEngine::_WriteMouseEvent(const til::point uiPos, const DWORD buttonState, const DWORD controlKeyState, const DWORD eventFlags) +void InputStateMachineEngine::_WriteMouseEvent(const til::point uiPos, const DWORD buttonState, const DWORD controlKeyState, const DWORD eventFlags) { const auto rgInput = SynthesizeMouseEvent(uiPos, buttonState, controlKeyState, eventFlags); - return _pDispatch->WriteInput({ &rgInput, 1 }); + _pDispatch->WriteInput({ &rgInput, 1 }); } // Method Description: @@ -1051,22 +1026,6 @@ bool InputStateMachineEngine::_GenerateKeyFromChar(const wchar_t wch, return true; } -// Method Description: -// - Sets us up for vt input passthrough. -// We'll set a couple members, and if they aren't null, when we get a -// sequence we don't understand, we'll pass it along to the app -// instead of eating it ourselves. -// Arguments: -// - pfnFlushToInputQueue: This is a callback to the underlying state machine to -// trigger it to call ActionPassThroughString with whatever sequence it's -// currently processing. -// Return Value: -// - -void InputStateMachineEngine::SetFlushToInputQueueCallback(std::function pfnFlushToInputQueue) -{ - _pfnFlushToInputQueue = pfnFlushToInputQueue; -} - // Method Description: // - Retrieves the type of window manipulation operation from the parameter pool // stored during Param actions. diff --git a/src/terminal/parser/InputStateMachineEngine.hpp b/src/terminal/parser/InputStateMachineEngine.hpp index a572ec41123..b37b67d4b6e 100644 --- a/src/terminal/parser/InputStateMachineEngine.hpp +++ b/src/terminal/parser/InputStateMachineEngine.hpp @@ -143,7 +143,7 @@ namespace Microsoft::Console::VirtualTerminal bool ActionPrintString(const std::wstring_view string) override; - bool ActionPassThroughString(const std::wstring_view string, const bool flush) override; + bool ActionPassThroughString(const std::wstring_view string) override; bool ActionEscDispatch(const VTID id) override; @@ -153,19 +153,12 @@ namespace Microsoft::Console::VirtualTerminal StringHandler ActionDcsDispatch(const VTID id, const VTParameters parameters) noexcept override; - bool ActionClear() noexcept override; - - bool ActionIgnore() noexcept override; - - bool ActionOscDispatch(const size_t parameter, const std::wstring_view string) override; + bool ActionOscDispatch(const size_t parameter, const std::wstring_view string) noexcept override; bool ActionSs3Dispatch(const wchar_t wch, const VTParameters parameters) override; - void SetFlushToInputQueueCallback(std::function pfnFlushToInputQueue); - private: const std::unique_ptr _pDispatch; - std::function _pfnFlushToInputQueue; std::atomic _lookingForDSR{ false }; bool _encounteredWin32InputModeSequence = false; DWORD _mouseButtonState = 0; @@ -190,10 +183,10 @@ namespace Microsoft::Console::VirtualTerminal bool _GetCursorKeysVkey(const VTID id, short& vkey) const; bool _GetSs3KeysVkey(const wchar_t wch, short& vkey) const; - bool _WriteSingleKey(const short vkey, const DWORD modifierState); - bool _WriteSingleKey(const wchar_t wch, const short vkey, const DWORD modifierState); + void _WriteSingleKey(const short vkey, const DWORD modifierState); + void _WriteSingleKey(const wchar_t wch, const short vkey, const DWORD modifierState); - bool _WriteMouseEvent(const til::point uiPos, const DWORD buttonState, const DWORD controlKeyState, const DWORD eventFlags); + void _WriteMouseEvent(const til::point uiPos, const DWORD buttonState, const DWORD controlKeyState, const DWORD eventFlags); void _GenerateWrappedSequence(const wchar_t wch, const short vkey, diff --git a/src/terminal/parser/OutputStateMachineEngine.cpp b/src/terminal/parser/OutputStateMachineEngine.cpp index 4058df7ff21..5339c29bdf9 100644 --- a/src/terminal/parser/OutputStateMachineEngine.cpp +++ b/src/terminal/parser/OutputStateMachineEngine.cpp @@ -176,7 +176,7 @@ bool OutputStateMachineEngine::ActionPrintString(const std::wstring_view string) // - flush - set to true if the string should be flushed immediately. // Return Value: // - true iff we successfully dispatched the sequence. -bool OutputStateMachineEngine::ActionPassThroughString(const std::wstring_view /*string*/, const bool /*flush*/) noexcept +bool OutputStateMachineEngine::ActionPassThroughString(const std::wstring_view /*string*/) noexcept { return true; } @@ -191,97 +191,94 @@ bool OutputStateMachineEngine::ActionPassThroughString(const std::wstring_view / // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionEscDispatch(const VTID id) { - auto success = false; - switch (id) { case EscActionCodes::ST_StringTerminator: // This is the 7-bit string terminator, which is essentially a no-op. - success = true; break; case EscActionCodes::DECBI_BackIndex: - success = _dispatch->BackIndex(); + _dispatch->BackIndex(); break; case EscActionCodes::DECSC_CursorSave: - success = _dispatch->CursorSaveState(); + _dispatch->CursorSaveState(); break; case EscActionCodes::DECRC_CursorRestore: - success = _dispatch->CursorRestoreState(); + _dispatch->CursorRestoreState(); break; case EscActionCodes::DECFI_ForwardIndex: - success = _dispatch->ForwardIndex(); + _dispatch->ForwardIndex(); break; case EscActionCodes::DECKPAM_KeypadApplicationMode: - success = _dispatch->SetKeypadMode(true); + _dispatch->SetKeypadMode(true); break; case EscActionCodes::DECKPNM_KeypadNumericMode: - success = _dispatch->SetKeypadMode(false); + _dispatch->SetKeypadMode(false); break; case EscActionCodes::NEL_NextLine: - success = _dispatch->LineFeed(DispatchTypes::LineFeedType::WithReturn); + _dispatch->LineFeed(DispatchTypes::LineFeedType::WithReturn); break; case EscActionCodes::IND_Index: - success = _dispatch->LineFeed(DispatchTypes::LineFeedType::WithoutReturn); + _dispatch->LineFeed(DispatchTypes::LineFeedType::WithoutReturn); break; case EscActionCodes::RI_ReverseLineFeed: - success = _dispatch->ReverseLineFeed(); + _dispatch->ReverseLineFeed(); break; case EscActionCodes::HTS_HorizontalTabSet: - success = _dispatch->HorizontalTabSet(); + _dispatch->HorizontalTabSet(); break; case EscActionCodes::DECID_IdentifyDevice: - success = _dispatch->DeviceAttributes(); + _dispatch->DeviceAttributes(); break; case EscActionCodes::RIS_ResetToInitialState: - success = _dispatch->HardReset(); + _dispatch->HardReset(); break; case EscActionCodes::SS2_SingleShift: - success = _dispatch->SingleShift(2); + _dispatch->SingleShift(2); break; case EscActionCodes::SS3_SingleShift: - success = _dispatch->SingleShift(3); + _dispatch->SingleShift(3); break; case EscActionCodes::LS2_LockingShift: - success = _dispatch->LockingShift(2); + _dispatch->LockingShift(2); break; case EscActionCodes::LS3_LockingShift: - success = _dispatch->LockingShift(3); + _dispatch->LockingShift(3); break; case EscActionCodes::LS1R_LockingShift: - success = _dispatch->LockingShiftRight(1); + _dispatch->LockingShiftRight(1); break; case EscActionCodes::LS2R_LockingShift: - success = _dispatch->LockingShiftRight(2); + _dispatch->LockingShiftRight(2); break; case EscActionCodes::LS3R_LockingShift: - success = _dispatch->LockingShiftRight(3); + _dispatch->LockingShiftRight(3); break; case EscActionCodes::DECAC1_AcceptC1Controls: - success = _dispatch->AcceptC1Controls(true); + _dispatch->AcceptC1Controls(true); break; case EscActionCodes::ACS_AnsiLevel1: - success = _dispatch->AnnounceCodeStructure(1); + _dispatch->AnnounceCodeStructure(1); break; case EscActionCodes::ACS_AnsiLevel2: - success = _dispatch->AnnounceCodeStructure(2); + _dispatch->AnnounceCodeStructure(2); break; case EscActionCodes::ACS_AnsiLevel3: - success = _dispatch->AnnounceCodeStructure(3); + _dispatch->AnnounceCodeStructure(3); break; case EscActionCodes::DECDHL_DoubleHeightLineTop: - success = _dispatch->SetLineRendition(LineRendition::DoubleHeightTop); + _dispatch->SetLineRendition(LineRendition::DoubleHeightTop); break; case EscActionCodes::DECDHL_DoubleHeightLineBottom: - success = _dispatch->SetLineRendition(LineRendition::DoubleHeightBottom); + _dispatch->SetLineRendition(LineRendition::DoubleHeightBottom); break; case EscActionCodes::DECSWL_SingleWidthLine: - success = _dispatch->SetLineRendition(LineRendition::SingleWidth); + _dispatch->SetLineRendition(LineRendition::SingleWidth); break; case EscActionCodes::DECDWL_DoubleWidthLine: - success = _dispatch->SetLineRendition(LineRendition::DoubleWidth); + _dispatch->SetLineRendition(LineRendition::DoubleWidth); break; case EscActionCodes::DECALN_ScreenAlignmentPattern: - success = _dispatch->ScreenAlignmentPattern(); + _dispatch->ScreenAlignmentPattern(); break; default: const auto commandChar = id[0]; @@ -289,39 +286,37 @@ bool OutputStateMachineEngine::ActionEscDispatch(const VTID id) switch (commandChar) { case '%': - success = _dispatch->DesignateCodingSystem(commandParameter); + _dispatch->DesignateCodingSystem(commandParameter); break; case '(': - success = _dispatch->Designate94Charset(0, commandParameter); + _dispatch->Designate94Charset(0, commandParameter); break; case ')': - success = _dispatch->Designate94Charset(1, commandParameter); + _dispatch->Designate94Charset(1, commandParameter); break; case '*': - success = _dispatch->Designate94Charset(2, commandParameter); + _dispatch->Designate94Charset(2, commandParameter); break; case '+': - success = _dispatch->Designate94Charset(3, commandParameter); + _dispatch->Designate94Charset(3, commandParameter); break; case '-': - success = _dispatch->Designate96Charset(1, commandParameter); + _dispatch->Designate96Charset(1, commandParameter); break; case '.': - success = _dispatch->Designate96Charset(2, commandParameter); + _dispatch->Designate96Charset(2, commandParameter); break; case '/': - success = _dispatch->Designate96Charset(3, commandParameter); + _dispatch->Designate96Charset(3, commandParameter); break; default: - // If no functions to call, overall dispatch was a failure. - success = false; break; } } _ClearLastChar(); - return success; + return true; } // Method Description: @@ -335,66 +330,62 @@ bool OutputStateMachineEngine::ActionEscDispatch(const VTID id) // - true iff we successfully dispatched the sequence. bool OutputStateMachineEngine::ActionVt52EscDispatch(const VTID id, const VTParameters parameters) { - auto success = false; - switch (id) { case Vt52ActionCodes::CursorUp: - success = _dispatch->CursorUp(1); + _dispatch->CursorUp(1); break; case Vt52ActionCodes::CursorDown: - success = _dispatch->CursorDown(1); + _dispatch->CursorDown(1); break; case Vt52ActionCodes::CursorRight: - success = _dispatch->CursorForward(1); + _dispatch->CursorForward(1); break; case Vt52ActionCodes::CursorLeft: - success = _dispatch->CursorBackward(1); + _dispatch->CursorBackward(1); break; case Vt52ActionCodes::EnterGraphicsMode: - success = _dispatch->Designate94Charset(0, DispatchTypes::CharacterSets::DecSpecialGraphics); + _dispatch->Designate94Charset(0, DispatchTypes::CharacterSets::DecSpecialGraphics); break; case Vt52ActionCodes::ExitGraphicsMode: - success = _dispatch->Designate94Charset(0, DispatchTypes::CharacterSets::ASCII); + _dispatch->Designate94Charset(0, DispatchTypes::CharacterSets::ASCII); break; case Vt52ActionCodes::CursorToHome: - success = _dispatch->CursorPosition(1, 1); + _dispatch->CursorPosition(1, 1); break; case Vt52ActionCodes::ReverseLineFeed: - success = _dispatch->ReverseLineFeed(); + _dispatch->ReverseLineFeed(); break; case Vt52ActionCodes::EraseToEndOfScreen: - success = _dispatch->EraseInDisplay(DispatchTypes::EraseType::ToEnd); + _dispatch->EraseInDisplay(DispatchTypes::EraseType::ToEnd); break; case Vt52ActionCodes::EraseToEndOfLine: - success = _dispatch->EraseInLine(DispatchTypes::EraseType::ToEnd); + _dispatch->EraseInLine(DispatchTypes::EraseType::ToEnd); break; case Vt52ActionCodes::DirectCursorAddress: // VT52 cursor addresses are provided as ASCII characters, with // the lowest value being a space, representing an address of 1. - success = _dispatch->CursorPosition(parameters.at(0).value() - ' ' + 1, parameters.at(1).value() - ' ' + 1); + _dispatch->CursorPosition(parameters.at(0).value() - ' ' + 1, parameters.at(1).value() - ' ' + 1); break; case Vt52ActionCodes::Identify: - success = _dispatch->Vt52DeviceAttributes(); + _dispatch->Vt52DeviceAttributes(); break; case Vt52ActionCodes::EnterAlternateKeypadMode: - success = _dispatch->SetKeypadMode(true); + _dispatch->SetKeypadMode(true); break; case Vt52ActionCodes::ExitAlternateKeypadMode: - success = _dispatch->SetKeypadMode(false); + _dispatch->SetKeypadMode(false); break; case Vt52ActionCodes::ExitVt52Mode: - success = _dispatch->SetMode(DispatchTypes::ModeParams::DECANM_AnsiMode); + _dispatch->SetMode(DispatchTypes::ModeParams::DECANM_AnsiMode); break; default: - // If no functions to call, overall dispatch was a failure. - success = false; break; } _ClearLastChar(); - return success; + return true; } // Routine Description: @@ -411,164 +402,171 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete // Bail out if we receive subparameters, but we don't accept them in the sequence. if (parameters.hasSubParams() && !_CanSeqAcceptSubParam(id, parameters)) [[unlikely]] { - return false; + return true; } - auto success = false; - switch (id) { case CsiActionCodes::CUU_CursorUp: - success = _dispatch->CursorUp(parameters.at(0)); + _dispatch->CursorUp(parameters.at(0)); break; case CsiActionCodes::CUD_CursorDown: - success = _dispatch->CursorDown(parameters.at(0)); + _dispatch->CursorDown(parameters.at(0)); break; case CsiActionCodes::CUF_CursorForward: - success = _dispatch->CursorForward(parameters.at(0)); + _dispatch->CursorForward(parameters.at(0)); break; case CsiActionCodes::CUB_CursorBackward: - success = _dispatch->CursorBackward(parameters.at(0)); + _dispatch->CursorBackward(parameters.at(0)); break; case CsiActionCodes::CNL_CursorNextLine: - success = _dispatch->CursorNextLine(parameters.at(0)); + _dispatch->CursorNextLine(parameters.at(0)); break; case CsiActionCodes::CPL_CursorPrevLine: - success = _dispatch->CursorPrevLine(parameters.at(0)); + _dispatch->CursorPrevLine(parameters.at(0)); break; case CsiActionCodes::CHA_CursorHorizontalAbsolute: case CsiActionCodes::HPA_HorizontalPositionAbsolute: - success = _dispatch->CursorHorizontalPositionAbsolute(parameters.at(0)); + _dispatch->CursorHorizontalPositionAbsolute(parameters.at(0)); break; case CsiActionCodes::VPA_VerticalLinePositionAbsolute: - success = _dispatch->VerticalLinePositionAbsolute(parameters.at(0)); + _dispatch->VerticalLinePositionAbsolute(parameters.at(0)); break; case CsiActionCodes::HPR_HorizontalPositionRelative: - success = _dispatch->HorizontalPositionRelative(parameters.at(0)); + _dispatch->HorizontalPositionRelative(parameters.at(0)); break; case CsiActionCodes::VPR_VerticalPositionRelative: - success = _dispatch->VerticalPositionRelative(parameters.at(0)); + _dispatch->VerticalPositionRelative(parameters.at(0)); break; case CsiActionCodes::CUP_CursorPosition: case CsiActionCodes::HVP_HorizontalVerticalPosition: - success = _dispatch->CursorPosition(parameters.at(0), parameters.at(1)); + _dispatch->CursorPosition(parameters.at(0), parameters.at(1)); break; case CsiActionCodes::DECSTBM_SetTopBottomMargins: - success = _dispatch->SetTopBottomScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0)); + _dispatch->SetTopBottomScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0)); break; case CsiActionCodes::DECSLRM_SetLeftRightMargins: // Note that this can also be ANSISYSSC, depending on the state of DECLRMM. - success = _dispatch->SetLeftRightScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0)); + _dispatch->SetLeftRightScrollingMargins(parameters.at(0).value_or(0), parameters.at(1).value_or(0)); break; case CsiActionCodes::ICH_InsertCharacter: - success = _dispatch->InsertCharacter(parameters.at(0)); + _dispatch->InsertCharacter(parameters.at(0)); break; case CsiActionCodes::DCH_DeleteCharacter: - success = _dispatch->DeleteCharacter(parameters.at(0)); + _dispatch->DeleteCharacter(parameters.at(0)); break; case CsiActionCodes::ED_EraseDisplay: - success = parameters.for_each([&](const auto eraseType) { - return _dispatch->EraseInDisplay(eraseType); + parameters.for_each([&](const auto eraseType) { + _dispatch->EraseInDisplay(eraseType); }); break; case CsiActionCodes::DECSED_SelectiveEraseDisplay: - success = parameters.for_each([&](const auto eraseType) { - return _dispatch->SelectiveEraseInDisplay(eraseType); + parameters.for_each([&](const auto eraseType) { + _dispatch->SelectiveEraseInDisplay(eraseType); }); break; case CsiActionCodes::EL_EraseLine: - success = parameters.for_each([&](const auto eraseType) { - return _dispatch->EraseInLine(eraseType); + parameters.for_each([&](const auto eraseType) { + _dispatch->EraseInLine(eraseType); }); break; case CsiActionCodes::DECSEL_SelectiveEraseLine: - success = parameters.for_each([&](const auto eraseType) { - return _dispatch->SelectiveEraseInLine(eraseType); + parameters.for_each([&](const auto eraseType) { + _dispatch->SelectiveEraseInLine(eraseType); }); break; case CsiActionCodes::SM_SetMode: - success = parameters.for_each([&](const auto mode) { - return _dispatch->SetMode(DispatchTypes::ANSIStandardMode(mode)); + parameters.for_each([&](const auto mode) { + _dispatch->SetMode(DispatchTypes::ANSIStandardMode(mode)); }); break; case CsiActionCodes::DECSET_PrivateModeSet: - success = parameters.for_each([&](const auto mode) { - return _dispatch->SetMode(DispatchTypes::DECPrivateMode(mode)); + parameters.for_each([&](const auto mode) { + _dispatch->SetMode(DispatchTypes::DECPrivateMode(mode)); }); break; case CsiActionCodes::RM_ResetMode: - success = parameters.for_each([&](const auto mode) { - return _dispatch->ResetMode(DispatchTypes::ANSIStandardMode(mode)); + parameters.for_each([&](const auto mode) { + _dispatch->ResetMode(DispatchTypes::ANSIStandardMode(mode)); }); break; case CsiActionCodes::DECRST_PrivateModeReset: - success = parameters.for_each([&](const auto mode) { - return _dispatch->ResetMode(DispatchTypes::DECPrivateMode(mode)); + parameters.for_each([&](const auto mode) { + _dispatch->ResetMode(DispatchTypes::DECPrivateMode(mode)); }); break; case CsiActionCodes::SGR_SetGraphicsRendition: - success = _dispatch->SetGraphicsRendition(parameters); + _dispatch->SetGraphicsRendition(parameters); break; case CsiActionCodes::DSR_DeviceStatusReport: - success = _dispatch->DeviceStatusReport(DispatchTypes::ANSIStandardStatus(parameters.at(0)), parameters.at(1)); + _dispatch->DeviceStatusReport(DispatchTypes::ANSIStandardStatus(parameters.at(0)), parameters.at(1)); break; case CsiActionCodes::DSR_PrivateDeviceStatusReport: - success = _dispatch->DeviceStatusReport(DispatchTypes::DECPrivateStatus(parameters.at(0)), parameters.at(1)); + _dispatch->DeviceStatusReport(DispatchTypes::DECPrivateStatus(parameters.at(0)), parameters.at(1)); break; case CsiActionCodes::DA_DeviceAttributes: - success = parameters.at(0).value_or(0) == 0 && _dispatch->DeviceAttributes(); + if (parameters.at(0).value_or(0) == 0) + { + _dispatch->DeviceAttributes(); + } break; case CsiActionCodes::DA2_SecondaryDeviceAttributes: - success = parameters.at(0).value_or(0) == 0 && _dispatch->SecondaryDeviceAttributes(); + if (parameters.at(0).value_or(0) == 0) + { + _dispatch->SecondaryDeviceAttributes(); + } break; case CsiActionCodes::DA3_TertiaryDeviceAttributes: - success = parameters.at(0).value_or(0) == 0 && _dispatch->TertiaryDeviceAttributes(); + if (parameters.at(0).value_or(0) == 0) + { + _dispatch->TertiaryDeviceAttributes(); + } break; case CsiActionCodes::DECREQTPARM_RequestTerminalParameters: - success = _dispatch->RequestTerminalParameters(parameters.at(0)); + _dispatch->RequestTerminalParameters(parameters.at(0)); break; case CsiActionCodes::SU_ScrollUp: - success = _dispatch->ScrollUp(parameters.at(0)); + _dispatch->ScrollUp(parameters.at(0)); break; case CsiActionCodes::SD_ScrollDown: - success = _dispatch->ScrollDown(parameters.at(0)); + _dispatch->ScrollDown(parameters.at(0)); break; case CsiActionCodes::NP_NextPage: - success = _dispatch->NextPage(parameters.at(0)); + _dispatch->NextPage(parameters.at(0)); break; case CsiActionCodes::PP_PrecedingPage: - success = _dispatch->PrecedingPage(parameters.at(0)); + _dispatch->PrecedingPage(parameters.at(0)); break; case CsiActionCodes::ANSISYSRC_CursorRestore: - success = _dispatch->CursorRestoreState(); + _dispatch->CursorRestoreState(); break; case CsiActionCodes::IL_InsertLine: - success = _dispatch->InsertLine(parameters.at(0)); + _dispatch->InsertLine(parameters.at(0)); break; case CsiActionCodes::DL_DeleteLine: - success = _dispatch->DeleteLine(parameters.at(0)); + _dispatch->DeleteLine(parameters.at(0)); break; case CsiActionCodes::CHT_CursorForwardTab: - success = _dispatch->ForwardTab(parameters.at(0)); + _dispatch->ForwardTab(parameters.at(0)); break; case CsiActionCodes::CBT_CursorBackTab: - success = _dispatch->BackwardsTab(parameters.at(0)); + _dispatch->BackwardsTab(parameters.at(0)); break; case CsiActionCodes::TBC_TabClear: - success = parameters.for_each([&](const auto clearType) { - return _dispatch->TabClear(clearType); + parameters.for_each([&](const auto clearType) { + _dispatch->TabClear(clearType); }); break; case CsiActionCodes::DECST8C_SetTabEvery8Columns: - success = parameters.for_each([&](const auto setType) { - return _dispatch->TabSet(setType); + parameters.for_each([&](const auto setType) { + _dispatch->TabSet(setType); }); break; case CsiActionCodes::ECH_EraseCharacters: - success = _dispatch->EraseCharacters(parameters.at(0)); + _dispatch->EraseCharacters(parameters.at(0)); break; case CsiActionCodes::DTTERM_WindowManipulation: - success = _dispatch->WindowManipulation(parameters.at(0), parameters.at(1), parameters.at(2)); + _dispatch->WindowManipulation(parameters.at(0), parameters.at(1), parameters.at(2)); break; case CsiActionCodes::REP_RepeatCharacter: // Handled w/o the dispatch. This function is unique in that way @@ -582,100 +580,97 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete std::wstring wstr(repeatCount, _lastPrintedChar); _dispatch->PrintString(wstr); } - success = true; break; case CsiActionCodes::PPA_PagePositionAbsolute: - success = _dispatch->PagePositionAbsolute(parameters.at(0)); + _dispatch->PagePositionAbsolute(parameters.at(0)); break; case CsiActionCodes::PPR_PagePositionRelative: - success = _dispatch->PagePositionRelative(parameters.at(0)); + _dispatch->PagePositionRelative(parameters.at(0)); break; case CsiActionCodes::PPB_PagePositionBack: - success = _dispatch->PagePositionBack(parameters.at(0)); + _dispatch->PagePositionBack(parameters.at(0)); break; case CsiActionCodes::DECSCUSR_SetCursorStyle: - success = _dispatch->SetCursorStyle(parameters.at(0)); + _dispatch->SetCursorStyle(parameters.at(0)); break; case CsiActionCodes::DECSTR_SoftReset: - success = _dispatch->SoftReset(); + _dispatch->SoftReset(); break; case CsiActionCodes::DECSCA_SetCharacterProtectionAttribute: - success = _dispatch->SetCharacterProtectionAttribute(parameters); + _dispatch->SetCharacterProtectionAttribute(parameters); break; case CsiActionCodes::DECRQDE_RequestDisplayedExtent: - success = _dispatch->RequestDisplayedExtent(); + _dispatch->RequestDisplayedExtent(); break; case CsiActionCodes::XT_PushSgr: case CsiActionCodes::XT_PushSgrAlias: - success = _dispatch->PushGraphicsRendition(parameters); + _dispatch->PushGraphicsRendition(parameters); break; case CsiActionCodes::XT_PopSgr: case CsiActionCodes::XT_PopSgrAlias: - success = _dispatch->PopGraphicsRendition(); + _dispatch->PopGraphicsRendition(); break; case CsiActionCodes::DECRQM_RequestMode: - success = _dispatch->RequestMode(DispatchTypes::ANSIStandardMode(parameters.at(0))); + _dispatch->RequestMode(DispatchTypes::ANSIStandardMode(parameters.at(0))); break; case CsiActionCodes::DECRQM_PrivateRequestMode: - success = _dispatch->RequestMode(DispatchTypes::DECPrivateMode(parameters.at(0))); + _dispatch->RequestMode(DispatchTypes::DECPrivateMode(parameters.at(0))); break; case CsiActionCodes::DECCARA_ChangeAttributesRectangularArea: - success = _dispatch->ChangeAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4)); + _dispatch->ChangeAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4)); break; case CsiActionCodes::DECRARA_ReverseAttributesRectangularArea: - success = _dispatch->ReverseAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4)); + _dispatch->ReverseAttributesRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.subspan(4)); break; case CsiActionCodes::DECCRA_CopyRectangularArea: - success = _dispatch->CopyRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.at(4), parameters.at(5), parameters.at(6), parameters.at(7)); + _dispatch->CopyRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.at(4), parameters.at(5), parameters.at(6), parameters.at(7)); break; case CsiActionCodes::DECRQTSR_RequestTerminalStateReport: - success = _dispatch->RequestTerminalStateReport(parameters.at(0), parameters.at(1)); + _dispatch->RequestTerminalStateReport(parameters.at(0), parameters.at(1)); break; case CsiActionCodes::DECRQPSR_RequestPresentationStateReport: - success = _dispatch->RequestPresentationStateReport(parameters.at(0)); + _dispatch->RequestPresentationStateReport(parameters.at(0)); break; case CsiActionCodes::DECFRA_FillRectangularArea: - success = _dispatch->FillRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2), parameters.at(3).value_or(0), parameters.at(4).value_or(0)); + _dispatch->FillRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2), parameters.at(3).value_or(0), parameters.at(4).value_or(0)); break; case CsiActionCodes::DECERA_EraseRectangularArea: - success = _dispatch->EraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0)); + _dispatch->EraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0)); break; case CsiActionCodes::DECSERA_SelectiveEraseRectangularArea: - success = _dispatch->SelectiveEraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0)); + _dispatch->SelectiveEraseRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0)); break; case CsiActionCodes::DECRQUPSS_RequestUserPreferenceSupplementalSet: - success = _dispatch->RequestUserPreferenceCharset(); + _dispatch->RequestUserPreferenceCharset(); break; case CsiActionCodes::DECIC_InsertColumn: - success = _dispatch->InsertColumn(parameters.at(0)); + _dispatch->InsertColumn(parameters.at(0)); break; case CsiActionCodes::DECDC_DeleteColumn: - success = _dispatch->DeleteColumn(parameters.at(0)); + _dispatch->DeleteColumn(parameters.at(0)); break; case CsiActionCodes::DECSACE_SelectAttributeChangeExtent: - success = _dispatch->SelectAttributeChangeExtent(parameters.at(0)); + _dispatch->SelectAttributeChangeExtent(parameters.at(0)); break; case CsiActionCodes::DECRQCRA_RequestChecksumRectangularArea: - success = _dispatch->RequestChecksumRectangularArea(parameters.at(0).value_or(0), parameters.at(1).value_or(0), parameters.at(2), parameters.at(3), parameters.at(4).value_or(0), parameters.at(5).value_or(0)); + _dispatch->RequestChecksumRectangularArea(parameters.at(0).value_or(0), parameters.at(1).value_or(0), parameters.at(2), parameters.at(3), parameters.at(4).value_or(0), parameters.at(5).value_or(0)); break; case CsiActionCodes::DECINVM_InvokeMacro: - success = _dispatch->InvokeMacro(parameters.at(0).value_or(0)); + _dispatch->InvokeMacro(parameters.at(0).value_or(0)); break; case CsiActionCodes::DECAC_AssignColor: - success = _dispatch->AssignColor(parameters.at(0), parameters.at(1).value_or(0), parameters.at(2).value_or(0)); + _dispatch->AssignColor(parameters.at(0), parameters.at(1).value_or(0), parameters.at(2).value_or(0)); break; case CsiActionCodes::DECPS_PlaySound: - success = _dispatch->PlaySounds(parameters); + _dispatch->PlaySounds(parameters); break; default: - // If no functions to call, overall dispatch was a failure. - success = false; break; } _ClearLastChar(); - return success; + return true; } // Routine Description: @@ -733,32 +728,6 @@ IStateMachineEngine::StringHandler OutputStateMachineEngine::ActionDcsDispatch(c return handler; } -// Routine Description: -// - Triggers the Clear action to indicate that the state machine should erase -// all internal state. -// Arguments: -// - -// Return Value: -// - -bool OutputStateMachineEngine::ActionClear() noexcept -{ - // do nothing. - return true; -} - -// Routine Description: -// - Triggers the Ignore action to indicate that the state machine should eat -// this character and say nothing. -// Arguments: -// - -// Return Value: -// - -bool OutputStateMachineEngine::ActionIgnore() noexcept -{ - // do nothing. - return true; -} - // Routine Description: // - Triggers the OscDispatch action to indicate that the listener should handle a control sequence. // These sequences perform various API-type commands that can include many parameters. @@ -769,8 +738,6 @@ bool OutputStateMachineEngine::ActionIgnore() noexcept // - true if we handled the dispatch. bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const std::wstring_view string) { - auto success = false; - switch (parameter) { case OscActionCodes::SetIconAndWindowTitle: @@ -778,25 +745,27 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s case OscActionCodes::SetWindowTitle: case OscActionCodes::DECSWT_SetWindowTitle: { - success = _dispatch->SetWindowTitle(string); + _dispatch->SetWindowTitle(string); break; } case OscActionCodes::SetColor: { std::vector tableIndexes; std::vector colors; - success = _GetOscSetColorTable(string, tableIndexes, colors); - for (size_t i = 0; i < tableIndexes.size(); i++) + if (_GetOscSetColorTable(string, tableIndexes, colors)) { - const auto tableIndex = til::at(tableIndexes, i); - const auto rgb = til::at(colors, i); - if (rgb == COLOR_INQUIRY_COLOR) - { - success = success && _dispatch->RequestColorTableEntry(tableIndex); - } - else + for (size_t i = 0; i < tableIndexes.size(); i++) { - success = success && _dispatch->SetColorTableEntry(tableIndex, rgb); + const auto tableIndex = til::at(tableIndexes, i); + const auto rgb = til::at(colors, i); + if (rgb == COLOR_INQUIRY_COLOR) + { + _dispatch->RequestColorTableEntry(tableIndex); + } + else + { + _dispatch->SetColorTableEntry(tableIndex, rgb); + } } } break; @@ -807,19 +776,18 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s case OscActionCodes::SetHighlightColor: { std::vector colors; - success = _GetOscSetColor(string, colors); - if (success) + if (_GetOscSetColor(string, colors)) { auto resource = parameter; for (auto&& color : colors) { if (color == COLOR_INQUIRY_COLOR) { - success = success && _dispatch->RequestXtermColorResource(resource); + _dispatch->RequestXtermColorResource(resource); } else if (color != INVALID_COLOR) { - success = success && _dispatch->SetXtermColorResource(resource, color); + _dispatch->SetXtermColorResource(resource, color); } resource++; } @@ -830,68 +798,67 @@ bool OutputStateMachineEngine::ActionOscDispatch(const size_t parameter, const s { std::wstring setClipboardContent; auto queryClipboard = false; - success = _GetOscSetClipboard(string, setClipboardContent, queryClipboard); - if (success && !queryClipboard) + if (_GetOscSetClipboard(string, setClipboardContent, queryClipboard) && !queryClipboard) { - success = _dispatch->SetClipboard(setClipboardContent); + _dispatch->SetClipboard(setClipboardContent); } break; } case OscActionCodes::ResetCursorColor: { - /* The reset codes for xterm dynamic resources are the set codes + 100 */ - success = _dispatch->SetXtermColorResource(parameter - 100u, INVALID_COLOR); + // The reset codes for xterm dynamic resources are the set codes + 100 + _dispatch->SetXtermColorResource(parameter - 100u, INVALID_COLOR); break; } case OscActionCodes::Hyperlink: { std::wstring params; std::wstring uri; - success = _ParseHyperlink(string, params, uri); - if (uri.empty()) + if (_ParseHyperlink(string, params, uri)) { - success = success && _dispatch->EndHyperlink(); - } - else - { - success = success && _dispatch->AddHyperlink(uri, params); + if (uri.empty()) + { + _dispatch->EndHyperlink(); + } + else + { + _dispatch->AddHyperlink(uri, params); + } } break; } case OscActionCodes::ConEmuAction: { - success = _dispatch->DoConEmuAction(string); + _dispatch->DoConEmuAction(string); break; } case OscActionCodes::ITerm2Action: { - success = _dispatch->DoITerm2Action(string); + _dispatch->DoITerm2Action(string); break; } case OscActionCodes::FinalTermAction: { - success = _dispatch->DoFinalTermAction(string); + _dispatch->DoFinalTermAction(string); break; } case OscActionCodes::VsCodeAction: { - success = _dispatch->DoVsCodeAction(string); + _dispatch->DoVsCodeAction(string); break; } case OscActionCodes::WTAction: { - success = _dispatch->DoWTAction(string); + _dispatch->DoWTAction(string); break; } default: - // If no functions to call, overall dispatch was a failure. - success = false; break; } _ClearLastChar(); - return success; + return true; } // Routine Description: @@ -907,7 +874,7 @@ bool OutputStateMachineEngine::ActionSs3Dispatch(const wchar_t /*wch*/, const VT { // The output engine doesn't handle any SS3 sequences. _ClearLastChar(); - return false; + return true; } // Routine Description: diff --git a/src/terminal/parser/OutputStateMachineEngine.hpp b/src/terminal/parser/OutputStateMachineEngine.hpp index d616294c472..ad594c269cd 100644 --- a/src/terminal/parser/OutputStateMachineEngine.hpp +++ b/src/terminal/parser/OutputStateMachineEngine.hpp @@ -33,7 +33,7 @@ namespace Microsoft::Console::VirtualTerminal bool ActionPrintString(const std::wstring_view string) override; - bool ActionPassThroughString(const std::wstring_view string, const bool flush) noexcept override; + bool ActionPassThroughString(const std::wstring_view string) noexcept override; bool ActionEscDispatch(const VTID id) override; @@ -43,10 +43,6 @@ namespace Microsoft::Console::VirtualTerminal StringHandler ActionDcsDispatch(const VTID id, const VTParameters parameters) override; - bool ActionClear() noexcept override; - - bool ActionIgnore() noexcept override; - bool ActionOscDispatch(const size_t parameter, const std::wstring_view string) override; bool ActionSs3Dispatch(const wchar_t wch, const VTParameters parameters) noexcept override; diff --git a/src/terminal/parser/stateMachine.cpp b/src/terminal/parser/stateMachine.cpp index 0eebe1308c9..65e7460e9b8 100644 --- a/src/terminal/parser/stateMachine.cpp +++ b/src/terminal/parser/stateMachine.cpp @@ -11,7 +11,7 @@ using namespace Microsoft::Console::VirtualTerminal; //Takes ownership of the pEngine. -StateMachine::StateMachine(std::unique_ptr engine, const bool isEngineForInput) : +StateMachine::StateMachine(std::unique_ptr engine, const bool isEngineForInput) noexcept : _engine(std::move(engine)), _isEngineForInput(isEngineForInput), _state(VTStates::Ground), @@ -606,7 +606,7 @@ void StateMachine::_ActionSubParam(const wchar_t wch) // - wch - Character to dispatch. // Return Value: // - -void StateMachine::_ActionClear() +void StateMachine::_ActionClear() noexcept { _trace.TraceOnAction(L"Clear"); @@ -625,8 +625,6 @@ void StateMachine::_ActionClear() _oscParameter = 0; _dcsStringHandler = nullptr; - - _engine->ActionClear(); } // Routine Description: @@ -728,14 +726,14 @@ void StateMachine::_ActionDcsDispatch(const wchar_t wch) const auto success = _SafeExecute([=]() { _dcsStringHandler = _engine->ActionDcsDispatch(_identifier.Finalize(wch), { _parameters.data(), _parameters.size() }); - // If the returned handler is null, the sequence is not supported. - return _dcsStringHandler != nullptr; + return true; }); // Trace the result. _trace.DispatchSequenceTrace(success); - if (success) + // If the returned handler is null, the sequence is not supported. + if (_dcsStringHandler) { // If successful, enter the pass through state. _EnterDcsPassThrough(); @@ -771,7 +769,7 @@ void StateMachine::_EnterGround() noexcept // - // Return Value: // - -void StateMachine::_EnterEscape() +void StateMachine::_EnterEscape() noexcept { _state = VTStates::Escape; _trace.TraceStateChange(L"Escape"); @@ -801,7 +799,7 @@ void StateMachine::_EnterEscapeIntermediate() noexcept // - // Return Value: // - -void StateMachine::_EnterCsiEntry() +void StateMachine::_EnterCsiEntry() noexcept { _state = VTStates::CsiEntry; _trace.TraceStateChange(L"CsiEntry"); @@ -917,7 +915,7 @@ void StateMachine::_EnterOscTermination() noexcept // - // Return Value: // - -void StateMachine::_EnterSs3Entry() +void StateMachine::_EnterSs3Entry() noexcept { _state = VTStates::Ss3Entry; _trace.TraceStateChange(L"Ss3Entry"); @@ -960,7 +958,7 @@ void StateMachine::_EnterVt52Param() noexcept // - // Return Value: // - -void StateMachine::_EnterDcsEntry() +void StateMachine::_EnterDcsEntry() noexcept { _state = VTStates::DcsEntry; _trace.TraceStateChange(L"DcsEntry"); @@ -2169,11 +2167,13 @@ template bool StateMachine::_SafeExecute(TLambda&& lambda) try { - return lambda(); -} -catch (const ShutdownException&) -{ - throw; + const auto ok = lambda(); + static_assert(std::is_same_v, "lambda must return bool"); + if (!ok) + { + FlushToTerminal(); + } + return ok; } catch (...) { diff --git a/src/terminal/parser/stateMachine.hpp b/src/terminal/parser/stateMachine.hpp index a1c0fed8f67..42756abd15d 100644 --- a/src/terminal/parser/stateMachine.hpp +++ b/src/terminal/parser/stateMachine.hpp @@ -64,11 +64,11 @@ namespace Microsoft::Console::VirtualTerminal public: template - StateMachine(std::unique_ptr engine) : + StateMachine(std::unique_ptr engine) noexcept : StateMachine(std::move(engine), std::is_same_v) { } - StateMachine(std::unique_ptr engine, const bool isEngineForInput); + StateMachine(std::unique_ptr engine, const bool isEngineForInput) noexcept; enum class Mode : size_t { @@ -93,13 +93,6 @@ namespace Microsoft::Console::VirtualTerminal const IStateMachineEngine& Engine() const noexcept; IStateMachineEngine& Engine() noexcept; - class ShutdownException : public wil::ResultException - { - public: - ShutdownException() noexcept : - ResultException(E_ABORT) {} - }; - private: void _ActionExecute(const wchar_t wch); void _ActionExecuteFromEscape(const wchar_t wch); @@ -117,14 +110,14 @@ namespace Microsoft::Console::VirtualTerminal void _ActionSs3Dispatch(const wchar_t wch); void _ActionDcsDispatch(const wchar_t wch); - void _ActionClear(); + void _ActionClear() noexcept; void _ActionIgnore() noexcept; void _ActionInterrupt(); void _EnterGround() noexcept; - void _EnterEscape(); + void _EnterEscape() noexcept; void _EnterEscapeIntermediate() noexcept; - void _EnterCsiEntry(); + void _EnterCsiEntry() noexcept; void _EnterCsiParam() noexcept; void _EnterCsiSubParam() noexcept; void _EnterCsiIgnore() noexcept; @@ -132,10 +125,10 @@ namespace Microsoft::Console::VirtualTerminal void _EnterOscParam() noexcept; void _EnterOscString() noexcept; void _EnterOscTermination() noexcept; - void _EnterSs3Entry(); + void _EnterSs3Entry() noexcept; void _EnterSs3Param() noexcept; void _EnterVt52Param() noexcept; - void _EnterDcsEntry(); + void _EnterDcsEntry() noexcept; void _EnterDcsParam() noexcept; void _EnterDcsIgnore() noexcept; void _EnterDcsIntermediate() noexcept; diff --git a/src/terminal/parser/ut_parser/InputEngineTest.cpp b/src/terminal/parser/ut_parser/InputEngineTest.cpp index fcb23734be5..00684b36ff0 100644 --- a/src/terminal/parser/ut_parser/InputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/InputEngineTest.cpp @@ -250,7 +250,6 @@ class Microsoft::Console::VirtualTerminal::InputEngineTest TEST_METHOD(C0Test); TEST_METHOD(AlphanumericTest); TEST_METHOD(RoundTripTest); - TEST_METHOD(WindowManipulationTest); TEST_METHOD(NonAsciiTest); TEST_METHOD(CursorPositioningTest); TEST_METHOD(CSICursorBackTabTest); @@ -316,20 +315,20 @@ class Microsoft::Console::VirtualTerminal::TestInteractDispatch final : public I public: TestInteractDispatch(_In_ std::function&)> pfn, _In_ TestState* testState); - virtual bool WriteInput(_In_ const std::span& inputEvents) override; + virtual void WriteInput(_In_ const std::span& inputEvents) override; - virtual bool WriteCtrlKey(const INPUT_RECORD& event) override; - virtual bool WindowManipulation(const DispatchTypes::WindowManipulationType function, + virtual void WriteCtrlKey(const INPUT_RECORD& event) override; + virtual void WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) override; // DTTERM_WindowManipulation - virtual bool WriteString(const std::wstring_view string) override; + virtual void WriteString(const std::wstring_view string) override; - virtual bool MoveCursor(const VTInt row, + virtual void MoveCursor(const VTInt row, const VTInt col) override; virtual bool IsVtInputEnabled() const override; - virtual bool FocusChanged(const bool focused) const override; + virtual void FocusChanged(const bool focused) override; private: std::function&)> _pfnWriteInputCallback; @@ -343,19 +342,18 @@ TestInteractDispatch::TestInteractDispatch(_In_ std::function& inputEvents) +void TestInteractDispatch::WriteInput(_In_ const std::span& inputEvents) { _pfnWriteInputCallback(inputEvents); - return true; } -bool TestInteractDispatch::WriteCtrlKey(const INPUT_RECORD& event) +void TestInteractDispatch::WriteCtrlKey(const INPUT_RECORD& event) { VERIFY_IS_TRUE(_testState->_expectSendCtrlC); - return WriteInput({ &event, 1 }); + WriteInput({ &event, 1 }); } -bool TestInteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, +void TestInteractDispatch::WindowManipulation(const DispatchTypes::WindowManipulationType function, const VTParameter parameter1, const VTParameter parameter2) { @@ -363,10 +361,9 @@ bool TestInteractDispatch::WindowManipulation(const DispatchTypes::WindowManipul VERIFY_ARE_EQUAL(_testState->_expectedWindowManipulation, function); VERIFY_ARE_EQUAL(_testState->_expectedParams[0], parameter1.value_or(0)); VERIFY_ARE_EQUAL(_testState->_expectedParams[1], parameter2.value_or(0)); - return true; } -bool TestInteractDispatch::WriteString(const std::wstring_view string) +void TestInteractDispatch::WriteString(const std::wstring_view string) { InputEventQueue keyEvents; @@ -377,25 +374,23 @@ bool TestInteractDispatch::WriteString(const std::wstring_view string) Microsoft::Console::Interactivity::CharToKeyEvents(wch, CP_USA, keyEvents); } - return WriteInput(keyEvents); + WriteInput(keyEvents); } -bool TestInteractDispatch::MoveCursor(const VTInt row, const VTInt col) +void TestInteractDispatch::MoveCursor(const VTInt row, const VTInt col) { VERIFY_IS_TRUE(_testState->_expectCursorPosition); til::point received{ col, row }; VERIFY_ARE_EQUAL(_testState->_expectedCursor, received); - return true; } bool TestInteractDispatch::IsVtInputEnabled() const { - return true; + return false; } -bool TestInteractDispatch::FocusChanged(const bool /*focused*/) const +void TestInteractDispatch::FocusChanged(const bool /*focused*/) { - return false; } void InputEngineTest::C0Test() @@ -612,60 +607,6 @@ void InputEngineTest::RoundTripTest() */ } -void InputEngineTest::WindowManipulationTest() -{ - auto pfn = std::bind(&TestState::TestInputCallback, &testState, std::placeholders::_1); - auto dispatch = std::make_unique(pfn, &testState); - auto inputEngine = std::make_unique(std::move(dispatch)); - auto _stateMachine = std::make_unique(std::move(inputEngine)); - VERIFY_IS_NOT_NULL(_stateMachine.get()); - testState._stateMachine = _stateMachine.get(); - - Log::Comment(NoThrowString().Format( - L"Try sending a bunch of Window Manipulation sequences. " - L"Only the valid ones should call the " - L"TestInteractDispatch::WindowManipulation callback.")); - - const auto param1 = 123; - const auto param2 = 456; - const auto wszParam1 = L"123"; - const auto wszParam2 = L"456"; - - for (unsigned int i = 0; i < static_cast(BYTE_MAX); i++) - { - std::wstringstream seqBuilder; - seqBuilder << L"\x1b[" << i; - - if (i == DispatchTypes::WindowManipulationType::ResizeWindowInCharacters) - { - // We need to build the string with the params as strings for some reason - - // x86 would implicitly convert them to chars (eg 123 -> '{') - // before appending them to the string - seqBuilder << L";" << wszParam1 << L";" << wszParam2; - - testState._expectedToCallWindowManipulation = true; - testState._expectedParams[0] = param1; - testState._expectedParams[1] = param2; - testState._expectedWindowManipulation = static_cast(i); - } - else - { - // other operations don't expect any params. - - testState._expectedToCallWindowManipulation = true; - testState._expectedParams[0] = 0; - testState._expectedParams[1] = 0; - testState._expectedWindowManipulation = static_cast(i); - } - seqBuilder << L"t"; - auto seq = seqBuilder.str(); - Log::Comment(NoThrowString().Format( - L"Processing \"%s\"", seq.c_str())); - _stateMachine->ProcessString(seq); - } - VerifyExpectedInputDrained(); -} - void InputEngineTest::NonAsciiTest() { auto pfn = std::bind(&TestState::TestInputStringCallback, &testState, std::placeholders::_1); diff --git a/src/terminal/parser/ut_parser/OutputEngineTest.cpp b/src/terminal/parser/ut_parser/OutputEngineTest.cpp index 8a5015e25cb..416ed6681d9 100644 --- a/src/terminal/parser/ut_parser/OutputEngineTest.cpp +++ b/src/terminal/parser/ut_parser/OutputEngineTest.cpp @@ -1173,128 +1173,110 @@ class StatefulDispatch final : public TermDispatch *this = dispatch; } - bool CursorUp(const VTInt uiDistance) noexcept override + void CursorUp(const VTInt uiDistance) noexcept override { _cursorUp = true; _cursorDistance = uiDistance; - return true; } - bool CursorDown(const VTInt uiDistance) noexcept override + void CursorDown(const VTInt uiDistance) noexcept override { _cursorDown = true; _cursorDistance = uiDistance; - return true; } - bool CursorBackward(const VTInt uiDistance) noexcept override + void CursorBackward(const VTInt uiDistance) noexcept override { _cursorBackward = true; _cursorDistance = uiDistance; - return true; } - bool CursorForward(const VTInt uiDistance) noexcept override + void CursorForward(const VTInt uiDistance) noexcept override { _cursorForward = true; _cursorDistance = uiDistance; - return true; } - bool CursorNextLine(const VTInt uiDistance) noexcept override + void CursorNextLine(const VTInt uiDistance) noexcept override { _cursorNextLine = true; _cursorDistance = uiDistance; - return true; } - bool CursorPrevLine(const VTInt uiDistance) noexcept override + void CursorPrevLine(const VTInt uiDistance) noexcept override { _cursorPreviousLine = true; _cursorDistance = uiDistance; - return true; } - bool CursorHorizontalPositionAbsolute(const VTInt uiPosition) noexcept override + void CursorHorizontalPositionAbsolute(const VTInt uiPosition) noexcept override { _cursorHorizontalPositionAbsolute = true; _cursorDistance = uiPosition; - return true; } - bool VerticalLinePositionAbsolute(const VTInt uiPosition) noexcept override + void VerticalLinePositionAbsolute(const VTInt uiPosition) noexcept override { _verticalLinePositionAbsolute = true; _cursorDistance = uiPosition; - return true; } - bool HorizontalPositionRelative(const VTInt uiDistance) noexcept override + void HorizontalPositionRelative(const VTInt uiDistance) noexcept override { _horizontalPositionRelative = true; _cursorDistance = uiDistance; - return true; } - bool VerticalPositionRelative(const VTInt uiDistance) noexcept override + void VerticalPositionRelative(const VTInt uiDistance) noexcept override { _verticalPositionRelative = true; _cursorDistance = uiDistance; - return true; } - bool CursorPosition(const VTInt uiLine, const VTInt uiColumn) noexcept override + void CursorPosition(const VTInt uiLine, const VTInt uiColumn) noexcept override { _cursorPosition = true; _line = uiLine; _column = uiColumn; - return true; } - bool CursorSaveState() noexcept override + void CursorSaveState() noexcept override { _cursorSave = true; - return true; } - bool CursorRestoreState() noexcept override + void CursorRestoreState() noexcept override { _cursorLoad = true; - return true; } - bool EraseInDisplay(const DispatchTypes::EraseType eraseType) noexcept override + void EraseInDisplay(const DispatchTypes::EraseType eraseType) noexcept override { _eraseDisplay = true; _eraseType = eraseType; _eraseTypes.push_back(eraseType); - return true; } - bool EraseInLine(const DispatchTypes::EraseType eraseType) noexcept override + void EraseInLine(const DispatchTypes::EraseType eraseType) noexcept override { _eraseLine = true; _eraseType = eraseType; _eraseTypes.push_back(eraseType); - return true; } - bool InsertCharacter(const VTInt uiCount) noexcept override + void InsertCharacter(const VTInt uiCount) noexcept override { _insertCharacter = true; _cursorDistance = uiCount; - return true; } - bool DeleteCharacter(const VTInt uiCount) noexcept override + void DeleteCharacter(const VTInt uiCount) noexcept override { _deleteCharacter = true; _cursorDistance = uiCount; - return true; } - bool SetGraphicsRendition(const VTParameters options) noexcept override - try + void SetGraphicsRendition(const VTParameters options) noexcept override { _options.clear(); for (size_t i = 0; i < options.size(); i++) @@ -1302,158 +1284,129 @@ class StatefulDispatch final : public TermDispatch _options.push_back(options.at(i)); } _setGraphics = true; - return true; } - CATCH_LOG_RETURN_FALSE() - bool DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter /*id*/) noexcept override + void DeviceStatusReport(const DispatchTypes::StatusType statusType, const VTParameter /*id*/) noexcept override { _deviceStatusReport = true; _statusReportType = statusType; - - return true; } - bool DeviceAttributes() noexcept override + void DeviceAttributes() noexcept override { _deviceAttributes = true; - - return true; } - bool SecondaryDeviceAttributes() noexcept override + void SecondaryDeviceAttributes() noexcept override { _secondaryDeviceAttributes = true; - - return true; } - bool TertiaryDeviceAttributes() noexcept override + void TertiaryDeviceAttributes() noexcept override { _tertiaryDeviceAttributes = true; - - return true; } - bool Vt52DeviceAttributes() noexcept override + void Vt52DeviceAttributes() noexcept override { _vt52DeviceAttributes = true; - - return true; } - bool RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) noexcept override + void RequestTerminalParameters(const DispatchTypes::ReportingPermission permission) noexcept override { _requestTerminalParameters = true; _reportingPermission = permission; - - return true; } - bool _ModeParamsHelper(_In_ DispatchTypes::ModeParams const param, const bool fEnable) + void _ModeParamsHelper(_In_ DispatchTypes::ModeParams const param, const bool fEnable) { _modeType = param; _modeTypes.push_back(param); _modeEnabled = fEnable; - - return true; } - bool SetMode(const DispatchTypes::ModeParams param) noexcept override + void SetMode(const DispatchTypes::ModeParams param) noexcept override { - return _ModeParamsHelper(param, true); + _ModeParamsHelper(param, true); } - bool ResetMode(const DispatchTypes::ModeParams param) noexcept override + void ResetMode(const DispatchTypes::ModeParams param) noexcept override { - return _ModeParamsHelper(param, false); + _ModeParamsHelper(param, false); } - bool SetAnsiMode(const bool ansiMode) noexcept override + void SetAnsiMode(const bool ansiMode) noexcept override { _ModeParamsHelper(DispatchTypes::DECANM_AnsiMode, ansiMode); - return true; } - bool WarningBell() noexcept override + void WarningBell() noexcept override { _warningBell = true; - return true; } - bool CarriageReturn() noexcept override + void CarriageReturn() noexcept override { _carriageReturn = true; - return true; } - bool LineFeed(const DispatchTypes::LineFeedType lineFeedType) noexcept override + void LineFeed(const DispatchTypes::LineFeedType lineFeedType) noexcept override { _lineFeed = true; _lineFeedType = lineFeedType; - return true; } - bool ReverseLineFeed() noexcept override + void ReverseLineFeed() noexcept override { _reverseLineFeed = true; - return true; } - bool SetWindowTitle(std::wstring_view title) override + void SetWindowTitle(std::wstring_view title) override { _setWindowTitle = true; _setWindowTitleText = title; - return true; } - bool ForwardTab(const VTInt numTabs) noexcept override + void ForwardTab(const VTInt numTabs) noexcept override { _forwardTab = true; _numTabs = numTabs; - return true; } - bool TabClear(const DispatchTypes::TabClearType clearType) noexcept override + void TabClear(const DispatchTypes::TabClearType clearType) noexcept override { _tabClear = true; _tabClearTypes.push_back(clearType); - return true; } - bool SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override + void SetColorTableEntry(const size_t tableIndex, const COLORREF color) noexcept override { _setColorTableEntry = true; _colorTable.at(tableIndex) = color; - return true; } - bool RequestColorTableEntry(const size_t tableIndex) noexcept override + void RequestColorTableEntry(const size_t tableIndex) noexcept override { _colorTableEntriesRequested.push_back(tableIndex); - return true; } - bool SetXtermColorResource(const size_t resource, const DWORD color) override + void SetXtermColorResource(const size_t resource, const DWORD color) override { _xtermResourcesChanged.push_back(resource); _xtermResourceValues.push_back(color); - return true; } - bool RequestXtermColorResource(const size_t resource) override + void RequestXtermColorResource(const size_t resource) override { _xtermResourcesRequested.push_back(resource); - return true; } - bool SetClipboard(wil::zwstring_view content) noexcept override + void SetClipboard(wil::zwstring_view content) noexcept override { _copyContent = content; - return true; } - bool AddHyperlink(std::wstring_view uri, std::wstring_view params) noexcept override + void AddHyperlink(std::wstring_view uri, std::wstring_view params) noexcept override { _hyperlinkMode = true; _uri = uri; @@ -1461,20 +1414,17 @@ class StatefulDispatch final : public TermDispatch { _customId = params; } - return true; } - bool EndHyperlink() noexcept override + void EndHyperlink() noexcept override { _hyperlinkMode = false; _uri.clear(); _customId.clear(); - return true; } - bool DoConEmuAction(const std::wstring_view /*string*/) noexcept override + void DoConEmuAction(const std::wstring_view /*string*/) noexcept override { - return true; } std::wstring _printString; @@ -1544,11 +1494,6 @@ class StateMachineExternalTest final { TEST_CLASS(StateMachineExternalTest); - TEST_METHOD_SETUP(SetupState) - { - return true; - } - void InsertNumberToMachine(StateMachine* const pMachine, size_t number) { static const size_t cchBufferMax = 20; diff --git a/src/terminal/parser/ut_parser/StateMachineTest.cpp b/src/terminal/parser/ut_parser/StateMachineTest.cpp index f910a72c1a4..b26243e0271 100644 --- a/src/terminal/parser/ut_parser/StateMachineTest.cpp +++ b/src/terminal/parser/ut_parser/StateMachineTest.cpp @@ -59,7 +59,7 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat return true; }; - bool ActionPassThroughString(const std::wstring_view string, const bool /*flush*/) override + bool ActionPassThroughString(const std::wstring_view string) override { passedThrough += string; return true; @@ -69,10 +69,6 @@ class Microsoft::Console::VirtualTerminal::TestStateMachineEngine : public IStat bool ActionVt52EscDispatch(const VTID /*id*/, const VTParameters /*parameters*/) override { return true; }; - bool ActionClear() override { return true; }; - - bool ActionIgnore() override { return true; }; - bool ActionOscDispatch(const size_t /* parameter */, const std::wstring_view /* string */) override { if (pfnFlushToTerminal)