-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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 LNM (Line Feed/New Line Mode) #15167
Comments
Isn't LNM basically a superset of the |
The current default behavior for Windows console apps (i.e. when When |
This PR adds support for the ANSI Line Feed/New Line mode (`LNM`), which determines whether outputting a linefeed control should also trigger a carriage return, and whether the `Return` key should generate an `LF` in addition to `CR`. ## Detailed Description of the Pull Request / Additional comments In ConHost, there was already a console mode which handled the output side of things, but I've now also added a `TerminalInput` mode that controls the behavior of the `Return` key. When `LNM` is set, both the output and input modes are enabled, and when reset, they're disabled. If they're not already matching, then `LNM` has no effect, and will be reported as unknown when queried. This is the typical state for legacy console applications, which expect a linefeed to trigger a carriage return, but wouldn't want the `Return` key generating both `CR`+`LF`. As part of this PR, I've also refactored the `ITerminalApi` interface to consolidate what I'm now calling the "system" modes: bracketed paste, auto wrap, and the new line feed mode. This closes another gap between Terminal and ConHost, so both auto wrap, and line feed mode will now be supported for conpty pass through. ## Validation Steps Performed I've added an `LNM` test that checks the escape sequence is triggering both of the expected mode changes, and added an additional `DECRQM` test covering the currently implemented standard modes: the new `LNM`, and the existing `IRM` (which wasn't previously tested). I've also extended the `DECRQM` private mode test to cover `DECAWM` and Bracketed Paste (which we also weren't previously testing). I've manually tested `LNM` in Vttest to confirm the keyboard is working as expected. Closes #15167
This PR adds support for the ANSI Line Feed/New Line mode (`LNM`), which determines whether outputting a linefeed control should also trigger a carriage return, and whether the `Return` key should generate an `LF` in addition to `CR`. ## Detailed Description of the Pull Request / Additional comments In ConHost, there was already a console mode which handled the output side of things, but I've now also added a `TerminalInput` mode that controls the behavior of the `Return` key. When `LNM` is set, both the output and input modes are enabled, and when reset, they're disabled. If they're not already matching, then `LNM` has no effect, and will be reported as unknown when queried. This is the typical state for legacy console applications, which expect a linefeed to trigger a carriage return, but wouldn't want the `Return` key generating both `CR`+`LF`. As part of this PR, I've also refactored the `ITerminalApi` interface to consolidate what I'm now calling the "system" modes: bracketed paste, auto wrap, and the new line feed mode. This closes another gap between Terminal and ConHost, so both auto wrap, and line feed mode will now be supported for conpty pass through. ## Validation Steps Performed I've added an `LNM` test that checks the escape sequence is triggering both of the expected mode changes, and added an additional `DECRQM` test covering the currently implemented standard modes: the new `LNM`, and the existing `IRM` (which wasn't previously tested). I've also extended the `DECRQM` private mode test to cover `DECAWM` and Bracketed Paste (which we also weren't previously testing). I've manually tested `LNM` in Vttest to confirm the keyboard is working as expected. Closes #15167 (cherry picked from commit 3d73721) Service-Card-Id: 89180225 Service-Version: 1.18
Description of the new feature/enhancement
When
LNM
is set, the linefeed controls (LF
,FF
, andVT
) will also trigger a carriage return. When reset they, they won't. This is essentially the inverse of our existing console mode,DISABLE_NEWLINE_AUTO_RETURN
.However,
LNM
has an additional effect on input. When set, the Return key generates both a carriage return and a line feed. When reset it only generates the carriage return.It's quite widely implemented, but I don't think VTE supports it, which suggests it's probably not that widely used. However, it is a requirement for meeting VT level 1 conformance, which is why I would like for us to support it.
Proposed technical implementation details (optional)
I had originally thought we could map it directly to the
DISABLE_NEWLINE_AUTO_RETURN
mode, since we're already using that to determine how linefeed controls are interpreted. However, when a Windows console app hasDISABLE_NEWLINE_AUTO_RETURN
reset (which is the equivalent ofLNM
being set), we don't typically want the Return key to behave differently.So my idea was this: We add a new input mode that specifically handles the
LNM
behavior for the Return key, which by default is disabled. And we treat theDISABLE_NEWLINE_AUTO_RETURN
mode as an inverse alias for theLNM
output behavior (as we already do).When those two match, we're in a valid VT state, and we can use the
LNM
mode to toggle them both at the same time. But when they're out of sync (which is the default state for a Windows console app), we just act as if theLNM
mode is not supported, i.e. we don't respond to any attempts to change it, andDECRQM
reports the mode as unknown.Does that seem like a reasonable approach to take?
The text was updated successfully, but these errors were encountered: