[PR #2731] [MERGED] Move cursor to left margin for IL and DL controls #25052

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2731
Author: @j4james
Created: 9/12/2019
Status: Merged
Merged: 9/12/2019
Merged by: @miniksa

Base: masterHead: fix-ildl-xpos


📝 Commits (2)

  • 5915a2e Move cursor position to the left margin after execution of the IL and DL escape sequences.
  • 8cec76f Update IL and DL screen buffer tests to account for the cursor moving to the left margin.

📊 Changes

2 files changed (+23 additions, -6 deletions)

View changed files

📝 src/host/getset.cpp (+5 -0)
📝 src/host/ut_host/ScreenBufferTests.cpp (+18 -6)

📄 Description

Summary of the Pull Request

According to the DEC STD 070 manual, the cursor position should be moved to the left margin after the execution of the IL and DL escape sequences. This PR updates the code to implement that behaviour.

PR Checklist

Detailed Description of the Pull Request / Additional comments

I've modified the DoSrvPrivateModifyLinesImpl function (which is where the IL and DL controls are ultimately handled), to update the cursor position - setting the column to 0 - after the screen has been scrolled. Note that this has to happen inside the IsCursorInMargins check, since the cursor is not supposed to be moved if it was outside the margin boundaries.

Also note that this should really be set to the left margin specified by DECSLRM, but we don't yet support that control, so for now it's hardcoded to 0.

When it came to actually setting the cursor position, I found there were a number of options to choose from, with quite different behaviours. Some operations use a variation of SetConsoleCursorPosition, some use AdjustCursorPosition, and some call the SCREEN_INFORMATION::SetCursorPosition method directly, or even just Cursor::SetPosition. It wasn't always clear to why a particular method was chosen.

I ultimately decided on SCREEN_INFORMATION::SetCursorPosition with the TurnOn parameter set to false, since that seemed the simplest option that also matched the behaviour of a carriage return. I'm not certain that's the best choice, though, so I'm open to other suggestions.

Validation Steps Performed

There were a number of existing IL and DL tests that assumed the cursor position was not meant to move, and validated that behaviour. I've updated all of those tests to confirm that cursor position is now moved to column 0 when those escape sequences are executed.


🔄 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/2731 **Author:** [@j4james](https://github.com/j4james) **Created:** 9/12/2019 **Status:** ✅ Merged **Merged:** 9/12/2019 **Merged by:** [@miniksa](https://github.com/miniksa) **Base:** `master` ← **Head:** `fix-ildl-xpos` --- ### 📝 Commits (2) - [`5915a2e`](https://github.com/microsoft/terminal/commit/5915a2ef5a0c4b7066eb5eb9ca3461572610d200) Move cursor position to the left margin after execution of the IL and DL escape sequences. - [`8cec76f`](https://github.com/microsoft/terminal/commit/8cec76fe88126a6de56a2be37b574632a54ea702) Update IL and DL screen buffer tests to account for the cursor moving to the left margin. ### 📊 Changes **2 files changed** (+23 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/host/getset.cpp` (+5 -0) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+18 -6) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request According to the DEC STD 070 manual, the cursor position should be moved to the left margin after the execution of the `IL` and `DL` escape sequences. This PR updates the code to implement that behaviour. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #2534 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests updated * [ ] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2534 <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments I've modified the `DoSrvPrivateModifyLinesImpl` function (which is where the `IL` and `DL` controls are ultimately handled), to update the cursor position - setting the column to 0 - after the screen has been scrolled. Note that this has to happen inside the `IsCursorInMargins` check, since the cursor is not supposed to be moved if it was outside the margin boundaries. Also note that this should really be set to the left margin specified by [`DECSLRM`](https://vt100.net/docs/vt510-rm/DECSLRM.html), but we don't yet support that control, so for now it's hardcoded to 0. When it came to actually setting the cursor position, I found there were a number of options to choose from, with quite different behaviours. Some operations use a variation of `SetConsoleCursorPosition`, some use `AdjustCursorPosition`, and some call the `SCREEN_INFORMATION::SetCursorPosition` method directly, or even just `Cursor::SetPosition`. It wasn't always clear to why a particular method was chosen. I ultimately decided on `SCREEN_INFORMATION::SetCursorPosition` with the `TurnOn` parameter set to false, since that seemed the simplest option that also matched the behaviour of a carriage return. I'm not certain that's the best choice, though, so I'm open to other suggestions. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed There were a number of existing `IL` and `DL` tests that assumed the cursor position was not meant to move, and validated that behaviour. I've updated all of those tests to confirm that cursor position is now moved to column 0 when those escape sequences are executed. --- <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:06:57 +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#25052