From 79cdcff7e44fe47b39b9ee9f66237e2f2987c0cf Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Wed, 29 Nov 2023 19:20:07 -0500 Subject: [PATCH] Fix: msg_window:combination and TTY getlin() ^P The ability to use ^P from within a TTY getlin prompt didn't work with msg_window:combination: it's a combination (unsurprisingly) of 'full' and 'single', but hooked_tty_getlin() was treating it like 'full': i.e. expecting everything to be displayed at once, with doprev_message() returning only once the user was finished reading. I didn't even know ^P was supposed to be accessible from a getlin prompt until Pat's recent commit 5120764, because I have always used msg_window:combination -- I had come up with a system where I'd name a potion thrown at me "xx", check the previous messages with ^P, and then rename it from the discoveries list. This will be a lot easier! --- win/tty/getline.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/win/tty/getline.c b/win/tty/getline.c index 38215abd1..093ef37cc 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -48,7 +48,7 @@ hooked_tty_getlin( register char *obufp = bufp; register int c; struct WinDesc *cw = wins[WIN_MESSAGE]; - boolean doprev = 0; + boolean doprev = FALSE; if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP)) more(); @@ -100,29 +100,36 @@ hooked_tty_getlin( *bufp = 0; } if (c == C('p')) { /* ctrl-P, doesn't honor rebinding #prevmsg cmd */ - if (iflags.prevmsg_window != 's') { - int sav = ttyDisplay->inread; + int sav = ttyDisplay->inread; - ttyDisplay->inread = 0; + ttyDisplay->inread = 0; + if (iflags.prevmsg_window == 's' + || (iflags.prevmsg_window == 'c' && !doprev)) { + /* msg_window:single, or msg_window:combination while it's + behaving like msg_window:single */ + if (!doprev) + (void) tty_doprev_message(); /* need two initially */ (void) tty_doprev_message(); ttyDisplay->inread = sav; + doprev = TRUE; + continue; + } else { + /* msg_window:full or reverse, or msg_window:combination while + it's behaving like msg_window:full */ + (void) tty_doprev_message(); + ttyDisplay->inread = sav; + doprev = FALSE; tty_clear_nhwindow(WIN_MESSAGE); cw->maxcol = cw->maxrow; addtopl(query); addtopl(" "); *bufp = 0; addtopl(obufp); - } else { - if (!doprev) - (void) tty_doprev_message(); /* need two initially */ - (void) tty_doprev_message(); - doprev = 1; - continue; } - } else if (doprev && iflags.prevmsg_window == 's') { + } else if (doprev) { tty_clear_nhwindow(WIN_MESSAGE); cw->maxcol = cw->maxrow; - doprev = 0; + doprev = FALSE; addtopl(query); addtopl(" "); *bufp = 0;