mirror-linux/drivers/tty/vt
Nicolas Pitre 81cf4d7d23 vt: add VT_GETCONSIZECSRPOS to retrieve console size and cursor position
The console dimension and cursor position are available through the
/dev/vcsa interface already. However the /dev/vcsa header format uses
single-byte fields therefore those values are clamped to 255.

As surprizing as this may seem, some people do use 240-column 67-row
screens (a 1920x1080 monitor with 8x16 pixel fonts) which is getting
close to the limit. Monitors with higher resolution are not uncommon
these days (3840x2160 producing a 480x135 character display) and it is
just a matter of time before someone with, say, a braille display using
the Linux VT console and BRLTTY on such a screen reports a bug about
missing and oddly misaligned screen content.

Let's add VT_GETCONSIZECSRPOS for the retrieval of console size and cursor
position without byte-sized limitations. The actual console size limit as
encoded in vt.c is 32767x32767 so using a short here is appropriate. Then
this can be used to get the cursor position when /dev/vcsa reports 255.

The screen dimension may already be obtained using TIOCGWINSZ and adding
the same information to VT_GETCONSIZECSRPOS might be redundant. However
applications that care about cursor position also care about display
size and having 2 separate system calls to obtain them separately is
wasteful. Also, the cursor position can be queried by writing "\e[6n" to
a tty and reading back the result but that may be done only by the actual
application using that tty and not a sideline observer.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Link: https://lore.kernel.org/r/20250520171851.1219676-3-nico@fluxnic.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-21 13:41:03 +02:00
..
.gitignore vt: create ucs_fallback_table.h_shipped with gen_ucs_fallback_table.py 2025-05-21 13:39:45 +02:00
Makefile vt: add ucs_get_fallback() 2025-05-21 13:39:45 +02:00
conmakehash.c tty: vt: conmakehash: remove non-portable code printing comment header 2024-08-13 11:06:29 +02:00
consolemap.c vt: remove zero-width-space handling from conv_uni_to_pc() 2025-04-26 11:22:04 +02:00
cp437.uni
defkeymap.c_shipped
defkeymap.map
gen_ucs_fallback_table.py vt: process the full-width ASCII fallback range programmatically 2025-05-21 13:39:45 +02:00
gen_ucs_recompose_table.py vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
gen_ucs_width_table.py vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
keyboard.c tty/vt: Gather the code that outputs char with utf8 in mind 2025-04-25 16:28:44 +02:00
selection.c vt: bracketed paste support 2025-05-21 13:41:03 +02:00
ucs.c vt: process the full-width ASCII fallback range programmatically 2025-05-21 13:39:45 +02:00
ucs_fallback_table.h_shipped vt: process the full-width ASCII fallback range programmatically 2025-05-21 13:39:45 +02:00
ucs_recompose_table.h_shipped vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
ucs_width_table.h_shipped vt: move UCS tables to the "shipped" form 2025-04-26 11:22:04 +02:00
vc_screen.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
vt.c vt: bracketed paste support 2025-05-21 13:41:03 +02:00
vt_ioctl.c vt: add VT_GETCONSIZECSRPOS to retrieve console size and cursor position 2025-05-21 13:41:03 +02:00