Exemple #1
0
static boolean get_menu_coloring(char *str, int *color, int *attr)
{
    struct menucoloring *tmpmc;
    if (iflags.use_menu_color && iflags.use_color)
	for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
# ifdef MENU_COLOR_REGEX
#  ifdef MENU_COLOR_REGEX_POSIX
	    if (regexec(&tmpmc->match, str, 0, NULL, 0) == 0) {
#  else

	    if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
#  endif
# else
	    if (pmatch(tmpmc->match, str)) {
# endif
		*color = tmpmc->color;
		*attr = curses_convert_attr(tmpmc->attr);
		return TRUE;
	    }
    return FALSE;
}
#endif /* MENU_COLOR */


/* Get the maximum height for a menu */

static int menu_max_height(void)
{
    return term_rows - 2;
}
Exemple #2
0
/*
putstr(window, attr, str)
                -- Print str on the window with the given attribute.  Only
                   printable ASCII characters (040-0126) must be supported.
                   Multiple putstr()s are output on separate lines.
Attributes
                   can be one of
                        ATR_NONE (or 0)
                        ATR_ULINE
                        ATR_BOLD
                        ATR_BLINK
                        ATR_INVERSE
                   If a window-port does not support all of these, it may map
                   unsupported attributes to a supported one (e.g. map them
                   all to ATR_INVERSE).  putstr() may compress spaces out of
                   str, break str, or truncate str, if necessary for the
                   display.  Where putstr() breaks a line, it has to clear
                   to end-of-line.
                -- putstr should be implemented such that if two putstr()s
                   are done consecutively the user will see the first and
                   then the second.  In the tty port, pline() achieves this
                   by calling more() or displaying both on the same line.
*/
void curses_putstr(winid wid, int attr, const char *text)
{
    int curses_attr = curses_convert_attr(attr);
    
    /* We need to convert NetHack attributes to curses attributes */
    curses_puts(wid, curses_attr, text);
}
Exemple #3
0
/*
add_menu(winid wid, int glyph, const anything identifier,
                                char accelerator, char groupacc,
                                int attr, char *str, boolean preselected)
                -- Add a text line str to the given menu window.  If identifier
                   is 0, then the line cannot be selected (e.g. a title).
                   Otherwise, identifier is the value returned if the line is
                   selected.  Accelerator is a keyboard key that can be used
                   to select the line.  If the accelerator of a selectable
                   item is 0, the window system is free to select its own
                   accelerator.  It is up to the window-port to make the
                   accelerator visible to the user (e.g. put "a - " in front
                   of str).  The value attr is the same as in putstr().
                   Glyph is an optional glyph to accompany the line.  If
                   window port cannot or does not want to display it, this
                   is OK.  If there is no glyph applicable, then this
                   value will be NO_GLYPH.
                -- All accelerators should be in the range [A-Za-z].
                -- It is expected that callers do not mix accelerator
                   choices.  Either all selectable items have an accelerator
                   or let the window system pick them.  Don't do both.
                -- Groupacc is a group accelerator.  It may be any character
                   outside of the standard accelerator (see above) or a
                   number.  If 0, the item is unaffected by any group
                   accelerator.  If this accelerator conflicts with
                   the menu command (or their user defined alises), it loses.
                   The menu commands and aliases take care not to interfere
                   with the default object class symbols.
                -- If you want this choice to be preselected when the
                   menu is displayed, set preselected to TRUE.
*/
void curses_add_menu(winid wid, int glyph, const ANY_P * identifier,
		char accelerator, char group_accel, int attr, 
		const char *str, boolean presel)
{
    int curses_attr = curses_convert_attr(attr);

    curses_add_nhmenu_item(wid, identifier, accelerator, group_accel,
     curses_attr, str, presel);
}
Exemple #4
0
static boolean get_menu_coloring(char *str, int *color, int *attr)
{
    struct menucoloring *tmpmc;
    boolean foundcolor = FALSE, foundattr = FALSE;

    if (iflags.use_menu_color && iflags.use_color)
        for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next)
# ifdef MENU_COLOR_REGEX
#  ifdef MENU_COLOR_REGEX_POSIX
            if (regexec(&tmpmc->match, str, 0, NULL, 0) == 0) {
#  else

            if (re_search(&tmpmc->match, str, strlen(str), 0, 9999, 0) >= 0) {
#  endif
# else
            if (pmatch(tmpmc->match, str)) {
# endif
                if (!foundcolor && tmpmc->color != CLR_UNDEFINED) {
                    *color = tmpmc->color;
                    foundcolor = TRUE;
                }
                if (!foundattr && tmpmc->attr != ATR_UNDEFINED) {
                    *attr = curses_convert_attr(tmpmc->attr);
                    foundattr = TRUE;
                }
                if (foundcolor && foundattr) return TRUE;
            }
    if (foundcolor && !foundattr) *attr = curses_convert_attr(ATR_NONE);
    if (foundattr && !foundcolor) *color = NO_COLOR;
    return foundcolor || foundattr;
}
#endif /* MENU_COLOR */


/* Get the maximum height for a menu */

static int menu_max_height(void)
{
    return term_rows - 2;
}
Exemple #5
0
static attr_t
get_trouble_color(const char *stat)
{
    attr_t res = curses_color_attr(CLR_GRAY, 0);
    const struct statcolor *clr;
    for (clr = default_colors; clr->txt; clr++) {
        if (stat && !strcmp(clr->txt, stat)) {
#ifdef STATUS_COLORS
            /* Check if we have a color enabled with statuscolors */
            if (!iflags.use_status_colors)
                return curses_color_attr(CLR_GRAY, 0); /* no color configured */

            struct color_option stat_color;

            stat_color = text_color_of(clr->txt, text_colors);
            if (stat_color.color == NO_COLOR && !stat_color.attr_bits)
                return curses_color_attr(CLR_GRAY, 0);

            if (stat_color.color != NO_COLOR)
                res = curses_color_attr(stat_color.color, 0);

            res = curses_color_attr(stat_color.color, 0);
            int count;
            for (count = 0; (1 << count) <= stat_color.attr_bits; count++) {
                if (count != ATR_NONE &&
                    (stat_color.attr_bits & (1 << count)))
                    res |= curses_convert_attr(count);
            }

            return res;
#else
            return curses_color_attr(clr->color, 0);
#endif
        }
    }

    return res;
}