Added support for DECSCUSR sequences (#941)
* Falling back to legacy cursor for higher values of CursorStyle Co-Authored-By: Michael Niksa <miniksa@microsoft.com>
This commit is contained in:
parent
547cba968c
commit
2d4eca7f4f
|
@ -910,6 +910,10 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
|
|||
void TermControl::_BlinkCursor(Windows::Foundation::IInspectable const& /* sender */,
|
||||
Windows::Foundation::IInspectable const& /* e */)
|
||||
{
|
||||
if (!_terminal->IsCursorBlinkingAllowed() && _terminal->IsCursorVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_terminal->SetCursorVisible(!_terminal->IsCursorVisible());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../terminal/adapter/DispatchTypes.hpp"
|
||||
|
||||
namespace Microsoft::Terminal::Core
|
||||
{
|
||||
class ITerminalApi
|
||||
|
@ -27,5 +29,7 @@ namespace Microsoft::Terminal::Core
|
|||
virtual bool SetWindowTitle(std::wstring_view title) = 0;
|
||||
|
||||
virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) = 0;
|
||||
|
||||
virtual bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) = 0;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -605,3 +605,9 @@ void Terminal::SetCursorVisible(const bool isVisible) noexcept
|
|||
auto& cursor = _buffer->GetCursor();
|
||||
cursor.SetIsVisible(isVisible);
|
||||
}
|
||||
|
||||
bool Terminal::IsCursorBlinkingAllowed() const noexcept
|
||||
{
|
||||
const auto& cursor = _buffer->GetCursor();
|
||||
return cursor.IsBlinkingAllowed();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
bool EraseCharacters(const unsigned int numChars) override;
|
||||
bool SetWindowTitle(std::wstring_view title) override;
|
||||
bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) override;
|
||||
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) override;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region ITerminalInput
|
||||
|
@ -114,6 +115,7 @@ public:
|
|||
void SetScrollPositionChangedCallback(std::function<void(const int, const int, const int)> pfn) noexcept;
|
||||
|
||||
void SetCursorVisible(const bool isVisible) noexcept;
|
||||
bool IsCursorBlinkingAllowed() const noexcept;
|
||||
|
||||
#pragma region TextSelection
|
||||
const bool IsSelectionActive() const noexcept;
|
||||
|
|
|
@ -169,3 +169,53 @@ bool Terminal::SetColorTableEntry(const size_t tableIndex, const DWORD dwColor)
|
|||
_buffer->GetRenderTarget().TriggerRedrawAll();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets the cursor style to the given style.
|
||||
// Arguments:
|
||||
// - cursorStyle: the style to be set for the cursor
|
||||
// Return Value:
|
||||
// - true iff we successfully set the cursor style
|
||||
bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
|
||||
{
|
||||
CursorType finalCursorType;
|
||||
bool fShouldBlink;
|
||||
|
||||
switch (cursorStyle)
|
||||
{
|
||||
case DispatchTypes::CursorStyle::BlinkingBlockDefault:
|
||||
[[fallthrough]];
|
||||
case DispatchTypes::CursorStyle::BlinkingBlock:
|
||||
finalCursorType = CursorType::FullBox;
|
||||
fShouldBlink = true;
|
||||
break;
|
||||
case DispatchTypes::CursorStyle::SteadyBlock:
|
||||
finalCursorType = CursorType::FullBox;
|
||||
fShouldBlink = false;
|
||||
break;
|
||||
case DispatchTypes::CursorStyle::BlinkingUnderline:
|
||||
finalCursorType = CursorType::Underscore;
|
||||
fShouldBlink = true;
|
||||
break;
|
||||
case DispatchTypes::CursorStyle::SteadyUnderline:
|
||||
finalCursorType = CursorType::Underscore;
|
||||
fShouldBlink = false;
|
||||
break;
|
||||
case DispatchTypes::CursorStyle::BlinkingBar:
|
||||
finalCursorType = CursorType::VerticalBar;
|
||||
fShouldBlink = true;
|
||||
break;
|
||||
case DispatchTypes::CursorStyle::SteadyBar:
|
||||
finalCursorType = CursorType::VerticalBar;
|
||||
fShouldBlink = false;
|
||||
break;
|
||||
default:
|
||||
finalCursorType = CursorType::Legacy;
|
||||
fShouldBlink = false;
|
||||
}
|
||||
|
||||
_buffer->GetCursor().SetType(finalCursorType);
|
||||
_buffer->GetCursor().SetBlinkingAllowed(fShouldBlink);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -70,3 +70,8 @@ bool TerminalDispatch::SetColorTableEntry(const size_t tableIndex,
|
|||
{
|
||||
return _terminalApi.SetColorTableEntry(tableIndex, dwColor);
|
||||
}
|
||||
|
||||
bool TerminalDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
|
||||
{
|
||||
return _terminalApi.SetCursorStyle(cursorStyle);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public:
|
|||
bool SetWindowTitle(std::wstring_view title) override;
|
||||
|
||||
bool SetColorTableEntry(const size_t tableIndex, const DWORD dwColor) override;
|
||||
bool SetCursorStyle(const ::Microsoft::Console::VirtualTerminal::DispatchTypes::CursorStyle cursorStyle) override;
|
||||
|
||||
private:
|
||||
::Microsoft::Terminal::Core::ITerminalApi& _terminalApi;
|
||||
|
|
Loading…
Reference in a new issue