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 the DECST8C escape sequence #16534

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
DECSLRM
DECSMKR
DECSR
DECST
DECSTBM
DECSTGLT
DECSTR
Expand Down Expand Up @@ -790,7 +791,7 @@
Hostx
HPA
hpcon
HPCON

Check warning on line 794 in .github/actions/spelling/expect/expect.txt

View workflow job for this annotation

GitHub Actions / Spell checking

`HPCON` is ignored by check spelling because another more general variant is also in expect. (ignored-expect-variant)
hpen
HPR
HProvider
Expand Down
10 changes: 10 additions & 0 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,16 @@ void ScreenBufferTests::TestResetClearTabStops()
stateMachine.ProcessString(resetToInitialState);
expectedStops = { 8, 16, 24, 32, 40, 48, 56, 64, 72 };
VERIFY_ARE_EQUAL(expectedStops, _GetTabStops(screenInfo));

Log::Comment(L"DECST8C with 5 parameter resets tabs to defaults.");
stateMachine.ProcessString(clearTabStops);
stateMachine.ProcessString(L"\033[?5W");
VERIFY_ARE_EQUAL(expectedStops, _GetTabStops(screenInfo));

Log::Comment(L"DECST8C with omitted parameter resets tabs to defaults.");
stateMachine.ProcessString(clearTabStops);
stateMachine.ProcessString(L"\033[?W");
VERIFY_ARE_EQUAL(expectedStops, _GetTabStops(screenInfo));
}

void ScreenBufferTests::TestAddTabStop()
Expand Down
5 changes: 5 additions & 0 deletions src/terminal/adapter/DispatchTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ namespace Microsoft::Console::VirtualTerminal::DispatchTypes
ClearAllColumns = 3
};

enum TabSetType : VTInt
{
SetEvery8Columns = 5
};

enum WindowManipulationType : VTInt
{
Invalid = 0,
Expand Down
1 change: 1 addition & 0 deletions src/terminal/adapter/ITermDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Microsoft::Console::VirtualTerminal::ITermDispatch
virtual bool ForwardTab(const VTInt numTabs) = 0; // CHT, HT
virtual bool BackwardsTab(const VTInt numTabs) = 0; // CBT
virtual bool TabClear(const DispatchTypes::TabClearType clearType) = 0; // TBC
virtual bool TabSet(const VTParameter setType) = 0; // DECST8C
virtual bool SetColorTableEntry(const size_t tableIndex, const DWORD color) = 0; // OSCColorTable
virtual bool SetDefaultForeground(const DWORD color) = 0; // OSCDefaultForeground
virtual bool SetDefaultBackground(const DWORD color) = 0; // OSCDefaultBackground
Expand Down
20 changes: 13 additions & 7 deletions src/terminal/adapter/adaptDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2793,16 +2793,22 @@ void AdaptDispatch::_ClearAllTabStops() noexcept
}

// Routine Description:
// - Clears all tab stops and sets the _initDefaultTabStops flag to indicate
// - DECST8C - If the parameter is SetEvery8Columns or is omitted, then this
// clears all tab stops and sets the _initDefaultTabStops flag to indicate
// that the default positions should be reinitialized when needed.
// Arguments:
// - <none>
// - setType - only SetEvery8Columns is supported
// Return value:
// - <none>
void AdaptDispatch::_ResetTabStops() noexcept
// - True if handled successfully. False otherwise.
bool AdaptDispatch::TabSet(const VTParameter setType) noexcept
{
_tabStopColumns.clear();
_initDefaultTabStops = true;
if (setType == DispatchTypes::TabSetType::SetEvery8Columns || !setType.has_value())
j4james marked this conversation as resolved.
Show resolved Hide resolved
{
_tabStopColumns.clear();
_initDefaultTabStops = true;
return true;
}
return false;
}

// Routine Description:
Expand Down Expand Up @@ -3076,7 +3082,7 @@ bool AdaptDispatch::HardReset()
_api.GetTextBuffer().GetCursor().SetBlinkingAllowed(true);

// Delete all current tab stops and reapply
_ResetTabStops();
TabSet(DispatchTypes::TabSetType::SetEvery8Columns);

// Clear the soft font in the renderer and delete the font buffer.
_renderer.UpdateSoftFont({}, {}, false);
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/adapter/adaptDispatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ namespace Microsoft::Console::VirtualTerminal
bool ForwardTab(const VTInt numTabs) override; // CHT, HT
bool BackwardsTab(const VTInt numTabs) override; // CBT
bool TabClear(const DispatchTypes::TabClearType clearType) override; // TBC
bool TabSet(const VTParameter setType) noexcept override; // DECST8C
bool DesignateCodingSystem(const VTID codingSystem) override; // DOCS
bool Designate94Charset(const VTInt gsetNumber, const VTID charset) override; // SCS
bool Designate96Charset(const VTInt gsetNumber, const VTID charset) override; // SCS
Expand Down Expand Up @@ -251,7 +252,6 @@ namespace Microsoft::Console::VirtualTerminal

void _ClearSingleTabStop();
void _ClearAllTabStops() noexcept;
void _ResetTabStops() noexcept;
void _InitTabStopsForWidth(const VTInt width);

StringHandler _RestoreColorTable();
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 @@ -61,6 +61,7 @@ class Microsoft::Console::VirtualTerminal::TermDispatch : public Microsoft::Cons
bool ForwardTab(const VTInt /*numTabs*/) override { return false; } // CHT, HT
bool BackwardsTab(const VTInt /*numTabs*/) override { return false; } // CBT
bool TabClear(const DispatchTypes::TabClearType /*clearType*/) override { return false; } // TBC
bool TabSet(const VTParameter /*setType*/) override { return false; } // DECST8C
bool SetColorTableEntry(const size_t /*tableIndex*/, const DWORD /*color*/) override { return false; } // OSCColorTable
bool SetDefaultForeground(const DWORD /*color*/) override { return false; } // OSCDefaultForeground
bool SetDefaultBackground(const DWORD /*color*/) override { return false; } // OSCDefaultBackground
Expand Down
5 changes: 5 additions & 0 deletions src/terminal/parser/OutputStateMachineEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ bool OutputStateMachineEngine::ActionCsiDispatch(const VTID id, const VTParamete
return _dispatch->TabClear(clearType);
});
break;
case CsiActionCodes::DECST8C_SetTabEvery8Columns:
success = parameters.for_each([&](const auto setType) {
return _dispatch->TabSet(setType);
});
break;
case CsiActionCodes::ECH_EraseCharacters:
success = _dispatch->EraseCharacters(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 @@ -121,6 +121,7 @@ namespace Microsoft::Console::VirtualTerminal
DCH_DeleteCharacter = VTID("P"),
SU_ScrollUp = VTID("S"),
SD_ScrollDown = VTID("T"),
DECST8C_SetTabEvery8Columns = VTID("?W"),
ECH_EraseCharacters = VTID("X"),
CBT_CursorBackTab = VTID("Z"),
HPA_HorizontalPositionAbsolute = VTID("`"),
Expand Down
Loading