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

Closed
opened 2026-01-30 21:46:21 +00:00 by claunia · 3 comments
Owner

Originally created by @j4james on GitHub (Apr 25, 2018).

Originally assigned to: @zadjii-msft on GitHub.

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 #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).

Originally created by @j4james on GitHub (Apr 25, 2018). Originally assigned to: @zadjii-msft on GitHub. ### 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 #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](https://user-images.githubusercontent.com/4181424/39218585-5c9403a8-481d-11e8-9f8c-3f7191b3dccb.png) **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](https://user-images.githubusercontent.com/4181424/39218633-a1370712-481d-11e8-8027-ebd61e7c4547.png) **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](https://user-images.githubusercontent.com/4181424/39218633-a1370712-481d-11e8-8027-ebd61e7c4547.png) **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](https://user-images.githubusercontent.com/4181424/39218696-db0ecb00-481d-11e8-89c2-c4bb9b0bc7ce.png) **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](https://user-images.githubusercontent.com/4181424/39218721-f0d05364-481d-11e8-92ee-512337aebb5f.png) **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](https://user-images.githubusercontent.com/4181424/39218748-1e14a3a2-481e-11e8-8cd4-9e6242ec5968.png) **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](https://user-images.githubusercontent.com/4181424/39218795-575f9748-481e-11e8-9957-9008d6ecc4f6.png) 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).
claunia added the Product-ConhostResolution-Fix-Available labels 2026-01-30 21:46:21 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Apr 25, 2018):

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

@zadjii-msft commented on GitHub (Apr 25, 2018): You always leave such great bug reports. Happy to add to my bug queue.
Author
Owner

@zadjii-msft commented on GitHub (Apr 27, 2018):

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 commented on GitHub (Apr 27, 2018): 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. <hr> Relevant: https://vt100.net/docs/vt220-rm/chapter4.html#S4.18
Author
Owner

@zadjii-msft commented on GitHub (Jul 19, 2018):

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!

@zadjii-msft commented on GitHub (Jul 19, 2018): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#231