-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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 CSI 18t #15295
Add support for CSI 18t #15295
Conversation
…halnpl/CSI_18t_support
…halnpl/CSI_18t_support
…halnpl/CSI_18t_support
…halnpl/CSI_18t_support
…halnpl/CSI_18t_support
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There are no TAEF tests. If you can add tests to this PR, I would greatly appreciate it so I can learn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I think we'll be swamped getting 1.18 out the door, so reviews might be slow.
You might be able to do something like
void ScreenBufferTests::TestGetWindowSizeInVt()
{
auto& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
auto& si = gci.GetActiveOutputBuffer();
auto& stateMachine = si.GetStateMachine();
auto& cursor = si.GetTextBuffer().GetCursor();
stateMachine.ProcessString(L"\x1b[18t");
gci.pInputBuffer.Read(...);
and then check the Char
of each of those key events.
Sorry I'm not more help ATM. Maybe after we sign off on 1.18 I can help more. We apparently didn't have tests like this, so I don't blame you for not writing a test for this one. I don't think there is prior art
@@ -3068,6 +3068,13 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy | |||
case DispatchTypes::WindowManipulationType::ResizeWindowInCharacters: | |||
_api.ResizeWindow(parameter2.value_or(0), parameter1.value_or(0)); | |||
return true; | |||
case DispatchTypes::WindowManipulationType::ReportTextSizeInCharacters: | |||
{ | |||
const til::rect viewport = _api.GetViewport(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to say that this is okay, but IIRC @j4james thought we should use the buffer width, not just the viewport width here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adressed.
…s viewport height
@zadjii-msft @j4james I addressed:
with and tested manually (still no TAEF): @zadjii-msft |
Tests for sequences like this are typically handled in For example, this is a test case for the terminal/src/terminal/adapter/ut_adapter/adapterTest.cpp Lines 1624 to 1630 in 10c6206
That seems similar to the sort of thing you might want to do. And note that you can access the text buffer the same way as the viewport with |
I've added a TAEF test for this. Thank you, @zadjii-msft and @j4james, for guiding me in the right direction. |
const std::wstring textSize = fmt::format(L"\033[8;{};{}t", _api.GetViewport().height(), _api.GetTextBuffer().GetSize().Width()); | ||
_api.ReturnResponse(std::wstring_view(textSize)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think that std::wstring
should automatically cast to std::wstring_view
, so you shouldn't need an explicit cast on the textSize
parameter. But with that out the way, you might as well embed the fmt::format
call directly within the ReturnResponse
call and avoid the textSize
variable altogether. I suspect we're doing the same thing in a bunch of other places, though, so it's not a big deal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't officially approve anything, but this looks good to me. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bearing with to write the test!
Going to need another approver to merge this, as @j4james mentioned he could not approve anything officially. |
@@ -3058,6 +3058,9 @@ bool AdaptDispatch::WindowManipulation(const DispatchTypes::WindowManipulationTy | |||
case DispatchTypes::WindowManipulationType::ResizeWindowInCharacters: | |||
_api.ResizeWindow(parameter2.value_or(0), parameter1.value_or(0)); | |||
return true; | |||
case DispatchTypes::WindowManipulationType::ReportTextSizeInCharacters: | |||
_api.ReturnResponse(fmt::format(L"\033[8;{};{}t", _api.GetViewport().height(), _api.GetTextBuffer().GetSize().Width())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: all of the other uses of fmt
in this file use FMT_COMPILE
for the format string. That keeps the code size down when this is compiled into Windows' conhost.exe.
Would you mind doing the same? 😄
…halnpl/CSI_18t_support
… is compiled into Windows' conhost.exe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I going crazy, or did Refined GitHub change the order of the signoff buttons?
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