Skip to content

Use ANSI CSI 18 to query console size#39833

Merged
poettering merged 2 commits intosystemd:mainfrom
keszybz:console-csi-18
Dec 18, 2025
Merged

Use ANSI CSI 18 to query console size#39833
poettering merged 2 commits intosystemd:mainfrom
keszybz:console-csi-18

Conversation

@keszybz
Copy link
Member

@keszybz keszybz commented Nov 20, 2025

No description provided.

In my tests, the sequence works on Ptyxis 49.0, gnome-terminal-3.56.3,
xterm-401, rxvt-unicode-9.31, under tmux-3.5a, over ssh and serial console
connected to ptyxis. It did not work on a text console in a VM (TERM=linux) or
under kmscon-9.1.0 (TERM=vt102).
@github-actions github-actions bot added util-lib tests please-review PR is ready for (re-)review by a maintainer labels Nov 20, 2025
return r;
}

/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kmscon seems quite active upstream, have you asked them to add this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kmscon/kmscon#166 filed now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a draft implementation for CSI 18 in kmscon at kmscon/libtsm#4

One thing I didn't figured out is what's the difference between "window size" and "screen size" ?
For kmscon, as it has only one full-screen window, CSI 18 and CSI 19 should report the same?

Copy link

@bam80 bam80 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know for sure, but in my impression when you split the screen e.g. in Vim (text-mode) session, and open embedded terminal in one of it's split window (with :term command) - it should report correct window size then. Not sure who is responsible for that in this case - the outer terminal or Vim itself.
BTW, if Vim is responsible, we should file an issue there, too (if it doesn't work there).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdj0c thanks!

I think the distinction isn't terribly relevant for our use case here. I doubt people are running systemd as PID1 in a split window in an editor ;)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt people are running systemd as PID1 in a split window in an editor ;)

If this happens when running in VM, this is exactly how I run it.

@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels Dec 5, 2025
@YHNdnzj YHNdnzj added good-to-merge/with-minor-suggestions and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed good-to-merge/after-next-release labels Dec 12, 2025
This allows us to query the window size without moving the cursor. We have
various reports about the cursor being in an unexpected position and/or state.

Closes systemd#37526.
@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels Dec 18, 2025
@poettering poettering merged commit 627e583 into systemd:main Dec 18, 2025
59 of 66 checks passed
@github-actions github-actions bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Dec 18, 2025
@keszybz keszybz deleted the console-csi-18 branch January 4, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Consider use of CSI 18(9?) t seq for querying the current terminal size

5 participants