MCPcopy Index your code
hub / github.com/NetHack/NetHack / handler_msg_window

Function handler_msg_window

src/options.c:5831–5890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5829}
5830
5831staticfn int
5832handler_msg_window(void)
5833{
5834#if PREV_MSGS /* tty or curses */
5835 winid tmpwin;
5836 anything any;
5837 boolean is_tty = WINDOWPORT(tty), is_curses = WINDOWPORT(curses);
5838 int clr = NO_COLOR;
5839
5840 if (is_tty || is_curses) {
5841 /* by Christian W. Cooper */
5842 boolean chngd;
5843 int i, n;
5844 char buf[BUFSZ], c,
5845 sep = iflags.menu_tab_sep ? '\t' : ' ',
5846 old_prevmsg_window = iflags.prevmsg_window;
5847 menu_item *window_pick = (menu_item *) 0;
5848
5849 tmpwin = create_nhwindow(NHW_MENU);
5850 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
5851 any = cg.zeroany;
5852
5853 for (i = 0; i < SIZE(menutype); i++) {
5854 if (i < 2 && is_curses)
5855 continue;
5856 Sprintf(buf, "%-12.12s%c%.60s", msgwind[i][0], sep,
5857 msgwind[i][1]);
5858 any.a_char = c = *msgwind[i][0];
5859 add_menu(tmpwin, &nul_glyphinfo, &any, *buf, 0,
5860 ATR_NONE, clr, buf,
5861 (c == iflags.prevmsg_window) ? MENU_ITEMFLAGS_SELECTED
5862 : MENU_ITEMFLAGS_NONE);
5863 /* second line is prefixed by spaces that "c - " would use */
5864 Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, msgwind[i][2]);
5865 add_menu_str(tmpwin, buf);
5866 }
5867 end_menu(tmpwin, "Select message history display type:");
5868 n = select_menu(tmpwin, PICK_ONE, &window_pick);
5869 if (n > 0) {
5870 c = window_pick[0].item.a_char;
5871 /* if there are two picks, use the one that wasn't pre-selected */
5872 if (n > 1 && c == old_prevmsg_window)
5873 c = window_pick[1].item.a_char;
5874 iflags.prevmsg_window = c;
5875 free((genericptr_t) window_pick);
5876 }
5877 destroy_nhwindow(tmpwin);
5878 chngd = (iflags.prevmsg_window != old_prevmsg_window);
5879 if (chngd || flags.verbose) {
5880 (void) optfn_msg_window(opt_msg_window, get_val,
5881 FALSE, buf, empty_optstr);
5882 pline("'msg_window' %.20s \"%.20s\".",
5883 chngd ? "changed to" : "is still", buf);
5884 }
5885 } else
5886#endif /* PREV_MSGS (for tty or curses) */
5887 pline("'%s' option is not supported for '%s'.",
5888 allopt[opt_msg_window].name, windowprocs.name);

Callers 1

optfn_msg_windowFunction · 0.85

Calls 5

add_menuFunction · 0.85
add_menu_strFunction · 0.85
select_menuFunction · 0.85
optfn_msg_windowFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected