VT parser for erase operations needs to be able to handle multiple arguments #2935

Closed
opened 2026-01-30 23:09:07 +00:00 by claunia · 2 comments
Owner

Originally created by @PankajBhojwani on GitHub (Jul 25, 2019).

Currently, _GetEraseOperation in OutputStateMachineEngine.cpp cannot handle input sequences which are meant to call the same erase operation more than once but with different erase types. For example, it cannot handle "]3;J" or "]3;2J". Upon receiving these kinds of inputs the function fails to convert the parameters into their respective erase types and the erase operation is not called at all.

This can be fixed by changing the output memory location to be an array of erase types instead of just a single erase type, and the function would then add erase types to that array as it loops through the input parameters.

Changes that would need to be made elsewhere to accommodate this change:

  • the erase operations themselves (in adaptDispatch and TerminalDispatch) would need to be changed to accept an array of erase types - they would then have to loop through the array and perform the required operations
  • the unit tests that call these functions would need to be updated
  • possibly other changes too
Originally created by @PankajBhojwani on GitHub (Jul 25, 2019). Currently, _GetEraseOperation in OutputStateMachineEngine.cpp cannot handle input sequences which are meant to call the same erase operation more than once but with different erase types. For example, it cannot handle "]3;J" or "]3;2J". Upon receiving these kinds of inputs the function fails to convert the parameters into their respective erase types and the erase operation is not called at all. This can be fixed by changing the output memory location to be an array of erase types instead of just a single erase type, and the function would then add erase types to that array as it loops through the input parameters. Changes that would need to be made elsewhere to accommodate this change: - the erase operations themselves (in adaptDispatch and TerminalDispatch) would need to be changed to accept an array of erase types - they would then have to loop through the array and perform the required operations - the unit tests that call these functions would need to be updated - possibly other changes too
Author
Owner

@j4james commented on GitHub (Jul 28, 2019):

Note that there are two related issues at work here.

  1. Most, if not all, single parameter commands should work with multiple parameters, assuming we want to match the behaviour of XTerm (I don't know if there is spec text to back this up). For example, consider this sequence:

    printf "X \e[5;10B Y\n"
    

    In XTerm that outputs the X and Y 5 lines apart. Even the though the Cursor Down command only takes one parameter, it still considers that a valid sequences and just ignores any additional parameters.

  2. Some commands, like Erase in Line and Erase in Display, are specifically documented as taking multiple parameters, even though they may appear to need only one. For these sequences, every one of the parameters should be processed in turn. So if you look at this sequence:

    printf "xxxxxxyyyyyy\b\b\b\b\b\b\e[0;1K\n" 
    

    Both parameters should be processed, so technically it should clear to both the beginning and the end of the line. However this behaviour was only documented for later VT terminals, as far as I can tell, and doesn't appear to be widely supported.

My point being that the first case is more important than the second, but also applies to far more than just the erase commands. The second case I would consider less of a priority, since I don't think even XTerm supports that.

@j4james commented on GitHub (Jul 28, 2019): Note that there are two related issues at work here. 1. Most, if not all, single parameter commands should work with multiple parameters, assuming we want to match the behaviour of XTerm (I don't know if there is spec text to back this up). For example, consider this sequence: ``` printf "X \e[5;10B Y\n" ``` In XTerm that outputs the X and Y 5 lines apart. Even the though the _Cursor Down_ command only takes one parameter, it still considers that a valid sequences and just ignores any additional parameters. 2. Some commands, like _Erase in Line_ and _Erase in Display_, are specifically documented as taking multiple parameters, even though they may appear to need only one. For these sequences, every one of the parameters should be processed in turn. So if you look at this sequence: ``` printf "xxxxxxyyyyyy\b\b\b\b\b\b\e[0;1K\n" ``` Both parameters should be processed, so technically it should clear to both the beginning and the end of the line. However this behaviour was only documented for later VT terminals, as far as I can tell, and doesn't appear to be widely supported. My point being that the first case is more important than the second, but also applies to far more than just the erase commands. The second case I would consider less of a priority, since I don't think even XTerm supports that.
Author
Owner

@ghost commented on GitHub (Nov 11, 2020):

:tada:This issue was addressed in #7799, which has now been successfully released as Windows Terminal Preview v1.5.3142.0.🎉

Handy links:

@ghost commented on GitHub (Nov 11, 2020): :tada:This issue was addressed in #7799, which has now been successfully released as `Windows Terminal Preview v1.5.3142.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.5.3142.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#2935