From e7372d18a1a661d8c3dba9f51e1f17b5f94171a7 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Wed, 10 Jan 2024 11:17:08 +0100 Subject: New upstream version 3.3.0 --- CRT.c | 212 ++++++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 134 insertions(+), 78 deletions(-) (limited to 'CRT.c') diff --git a/CRT.c b/CRT.c index 868f237..bd5453b 100644 --- a/CRT.c +++ b/CRT.c @@ -19,7 +19,9 @@ in the source distribution for its full text. #include #include +#include "CommandLine.h" #include "ProvideCurses.h" +#include "ProvideTerm.h" #include "XUtils.h" #if !defined(NDEBUG) && defined(HAVE_MEMFD_CREATE) @@ -134,7 +136,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [METER_VALUE] = A_BOLD | ColorPair(Cyan, Black), [METER_VALUE_ERROR] = A_BOLD | ColorPair(Red, Black), [METER_VALUE_IOREAD] = ColorPair(Green, Black), - [METER_VALUE_IOWRITE] = ColorPair(Blue, Black), + [METER_VALUE_IOWRITE] = A_BOLD | ColorPair(Blue, Black), [METER_VALUE_NOTICE] = A_BOLD | ColorPair(White, Black), [METER_VALUE_OK] = ColorPair(Green, Black), [METER_VALUE_WARN] = A_BOLD | ColorPair(Yellow, Black), @@ -156,22 +158,25 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD] = ColorPair(Green, Black), [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Green, Black), [PROCESS_COMM] = ColorPair(Magenta, Black), - [PROCESS_THREAD_COMM] = ColorPair(Blue, Black), + [PROCESS_THREAD_COMM] = A_BOLD | ColorPair(Blue, Black), + [PROCESS_PRIV] = ColorPair(Magenta, Black), [BAR_BORDER] = A_BOLD, [BAR_SHADOW] = A_BOLD | ColorPairGrayBlack, [SWAP] = ColorPair(Red, Black), [SWAP_CACHE] = ColorPair(Yellow, Black), + [SWAP_FRONTSWAP] = A_BOLD | ColorPairGrayBlack, [GRAPH_1] = A_BOLD | ColorPair(Cyan, Black), [GRAPH_2] = ColorPair(Cyan, Black), [MEMORY_USED] = ColorPair(Green, Black), - [MEMORY_BUFFERS] = ColorPair(Blue, Black), + [MEMORY_BUFFERS] = A_BOLD | ColorPair(Blue, Black), [MEMORY_BUFFERS_TEXT] = A_BOLD | ColorPair(Blue, Black), [MEMORY_CACHE] = ColorPair(Yellow, Black), [MEMORY_SHARED] = ColorPair(Magenta, Black), + [MEMORY_COMPRESSED] = A_BOLD | ColorPairGrayBlack, [HUGEPAGE_1] = ColorPair(Green, Black), [HUGEPAGE_2] = ColorPair(Yellow, Black), [HUGEPAGE_3] = ColorPair(Red, Black), - [HUGEPAGE_4] = ColorPair(Blue, Black), + [HUGEPAGE_4] = A_BOLD | ColorPair(Blue, Black), [LOAD_AVERAGE_FIFTEEN] = ColorPair(Cyan, Black), [LOAD_AVERAGE_FIVE] = A_BOLD | ColorPair(Cyan, Black), [LOAD_AVERAGE_ONE] = A_BOLD | ColorPair(White, Black), @@ -185,7 +190,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CHECK_MARK] = A_BOLD, [CHECK_TEXT] = A_NORMAL, [HOSTNAME] = A_BOLD, - [CPU_NICE] = ColorPair(Blue, Black), + [CPU_NICE] = A_BOLD | ColorPair(Blue, Black), [CPU_NICE_TEXT] = A_BOLD | ColorPair(Blue, Black), [CPU_NORMAL] = ColorPair(Green, Black), [CPU_SYSTEM] = ColorPair(Red, Black), @@ -202,19 +207,22 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Cyan, Black), [PRESSURE_STALL_SIXTY] = A_BOLD | ColorPair(Cyan, Black), [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(White, Black), - [ZFS_MFU] = ColorPair(Blue, Black), + [FILE_DESCRIPTOR_USED] = ColorPair(Green, Black), + [FILE_DESCRIPTOR_MAX] = A_BOLD | ColorPair(Blue, Black), + [ZFS_MFU] = A_BOLD | ColorPair(Blue, Black), [ZFS_MRU] = ColorPair(Yellow, Black), [ZFS_ANON] = ColorPair(Magenta, Black), [ZFS_HEADER] = ColorPair(Cyan, Black), [ZFS_OTHER] = ColorPair(Magenta, Black), - [ZFS_COMPRESSED] = ColorPair(Blue, Black), + [ZFS_COMPRESSED] = A_BOLD | ColorPair(Blue, Black), [ZFS_RATIO] = ColorPair(Magenta, Black), - [ZRAM] = ColorPair(Yellow, Black), + [ZRAM_COMPRESSED] = A_BOLD | ColorPair(Blue, Black), + [ZRAM_UNCOMPRESSED] = ColorPair(Yellow, Black), [DYNAMIC_GRAY] = ColorPairGrayBlack, [DYNAMIC_DARKGRAY] = A_BOLD | ColorPairGrayBlack, [DYNAMIC_RED] = ColorPair(Red, Black), [DYNAMIC_GREEN] = ColorPair(Green, Black), - [DYNAMIC_BLUE] = ColorPair(Blue, Black), + [DYNAMIC_BLUE] = A_BOLD | ColorPair(Blue, Black), [DYNAMIC_CYAN] = ColorPair(Cyan, Black), [DYNAMIC_MAGENTA] = ColorPair(Magenta, Black), [DYNAMIC_YELLOW] = ColorPair(Yellow, Black), @@ -264,10 +272,12 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD_BASENAME] = A_REVERSE, [PROCESS_COMM] = A_BOLD, [PROCESS_THREAD_COMM] = A_REVERSE, + [PROCESS_PRIV] = A_BOLD, [BAR_BORDER] = A_BOLD, [BAR_SHADOW] = A_DIM, [SWAP] = A_BOLD, [SWAP_CACHE] = A_NORMAL, + [SWAP_FRONTSWAP] = A_DIM, [GRAPH_1] = A_BOLD, [GRAPH_2] = A_NORMAL, [MEMORY_USED] = A_BOLD, @@ -275,6 +285,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [MEMORY_BUFFERS_TEXT] = A_NORMAL, [MEMORY_CACHE] = A_NORMAL, [MEMORY_SHARED] = A_NORMAL, + [MEMORY_COMPRESSED] = A_DIM, [HUGEPAGE_1] = A_BOLD, [HUGEPAGE_2] = A_NORMAL, [HUGEPAGE_3] = A_REVERSE | A_BOLD, @@ -309,6 +320,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PRESSURE_STALL_THREEHUNDRED] = A_DIM, [PRESSURE_STALL_SIXTY] = A_NORMAL, [PRESSURE_STALL_TEN] = A_BOLD, + [FILE_DESCRIPTOR_USED] = A_BOLD, + [FILE_DESCRIPTOR_MAX] = A_BOLD, [ZFS_MFU] = A_NORMAL, [ZFS_MRU] = A_NORMAL, [ZFS_ANON] = A_DIM, @@ -316,7 +329,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [ZFS_OTHER] = A_DIM, [ZFS_COMPRESSED] = A_BOLD, [ZFS_RATIO] = A_BOLD, - [ZRAM] = A_NORMAL, + [ZRAM_COMPRESSED] = A_NORMAL, + [ZRAM_UNCOMPRESSED] = A_NORMAL, [DYNAMIC_GRAY] = A_DIM, [DYNAMIC_DARKGRAY] = A_DIM, [DYNAMIC_RED] = A_BOLD, @@ -371,10 +385,12 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue, White), [PROCESS_COMM] = ColorPair(Magenta, White), [PROCESS_THREAD_COMM] = ColorPair(Green, White), + [PROCESS_PRIV] = ColorPair(Magenta, White), [BAR_BORDER] = ColorPair(Blue, White), [BAR_SHADOW] = ColorPair(Black, White), [SWAP] = ColorPair(Red, White), [SWAP_CACHE] = ColorPair(Yellow, White), + [SWAP_FRONTSWAP] = A_BOLD | ColorPair(Black, White), [GRAPH_1] = A_BOLD | ColorPair(Blue, White), [GRAPH_2] = ColorPair(Blue, White), [MEMORY_USED] = ColorPair(Green, White), @@ -382,6 +398,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [MEMORY_BUFFERS_TEXT] = ColorPair(Cyan, White), [MEMORY_CACHE] = ColorPair(Yellow, White), [MEMORY_SHARED] = ColorPair(Magenta, White), + [MEMORY_COMPRESSED] = A_BOLD | ColorPair(Black, White), [HUGEPAGE_1] = ColorPair(Green, White), [HUGEPAGE_2] = ColorPair(Yellow, White), [HUGEPAGE_3] = ColorPair(Red, White), @@ -408,14 +425,16 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, White), [CPU_STEAL] = ColorPair(Cyan, White), [CPU_GUEST] = ColorPair(Cyan, White), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Black,White), - [SCREENS_OTH_TEXT] = A_BOLD | ColorPair(Black,White), - [SCREENS_CUR_BORDER] = ColorPair(Green,Green), - [SCREENS_CUR_TEXT] = ColorPair(Black,Green), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Black, White), + [SCREENS_OTH_TEXT] = A_BOLD | ColorPair(Black, White), + [SCREENS_CUR_BORDER] = ColorPair(Green, Green), + [SCREENS_CUR_TEXT] = ColorPair(Black, Green), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black, White), [PRESSURE_STALL_SIXTY] = ColorPair(Black, White), [PRESSURE_STALL_TEN] = ColorPair(Black, White), + [FILE_DESCRIPTOR_USED] = ColorPair(Green, White), + [FILE_DESCRIPTOR_MAX] = ColorPair(Blue, White), [ZFS_MFU] = ColorPair(Cyan, White), [ZFS_MRU] = ColorPair(Yellow, White), [ZFS_ANON] = ColorPair(Magenta, White), @@ -423,7 +442,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [ZFS_OTHER] = ColorPair(Magenta, White), [ZFS_COMPRESSED] = ColorPair(Cyan, White), [ZFS_RATIO] = ColorPair(Magenta, White), - [ZRAM] = ColorPair(Yellow, White), + [ZRAM_COMPRESSED] = ColorPair(Cyan, White), + [ZRAM_UNCOMPRESSED] = ColorPair(Yellow, White), [DYNAMIC_GRAY] = ColorPair(Black, White), [DYNAMIC_DARKGRAY] = A_BOLD | ColorPair(Black, White), [DYNAMIC_RED] = ColorPair(Red, White), @@ -478,10 +498,12 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue, Black), [PROCESS_COMM] = ColorPair(Magenta, Black), [PROCESS_THREAD_COMM] = ColorPair(Yellow, Black), + [PROCESS_PRIV] = ColorPair(Magenta, Black), [BAR_BORDER] = ColorPair(Blue, Black), [BAR_SHADOW] = ColorPairGrayBlack, [SWAP] = ColorPair(Red, Black), [SWAP_CACHE] = ColorPair(Yellow, Black), + [SWAP_FRONTSWAP] = ColorPairGrayBlack, [GRAPH_1] = A_BOLD | ColorPair(Cyan, Black), [GRAPH_2] = ColorPair(Cyan, Black), [MEMORY_USED] = ColorPair(Green, Black), @@ -489,6 +511,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [MEMORY_BUFFERS_TEXT] = ColorPair(Cyan, Black), [MEMORY_CACHE] = ColorPair(Yellow, Black), [MEMORY_SHARED] = ColorPair(Magenta, Black), + [MEMORY_COMPRESSED] = ColorPairGrayBlack, [HUGEPAGE_1] = ColorPair(Green, Black), [HUGEPAGE_2] = ColorPair(Yellow, Black), [HUGEPAGE_3] = ColorPair(Red, Black), @@ -515,14 +538,16 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, Black), [CPU_STEAL] = ColorPair(Black, Black), [CPU_GUEST] = ColorPair(Black, Black), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = ColorPair(Blue,Black), - [SCREENS_OTH_TEXT] = ColorPair(Blue,Black), - [SCREENS_CUR_BORDER] = ColorPair(Green,Green), - [SCREENS_CUR_TEXT] = ColorPair(Black,Green), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = ColorPair(Blue, Black), + [SCREENS_OTH_TEXT] = ColorPair(Blue, Black), + [SCREENS_CUR_BORDER] = ColorPair(Green, Green), + [SCREENS_CUR_TEXT] = ColorPair(Black, Green), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black, Black), [PRESSURE_STALL_SIXTY] = ColorPair(Black, Black), [PRESSURE_STALL_TEN] = ColorPair(Black, Black), + [FILE_DESCRIPTOR_USED] = ColorPair(Green, Black), + [FILE_DESCRIPTOR_MAX] = A_BOLD | ColorPair(Blue, Black), [ZFS_MFU] = ColorPair(Cyan, Black), [ZFS_MRU] = ColorPair(Yellow, Black), [ZFS_ANON] = A_BOLD | ColorPair(Magenta, Black), @@ -530,7 +555,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [ZFS_OTHER] = A_BOLD | ColorPair(Magenta, Black), [ZFS_COMPRESSED] = ColorPair(Cyan, Black), [ZFS_RATIO] = A_BOLD | ColorPair(Magenta, Black), - [ZRAM] = ColorPair(Yellow, Black), + [ZRAM_COMPRESSED] = ColorPair(Cyan, Black), + [ZRAM_UNCOMPRESSED] = ColorPair(Yellow, Black), [DYNAMIC_GRAY] = ColorPairGrayBlack, [DYNAMIC_DARKGRAY] = A_BOLD | ColorPairGrayBlack, [DYNAMIC_RED] = ColorPair(Red, Black), @@ -585,10 +611,12 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Green, Blue), [PROCESS_COMM] = ColorPair(Magenta, Blue), [PROCESS_THREAD_COMM] = ColorPair(Black, Blue), + [PROCESS_PRIV] = ColorPair(Magenta, Blue), [BAR_BORDER] = A_BOLD | ColorPair(Yellow, Blue), [BAR_SHADOW] = ColorPair(Cyan, Blue), [SWAP] = ColorPair(Red, Blue), [SWAP_CACHE] = A_BOLD | ColorPair(Yellow, Blue), + [SWAP_FRONTSWAP] = A_BOLD | ColorPair(Black, Blue), [GRAPH_1] = A_BOLD | ColorPair(Cyan, Blue), [GRAPH_2] = ColorPair(Cyan, Blue), [MEMORY_USED] = A_BOLD | ColorPair(Green, Blue), @@ -596,6 +624,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [MEMORY_BUFFERS_TEXT] = A_BOLD | ColorPair(Cyan, Blue), [MEMORY_CACHE] = A_BOLD | ColorPair(Yellow, Blue), [MEMORY_SHARED] = A_BOLD | ColorPair(Magenta, Blue), + [MEMORY_COMPRESSED] = A_BOLD | ColorPair(Black, Blue), [HUGEPAGE_1] = A_BOLD | ColorPair(Green, Blue), [HUGEPAGE_2] = A_BOLD | ColorPair(Yellow, Blue), [HUGEPAGE_3] = A_BOLD | ColorPair(Red, Blue), @@ -622,14 +651,16 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Black, Blue), [CPU_STEAL] = ColorPair(White, Blue), [CPU_GUEST] = ColorPair(White, Blue), - [PANEL_EDIT] = ColorPair(White,Blue), - [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Yellow,Blue), - [SCREENS_OTH_TEXT] = ColorPair(Cyan,Blue), - [SCREENS_CUR_BORDER] = ColorPair(Cyan,Cyan), - [SCREENS_CUR_TEXT] = ColorPair(Black,Cyan), + [PANEL_EDIT] = ColorPair(White, Blue), + [SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Yellow, Blue), + [SCREENS_OTH_TEXT] = ColorPair(Cyan, Blue), + [SCREENS_CUR_BORDER] = ColorPair(Cyan, Cyan), + [SCREENS_CUR_TEXT] = ColorPair(Black, Cyan), [PRESSURE_STALL_THREEHUNDRED] = A_BOLD | ColorPair(Black, Blue), [PRESSURE_STALL_SIXTY] = A_NORMAL | ColorPair(White, Blue), [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(White, Blue), + [FILE_DESCRIPTOR_USED] = A_BOLD | ColorPair(Green, Blue), + [FILE_DESCRIPTOR_MAX] = A_BOLD | ColorPair(Red, Blue), [ZFS_MFU] = A_BOLD | ColorPair(White, Blue), [ZFS_MRU] = A_BOLD | ColorPair(Yellow, Blue), [ZFS_ANON] = A_BOLD | ColorPair(Magenta, Blue), @@ -637,7 +668,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [ZFS_OTHER] = A_BOLD | ColorPair(Magenta, Blue), [ZFS_COMPRESSED] = A_BOLD | ColorPair(White, Blue), [ZFS_RATIO] = A_BOLD | ColorPair(Magenta, Blue), - [ZRAM] = A_BOLD | ColorPair(Yellow, Blue), + [ZRAM_COMPRESSED] = ColorPair(Cyan, Blue), + [ZRAM_UNCOMPRESSED] = ColorPair(Yellow, Blue), [DYNAMIC_GRAY] = ColorPairGrayBlack, [DYNAMIC_DARKGRAY] = A_BOLD | ColorPairGrayBlack, [DYNAMIC_RED] = ColorPair(Red, Blue), @@ -692,10 +724,12 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [PROCESS_LOW_PRIORITY] = ColorPair(Green, Black), [PROCESS_NEW] = ColorPair(Black, Green), [PROCESS_TOMB] = ColorPair(Black, Red), + [PROCESS_PRIV] = ColorPair(Magenta, Black), [BAR_BORDER] = A_BOLD | ColorPair(Green, Black), [BAR_SHADOW] = ColorPair(Cyan, Black), [SWAP] = ColorPair(Red, Black), [SWAP_CACHE] = ColorPair(Yellow, Black), + [SWAP_FRONTSWAP] = ColorPair(Yellow, Black), [GRAPH_1] = A_BOLD | ColorPair(Green, Black), [GRAPH_2] = ColorPair(Green, Black), [MEMORY_USED] = ColorPair(Green, Black), @@ -703,6 +737,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [MEMORY_BUFFERS_TEXT] = A_BOLD | ColorPair(Blue, Black), [MEMORY_CACHE] = ColorPair(Yellow, Black), [MEMORY_SHARED] = ColorPair(Magenta, Black), + [MEMORY_COMPRESSED] = ColorPair(Yellow, Black), [HUGEPAGE_1] = ColorPair(Green, Black), [HUGEPAGE_2] = ColorPair(Yellow, Black), [HUGEPAGE_3] = ColorPair(Red, Black), @@ -727,14 +762,16 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue, Black), [CPU_STEAL] = ColorPair(Cyan, Black), [CPU_GUEST] = ColorPair(Cyan, Black), - [PANEL_EDIT] = ColorPair(White,Cyan), - [SCREENS_OTH_BORDER] = ColorPair(White,Black), - [SCREENS_OTH_TEXT] = ColorPair(Cyan,Black), - [SCREENS_CUR_BORDER] = A_BOLD | ColorPair(White,Black), - [SCREENS_CUR_TEXT] = A_BOLD | ColorPair(Green,Black), + [PANEL_EDIT] = ColorPair(White, Cyan), + [SCREENS_OTH_BORDER] = ColorPair(White, Black), + [SCREENS_OTH_TEXT] = ColorPair(Cyan, Black), + [SCREENS_CUR_BORDER] = A_BOLD | ColorPair(White, Black), + [SCREENS_CUR_TEXT] = A_BOLD | ColorPair(Green, Black), [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Green, Black), [PRESSURE_STALL_SIXTY] = ColorPair(Green, Black), [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(Green, Black), + [FILE_DESCRIPTOR_USED] = ColorPair(Green, Black), + [FILE_DESCRIPTOR_MAX] = A_BOLD | ColorPair(Blue, Black), [ZFS_MFU] = ColorPair(Blue, Black), [ZFS_MRU] = ColorPair(Yellow, Black), [ZFS_ANON] = ColorPair(Magenta, Black), @@ -742,7 +779,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [ZFS_OTHER] = ColorPair(Magenta, Black), [ZFS_COMPRESSED] = ColorPair(Blue, Black), [ZFS_RATIO] = ColorPair(Magenta, Black), - [ZRAM] = ColorPair(Yellow, Black), + [ZRAM_COMPRESSED] = ColorPair(Blue, Black), + [ZRAM_UNCOMPRESSED] = ColorPair(Yellow, Black), [DYNAMIC_GRAY] = ColorPairGrayBlack, [DYNAMIC_DARKGRAY] = A_BOLD | ColorPairGrayBlack, [DYNAMIC_RED] = ColorPair(Red, Black), @@ -756,6 +794,8 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [COLORSCHEME_BROKENGRAY] = { 0 } // dynamically generated. }; +static bool CRT_retainScreenOnExit = false; + int CRT_scrollHAmount = 5; int CRT_scrollWheelVAmount = 10; @@ -834,7 +874,7 @@ static void dumpStderr(void) { fprintf(stderr, ">>>>>>>>>> stderr output >>>>>>>>>>\n"); header = true; } - (void)! write(STDERR_FILENO, buffer, res); + full_write(STDERR_FILENO, buffer, res); } } @@ -869,16 +909,16 @@ static struct sigaction old_sig_handler[32]; static void CRT_installSignalHandlers(void) { struct sigaction act; - sigemptyset (&act.sa_mask); + sigemptyset(&act.sa_mask); act.sa_flags = (int)SA_RESETHAND | SA_NODEFER; act.sa_handler = CRT_handleSIGSEGV; - sigaction (SIGSEGV, &act, &old_sig_handler[SIGSEGV]); - sigaction (SIGFPE, &act, &old_sig_handler[SIGFPE]); - sigaction (SIGILL, &act, &old_sig_handler[SIGILL]); - sigaction (SIGBUS, &act, &old_sig_handler[SIGBUS]); - sigaction (SIGPIPE, &act, &old_sig_handler[SIGPIPE]); - sigaction (SIGSYS, &act, &old_sig_handler[SIGSYS]); - sigaction (SIGABRT, &act, &old_sig_handler[SIGABRT]); + sigaction(SIGSEGV, &act, &old_sig_handler[SIGSEGV]); + sigaction(SIGFPE, &act, &old_sig_handler[SIGFPE]); + sigaction(SIGILL, &act, &old_sig_handler[SIGILL]); + sigaction(SIGBUS, &act, &old_sig_handler[SIGBUS]); + sigaction(SIGPIPE, &act, &old_sig_handler[SIGPIPE]); + sigaction(SIGSYS, &act, &old_sig_handler[SIGSYS]); + sigaction(SIGABRT, &act, &old_sig_handler[SIGABRT]); signal(SIGCHLD, SIG_DFL); signal(SIGINT, CRT_handleSIGTERM); @@ -887,21 +927,21 @@ static void CRT_installSignalHandlers(void) { } void CRT_resetSignalHandlers(void) { - sigaction (SIGSEGV, &old_sig_handler[SIGSEGV], NULL); - sigaction (SIGFPE, &old_sig_handler[SIGFPE], NULL); - sigaction (SIGILL, &old_sig_handler[SIGILL], NULL); - sigaction (SIGBUS, &old_sig_handler[SIGBUS], NULL); - sigaction (SIGPIPE, &old_sig_handler[SIGPIPE], NULL); - sigaction (SIGSYS, &old_sig_handler[SIGSYS], NULL); - sigaction (SIGABRT, &old_sig_handler[SIGABRT], NULL); + sigaction(SIGSEGV, &old_sig_handler[SIGSEGV], NULL); + sigaction(SIGFPE, &old_sig_handler[SIGFPE], NULL); + sigaction(SIGILL, &old_sig_handler[SIGILL], NULL); + sigaction(SIGBUS, &old_sig_handler[SIGBUS], NULL); + sigaction(SIGPIPE, &old_sig_handler[SIGPIPE], NULL); + sigaction(SIGSYS, &old_sig_handler[SIGSYS], NULL); + sigaction(SIGABRT, &old_sig_handler[SIGABRT], NULL); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); signal(SIGQUIT, SIG_DFL); } -void CRT_setMouse(bool enabled) { #ifdef HAVE_GETMOUSE +void CRT_setMouse(bool enabled) { if (enabled) { #if NCURSES_MOUSE_VERSION > 1 mousemask(BUTTON1_RELEASED | BUTTON4_PRESSED | BUTTON5_PRESSED, NULL); @@ -911,13 +951,23 @@ void CRT_setMouse(bool enabled) { } else { mousemask(0, NULL); } -#endif } +#endif -void CRT_init(const Settings* settings, bool allowUnicode) { - redirectStderr(); - +void CRT_init(const Settings* settings, bool allowUnicode, bool retainScreenOnExit) { initscr(); + + if (retainScreenOnExit) { + CRT_retainScreenOnExit = true; + refresh(); + tputs(exit_ca_mode, 0, putchar); + tputs(clear_screen, 0, putchar); + fflush(stdout); + enter_ca_mode = 0; + exit_ca_mode = 0; + } + + redirectStderr(); noecho(); CRT_crashSettings = settings; CRT_delay = &(settings->delay); @@ -1012,12 +1062,18 @@ IGNORE_WCASTQUAL_END CRT_degreeSign = initDegreeSign(); } -void CRT_done() { - attron(CRT_colors[RESET_COLOR]); +void CRT_done(void) { + int resetColor = CRT_colors ? CRT_colors[RESET_COLOR] : CRT_colorSchemes[COLORSCHEME_DEFAULT][RESET_COLOR]; + + attron(resetColor); mvhline(LINES - 1, 0, ' ', COLS); - attroff(CRT_colors[RESET_COLOR]); + attroff(resetColor); refresh(); + if (CRT_retainScreenOnExit) { + mvcur(-1, -1, LINES - 1, 0); + } + curs_set(1); endwin(); @@ -1031,7 +1087,7 @@ void CRT_fatalError(const char* note) { exit(2); } -int CRT_readKey() { +int CRT_readKey(void) { nocbreak(); cbreak(); nodelay(stdscr, FALSE); @@ -1040,13 +1096,13 @@ int CRT_readKey() { return ret; } -void CRT_disableDelay() { +void CRT_disableDelay(void) { nocbreak(); cbreak(); nodelay(stdscr, TRUE); } -void CRT_enableDelay() { +void CRT_enableDelay(void) { halfdelay(*CRT_delay); } @@ -1056,9 +1112,7 @@ void CRT_setColors(int colorScheme) { for (short int i = 0; i < 8; i++) { for (short int j = 0; j < 8; j++) { if (ColorIndex(i, j) != ColorIndexGrayBlack && ColorIndex(i, j) != ColorIndexWhiteDefault) { - short int bg = (colorScheme != COLORSCHEME_BLACKNIGHT) - ? (j == 0 ? -1 : j) - : j; + short int bg = (colorScheme != COLORSCHEME_BLACKNIGHT) && (j == 0) ? -1 : j; init_pair(ColorIndex(i, j), i, bg); } } @@ -1095,7 +1149,7 @@ static void print_backtrace(void) { unw_get_proc_name(&cursor, symbolName, sizeof(symbolName), &offset); unw_proc_info_t pip; - pip.unwind_info = NULL; + pip.unwind_info = 0; const char* fname = "?"; const void* ptr = 0; @@ -1109,11 +1163,10 @@ static void print_backtrace(void) { #endif } - const char* frame = ""; - if (unw_is_signal_frame(&cursor) > 0) - frame = "{signal frame}"; + const bool is_signal_frame = unw_is_signal_frame(&cursor) > 0; + const char* frame = is_signal_frame ? " {signal frame}" : ""; - fprintf(stderr, "%2u: %#14lx %s (%s+%#lx) [%p]%s%s\n", item++, pc, fname, symbolName, offset, ptr, frame ? " " : "", frame); + fprintf(stderr, "%2u: %#14lx %s (%s+%#lx) [%p]%s\n", item++, pc, fname, symbolName, offset, ptr, frame); } #elif defined(HAVE_EXECINFO_H) void* backtraceArray[256]; @@ -1134,10 +1187,11 @@ void CRT_handleSIGSEGV(int signal) { "============================\n" "Please check at https://htop.dev/issues whether this issue has already been reported.\n" "If no similar issue has been reported before, please create a new issue with the following information:\n" - " - Your "PACKAGE" version: '"VERSION"'\n" + " - Your %s version: '"VERSION"'\n" " - Your OS and kernel version (uname -a)\n" " - Your distribution and release (lsb_release -a)\n" - " - Likely steps to reproduce (How did it happen?)\n" + " - Likely steps to reproduce (How did it happen?)\n", + program ); #ifdef PRINT_BACKTRACE @@ -1177,15 +1231,16 @@ void CRT_handleSIGSEGV(int signal) { fprintf(stderr, "\n" "To make the above information more practical to work with, " - "please also provide a disassembly of your "PACKAGE" binary. " + "please also provide a disassembly of your %s binary. " "This can usually be done by running the following command:\n" - "\n" + "\n", + program ); #ifdef HTOP_DARWIN - fprintf(stderr, " otool -tvV `which "PACKAGE"` > ~/htop.otool\n"); + fprintf(stderr, " otool -tvV `which %s` > ~/%s.otool\n", program, program); #else - fprintf(stderr, " objdump -d -S -w `which "PACKAGE"` > ~/htop.objdump\n"); + fprintf(stderr, " objdump -d -S -w `which %s` > ~/%s.objdump\n", program, program); #endif fprintf(stderr, @@ -1197,12 +1252,13 @@ void CRT_handleSIGSEGV(int signal) { fprintf(stderr, "Running this program with debug symbols or inside a debugger may provide further insights.\n" "\n" - "Thank you for helping to improve "PACKAGE"!\n" - "\n" + "Thank you for helping to improve %s!\n" + "\n", + program ); /* Call old sigsegv handler; may be default exit or third party one (e.g. ASAN) */ - if (sigaction (signal, &old_sig_handler[signal], NULL) < 0) { + if (sigaction(signal, &old_sig_handler[signal], NULL) < 0) { /* This avoids an infinite loop in case the handler could not be reset. */ fprintf(stderr, "!!! Chained handler could not be restored. Forcing exit.\n" -- cgit v1.2.3