OSDN Git Service

upgrade to 3.6.2
[jnethack/source.git] / win / chain / wc_chainout.c
1 /* NetHack 3.6  wc_chainout.c   $NHDT-Date: 1433806611 2015/06/08 23:36:51 $  $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
2 /* Copyright (c) Kenneth Lorber, 2012                             */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /* -chainout is an internal processor that changes the flow from chain_procs
6  * back to window_procs. */
7
8 #include "hack.h"
9
10 struct chainout_data {
11     struct window_procs *nprocs;
12 #if 0
13     void *ndata;
14
15 #endif
16     int linknum;
17 };
18
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;
26 {
27     struct chainout_data *tdp = 0;
28
29     switch (cmd) {
30     case WINCHAIN_ALLOC:
31         tdp = (struct chainout_data *) alloc(sizeof *tdp);
32         tdp->nprocs = 0;
33         tdp->linknum = n;
34         break;
35     case WINCHAIN_INIT:
36         tdp = me;
37         tdp->nprocs = nextprocs;
38         break;
39     default:
40         panic("chainout_procs_chain: bad cmd\n");
41         /*NOTREACHED*/
42     }
43     return tdp;
44 }
45
46 /* XXX if we don't need this, take it out of the table */
47 void
48 chainout_procs_init(dir)
49 int dir UNUSED;
50 {
51 }
52
53 /***
54  *** winprocs
55  ***/
56
57 void
58 chainout_init_nhwindows(vp, argcp, argv)
59 void *vp;
60 int *argcp;
61 char **argv;
62 {
63     struct chainout_data *tdp = vp;
64
65     (*tdp->nprocs->win_init_nhwindows)(argcp, argv);
66 }
67
68 void
69 chainout_player_selection(vp)
70 void *vp;
71 {
72     struct chainout_data *tdp = vp;
73
74     (*tdp->nprocs->win_player_selection)();
75 }
76
77 void
78 chainout_askname(vp)
79 void *vp;
80 {
81     struct chainout_data *tdp = vp;
82
83     (*tdp->nprocs->win_askname)();
84 }
85
86 void
87 chainout_get_nh_event(vp)
88 void *vp;
89 {
90     struct chainout_data *tdp = vp;
91
92     (*tdp->nprocs->win_get_nh_event)();
93 }
94
95 void
96 chainout_exit_nhwindows(vp, str)
97 void *vp;
98 const char *str;
99 {
100     struct chainout_data *tdp = vp;
101
102     (*tdp->nprocs->win_exit_nhwindows)(str);
103 }
104
105 void
106 chainout_suspend_nhwindows(vp, str)
107 void *vp;
108 const char *str;
109 {
110     struct chainout_data *tdp = vp;
111
112     (*tdp->nprocs->win_suspend_nhwindows)(str);
113 }
114
115 void
116 chainout_resume_nhwindows(vp)
117 void *vp;
118 {
119     struct chainout_data *tdp = vp;
120
121     (*tdp->nprocs->win_resume_nhwindows)();
122 }
123
124 winid
125 chainout_create_nhwindow(vp, type)
126 void *vp;
127 int type;
128 {
129     struct chainout_data *tdp = vp;
130     winid rv;
131
132     rv = (*tdp->nprocs->win_create_nhwindow)(type);
133
134     return rv;
135 }
136
137 void
138 chainout_clear_nhwindow(vp, window)
139 void *vp;
140 winid window;
141 {
142     struct chainout_data *tdp = vp;
143
144     (*tdp->nprocs->win_clear_nhwindow)(window);
145 }
146
147 void
148 chainout_display_nhwindow(vp, window, blocking)
149 void *vp;
150 winid window;
151 BOOLEAN_P blocking;
152 {
153     struct chainout_data *tdp = vp;
154
155     (*tdp->nprocs->win_display_nhwindow)(window, blocking);
156 }
157
158 void
159 chainout_destroy_nhwindow(vp, window)
160 void *vp;
161 winid window;
162 {
163     struct chainout_data *tdp = vp;
164
165     (*tdp->nprocs->win_destroy_nhwindow)(window);
166 }
167
168 void
169 chainout_curs(vp, window, x, y)
170 void *vp;
171 winid window;
172 int x;
173 int y;
174 {
175     struct chainout_data *tdp = vp;
176
177     (*tdp->nprocs->win_curs)(window, x, y);
178 }
179
180 void
181 chainout_putstr(vp, window, attr, str)
182 void *vp;
183 winid window;
184 int attr;
185 const char *str;
186 {
187     struct chainout_data *tdp = vp;
188
189     (*tdp->nprocs->win_putstr)(window, attr, str);
190 }
191
192 void
193 chainout_putmixed(vp, window, attr, str)
194 void *vp;
195 winid window;
196 int attr;
197 const char *str;
198 {
199     struct chainout_data *tdp = vp;
200
201     (*tdp->nprocs->win_putmixed)(window, attr, str);
202 }
203
204 void
205 chainout_display_file(vp, fname, complain)
206 void *vp;
207 const char *fname;
208 boolean complain;
209 {
210     struct chainout_data *tdp = vp;
211
212     (*tdp->nprocs->win_display_file)(fname, complain);
213 }
214
215 void
216 chainout_start_menu(vp, window)
217 void *vp;
218 winid window;
219 {
220     struct chainout_data *tdp = vp;
221
222     (*tdp->nprocs->win_start_menu)(window);
223 }
224
225 void
226 chainout_add_menu(vp, window, glyph, identifier, ch, gch, attr, str,
227                   preselected)
228 void *vp;
229 winid window;               /* window to use, must be of type NHW_MENU */
230 int glyph;                  /* glyph to display with item (unused) */
231 const anything *identifier; /* what to return if selected */
232 char ch;                    /* keyboard accelerator (0 = pick our own) */
233 char gch;                   /* group accelerator (0 = no group) */
234 int attr;                   /* attribute for string (like tty_putstr()) */
235 const char *str;            /* menu string */
236 boolean preselected;        /* item is marked as selected */
237 {
238     struct chainout_data *tdp = vp;
239
240     (*tdp->nprocs->win_add_menu)(window, glyph, identifier, ch, gch, attr,
241                                  str, preselected);
242 }
243
244 void
245 chainout_end_menu(vp, window, prompt)
246 void *vp;
247 winid window;
248 const char *prompt;
249 {
250     struct chainout_data *tdp = vp;
251
252     (*tdp->nprocs->win_end_menu)(window, prompt);
253 }
254
255 int
256 chainout_select_menu(vp, window, how, menu_list)
257 void *vp;
258 winid window;
259 int how;
260 menu_item **menu_list;
261 {
262     struct chainout_data *tdp = vp;
263     int rv;
264
265     rv = (*tdp->nprocs->win_select_menu)(window, how, (void *) menu_list);
266
267     return rv;
268 }
269
270 char
271 chainout_message_menu(vp, let, how, mesg)
272 void *vp;
273 char let;
274 int how;
275 const char *mesg;
276 {
277     struct chainout_data *tdp = vp;
278     char rv;
279
280     rv = (*tdp->nprocs->win_message_menu)(let, how, mesg);
281
282     return rv;
283 }
284
285 void
286 chainout_update_inventory(vp)
287 void *vp;
288 {
289     struct chainout_data *tdp = vp;
290
291     (*tdp->nprocs->win_update_inventory)();
292 }
293
294 void
295 chainout_mark_synch(vp)
296 void *vp;
297 {
298     struct chainout_data *tdp = vp;
299
300     (*tdp->nprocs->win_mark_synch)();
301 }
302
303 void
304 chainout_wait_synch(vp)
305 void *vp;
306 {
307     struct chainout_data *tdp = vp;
308
309     (*tdp->nprocs->win_wait_synch)();
310 }
311
312 #ifdef CLIPPING
313 void
314 chainout_cliparound(vp, x, y)
315 void *vp;
316 int x;
317 int y;
318 {
319     struct chainout_data *tdp = vp;
320
321     (*tdp->nprocs->win_cliparound)(x, y);
322 }
323 #endif
324
325 #ifdef POSITIONBAR
326 void
327 chainout_update_positionbar(vp, posbar)
328 void *vp;
329 char *posbar;
330 {
331     struct chainout_data *tdp = vp;
332
333     (*tdp->nprocs->win_update_positionbar)(posbar);
334 }
335 #endif
336
337 void
338 chainout_print_glyph(vp, window, x, y, glyph, bkglyph)
339 void *vp;
340 winid window;
341 xchar x, y;
342 int glyph, bkglyph;
343 {
344     struct chainout_data *tdp = vp;
345
346     (*tdp->nprocs->win_print_glyph)(window, x, y, glyph, bkglyph);
347 }
348
349 void
350 chainout_raw_print(vp, str)
351 void *vp;
352 const char *str;
353 {
354     struct chainout_data *tdp = vp;
355
356     (*tdp->nprocs->win_raw_print)(str);
357 }
358
359 void
360 chainout_raw_print_bold(vp, str)
361 void *vp;
362 const char *str;
363 {
364     struct chainout_data *tdp = vp;
365
366     (*tdp->nprocs->win_raw_print_bold)(str);
367 }
368
369 int
370 chainout_nhgetch(vp)
371 void *vp;
372 {
373     struct chainout_data *tdp = vp;
374     int rv;
375
376     rv = (*tdp->nprocs->win_nhgetch)();
377
378     return rv;
379 }
380
381 int
382 chainout_nh_poskey(vp, x, y, mod)
383 void *vp;
384 int *x;
385 int *y;
386 int *mod;
387 {
388     struct chainout_data *tdp = vp;
389     int rv;
390
391     rv = (*tdp->nprocs->win_nh_poskey)(x, y, mod);
392
393     return rv;
394 }
395
396 void
397 chainout_nhbell(vp)
398 void *vp;
399 {
400     struct chainout_data *tdp = vp;
401
402     (*tdp->nprocs->win_nhbell)();
403 }
404
405 int
406 chainout_doprev_message(vp)
407 void *vp;
408 {
409     struct chainout_data *tdp = vp;
410     int rv;
411
412     rv = (*tdp->nprocs->win_doprev_message)();
413
414     return rv;
415 }
416
417 char
418 chainout_yn_function(vp, query, resp, def)
419 void *vp;
420 const char *query, *resp;
421 char def;
422 {
423     struct chainout_data *tdp = vp;
424     int rv;
425
426     rv = (*tdp->nprocs->win_yn_function)(query, resp, def);
427
428     return rv;
429 }
430
431 void
432 chainout_getlin(vp, query, bufp)
433 void *vp;
434 const char *query;
435 char *bufp;
436 {
437     struct chainout_data *tdp = vp;
438
439     (*tdp->nprocs->win_getlin)(query, bufp);
440 }
441
442 int
443 chainout_get_ext_cmd(vp)
444 void *vp;
445 {
446     struct chainout_data *tdp = vp;
447     int rv;
448
449     rv = (*tdp->nprocs->win_get_ext_cmd)();
450
451     return rv;
452 }
453
454 void
455 chainout_number_pad(vp, state)
456 void *vp;
457 int state;
458 {
459     struct chainout_data *tdp = vp;
460
461     (*tdp->nprocs->win_number_pad)(state);
462 }
463
464 void
465 chainout_delay_output(vp)
466 void *vp;
467 {
468     struct chainout_data *tdp = vp;
469
470     (*tdp->nprocs->win_delay_output)();
471 }
472
473 #ifdef CHANGE_COLOR
474 void
475 chainout_change_color(vp, color, value, reverse)
476 void *vp;
477 int color;
478 long value;
479 int reverse;
480 {
481     struct chainout_data *tdp = vp;
482
483     (*tdp->nprocs->win_change_color)(color, value, reverse);
484 }
485
486 #ifdef MAC
487 void
488 chainout_change_background(vp, bw)
489 void *vp;
490 int bw;
491 {
492     struct chainout_data *tdp = vp;
493
494     (*tdp->nprocs->win_change_background)(bw);
495 }
496
497 short
498 chainout_set_font_name(vp, window, font)
499 void *vp;
500 winid window;
501 char *font;
502 {
503     struct chainout_data *tdp = vp;
504     short rv;
505
506     rv = (*tdp->nprocs->win_set_font_name)(window, font);
507
508     return rv;
509 }
510 #endif
511
512 char *
513 trace_get_color_string(vp)
514 void *vp;
515 {
516     struct chainout_data *tdp = vp;
517     char *rv;
518
519     rv = (*tdp->nprocs->win_get_color_string)();
520
521     return rv;
522 }
523
524 #endif
525
526 /* other defs that really should go away (they're tty specific) */
527 void
528 chainout_start_screen(vp)
529 void *vp;
530 {
531     struct chainout_data *tdp = vp;
532
533     (*tdp->nprocs->win_start_screen)();
534 }
535
536 void
537 chainout_end_screen(vp)
538 void *vp;
539 {
540     struct chainout_data *tdp = vp;
541
542     (*tdp->nprocs->win_end_screen)();
543 }
544
545 void
546 chainout_outrip(vp, tmpwin, how, when)
547 void *vp;
548 winid tmpwin;
549 int how;
550 time_t when;
551 {
552     struct chainout_data *tdp = vp;
553
554     (*tdp->nprocs->win_outrip)(tmpwin, how, when);
555 }
556
557 void
558 chainout_preference_update(vp, pref)
559 void *vp;
560 const char *pref;
561 {
562     struct chainout_data *tdp = vp;
563
564     (*tdp->nprocs->win_preference_update)(pref);
565 }
566
567 char *
568 chainout_getmsghistory(vp, init)
569 void *vp;
570 boolean init;
571 {
572     struct chainout_data *tdp = vp;
573     char *rv;
574
575     rv = (*tdp->nprocs->win_getmsghistory)(init);
576
577     return rv;
578 }
579
580 void
581 chainout_putmsghistory(vp, msg, is_restoring)
582 void *vp;
583 const char *msg;
584 boolean is_restoring;
585 {
586     struct chainout_data *tdp = vp;
587
588     (*tdp->nprocs->win_putmsghistory)(msg, is_restoring);
589 }
590
591 void
592 chainout_status_init(vp)
593 void *vp;
594 {
595     struct chainout_data *tdp = vp;
596
597     (*tdp->nprocs->win_status_init)();
598 }
599
600 void
601 chainout_status_finish(vp)
602 void *vp;
603 {
604     struct chainout_data *tdp = vp;
605
606     (*tdp->nprocs->win_status_finish)();
607 }
608
609 void
610 chainout_status_enablefield(vp, fieldidx, nm, fmt, enable)
611 void *vp;
612 int fieldidx;
613 const char *nm;
614 const char *fmt;
615 boolean enable;
616 {
617     struct chainout_data *tdp = vp;
618
619     (*tdp->nprocs->win_status_enablefield)(fieldidx, nm, fmt, enable);
620 }
621
622 void
623 chainout_status_update(vp, idx, ptr, chg, percent, color, colormasks)
624 void *vp;
625 int idx, chg, percent, color;
626 genericptr_t ptr;
627 unsigned long *colormasks;
628 {
629     struct chainout_data *tdp = vp;
630
631     (*tdp->nprocs->win_status_update)(idx, ptr, chg, percent, color, colormasks);
632 }
633
634 boolean
635 chainout_can_suspend(vp)
636 void *vp;
637 {
638     struct chainout_data *tdp = vp;
639     boolean rv;
640
641     rv = (*tdp->nprocs->win_can_suspend)();
642
643     return rv;
644 }
645
646 struct chain_procs chainout_procs = {
647     "-chainout", 0, /* wincap */
648     0,              /* wincap2 */
649     /*
650     XXX problem - the above need to come from the real window port, possibly
651     modified.  May need to do something to call an additional init fn later
652     or if this is the only place like this the choose_windows fn can do the
653     fixup
654     (but not if the value can be modified by the stack?)  TBD
655     */
656     chainout_init_nhwindows,
657     chainout_player_selection, chainout_askname, chainout_get_nh_event,
658     chainout_exit_nhwindows, chainout_suspend_nhwindows,
659     chainout_resume_nhwindows, chainout_create_nhwindow,
660     chainout_clear_nhwindow, chainout_display_nhwindow,
661     chainout_destroy_nhwindow, chainout_curs, chainout_putstr,
662     chainout_putmixed, chainout_display_file, chainout_start_menu,
663     chainout_add_menu, chainout_end_menu, chainout_select_menu,
664     chainout_message_menu, chainout_update_inventory, chainout_mark_synch,
665     chainout_wait_synch,
666 #ifdef CLIPPING
667     chainout_cliparound,
668 #endif
669 #ifdef POSITIONBAR
670     chainout_update_positionbar,
671 #endif
672     chainout_print_glyph, chainout_raw_print, chainout_raw_print_bold,
673     chainout_nhgetch, chainout_nh_poskey, chainout_nhbell,
674     chainout_doprev_message, chainout_yn_function, chainout_getlin,
675     chainout_get_ext_cmd, chainout_number_pad, chainout_delay_output,
676 #ifdef CHANGE_COLOR
677     chainout_change_color,
678 #ifdef MAC
679     chainout_change_background, chainout_set_font_name,
680 #endif
681     chainout_get_color_string,
682 #endif
683
684     chainout_start_screen, chainout_end_screen,
685
686     chainout_outrip, chainout_preference_update, chainout_getmsghistory,
687     chainout_putmsghistory,
688     chainout_status_init, chainout_status_finish, chainout_status_enablefield,
689     chainout_status_update,
690     chainout_can_suspend,
691 };