CRT.h 3.54 KB
Newer Older
Hisham Muhammad's avatar
Hisham Muhammad committed
1
/* Do not edit this file. It was automatically generated. */
Hisham Muhammad's avatar
Hisham Muhammad committed
2
3
4
5
6

#ifndef HEADER_CRT
#define HEADER_CRT
/*
htop - CRT.h
Hisham Muhammad's avatar
Hisham Muhammad committed
7
(C) 2004-2011 Hisham H. Muhammad
Hisham Muhammad's avatar
Hisham Muhammad committed
8
9
10
11
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/

12
13
14
#if HAVE_SETUID_ENABLED
#endif

15
16
17
#define ColorIndex(i,j) ((7-i)*8+j)

#define ColorPair(i,j) COLOR_PAIR(ColorIndex(i,j))
Hisham Muhammad's avatar
Hisham Muhammad committed
18
19
20
21
22
23
24
25
26
27

#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

28
#define ColorPairGrayBlack ColorPair(Magenta,Magenta)
29
#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta)
30

31
32
#define KEY_WHEELUP KEY_F(20)
#define KEY_WHEELDOWN KEY_F(21)
33
#define KEY_RECLICK KEY_F(22)
34
#define KEY_SHIFT_TAB KEY_F(23)
35

Hisham Muhammad's avatar
Hisham Muhammad committed
36
37
//#link curses

Hisham Muhammad's avatar
Hisham Muhammad committed
38
#include <stdbool.h>
Hisham Muhammad's avatar
Hisham Muhammad committed
39

Hisham Muhammad's avatar
Hisham Muhammad committed
40
41
42
43
44
45
46
47
48
49
50
typedef enum TreeStr_ {
   TREE_STR_HORZ,
   TREE_STR_VERT,
   TREE_STR_RTEE,
   TREE_STR_BEND,
   TREE_STR_TEND,
   TREE_STR_OPEN,
   TREE_STR_SHUT,
   TREE_STR_COUNT
} TreeStr;

51
52
53
54
55
56
57
typedef enum ColorSchemes_ {
   COLORSCHEME_DEFAULT = 0,
   COLORSCHEME_MONOCHROME = 1,
   COLORSCHEME_BLACKONWHITE = 2,
   COLORSCHEME_LIGHTTERMINAL = 3,
   COLORSCHEME_MIDNIGHT = 4,
   COLORSCHEME_BLACKNIGHT = 5,
58
59
   COLORSCHEME_BROKENGRAY = 6,
   LAST_COLORSCHEME = 7,
60
61
} ColorSchemes;

Hisham Muhammad's avatar
Hisham Muhammad committed
62
63
64
65
66
67
68
69
typedef enum ColorElements_ {
   RESET_COLOR,
   DEFAULT_COLOR,
   FUNCTION_BAR,
   FUNCTION_KEY,
   FAILED_SEARCH,
   PANEL_HEADER_FOCUS,
   PANEL_HEADER_UNFOCUS,
70
71
72
   PANEL_SELECTION_FOCUS,
   PANEL_SELECTION_FOLLOW,
   PANEL_SELECTION_UNFOCUS,
Hisham Muhammad's avatar
Hisham Muhammad committed
73
74
75
76
77
   LARGE_NUMBER,
   METER_TEXT,
   METER_VALUE,
   LED_COLOR,
   UPTIME,
Hisham Muhammad's avatar
Hisham Muhammad committed
78
   BATTERY,
Hisham Muhammad's avatar
Hisham Muhammad committed
79
80
81
82
83
84
85
86
   TASKS_RUNNING,
   SWAP,
   PROCESS,
   PROCESS_SHADOW,
   PROCESS_TAG,
   PROCESS_MEGABYTES,
   PROCESS_TREE,
   PROCESS_R_STATE,
87
   PROCESS_D_STATE,
Hisham Muhammad's avatar
Hisham Muhammad committed
88
89
90
   PROCESS_BASENAME,
   PROCESS_HIGH_PRIORITY,
   PROCESS_LOW_PRIORITY,
91
92
   PROCESS_THREAD,
   PROCESS_THREAD_BASENAME,
Hisham Muhammad's avatar
Hisham Muhammad committed
93
94
95
96
97
98
   BAR_BORDER,
   BAR_SHADOW,
   GRAPH_1,
   GRAPH_2,
   MEMORY_USED,
   MEMORY_BUFFERS,
99
   MEMORY_BUFFERS_TEXT,
Hisham Muhammad's avatar
Hisham Muhammad committed
100
101
102
103
104
105
106
107
108
   MEMORY_CACHE,
   LOAD,
   LOAD_AVERAGE_FIFTEEN,
   LOAD_AVERAGE_FIVE,
   LOAD_AVERAGE_ONE,
   CHECK_BOX,
   CHECK_MARK,
   CHECK_TEXT,
   CLOCK,
109
110
   HELP_BOLD,
   HOSTNAME,
Hisham Muhammad's avatar
Hisham Muhammad committed
111
   CPU_NICE,
112
   CPU_NICE_TEXT,
Hisham Muhammad's avatar
Hisham Muhammad committed
113
114
   CPU_NORMAL,
   CPU_KERNEL,
115
116
117
   CPU_IOWAIT,
   CPU_IRQ,
   CPU_SOFTIRQ,
118
119
   CPU_STEAL,
   CPU_GUEST,
120
   PANEL_EDIT,
Hisham Muhammad's avatar
Hisham Muhammad committed
121
122
123
   LAST_COLORELEMENT
} ColorElements;

Hisham Muhammad's avatar
Hisham Muhammad committed
124
125
void CRT_fatalError(const char* note) __attribute__ ((noreturn));

126
127
void CRT_handleSIGSEGV(int sgn);

128
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
129

Hisham Muhammad's avatar
Hisham Muhammad committed
130

Hisham Muhammad's avatar
Hisham Muhammad committed
131
extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
Hisham Muhammad's avatar
Hisham Muhammad committed
132

133
134
#ifdef HAVE_LIBNCURSESW

Hisham Muhammad's avatar
Hisham Muhammad committed
135
136
extern const char *CRT_treeStrUtf8[TREE_STR_COUNT];

137
138
139
140
extern bool CRT_utf8;

#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
141
extern const char **CRT_treeStr;
Hisham Muhammad's avatar
Hisham Muhammad committed
142

143
144
extern int CRT_delay;

145
146
147
int* CRT_colors;

extern int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT];
Hisham Muhammad's avatar
Hisham Muhammad committed
148

Hisham Muhammad's avatar
Hisham Muhammad committed
149
150
extern int CRT_scrollHAmount;

151
152
extern int CRT_scrollWheelVAmount;

153
154
char* CRT_termType;

Hisham Muhammad's avatar
Hisham Muhammad committed
155
156
157
158
// TODO move color scheme to Settings, perhaps?

extern int CRT_colorScheme;

159
160
void *backtraceArray[128];

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#if HAVE_SETUID_ENABLED

#define DIE(msg) do { CRT_done(); fprintf(stderr, msg); exit(1); } while(0)

void CRT_dropPrivileges();

void CRT_restorePrivileges();

#else

/* Turn setuid operations into NOPs */

#ifndef CRT_dropPrivileges
#define CRT_dropPrivileges()
#define CRT_restorePrivileges()
#endif

#endif

Hisham Muhammad's avatar
Hisham Muhammad committed
180
181
182
// TODO: pass an instance of Settings instead.

void CRT_init(int delay, int colorScheme);
Hisham Muhammad's avatar
Hisham Muhammad committed
183
184
185

void CRT_done();

186
187
void CRT_fatalError(const char* note);

Hisham Muhammad's avatar
Hisham Muhammad committed
188
189
int CRT_readKey();

Hisham Muhammad's avatar
Hisham Muhammad committed
190
191
192
193
void CRT_disableDelay();

void CRT_enableDelay();

Hisham Muhammad's avatar
Hisham Muhammad committed
194
195
196
void CRT_setColors(int colorScheme);

#endif