Skip to content

Commit b2dd7fa

Browse files
authored
Add support for CSI 18t (#15295)
Adds support for CSI 18t to report the buffer screen size in characters. This pull request adds support for **CSI 18t**. When submitted to the terminal, it will respond with **"\033[8;{A};{B}t"** where **A** is equal to the **height** and **B** is equal to the **width** of the screen buffer in the number of characters (not pixels). ## Validation Steps Performed Manual tests against PowerShell 7 and ConHost. Added adapterTest Closes #13944
1 parent c553b21 commit b2dd7fa

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/terminal/adapter/DispatchTypes.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ namespace Microsoft::Console::VirtualTerminal::DispatchTypes
467467
IconifyWindow = 2,
468468
RefreshWindow = 7,
469469
ResizeWindowInCharacters = 8,
470+
ReportTextSizeInCharacters = 18
470471
};
471472

472473
enum class CursorStyle : VTInt

src/terminal/adapter/adaptDispatch.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,9 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy
30583058
case DispatchTypes::WindowManipulationType::ResizeWindowInCharacters:
30593059
_api.ResizeWindow(parameter2.value_or(0), parameter1.value_or(0));
30603060
return true;
3061+
case DispatchTypes::WindowManipulationType::ReportTextSizeInCharacters:
3062+
_api.ReturnResponse(fmt::format(FMT_COMPILE(L"\033[8;{};{}t"), _api.GetViewport().height(), _api.GetTextBuffer().GetSize().Width()));
3063+
return true;
30613064
default:
30623065
return false;
30633066
}

src/terminal/adapter/ut_adapter/adapterTest.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,14 @@ class AdapterTest
28522852
_pDispatch->_macroBuffer = nullptr;
28532853
}
28542854

2855+
TEST_METHOD(WindowManipulationTypeTests)
2856+
{
2857+
_testGetSet->PrepData();
2858+
_pDispatch->WindowManipulation(DispatchTypes::WindowManipulationType::ReportTextSizeInCharacters, NULL, NULL);
2859+
const std::wstring expectedResponse = fmt::format(L"\033[8;{};{}t", _testGetSet->GetViewport().height(), _testGetSet->GetTextBuffer().GetSize().Width());
2860+
_testGetSet->ValidateInputEvent(expectedResponse.c_str());
2861+
}
2862+
28552863
private:
28562864
TerminalInput _terminalInput{ nullptr };
28572865
std::unique_ptr<TestGetSet> _testGetSet;

0 commit comments

Comments
 (0)