Reset C1 parsing mode in DECSTR and DECRC.

This commit is contained in:
James Holderness 2021-11-04 15:42:42 +00:00
parent 4467b4fe53
commit d41a0ff12c
8 changed files with 36 additions and 0 deletions

View file

@ -279,6 +279,20 @@ bool ConhostInternalGetSet::SetParserMode(const StateMachine::Mode mode, const b
return true;
}
// Routine Description:
// - Retrieves the various StateMachine parser modes.
// GetParserMode is an internal-only "API" call that the vt commands can execute,
// but it is not represented as a function call on out public API surface.
// Arguments:
// - mode - the parser mode to query.
// Return Value:
// - true if the mode is enabled. false if disabled.
bool ConhostInternalGetSet::GetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode) const
{
auto& stateMachine = _io.GetActiveOutputBuffer().GetStateMachine();
return stateMachine.GetParserMode(mode);
}
// Routine Description:
// - Connects the PrivateSetScreenMode call directly into our Driver Message servicing call inside Conhost.exe
// PrivateSetScreenMode is an internal-only "API" call that the vt commands can execute,

View file

@ -74,6 +74,7 @@ public:
bool SetInputMode(const Microsoft::Console::VirtualTerminal::TerminalInput::Mode mode, const bool enabled) override;
bool SetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode, const bool enabled) override;
bool GetParserMode(const Microsoft::Console::VirtualTerminal::StateMachine::Mode mode) const override;
bool PrivateSetScreenMode(const bool reverseMode) override;
bool PrivateSetAutoWrapMode(const bool wrapAtEOL) override;

View file

@ -344,6 +344,7 @@ bool AdaptDispatch::CursorSaveState()
savedCursorState.IsOriginModeRelative = _isOriginModeRelative;
savedCursorState.Attributes = attributes;
savedCursorState.TermOutput = _termOutput;
savedCursorState.C1ControlsAccepted = _pConApi->GetParserMode(StateMachine::Mode::AcceptC1);
_pConApi->GetConsoleOutputCP(savedCursorState.CodePage);
}
@ -386,6 +387,9 @@ bool AdaptDispatch::CursorRestoreState()
// Restore designated character set.
_termOutput = savedCursorState.TermOutput;
// Restore the parsing state of C1 control codes.
_pConApi->SetParserMode(StateMachine::Mode::AcceptC1, savedCursorState.C1ControlsAccepted);
// Restore the code page if it was previously saved.
if (savedCursorState.CodePage != 0)
{
@ -1848,6 +1852,8 @@ bool AdaptDispatch::SoftReset()
// Restore initial code page if previously changed by a DOCS sequence.
success = _pConApi->SetConsoleOutputCP(_initialCodePage.value()) && success;
}
// Disable parsing of C1 control codes.
success = _pConApi->SetParserMode(StateMachine::Mode::AcceptC1, false) && success;
success = SetGraphicsRendition({}) && success; // Normal rendition.

View file

@ -155,6 +155,7 @@ namespace Microsoft::Console::VirtualTerminal
bool IsOriginModeRelative = false;
TextAttribute Attributes = {};
TerminalOutput TermOutput = {};
bool C1ControlsAccepted = false;
unsigned int CodePage = 0;
};
struct Offset

View file

@ -51,6 +51,7 @@ namespace Microsoft::Console::VirtualTerminal
virtual bool SetInputMode(const TerminalInput::Mode mode, const bool enabled) = 0;
virtual bool SetParserMode(const StateMachine::Mode mode, const bool enabled) = 0;
virtual bool GetParserMode(const StateMachine::Mode mode) const = 0;
virtual bool PrivateSetScreenMode(const bool reverseMode) = 0;
virtual bool PrivateSetAutoWrapMode(const bool wrapAtEOL) = 0;

View file

@ -138,6 +138,13 @@ public:
return _setParserModeResult;
}
bool GetParserMode(const StateMachine::Mode /*mode*/) const override
{
Log::Comment(L"GetParserMode MOCK called...");
return false;
}
bool PrivateSetScreenMode(const bool /*reverseMode*/) override
{
Log::Comment(L"PrivateSetScreenMode MOCK called...");

View file

@ -28,6 +28,11 @@ void StateMachine::SetParserMode(const Mode mode, const bool enabled)
_parserMode.set(mode, enabled);
}
bool StateMachine::GetParserMode(const Mode mode) const
{
return _parserMode.test(mode);
}
const IStateMachineEngine& StateMachine::Engine() const noexcept
{
return *_engine;

View file

@ -49,6 +49,7 @@ namespace Microsoft::Console::VirtualTerminal
};
void SetParserMode(const Mode mode, const bool enabled);
bool GetParserMode(const Mode mode) const;
void ProcessCharacter(const wchar_t wch);
void ProcessString(const std::wstring_view string);