From: Richard Russon Date: Fri, 27 Sep 2019 12:57:35 +0000 (+0100) Subject: refactor: ATTR_SET() to mutt_curses_set_attr() X-Git-Tag: 2019-10-25~30^2~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f9087322269a11adde76468a6b6f22de56667ba;p=neomutt refactor: ATTR_SET() to mutt_curses_set_attr() Encapsulate a curses function to reduce dependencies. --- diff --git a/menu.c b/menu.c index e210fe7f3..27fcf5ef7 100644 --- a/menu.c +++ b/menu.c @@ -156,7 +156,7 @@ static void print_enriched_string(int index, int attr, unsigned char *s, bool do /* Combining tree fg color and another bg color requires * having use_default_colors, because the other bg color * may be undefined. */ - ATTR_SET(mutt_color_combine(ColorDefs[MT_COLOR_TREE], attr)); + mutt_curses_set_attr(mutt_color_combine(ColorDefs[MT_COLOR_TREE], attr)); #else mutt_curses_set_color(MT_COLOR_TREE); #endif @@ -279,7 +279,7 @@ static void print_enriched_string(int index, int attr, unsigned char *s, bool do n--; } if (do_color) - ATTR_SET(attr); + mutt_curses_set_attr(attr); } else if (*s == MUTT_SPECIAL_INDEX) { @@ -430,7 +430,7 @@ void menu_redraw_index(struct Menu *menu) menu_make_entry(buf, sizeof(buf), menu, i); menu_pad_string(menu, buf, sizeof(buf)); - ATTR_SET(attr); + mutt_curses_set_attr(attr); mutt_window_move(menu->indexwin, i - menu->top + menu->offset, 0); do_color = true; @@ -440,7 +440,7 @@ void menu_redraw_index(struct Menu *menu) if (C_ArrowCursor) { addstr("->"); - ATTR_SET(attr); + mutt_curses_set_attr(attr); addch(' '); } else @@ -481,7 +481,7 @@ void menu_redraw_motion(struct Menu *menu) * position the cursor for drawing. */ const int old_color = menu->menu_color(menu->oldcurrent); mutt_window_move(menu->indexwin, menu->oldcurrent + menu->offset - menu->top, 0); - ATTR_SET(old_color); + mutt_curses_set_attr(old_color); if (C_ArrowCursor) { @@ -536,7 +536,7 @@ void menu_redraw_current(struct Menu *menu) if (C_ArrowCursor) { addstr("->"); - ATTR_SET(attr); + mutt_curses_set_attr(attr); addch(' '); menu_pad_string(menu, buf, sizeof(buf)); print_enriched_string(menu->current, attr, (unsigned char *) buf, true); diff --git a/mutt_curses.c b/mutt_curses.c index 12146455a..68c32f8c6 100644 --- a/mutt_curses.c +++ b/mutt_curses.c @@ -26,6 +26,17 @@ #include "mutt_curses.h" #include "color.h" +/** + * mutt_curses_set_attr - Set the attributes for text + * @param attr Attributes to set, e.g. A_UNDERLINE + */ +void mutt_curses_set_attr(int attr) +{ +#ifdef HAVE_BKGDSET + bkgdset(attr | ' '); +#endif +} + /** * mutt_curses_set_color - Set the current colour for text * @param color Colour to set, e.g. #MT_COLOR_HEADER diff --git a/mutt_curses.h b/mutt_curses.h index 6c76e01f9..6b9df2d03 100644 --- a/mutt_curses.h +++ b/mutt_curses.h @@ -102,13 +102,8 @@ void mutt_curs_set(int cursor); #define CI_is_return(ch) (((ch) == '\r') || ((ch) == '\n')) #endif +void mutt_curses_set_attr(int attr); void mutt_curses_set_color(enum ColorId color); void mutt_resize_screen(void); -#ifdef HAVE_BKGDSET -#define ATTR_SET(X) bkgdset(X | ' ') -#else -#define ATTR_SET attrset -#endif - #endif /* MUTT_MUTT_CURSES_H */ diff --git a/pager.c b/pager.c index 84743ce7d..4389301c9 100644 --- a/pager.c +++ b/pager.c @@ -480,7 +480,7 @@ static void resolve_color(struct Line *line_info, int n, int cnt, if (color != last_color) { - ATTR_SET(color); + mutt_curses_set_attr(color); last_color = color; } } @@ -1875,7 +1875,7 @@ static int display_line(FILE *fp, LOFF_T *last_pos, struct Line **line_info, else def_color = ColorDefs[(*line_info)[m].type]; - ATTR_SET(def_color); + mutt_curses_set_attr(def_color); } if (col < pager_window->cols)