1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
/*
* Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
* WeeChat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* gui-gtk-color.c: color functions for Gtk GUI
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-string.h"
#include "../gui-color.h"
#include "gui-gtk.h"
struct t_gui_color gui_weechat_colors[] =
{ { -1, 0, 0, "default" },
{ WEECHAT_COLOR_BLACK, 0, 0, "black" },
{ WEECHAT_COLOR_RED, 0, 0, "red" },
{ WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" },
{ WEECHAT_COLOR_GREEN, 0, 0, "green" },
{ WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" },
{ WEECHAT_COLOR_YELLOW, 0, 0, "brown" },
{ WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" },
{ WEECHAT_COLOR_BLUE, 0, 0, "blue" },
{ WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" },
{ WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" },
{ WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" },
{ WEECHAT_COLOR_CYAN, 0, 0, "cyan" },
{ WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" },
{ WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" },
{ 0, 0, 0, NULL }
};
/*
* gui_color_search: search a color by name
* Return: number of color in WeeChat colors table
*/
int
gui_color_search (const char *color_name)
{
int i;
for (i = 0; gui_weechat_colors[i].string; i++)
{
if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
return i;
}
/* color not found */
return -1;
}
/*
* gui_color_assign: assign a WeeChat color (read from config)
*/
int
gui_color_assign (int *color, const char *color_name)
{
int i;
/* look for curses colors in table */
i = 0;
while (gui_weechat_colors[i].string)
{
if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0)
{
*color = i;
return 1;
}
i++;
}
/* color not found */
return 0;
}
/*
* gui_color_assign_by_diff: assign color by difference
* It is called when a color option is
* set with value ++X or --X, to search
* another color (for example ++1 is
* next color/alias in list)
* return 1 if ok, 0 if error
*/
int
gui_color_assign_by_diff (int *color, const char *color_name, int diff)
{
/* TODO: write this function for Gtk */
(void) color;
(void) color_name;
(void) diff;
return 1;
}
/*
* gui_color_get_weechat_colors_number: get number of available colors
*/
int
gui_color_get_weechat_colors_number ()
{
return 0;
}
/*
* gui_color_get_term_colors: get number of colors supported by terminal
*/
int
gui_color_get_term_colors ()
{
return 0;
}
/*
* gui_color_get_pair: get a pair with given foreground/background colors
*/
int
gui_color_get_pair (int fg, int bg)
{
(void) fg;
(void) bg;
return 0;
}
/*
* gui_color_weechat_get_pair: get color pair with a WeeChat color number
*/
int
gui_color_weechat_get_pair (int weechat_color)
{
(void) weechat_color;
return 0;
}
/*
* gui_color_get_name: get color name
*/
const char *
gui_color_get_name (int num_color)
{
return gui_weechat_colors[num_color].string;
}
/*
* gui_color_init_weechat: init WeeChat colors
*/
void
gui_color_init_weechat ()
{
/* TODO: write this function for Gtk */
}
/*
* gui_color_rebuild_weechat: rebuild WeeChat colors
*/
void
gui_color_rebuild_weechat ()
{
int i;
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
{
if (gui_color[i])
{
if (gui_color[i]->string)
free (gui_color[i]->string);
free (gui_color[i]);
gui_color[i] = NULL;
}
}
gui_color_init_weechat ();
}
/*
* gui_color_display_terminal_colors: display terminal colors
* This is called by command line option
* "-c" / "--colors"
*/
void
gui_color_display_terminal_colors ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_buffer_display: display content of color buffer
*/
void
gui_color_buffer_display ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_switch_colrs: switch between WeeChat and terminal colors
*/
void
gui_color_switch_colors ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_reset_pairs: reset all color pairs
*/
void
gui_color_reset_pairs ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_buffer_assign: assign color buffer to pointer if it is not yet set
*/
void
gui_color_buffer_assign ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_buffer_open: open a buffer to display colors
*/
void
gui_color_buffer_open ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_palette_build_aliases: build aliases for palette
*/
void
gui_color_palette_build_aliases ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_palette_new: create a new color in palette
*/
struct t_gui_color_palette *
gui_color_palette_new (int number, const char *value)
{
/* This function does nothing in Gtk GUI */
(void) number;
(void) value;
return NULL;
}
/*
* gui_color_palette_free: free a color in palette
*/
void
gui_color_palette_free (struct t_gui_color_palette *color_palette)
{
/* This function does nothing in Gtk GUI */
(void) color_palette;
}
/*
* gui_color_pre_init: pre-init colors
*/
void
gui_color_pre_init ()
{
int i;
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
{
gui_color[i] = NULL;
}
}
/*
* gui_color_init: init GUI colors
*/
void
gui_color_init ()
{
gui_color_init_weechat ();
}
/*
* gui_color_dump: dump colors
*/
void
gui_color_dump ()
{
/* This function does nothing in Gtk GUI */
}
/*
* gui_color_end: end GUI colors
*/
void
gui_color_end ()
{
int i;
for (i = 0; i < GUI_COLOR_NUM_COLORS; i++)
{
gui_color_free (gui_color[i]);
}
}
|