-/* NetHack 3.6 getline.c $NHDT-Date: 1432512813 2015/05/25 00:13:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
+/* NetHack 3.6 getline.c $NHDT-Date: 1523619111 2018/04/13 11:31:51 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.35 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
+/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
/*
#include "func_tab.h"
char morc = 0; /* tell the outside world what char you chose */
+STATIC_VAR boolean suppress_history;
STATIC_DCL boolean FDECL(ext_cmd_getlin_hook, (char *));
typedef boolean FDECL((*getlin_hook_proc), (char *));
const char *query;
register char *bufp;
{
+ suppress_history = FALSE;
hooked_tty_getlin(query, bufp, (getlin_hook_proc) 0);
}
cw->flags &= ~WIN_STOP;
ttyDisplay->toplin = 3; /* special prompt state */
ttyDisplay->inread++;
- pline("%s ", query);
- *obufp = 0;
+
+ /* issue the prompt */
+ custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query);
+#ifdef EDIT_GETLIN
+ /* bufp is input/output; treat current contents (presumed to be from
+ previous getlin()) as default input */
+ addtopl(obufp);
+ bufp = eos(obufp);
+#else
+ /* !EDIT_GETLIN: bufp is output only; init it to empty */
+ *bufp = '\0';
+#endif
+
for (;;) {
(void) fflush(stdout);
Strcat(strcat(strcpy(toplines, query), " "), obufp);
if (c == '\020') { /* ctrl-P */
if (iflags.prevmsg_window != 's') {
int sav = ttyDisplay->inread;
+
ttyDisplay->inread = 0;
(void) tty_doprev_message();
ttyDisplay->inread = sav;
}
}
#endif
-#if defined(apollo)
} else if (c == '\n' || c == '\r') {
-#else
- } else if (c == '\n') {
-#endif
#ifndef NEWAUTOCOMP
*bufp = 0;
#endif /* not NEWAUTOCOMP */
#if 0 /*JP*/
} else if (' ' <= (unsigned char) c && c != '\177'
#else
- } else if(' ' <= uc && uc < '\377'
+ } else if (' ' <= uc && uc < '\377'
#endif
+ /* avoid isprint() - some people don't have it
+ ' ' is not always a printing char */
&& (bufp - obufp < BUFSZ - 1 && bufp - obufp < COLNO)) {
-/* avoid isprint() - some people don't have it
- ' ' is not always a printing char */
#ifdef NEWAUTOCOMP
char *i = eos(bufp);
#endif /* NEWAUTOCOMP */
}
} else if (c == kill_char || c == '\177') { /* Robert Viduya */
-/* this test last - @ might be the kill_char */
+ /* this test last - @ might be the kill_char */
#ifndef NEWAUTOCOMP
while (bufp != obufp) {
bufp--;
#if 1 /*JP*/
Strcpy(bfp, str2ic(tmp));
#endif
+
+ if (suppress_history) {
+ /* prevent next message from pushing current query+answer into
+ tty message history */
+ *toplines = '\0';
+#ifdef DUMPLOG
+ } else {
+ /* needed because we've bypassed pline() */
+ dumplogmsg(toplines);
+#endif
+ }
}
void
!program_state.done_hup &&
#endif
(c = tty_nhgetch()) != EOF) {
- if (c == '\n')
+ if (c == '\n' || c == '\r')
break;
if (iflags.cbreak) {
morc = '\033';
break;
}
- if ((s && index(s, c)) || c == x) {
+ if ((s && index(s, c)) || c == x || (x == '\n' && c == '\r')) {
morc = (char) c;
break;
}
com_index = -1;
for (oindex = 0; extcmdlist[oindex].ef_txt != (char *) 0; oindex++) {
- if (!strncmpi(base, extcmdlist[oindex].ef_txt, strlen(base))) {
+ if ((extcmdlist[oindex].flags & AUTOCOMPLETE)
+ && !(!wizard && (extcmdlist[oindex].flags & WIZMODECMD))
+ && !strncmpi(base, extcmdlist[oindex].ef_txt, strlen(base))) {
if (com_index == -1) /* no matches yet */
com_index = oindex;
else /* more than 1 match */
if (iflags.extmenu)
return extcmd_via_menu();
- /* maybe a runtime option? */
- /* hooked_tty_getlin("#", buf, flags.cmd_comp ? ext_cmd_getlin_hook :
- * (getlin_hook_proc) 0); */
+
+ suppress_history = TRUE;
+ /* maybe a runtime option?
+ * hooked_tty_getlin("#", buf,
+ * (flags.cmd_comp && !in_doagain)
+ * ? ext_cmd_getlin_hook
+ * : (getlin_hook_proc) 0);
+ */
+ buf[0] = '\0';
hooked_tty_getlin("#", buf, in_doagain ? (getlin_hook_proc) 0
: ext_cmd_getlin_hook);
(void) mungspaces(buf);