1 /* NetHack 3.6 mgetline.c $NHDT-Date: 1432512797 2015/05/25 00:13:17 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
11 extern int NDECL(extcmd_via_menu); /* cmd.c */
13 typedef Boolean FDECL((*key_func), (unsigned char));
16 get_line_from_key_queue(char *bufp)
19 if (try_key_queue(bufp)) {
21 if (*bufp == 10 || *bufp == 13) {
32 topl_getlin(const char *query, char *bufp, Boolean ext)
34 if (get_line_from_key_queue(bufp))
37 enter_topl_mode((char *) query);
38 while (topl_key(nhgetch(), ext))
40 leave_topl_mode(bufp);
44 * Read a line closed with '\n' into the array char bufp[BUFSZ].
45 * (The '\n' is not stored. The string is closed with a '\0'.)
46 * Reading can be interrupted by an escape ('\033') - now the
47 * resulting string is "\033".
50 mac_getlin(const char *query, char *bufp)
52 topl_getlin(query, bufp, false);
55 /* Read in an extended command - doing command line completion for
56 * when enough characters have been entered to make a unique command.
57 * This is just a modified getlin() followed by a lookup. -jsb
66 return extcmd_via_menu();
67 topl_getlin("# ", bufp, true);
68 for (i = 0; extcmdlist[i].ef_txt != (char *) 0; i++)
69 if (!strcmp(bufp, extcmdlist[i].ef_txt))
71 if (extcmdlist[i].ef_txt == (char *) 0)
72 i = -1; /* not found */