CRT.c 24.6 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
2
/*
htop - CRT.c
Hisham Muhammad's avatar
Hisham Muhammad committed
3
(C) 2004-2011 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
4
5
6
7
8
9
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

#include "CRT.h"

Hisham Muhammad's avatar
Hisham Muhammad committed
10
11
12
#include "config.h"
#include "String.h"

Hisham Muhammad's avatar
Hisham Muhammad committed
13
14
15
#include <curses.h>
#include <signal.h>
#include <stdlib.h>
16
#ifdef HAVE_EXECINFO_H
17
#include <execinfo.h>
18
#endif
Hisham Muhammad's avatar
Hisham Muhammad committed
19
20
21

#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)

Hisham Muhammad's avatar
Hisham Muhammad committed
22
23
24
25
26
27
28
#define COLORSCHEME_DEFAULT 0
#define COLORSCHEME_MONOCHROME 1
#define COLORSCHEME_BLACKONWHITE 2
#define COLORSCHEME_BLACKONWHITE2 3
#define COLORSCHEME_MIDNIGHT 4
#define COLORSCHEME_BLACKNIGHT 5

Hisham Muhammad's avatar
Hisham Muhammad committed
29
30
31
32
33
34
35
36
37
38
39
40
#define Black COLOR_BLACK
#define Red COLOR_RED
#define Green COLOR_GREEN
#define Yellow COLOR_YELLOW
#define Blue COLOR_BLUE
#define Magenta COLOR_MAGENTA
#define Cyan COLOR_CYAN
#define White COLOR_WHITE

//#link curses

/*{
Hisham Muhammad's avatar
Hisham Muhammad committed
41
#include <stdbool.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

typedef enum ColorElements_ {
   RESET_COLOR,
   DEFAULT_COLOR,
   FUNCTION_BAR,
   FUNCTION_KEY,
   FAILED_SEARCH,
   PANEL_HEADER_FOCUS,
   PANEL_HEADER_UNFOCUS,
   PANEL_HIGHLIGHT_FOCUS,
   PANEL_HIGHLIGHT_UNFOCUS,
   LARGE_NUMBER,
   METER_TEXT,
   METER_VALUE,
   LED_COLOR,
   UPTIME,
Hisham Muhammad's avatar
Hisham Muhammad committed
58
   BATTERY,
Hisham Muhammad's avatar
Hisham Muhammad committed
59
60
61
62
63
64
65
66
67
68
69
   TASKS_RUNNING,
   SWAP,
   PROCESS,
   PROCESS_SHADOW,
   PROCESS_TAG,
   PROCESS_MEGABYTES,
   PROCESS_TREE,
   PROCESS_R_STATE,
   PROCESS_BASENAME,
   PROCESS_HIGH_PRIORITY,
   PROCESS_LOW_PRIORITY,
70
71
   PROCESS_THREAD,
   PROCESS_THREAD_BASENAME,
Hisham Muhammad's avatar
Hisham Muhammad committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
   BAR_BORDER,
   BAR_SHADOW,
   GRAPH_1,
   GRAPH_2,
   GRAPH_3,
   GRAPH_4,
   GRAPH_5,
   GRAPH_6,
   GRAPH_7,
   GRAPH_8,
   GRAPH_9,
   MEMORY_USED,
   MEMORY_BUFFERS,
   MEMORY_CACHE,
   LOAD,
   LOAD_AVERAGE_FIFTEEN,
   LOAD_AVERAGE_FIVE,
   LOAD_AVERAGE_ONE,
   CHECK_BOX,
   CHECK_MARK,
   CHECK_TEXT,
   CLOCK,
94
95
   HELP_BOLD,
   HOSTNAME,
Hisham Muhammad's avatar
Hisham Muhammad committed
96
97
98
   CPU_NICE,
   CPU_NORMAL,
   CPU_KERNEL,
99
100
101
   CPU_IOWAIT,
   CPU_IRQ,
   CPU_SOFTIRQ,
102
103
   CPU_STEAL,
   CPU_GUEST,
Hisham Muhammad's avatar
Hisham Muhammad committed
104
105
106
107
108
109
110
   LAST_COLORELEMENT
} ColorElements;

}*/

// TODO: centralize these in Settings.

Hisham Muhammad's avatar
Hisham Muhammad committed
111
112
static bool CRT_hasColors;

113
int CRT_delay = 0;
Hisham Muhammad's avatar
Hisham Muhammad committed
114

115
int CRT_colorScheme = 0;
Hisham Muhammad's avatar
Hisham Muhammad committed
116

117
int CRT_colors[LAST_COLORELEMENT] = { 0 };
Hisham Muhammad's avatar
Hisham Muhammad committed
118

119
120
int CRT_cursorX = 0;

121
122
char* CRT_termType;

123
124
void *backtraceArray[128];

Hisham Muhammad's avatar
Hisham Muhammad committed
125
126
static void CRT_handleSIGSEGV(int sgn) {
   (void) sgn;
127
   CRT_done();
128
   #if __linux
129
   fprintf(stderr, "\n\nhtop " VERSION " aborting. Please report bug at http://htop.sf.net\n");
130
   #ifdef HAVE_EXECINFO_H
131
   size_t size = backtrace(backtraceArray, sizeof(backtraceArray) / sizeof(void *));
132
133
   fprintf(stderr, "Backtrace: \n");
   backtrace_symbols_fd(backtraceArray, size, 2);
Hisham Muhammad's avatar
Hisham Muhammad committed
134
135
136
137
138
   fprintf(stderr, "\nAdditionally, in order to make the above backtrace useful,");
   fprintf(stderr, "\nplease also run the following command to generate a disassembly of your binary:");
   fprintf(stderr, "\n\n   objdump -d `which htop` > ~/htop.objdump");
   fprintf(stderr, "\n\nand then attach the file ~/htop.objdump to your bug report.");
   fprintf(stderr, "\n\nThank you for helping to improve htop!\n\n");
139
140
141
142
   #endif
   #else
   fprintf(stderr, "\n\nhtop " VERSION " aborting. Unsupported platform.\n");
   #endif
143
   abort();
144
145
}

Hisham Muhammad's avatar
Hisham Muhammad committed
146
147
static void CRT_handleSIGTERM(int sgn) {
   (void) sgn;
148
149
150
151
   CRT_done();
   exit(0);
}

Hisham Muhammad's avatar
Hisham Muhammad committed
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// TODO: pass an instance of Settings instead.

void CRT_init(int delay, int colorScheme) {
   initscr();
   noecho();
   CRT_delay = delay;
   CRT_colorScheme = colorScheme;
   halfdelay(CRT_delay);
   nonl();
   intrflush(stdscr, false);
   keypad(stdscr, true);
   curs_set(0);
   if (has_colors()) {
      start_color();
      CRT_hasColors = true;
   } else {
      CRT_hasColors = false;
   }
170
171
   CRT_termType = getenv("TERM");
   if (String_eq(CRT_termType, "xterm") || String_eq(CRT_termType, "xterm-color") || String_eq(CRT_termType, "vt220")) {
Hisham Muhammad's avatar
Hisham Muhammad committed
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
      define_key("\033[H", KEY_HOME);
      define_key("\033[F", KEY_END);
      define_key("\033OP", KEY_F(1));
      define_key("\033OQ", KEY_F(2));
      define_key("\033OR", KEY_F(3));
      define_key("\033OS", KEY_F(4));
      define_key("\033[11~", KEY_F(1));
      define_key("\033[12~", KEY_F(2));
      define_key("\033[13~", KEY_F(3));
      define_key("\033[14~", KEY_F(4));
      define_key("\033[17;2~", KEY_F(18));
   }
#ifndef DEBUG
   signal(11, CRT_handleSIGSEGV);
#endif
   signal(SIGTERM, CRT_handleSIGTERM);
   use_default_colors();
   if (!has_colors())
      CRT_colorScheme = 1;
   CRT_setColors(CRT_colorScheme);

   mousemask(BUTTON1_CLICKED, NULL);
}

void CRT_done() {
   curs_set(1);
   endwin();
}

int CRT_readKey() {
   nocbreak();
   cbreak();
Hisham Muhammad's avatar
Hisham Muhammad committed
204
   nodelay(stdscr, FALSE);
Hisham Muhammad's avatar
Hisham Muhammad committed
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
   int ret = getch();
   halfdelay(CRT_delay);
   return ret;
}

void CRT_disableDelay() {
   nocbreak();
   cbreak();
   nodelay(stdscr, TRUE);
}

void CRT_enableDelay() {
   halfdelay(CRT_delay);
}

void CRT_setColors(int colorScheme) {
   CRT_colorScheme = colorScheme;
   if (colorScheme == COLORSCHEME_BLACKNIGHT) {
      for (int i = 0; i < 8; i++)
         for (int j = 0; j < 8; j++)
            init_pair((7-i)*8+j, i, j);
   } else {
      for (int i = 0; i < 8; i++) 
         for (int j = 0; j < 8; j++)
            init_pair((7-i)*8+j, i, (j==0?-1:j));
   }

   if (colorScheme == COLORSCHEME_MONOCHROME) {
      CRT_colors[RESET_COLOR] = A_NORMAL;
      CRT_colors[DEFAULT_COLOR] = A_NORMAL;
      CRT_colors[FUNCTION_BAR] = A_REVERSE;
      CRT_colors[FUNCTION_KEY] = A_NORMAL;
      CRT_colors[PANEL_HEADER_FOCUS] = A_REVERSE;
      CRT_colors[PANEL_HEADER_UNFOCUS] = A_REVERSE;
239
240
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = A_REVERSE;
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = A_BOLD;
Hisham Muhammad's avatar
Hisham Muhammad committed
241
242
      CRT_colors[FAILED_SEARCH] = A_REVERSE | A_BOLD;
      CRT_colors[UPTIME] = A_BOLD;
Hisham Muhammad's avatar
Hisham Muhammad committed
243
      CRT_colors[BATTERY] = A_BOLD;
Hisham Muhammad's avatar
Hisham Muhammad committed
244
245
246
247
248
249
250
251
252
253
254
255
256
257
      CRT_colors[LARGE_NUMBER] = A_BOLD;
      CRT_colors[METER_TEXT] = A_NORMAL;
      CRT_colors[METER_VALUE] = A_BOLD;
      CRT_colors[LED_COLOR] = A_NORMAL;
      CRT_colors[TASKS_RUNNING] = A_BOLD;
      CRT_colors[PROCESS] = A_NORMAL;
      CRT_colors[PROCESS_SHADOW] = A_DIM;
      CRT_colors[PROCESS_TAG] = A_BOLD;
      CRT_colors[PROCESS_MEGABYTES] = A_BOLD;
      CRT_colors[PROCESS_BASENAME] = A_BOLD;
      CRT_colors[PROCESS_TREE] = A_BOLD;
      CRT_colors[PROCESS_R_STATE] = A_BOLD;
      CRT_colors[PROCESS_HIGH_PRIORITY] = A_BOLD;
      CRT_colors[PROCESS_LOW_PRIORITY] = A_DIM;
258
259
      CRT_colors[PROCESS_THREAD] = A_BOLD;
      CRT_colors[PROCESS_THREAD_BASENAME] = A_REVERSE;
Hisham Muhammad's avatar
Hisham Muhammad committed
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
      CRT_colors[BAR_BORDER] = A_BOLD;
      CRT_colors[BAR_SHADOW] = A_DIM;
      CRT_colors[SWAP] = A_BOLD;
      CRT_colors[GRAPH_1] = A_BOLD;
      CRT_colors[GRAPH_2] = A_BOLD;
      CRT_colors[GRAPH_3] = A_BOLD;
      CRT_colors[GRAPH_4] = A_NORMAL;
      CRT_colors[GRAPH_5] = A_NORMAL;
      CRT_colors[GRAPH_6] = A_NORMAL;
      CRT_colors[GRAPH_7] = A_DIM;
      CRT_colors[GRAPH_8] = A_DIM;
      CRT_colors[GRAPH_9] = A_DIM;
      CRT_colors[MEMORY_USED] = A_BOLD;
      CRT_colors[MEMORY_BUFFERS] = A_NORMAL;
      CRT_colors[MEMORY_CACHE] = A_NORMAL;
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = A_DIM;
      CRT_colors[LOAD_AVERAGE_FIVE] = A_NORMAL;
      CRT_colors[LOAD_AVERAGE_ONE] = A_BOLD;
      CRT_colors[LOAD] = A_BOLD;
      CRT_colors[HELP_BOLD] = A_BOLD;
      CRT_colors[CLOCK] = A_BOLD;
      CRT_colors[CHECK_BOX] = A_BOLD;
      CRT_colors[CHECK_MARK] = A_NORMAL;
      CRT_colors[CHECK_TEXT] = A_NORMAL;
284
285
286
287
      CRT_colors[HOSTNAME] = A_BOLD;
      CRT_colors[CPU_NICE] = A_NORMAL;
      CRT_colors[CPU_NORMAL] = A_BOLD;
      CRT_colors[CPU_KERNEL] = A_BOLD;
288
      CRT_colors[CPU_IOWAIT] = A_NORMAL;
289
290
      CRT_colors[CPU_IRQ] = A_BOLD;
      CRT_colors[CPU_SOFTIRQ] = A_BOLD;
291
292
      CRT_colors[CPU_STEAL] = A_REVERSE;
      CRT_colors[CPU_GUEST] = A_REVERSE;
Hisham Muhammad's avatar
Hisham Muhammad committed
293
294
295
296
297
298
299
300
301
302
303
   } else if (CRT_colorScheme == COLORSCHEME_BLACKONWHITE) {
      CRT_colors[RESET_COLOR] = ColorPair(Black,White);
      CRT_colors[DEFAULT_COLOR] = ColorPair(Black,White);
      CRT_colors[FUNCTION_BAR] = ColorPair(Black,Cyan);
      CRT_colors[FUNCTION_KEY] = ColorPair(Black,White);
      CRT_colors[PANEL_HEADER_FOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Blue,White);
      CRT_colors[FAILED_SEARCH] = ColorPair(Red,Cyan);
      CRT_colors[UPTIME] = ColorPair(Yellow,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
304
      CRT_colors[BATTERY] = ColorPair(Yellow,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
305
306
307
308
309
310
311
312
313
      CRT_colors[LARGE_NUMBER] = ColorPair(Red,White);
      CRT_colors[METER_TEXT] = ColorPair(Blue,White);
      CRT_colors[METER_VALUE] = ColorPair(Black,White);
      CRT_colors[LED_COLOR] = ColorPair(Green,White);
      CRT_colors[TASKS_RUNNING] = ColorPair(Green,White);
      CRT_colors[PROCESS] = ColorPair(Black,White);
      CRT_colors[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,White);
      CRT_colors[PROCESS_TAG] = ColorPair(White,Blue);
      CRT_colors[PROCESS_MEGABYTES] = ColorPair(Blue,White);
314
315
      CRT_colors[PROCESS_BASENAME] = ColorPair(Blue,White);
      CRT_colors[PROCESS_TREE] = ColorPair(Green,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
316
317
318
      CRT_colors[PROCESS_R_STATE] = ColorPair(Green,White);
      CRT_colors[PROCESS_HIGH_PRIORITY] = ColorPair(Red,White);
      CRT_colors[PROCESS_LOW_PRIORITY] = ColorPair(Red,White);
319
320
      CRT_colors[PROCESS_THREAD] = ColorPair(Blue,White);
      CRT_colors[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
      CRT_colors[BAR_BORDER] = ColorPair(Blue,White);
      CRT_colors[BAR_SHADOW] = ColorPair(Black,White);
      CRT_colors[SWAP] = ColorPair(Red,White);
      CRT_colors[GRAPH_1] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_2] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_3] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_4] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_5] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_6] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_7] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_8] = ColorPair(Yellow,White);
      CRT_colors[GRAPH_9] = ColorPair(Yellow,White);
      CRT_colors[MEMORY_USED] = ColorPair(Green,White);
      CRT_colors[MEMORY_BUFFERS] = ColorPair(Cyan,White);
      CRT_colors[MEMORY_CACHE] = ColorPair(Yellow,White);
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = ColorPair(Black,White);
      CRT_colors[LOAD_AVERAGE_FIVE] = ColorPair(Black,White);
      CRT_colors[LOAD_AVERAGE_ONE] = ColorPair(Black,White);
      CRT_colors[LOAD] = ColorPair(Black,White);
      CRT_colors[HELP_BOLD] = ColorPair(Blue,White);
341
      CRT_colors[CLOCK] = ColorPair(Black,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
342
343
344
      CRT_colors[CHECK_BOX] = ColorPair(Blue,White);
      CRT_colors[CHECK_MARK] = ColorPair(Black,White);
      CRT_colors[CHECK_TEXT] = ColorPair(Black,White);
345
346
347
348
      CRT_colors[HOSTNAME] = ColorPair(Black,White);
      CRT_colors[CPU_NICE] = ColorPair(Cyan,White);
      CRT_colors[CPU_NORMAL] = ColorPair(Green,White);
      CRT_colors[CPU_KERNEL] = ColorPair(Red,White);
349
      CRT_colors[CPU_IOWAIT] = A_BOLD | ColorPair(Black, White);
350
351
      CRT_colors[CPU_IRQ] = ColorPair(Blue,White);
      CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,White);
352
353
      CRT_colors[CPU_STEAL] = ColorPair(Cyan,White);
      CRT_colors[CPU_GUEST] = ColorPair(Cyan,White);
Hisham Muhammad's avatar
Hisham Muhammad committed
354
355
356
357
358
359
360
361
362
363
364
   } else if (CRT_colorScheme == COLORSCHEME_BLACKONWHITE2) {
      CRT_colors[RESET_COLOR] = ColorPair(Black,Black);
      CRT_colors[DEFAULT_COLOR] = ColorPair(Black,Black);
      CRT_colors[FUNCTION_BAR] = ColorPair(Black,Cyan);
      CRT_colors[FUNCTION_KEY] = ColorPair(Black,Black);
      CRT_colors[PANEL_HEADER_FOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Blue,Black);
      CRT_colors[FAILED_SEARCH] = ColorPair(Red,Cyan);
      CRT_colors[UPTIME] = ColorPair(Yellow,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
365
      CRT_colors[BATTERY] = ColorPair(Yellow,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
366
367
368
369
370
371
372
373
374
375
376
377
378
379
      CRT_colors[LARGE_NUMBER] = ColorPair(Red,Black);
      CRT_colors[METER_TEXT] = ColorPair(Blue,Black);
      CRT_colors[METER_VALUE] = ColorPair(Black,Black);
      CRT_colors[LED_COLOR] = ColorPair(Green,Black);
      CRT_colors[TASKS_RUNNING] = ColorPair(Green,Black);
      CRT_colors[PROCESS] = ColorPair(Black,Black);
      CRT_colors[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[PROCESS_TAG] = ColorPair(White,Blue);
      CRT_colors[PROCESS_MEGABYTES] = ColorPair(Blue,Black);
      CRT_colors[PROCESS_BASENAME] = ColorPair(Green,Black);
      CRT_colors[PROCESS_TREE] = ColorPair(Blue,Black);
      CRT_colors[PROCESS_R_STATE] = ColorPair(Green,Black);
      CRT_colors[PROCESS_HIGH_PRIORITY] = ColorPair(Red,Black);
      CRT_colors[PROCESS_LOW_PRIORITY] = ColorPair(Red,Black);
380
381
      CRT_colors[PROCESS_THREAD] = ColorPair(Blue,Black);
      CRT_colors[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
      CRT_colors[BAR_BORDER] = ColorPair(Blue,Black);
      CRT_colors[BAR_SHADOW] = ColorPair(Black,Black);
      CRT_colors[SWAP] = ColorPair(Red,Black);
      CRT_colors[GRAPH_1] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_2] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_3] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_4] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_5] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_6] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_7] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_8] = ColorPair(Yellow,Black);
      CRT_colors[GRAPH_9] = ColorPair(Yellow,Black);
      CRT_colors[MEMORY_USED] = ColorPair(Green,Black);
      CRT_colors[MEMORY_BUFFERS] = ColorPair(Cyan,Black);
      CRT_colors[MEMORY_CACHE] = ColorPair(Yellow,Black);
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = ColorPair(Black,Black);
      CRT_colors[LOAD_AVERAGE_FIVE] = ColorPair(Black,Black);
      CRT_colors[LOAD_AVERAGE_ONE] = ColorPair(Black,Black);
      CRT_colors[LOAD] = ColorPair(White,Black);
      CRT_colors[HELP_BOLD] = ColorPair(Blue,Black);
      CRT_colors[CLOCK] = ColorPair(White,Black);
      CRT_colors[CHECK_BOX] = ColorPair(Blue,Black);
      CRT_colors[CHECK_MARK] = ColorPair(Black,Black);
      CRT_colors[CHECK_TEXT] = ColorPair(Black,Black);
406
407
408
409
      CRT_colors[HOSTNAME] = ColorPair(White,Black);
      CRT_colors[CPU_NICE] = ColorPair(Cyan,Black);
      CRT_colors[CPU_NORMAL] = ColorPair(Green,Black);
      CRT_colors[CPU_KERNEL] = ColorPair(Red,Black);
410
      CRT_colors[CPU_IOWAIT] = A_BOLD | ColorPair(Black, Black);
411
412
      CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Blue,Black);
      CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,Black);
413
414
      CRT_colors[CPU_STEAL] = ColorPair(Black,Black);
      CRT_colors[CPU_GUEST] = ColorPair(Black,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
415
416
417
418
419
420
421
422
423
424
425
   } else if (CRT_colorScheme == COLORSCHEME_MIDNIGHT) {
      CRT_colors[RESET_COLOR] = ColorPair(White,Blue);
      CRT_colors[DEFAULT_COLOR] = ColorPair(White,Blue);
      CRT_colors[FUNCTION_BAR] = ColorPair(Black,Cyan);
      CRT_colors[FUNCTION_KEY] = A_NORMAL;
      CRT_colors[PANEL_HEADER_FOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,White);
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[FAILED_SEARCH] = ColorPair(Red,Cyan);
      CRT_colors[UPTIME] = A_BOLD | ColorPair(Yellow,Blue);
Hisham Muhammad's avatar
Hisham Muhammad committed
426
      CRT_colors[BATTERY] = A_BOLD | ColorPair(Yellow,Blue);
Hisham Muhammad's avatar
Hisham Muhammad committed
427
428
429
430
431
432
433
434
435
436
437
438
439
440
      CRT_colors[LARGE_NUMBER] = A_BOLD | ColorPair(Red,Blue);
      CRT_colors[METER_TEXT] = ColorPair(Cyan,Blue);
      CRT_colors[METER_VALUE] = A_BOLD | ColorPair(Cyan,Blue);
      CRT_colors[LED_COLOR] = ColorPair(Green,Blue);
      CRT_colors[TASKS_RUNNING] = A_BOLD | ColorPair(Green,Blue);
      CRT_colors[PROCESS] = ColorPair(White,Blue);
      CRT_colors[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Blue);
      CRT_colors[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[PROCESS_MEGABYTES] = ColorPair(Cyan,Blue);
      CRT_colors[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan,Blue);
      CRT_colors[PROCESS_TREE] = ColorPair(Cyan,Blue);
      CRT_colors[PROCESS_R_STATE] = ColorPair(Green,Blue);
      CRT_colors[PROCESS_HIGH_PRIORITY] = ColorPair(Red,Blue);
      CRT_colors[PROCESS_LOW_PRIORITY] = ColorPair(Red,Blue);
441
442
      CRT_colors[PROCESS_THREAD] = ColorPair(Green,Blue);
      CRT_colors[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Green,Blue);
Hisham Muhammad's avatar
Hisham Muhammad committed
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
      CRT_colors[BAR_BORDER] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[BAR_SHADOW] = ColorPair(Cyan,Blue);
      CRT_colors[SWAP] = ColorPair(Red,Blue);
      CRT_colors[GRAPH_1] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_2] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_3] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_4] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_5] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_6] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_7] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_8] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[GRAPH_9] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[MEMORY_USED] = A_BOLD | ColorPair(Green,Blue);
      CRT_colors[MEMORY_BUFFERS] = A_BOLD | ColorPair(Cyan,Blue);
      CRT_colors[MEMORY_CACHE] = A_BOLD | ColorPair(Yellow,Blue);
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = A_BOLD | ColorPair(Black,Blue);
      CRT_colors[LOAD_AVERAGE_FIVE] = A_NORMAL | ColorPair(White,Blue);
      CRT_colors[LOAD_AVERAGE_ONE] = A_BOLD | ColorPair(White,Blue);
      CRT_colors[LOAD] = A_BOLD | ColorPair(White,Blue);
      CRT_colors[HELP_BOLD] = A_BOLD | ColorPair(Cyan,Blue);
      CRT_colors[CLOCK] = ColorPair(White,Blue);
      CRT_colors[CHECK_BOX] = ColorPair(Cyan,Blue);
      CRT_colors[CHECK_MARK] = A_BOLD | ColorPair(White,Blue);
      CRT_colors[CHECK_TEXT] = A_NORMAL | ColorPair(White,Blue);
467
468
469
470
471
      CRT_colors[HOSTNAME] = ColorPair(White,Blue);
      CRT_colors[CPU_NICE] = A_BOLD | ColorPair(Cyan,Blue);
      CRT_colors[CPU_NORMAL] = A_BOLD | ColorPair(Green,Blue);
      CRT_colors[CPU_KERNEL] = A_BOLD | ColorPair(Red,Blue);
      CRT_colors[CPU_IOWAIT] = A_BOLD | ColorPair(Blue,Blue);
472
473
      CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Black,Blue);
      CRT_colors[CPU_SOFTIRQ] = ColorPair(Black,Blue);
474
475
      CRT_colors[CPU_STEAL] = ColorPair(White,Blue);
      CRT_colors[CPU_GUEST] = ColorPair(White,Blue);
Hisham Muhammad's avatar
Hisham Muhammad committed
476
477
478
479
480
481
482
483
484
485
486
   } else if (CRT_colorScheme == COLORSCHEME_BLACKNIGHT) {
      CRT_colors[RESET_COLOR] = ColorPair(Cyan,Black);
      CRT_colors[DEFAULT_COLOR] = ColorPair(Cyan,Black);
      CRT_colors[FUNCTION_BAR] = ColorPair(Black,Green);
      CRT_colors[FUNCTION_KEY] = ColorPair(Cyan,Black);
      CRT_colors[PANEL_HEADER_FOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Black,White);
      CRT_colors[FAILED_SEARCH] = ColorPair(Red,Cyan);
      CRT_colors[UPTIME] = ColorPair(Green,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
487
      CRT_colors[BATTERY] = ColorPair(Green,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
488
489
490
491
492
493
494
495
496
497
498
      CRT_colors[LARGE_NUMBER] = A_BOLD | ColorPair(Red,Black);
      CRT_colors[METER_TEXT] = ColorPair(Cyan,Black);
      CRT_colors[METER_VALUE] = ColorPair(Green,Black);
      CRT_colors[LED_COLOR] = ColorPair(Green,Black);
      CRT_colors[TASKS_RUNNING] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[PROCESS] = ColorPair(Cyan,Black);
      CRT_colors[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black);
      CRT_colors[PROCESS_MEGABYTES] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[PROCESS_BASENAME] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[PROCESS_TREE] = ColorPair(Cyan,Black);
499
500
      CRT_colors[PROCESS_THREAD] = ColorPair(Green,Black);
      CRT_colors[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
      CRT_colors[PROCESS_R_STATE] = ColorPair(Green,Black);
      CRT_colors[PROCESS_HIGH_PRIORITY] = ColorPair(Red,Black);
      CRT_colors[PROCESS_LOW_PRIORITY] = ColorPair(Red,Black);
      CRT_colors[BAR_BORDER] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[BAR_SHADOW] = ColorPair(Cyan,Black);
      CRT_colors[SWAP] = ColorPair(Red,Black);
      CRT_colors[GRAPH_1] = A_BOLD | ColorPair(Red,Black);
      CRT_colors[GRAPH_2] = ColorPair(Red,Black);
      CRT_colors[GRAPH_3] = A_BOLD | ColorPair(Yellow,Black);
      CRT_colors[GRAPH_4] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[GRAPH_5] = ColorPair(Green,Black);
      CRT_colors[GRAPH_6] = ColorPair(Cyan,Black);
      CRT_colors[GRAPH_7] = A_BOLD | ColorPair(Blue,Black);
      CRT_colors[GRAPH_8] = ColorPair(Blue,Black);
      CRT_colors[GRAPH_9] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[MEMORY_USED] = ColorPair(Green,Black);
      CRT_colors[MEMORY_BUFFERS] = ColorPair(Blue,Black);
      CRT_colors[MEMORY_CACHE] = ColorPair(Yellow,Black);
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = ColorPair(Green,Black);
      CRT_colors[LOAD_AVERAGE_FIVE] = ColorPair(Green,Black);
      CRT_colors[LOAD_AVERAGE_ONE] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[LOAD] = A_BOLD;
      CRT_colors[HELP_BOLD] = A_BOLD | ColorPair(Cyan,Black);
524
      CRT_colors[CLOCK] = ColorPair(Green,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
525
526
527
      CRT_colors[CHECK_BOX] = ColorPair(Green,Black);
      CRT_colors[CHECK_MARK] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[CHECK_TEXT] = ColorPair(Cyan,Black);
528
529
530
531
      CRT_colors[HOSTNAME] = ColorPair(Green,Black);
      CRT_colors[CPU_NICE] = ColorPair(Blue,Black);
      CRT_colors[CPU_NORMAL] = ColorPair(Green,Black);
      CRT_colors[CPU_KERNEL] = ColorPair(Red,Black);
532
533
534
      CRT_colors[CPU_IOWAIT] = ColorPair(Yellow,Black);
      CRT_colors[CPU_IRQ] = A_BOLD | ColorPair(Blue,Black);
      CRT_colors[CPU_SOFTIRQ] = ColorPair(Blue,Black);
535
536
      CRT_colors[CPU_STEAL] = ColorPair(Cyan,Black);
      CRT_colors[CPU_GUEST] = ColorPair(Cyan,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
537
538
539
540
541
542
543
544
545
546
547
548
   } else {
      /* Default */
      CRT_colors[RESET_COLOR] = ColorPair(White,Black);
      CRT_colors[DEFAULT_COLOR] = ColorPair(White,Black);
      CRT_colors[FUNCTION_BAR] = ColorPair(Black,Cyan);
      CRT_colors[FUNCTION_KEY] = ColorPair(White,Black);
      CRT_colors[PANEL_HEADER_FOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HEADER_UNFOCUS] = ColorPair(Black,Green);
      CRT_colors[PANEL_HIGHLIGHT_FOCUS] = ColorPair(Black,Cyan);
      CRT_colors[PANEL_HIGHLIGHT_UNFOCUS] = ColorPair(Black,White);
      CRT_colors[FAILED_SEARCH] = ColorPair(Red,Cyan);
      CRT_colors[UPTIME] = A_BOLD | ColorPair(Cyan,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
549
      CRT_colors[BATTERY] = A_BOLD | ColorPair(Cyan,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
550
551
552
553
554
555
556
557
558
559
560
561
562
563
      CRT_colors[LARGE_NUMBER] = A_BOLD | ColorPair(Red,Black);
      CRT_colors[METER_TEXT] = ColorPair(Cyan,Black);
      CRT_colors[METER_VALUE] = A_BOLD | ColorPair(Cyan,Black);
      CRT_colors[LED_COLOR] = ColorPair(Green,Black);
      CRT_colors[TASKS_RUNNING] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[PROCESS] = A_NORMAL;
      CRT_colors[PROCESS_SHADOW] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[PROCESS_TAG] = A_BOLD | ColorPair(Yellow,Black);
      CRT_colors[PROCESS_MEGABYTES] = ColorPair(Cyan,Black);
      CRT_colors[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan,Black);
      CRT_colors[PROCESS_TREE] = ColorPair(Cyan,Black);
      CRT_colors[PROCESS_R_STATE] = ColorPair(Green,Black);
      CRT_colors[PROCESS_HIGH_PRIORITY] = ColorPair(Red,Black);
      CRT_colors[PROCESS_LOW_PRIORITY] = ColorPair(Red,Black);
564
565
      CRT_colors[PROCESS_THREAD] = ColorPair(Green,Black);
      CRT_colors[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Green,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
      CRT_colors[BAR_BORDER] = A_BOLD;
      CRT_colors[BAR_SHADOW] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[SWAP] = ColorPair(Red,Black);
      CRT_colors[GRAPH_1] = A_BOLD | ColorPair(Red,Black);
      CRT_colors[GRAPH_2] = ColorPair(Red,Black);
      CRT_colors[GRAPH_3] = A_BOLD | ColorPair(Yellow,Black);
      CRT_colors[GRAPH_4] = A_BOLD | ColorPair(Green,Black);
      CRT_colors[GRAPH_5] = ColorPair(Green,Black);
      CRT_colors[GRAPH_6] = ColorPair(Cyan,Black);
      CRT_colors[GRAPH_7] = A_BOLD | ColorPair(Blue,Black);
      CRT_colors[GRAPH_8] = ColorPair(Blue,Black);
      CRT_colors[GRAPH_9] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[MEMORY_USED] = ColorPair(Green,Black);
      CRT_colors[MEMORY_BUFFERS] = ColorPair(Blue,Black);
      CRT_colors[MEMORY_CACHE] = ColorPair(Yellow,Black);
      CRT_colors[LOAD_AVERAGE_FIFTEEN] = A_BOLD | ColorPair(Black,Black);
      CRT_colors[LOAD_AVERAGE_FIVE] = A_NORMAL;
      CRT_colors[LOAD_AVERAGE_ONE] = A_BOLD;
      CRT_colors[LOAD] = A_BOLD;
      CRT_colors[HELP_BOLD] = A_BOLD | ColorPair(Cyan,Black);
      CRT_colors[CLOCK] = A_BOLD;
      CRT_colors[CHECK_BOX] = ColorPair(Cyan,Black);
      CRT_colors[CHECK_MARK] = A_BOLD;
      CRT_colors[CHECK_TEXT] = A_NORMAL;
590
591
592
593
      CRT_colors[HOSTNAME] = A_BOLD;
      CRT_colors[CPU_NICE] = ColorPair(Blue,Black);
      CRT_colors[CPU_NORMAL] = ColorPair(Green,Black);
      CRT_colors[CPU_KERNEL] = ColorPair(Red,Black);
594
      CRT_colors[CPU_IOWAIT] = A_BOLD | ColorPair(Black, Black);
595
596
      CRT_colors[CPU_IRQ] = ColorPair(Yellow,Black);
      CRT_colors[CPU_SOFTIRQ] = ColorPair(Magenta,Black);
597
598
      CRT_colors[CPU_STEAL] = ColorPair(Cyan,Black);
      CRT_colors[CPU_GUEST] = ColorPair(Cyan,Black);
Hisham Muhammad's avatar
Hisham Muhammad committed
599
600
   }
}