Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Reset to Initial State (RIS) doesn't reset very much #159

Closed
j4james opened this issue Apr 24, 2018 · 3 comments
Closed

Reset to Initial State (RIS) doesn't reset very much #159

j4james opened this issue Apr 24, 2018 · 3 comments
Assignees
Labels
Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release
Milestone

Comments

@j4james
Copy link
Collaborator

j4james commented Apr 24, 2018

Your Windows build number:

Microsoft Windows [Version 10.0.16299.371]

What you're doing and what's happening:

I was experimenting with the RIS (Reset to Initial State) escape sequence, ESC c, to see which properties are actually reset by it. It turns out that quite a lot of properties aren't reset in the Windows console (at least the version that I have).

  • Scroll margins (DECSTBM)
  • Saved cursor position (DECSC and ANSISC)
  • User-defined tab stops (HTS) - I've mentioned this before in issue Unexpected behaviour when setting tab stops #140
  • Cursor visibility (DECTCEM)
  • Cursor blinking state (ATT160)
  • The window title
  • Cursor key application mode (DECCKM)

I've also tested on XTerm, which does reset most of these properties. Below are a few test cases comparing the behaviour between XTerm (on the left) and the Windows console (on the right).

Scroll margins: If RIS reset the scroll margins, this should ouput on line 8, and not line 2.

printf "\e[1;2r\ec\n\n\n\n\n\n\nLine 8?\e[r"; read -n1

image

Saved cursor position (DECSC): If RIS resets the saved cursor position, this should output in the top left of the screen, and not offset at row 3, column 6.

printf "\e[3;6H\e7\ec\e8Top left?\n"

image

Saved cursor position (ANSISC): Again if RIS resets the saved cursor position, this should output in the top left of the screen, and not offset at row 3, column 6.

printf "\e[3;6H\e[s\ec\e[uTop left?\n"

image

User-defined tab stops: If RIS resets the tab stops, this should output at column 8, not column 2.

printf "\e[H  \eH\ec\t\e[gColumn 8?\n"

image

Cursor visibility: If RIS resets the cursor visibility, this should show a visible cursor.

printf "\e[?25l\ecCursor visible?"; read -n1; printf "\e[?25h"

image

Cursor blinking: If RIS resets the cursor blinking, this should show a blinking cursor.

printf "\e[?12l\ecCursor blinking?"; read -n1; printf "\e[?12h"

This is not really something that can be shown in a screenshot, but I'm seeing a static cursor in the Windows console. I couldn't test on Linux because the ATT160 sequence doesn't appear to be supported on any of the Linux terminal emulators that I tried.

Window title: If RIS resets the title, this should not leave the title displaying the letter X. This is one case that isn't reset by XTerm either (or any of the other Linux emulators I tried).

printf "\e]2;X\a\ecTitle not X?"; read -n1

image

Cursor key application mode: If RIS resets the cursor key mode, this test should generate output in the form ^[[A^[[B^[[C^[[D, and not ^[OA^[OB^[OC^[OC.

printf "\e[?1h\ecPress some cursor keys:\n"; read

image

I'd expect similar behaviour for the keypad application mode (DECKPAM), but that doesn't appear to be working in the Windows console at all, so I couldn't test whether the reset has any effect on it.

What's wrong / what should be happening instead:

The VT100 manual defines the RIS command as: "Resets the VT100 to its initial state, i.e. the state it has after it is powered on." Given that definition, I would have expected all of the above mentioned properties to be reset. That said, I could understand the window title not being reset if nobody else supports that either (and I guess none of the VT terminals would have had a window title anyway).

@zadjii-msft
Copy link
Member

You always leave such great bug reports. Happy to add to my bug queue.

@zadjii-msft zadjii-msft self-assigned this Apr 25, 2018
@zadjii-msft zadjii-msft added Work-Item It's being tracked by an actual work item internally. (to be removed soon) Product-Conhost For issues in the Console codebase labels Apr 25, 2018
@zadjii-msft zadjii-msft added this to the RS5 milestone Apr 25, 2018
@zadjii-msft
Copy link
Member

Ah. I see what's happening here.

Soft Reset (DECSTR) does almost everything listed here, very specifically, the parts of soft reset we support are

Text cursor enable          DECTCEM     Cursor enabled.
Numeric keypad              DECNKM      Numeric characters.
Cursor keys                 DECCKM      Normal (arrow keys).
Set top and bottom margins  DECSTBM     Top margin = 1; bottom margin = page length.
All character sets          G0, G1, G2, Default settings.
Select graphic rendition    SGR         Normal rendition.
Save cursor state           DECSC       Home position.

While RIS does a totally different set of things.

I couldn't find any documentation that hard reset is supposed to also perform a soft reset, even though logically that makes sense to me. And as you've shown above, clearly, hard reset is supposed to soft reset. So, I can pretty easily make that happen.

In addition, I'm pretty sure it's not supposed to touch the title, I couldn't find anything that mentions doing anything to the title, and if no one on linux is doing it, then it's probably safe for us to not to it either.


Relevant:

https://vt100.net/docs/vt220-rm/chapter4.html#S4.18

@zadjii-msft zadjii-msft added Resolution-Fix-Available It's available in an Insiders build or a release and removed Work-Item It's being tracked by an actual work item internally. (to be removed soon) labels Jul 19, 2018
@zadjii-msft
Copy link
Member

I don't remember exactly when I submitted the fix for this, but it's certainly in Insider's by now. Thanks for the detailed report!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Product-Conhost For issues in the Console codebase Resolution-Fix-Available It's available in an Insiders build or a release
Projects
None yet
Development

No branches or pull requests

2 participants