[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <518b6620-bca0-45e4-8c1f-6cd9ab18bee2@kernel.org>
Date: Wed, 14 May 2025 07:57:54 +0200
From: Jiri Slaby <jirislaby@...nel.org>
To: Nicolas Pitre <nico@...xnic.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Nicolas Pitre <npitre@...libre.com>, linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] vt: add TIOCL_GETCURSORPOS to retrieve the screen
cursor position
On 14. 05. 25, 3:52, Nicolas Pitre wrote:
...
> So let's work around this limitation by adding TIOCL_GETCURSORPOS as a
> fallback method to get the cursor position when /dev/vcsa reports 255.
...
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
...
> +/* invoked via ioctl(TIOCLINUX) */
> +static int get_cursor_pos(struct tty_struct *tty)
> +{
> + struct vc_data *vc = tty->driver_data;
> + unsigned int x, y;
> +
> + console_lock();
> + x = vc->state.x;
> + y = vc->state.y;
> + console_unlock();
> +
> + /*
> + * Clamp x to 16 bits, y to 15 bits. A display larger than 65535x32767
> + * characters won't be a concern for the foreseeable future.
> + * Bit 31 is reserved to represent negative error codes elsewhere.
> + */
> + return min(x, 0xFFFFu) | (min(y, 0x7FFFu) << 16);
Hmm, I would do a proper struct instead. Like winsize.
> --- a/include/uapi/linux/tiocl.h
> +++ b/include/uapi/linux/tiocl.h
> @@ -38,4 +38,8 @@ struct tiocl_selection {
> #define TIOCL_GETKMSGREDIRECT 17 /* get the vt the kernel messages are restricted to */
> #define TIOCL_GETBRACKETEDPASTE 18 /* get whether paste may be bracketed */
>
> +#define TIOCL_GETCURSORPOS 20 /* Get screen cursor position */
The same question about man-pages :).
thanks,
--
js
suse labs
Powered by blists - more mailing lists