2006-03-04 18:16:49 +00:00
|
|
|
#ifndef HEADER_CRT
|
|
|
|
#define HEADER_CRT
|
|
|
|
/*
|
|
|
|
htop - CRT.h
|
2011-05-26 16:35:07 +00:00
|
|
|
(C) 2004-2011 Hisham H. Muhammad
|
2020-10-05 09:51:32 +02:00
|
|
|
Released under the GNU GPLv2, see the COPYING file
|
2006-03-04 18:16:49 +00:00
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2020-09-19 13:55:23 +02:00
|
|
|
#include "config.h"
|
2020-09-09 21:35:15 +02:00
|
|
|
|
2020-09-12 18:25:25 -03:00
|
|
|
#include <stdbool.h>
|
2017-05-23 14:02:34 -03:00
|
|
|
|
2020-09-19 13:55:23 +02:00
|
|
|
#include "Macros.h"
|
|
|
|
#include "ProvideCurses.h"
|
|
|
|
|
|
|
|
|
2015-01-21 23:27:31 -02:00
|
|
|
typedef enum TreeStr_ {
|
|
|
|
TREE_STR_VERT,
|
|
|
|
TREE_STR_RTEE,
|
|
|
|
TREE_STR_BEND,
|
|
|
|
TREE_STR_TEND,
|
|
|
|
TREE_STR_OPEN,
|
|
|
|
TREE_STR_SHUT,
|
2020-12-28 20:41:33 +01:00
|
|
|
TREE_STR_ASC,
|
|
|
|
TREE_STR_DESC,
|
2020-12-14 15:45:48 +01:00
|
|
|
LAST_TREE_STR
|
2015-01-21 23:27:31 -02:00
|
|
|
} TreeStr;
|
|
|
|
|
2020-12-14 15:45:48 +01:00
|
|
|
typedef enum ColorScheme_ {
|
|
|
|
COLORSCHEME_DEFAULT,
|
2020-10-05 17:24:59 +02:00
|
|
|
COLORSCHEME_MONOCHROME,
|
|
|
|
COLORSCHEME_BLACKONWHITE,
|
|
|
|
COLORSCHEME_LIGHTTERMINAL,
|
|
|
|
COLORSCHEME_MIDNIGHT,
|
|
|
|
COLORSCHEME_BLACKNIGHT,
|
|
|
|
COLORSCHEME_BROKENGRAY,
|
2020-12-14 15:45:48 +01:00
|
|
|
LAST_COLORSCHEME
|
|
|
|
} ColorScheme;
|
2015-02-03 22:30:05 +01:00
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
typedef enum ColorElements_ {
|
|
|
|
RESET_COLOR,
|
|
|
|
DEFAULT_COLOR,
|
|
|
|
FUNCTION_BAR,
|
|
|
|
FUNCTION_KEY,
|
|
|
|
FAILED_SEARCH,
|
2020-10-17 16:24:45 +05:30
|
|
|
FAILED_READ,
|
2020-10-05 15:14:54 +02:00
|
|
|
PAUSED,
|
2006-03-04 18:16:49 +00:00
|
|
|
PANEL_HEADER_FOCUS,
|
|
|
|
PANEL_HEADER_UNFOCUS,
|
2015-04-09 15:17:20 -03:00
|
|
|
PANEL_SELECTION_FOCUS,
|
|
|
|
PANEL_SELECTION_FOLLOW,
|
|
|
|
PANEL_SELECTION_UNFOCUS,
|
2006-03-04 18:16:49 +00:00
|
|
|
LARGE_NUMBER,
|
|
|
|
METER_TEXT,
|
|
|
|
METER_VALUE,
|
2020-10-20 21:40:51 +02:00
|
|
|
METER_VALUE_ERROR,
|
2020-10-16 19:44:53 +02:00
|
|
|
METER_VALUE_IOREAD,
|
|
|
|
METER_VALUE_IOWRITE,
|
2020-10-07 15:42:13 +02:00
|
|
|
METER_VALUE_NOTICE,
|
|
|
|
METER_VALUE_OK,
|
2020-12-23 20:54:03 +01:00
|
|
|
METER_VALUE_WARN,
|
2006-03-04 18:16:49 +00:00
|
|
|
LED_COLOR,
|
|
|
|
UPTIME,
|
2008-09-23 06:21:28 +00:00
|
|
|
BATTERY,
|
2006-03-04 18:16:49 +00:00
|
|
|
TASKS_RUNNING,
|
|
|
|
SWAP,
|
|
|
|
PROCESS,
|
|
|
|
PROCESS_SHADOW,
|
|
|
|
PROCESS_TAG,
|
|
|
|
PROCESS_MEGABYTES,
|
2020-09-13 23:50:24 +02:00
|
|
|
PROCESS_GIGABYTES,
|
2006-03-04 18:16:49 +00:00
|
|
|
PROCESS_TREE,
|
|
|
|
PROCESS_R_STATE,
|
2014-10-14 02:30:17 +01:00
|
|
|
PROCESS_D_STATE,
|
2006-03-04 18:16:49 +00:00
|
|
|
PROCESS_BASENAME,
|
|
|
|
PROCESS_HIGH_PRIORITY,
|
|
|
|
PROCESS_LOW_PRIORITY,
|
2020-10-30 21:56:16 -04:00
|
|
|
PROCESS_NEW,
|
|
|
|
PROCESS_TOMB,
|
2008-03-08 23:39:48 +00:00
|
|
|
PROCESS_THREAD,
|
|
|
|
PROCESS_THREAD_BASENAME,
|
2020-10-17 16:24:45 +05:30
|
|
|
PROCESS_COMM,
|
|
|
|
PROCESS_THREAD_COMM,
|
2006-03-04 18:16:49 +00:00
|
|
|
BAR_BORDER,
|
|
|
|
BAR_SHADOW,
|
|
|
|
GRAPH_1,
|
|
|
|
GRAPH_2,
|
|
|
|
MEMORY_USED,
|
|
|
|
MEMORY_BUFFERS,
|
2014-04-24 13:15:52 -03:00
|
|
|
MEMORY_BUFFERS_TEXT,
|
2006-03-04 18:16:49 +00:00
|
|
|
MEMORY_CACHE,
|
|
|
|
LOAD,
|
|
|
|
LOAD_AVERAGE_FIFTEEN,
|
|
|
|
LOAD_AVERAGE_FIVE,
|
|
|
|
LOAD_AVERAGE_ONE,
|
2020-08-31 22:08:35 +02:00
|
|
|
CHECK_BOX,
|
2006-03-04 18:16:49 +00:00
|
|
|
CHECK_MARK,
|
|
|
|
CHECK_TEXT,
|
|
|
|
CLOCK,
|
2020-10-05 13:52:58 +02:00
|
|
|
DATE,
|
|
|
|
DATETIME,
|
2010-08-24 23:20:38 +00:00
|
|
|
HELP_BOLD,
|
|
|
|
HOSTNAME,
|
2006-03-04 18:16:49 +00:00
|
|
|
CPU_NICE,
|
2014-04-24 13:15:52 -03:00
|
|
|
CPU_NICE_TEXT,
|
2006-03-04 18:16:49 +00:00
|
|
|
CPU_NORMAL,
|
2020-08-20 14:09:27 +10:00
|
|
|
CPU_SYSTEM,
|
2006-10-04 14:21:27 +00:00
|
|
|
CPU_IOWAIT,
|
|
|
|
CPU_IRQ,
|
|
|
|
CPU_SOFTIRQ,
|
2010-08-24 23:20:38 +00:00
|
|
|
CPU_STEAL,
|
|
|
|
CPU_GUEST,
|
2020-08-20 13:59:41 +10:00
|
|
|
PRESSURE_STALL_TEN,
|
|
|
|
PRESSURE_STALL_SIXTY,
|
|
|
|
PRESSURE_STALL_THREEHUNDRED,
|
2019-07-06 04:27:49 +00:00
|
|
|
ZFS_MFU,
|
|
|
|
ZFS_MRU,
|
|
|
|
ZFS_ANON,
|
|
|
|
ZFS_HEADER,
|
|
|
|
ZFS_OTHER,
|
2019-09-03 18:26:02 +00:00
|
|
|
ZFS_COMPRESSED,
|
|
|
|
ZFS_RATIO,
|
2020-09-22 18:54:15 +07:00
|
|
|
ZRAM,
|
2006-03-04 18:16:49 +00:00
|
|
|
LAST_COLORELEMENT
|
|
|
|
} ColorElements;
|
|
|
|
|
2020-09-09 21:35:15 +02:00
|
|
|
void CRT_fatalError(const char* note) ATTR_NORETURN;
|
2014-04-24 12:20:03 -03:00
|
|
|
|
2020-10-03 17:53:15 +02:00
|
|
|
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
|
2014-11-24 18:55:03 -02:00
|
|
|
|
2020-10-05 17:24:59 +02:00
|
|
|
#define KEY_WHEELUP KEY_F(20)
|
|
|
|
#define KEY_WHEELDOWN KEY_F(21)
|
|
|
|
#define KEY_RECLICK KEY_F(22)
|
|
|
|
#define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A'))
|
2016-02-19 13:38:02 -02:00
|
|
|
|
2020-09-10 19:56:33 +02:00
|
|
|
extern const char* CRT_degreeSign;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2015-07-17 14:33:34 +02:00
|
|
|
#ifdef HAVE_LIBNCURSESW
|
|
|
|
|
2020-08-31 22:08:35 +02:00
|
|
|
extern bool CRT_utf8;
|
2015-07-17 14:33:34 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2020-10-31 23:28:02 +01:00
|
|
|
extern const char* const* CRT_treeStr;
|
2006-06-06 20:28:42 +00:00
|
|
|
|
2020-10-05 17:24:59 +02:00
|
|
|
extern const int* CRT_colors;
|
2015-02-03 22:30:05 +01:00
|
|
|
|
2011-09-08 01:10:58 +00:00
|
|
|
extern int CRT_cursorX;
|
|
|
|
|
2014-02-27 16:35:22 -03:00
|
|
|
extern int CRT_scrollHAmount;
|
|
|
|
|
2015-08-19 18:55:24 -03:00
|
|
|
extern int CRT_scrollWheelVAmount;
|
|
|
|
|
2020-12-14 15:45:48 +01:00
|
|
|
extern ColorScheme CRT_colorScheme;
|
2015-01-21 23:27:31 -02:00
|
|
|
|
2020-09-08 13:59:30 +02:00
|
|
|
#ifdef HAVE_SETUID_ENABLED
|
2017-07-26 15:40:55 -03:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
void CRT_dropPrivileges(void);
|
2017-07-26 15:40:55 -03:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
void CRT_restorePrivileges(void);
|
2017-07-26 15:40:55 -03:00
|
|
|
|
2020-09-08 13:59:30 +02:00
|
|
|
#else /* HAVE_SETUID_ENABLED */
|
2017-07-26 15:40:55 -03:00
|
|
|
|
|
|
|
/* Turn setuid operations into NOPs */
|
2020-10-05 17:24:59 +02:00
|
|
|
static inline void CRT_dropPrivileges(void) { }
|
|
|
|
static inline void CRT_restorePrivileges(void) { }
|
2017-07-26 15:40:55 -03:00
|
|
|
|
2020-09-08 13:59:30 +02:00
|
|
|
#endif /* HAVE_SETUID_ENABLED */
|
2017-07-26 15:40:55 -03:00
|
|
|
|
2020-11-21 21:40:08 +01:00
|
|
|
void CRT_init(const int* delay, int colorScheme, bool allowUnicode);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
void CRT_done(void);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
int CRT_readKey(void);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
void CRT_disableDelay(void);
|
2006-06-06 20:28:42 +00:00
|
|
|
|
2020-09-08 14:28:34 +02:00
|
|
|
void CRT_enableDelay(void);
|
2006-06-06 20:28:42 +00:00
|
|
|
|
2020-09-02 02:38:44 -05:00
|
|
|
void CRT_setColors(int colorScheme);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#endif
|