From 93cbd1fbb1b74d7a597ea0d9b681bdff345e1860 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Mon, 27 Apr 2015 18:43:55 +0300 Subject: [PATCH] Allow all text attributes for menu_headings --- doc/Guidebook.mn | 4 ++-- doc/Guidebook.tex | 5 ++-- src/options.c | 61 ++++++++++++----------------------------------- 3 files changed, 20 insertions(+), 50 deletions(-) diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 9466f72e5..c700b8a0d 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -2097,8 +2097,8 @@ Implemented by the Amiga, Gem and tty ports. Default '^'. .lp menu_headings Controls how the headings in a menu are highlighted. -Values are 'bold', 'inverse', or 'underline'. -Not all ports can actually display all three types. +Values are 'none', 'bold', 'dim', 'underline', 'blink', or 'inverse'. +Not all ports can actually display all types. .lp menu_invert_all Menu character accelerator to invert all items in a menu. Implemented by the Amiga, Gem, X11 and tty ports. diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index 7855d595b..2b7e2deba 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -2530,8 +2530,9 @@ Implemented by the Amiga, Gem and tty ports. Default `\verb+^+'. \item[\ib{menu\_headings}] Controls how the headings in a menu are highlighted. -Values are ``{\tt bold}'', ``{\tt inverse}'', or ``{\tt underline}''. -Not all ports can actually display all three types. +Values are ``{\tt none}'', ``{\tt bold}'', ``{\tt dim}'', +``{\tt underline}'', ``{\tt blink}'', or ``{\tt inverse}''. +Not all ports can actually display all types. \item[\ib{menu\_invert\_all}] Menu character accelerator to invert all items in a menu. Implemented by the Amiga, Gem, X11 and tty ports. diff --git a/src/options.c b/src/options.c index c5397b40d..7c0998917 100644 --- a/src/options.c +++ b/src/options.c @@ -283,7 +283,7 @@ static struct Comp_Opt 4, SET_IN_FILE }, { "menu_first_page", "jump to the first page in a menu", 4, SET_IN_FILE }, - { "menu_headings", "bold, inverse, or underline headings", 9, SET_IN_GAME }, + { "menu_headings", "text attribute for menu headings", 9, SET_IN_GAME }, { "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE }, { "menu_invert_page", "invert all items on this page of a menu", 4, SET_IN_FILE }, @@ -501,7 +501,7 @@ STATIC_OVL int FDECL(count_ape_maps, (int *, int *)); STATIC_DCL const char *FDECL(clr2colorname, (int)); STATIC_DCL const char *FDECL(attr2attrname, (int)); STATIC_DCL int NDECL(query_color); -STATIC_DCL int NDECL(query_attr); +STATIC_DCL int FDECL(query_attr, (char *)); STATIC_DCL boolean FDECL(add_menu_coloring_parsed, (char *, int, int)); STATIC_DCL void FDECL(free_one_menu_coloring, (int)); STATIC_DCL int NDECL(count_menucolors); @@ -1219,7 +1219,8 @@ query_color() } int -query_attr() +query_attr(prompt) +char *prompt; { winid tmpwin; anything any; @@ -1233,7 +1234,7 @@ query_attr() any.a_int = i + 1; add_menu(tmpwin, NO_GLYPH, &any, 0, 0, attrnames[i].attr, attrnames[i].name, MENU_UNSELECTED); } - end_menu(tmpwin, "Pick an attribute"); + end_menu(tmpwin, prompt ? prompt : "Pick an attribute"); pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); destroy_nhwindow(tmpwin); if (pick_cnt > 0) { @@ -2751,14 +2752,12 @@ goodfruit: else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { return; } - if (!strcmpi(opts,"bold")) - iflags.menu_headings = ATR_BOLD; - else if (!strcmpi(opts,"inverse")) - iflags.menu_headings = ATR_INVERSE; - else if (!strcmpi(opts,"underline")) - iflags.menu_headings = ATR_ULINE; - else - badoption(opts); + for (i = 0; i < SIZE(attrnames); i++) + if (!strcmpi(opts, attrnames[i].name)) { + iflags.menu_headings = attrnames[i].attr; + return; + } + badoption(opts); return; } @@ -3647,35 +3646,8 @@ boolean setinitial,setfromfile; } destroy_nhwindow(tmpwin); } else if (!strcmp("menu_headings", optname)) { - static const char *mhchoices[3] = {"bold", "inverse", "underline"}; - const char *npletters = "biu"; - menu_item *mode_pick = (menu_item *)0; - - tmpwin = create_nhwindow(NHW_MENU); - start_menu(tmpwin); - any = zeroany; - for (i = 0; i < SIZE(mhchoices); i++) { - any.a_int = i + 1; - add_menu(tmpwin, NO_GLYPH, &any, npletters[i], 0, - ATR_NONE, mhchoices[i], MENU_UNSELECTED); - } - end_menu(tmpwin, "How to highlight menu headings:"); - if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { - int mode = mode_pick->item.a_int - 1; - switch(mode) { - case 2: - iflags.menu_headings = ATR_ULINE; - break; - case 0: - iflags.menu_headings = ATR_BOLD; - break; - case 1: - default: - iflags.menu_headings = ATR_INVERSE; - } - free((genericptr_t)mode_pick); - } - destroy_nhwindow(tmpwin); + int mhattr = query_attr("How to highlight menu headings:"); + if (mhattr != -1) iflags.menu_headings = mhattr; } else if (!strcmp("menucolors", optname)) { int opt_idx, nmc, mcclr, mcattr; char mcbuf[BUFSZ]; @@ -3689,7 +3661,7 @@ menucolors_again: if (*mcbuf == '\033' || !*mcbuf) goto menucolors_again; mcclr = query_color(); if (mcclr == -1) goto menucolors_again; - mcattr = query_attr(); + mcattr = query_attr(NULL); if (mcattr == -1) goto menucolors_again; if (!add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) { pline("Error adding the menu color."); @@ -4083,10 +4055,7 @@ char *buf; else if (!strcmp(optname, "menu_invert_all")) Sprintf(buf, "%s", to_be_done); else if (!strcmp(optname, "menu_headings")) { - Sprintf(buf, "%s", (iflags.menu_headings == ATR_BOLD) ? - "bold" : (iflags.menu_headings == ATR_INVERSE) ? - "inverse" : (iflags.menu_headings == ATR_ULINE) ? - "underline" : "unknown"); + Sprintf(buf, "%s", attr2attrname(iflags.menu_headings)); } else if (!strcmp(optname, "menu_invert_page")) Sprintf(buf, "%s", to_be_done);