public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Nicolas Pitre <nico@fluxnic.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Nicolas Pitre <npitre@baylibre.com>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] vt: add TIOCL_GETCURSORPOS to retrieve the screen cursor position
Date: Wed, 14 May 2025 07:57:54 +0200	[thread overview]
Message-ID: <518b6620-bca0-45e4-8c1f-6cd9ab18bee2@kernel.org> (raw)
In-Reply-To: <20250514015554.19978-3-nico@fluxnic.net>

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

  reply	other threads:[~2025-05-14  5:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-14  1:52 [PATCH 0/2] vt: bracketed paste and cursor position Nicolas Pitre
2025-05-14  1:52 ` [PATCH 1/2] vt: bracketed paste support Nicolas Pitre
2025-05-14  5:43   ` Jiri Slaby
2025-05-14  1:52 ` [PATCH 2/2] vt: add TIOCL_GETCURSORPOS to retrieve the screen cursor position Nicolas Pitre
2025-05-14  5:57   ` Jiri Slaby [this message]
2025-05-14 13:25     ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=518b6620-bca0-45e4-8c1f-6cd9ab18bee2@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=nico@fluxnic.net \
    --cc=npitre@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox