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 LNM (Line Feed/New Line Mode) #15261

Merged
merged 3 commits into from
May 12, 2023

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Apr 28, 2023

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

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-VT Virtual Terminal sequence support Product-Conhost For issues in the Console codebase labels Apr 28, 2023
@j4james j4james marked this pull request as ready for review April 28, 2023 22:00
@zadjii-msft zadjii-msft added this to the Terminal v1.18 milestone May 1, 2023
@DHowett
Copy link
Member

DHowett commented May 12, 2023

Thanks for doing this!

@DHowett DHowett merged commit 3d73721 into microsoft:main May 12, 2023
DHowett pushed a commit that referenced this pull request May 15, 2023
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
@j4james j4james deleted the feature-lnm branch May 30, 2023 00:48
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 Issue-Task It's a feature request, but it doesn't really need a major design. Product-Conhost For issues in the Console codebase zBugBash-Consider
Projects
Development

Successfully merging this pull request may close these issues.

Add support for LNM (Line Feed/New Line Mode)
3 participants