Compile-time option to allow some prompts remember the input
Define EDIT_GETLIN to make the tty, X11, and Qt4 windowports to remember the input strings for wishing and annotation.
This commit is contained in:
@@ -831,6 +831,7 @@ win32gui: save and load map colors from registry
|
||||
X11: add new character selection dialog, and obey player_selection:dialog
|
||||
unix: reduce makefile verbosity by default
|
||||
win32gui: new player selection dialog
|
||||
tty, x11, qt4: compile-time option to allow some prompts remember the input
|
||||
|
||||
|
||||
NetHack Community Patches (or Variation) Included
|
||||
|
||||
@@ -514,6 +514,11 @@ typedef unsigned char uchar;
|
||||
but it isn't necessary for successful operation of the program */
|
||||
#define FREE_ALL_MEMORY /* free all memory at exit */
|
||||
|
||||
/* EDIT_GETLIN makes the string input in TTY, Qt4, and X11
|
||||
so some prompts will remember the previously input text
|
||||
(within the same session) */
|
||||
/* #define EDIT_GETLIN */
|
||||
|
||||
/* #define DUMPLOG */ /* End-of-game dump logs */
|
||||
#ifdef DUMPLOG
|
||||
|
||||
|
||||
@@ -2740,7 +2740,7 @@ choose_value:
|
||||
|
||||
if (behavior == BL_TH_VAL_PERCENTAGE
|
||||
|| behavior == BL_TH_VAL_ABSOLUTE) {
|
||||
char inbuf[BUFSZ], buf[BUFSZ];
|
||||
char inbuf[BUFSZ] = DUMMY, buf[BUFSZ];
|
||||
int val;
|
||||
boolean skipltgt = FALSE;
|
||||
boolean gotnum = FALSE;
|
||||
@@ -2902,7 +2902,7 @@ choose_value:
|
||||
hilite.rel = TXT_VALUE;
|
||||
Strcpy(hilite.textmatch, rolelist[rv]);
|
||||
} else {
|
||||
char inbuf[BUFSZ];
|
||||
char inbuf[BUFSZ] = DUMMY;
|
||||
|
||||
inbuf[0] = '\0';
|
||||
getlin(qry_buf, inbuf);
|
||||
|
||||
@@ -750,7 +750,7 @@ wiz_mon_polycontrol(VOID_ARGS)
|
||||
STATIC_PTR int
|
||||
wiz_level_change(VOID_ARGS)
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
int newlevel;
|
||||
int ret;
|
||||
|
||||
@@ -3697,7 +3697,7 @@ static int
|
||||
wiz_migrate_mons()
|
||||
{
|
||||
int mcount = 0;
|
||||
char inbuf[BUFSZ];
|
||||
char inbuf[BUFSZ] = DUMMY;
|
||||
struct permonst *ptr;
|
||||
struct monst *mtmp;
|
||||
d_level tolevel;
|
||||
@@ -5449,7 +5449,7 @@ const char *prompt;
|
||||
to give the go-ahead for this query; default is "no" unless the
|
||||
ParanoidConfirm flag is set in which case there's no default */
|
||||
if (be_paranoid) {
|
||||
char qbuf[QBUFSZ], ans[BUFSZ];
|
||||
char qbuf[QBUFSZ], ans[BUFSZ] = DUMMY;
|
||||
const char *promptprefix = "", *responsetype = ParanoidConfirm
|
||||
? "(yes|no)"
|
||||
: "(yes) [no]";
|
||||
|
||||
@@ -1109,7 +1109,7 @@ char *monnambuf, *usrbuf;
|
||||
STATIC_OVL void
|
||||
do_mname()
|
||||
{
|
||||
char buf[BUFSZ], monnambuf[BUFSZ], qbuf[QBUFSZ];
|
||||
char buf[BUFSZ] = DUMMY, monnambuf[BUFSZ], qbuf[QBUFSZ];
|
||||
coord cc;
|
||||
int cx, cy;
|
||||
struct monst *mtmp = 0;
|
||||
@@ -1188,7 +1188,7 @@ void
|
||||
do_oname(obj)
|
||||
register struct obj *obj;
|
||||
{
|
||||
char *bufp, buf[BUFSZ], bufcpy[BUFSZ], qbuf[QBUFSZ];
|
||||
char *bufp, buf[BUFSZ] = DUMMY, bufcpy[BUFSZ], qbuf[QBUFSZ];
|
||||
const char *aname;
|
||||
short objtyp;
|
||||
|
||||
@@ -1443,7 +1443,7 @@ void
|
||||
docall(obj)
|
||||
struct obj *obj;
|
||||
{
|
||||
char buf[BUFSZ], qbuf[QBUFSZ];
|
||||
char buf[BUFSZ] = DUMMY, qbuf[QBUFSZ];
|
||||
char **str1;
|
||||
|
||||
if (!obj->dknown)
|
||||
|
||||
@@ -2034,17 +2034,24 @@ int
|
||||
donamelevel()
|
||||
{
|
||||
mapseen *mptr;
|
||||
char nbuf[BUFSZ]; /* Buffer for response */
|
||||
char nbuf[BUFSZ] = DUMMY; /* Buffer for response */
|
||||
|
||||
if (!(mptr = find_mapseen(&u.uz)))
|
||||
return 0;
|
||||
|
||||
#ifdef EDIT_GETLIN
|
||||
if (mptr->custom) {
|
||||
(void) strncpy(nbuf, mptr->custom, BUFSZ);
|
||||
nbuf[BUFSZ-1] = '\0';
|
||||
}
|
||||
#else
|
||||
if (mptr->custom) {
|
||||
char tmpbuf[BUFSZ];
|
||||
Sprintf(tmpbuf, "Replace annotation \"%.30s%s\" with?", mptr->custom,
|
||||
strlen(mptr->custom) > 30 ? "..." : "");
|
||||
getlin(tmpbuf, nbuf);
|
||||
} else
|
||||
#endif
|
||||
getlin("What do you want to call this dungeon level?", nbuf);
|
||||
if (index(nbuf, '\033'))
|
||||
return 0;
|
||||
|
||||
@@ -1593,7 +1593,7 @@ unsigned *resultflags;
|
||||
int oletct, iletct, unpaid, oc_of_sym;
|
||||
char sym, *ip, olets[MAXOCLASSES + 5], ilets[MAXOCLASSES + 10];
|
||||
char extra_removeables[3 + 1]; /* uwep,uswapwep,uquiver */
|
||||
char buf[BUFSZ], qbuf[QBUFSZ];
|
||||
char buf[BUFSZ] = DUMMY, qbuf[QBUFSZ];
|
||||
|
||||
if (!invent) {
|
||||
You("have nothing to %s.", word);
|
||||
|
||||
@@ -691,7 +691,7 @@ struct obj *otmp;
|
||||
{
|
||||
#ifdef SHELL /* can't access mail reader without spawning subprocess */
|
||||
const char *txt, *cmd;
|
||||
char *p, buf[BUFSZ], qbuf[BUFSZ];
|
||||
char *p, buf[BUFSZ] = DUMMY, qbuf[BUFSZ];
|
||||
int len;
|
||||
|
||||
/* there should be a command in OMAILCMD */
|
||||
|
||||
@@ -298,7 +298,7 @@ long
|
||||
bribe(mtmp)
|
||||
struct monst *mtmp;
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
long offer;
|
||||
long umoney = money_cnt(invent);
|
||||
|
||||
|
||||
@@ -3266,7 +3266,7 @@ struct monst *mon;
|
||||
|
||||
/* for debugging: allow control of polymorphed monster */
|
||||
if (wizard && iflags.mon_polycontrol) {
|
||||
char pprompt[BUFSZ], buf[BUFSZ];
|
||||
char pprompt[BUFSZ], buf[BUFSZ] = DUMMY;
|
||||
int monclass;
|
||||
|
||||
Sprintf(pprompt, "Change %s @ %s into what kind of monster?",
|
||||
|
||||
@@ -609,7 +609,7 @@ int
|
||||
do_play_instrument(instr)
|
||||
struct obj *instr;
|
||||
{
|
||||
char buf[BUFSZ], c = 'y';
|
||||
char buf[BUFSZ] = DUMMY, c = 'y';
|
||||
char *s;
|
||||
int x, y;
|
||||
boolean ok;
|
||||
|
||||
@@ -2836,7 +2836,7 @@ boolean tinitial, tfrom_file;
|
||||
fullname = "pickup_types";
|
||||
if (match_optname(opts, fullname, 8, TRUE)) {
|
||||
char ocl[MAXOCLASSES + 1], tbuf[MAXOCLASSES + 1], qbuf[QBUFSZ],
|
||||
abuf[BUFSZ];
|
||||
abuf[BUFSZ] = DUMMY;
|
||||
int oc_sym;
|
||||
boolean badopt = FALSE, compat = (strlen(opts) <= 6), use_menu;
|
||||
|
||||
@@ -4100,7 +4100,7 @@ int
|
||||
doset() /* changing options via menu by Per Liboriussen */
|
||||
{
|
||||
static boolean made_fmtstr = FALSE;
|
||||
char buf[BUFSZ], buf2[BUFSZ];
|
||||
char buf[BUFSZ], buf2[BUFSZ] = DUMMY;
|
||||
const char *name;
|
||||
int i = 0, pass, boolcount, pick_cnt, pick_idx, opt_indx;
|
||||
boolean *bool_p;
|
||||
@@ -4779,7 +4779,7 @@ boolean setinitial, setfromfile;
|
||||
iflags.menu_headings = mhattr;
|
||||
} else if (!strcmp("msgtype", optname)) {
|
||||
int opt_idx, nmt, mttyp;
|
||||
char mtbuf[BUFSZ];
|
||||
char mtbuf[BUFSZ] = DUMMY;
|
||||
|
||||
msgtypes_again:
|
||||
nmt = msgtype_count();
|
||||
@@ -4841,7 +4841,7 @@ boolean setinitial, setfromfile;
|
||||
}
|
||||
} else if (!strcmp("menucolors", optname)) {
|
||||
int opt_idx, nmc, mcclr, mcattr;
|
||||
char mcbuf[BUFSZ];
|
||||
char mcbuf[BUFSZ] = DUMMY;
|
||||
|
||||
menucolors_again:
|
||||
nmc = count_menucolors();
|
||||
@@ -4912,7 +4912,7 @@ boolean setinitial, setfromfile;
|
||||
}
|
||||
} else if (!strcmp("autopickup_exception", optname)) {
|
||||
int opt_idx, pass, totalapes = 0, numapes[2] = { 0, 0 };
|
||||
char apebuf[1 + BUFSZ]; /* so &apebuf[1] is BUFSZ long for getlin() */
|
||||
char apebuf[1 + BUFSZ] = DUMMY; /* so &apebuf[1] is BUFSZ long for getlin() */
|
||||
struct autopickup_exception *ape;
|
||||
|
||||
ape_again:
|
||||
|
||||
@@ -1033,7 +1033,7 @@ coord *click_cc;
|
||||
{
|
||||
boolean quick = (mode == 1); /* use cursor; don't search for "more info" */
|
||||
boolean clicklook = (mode == 2); /* right mouse-click method */
|
||||
char out_str[BUFSZ];
|
||||
char out_str[BUFSZ] = DUMMY;
|
||||
const char *firstmatch = 0;
|
||||
struct permonst *pm = 0;
|
||||
int i = '\0', ans = 0;
|
||||
|
||||
@@ -149,7 +149,7 @@ struct obj *objs;
|
||||
boolean here;
|
||||
int *menu_on_demand;
|
||||
{
|
||||
char ilets[36], inbuf[BUFSZ]; /* FIXME: hardcoded ilets[] length */
|
||||
char ilets[36], inbuf[BUFSZ] = DUMMY; /* FIXME: hardcoded ilets[] length */
|
||||
int iletct, oclassct;
|
||||
boolean not_everything, filtered;
|
||||
char qbuf[QBUFSZ];
|
||||
|
||||
@@ -384,7 +384,7 @@ void
|
||||
polyself(psflags)
|
||||
int psflags;
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
int old_light, new_light, mntmp, class, tryct;
|
||||
boolean forcecontrol = (psflags == 1), monsterpoly = (psflags == 2),
|
||||
draconian = (uarm && Is_dragon_armor(uarm)),
|
||||
|
||||
@@ -2017,7 +2017,7 @@ STATIC_OVL void
|
||||
do_class_genocide()
|
||||
{
|
||||
int i, j, immunecnt, gonecnt, goodcnt, class, feel_dead = 0;
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
boolean gameover = FALSE; /* true iff killed self */
|
||||
|
||||
for (j = 0;; j++) {
|
||||
@@ -2169,7 +2169,7 @@ int how;
|
||||
/* 3 = forced genocide of player */
|
||||
/* 5 (4 | 1) = normal genocide from throne */
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
register int i, killplayer = 0;
|
||||
register int mndx;
|
||||
register struct permonst *ptr;
|
||||
@@ -2425,7 +2425,7 @@ struct obj *from_obj;
|
||||
boolean
|
||||
create_particular()
|
||||
{
|
||||
char buf[BUFSZ], *bufp, monclass;
|
||||
char buf[BUFSZ] = DUMMY, *bufp, monclass;
|
||||
char *tmpp;
|
||||
int which, tryct, i, firstchoice = NON_PM;
|
||||
struct permonst *whichpm = NULL;
|
||||
|
||||
@@ -595,7 +595,7 @@ level_tele()
|
||||
register int newlev;
|
||||
d_level newlevel;
|
||||
const char *escape_by_flying = 0; /* when surviving dest of -N */
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
boolean force_dest = FALSE;
|
||||
|
||||
if ((u.uhave.amulet || In_endgame(&u.uz) || In_sokoban(&u.uz))
|
||||
|
||||
@@ -230,7 +230,7 @@ invault()
|
||||
guard = findgd();
|
||||
if (++u.uinvault % VAULT_GUARD_TIME == 0 && !guard) {
|
||||
/* if time ok and no guard now. */
|
||||
char buf[BUFSZ];
|
||||
char buf[BUFSZ] = DUMMY;
|
||||
register int x, y, dd, gx, gy;
|
||||
int lx = 0, ly = 0;
|
||||
long umoney;
|
||||
|
||||
@@ -95,7 +95,7 @@ dowrite(pen)
|
||||
register struct obj *pen;
|
||||
{
|
||||
register struct obj *paper;
|
||||
char namebuf[BUFSZ], *nm, *bp;
|
||||
char namebuf[BUFSZ] = DUMMY, *nm, *bp;
|
||||
register struct obj *new_obj;
|
||||
int basecost, actualcost;
|
||||
int curseval;
|
||||
|
||||
@@ -5050,7 +5050,8 @@ int triesleft;
|
||||
void
|
||||
makewish()
|
||||
{
|
||||
char buf[BUFSZ], promptbuf[BUFSZ];
|
||||
static char buf[BUFSZ] = DUMMY;
|
||||
char promptbuf[BUFSZ];
|
||||
struct obj *otmp, nothing;
|
||||
int tries = 0;
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ bool NetHackQtStringRequestor::Get(char* buffer, int maxchar)
|
||||
resize(fontMetrics().width(prompt.text())*2+50,fontMetrics().height()*4);
|
||||
}
|
||||
|
||||
#ifdef EDIT_GETLIN
|
||||
input.setText(buffer);
|
||||
#endif
|
||||
centerOnMain(this);
|
||||
show();
|
||||
input.setFocus();
|
||||
|
||||
@@ -1623,7 +1623,11 @@ char *input;
|
||||
slide left hiding some chars at the beginning of the response but
|
||||
making room to type more. [Prior to 3.6.1, width wasn't specifiable
|
||||
and answer box always got sized to match the width of the prompt.] */
|
||||
#ifdef EDIT_GETLIN
|
||||
SetDialogResponse(getline_dialog, input, 60); /* set default answer */
|
||||
#else
|
||||
SetDialogResponse(getline_dialog, nhStr(""), 60); /* set default answer */
|
||||
#endif
|
||||
positionpopup(getline_popup, TRUE); /* center,bottom */
|
||||
|
||||
nh_XtPopup(getline_popup, (int) XtGrabExclusive, getline_dialog);
|
||||
|
||||
@@ -56,8 +56,13 @@ getlin_hook_proc hook;
|
||||
cw->flags &= ~WIN_STOP;
|
||||
ttyDisplay->toplin = 3; /* special prompt state */
|
||||
ttyDisplay->inread++;
|
||||
#ifdef EDIT_GETLIN
|
||||
custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s %s", query, bufp);
|
||||
bufp = eos(obufp);
|
||||
#else
|
||||
custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query);
|
||||
*obufp = 0;
|
||||
#endif
|
||||
for (;;) {
|
||||
(void) fflush(stdout);
|
||||
Strcat(strcat(strcpy(toplines, query), " "), obufp);
|
||||
|
||||
Reference in New Issue
Block a user