Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DECSCUSR "0" to restore cursor to user default #7379

Merged
15 commits merged into from
Sep 4, 2020
4 changes: 4 additions & 0 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ void Terminal::UpdateSettings(ICoreSettings settings)
cursorShape);
}

_defaultCursorHeight = settings.CursorHeight();
_defaultCursorColor = settings.CursorColor();
_defaultCursorShape = cursorShape;

for (int i = 0; i < 16; i++)
{
_colorTable.at(i) = settings.GetColorTableEntry(i);
Expand Down
3 changes: 3 additions & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ class Microsoft::Terminal::Core::Terminal final :
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
COLORREF _defaultFg;
COLORREF _defaultBg;
ULONG _defaultCursorHeight;
COLORREF _defaultCursorColor;
CursorType _defaultCursorShape;
bool _screenReversed;

bool _snapOnInput;
Expand Down
5 changes: 3 additions & 2 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,9 @@ bool Terminal::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle) noex

switch (cursorStyle)
{
case DispatchTypes::CursorStyle::BlinkingBlockDefault:
[[fallthrough]];
case DispatchTypes::CursorStyle::UserDefault:
finalCursorType = _defaultCursorShape;
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved
return true;
case DispatchTypes::CursorStyle::BlinkingBlock:
finalCursorType = CursorType::FullBox;
shouldBlink = true;
Expand Down
4 changes: 2 additions & 2 deletions src/terminal/adapter/DispatchTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ namespace Microsoft::Console::VirtualTerminal::DispatchTypes

enum class CursorStyle : unsigned int
{
BlinkingBlock = 0,
BlinkingBlockDefault = 1,
UserDefault = 0, // Implemented as "restore cursor to user default".
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved
BlinkingBlock = 1,
SteadyBlock = 2,
BlinkingUnderline = 3,
SteadyUnderline = 4,
Expand Down
1 change: 0 additions & 1 deletion src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,6 @@ bool AdaptDispatch::SetCursorStyle(const DispatchTypes::CursorStyle cursorStyle)
switch (cursorStyle)
{
case DispatchTypes::CursorStyle::BlinkingBlock:
skyline75489 marked this conversation as resolved.
Show resolved Hide resolved
case DispatchTypes::CursorStyle::BlinkingBlockDefault:
fEnableBlinking = true;
actualType = CursorType::FullBox;
break;
Comment on lines 2167 to 2170
Copy link
Collaborator

@j4james j4james Aug 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the behaviour for conhost is right. We should either leave UserDefault as an alias for BlinkingBlock, which is at least compatible with the DEC standard, or we should try and map it to the actual user preference (which I'm honestly not sure how to do). Worst case we could possibly map it to blinking legacy, which I think is the system default. But as it stands, it looks like you're going to get non-blinking legacy, which is neither one thing nor the other.

Edit: Sorry this is essentially a long-winded dup of DHowett's comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More detail = more good

Expand Down
2 changes: 1 addition & 1 deletion src/terminal/parser/OutputStateMachineEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ namespace Microsoft::Console::VirtualTerminal
bool _GetOscSetColor(const std::wstring_view string,
DWORD& rgb) const noexcept;

static constexpr DispatchTypes::CursorStyle DefaultCursorStyle = DispatchTypes::CursorStyle::BlinkingBlockDefault;
static constexpr DispatchTypes::CursorStyle DefaultCursorStyle = DispatchTypes::CursorStyle::UserDefault;
bool _GetCursorStyle(const gsl::span<const size_t> parameters,
DispatchTypes::CursorStyle& cursorStyle) const noexcept;

Expand Down