Add support for horizontal margin sequences #19405

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

Originally created by @j4james on GitHub (Feb 19, 2023).

Description of the new feature/enhancement

The DECSLRM escape sequence lets you set left and right margins, so you can wrap your output within a given horizontal range, and also limit the scrolling within those boundaries. This is useful for apps like multiplexers, where you can have two panes side by side, and you need to be able to scroll the one side independently of the other.

Proposed technical implementation details (optional)

There are actually two sequences we need to implement for this. The first is DECLRMM (Left Right Margin Mode), without which the margin functionality won't be active. It's disabled by default because you can't use horizontal margins at the same time as double-width line attributes.

The main sequence is DECSLRM (Set Left Right Margins), which works similarly to the DECSTBM sequence (Set Top Bottom Margins) which we already support. But there a bunch of operations we then need to update to take those margins into account - cursor movement, insert and delete ops, text output, etc.

I should also note that the DECSLRM sequence clashes with the ANSISYSSC sequence which we already support. But the way most modern terminals deal with that is to disable ANSISYSSC when the DECLRMM mode is enabled. So by default CSI s is ANSISYSSC (as we have it now), but with DECLRMM enabled it's interpreted as DECSLRM.

Originally created by @j4james on GitHub (Feb 19, 2023). # Description of the new feature/enhancement The `DECSLRM` escape sequence lets you set left and right margins, so you can wrap your output within a given horizontal range, and also limit the scrolling within those boundaries. This is useful for apps like multiplexers, where you can have two panes side by side, and you need to be able to scroll the one side independently of the other. # Proposed technical implementation details (optional) There are actually two sequences we need to implement for this. The first is `DECLRMM` (Left Right Margin Mode), without which the margin functionality won't be active. It's disabled by default because you can't use horizontal margins at the same time as double-width line attributes. The main sequence is `DECSLRM` (Set Left Right Margins), which works similarly to the `DECSTBM` sequence (Set Top Bottom Margins) which we already support. But there a bunch of operations we then need to update to take those margins into account - cursor movement, insert and delete ops, text output, etc. I should also note that the `DECSLRM` sequence clashes with the `ANSISYSSC` sequence which we already support. But the way most modern terminals deal with that is to disable `ANSISYSSC` when the `DECLRMM` mode is enabled. So by default `CSI s` is `ANSISYSSC` (as we have it now), but with `DECLRMM` enabled it's interpreted as `DECSLRM`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19405