Add support for the VPR and HPR escape sequences #4793

Closed
opened 2026-01-30 23:56:40 +00:00 by claunia · 1 comment
Owner

Originally created by @j4james on GitHub (Nov 4, 2019).

Description of the new feature/enhancement

The VPR (vertical position relative) and HPR (horizontal position relative) escape sequences were introduced in the VT510 terminal, and are similar to CUD and CUF, except that CUD and CUF are constrained by the vertical and horizontal margins, while VPR and HPR are not (unless the DECOM origin mode is set to relative, in which case everything is constrained by the margins).

There's probably not a lot of demand for these, since they don't appear to be widely supported, but they are required to pass some of the higher level tests in Vttest.

I should point out that the ECMA-048 standard also defines VPB and HPB operations, which are essentially the reverse of VPR and HPR. However, those don't seem to have been supported by any of the VT terminals, and they aren't supported by XTerm either, so I'm not sure they're worth adding.

Proposed technical implementation details (optional)

As mentioned above, VPR and HPR are quite similar to CUD and CUF, but not similar enough to easily share any of the existing code. So I thought this might be a good opportunity to evalute all the cursor movement operations, and see if we could find a way to make the code more reusable between them.

There are currently three different routines used for cursor movement:

None of these routines are really appropriate for the proposed VPR and HPR commands. Nor do they correctly handle the CNL and CPL commands (see issue #2926). However, I think it should be possible to unify them into a single routine that could handle all of the above cases.

Let's say we created a method that could take x and y offsets, each of which could be absolute or relative, and then also a flag specifying whether the operation should be constrained by the margins. We could then handle the various operations as follows:

Operation X Offset Y Offset Margin Constraint
CUU/CUD relative 0 relative distance yes
CUF/CUB relative distance relative 0 yes
CNL/CPL absolute 0 relative distance yes
HPA/CHA absolute column relative 0 no
VPA relative 0 absolute row no
CUP absolute column absolute row no
HPR relative distance relative 0 no
VPR relative 0 relative distance no

Note that a relative offset of 0 is used when you don't want one of the coordinates to change. And an absolute offset of 0 in the x coordinate is used to force a carriage return.

Such a routine shouldn't be any more complicated than the existing methods, but could still handle all of their functionality and more.

Originally created by @j4james on GitHub (Nov 4, 2019). # Description of the new feature/enhancement The [`VPR`](https://www.vt100.net/docs/vt510-rm/VPR.html) (vertical position relative) and [`HPR`](https://www.vt100.net/docs/vt510-rm/HPR.html) (horizontal position relative) escape sequences were introduced in the VT510 terminal, and are similar to [`CUD`](https://www.vt100.net/docs/vt510-rm/CUD.html) and [`CUF`](https://www.vt100.net/docs/vt510-rm/CUF.html), except that `CUD` and `CUF` are constrained by the vertical and horizontal margins, while `VPR` and `HPR` are not (unless the [`DECOM`](https://www.vt100.net/docs/vt510-rm/DECOM.html) origin mode is set to relative, in which case everything is constrained by the margins). There's probably not a lot of demand for these, since they don't appear to be widely supported, but they are required to pass some of the higher level tests in [Vttest](https://invisible-island.net/vttest/). I should point out that the ECMA-048 standard also defines `VPB` and `HPB` operations, which are essentially the reverse of `VPR` and `HPR`. However, those don't seem to have been supported by any of the VT terminals, and they aren't supported by XTerm either, so I'm not sure they're worth adding. # Proposed technical implementation details (optional) As mentioned above, `VPR` and `HPR` are quite similar to `CUD` and `CUF`, but not similar enough to easily share any of the existing code. So I thought this might be a good opportunity to evalute all the cursor movement operations, and see if we could find a way to make the code more reusable between them. There are currently three different routines used for cursor movement: - [`AdaptDispatch::_CursorMovement`](https://github.com/microsoft/terminal/blob/94fc40ed31c0de050304248644458b21d0cce2e9/src/terminal/adapter/adaptDispatch.cpp#L77) is used by `CUF`, `CUB`, `CNL`, and `CPL`. - [`AdaptDispatch::_CursorMovePosition`](https://github.com/microsoft/terminal/blob/94fc40ed31c0de050304248644458b21d0cce2e9/src/terminal/adapter/adaptDispatch.cpp#L297) is used by `CUP`, `VPA`, `HPA`, and `CHA`. - [`DoSrvMoveCursorVertically`](https://github.com/microsoft/terminal/blob/b664761c798e7aaa63031e6f409a29715691f5a1/src/host/getset.cpp#L1458) (via `ConGetSet::MoveCursorVertically`) is used by `CUU` and `CUD`. None of these routines are really appropriate for the proposed `VPR` and `HPR` commands. Nor do they correctly handle the `CNL` and `CPL` commands (see issue #2926). However, I think it should be possible to unify them into a single routine that could handle all of the above cases. Let's say we created a method that could take x and y offsets, each of which could be absolute or relative, and then also a flag specifying whether the operation should be constrained by the margins. We could then handle the various operations as follows: | Operation | X Offset | Y Offset | Margin Constraint | | ------------- | --------------------- | --------------------- | ------------- | | `CUU`/`CUD` | relative 0 | relative _distance_ | yes | | `CUF`/`CUB` | relative _distance_ | relative 0 | yes | | `CNL`/`CPL` | absolute 0 | relative _distance_ | yes | | `HPA`/`CHA` | absolute _column_ | relative 0 | no | | `VPA` | relative 0 | absolute _row_ | no | | `CUP` | absolute _column_ | absolute _row_ | no | | `HPR` | relative _distance_ | relative 0 | no | | `VPR` | relative 0 | relative _distance_ | no | Note that a relative offset of 0 is used when you don't want one of the coordinates to change. And an absolute offset of 0 in the x coordinate is used to force a carriage return. Such a routine shouldn't be any more complicated than the existing methods, but could still handle all of their functionality and more.
claunia added the Product-ConhostResolution-Fix-CommittedIssue-TaskArea-VT labels 2026-01-30 23:56:40 +00:00
Author
Owner

@ghost commented on GitHub (Feb 13, 2020):

:tada:This issue was addressed in #4297, which has now been successfully released as Windows Terminal Preview v0.9.433.0.🎉

Handy links:

@ghost commented on GitHub (Feb 13, 2020): :tada:This issue was addressed in #4297, which has now been successfully released as `Windows Terminal Preview v0.9.433.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.9.433.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?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#4793