Skip to content

Commit

Permalink
Add DECRQSS report for DECSCUSR cursor style
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Aug 2, 2024
1 parent be9763d commit 7fcb05b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4259,6 +4259,9 @@ ITermDispatch::StringHandler AdaptDispatch::RequestSetting()
case VTID("s"):
_ReportDECSLRMSetting();
break;
case VTID(" q"):
_ReportDECSCUSRSetting();
break;
case VTID("\"q"):
_ReportDECSCASetting();
break;
Expand Down Expand Up @@ -4400,6 +4403,40 @@ void AdaptDispatch::_ReportDECSLRMSetting()
_api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033P1$r{};{}s\033\\"), marginLeft + 1, marginRight + 1));
}

// Method Description:
// - Reports the DECSCUSR cursor style in response to a DECRQSS query.
// Arguments:
// - None
// Return Value:
// - None
void AdaptDispatch::_ReportDECSCUSRSetting() const
{
const auto& cursor = _pages.ActivePage().Cursor();
const auto blinking = cursor.IsBlinkingAllowed();
// A valid response always starts with DCS 1 $ r. This is followed by a
// number from 1 to 6 representing the cursor style. The ' q' indicates
// this is a DECSCUSR response, and ST ends the sequence.
switch (cursor.GetType())
{
case CursorType::FullBox:
_api.ReturnResponse(blinking ? L"\033P1$r1 q\033\\" : L"\033P1$r2 q\033\\");
break;
case CursorType::Underscore:
_api.ReturnResponse(blinking ? L"\033P1$r3 q\033\\" : L"\033P1$r4 q\033\\");
break;
case CursorType::VerticalBar:
_api.ReturnResponse(blinking ? L"\033P1$r5 q\033\\" : L"\033P1$r6 q\033\\");
break;
default:
// If we have a non-standard style, this is likely because it's the
// user's chosen default style, so we report a default value of 0.
// That way, if an application leter tries to restore the cursor with
// the returned value, it should be reset to its original state.
_api.ReturnResponse(L"\033P1$r0 q\033\\");
break;
}
}

// Method Description:
// - Reports the DECSCA protected attribute in response to a DECRQSS query.
// Arguments:
Expand Down
1 change: 1 addition & 0 deletions src/terminal/adapter/adaptDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ namespace Microsoft::Console::VirtualTerminal
void _ReportSGRSetting() const;
void _ReportDECSTBMSetting();
void _ReportDECSLRMSetting();
void _ReportDECSCUSRSetting() const;
void _ReportDECSCASetting() const;
void _ReportDECSACESetting() const;
void _ReportDECACSetting(const VTInt itemNumber) const;
Expand Down

0 comments on commit 7fcb05b

Please sign in to comment.