1 /***************************************************************************
2  *  Pinfo is a ncurses based lynx style info documentation browser
3  *
4  *  Copyright (C) 1999  Przemek Borys <pborys@dione.ids.pl>
5  *  Copyright (C) 2005  Bas Zoetekouw <bas@debian.org>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of version 2 of the GNU General Public License as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful, but
12  *  WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19  *  USA
20  ***************************************************************************/
21 
22 #include "common_includes.h"
23 
24 #ifdef HAVE_CURSES_COLOR
25 extern struct colours cols;
26 #endif /* HAVE_CURSES_COLOR */
27 
28 int normal;
29 int menuselected;
30 int menu;
31 int noteselected;
32 int note;
33 int topline;
34 int bottomline;
35 int manualbold;
36 int manualitalic;
37 int url;
38 int urlselected;
39 int infohighlight;
40 int searchhighlight;
41 
42 void
initcolors()43 initcolors()
44 {
45 #ifdef HAVE_CURSES_COLOR
46 	if (has_colors())
47 	{
48 		start_color();
49 #ifdef HAVE_DECL_USE_DEFAULT_COLORS
50 		use_default_colors();
51 #endif
52 		normal = COLOR_PAIR(NORMAL);	/* normal text */
53 		init_pair(NORMAL, cols.normal_fore, cols.normal_back);
54 		if (cols.normal_bold)
55 			normal |= A_BOLD;
56 		if (cols.normal_blink)
57 			normal |= A_BLINK;
58 
59 		menuselected = COLOR_PAIR(MENUSELECTED);		/* selected menu */
60 		init_pair(MENUSELECTED, cols.menuselected_fore, cols.menuselected_back);
61 		if (cols.menuselected_bold)
62 			menuselected |= A_BOLD;
63 		if (cols.menuselected_blink)
64 			menuselected |= A_BLINK;
65 
66 		menu = COLOR_PAIR(MENU);	/* just menu */
67 		init_pair(MENU, cols.menu_fore, cols.menu_back);
68 		if (cols.menu_bold)
69 			menu |= A_BOLD;
70 		if (cols.menu_blink)
71 			menu |= A_BLINK;
72 
73 		noteselected = COLOR_PAIR(NOTESELECTED);		/* selected note */
74 		init_pair(NOTESELECTED, cols.noteselected_fore, cols.noteselected_back);
75 		if (cols.noteselected_bold)
76 			noteselected |= A_BOLD;
77 		if (cols.noteselected_blink)
78 			noteselected |= A_BLINK;
79 
80 		note = COLOR_PAIR(NOTE);	/* just note */
81 		init_pair(NOTE, cols.note_fore, cols.note_back);
82 		if (cols.note_bold)
83 			note |= A_BOLD;
84 		if (cols.note_blink)
85 			note |= A_BLINK;
86 
87 		topline = COLOR_PAIR(TOPLINE);	/* topline color */
88 		init_pair(TOPLINE, cols.topline_fore, cols.topline_back);
89 		if (cols.topline_bold)
90 			topline |= A_BOLD;
91 		if (cols.topline_blink)
92 			topline |= A_BLINK;
93 
94 		bottomline = COLOR_PAIR(BOTTOMLINE);	/* bottomline color */
95 		init_pair(BOTTOMLINE, cols.bottomline_fore, cols.bottomline_back);
96 		if (cols.bottomline_bold)
97 			bottomline |= A_BOLD;
98 		if (cols.bottomline_blink)
99 			bottomline |= A_BLINK;
100 
101 		manualbold = COLOR_PAIR(MANUALBOLD);	/* manual bold color */
102 		init_pair(MANUALBOLD, cols.manualbold_fore, cols.manualbold_back);
103 		if (cols.manualbold_bold)
104 			manualbold |= A_BOLD;
105 		if (cols.manualbold_blink)
106 			manualbold |= A_BLINK;
107 
108 		manualitalic = COLOR_PAIR(MANUALITALIC);		/* manual italic color */
109 		init_pair(MANUALITALIC, cols.manualitalic_fore, cols.manualitalic_back);
110 		if (cols.manualitalic_bold)
111 			manualitalic |= A_BOLD;
112 		if (cols.manualitalic_blink)
113 			manualitalic |= A_BLINK;
114 
115 		url = COLOR_PAIR(URL);	/* url(http, ftp) color */
116 		init_pair(URL, cols.url_fore, cols.url_back);
117 		if (cols.url_bold)
118 			url |= A_BOLD;
119 		if (cols.url_blink)
120 			url |= A_BLINK;
121 
122 		urlselected = COLOR_PAIR(URLSELECTED);	/* selected url */
123 		init_pair(URLSELECTED, cols.urlselected_fore, cols.urlselected_back);
124 		if (cols.urlselected_bold)
125 			urlselected |= A_BOLD;
126 		if (cols.urlselected_blink)
127 			urlselected |= A_BLINK;
128 
129 		infohighlight = COLOR_PAIR(INFOHIGHLIGHT);	/* highlight for info quotes */
130 		init_pair(INFOHIGHLIGHT, cols.infohighlight_fore, cols.infohighlight_back);
131 		if (cols.infohighlight_bold)
132 			infohighlight |= A_BOLD;
133 		if (cols.infohighlight_blink)
134 			infohighlight |= A_BLINK;
135 
136 		searchhighlight = COLOR_PAIR(SEARCHHIGHLIGHT);	/* highlight for info quotes */
137 		init_pair(SEARCHHIGHLIGHT, cols.searchhighlight_fore, cols.searchhighlight_back);
138 		if (cols.searchhighlight_bold)
139 			searchhighlight |= A_BOLD;
140 		if (cols.searchhighlight_blink)
141 			searchhighlight |= A_BLINK;
142 	}
143 	else
144 	{
145 #endif /* HAVE_CURSES_COLOR */
146 		normal = A_NORMAL;
147 		menu = A_BOLD;
148 		note = A_BOLD;
149 		url = A_BOLD;
150 		menuselected = A_REVERSE;
151 		noteselected = A_REVERSE;
152 		urlselected = A_REVERSE;
153 		topline = A_REVERSE;
154 		bottomline = A_REVERSE;
155 		manualbold = A_BOLD;
156 		manualitalic = A_BOLD;
157 		infohighlight = A_BOLD;
158 		searchhighlight = A_BOLD;
159 #ifdef HAVE_CURSES_COLOR
160 	}
161 #endif /* HAVE_CURSES_COLOR */
162 }
163