ncmpc  0.29
paint.h
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2017 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef NCMPC_PAINT_H
21 #define NCMPC_PAINT_H
22 
23 #include "colors.h"
24 #include "options.h"
25 
30 static inline void
31 row_color(WINDOW *w, enum color color, bool selected)
32 {
33  colors_use(w, color);
34 
35  if (selected)
36  wattron(w, A_REVERSE);
37  else
38  wattroff(w, A_REVERSE);
39 }
40 
45 static inline void
46 row_color_end(WINDOW *w)
47 {
48  wattroff(w, A_REVERSE);
49 }
50 
56 static inline void
57 row_clear_to_eol(WINDOW *w, unsigned width, bool selected)
58 {
59  if (selected && options.wide_cursor)
60  whline(w, ' ', width);
61  else
62  wclrtoeol(w);
63 }
64 
68 static inline void
69 row_paint_text(WINDOW *w, unsigned width,
70  enum color color, bool selected,
71  const char *text)
72 {
73  row_color(w, color, selected);
74 
75  waddstr(w, text);
76 
77  /* erase the unused space after the text */
78  row_clear_to_eol(w, width, selected);
79 }
80 
81 #endif
color
Definition: colors.h:29
options_t options
void colors_use(WINDOW *w, enum color id)
bool wide_cursor
Definition: options.h:64