[PATCH] Turn off curses meta() mode before exiting.
"Kevin J. McCarthy" <[email protected]> Mon, 22 Jun 2026 13:30:06 +0800
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <[email protected]> |
Ncurses does not change the mode back, thus leaving some terminals,
such as foot, in a different state than when they started.
---
This is a patch against stable branch.
See gitlab ticket: https://gitlab.com/muttmua/mutt/-/work_items/528
and also the foot ticket referenced there at:
https://codeberg.org/dnkl/foot/issues/2393
I also emailed Thomas Dickey to check with him about this. He
confirmed that meta() is not reset. It's apparently a rarely set
mode, and so he also advised to turn it back off before exiting.
curs_lib.c | 10 ++++++++++
main.c | 9 ++++++++-
mutt_curses.h | 1 +
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/curs_lib.c b/curs_lib.c
index 5c93cbb0..62451c43 100644
--- a/curs_lib.c
+++ b/curs_lib.c
@@ -1008,6 +1008,16 @@ void mutt_show_error(void)
mutt_window_clrtoeol(MuttMessageWindow);
}
+/* Before exiting, turn off features enabled in start_curses() that
+ * are not reversed by endwin().
+ */
+void mutt_curses_cleanup(void)
+{
+#if HAVE_META
+ meta(stdscr, FALSE);
+#endif
+}
+
void mutt_endwin(const char *msg)
{
int e = errno;
diff --git a/main.c b/main.c
index 376d9407..95720f2b 100644
--- a/main.c
+++ b/main.c
@@ -126,7 +126,11 @@ char **envlist;
void mutt_exit(int code)
{
- mutt_endwin(NULL);
+ if (!option(OPTNOCURSES))
+ {
+ mutt_curses_cleanup();
+ mutt_endwin(NULL);
+ }
exit(code);
}
@@ -1433,6 +1437,9 @@ cleanup_and_exit:
mutt_free_windows();
mutt_buffer_pool_free();
if (!option(OPTNOCURSES))
+ {
+ mutt_curses_cleanup();
mutt_endwin(exit_endwin_msg);
+ }
exit(exit_code);
}
diff --git a/mutt_curses.h b/mutt_curses.h
index cdd63c72..75f193ca 100644
--- a/mutt_curses.h
+++ b/mutt_curses.h
@@ -86,6 +86,7 @@ extern int MuttGetchTimeout;
event_t mutt_getch(void);
void mutt_getch_timeout(int);
+void mutt_curses_cleanup(void);
void mutt_endwin(const char *);
void mutt_flushinp(void);
void mutt_refresh(void);
--
2.54.0