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. */
10 struct chainout_data
{
11 struct window_procs
*nprocs
;
20 chainout_procs_chain(cmd
, n
, me
, nextprocs
, nextdata
)
25 void *nextdata UNUSED
;
28 case WINCHAIN_ALLOC
: {
29 struct chainout_data
*tdp
= calloc(1, sizeof(struct chainout_data
));
34 struct chainout_data
*tdp
= me
;
35 tdp
->nprocs
= nextprocs
;
39 raw_printf("chainout_procs_chain: bad cmd\n");
44 /* XXX if we don't need this, take it out of the table */
46 chainout_procs_init(dir
)
56 chainout_init_nhwindows(vp
, argcp
, argv
)
61 struct chainout_data
*tdp
= vp
;
63 (*tdp
->nprocs
->win_init_nhwindows
)(argcp
, argv
);
67 chainout_player_selection(vp
)
70 struct chainout_data
*tdp
= vp
;
72 (*tdp
->nprocs
->win_player_selection
)();
79 struct chainout_data
*tdp
= vp
;
81 (*tdp
->nprocs
->win_askname
)();
85 chainout_get_nh_event(vp
)
88 struct chainout_data
*tdp
= vp
;
90 (*tdp
->nprocs
->win_get_nh_event
)();
94 chainout_exit_nhwindows(vp
, str
)
98 struct chainout_data
*tdp
= vp
;
100 (*tdp
->nprocs
->win_exit_nhwindows
)(str
);
104 chainout_suspend_nhwindows(vp
, str
)
108 struct chainout_data
*tdp
= vp
;
110 (*tdp
->nprocs
->win_suspend_nhwindows
)(str
);
114 chainout_resume_nhwindows(vp
)
117 struct chainout_data
*tdp
= vp
;
119 (*tdp
->nprocs
->win_resume_nhwindows
)();
123 chainout_create_nhwindow(vp
, type
)
127 struct chainout_data
*tdp
= vp
;
130 rv
= (*tdp
->nprocs
->win_create_nhwindow
)(type
);
136 chainout_clear_nhwindow(vp
, window
)
140 struct chainout_data
*tdp
= vp
;
142 (*tdp
->nprocs
->win_clear_nhwindow
)(window
);
146 chainout_display_nhwindow(vp
, window
, blocking
)
151 struct chainout_data
*tdp
= vp
;
153 (*tdp
->nprocs
->win_display_nhwindow
)(window
, blocking
);
157 chainout_destroy_nhwindow(vp
, window
)
161 struct chainout_data
*tdp
= vp
;
163 (*tdp
->nprocs
->win_destroy_nhwindow
)(window
);
167 chainout_curs(vp
, window
, x
, y
)
173 struct chainout_data
*tdp
= vp
;
175 (*tdp
->nprocs
->win_curs
)(window
, x
, y
);
179 chainout_putstr(vp
, window
, attr
, str
)
185 struct chainout_data
*tdp
= vp
;
187 (*tdp
->nprocs
->win_putstr
)(window
, attr
, str
);
191 chainout_putmixed(vp
, window
, attr
, str
)
197 struct chainout_data
*tdp
= vp
;
199 (*tdp
->nprocs
->win_putmixed
)(window
, attr
, str
);
203 chainout_display_file(vp
, fname
, complain
)
208 struct chainout_data
*tdp
= vp
;
210 (*tdp
->nprocs
->win_display_file
)(fname
, complain
);
214 chainout_start_menu(vp
, window
)
218 struct chainout_data
*tdp
= vp
;
220 (*tdp
->nprocs
->win_start_menu
)(window
);
224 chainout_add_menu(vp
, window
, glyph
, identifier
, ch
, gch
, attr
, str
,
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
,
243 chainout_end_menu(vp
, window
, prompt
)
248 struct chainout_data
*tdp
= vp
;
250 (*tdp
->nprocs
->win_end_menu
)(window
, prompt
);
254 chainout_select_menu(vp
, window
, how
, menu_list
)
258 menu_item
**menu_list
;
260 struct chainout_data
*tdp
= vp
;
263 rv
= (*tdp
->nprocs
->win_select_menu
)(window
, how
, (void *) menu_list
);
269 chainout_message_menu(vp
, let
, how
, mesg
)
275 struct chainout_data
*tdp
= vp
;
278 rv
= (*tdp
->nprocs
->win_message_menu
)(let
, how
, mesg
);
284 chainout_update_inventory(vp
)
287 struct chainout_data
*tdp
= vp
;
289 (*tdp
->nprocs
->win_update_inventory
)();
293 chainout_mark_synch(vp
)
296 struct chainout_data
*tdp
= vp
;
298 (*tdp
->nprocs
->win_mark_synch
)();
302 chainout_wait_synch(vp
)
305 struct chainout_data
*tdp
= vp
;
307 (*tdp
->nprocs
->win_wait_synch
)();
312 chainout_cliparound(vp
, x
, y
)
317 struct chainout_data
*tdp
= vp
;
319 (*tdp
->nprocs
->win_cliparound
)(x
, y
);
325 chainout_update_positionbar(vp
, posbar
)
329 struct chainout_data
*tdp
= vp
;
331 (*tdp
->nprocs
->win_update_positionbar
)(posbar
);
336 chainout_print_glyph(vp
, window
, x
, y
, glyph
, bkglyph
)
342 struct chainout_data
*tdp
= vp
;
344 (*tdp
->nprocs
->win_print_glyph
)(window
, x
, y
, glyph
, bkglyph
);
348 chainout_raw_print(vp
, str
)
352 struct chainout_data
*tdp
= vp
;
354 (*tdp
->nprocs
->win_raw_print
)(str
);
358 chainout_raw_print_bold(vp
, str
)
362 struct chainout_data
*tdp
= vp
;
364 (*tdp
->nprocs
->win_raw_print_bold
)(str
);
371 struct chainout_data
*tdp
= vp
;
374 rv
= (*tdp
->nprocs
->win_nhgetch
)();
380 chainout_nh_poskey(vp
, x
, y
, mod
)
386 struct chainout_data
*tdp
= vp
;
389 rv
= (*tdp
->nprocs
->win_nh_poskey
)(x
, y
, mod
);
398 struct chainout_data
*tdp
= vp
;
400 (*tdp
->nprocs
->win_nhbell
)();
404 chainout_doprev_message(vp
)
407 struct chainout_data
*tdp
= vp
;
410 rv
= (*tdp
->nprocs
->win_doprev_message
)();
416 chainout_yn_function(vp
, query
, resp
, def
)
418 const char *query
, *resp
;
421 struct chainout_data
*tdp
= vp
;
424 rv
= (*tdp
->nprocs
->win_yn_function
)(query
, resp
, def
);
430 chainout_getlin(vp
, query
, bufp
)
435 struct chainout_data
*tdp
= vp
;
437 (*tdp
->nprocs
->win_getlin
)(query
, bufp
);
441 chainout_get_ext_cmd(vp
)
444 struct chainout_data
*tdp
= vp
;
447 rv
= (*tdp
->nprocs
->win_get_ext_cmd
)();
453 chainout_number_pad(vp
, state
)
457 struct chainout_data
*tdp
= vp
;
459 (*tdp
->nprocs
->win_number_pad
)(state
);
463 chainout_delay_output(vp
)
466 struct chainout_data
*tdp
= vp
;
468 (*tdp
->nprocs
->win_delay_output
)();
473 chainout_change_color(vp
, color
, value
, reverse
)
479 struct chainout_data
*tdp
= vp
;
481 (*tdp
->nprocs
->win_change_color
)(color
, value
, reverse
);
486 chainout_change_background(vp
, bw
)
490 struct chainout_data
*tdp
= vp
;
492 (*tdp
->nprocs
->win_change_background
)(bw
);
496 chainout_set_font_name(vp
, window
, font
)
501 struct chainout_data
*tdp
= vp
;
504 rv
= (*tdp
->nprocs
->win_set_font_name
)(window
, font
);
511 trace_get_color_string(vp
)
514 struct chainout_data
*tdp
= vp
;
517 rv
= (*tdp
->nprocs
->win_get_color_string
)();
524 /* other defs that really should go away (they're tty specific) */
526 chainout_start_screen(vp
)
529 struct chainout_data
*tdp
= vp
;
531 (*tdp
->nprocs
->win_start_screen
)();
535 chainout_end_screen(vp
)
538 struct chainout_data
*tdp
= vp
;
540 (*tdp
->nprocs
->win_end_screen
)();
544 chainout_outrip(vp
, tmpwin
, how
, when
)
550 struct chainout_data
*tdp
= vp
;
552 (*tdp
->nprocs
->win_outrip
)(tmpwin
, how
, when
);
556 chainout_preference_update(vp
, pref
)
560 struct chainout_data
*tdp
= vp
;
562 (*tdp
->nprocs
->win_preference_update
)(pref
);
566 chainout_getmsghistory(vp
, init
)
570 struct chainout_data
*tdp
= vp
;
573 rv
= (*tdp
->nprocs
->win_getmsghistory
)(init
);
579 chainout_putmsghistory(vp
, msg
, is_restoring
)
582 boolean is_restoring
;
584 struct chainout_data
*tdp
= vp
;
586 (*tdp
->nprocs
->win_putmsghistory
)(msg
, is_restoring
);
589 #ifdef STATUS_VIA_WINDOWPORT
591 chainout_status_init(vp
)
594 struct chainout_data
*tdp
= vp
;
596 (*tdp
->nprocs
->win_status_init
)();
600 chainout_status_finish(vp
)
603 struct chainout_data
*tdp
= vp
;
605 (*tdp
->nprocs
->win_status_finish
)();
609 chainout_status_enablefield(vp
, fieldidx
, nm
, fmt
, enable
)
616 struct chainout_data
*tdp
= vp
;
618 (*tdp
->nprocs
->win_status_enablefield
)(fieldidx
, nm
, fmt
, enable
);
622 chainout_status_update(vp
, idx
, ptr
, chg
, percent
)
624 int idx
, chg
, percent
;
627 struct chainout_data
*tdp
= vp
;
629 (*tdp
->nprocs
->win_status_update
)(idx
, ptr
, chg
, percent
);
632 #ifdef STATUS_HILITES
634 chainout_status_threshold(vp
, fldidx
, thresholdtype
, threshold
, behavior
,
637 int fldidx
, thresholdtype
;
638 int behavior
, under
, over
;
641 struct chainout_data
*tdp
= vp
;
643 (*tdp
->nprocs
->win_status_threshold
)(fldidx
, thresholdtype
, threshold
,
644 behavior
, under
, over
);
650 chainout_can_suspend(vp
)
653 struct chainout_data
*tdp
= vp
;
656 rv
= (*tdp
->nprocs
->win_can_suspend
)();
661 struct chain_procs chainout_procs
= {
662 "-chainout", 0, /* wincap */
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
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
,
685 chainout_update_positionbar
,
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
,
692 chainout_change_color
,
694 chainout_change_background
, chainout_set_font_name
,
696 chainout_get_color_string
,
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
,
710 chainout_can_suspend
,