NHDT->ANH, nethack->anethack, nhdat->anhdat
[aNetHack.git] / win / chain / wc_chainout.c
blob42b656552871ac9d51577277f938719b9ee65396
1 /* aNetHack 0.0.1 wc_chainout.c $ANH-Date: 1433806611 2015/06/08 23:36:51 $ $ANH-Branch: master $:$ANH-Revision: 1.7 $ */
2 /* Copyright (c) Kenneth Lorber, 2012 */
3 /* aNetHack may be freely redistributed. See license for details. */
5 /* -chainout is an internal processor that changes the flow from chain_procs
6 * back to window_procs. */
8 #include "hack.h"
10 struct chainout_data {
11 struct window_procs *nprocs;
12 #if 0
13 void *ndata;
15 #endif
16 int linknum;
19 void *
20 chainout_procs_chain(cmd, n, me, nextprocs, nextdata)
21 int cmd;
22 int n;
23 void *me;
24 void *nextprocs;
25 void *nextdata UNUSED;
27 switch (cmd) {
28 case WINCHAIN_ALLOC: {
29 struct chainout_data *tdp = calloc(1, sizeof(struct chainout_data));
30 tdp->linknum = n;
31 return tdp;
33 case WINCHAIN_INIT: {
34 struct chainout_data *tdp = me;
35 tdp->nprocs = nextprocs;
36 return tdp;
38 default:
39 raw_printf("chainout_procs_chain: bad cmd\n");
40 exit(EXIT_FAILURE);
44 /* XXX if we don't need this, take it out of the table */
45 void
46 chainout_procs_init(dir)
47 int dir UNUSED;
51 /***
52 *** winprocs
53 ***/
55 void
56 chainout_init_nhwindows(vp, argcp, argv)
57 void *vp;
58 int *argcp;
59 char **argv;
61 struct chainout_data *tdp = vp;
63 (*tdp->nprocs->win_init_nhwindows)(argcp, argv);
66 void
67 chainout_player_selection(vp)
68 void *vp;
70 struct chainout_data *tdp = vp;
72 (*tdp->nprocs->win_player_selection)();
75 void
76 chainout_askname(vp)
77 void *vp;
79 struct chainout_data *tdp = vp;
81 (*tdp->nprocs->win_askname)();
84 void
85 chainout_get_nh_event(vp)
86 void *vp;
88 struct chainout_data *tdp = vp;
90 (*tdp->nprocs->win_get_nh_event)();
93 void
94 chainout_exit_nhwindows(vp, str)
95 void *vp;
96 const char *str;
98 struct chainout_data *tdp = vp;
100 (*tdp->nprocs->win_exit_nhwindows)(str);
103 void
104 chainout_suspend_nhwindows(vp, str)
105 void *vp;
106 const char *str;
108 struct chainout_data *tdp = vp;
110 (*tdp->nprocs->win_suspend_nhwindows)(str);
113 void
114 chainout_resume_nhwindows(vp)
115 void *vp;
117 struct chainout_data *tdp = vp;
119 (*tdp->nprocs->win_resume_nhwindows)();
122 winid
123 chainout_create_nhwindow(vp, type)
124 void *vp;
125 int type;
127 struct chainout_data *tdp = vp;
128 winid rv;
130 rv = (*tdp->nprocs->win_create_nhwindow)(type);
132 return rv;
135 void
136 chainout_clear_nhwindow(vp, window)
137 void *vp;
138 winid window;
140 struct chainout_data *tdp = vp;
142 (*tdp->nprocs->win_clear_nhwindow)(window);
145 void
146 chainout_display_nhwindow(vp, window, blocking)
147 void *vp;
148 winid window;
149 BOOLEAN_P blocking;
151 struct chainout_data *tdp = vp;
153 (*tdp->nprocs->win_display_nhwindow)(window, blocking);
156 void
157 chainout_destroy_nhwindow(vp, window)
158 void *vp;
159 winid window;
161 struct chainout_data *tdp = vp;
163 (*tdp->nprocs->win_destroy_nhwindow)(window);
166 void
167 chainout_curs(vp, window, x, y)
168 void *vp;
169 winid window;
170 int x;
171 int y;
173 struct chainout_data *tdp = vp;
175 (*tdp->nprocs->win_curs)(window, x, y);
178 void
179 chainout_putstr(vp, window, attr, str)
180 void *vp;
181 winid window;
182 int attr;
183 const char *str;
185 struct chainout_data *tdp = vp;
187 (*tdp->nprocs->win_putstr)(window, attr, str);
190 void
191 chainout_putmixed(vp, window, attr, str)
192 void *vp;
193 winid window;
194 int attr;
195 const char *str;
197 struct chainout_data *tdp = vp;
199 (*tdp->nprocs->win_putmixed)(window, attr, str);
202 void
203 chainout_display_file(vp, fname, complain)
204 void *vp;
205 const char *fname;
206 boolean complain;
208 struct chainout_data *tdp = vp;
210 (*tdp->nprocs->win_display_file)(fname, complain);
213 void
214 chainout_start_menu(vp, window)
215 void *vp;
216 winid window;
218 struct chainout_data *tdp = vp;
220 (*tdp->nprocs->win_start_menu)(window);
223 void
224 chainout_add_menu(vp, window, glyph, identifier, ch, gch, attr, str,
225 preselected)
226 void *vp;
227 winid window; /* window to use, must be of type NHW_MENU */
228 int glyph; /* glyph to display with item (unused) */
229 const anything *identifier; /* what to return if selected */
230 char ch; /* keyboard accelerator (0 = pick our own) */
231 char gch; /* group accelerator (0 = no group) */
232 int attr; /* attribute for string (like tty_putstr()) */
233 const char *str; /* menu string */
234 boolean preselected; /* item is marked as selected */
236 struct chainout_data *tdp = vp;
238 (*tdp->nprocs->win_add_menu)(window, glyph, identifier, ch, gch, attr,
239 str, preselected);
242 void
243 chainout_end_menu(vp, window, prompt)
244 void *vp;
245 winid window;
246 const char *prompt;
248 struct chainout_data *tdp = vp;
250 (*tdp->nprocs->win_end_menu)(window, prompt);
254 chainout_select_menu(vp, window, how, menu_list)
255 void *vp;
256 winid window;
257 int how;
258 menu_item **menu_list;
260 struct chainout_data *tdp = vp;
261 int rv;
263 rv = (*tdp->nprocs->win_select_menu)(window, how, (void *) menu_list);
265 return rv;
268 char
269 chainout_message_menu(vp, let, how, mesg)
270 void *vp;
271 char let;
272 int how;
273 const char *mesg;
275 struct chainout_data *tdp = vp;
276 char rv;
278 rv = (*tdp->nprocs->win_message_menu)(let, how, mesg);
280 return rv;
283 void
284 chainout_update_inventory(vp)
285 void *vp;
287 struct chainout_data *tdp = vp;
289 (*tdp->nprocs->win_update_inventory)();
292 void
293 chainout_mark_synch(vp)
294 void *vp;
296 struct chainout_data *tdp = vp;
298 (*tdp->nprocs->win_mark_synch)();
301 void
302 chainout_wait_synch(vp)
303 void *vp;
305 struct chainout_data *tdp = vp;
307 (*tdp->nprocs->win_wait_synch)();
310 #ifdef CLIPPING
311 void
312 chainout_cliparound(vp, x, y)
313 void *vp;
314 int x;
315 int y;
317 struct chainout_data *tdp = vp;
319 (*tdp->nprocs->win_cliparound)(x, y);
321 #endif
323 #ifdef POSITIONBAR
324 void
325 chainout_update_positionbar(vp, posbar)
326 void *vp;
327 char *posbar;
329 struct chainout_data *tdp = vp;
331 (*tdp->nprocs->win_update_positionbar)(posbar);
333 #endif
335 void
336 chainout_print_glyph(vp, window, x, y, glyph, bkglyph)
337 void *vp;
338 winid window;
339 xchar x, y;
340 int glyph, bkglyph;
342 struct chainout_data *tdp = vp;
344 (*tdp->nprocs->win_print_glyph)(window, x, y, glyph, bkglyph);
347 void
348 chainout_raw_print(vp, str)
349 void *vp;
350 const char *str;
352 struct chainout_data *tdp = vp;
354 (*tdp->nprocs->win_raw_print)(str);
357 void
358 chainout_raw_print_bold(vp, str)
359 void *vp;
360 const char *str;
362 struct chainout_data *tdp = vp;
364 (*tdp->nprocs->win_raw_print_bold)(str);
368 chainout_nhgetch(vp)
369 void *vp;
371 struct chainout_data *tdp = vp;
372 int rv;
374 rv = (*tdp->nprocs->win_nhgetch)();
376 return rv;
380 chainout_nh_poskey(vp, x, y, mod)
381 void *vp;
382 int *x;
383 int *y;
384 int *mod;
386 struct chainout_data *tdp = vp;
387 int rv;
389 rv = (*tdp->nprocs->win_nh_poskey)(x, y, mod);
391 return rv;
394 void
395 chainout_nhbell(vp)
396 void *vp;
398 struct chainout_data *tdp = vp;
400 (*tdp->nprocs->win_nhbell)();
404 chainout_doprev_message(vp)
405 void *vp;
407 struct chainout_data *tdp = vp;
408 int rv;
410 rv = (*tdp->nprocs->win_doprev_message)();
412 return rv;
415 char
416 chainout_yn_function(vp, query, resp, def)
417 void *vp;
418 const char *query, *resp;
419 char def;
421 struct chainout_data *tdp = vp;
422 int rv;
424 rv = (*tdp->nprocs->win_yn_function)(query, resp, def);
426 return rv;
429 void
430 chainout_getlin(vp, query, bufp)
431 void *vp;
432 const char *query;
433 char *bufp;
435 struct chainout_data *tdp = vp;
437 (*tdp->nprocs->win_getlin)(query, bufp);
441 chainout_get_ext_cmd(vp)
442 void *vp;
444 struct chainout_data *tdp = vp;
445 int rv;
447 rv = (*tdp->nprocs->win_get_ext_cmd)();
449 return rv;
452 void
453 chainout_number_pad(vp, state)
454 void *vp;
455 int state;
457 struct chainout_data *tdp = vp;
459 (*tdp->nprocs->win_number_pad)(state);
462 void
463 chainout_delay_output(vp)
464 void *vp;
466 struct chainout_data *tdp = vp;
468 (*tdp->nprocs->win_delay_output)();
471 #ifdef CHANGE_COLOR
472 void
473 chainout_change_color(vp, color, value, reverse)
474 void *vp;
475 int color;
476 long value;
477 int reverse;
479 struct chainout_data *tdp = vp;
481 (*tdp->nprocs->win_change_color)(color, value, reverse);
484 #ifdef MAC
485 void
486 chainout_change_background(vp, bw)
487 void *vp;
488 int bw;
490 struct chainout_data *tdp = vp;
492 (*tdp->nprocs->win_change_background)(bw);
495 short
496 chainout_set_font_name(vp, window, font)
497 void *vp;
498 winid window;
499 char *font;
501 struct chainout_data *tdp = vp;
502 short rv;
504 rv = (*tdp->nprocs->win_set_font_name)(window, font);
506 return rv;
508 #endif
510 char *
511 trace_get_color_string(vp)
512 void *vp;
514 struct chainout_data *tdp = vp;
515 char *rv;
517 rv = (*tdp->nprocs->win_get_color_string)();
519 return rv;
522 #endif
524 /* other defs that really should go away (they're tty specific) */
525 void
526 chainout_start_screen(vp)
527 void *vp;
529 struct chainout_data *tdp = vp;
531 (*tdp->nprocs->win_start_screen)();
534 void
535 chainout_end_screen(vp)
536 void *vp;
538 struct chainout_data *tdp = vp;
540 (*tdp->nprocs->win_end_screen)();
543 void
544 chainout_outrip(vp, tmpwin, how, when)
545 void *vp;
546 winid tmpwin;
547 int how;
548 time_t when;
550 struct chainout_data *tdp = vp;
552 (*tdp->nprocs->win_outrip)(tmpwin, how, when);
555 void
556 chainout_preference_update(vp, pref)
557 void *vp;
558 const char *pref;
560 struct chainout_data *tdp = vp;
562 (*tdp->nprocs->win_preference_update)(pref);
565 char *
566 chainout_getmsghistory(vp, init)
567 void *vp;
568 boolean init;
570 struct chainout_data *tdp = vp;
571 char *rv;
573 rv = (*tdp->nprocs->win_getmsghistory)(init);
575 return rv;
578 void
579 chainout_putmsghistory(vp, msg, is_restoring)
580 void *vp;
581 const char *msg;
582 boolean is_restoring;
584 struct chainout_data *tdp = vp;
586 (*tdp->nprocs->win_putmsghistory)(msg, is_restoring);
589 #ifdef STATUS_VIA_WINDOWPORT
590 void
591 chainout_status_init(vp)
592 void *vp;
594 struct chainout_data *tdp = vp;
596 (*tdp->nprocs->win_status_init)();
599 void
600 chainout_status_finish(vp)
601 void *vp;
603 struct chainout_data *tdp = vp;
605 (*tdp->nprocs->win_status_finish)();
608 void
609 chainout_status_enablefield(vp, fieldidx, nm, fmt, enable)
610 void *vp;
611 int fieldidx;
612 const char *nm;
613 const char *fmt;
614 boolean enable;
616 struct chainout_data *tdp = vp;
618 (*tdp->nprocs->win_status_enablefield)(fieldidx, nm, fmt, enable);
621 void
622 chainout_status_update(vp, idx, ptr, chg, percent)
623 void *vp;
624 int idx, chg, percent;
625 genericptr_t ptr;
627 struct chainout_data *tdp = vp;
629 (*tdp->nprocs->win_status_update)(idx, ptr, chg, percent);
632 #ifdef STATUS_HILITES
633 void
634 chainout_status_threshold(vp, fldidx, thresholdtype, threshold, behavior,
635 under, over)
636 void *vp;
637 int fldidx, thresholdtype;
638 int behavior, under, over;
639 anything threshold;
641 struct chainout_data *tdp = vp;
643 (*tdp->nprocs->win_status_threshold)(fldidx, thresholdtype, threshold,
644 behavior, under, over);
646 #endif
647 #endif
649 boolean
650 chainout_can_suspend(vp)
651 void *vp;
653 struct chainout_data *tdp = vp;
654 boolean rv;
656 rv = (*tdp->nprocs->win_can_suspend)();
658 return rv;
661 struct chain_procs chainout_procs = {
662 "-chainout", 0, /* wincap */
663 0, /* wincap2 */
665 XXX problem - the above need to come from the real window port, possibly
666 modified. May need to do something to call an additional init fn later
667 or if this is the only place like this the choose_windows fn can do the
668 fixup
669 (but not if the value can be modified by the stack?) TBD
671 chainout_init_nhwindows,
672 chainout_player_selection, chainout_askname, chainout_get_nh_event,
673 chainout_exit_nhwindows, chainout_suspend_nhwindows,
674 chainout_resume_nhwindows, chainout_create_nhwindow,
675 chainout_clear_nhwindow, chainout_display_nhwindow,
676 chainout_destroy_nhwindow, chainout_curs, chainout_putstr,
677 chainout_putmixed, chainout_display_file, chainout_start_menu,
678 chainout_add_menu, chainout_end_menu, chainout_select_menu,
679 chainout_message_menu, chainout_update_inventory, chainout_mark_synch,
680 chainout_wait_synch,
681 #ifdef CLIPPING
682 chainout_cliparound,
683 #endif
684 #ifdef POSITIONBAR
685 chainout_update_positionbar,
686 #endif
687 chainout_print_glyph, chainout_raw_print, chainout_raw_print_bold,
688 chainout_nhgetch, chainout_nh_poskey, chainout_nhbell,
689 chainout_doprev_message, chainout_yn_function, chainout_getlin,
690 chainout_get_ext_cmd, chainout_number_pad, chainout_delay_output,
691 #ifdef CHANGE_COLOR
692 chainout_change_color,
693 #ifdef MAC
694 chainout_change_background, chainout_set_font_name,
695 #endif
696 chainout_get_color_string,
697 #endif
699 chainout_start_screen, chainout_end_screen,
701 chainout_outrip, chainout_preference_update, chainout_getmsghistory,
702 chainout_putmsghistory,
703 #ifdef STATUS_VIA_WINDOWPORT
704 chainout_status_init, chainout_status_finish, chainout_status_enablefield,
705 chainout_status_update,
706 #ifdef STATUS_HILITES
707 chainout_status_threshold,
708 #endif
709 #endif
710 chainout_can_suspend,