Skip to content

Commit

Permalink
Hook up the dispatch framework for the DECRQTSR query.
Browse files Browse the repository at this point in the history
  • Loading branch information
j4james committed Aug 8, 2024
1 parent edfa3ea commit 6a7f9a2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/terminal/adapter/ITermDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
const DispatchTypes::MacroEncoding encoding) = 0; // DECDMAC
virtual bool InvokeMacro(const VTInt macroId) = 0; // DECINVM

virtual bool RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) = 0; // DECRQTSR
virtual StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat format) = 0; // DECRSTS

virtual StringHandler RequestSetting() = 0; // DECRQSS
Expand Down
31 changes: 31 additions & 0 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4166,6 +4166,27 @@ bool AdaptDispatch::InvokeMacro(const VTInt macroId)
return true;
}

// Routine Description:
// - DECRQTSR - Queries the state of the terminal. This can either be a terminal
// state report, generally covering all settable state in the terminal (with
// the exception of large data items), or a color table report.
// Arguments:
// - format - the format of the report being requested.
// - formatOption - a format-specific option.
// Return Value:
// - True if handled successfully. False otherwise.
bool AdaptDispatch::RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption)
{
switch (format)
{
case DispatchTypes::ReportFormat::ColorTableReport:
_ReportColorTable(formatOption);
return true;
default:
return false;
}
}

// Method Description:
// - DECRSTS - Restores the terminal state from a stream of data previously
// saved with a DECRQTSR query.
Expand All @@ -4184,6 +4205,16 @@ ITermDispatch::StringHandler AdaptDispatch::RestoreTerminalState(const DispatchT
}
}

// Method Description:
// - DECCTR - Returns the Color Table Report in response to a DECRQTSR query.
// Arguments:
// - colorModel - the color model to use in the report (1 = HLS, 2 = RGB).
// Return Value:
// - None
void AdaptDispatch::_ReportColorTable(const DispatchTypes::ColorModel /*colorModel*/) const
{
}

// Method Description:
// - DECCTR - This is a parser for the Color Table Report received via DECRSTS.
// The report contains a list of color definitions separated with a slash
Expand Down
2 changes: 2 additions & 0 deletions src/terminal/adapter/adaptDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace Microsoft::Console::VirtualTerminal
const DispatchTypes::MacroEncoding encoding) override; // DECDMAC
bool InvokeMacro(const VTInt macroId) override; // DECINVM

bool RequestTerminalStateReport(const DispatchTypes::ReportFormat format, const VTParameter formatOption) override; // DECRQTSR
StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat format) override; // DECRSTS

StringHandler RequestSetting() override; // DECRQSS
Expand Down Expand Up @@ -272,6 +273,7 @@ namespace Microsoft::Console::VirtualTerminal
void _ClearAllTabStops() noexcept;
void _InitTabStopsForWidth(const VTInt width);

void _ReportColorTable(const DispatchTypes::ColorModel colorModel) const;
StringHandler _RestoreColorTable();

void _ReportSGRSetting() const;
Expand Down
1 change: 1 addition & 0 deletions src/terminal/adapter/termDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons
const DispatchTypes::MacroEncoding /*encoding*/) override { return nullptr; } // DECDMAC
bool InvokeMacro(const VTInt /*macroId*/) override { return false; } // DECINVM

bool RequestTerminalStateReport(const DispatchTypes::ReportFormat /*format*/, const VTParameter /*formatOption*/) override { return false; } // DECRQTSR
StringHandler RestoreTerminalState(const DispatchTypes::ReportFormat /*format*/) override { return nullptr; }; // DECRSTS

StringHandler RequestSetting() override { return nullptr; }; // DECRQSS
Expand Down
3 changes: 3 additions & 0 deletions src/terminal/parser/OutputStateMachineEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,9 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete
case CsiActionCodes::DECCRA_CopyRectangularArea:
success = _dispatch->CopyRectangularArea(parameters.at(0), parameters.at(1), parameters.at(2).value_or(0), parameters.at(3).value_or(0), parameters.at(4), parameters.at(5), parameters.at(6), parameters.at(7));
break;
case CsiActionCodes::DECRQTSR_RequestTerminalStateReport:
success = _dispatch->RequestTerminalStateReport(parameters.at(0), parameters.at(1));
break;
case CsiActionCodes::DECRQPSR_RequestPresentationStateReport:
success = _dispatch->RequestPresentationStateReport(parameters.at(0));
break;
Expand Down
1 change: 1 addition & 0 deletions src/terminal/parser/OutputStateMachineEngine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ namespace Microsoft::Console::VirtualTerminal
DECRQM_PrivateRequestMode = VTID("?$p"),
DECCARA_ChangeAttributesRectangularArea = VTID("$r"),
DECRARA_ReverseAttributesRectangularArea = VTID("$t"),
DECRQTSR_RequestTerminalStateReport = VTID("$u"),
DECCRA_CopyRectangularArea = VTID("$v"),
DECRQPSR_RequestPresentationStateReport = VTID("$w"),
DECFRA_FillRectangularArea = VTID("$x"),
Expand Down

0 comments on commit 6a7f9a2

Please sign in to comment.