[PR #15261] [MERGED] Add support for LNM (Line Feed/New Line Mode) #30551

Open
opened 2026-01-31 09:41:31 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/15261
Author: @j4james
Created: 4/28/2023
Status: Merged
Merged: 5/13/2023
Merged by: @DHowett

Base: mainHead: feature-lnm


📝 Commits (3)

📊 Changes

12 files changed (+168 additions, -125 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.cpp (+1 -1)
📝 src/cascadia/TerminalCore/Terminal.hpp (+4 -6)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+4 -21)
📝 src/host/outputStream.cpp (+32 -46)
📝 src/host/outputStream.hpp (+2 -6)
📝 src/host/ut_host/ScreenBufferTests.cpp (+23 -0)
📝 src/terminal/adapter/DispatchTypes.hpp (+1 -0)
📝 src/terminal/adapter/ITerminalApi.hpp (+9 -5)
📝 src/terminal/adapter/adaptDispatch.cpp (+34 -8)
📝 src/terminal/adapter/ut_adapter/adapterTest.cpp (+48 -32)
📝 src/terminal/input/terminalInput.cpp (+9 -0)
📝 src/terminal/input/terminalInput.hpp (+1 -0)

📄 Description

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 issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/15261 **Author:** [@j4james](https://github.com/j4james) **Created:** 4/28/2023 **Status:** ✅ Merged **Merged:** 5/13/2023 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `feature-lnm` --- ### 📝 Commits (3) - [`dc77355`](https://github.com/microsoft/terminal/commit/dc773550fbed7b085520e7538d7df4559be911db) Consolidate the "system" modes. - [`6ad0992`](https://github.com/microsoft/terminal/commit/6ad0992c3672c6a980479adb6399b2dcb40f1621) Add support for LNM. - [`d42716a`](https://github.com/microsoft/terminal/commit/d42716a9e6e4991f9dec6657bc75a27cc0db63d8) Add some unit tests. ### 📊 Changes **12 files changed** (+168 additions, -125 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+1 -1) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+4 -6) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+4 -21) 📝 `src/host/outputStream.cpp` (+32 -46) 📝 `src/host/outputStream.hpp` (+2 -6) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+23 -0) 📝 `src/terminal/adapter/DispatchTypes.hpp` (+1 -0) 📝 `src/terminal/adapter/ITerminalApi.hpp` (+9 -5) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+34 -8) 📝 `src/terminal/adapter/ut_adapter/adapterTest.cpp` (+48 -32) 📝 `src/terminal/input/terminalInput.cpp` (+9 -0) 📝 `src/terminal/input/terminalInput.hpp` (+1 -0) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:41:31 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#30551