From b72f7401d578bd800e71cd9504e7de0311887dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 15 Jan 2021 15:46:50 +0100 Subject: [PATCH] =?UTF-8?q?csi:=20overwrite=20=E2=80=9Csaved=20cursor?= =?UTF-8?q?=E2=80=9D=20position=20when=20entering=20the=20alt=20screen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verified with vttest 11.8.7.3 - XTerm Alternate Screen features --- CHANGELOG.md | 2 ++ csi.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21baf89b..7a731886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,8 @@ (https://codeberg.org/dnkl/foot/issues/291). * Sixel “current geometry” query response not being bounded by the current window dimensions (fixes `lsix` output) +* Entering the alt screen did not update the normal screen’s “saved + cursor” position. ### Security diff --git a/csi.c b/csi.c index e833d2a7..af079df7 100644 --- a/csi.c +++ b/csi.c @@ -493,6 +493,18 @@ decset_decrst(struct terminal *term, unsigned param, bool enable) if (enable && term->grid != &term->alt) { selection_cancel(term); + /* + * A ‘cursor restore’ *after* returning from alt screen + * should restore the cursor from where it was when + * *entering* alt mode. + * + * I.e. entering alt mode “overwrites” the previous saved + * cursor position. + * + * Checked by vttest 11.8.7.3 + */ + term->grid->saved_cursor = term->grid->cursor; + term->grid = &term->alt; term_cursor_to(