Message recall window extensions

by <Someone>

(the following text accompanies the patch at <Someone>'s web page)

add more configurability to the new msg_window option of [..]3.4.0.
It allows the configuration option to take an optional parameter to
specify the style of message history display to use.

allows the following configuration options:

msg_window:s - single message (as was the default in 3.3.0)
msg_window:c - combination; two messages in 'single', then as 'full'
msg_window:f - full window; oldest message first
msg_window:r - full window reversed; newest message first

In the event of no parameter being provided,
the patch is compatible with the current 3.4.0 behaviour:
msg_window = 'full'
!msg_window = 'single'
msg_window can be configured for these options in the
Options menu (Shift-O)
msg_window stores the current window type in the non-persistent
iflags structure, which means that savefile/bones files should be
100% compatible with Vanilla, but at the disadvantage that your
customisations to msg_window will be replaced with your
defaults.nh (or ~/.nethackrc) value every time you restart a saved game.
Credits:

The patch draws inspiration (and code snippets) extensively
from <Someone>'s original msg_window patch, [...] as well as <Someone>'s code for reverse ordering implemented until recently in
Slash'em.
This commit is contained in:
nethack.allison
2002-04-20 14:16:23 +00:00
parent 8bcec06645
commit 5d3448fc16
8 changed files with 204 additions and 51 deletions

View File

@@ -74,9 +74,6 @@ timed_delay on unix and VMS, use a timer instead of sending
display effect. on MSDOS without the termcap
lib, whether or not to pause for visual effect. [TRUE]
Boolean option if TTY_GRAPHICS was set at compile time:
msg_window show previous messages in a screen-size window [FALSE]
Boolean option if USE_TILES was set at compile time (MSDOS protected mode only):
preload_tiles control whether tiles get pre-loaded into RAM at the
start of the game. Doing so enhances performance
@@ -204,6 +201,12 @@ traps like dungeon, but for trap symbols
default: ^^^^^^^^^^^^^^^^^"^^^^
windowtype windowing system to be used [depends on operating system]
Compound option if TTY_GRAPHICS was set at compile time:
msg_window the type of message window to use:
Single -- One message at a time
Full -- Full window with all saved top line messages
Reverse -- Same as full, but messages printed most-recent-first
Combination -- Two single messages, then as full
Some sample options lists are:
!autopickup,!tombstone,name:Gandalf,scores:own/3 top/2 around

View File

@@ -5,7 +5,7 @@
.ds vr "NetHack 3.4
.ds f0 "\*(vr
.ds f1
.ds f2 "April 3, 2002
.ds f2 "April 20, 2002
.mt
A Guide to the Mazes of Menace
(Guidebook for NetHack)
@@ -1906,8 +1906,19 @@ Cannot be set with the `O' command.
The number of top line messages to save (and recall with ^P) (default 20).
Cannot be set with the `O' command.
.lp msg_window
Use a screen-size window to show the previous messages with ^P instead of
showing them one at a time. (Currently implemented for tty only.)
Allows you to change the way recalled messages are displayed.
(It is currently implemented for tty only.)
The possible values are:
.sd
.si
s - single message (the default prior to 3.4.0).
c - combination, two messages as `single', then as `full'.
f - full window, oldest message first.
r - full window, newest message first.
.ei
.ed
For backward compatibility, no value needs to be specified (which
defaults to `full'), or it can be negated (which defaults to `single').
.lp "name "
Set your character's name (defaults to your user name). You can also
set your character's role by appending a dash and one or more letters of

View File

@@ -27,7 +27,7 @@
\begin{document}
%
% input file: guidebook.mn
% $Revision: 1.40 $ $Date: 2002/04/04 03:44:18 $
% $Revision: 1.41 $ $Date: 2002/04/13 16:00:06 $
%
%.ds h0 "
%.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
%.au
\author{Eric S. Raymond\\
(Extensively edited and expanded for 3.4)}
\date{April 3, 2002}
\date{April 20, 2002}
\maketitle
@@ -2342,8 +2342,21 @@ The number of top line messages to save (and recall with `{\tt \^{}P}')
(default 20). Cannot be set with the `{\tt O}' command.
%.lp
\item[\ib{msg\_window}]
Use a screen-size window to show the previous messages with `{\tt \^{}P}'
instead of showing them one at a time. (Currently implemented for tty only.)
Allows you to change the way recalled messages are displayed.
(It is currently implemented for tty only.) The possible values are:
%.sd
%.si
{\tt s} --- single message (the default prior to 3.4.0).\\
{\tt c} --- combination, two messages as {\it single\/}, then as {\it full\/}.\\
{\tt f} --- full window, oldest message first.\\
{\tt r} --- full window, newest message first.
%.ei
%.ed
For backward compatibility, no value needs to be specified (which
defaults to {\it full\/}), or it can be negated (which defaults
to {\it single\/}).
%.lp
\item[\ib{name}]
Set your character's name (defaults to your user name). You can also

View File

@@ -174,7 +174,7 @@ struct instance_flags {
boolean mon_polycontrol; /* debug: control monster polymorphs */
#endif
#ifdef TTY_GRAPHICS
boolean prevmsg_window; /* show more old messages at a time */
char prevmsg_window; /* type of old message window to use */
boolean extmenu; /* extended commands use menu interface */
#endif
#ifdef MFLOPPY

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)patchlevel.h 3.4 2002/03/29 */
/* SCCS Id: @(#)patchlevel.h 3.4 2002/04/20 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -40,11 +40,16 @@
/*****************************************************************************/
/* Version 3.4.x */
/* Patch 1, March 31, 2002
* Fix a fatal error involving land mines and boulders/statues
* Several message and other glitches corrected
/* Patch 1, May 1, 2002
* Fix a couple of fatal errors including one for reentering shops, one
* involving land mines and boulders/statues, and one for delayed
* polymorph
* Dozens of general bug fixes
* Several message and other glitches corrected
* Travel command adjustments and ability to disable travel command
* win32: some interface improvements
* unix: improved tile support
* message recall window extensions (by Christian Cooper)
*/
/*

View File

@@ -122,11 +122,6 @@ static struct Bool_Opt
{"menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_GAME},
#else
{"menu_tab_sep", (boolean *)0, FALSE, SET_IN_FILE},
#endif
#ifdef TTY_GRAPHICS
{"msg_window", &iflags.prevmsg_window, FALSE, SET_IN_GAME},
#else
{"msg_window", (boolean *)0, FALSE, SET_IN_FILE},
#endif
{"mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME}, /*WC*/
#ifdef NEWS
@@ -258,6 +253,11 @@ static struct Comp_Opt
MAXMCLASSES, SET_IN_FILE },
{ "msghistory", "number of top line messages to save",
5, DISP_IN_GAME },
# ifdef TTY_GRAPHICS
{"msg_window", "the type of message window required",1, SET_IN_GAME},
# else
{"msg_window", "the type of message window required", 1, SET_IN_FILE},
# endif
{ "name", "your character's name (e.g., name:Merlin-W)",
PL_NSIZ, DISP_IN_GAME },
{ "objects", "the symbols to use for objects",
@@ -476,6 +476,7 @@ initoptions()
flags.end_top = 3;
flags.end_around = 2;
iflags.msg_history = 20;
iflags.prevmsg_window = 's';
/* Use negative indices to indicate not yet selected */
flags.initrole = -1;
@@ -1056,6 +1057,40 @@ boolean tinitial, tfrom_file;
return;
}
#ifdef TTY_GRAPHICS
fullname="msg_window";
/* msg_window:single, combo, full or reversed */
if (match_optname(opts, fullname, 4, TRUE)) {
int tmp;
if (!(op = string_for_opt(opts, TRUE))) {
tmp = negated ? 's' : 'f';
} else {
if (negated) {
bad_negation(fullname, TRUE);
return;
}
tmp = tolower(*op);
}
switch (tmp) {
case 's': /* single message history cycle (default if negated) */
iflags.prevmsg_window = 's';
break;
case 'c': /* combination: two singles, then full page reversed */
iflags.prevmsg_window = 'c';
break;
case 'f': /* full page (default if no opts) */
iflags.prevmsg_window = 'f';
break;
case 'r': /* full page (reversed) */
iflags.prevmsg_window = 'r';
break;
default:
badoption(opts);
}
return;
}
#endif
/* WINCAP
* setting font options */
fullname = "font";
@@ -2331,7 +2366,8 @@ boolean setinitial,setfromfile;
char buf[BUFSZ];
boolean retval = FALSE;
/* Special handling of menustyle, pickup_burden, and pickup_types, disclose options. */
/* Special handling of menustyle, pickup_burden, and pickup_types, disclose
and msg_window options. */
if (!strcmp("menustyle", optname)) {
const char *style_name;
menu_item *style_pick = (menu_item *)0;
@@ -2438,6 +2474,30 @@ boolean setinitial,setfromfile;
}
}
retval = TRUE;
} else if (!strcmp("msg_window", optname)) {
/* by Christian W. Cooper */
menu_item *window_pick = (menu_item *)0;
tmpwin = create_nhwindow(NHW_MENU);
start_menu(tmpwin);
any.a_char = 's';
add_menu(tmpwin, NO_GLYPH, &any, 's', 0,
ATR_NONE, "single", MENU_UNSELECTED);
any.a_char = 'c';
add_menu(tmpwin, NO_GLYPH, &any, 'c', 0,
ATR_NONE, "combination", MENU_UNSELECTED);
any.a_char = 'f';
add_menu(tmpwin, NO_GLYPH, &any, 'f', 0,
ATR_NONE, "full", MENU_UNSELECTED);
any.a_char = 'r';
add_menu(tmpwin, NO_GLYPH, &any, 'r', 0,
ATR_NONE, "reversed", MENU_UNSELECTED);
end_menu(tmpwin, "Select message history display type:");
if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {
iflags.prevmsg_window = window_pick->item.a_char;
free((genericptr_t)window_pick);
}
destroy_nhwindow(tmpwin);
retval = TRUE;
}
return retval;
}
@@ -2575,6 +2635,10 @@ char *buf;
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "msghistory"))
Sprintf(buf, "%u", iflags.msg_history);
else if (!strcmp(optname, "msg_window"))
Sprintf(buf, "%s", (iflags.prevmsg_window=='s') ? "single" :
(iflags.prevmsg_window=='c') ? "combination" :
(iflags.prevmsg_window=='f') ? "full" : "reversed");
else if (!strcmp(optname, "name"))
Sprintf(buf, "%s", plname);
else if (!strcmp(optname, "objects"))

View File

@@ -72,7 +72,7 @@ getlin_hook_proc hook;
*bufp = 0;
}
if(c == '\020') { /* ctrl-P */
if (iflags.prevmsg_window) {
if (iflags.prevmsg_window != 's') {
int sav = ttyDisplay->inread;
ttyDisplay->inread = 0;
(void) tty_doprev_message();
@@ -90,7 +90,7 @@ getlin_hook_proc hook;
doprev = 1;
continue;
}
} else if (doprev && !iflags.prevmsg_window) {
} else if (doprev && iflags.prevmsg_window == 's') {
tty_clear_nhwindow(WIN_MESSAGE);
cw->maxcol = cw->maxrow;
doprev = 0;

View File

@@ -28,34 +28,91 @@ tty_doprev_message()
winid prevmsg_win;
int i;
if ((iflags.prevmsg_window != 's') && !ttyDisplay->inread) { /* not single */
if(iflags.prevmsg_window == 'f') { /* full */
prevmsg_win = create_nhwindow(NHW_MENU);
putstr(prevmsg_win, 0, "Message History");
putstr(prevmsg_win, 0, "");
cw->maxcol = cw->maxrow;
i = cw->maxcol;
do {
if(cw->data[i] && strcmp(cw->data[i], "") )
putstr(prevmsg_win, 0, cw->data[i]);
i = (i + 1) % cw->rows;
} while (i != cw->maxcol);
putstr(prevmsg_win, 0, toplines);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
} else if (iflags.prevmsg_window == 'c') { /* combination */
do {
morc = 0;
if (cw->maxcol == cw->maxrow) {
ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */
redotoplin(toplines);
cw->maxcol--;
if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
if (!cw->data[cw->maxcol])
cw->maxcol = cw->maxrow;
} else if (cw->maxcol == (cw->maxrow - 1)){
ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */
redotoplin(cw->data[cw->maxcol]);
cw->maxcol--;
if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
if (!cw->data[cw->maxcol])
cw->maxcol = cw->maxrow;
} else {
prevmsg_win = create_nhwindow(NHW_MENU);
putstr(prevmsg_win, 0, "Message History");
putstr(prevmsg_win, 0, "");
cw->maxcol = cw->maxrow;
i = cw->maxcol;
do {
if(cw->data[i] && strcmp(cw->data[i], "") )
putstr(prevmsg_win, 0, cw->data[i]);
i = (i + 1) % cw->rows;
} while (i != cw->maxcol);
putstr(prevmsg_win, 0, toplines);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
}
if (iflags.prevmsg_window && !ttyDisplay->inread) {
prevmsg_win = create_nhwindow(NHW_MENU);
putstr(prevmsg_win, 0, "Message History");
putstr(prevmsg_win, 0, "");
i = cw->maxcol;
do {
if(cw->data[i] && strcmp(cw->data[i], "") )
putstr(prevmsg_win, 0, cw->data[i]);
i = (i + 1) % cw->rows;
} while (i != cw->maxcol);
putstr(prevmsg_win, 0, toplines);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
} else {
ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */
do {
morc = 0;
if (cw->maxcol == cw->maxrow)
redotoplin(toplines);
else if (cw->data[cw->maxcol])
redotoplin(cw->data[cw->maxcol]);
cw->maxcol--;
if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
if (!cw->data[cw->maxcol])
cw->maxcol = cw->maxrow;
} while (morc == C('p'));
ttyDisplay->dismiss_more = 0;
} while (morc == C('p'));
ttyDisplay->dismiss_more = 0;
} else { /* reversed */
morc = 0;
prevmsg_win = create_nhwindow(NHW_MENU);
putstr(prevmsg_win, 0, "Message History");
putstr(prevmsg_win, 0, "");
putstr(prevmsg_win, 0, toplines);
cw->maxcol=cw->maxrow-1;
if(cw->maxcol < 0) cw->maxcol = cw->rows-1;
do {
putstr(prevmsg_win, 0, cw->data[cw->maxcol]);
cw->maxcol--;
if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
if (!cw->data[cw->maxcol])
cw->maxcol = cw->maxrow;
} while (cw->maxcol != cw->maxrow);
display_nhwindow(prevmsg_win, TRUE);
destroy_nhwindow(prevmsg_win);
cw->maxcol = cw->maxrow;
ttyDisplay->dismiss_more = 0;
}
} else if(iflags.prevmsg_window == 's') { /* single */
ttyDisplay->dismiss_more = C('p'); /* <ctrl/P> allowed at --More-- */
do {
morc = 0;
if (cw->maxcol == cw->maxrow)
redotoplin(toplines);
else if (cw->data[cw->maxcol])
redotoplin(cw->data[cw->maxcol]);
cw->maxcol--;
if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
if (!cw->data[cw->maxcol])
cw->maxcol = cw->maxrow;
} while (morc == C('p'));
ttyDisplay->dismiss_more = 0;
}
return 0;
}
@@ -298,7 +355,7 @@ char def;
do { /* loop until we get valid input */
q = lowc(readchar());
if (q == '\020') { /* ctrl-P */
if (iflags.prevmsg_window) {
if (iflags.prevmsg_window != 's') {
int sav = ttyDisplay->inread;
ttyDisplay->inread = 0;
(void) tty_doprev_message();