WINCHAIN - a framework allowing multiple processors between core and winport
This is the code I built trying to figure out the large window size issue. It completely compiles out if not needed (see -DWINCHAIN in hints/macos10.7) and except for one call during setup has zero overhead if compiled in and not used. See window.doc for more info. Defs for UNUSED parms. I know this has been controversial, so use is isolated to the chain code and windows.c (where it shouldn't be intrusive and saves about 50 warnings). Hints file for 10.7, but the build process still needs to be migrated from the branch.
This commit is contained in:
598
win/chain/wc_chainin.c
Normal file
598
win/chain/wc_chainin.c
Normal file
@@ -0,0 +1,598 @@
|
||||
/* NetHack 3.5 wc_chainin.c $Date$ $Revision$ */
|
||||
/* Copyright (c) Kenneth Lorber, 2012 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* -chainin is an internal processor that changes the flow from window_procs
|
||||
* to chain_procs. */
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
struct chainin_data {
|
||||
struct chain_procs *nprocs;
|
||||
void *ndata;
|
||||
|
||||
int linknum;
|
||||
};
|
||||
|
||||
/* Normally, a processor gets this information from the first parm of each
|
||||
* call, but here we are keeping the original API, so that parm doesn't exist,
|
||||
* so we use this instead. */
|
||||
static struct chainin_data *cibase;
|
||||
|
||||
void *
|
||||
chainin_procs_chain(cmd, n, me, nextprocs, nextdata)
|
||||
int cmd;
|
||||
int n;
|
||||
void *me;
|
||||
void *nextprocs;
|
||||
void *nextdata;
|
||||
{
|
||||
switch(cmd){
|
||||
case WINCHAIN_ALLOC: {
|
||||
struct chainin_data *tdp = calloc(1, sizeof(struct chainin_data));
|
||||
tdp->linknum = n;
|
||||
cibase = tdp;
|
||||
return tdp;
|
||||
}
|
||||
case WINCHAIN_INIT: {
|
||||
struct chainin_data *tdp = me;
|
||||
tdp->nprocs = nextprocs;
|
||||
tdp->ndata = nextdata;
|
||||
return tdp;
|
||||
}
|
||||
default:
|
||||
raw_printf("chainin_procs_chain: bad cmd\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX if we don't need this, take it out of the table */
|
||||
void
|
||||
chainin_procs_init(dir)
|
||||
int dir UNUSED;
|
||||
{
|
||||
}
|
||||
|
||||
/***
|
||||
*** winprocs
|
||||
***/
|
||||
|
||||
void
|
||||
chainin_init_nhwindows(argcp, argv)
|
||||
int *argcp;
|
||||
char **argv;
|
||||
{
|
||||
(*cibase->nprocs->win_init_nhwindows)(cibase->ndata, argcp, argv);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chainin_player_selection()
|
||||
{
|
||||
(*cibase->nprocs->win_player_selection)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_askname()
|
||||
{
|
||||
(*cibase->nprocs->win_askname)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_get_nh_event()
|
||||
{
|
||||
(*cibase->nprocs->win_get_nh_event)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_exit_nhwindows(str)
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_exit_nhwindows)(cibase->ndata, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_suspend_nhwindows(str)
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_suspend_nhwindows)(cibase->ndata, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_resume_nhwindows()
|
||||
{
|
||||
(*cibase->nprocs->win_resume_nhwindows)(cibase->ndata);
|
||||
}
|
||||
|
||||
winid
|
||||
chainin_create_nhwindow(type)
|
||||
int type;
|
||||
{
|
||||
winid rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_create_nhwindow)(cibase->ndata, type);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainin_clear_nhwindow(window)
|
||||
winid window;
|
||||
{
|
||||
(*cibase->nprocs->win_clear_nhwindow)(cibase->ndata, window);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_display_nhwindow(window, blocking)
|
||||
winid window;
|
||||
BOOLEAN_P blocking;
|
||||
{
|
||||
(*cibase->nprocs->win_display_nhwindow)(cibase->ndata, window, blocking);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_destroy_nhwindow(window)
|
||||
winid window;
|
||||
{
|
||||
(*cibase->nprocs->win_destroy_nhwindow)(cibase->ndata, window);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_curs(window, x, y)
|
||||
winid window;
|
||||
int x;
|
||||
int y;
|
||||
{
|
||||
(*cibase->nprocs->win_curs)(cibase->ndata, window, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_putstr(window, attr, str)
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_putstr)(cibase->ndata, window, attr, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_putmixed(window, attr, str)
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_putmixed)(cibase->ndata, window, attr, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_display_file(fname, complain)
|
||||
const char *fname;
|
||||
boolean complain;
|
||||
{
|
||||
(*cibase->nprocs->win_display_file)(cibase->ndata, fname, complain);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_start_menu(window)
|
||||
winid window;
|
||||
{
|
||||
(*cibase->nprocs->win_start_menu)(cibase->ndata, window);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_add_menu(window, glyph, identifier, ch, gch, attr, str, preselected)
|
||||
winid window; /* window to use, must be of type NHW_MENU */
|
||||
int glyph; /* glyph to display with item (unused) */
|
||||
const anything *identifier; /* what to return if selected */
|
||||
char ch; /* keyboard accelerator (0 = pick our own) */
|
||||
char gch; /* group accelerator (0 = no group) */
|
||||
int attr; /* attribute for string (like tty_putstr()) */
|
||||
const char *str; /* menu string */
|
||||
boolean preselected; /* item is marked as selected */
|
||||
{
|
||||
(*cibase->nprocs->win_add_menu)(cibase->ndata, window, glyph, identifier,
|
||||
ch, gch, attr, str, preselected);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_end_menu(window, prompt)
|
||||
winid window;
|
||||
const char *prompt;
|
||||
{
|
||||
(*cibase->nprocs->win_end_menu)(cibase->ndata, window, prompt);
|
||||
}
|
||||
|
||||
int
|
||||
chainin_select_menu(window, how, menu_list)
|
||||
winid window;
|
||||
int how;
|
||||
menu_item **menu_list;
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_select_menu)(cibase->ndata, window, how,
|
||||
(void *)menu_list);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
char
|
||||
chainin_message_menu(let, how, mesg)
|
||||
char let;
|
||||
int how;
|
||||
const char *mesg;
|
||||
{
|
||||
char rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_message_menu)(cibase->ndata, let, how, mesg);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainin_update_inventory()
|
||||
{
|
||||
(*cibase->nprocs->win_update_inventory)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_mark_synch()
|
||||
{
|
||||
(*cibase->nprocs->win_mark_synch)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_wait_synch()
|
||||
{
|
||||
(*cibase->nprocs->win_wait_synch)(cibase->ndata);
|
||||
}
|
||||
|
||||
#ifdef CLIPPING
|
||||
void
|
||||
chainin_cliparound(x, y)
|
||||
int x;
|
||||
int y;
|
||||
{
|
||||
(*cibase->nprocs->win_cliparound)(cibase->ndata, x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef POSITIONBAR
|
||||
void
|
||||
chainin_update_positionbar(posbar)
|
||||
char *posbar;
|
||||
{
|
||||
(*cibase->nprocs->win_update_positionbar)(cibase->ndata, posbar);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* XXX can we decode the glyph in a meaningful way? */
|
||||
void
|
||||
chainin_print_glyph(window, x, y, glyph)
|
||||
winid window;
|
||||
xchar x, y;
|
||||
int glyph;
|
||||
{
|
||||
(*cibase->nprocs->win_print_glyph)(cibase->ndata, window, x, y, glyph);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_raw_print(str)
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_raw_print)(cibase->ndata, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_raw_print_bold(str)
|
||||
const char *str;
|
||||
{
|
||||
(*cibase->nprocs->win_raw_print_bold)(cibase->ndata, str);
|
||||
}
|
||||
|
||||
int
|
||||
chainin_nhgetch()
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_nhgetch)(cibase->ndata);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
chainin_nh_poskey(x, y, mod)
|
||||
int *x;
|
||||
int *y;
|
||||
int *mod;
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_nh_poskey)(cibase->ndata, x, y, mod);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainin_nhbell()
|
||||
{
|
||||
(*cibase->nprocs->win_nhbell)(cibase->ndata);
|
||||
}
|
||||
|
||||
int
|
||||
chainin_doprev_message()
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_doprev_message)(cibase->ndata);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
char
|
||||
chainin_yn_function(query, resp, def)
|
||||
const char *query, *resp;
|
||||
char def;
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_yn_function)(cibase->ndata, query, resp, def);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chainin_getlin(query, bufp)
|
||||
const char *query;
|
||||
char *bufp;
|
||||
{
|
||||
(*cibase->nprocs->win_getlin)(cibase->ndata, query, bufp);
|
||||
}
|
||||
|
||||
int
|
||||
chainin_get_ext_cmd()
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_get_ext_cmd)(cibase->ndata);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainin_number_pad(state)
|
||||
int state;
|
||||
{
|
||||
(*cibase->nprocs->win_number_pad)(cibase->ndata, state);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_delay_output()
|
||||
{
|
||||
(*cibase->nprocs->win_delay_output)(cibase->ndata);
|
||||
}
|
||||
|
||||
#ifdef CHANGE_COLOR
|
||||
void
|
||||
chainin_change_color(color, value, reverse)
|
||||
int color;
|
||||
long value;
|
||||
int reverse;
|
||||
{
|
||||
(*cibase->nprocs->win_change_color)(cibase->ndata, color, value, reverse);
|
||||
}
|
||||
|
||||
#ifdef MAC
|
||||
void
|
||||
chainin_change_background(bw)
|
||||
int bw;
|
||||
{
|
||||
(*cibase->nprocs->win_change_background)(cibase->ndata, bw);
|
||||
}
|
||||
|
||||
short
|
||||
chainin_set_font_name(window, font)
|
||||
winid window;
|
||||
char *font;
|
||||
{
|
||||
short rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_set_font_name)(cibase->ndata, window, font);
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *trace_get_color_string()
|
||||
{
|
||||
char *rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_get_color_string)(cibase->ndata);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* other defs that really should go away (they're tty specific) */
|
||||
void
|
||||
chainin_start_screen()
|
||||
{
|
||||
(*cibase->nprocs->win_start_screen)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_end_screen()
|
||||
{
|
||||
(*cibase->nprocs->win_end_screen)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_outrip(tmpwin, how)
|
||||
winid tmpwin;
|
||||
int how;
|
||||
{
|
||||
(*cibase->nprocs->win_outrip)(cibase->ndata, tmpwin, how);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_preference_update(pref)
|
||||
const char *pref;
|
||||
{
|
||||
(*cibase->nprocs->win_preference_update)(cibase->ndata, pref);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
chainin_getmsghistory(init)
|
||||
boolean init;
|
||||
{
|
||||
char *rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_getmsghistory)(cibase->ndata,init);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainin_putmsghistory(msg, is_restoring)
|
||||
const char *msg;
|
||||
boolean is_restoring;
|
||||
{
|
||||
(*cibase->nprocs->win_putmsghistory)(cibase->ndata, msg, is_restoring);
|
||||
}
|
||||
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
void
|
||||
chainin_status_init()
|
||||
{
|
||||
(*cibase->nprocs->win_status_init)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_status_finish()
|
||||
{
|
||||
(*cibase->nprocs->win_status_finish)(cibase->ndata);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_status_enablefield(fieldidx, nm, fmt, enable)
|
||||
int fieldidx;
|
||||
const char *nm;
|
||||
const char *fmt;
|
||||
boolean enable;
|
||||
{
|
||||
(*cibase->nprocs->win_status_enablefield)(cibase->ndata, fieldidx, nm,
|
||||
fmt, enable);
|
||||
}
|
||||
|
||||
void
|
||||
chainin_status_update(idx, ptr, chg, percent)
|
||||
int idx, chg, percent;
|
||||
genericptr_t ptr;
|
||||
{
|
||||
(*cibase->nprocs->win_status_update)(cibase->ndata, idx, ptr, chg, percent);
|
||||
}
|
||||
|
||||
# ifdef STATUS_HILITES
|
||||
void
|
||||
chainin_status_threshold(fldidx, thresholdtype, threshold, behavior, under, over)
|
||||
int fldidx,thresholdtype;
|
||||
int behavior, under, over;
|
||||
anything threshold;
|
||||
{
|
||||
(*cibase->nprocs->win_status_threshold)(cibase->ndata,fldidx, thresholdtype,
|
||||
threshold, behavior, under, over);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
boolean
|
||||
chainin_can_suspend()
|
||||
{
|
||||
boolean rv;
|
||||
|
||||
rv = (*cibase->nprocs->win_can_suspend)(cibase->ndata);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
struct window_procs chainin_procs = {
|
||||
"-chainin",
|
||||
0, /* wincap */
|
||||
0, /* wincap2 */
|
||||
/*
|
||||
XXX problem - the above need to come from the real window port, possibly
|
||||
modified. May need to do something to call an additional init fn later
|
||||
or if this is the only place like this the choose_windows fn can do the fixup
|
||||
(but not if the value can be modified by the stack?) TBD
|
||||
*/
|
||||
chainin_init_nhwindows,
|
||||
chainin_player_selection,
|
||||
chainin_askname,
|
||||
chainin_get_nh_event,
|
||||
chainin_exit_nhwindows,
|
||||
chainin_suspend_nhwindows,
|
||||
chainin_resume_nhwindows,
|
||||
chainin_create_nhwindow,
|
||||
chainin_clear_nhwindow,
|
||||
chainin_display_nhwindow,
|
||||
chainin_destroy_nhwindow,
|
||||
chainin_curs,
|
||||
chainin_putstr,
|
||||
chainin_putmixed,
|
||||
chainin_display_file,
|
||||
chainin_start_menu,
|
||||
chainin_add_menu,
|
||||
chainin_end_menu,
|
||||
chainin_select_menu,
|
||||
chainin_message_menu,
|
||||
chainin_update_inventory,
|
||||
chainin_mark_synch,
|
||||
chainin_wait_synch,
|
||||
#ifdef CLIPPING
|
||||
chainin_cliparound,
|
||||
#endif
|
||||
#ifdef POSITIONBAR
|
||||
chainin_update_positionbar,
|
||||
#endif
|
||||
chainin_print_glyph,
|
||||
chainin_raw_print,
|
||||
chainin_raw_print_bold,
|
||||
chainin_nhgetch,
|
||||
chainin_nh_poskey,
|
||||
chainin_nhbell,
|
||||
chainin_doprev_message,
|
||||
chainin_yn_function,
|
||||
chainin_getlin,
|
||||
chainin_get_ext_cmd,
|
||||
chainin_number_pad,
|
||||
chainin_delay_output,
|
||||
#ifdef CHANGE_COLOR
|
||||
chainin_change_color,
|
||||
#ifdef MAC
|
||||
chainin_change_background,
|
||||
chainin_set_font_name,
|
||||
#endif
|
||||
chainin_get_color_string,
|
||||
#endif
|
||||
|
||||
chainin_start_screen,
|
||||
chainin_end_screen,
|
||||
|
||||
chainin_outrip,
|
||||
chainin_preference_update,
|
||||
chainin_getmsghistory,
|
||||
chainin_putmsghistory,
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
chainin_status_init,
|
||||
chainin_status_finish,
|
||||
chainin_status_enablefield,
|
||||
chainin_status_update,
|
||||
# ifdef STATUS_HILITES
|
||||
chainin_status_threshold,
|
||||
# endif
|
||||
#endif
|
||||
chainin_can_suspend,
|
||||
};
|
||||
737
win/chain/wc_chainout.c
Normal file
737
win/chain/wc_chainout.c
Normal file
@@ -0,0 +1,737 @@
|
||||
/* NetHack 3.5 wc_chainout.c $Date$ $Revision$ */
|
||||
/* Copyright (c) Kenneth Lorber, 2012 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* -chainout is an internal processor that changes the flow from chain_procs
|
||||
* back to window_procs. */
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
struct chainout_data {
|
||||
struct window_procs *nprocs;
|
||||
#if 0
|
||||
void *ndata;
|
||||
|
||||
#endif
|
||||
int linknum;
|
||||
};
|
||||
|
||||
void *
|
||||
chainout_procs_chain(cmd, n, me, nextprocs, nextdata)
|
||||
int cmd;
|
||||
int n;
|
||||
void *me;
|
||||
void *nextprocs;
|
||||
void *nextdata UNUSED;
|
||||
{
|
||||
switch(cmd){
|
||||
case WINCHAIN_ALLOC: {
|
||||
struct chainout_data *tdp = calloc(1, sizeof(struct chainout_data));
|
||||
tdp->linknum = n;
|
||||
return tdp;
|
||||
}
|
||||
case WINCHAIN_INIT: {
|
||||
struct chainout_data *tdp = me;
|
||||
tdp->nprocs = nextprocs;
|
||||
return tdp;
|
||||
}
|
||||
default:
|
||||
raw_printf("chainout_procs_chain: bad cmd\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX if we don't need this, take it out of the table */
|
||||
void
|
||||
chainout_procs_init(dir)
|
||||
int dir UNUSED;
|
||||
{
|
||||
}
|
||||
|
||||
/***
|
||||
*** winprocs
|
||||
***/
|
||||
|
||||
void
|
||||
chainout_init_nhwindows(vp, argcp, argv)
|
||||
void *vp;
|
||||
int *argcp;
|
||||
char **argv;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_init_nhwindows)(argcp, argv);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
chainout_player_selection(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_player_selection)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_askname(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_askname)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_get_nh_event(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_get_nh_event)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_exit_nhwindows(vp, str)
|
||||
void *vp;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_exit_nhwindows)(str);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_suspend_nhwindows(vp, str)
|
||||
void *vp;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_suspend_nhwindows)(str);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_resume_nhwindows(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_resume_nhwindows)();
|
||||
}
|
||||
|
||||
winid
|
||||
chainout_create_nhwindow(vp, type)
|
||||
void *vp;
|
||||
int type;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
winid rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_create_nhwindow)(type);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_clear_nhwindow(vp, window)
|
||||
void *vp;
|
||||
winid window;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_clear_nhwindow)(window);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_display_nhwindow(vp, window, blocking)
|
||||
void *vp;
|
||||
winid window;
|
||||
BOOLEAN_P blocking;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_display_nhwindow)(window, blocking);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_destroy_nhwindow(vp, window)
|
||||
void *vp;
|
||||
winid window;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_destroy_nhwindow)(window);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_curs(vp, window, x, y)
|
||||
void *vp;
|
||||
winid window;
|
||||
int x;
|
||||
int y;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_curs)(window, x, y);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_putstr(vp, window, attr, str)
|
||||
void *vp;
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_putstr)(window, attr, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_putmixed(vp, window, attr, str)
|
||||
void *vp;
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_putmixed)(window, attr, str);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_display_file(vp, fname, complain)
|
||||
void *vp;
|
||||
const char *fname;
|
||||
boolean complain;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_display_file)(fname, complain);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_start_menu(vp, window)
|
||||
void *vp;
|
||||
winid window;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_start_menu)(window);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_add_menu(vp, window, glyph, identifier, ch, gch, attr, str, preselected)
|
||||
void *vp;
|
||||
winid window; /* window to use, must be of type NHW_MENU */
|
||||
int glyph; /* glyph to display with item (unused) */
|
||||
const anything *identifier; /* what to return if selected */
|
||||
char ch; /* keyboard accelerator (0 = pick our own) */
|
||||
char gch; /* group accelerator (0 = no group) */
|
||||
int attr; /* attribute for string (like tty_putstr()) */
|
||||
const char *str; /* menu string */
|
||||
boolean preselected; /* item is marked as selected */
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_add_menu)(window, glyph, identifier,
|
||||
ch, gch, attr, str, preselected);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_end_menu(vp, window, prompt)
|
||||
void *vp;
|
||||
winid window;
|
||||
const char *prompt;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_end_menu)(window, prompt);
|
||||
}
|
||||
|
||||
int
|
||||
chainout_select_menu(vp, window, how, menu_list)
|
||||
void *vp;
|
||||
winid window;
|
||||
int how;
|
||||
menu_item **menu_list;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_select_menu)(window, how, (void *)menu_list);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
char
|
||||
chainout_message_menu(vp, let, how, mesg)
|
||||
void *vp;
|
||||
char let;
|
||||
int how;
|
||||
const char *mesg;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
char rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_message_menu)(let, how, mesg);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_update_inventory(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_update_inventory)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_mark_synch(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_mark_synch)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_wait_synch(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_wait_synch)();
|
||||
}
|
||||
|
||||
#ifdef CLIPPING
|
||||
void
|
||||
chainout_cliparound(vp, x, y)
|
||||
void *vp;
|
||||
int x;
|
||||
int y;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_cliparound)(x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef POSITIONBAR
|
||||
void
|
||||
chainout_update_positionbar(vp, posbar)
|
||||
void *vp;
|
||||
char *posbar;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_update_positionbar)(posbar);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
chainout_print_glyph(vp, window, x, y, glyph)
|
||||
void *vp;
|
||||
winid window;
|
||||
xchar x, y;
|
||||
int glyph;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_print_glyph)(window, x, y, glyph);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_raw_print(vp, str)
|
||||
void *vp;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_raw_print)(str);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_raw_print_bold(vp, str)
|
||||
void *vp;
|
||||
const char *str;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_raw_print_bold)(str);
|
||||
}
|
||||
|
||||
int
|
||||
chainout_nhgetch(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_nhgetch)();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
chainout_nh_poskey(vp, x, y, mod)
|
||||
void *vp;
|
||||
int *x;
|
||||
int *y;
|
||||
int *mod;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_nh_poskey)(x, y, mod);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_nhbell(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_nhbell)();
|
||||
}
|
||||
|
||||
int
|
||||
chainout_doprev_message(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_doprev_message)();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
char
|
||||
chainout_yn_function(vp, query, resp, def)
|
||||
void *vp;
|
||||
const char *query, *resp;
|
||||
char def;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_yn_function)(query, resp, def);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_getlin(vp, query, bufp)
|
||||
void *vp;
|
||||
const char *query;
|
||||
char *bufp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_getlin)(query, bufp);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
chainout_get_ext_cmd(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
int rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_get_ext_cmd)();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_number_pad(vp, state)
|
||||
void *vp;
|
||||
int state;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_number_pad)(state);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_delay_output(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_delay_output)();
|
||||
}
|
||||
|
||||
#ifdef CHANGE_COLOR
|
||||
void
|
||||
chainout_change_color(vp, color, value, reverse)
|
||||
void *vp;
|
||||
int color;
|
||||
long value;
|
||||
int reverse;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_change_color)(color, value, reverse);
|
||||
}
|
||||
|
||||
#ifdef MAC
|
||||
void
|
||||
chainout_change_background(vp, bw)
|
||||
void *vp;
|
||||
int bw;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_change_background)(bw);
|
||||
}
|
||||
|
||||
short
|
||||
chainout_set_font_name(vp, window, font)
|
||||
void *vp;
|
||||
winid window;
|
||||
char *font;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
short rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_set_font_name)(window, font);
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *trace_get_color_string(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
char *rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_get_color_string)();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* other defs that really should go away (they're tty specific) */
|
||||
void
|
||||
chainout_start_screen(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_start_screen)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_end_screen(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_end_screen)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_outrip(vp, tmpwin, how)
|
||||
void *vp;
|
||||
winid tmpwin;
|
||||
int how;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_outrip)(tmpwin, how);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_preference_update(vp, pref)
|
||||
void *vp;
|
||||
const char *pref;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_preference_update)(pref);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
chainout_getmsghistory(vp, init)
|
||||
void *vp;
|
||||
boolean init;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
char *rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_getmsghistory)(init);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
chainout_putmsghistory(vp, msg, is_restoring)
|
||||
void *vp;
|
||||
const char *msg;
|
||||
boolean is_restoring;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_putmsghistory)(msg, is_restoring);
|
||||
}
|
||||
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
void
|
||||
chainout_status_init(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_status_init)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_status_finish(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_status_finish)();
|
||||
}
|
||||
|
||||
void
|
||||
chainout_status_enablefield(vp, fieldidx, nm, fmt, enable)
|
||||
void *vp;
|
||||
int fieldidx;
|
||||
const char *nm;
|
||||
const char *fmt;
|
||||
boolean enable;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_status_enablefield)(fieldidx, nm, fmt, enable);
|
||||
}
|
||||
|
||||
void
|
||||
chainout_status_update(vp, idx, ptr, chg, percent)
|
||||
void *vp;
|
||||
int idx, chg, percent;
|
||||
genericptr_t ptr;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_status_update)(idx, ptr, chg, percent);
|
||||
}
|
||||
|
||||
# ifdef STATUS_HILITES
|
||||
void
|
||||
chainout_status_threshold(vp, fldidx, thresholdtype, threshold, behavior, under, over)
|
||||
void *vp;
|
||||
int fldidx,thresholdtype;
|
||||
int behavior, under, over;
|
||||
anything threshold;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
|
||||
(*tdp->nprocs->win_status_threshold)(fldidx, thresholdtype,
|
||||
threshold, behavior, under, over);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
boolean
|
||||
chainout_can_suspend(vp)
|
||||
void *vp;
|
||||
{
|
||||
struct chainout_data *tdp = vp;
|
||||
boolean rv;
|
||||
|
||||
rv = (*tdp->nprocs->win_can_suspend)();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
struct chain_procs chainout_procs = {
|
||||
"-chainout",
|
||||
0, /* wincap */
|
||||
0, /* wincap2 */
|
||||
/*
|
||||
XXX problem - the above need to come from the real window port, possibly
|
||||
modified. May need to do something to call an additional init fn later
|
||||
or if this is the only place like this the choose_windows fn can do the fixup
|
||||
(but not if the value can be modified by the stack?) TBD
|
||||
*/
|
||||
chainout_init_nhwindows,
|
||||
chainout_player_selection,
|
||||
chainout_askname,
|
||||
chainout_get_nh_event,
|
||||
chainout_exit_nhwindows,
|
||||
chainout_suspend_nhwindows,
|
||||
chainout_resume_nhwindows,
|
||||
chainout_create_nhwindow,
|
||||
chainout_clear_nhwindow,
|
||||
chainout_display_nhwindow,
|
||||
chainout_destroy_nhwindow,
|
||||
chainout_curs,
|
||||
chainout_putstr,
|
||||
chainout_putmixed,
|
||||
chainout_display_file,
|
||||
chainout_start_menu,
|
||||
chainout_add_menu,
|
||||
chainout_end_menu,
|
||||
chainout_select_menu,
|
||||
chainout_message_menu,
|
||||
chainout_update_inventory,
|
||||
chainout_mark_synch,
|
||||
chainout_wait_synch,
|
||||
#ifdef CLIPPING
|
||||
chainout_cliparound,
|
||||
#endif
|
||||
#ifdef POSITIONBAR
|
||||
chainout_update_positionbar,
|
||||
#endif
|
||||
chainout_print_glyph,
|
||||
chainout_raw_print,
|
||||
chainout_raw_print_bold,
|
||||
chainout_nhgetch,
|
||||
chainout_nh_poskey,
|
||||
chainout_nhbell,
|
||||
chainout_doprev_message,
|
||||
chainout_yn_function,
|
||||
chainout_getlin,
|
||||
chainout_get_ext_cmd,
|
||||
chainout_number_pad,
|
||||
chainout_delay_output,
|
||||
#ifdef CHANGE_COLOR
|
||||
chainout_change_color,
|
||||
#ifdef MAC
|
||||
chainout_change_background,
|
||||
chainout_set_font_name,
|
||||
#endif
|
||||
chainout_get_color_string,
|
||||
#endif
|
||||
|
||||
chainout_start_screen,
|
||||
chainout_end_screen,
|
||||
|
||||
chainout_outrip,
|
||||
chainout_preference_update,
|
||||
chainout_getmsghistory,
|
||||
chainout_putmsghistory,
|
||||
#ifdef STATUS_VIA_WINDOWPORT
|
||||
chainout_status_init,
|
||||
chainout_status_finish,
|
||||
chainout_status_enablefield,
|
||||
chainout_status_update,
|
||||
# ifdef STATUS_HILITES
|
||||
chainout_status_threshold,
|
||||
# endif
|
||||
#endif
|
||||
chainout_can_suspend,
|
||||
};
|
||||
1197
win/chain/wc_trace.c
Normal file
1197
win/chain/wc_trace.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
/* Support for logging SIGWINCH. */
|
||||
#ifdef WINCHAIN
|
||||
# include "winprocs.h"
|
||||
#endif
|
||||
|
||||
#include "dlb.h"
|
||||
#include "date.h"
|
||||
#ifdef SHORT_FILENAMES
|
||||
@@ -247,7 +253,24 @@ winch()
|
||||
int oldLI = LI, oldCO = CO, i;
|
||||
register struct WinDesc *cw;
|
||||
|
||||
# ifdef WINCHAIN
|
||||
{
|
||||
# define WINCH_MESSAGE "(SIGWINCH)"
|
||||
if(wc_tracelogf)
|
||||
(void)write(fileno(wc_tracelogf), WINCH_MESSAGE, strlen(WINCH_MESSAGE));
|
||||
# undef WINCH_MESSAGE
|
||||
}
|
||||
# endif
|
||||
getwindowsz();
|
||||
/* For long running events such as multi-page menus and
|
||||
* display_file(), we note the signal's occurance and
|
||||
* hope the code there decides to handle the situation
|
||||
* and reset the flag. There will be race conditions
|
||||
* when handling this - code handlers so it doesn't matter.
|
||||
*/
|
||||
# ifdef notyet
|
||||
winch_seen = TRUE;
|
||||
# endif
|
||||
if((oldLI != LI || oldCO != CO) && ttyDisplay) {
|
||||
ttyDisplay->rows = LI;
|
||||
ttyDisplay->cols = CO;
|
||||
@@ -1805,10 +1828,6 @@ tty_display_nhwindow(window, blocking)
|
||||
case NHW_MENU:
|
||||
cw->active = 1;
|
||||
#ifdef H2344_BROKEN
|
||||
/* XXX this is the block that messes up corner win for player selection
|
||||
(at least when undoing the patch one piece at a time from the start
|
||||
of the file)
|
||||
*/
|
||||
cw->offx = (cw->type==NHW_TEXT)
|
||||
? 0
|
||||
: min( min(82,ttyDisplay->cols/2), ttyDisplay->cols - cw->maxcol - 1);
|
||||
@@ -2356,6 +2375,9 @@ boolean complain;
|
||||
terminate(EXIT_FAILURE);
|
||||
}
|
||||
(void) close(fd);
|
||||
# ifdef notyet
|
||||
winch_seen = 0;
|
||||
# endif
|
||||
}
|
||||
#else /* DEF_PAGER */
|
||||
{
|
||||
@@ -2517,6 +2539,7 @@ tty_end_menu(window, prompt)
|
||||
tty_add_menu(window, NO_GLYPH, &any, 0, 0, ATR_NONE, prompt, MENU_UNSELECTED);
|
||||
}
|
||||
|
||||
/* XXX another magic number? 52 */
|
||||
lmax = min(52, (int)ttyDisplay->rows - 1); /* # lines per page */
|
||||
cw->npages = (cw->nitems + (lmax - 1)) / lmax; /* # of pages */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user