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 display effect. on MSDOS without the termcap
lib, whether or not to pause for visual effect. [TRUE] 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): 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 preload_tiles control whether tiles get pre-loaded into RAM at the
start of the game. Doing so enhances performance start of the game. Doing so enhances performance
@@ -204,6 +201,12 @@ traps like dungeon, but for trap symbols
default: ^^^^^^^^^^^^^^^^^"^^^^ default: ^^^^^^^^^^^^^^^^^"^^^^
windowtype windowing system to be used [depends on operating system] 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: Some sample options lists are:
!autopickup,!tombstone,name:Gandalf,scores:own/3 top/2 around !autopickup,!tombstone,name:Gandalf,scores:own/3 top/2 around

View File

@@ -5,7 +5,7 @@
.ds vr "NetHack 3.4 .ds vr "NetHack 3.4
.ds f0 "\*(vr .ds f0 "\*(vr
.ds f1 .ds f1
.ds f2 "April 3, 2002 .ds f2 "April 20, 2002
.mt .mt
A Guide to the Mazes of Menace A Guide to the Mazes of Menace
(Guidebook for NetHack) (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). The number of top line messages to save (and recall with ^P) (default 20).
Cannot be set with the `O' command. Cannot be set with the `O' command.
.lp msg_window .lp msg_window
Use a screen-size window to show the previous messages with ^P instead of Allows you to change the way recalled messages are displayed.
showing them one at a time. (Currently implemented for tty only.) (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 " .lp "name "
Set your character's name (defaults to your user name). You can also 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 set your character's role by appending a dash and one or more letters of

View File

@@ -27,7 +27,7 @@
\begin{document} \begin{document}
% %
% input file: guidebook.mn % 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 h0 "
%.ds h1 %.ds h2 \% %.ds h1 %.ds h2 \%
@@ -40,7 +40,7 @@
%.au %.au
\author{Eric S. Raymond\\ \author{Eric S. Raymond\\
(Extensively edited and expanded for 3.4)} (Extensively edited and expanded for 3.4)}
\date{April 3, 2002} \date{April 20, 2002}
\maketitle \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. (default 20). Cannot be set with the `{\tt O}' command.
%.lp %.lp
\item[\ib{msg\_window}] \item[\ib{msg\_window}]
Use a screen-size window to show the previous messages with `{\tt \^{}P}' Allows you to change the way recalled messages are displayed.
instead of showing them one at a time. (Currently implemented for tty only.) (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 %.lp
\item[\ib{name}] \item[\ib{name}]
Set your character's name (defaults to your user name). You can also 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 */ boolean mon_polycontrol; /* debug: control monster polymorphs */
#endif #endif
#ifdef TTY_GRAPHICS #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 */ boolean extmenu; /* extended commands use menu interface */
#endif #endif
#ifdef MFLOPPY #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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -40,11 +40,16 @@
/*****************************************************************************/ /*****************************************************************************/
/* Version 3.4.x */ /* Version 3.4.x */
/* Patch 1, March 31, 2002 /* Patch 1, May 1, 2002
* Fix a fatal error involving land mines and boulders/statues * 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 * Several message and other glitches corrected
* Travel command adjustments and ability to disable travel command
* win32: some interface improvements * win32: some interface improvements
* unix: improved tile support * 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}, {"menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_GAME},
#else #else
{"menu_tab_sep", (boolean *)0, FALSE, SET_IN_FILE}, {"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 #endif
{"mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME}, /*WC*/ {"mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME}, /*WC*/
#ifdef NEWS #ifdef NEWS
@@ -258,6 +253,11 @@ static struct Comp_Opt
MAXMCLASSES, SET_IN_FILE }, MAXMCLASSES, SET_IN_FILE },
{ "msghistory", "number of top line messages to save", { "msghistory", "number of top line messages to save",
5, DISP_IN_GAME }, 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)", { "name", "your character's name (e.g., name:Merlin-W)",
PL_NSIZ, DISP_IN_GAME }, PL_NSIZ, DISP_IN_GAME },
{ "objects", "the symbols to use for objects", { "objects", "the symbols to use for objects",
@@ -476,6 +476,7 @@ initoptions()
flags.end_top = 3; flags.end_top = 3;
flags.end_around = 2; flags.end_around = 2;
iflags.msg_history = 20; iflags.msg_history = 20;
iflags.prevmsg_window = 's';
/* Use negative indices to indicate not yet selected */ /* Use negative indices to indicate not yet selected */
flags.initrole = -1; flags.initrole = -1;
@@ -1056,6 +1057,40 @@ boolean tinitial, tfrom_file;
return; 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 /* WINCAP
* setting font options */ * setting font options */
fullname = "font"; fullname = "font";
@@ -2331,7 +2366,8 @@ boolean setinitial,setfromfile;
char buf[BUFSZ]; char buf[BUFSZ];
boolean retval = FALSE; 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)) { if (!strcmp("menustyle", optname)) {
const char *style_name; const char *style_name;
menu_item *style_pick = (menu_item *)0; menu_item *style_pick = (menu_item *)0;
@@ -2438,6 +2474,30 @@ boolean setinitial,setfromfile;
} }
} }
retval = TRUE; 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; return retval;
} }
@@ -2575,6 +2635,10 @@ char *buf;
Sprintf(buf, "%s", to_be_done); Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "msghistory")) else if (!strcmp(optname, "msghistory"))
Sprintf(buf, "%u", iflags.msg_history); 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")) else if (!strcmp(optname, "name"))
Sprintf(buf, "%s", plname); Sprintf(buf, "%s", plname);
else if (!strcmp(optname, "objects")) else if (!strcmp(optname, "objects"))

View File

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

View File

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