Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void Terminal::UpdateSettings(ICoreSettings settings)

if (_stateMachine)
{
SetVtChecksumReportSupport(settings.AllowVtChecksumReport());
SetOptionalFeatures(settings);
}

_getTerminalInput().ForceDisableWin32InputMode(settings.ForceVTInput());
Expand Down Expand Up @@ -219,10 +219,13 @@ void Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
engine.Dispatch().SetCursorStyle(cursorStyle);
}

void Terminal::SetVtChecksumReportSupport(const bool enabled)
void Terminal::SetOptionalFeatures(winrt::Microsoft::Terminal::Core::ICoreSettings settings)
{
auto& engine = reinterpret_cast<OutputStateMachineEngine&>(_stateMachine->Engine());
engine.Dispatch().SetVtChecksumReportSupport(enabled);
auto features = til::enumset<ITermDispatch::OptionalFeature>{};
features.set(ITermDispatch::OptionalFeature::ChecksumReport, settings.AllowVtChecksumReport());
features.set(ITermDispatch::OptionalFeature::ClipboardWrite, settings.AllowVtClipboardWrite());
engine.Dispatch().SetOptionalFeatures(features);
}

bool Terminal::IsXtermBracketedPasteModeEnabled() const noexcept
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Microsoft::Terminal::Core::Terminal final :
void UpdateAppearance(const winrt::Microsoft::Terminal::Core::ICoreAppearance& appearance);
void SetFontInfo(const FontInfo& fontInfo);
void SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle);
void SetVtChecksumReportSupport(const bool enabled);
void SetOptionalFeatures(winrt::Microsoft::Terminal::Core::ICoreSettings settings);
bool IsXtermBracketedPasteModeEnabled() const noexcept;
std::wstring_view GetWorkingDirectory() noexcept;

Expand Down
9 changes: 8 additions & 1 deletion src/terminal/adapter/ITermDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
public:
using StringHandler = std::function<bool(const wchar_t)>;

enum class OptionalFeature
{
ChecksumReport,
ClipboardWrite,
};

#pragma warning(push)
#pragma warning(disable : 26432) // suppress rule of 5 violation on interface because tampering with this is fraught with peril
virtual ~ITermDispatch() = 0;
Expand Down Expand Up @@ -133,7 +139,6 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
virtual void ScreenAlignmentPattern() = 0; // DECALN

virtual void SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) = 0; // DECSCUSR
virtual void SetVtChecksumReportSupport(const bool enabled) = 0;

virtual void SetClipboard(wil::zwstring_view content) = 0; // OSCSetClipboard

Expand Down Expand Up @@ -185,6 +190,8 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
virtual StringHandler RestorePresentationState(const DispatchTypes::PresentationReportFormat format) = 0; // DECRSPS

virtual void PlaySounds(const VTParameters parameters) = 0; // DECPS

virtual void SetOptionalFeatures(const til::enumset<OptionalFeature> features) = 0;
};
inline Microsoft::Console::VirtualTerminal::ITermDispatch::~ITermDispatch() = default;
#pragma warning(pop)
22 changes: 15 additions & 7 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,11 +1297,6 @@ void AdaptDispatch::SelectAttributeChangeExtent(const DispatchTypes::ChangeExten
}
}

void AdaptDispatch::SetVtChecksumReportSupport(const bool enabled) noexcept
{
_vtChecksumReportEnabled = enabled;
}

// Routine Description:
// - DECRQCRA - Computes and reports a checksum of the specified area of
// the buffer memory.
Expand All @@ -1318,7 +1313,7 @@ void AdaptDispatch::RequestChecksumRectangularArea(const VTInt id, const VTInt p
// If this feature is not enabled, we'll just report a zero checksum.
if constexpr (Feature_VtChecksumReport::IsEnabled())
{
if (_vtChecksumReportEnabled)
if (_optionalFeatures.test(OptionalFeature::ChecksumReport))
{
// If the page number is 0, then we're meant to return a checksum of all
// of the pages, but we have no need for that, so we'll just return 0.
Expand Down Expand Up @@ -1483,8 +1478,16 @@ void AdaptDispatch::DeviceAttributes()
// 28 = Rectangular area operations
// 32 = Text macros
// 42 = ISO Latin-2 character set
// 52 = Clipboard access

_ReturnCsiResponse(L"?61;4;6;7;14;21;22;23;24;28;32;42c");
if (_optionalFeatures.test(OptionalFeature::ClipboardWrite))
{
_ReturnCsiResponse(L"?61;4;6;7;14;21;22;23;24;28;32;42;52c");
}
else
{
_ReturnCsiResponse(L"?61;4;6;7;14;21;22;23;24;28;32;42c");
}
}

// Routine Description:
Expand Down Expand Up @@ -4790,3 +4793,8 @@ void AdaptDispatch::PlaySounds(const VTParameters parameters)
_api.PlayMidiNote(noteNumber, noteNumber == 71 ? 0 : velocity, duration);
});
}

void AdaptDispatch::SetOptionalFeatures(const til::enumset<OptionalFeature> features) noexcept
{
_optionalFeatures = features;
}
4 changes: 2 additions & 2 deletions src/terminal/adapter/adaptDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace Microsoft::Console::VirtualTerminal

void PlaySounds(const VTParameters parameters) override; // DECPS

void SetVtChecksumReportSupport(const bool enabled) noexcept override;
void SetOptionalFeatures(const til::enumset<OptionalFeature> features) noexcept override;

private:
enum class Mode
Expand Down Expand Up @@ -313,7 +313,7 @@ namespace Microsoft::Console::VirtualTerminal
std::unique_ptr<FontBuffer> _fontBuffer;
std::shared_ptr<MacroBuffer> _macroBuffer;
std::optional<unsigned int> _initialCodePage;
bool _vtChecksumReportEnabled = false;
til::enumset<OptionalFeature> _optionalFeatures = { OptionalFeature::ClipboardWrite };

// We have two instances of the saved cursor state, because we need
// one for the main buffer (at index 0), and another for the alt buffer
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/adapter/termDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons

void PlaySounds(const VTParameters /*parameters*/) override{}; // DECPS

void SetVtChecksumReportSupport(const bool /*enabled*/) override{};
void SetOptionalFeatures(const til::enumset<OptionalFeature> /*features*/) override{};
};

#pragma warning(default : 26440) // Restore "can be declared noexcept" warning
13 changes: 9 additions & 4 deletions src/terminal/adapter/ut_adapter/adapterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ class AdapterTest
auto& renderer = _testGetSet->_renderer;
auto& renderSettings = renderer._renderSettings;
auto adapter = std::make_unique<AdaptDispatch>(*_testGetSet, &renderer, renderSettings, _terminalInput);
adapter->SetVtChecksumReportSupport(true);

fSuccess = adapter.get() != nullptr;
if (fSuccess)
Expand Down Expand Up @@ -1737,11 +1736,15 @@ class AdapterTest
Log::Comment(L"Test 1: Verify normal response.");
_testGetSet->PrepData();
_pDispatch->DeviceAttributes();
_testGetSet->ValidateInputEvent(L"\x1b[?61;4;6;7;14;21;22;23;24;28;32;42;52c");

auto pwszExpectedResponse = L"\x1b[?61;4;6;7;14;21;22;23;24;28;32;42c";
_testGetSet->ValidateInputEvent(pwszExpectedResponse);
Log::Comment(L"Test 2: Verify response with clipboard disabled.");
_testGetSet->PrepData();
_pDispatch->SetOptionalFeatures({});
_pDispatch->DeviceAttributes();
_testGetSet->ValidateInputEvent(L"\x1b[?61;4;6;7;14;21;22;23;24;28;32;42c");

Log::Comment(L"Test 2: Verify failure when ReturnResponse doesn't work.");
Log::Comment(L"Test 3: Verify failure when ReturnResponse doesn't work.");
_testGetSet->PrepData();
_testGetSet->_returnResponseResult = FALSE;

Expand Down Expand Up @@ -2187,6 +2190,8 @@ class AdapterTest

using namespace std::string_view_literals;

_pDispatch->SetOptionalFeatures(ITermDispatch::OptionalFeature::ChecksumReport);

Log::Comment(L"Test 1: ASCII characters");
outputText(L"A"sv);
verifyChecksumReport(L"FF4F");
Expand Down
Loading