From: Jiri Slaby <jirislaby@kernel.org>
To: Calixte Pernot <calixte.pernot@grenoble-inp.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH] vt: add support for smput/rmput escape codes
Date: Mon, 25 Aug 2025 07:47:10 +0200 [thread overview]
Message-ID: <e5f75c37-30a5-4c4e-aae5-a72060be24da@kernel.org> (raw)
In-Reply-To: <20250824142016.47219-1-calixte.pernot@grenoble-inp.org>
Hi,
On 24. 08. 25, 16:20, Calixte Pernot wrote:
> Support "\e[?1049h" and "\e[?1049l" escape codes.
> This patch allows programs to enter and leave alternate screens.
> This feature is widely available in graphical terminal emulators and mostly
> used by fullscreen terminal-based user interfaces such as text editors.
> Most editors such as vim and nano assume this escape code in not supported
> and will not try to print the escape sequence if TERM=linux.
> To try out this patch, run `TERM=xterm-256color vim` inside a VT.
>
> Signed-off-by: Calixte Pernot <calixte.pernot@grenoble-inp.org>
...
> --- a/drivers/tty/vt/vt.c
> +++ b/drivers/tty/vt/vt.c
...
> @@ -1878,6 +1883,46 @@ static int get_bracketed_paste(struct tty_struct *tty)
> return vc->vc_bracketed_paste;
> }
>
> +/* console_lock is held */
> +static void enter_alt_screen(struct vc_data *vc)
> +{
> + unsigned int size = vc->vc_rows * vc->vc_cols * 2;
> +
> + if (vc->vc_saved_screen != NULL)
> + return; /* Already inside an alt-screen */
All this is protected by console_lock, right?
> + vc->vc_saved_screen = kzalloc(size, GFP_NOWAIT);
Why GFP_NOWAIT?
> + if (vc->vc_saved_screen == NULL)
> + return;
> + memcpy(vc->vc_saved_screen, (u16 *)vc->vc_origin, size);
kmemdup();
> + vc->vc_saved_rows = vc->vc_rows;
> + vc->vc_saved_cols = vc->vc_cols;
> + save_cur(vc);
> + /* clear entire screen */
> + csi_J(vc, CSI_J_FULL);
> +}
> +
> +/* console_lock is held */
> +static void leave_alt_screen(struct vc_data *vc)
> +{
> + unsigned int rows = min(vc->vc_saved_rows, vc->vc_rows);
> + unsigned int cols = min(vc->vc_saved_cols, vc->vc_cols);
> + unsigned short *src, *dest;
u16
> +
> + if (vc->vc_saved_screen == NULL)
> + return; /* Not inside an alt-screen */
> + for (int r = 0; r < rows; r++) {
unsigned
> + src = vc->vc_saved_screen + r * vc->vc_saved_cols;
> + dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols;
> + memcpy(dest, src, 2 * cols);
> + }
> + restore_cur(vc);
> + /* Update the entire screen */
> + if (con_should_update(vc))
> + do_update_region(vc, vc->vc_origin, vc->vc_screenbuf_size / 2);
> + kfree(vc->vc_saved_screen);
> + vc->vc_saved_screen = NULL;
> +}
...
> --- a/include/linux/console_struct.h
> +++ b/include/linux/console_struct.h
> @@ -159,6 +159,9 @@ struct vc_data {
> struct uni_pagedict *uni_pagedict;
> struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */
> u32 **vc_uni_lines; /* unicode screen content */
> + unsigned short *vc_saved_screen;
u16 *
> + unsigned int vc_saved_cols;
> + unsigned int vc_saved_rows;
> /* additional information is in vt_kern.h */
> };
>
thanks,
--
js
suse labs
next prev parent reply other threads:[~2025-08-25 5:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-24 14:20 [PATCH] vt: add support for smput/rmput escape codes Calixte Pernot
2025-08-25 5:47 ` Jiri Slaby [this message]
2025-08-25 11:41 ` Calixte Pernot
2025-08-25 12:56 ` [PATCH v2] " Calixte Pernot
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=e5f75c37-30a5-4c4e-aae5-a72060be24da@kernel.org \
--to=jirislaby@kernel.org \
--cc=calixte.pernot@grenoble-inp.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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