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 Presentation State reports #14984

Closed
j4james opened this issue Mar 12, 2023 · 10 comments · Fixed by #14998
Closed

Add support for Presentation State reports #14984

j4james opened this issue Mar 12, 2023 · 10 comments · Fixed by #14998
Labels
Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements

Comments

@j4james
Copy link
Collaborator

j4james commented Mar 12, 2023

Description of the new feature/enhancement

There are two reports that can be queried with the DECRQPSR (request presentation state) escape sequence. The one returns the active tab stops, and the other returns what they call "cursor information", which includes things like cursor position, SGR attributes, and character set designations.

There is also then a corresponding DECRSPS sequence (restore presentation state) which can restore the saved information from the above mentioned reports.

There are a number of uses for these sequences, but the main reason I want to support them is because they're needed to meet the requirements of the TSI (terminal state interrogation) feature, which is itself a requirement for level 3 compliance.

Proposed technical implementation details (optional)

This will require some additional work in the TerminalOuput class to track the actual IDs of the designated character sets so we can return that information in the report. I think most of the other information we need should be easy to access.

@j4james j4james added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Mar 12, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Mar 12, 2023
@j4james
Copy link
Collaborator Author

j4james commented Mar 12, 2023

@al20878 I've got another couple of tests which I'd previously created for these reports. They were written as bash scripts, though, so just let me know if that's a problem and I can rewrite them in Python.

Also, note that they don't actually log anything, the results are displayed on the screen, so I'd be grateful if you could take a photograph of each run and post that here.

This is for the tab stop report:
https://gist.github.com/j4james/a25e6290772353c06f85c584007c2aa0

And this one is for the cursor information report:
https://gist.github.com/j4james/570a9b7dd28dbdd8b626be2770567210

@j4james
Copy link
Collaborator Author

j4james commented Mar 12, 2023

I forgot to say, I'd ideally like to see this run on a VT525 - specifically the cursor information report - because I think it might include additional information for the active SGR colors that other terminals wouldn't include.

@al20878
Copy link

al20878 commented Mar 12, 2023

Shell scripts are fine, I'll be running them on Linux (Raspbian), so it's all good, I hope. Downloaded both, will post the results.

@al20878
Copy link

al20878 commented Mar 12, 2023

Unfortunately, I'm having issues with these two... The first one (dectabsr.sh) makes the terminal reset and then appears like it also generates some garbage on the screen. Attaching the final pic, but I also shot a video of how it's run.

dectabsr

The other one, too, appears to behave erratically but not as bad. The final screenshot is here (and, there's a video as well, I'll post the links to both in a few):

deccir

@j4james
Copy link
Collaborator Author

j4james commented Mar 12, 2023

@al20878 Thanks again. This is very useful. The cursor information report (the second one) is perfect. I think the weirdness you're seeing is just the test doing it's thing. It's moving the cursor to different positions on the screen, changing the active page, and setting margins, etc. and all the while it's requesting reports from the terminal which take a couple seconds. The final result is exactly what I was expecting to see. I had hoped there might also be color information, but that wasn't the case.

I think the problem with the first one is that I'm switching back and forth between 80 columns and 132 columns, and I suspect I need to give the terminal time to make that switch before throwing queries at it. If it's not ready to respond fast enough, the report reader probably times out, and the report then ends up written on to the screen.

I'll try and make some adjustments to the script to see if I can fix the issue and let you know when I have another version ready to test.

@j4james
Copy link
Collaborator Author

j4james commented Mar 12, 2023

@al20878 I've uploaded a revision of the dectabsr script with a one second delay after each column mode change, and a longer timeout on the report reader. Hopefully that should work better. When you have a chance, I'd appreciate you trying it again.

https://gist.github.com/j4james/a25e6290772353c06f85c584007c2aa0

@al20878
Copy link

al20878 commented Mar 13, 2023

Indeed, the new version runs absolutely clean (I mean I can now tell that the terminal switches between the modes, because previously it was just blinking like it was reset a couple times; also no garbage on screen). The result:
dectabsr

@j4james
Copy link
Collaborator Author

j4james commented Mar 13, 2023

@al20878 Perfect. That tells me everything I needed to know. Thank you so much for doing all this testing. This is going to keep me busy for a while, so I'll leave you in peace for a bit. 😉

@al20878
Copy link

al20878 commented Mar 13, 2023

No problem, @j4james! I was happy to help :-)
Please feel free to reach out if you need any further testing. And good luck!

@zadjii-msft zadjii-msft added Help Wanted We encourage anyone to jump in on these. Area-VT Virtual Terminal sequence support Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Mar 13, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Mar 16, 2023
DHowett pushed a commit that referenced this issue Mar 23, 2023
This PR introduces two new sequences, `DECRQPSR` and `DECRSPS`, which
provide a way for applications to query and restore the presentation
state reports. This includes the tab stop report (`DECTABSR`) and the
cursor information report (`DECCIR`). 

One part of the cursor information report contains the character set
designations and mapped G-sets. But we weren't tracking that data in a
way that could easily be reported, so I needed to do some refactoring in
the `TerminalOutput` class to make that accessible.

Other than that, the rest was fairly straightforward. It was just a
matter of packaging up all the information into the correct format for
the returned `DCS` string, and in the case of the restore operations,
parsing the incoming data and applying the new state. 

## Validation Steps Performed

Thanks to @al20878, we were able to test these operations on a real
VT525, and I've manually verified that our implementation matches that
behavior. I've also added some unit tests covering both reports.

Closes #14984
microsoft-github-policy-service bot pushed a commit that referenced this issue Jan 24, 2024
## Summary of the Pull Request

This PR adds support for the `DECST8C` escape sequence, which resets the
tab stops to every 8 columns.

## Detailed Description of the Pull Request / Additional comments

This is actually a private parameter variant of the ANSI `CTC` sequence
(Cursor Tabulation Control), which accepts a selective parameter which
specifies the type of tab operation to be performed. But the DEC variant
only defines a single parameter value (5), which resets all tab stops.
It also considers an omitted parameter to be the equivalent of 5, so we
support that too.

## Validation Steps Performed

I've extended the existing tab stop tests in `ScreenBufferTests` with
some basic coverage of this sequence.

I've also manually verified that the `DECTABSR` script in #14984 now
passes the `DECST8C` portion of the test.

## PR Checklist
- [x] Closes #16533
- [x] Tests added/passed
DHowett pushed a commit that referenced this issue Jan 25, 2024
## Summary of the Pull Request

This PR adds support for the `DECST8C` escape sequence, which resets the
tab stops to every 8 columns.

## Detailed Description of the Pull Request / Additional comments

This is actually a private parameter variant of the ANSI `CTC` sequence
(Cursor Tabulation Control), which accepts a selective parameter which
specifies the type of tab operation to be performed. But the DEC variant
only defines a single parameter value (5), which resets all tab stops.
It also considers an omitted parameter to be the equivalent of 5, so we
support that too.

## Validation Steps Performed

I've extended the existing tab stop tests in `ScreenBufferTests` with
some basic coverage of this sequence.

I've also manually verified that the `DECTABSR` script in #14984 now
passes the `DECST8C` portion of the test.

## PR Checklist
- [x] Closes #16533
- [x] Tests added/passed

(cherry picked from commit f589888)
Service-Card-Id: 91631721
Service-Version: 1.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants