From 211121f060114bba5120538b77c8b94652d358df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 27 Jan 2021 17:06:21 +0100 Subject: [PATCH 1/2] Drop invalid todo The surrounding code has nothing to do with colors --- Action.c | 1 - 1 file changed, 1 deletion(-) diff --git a/Action.c b/Action.c index 0b5c8990..4efb7e3d 100644 --- a/Action.c +++ b/Action.c @@ -361,7 +361,6 @@ Htop_Reaction Action_follow(State* st) { static Htop_Reaction actionSetup(State* st) { Action_runSetup(st); - // TODO: shouldn't need this, colors should be dynamic int headerHeight = Header_calculateHeight(st->header); Panel_move(st->panel, 0, headerHeight); Panel_resize(st->panel, COLS, LINES-headerHeight-1); From 6dba60f6bdebef740c7ddc916cd0c5f6837601ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Wed, 27 Jan 2021 17:14:15 +0100 Subject: [PATCH 2/2] Pass Settings to CRT_init Resolve todo --- CRT.c | 10 ++++------ CRT.h | 3 ++- htop.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CRT.c b/CRT.c index e3b1a20a..6191fca9 100644 --- a/CRT.c +++ b/CRT.c @@ -687,14 +687,12 @@ void CRT_restorePrivileges() { static struct sigaction old_sig_handler[32]; -// TODO: pass an instance of Settings instead. - -void CRT_init(const int* delay, int colorScheme, bool allowUnicode) { +void CRT_init(const Settings* settings, bool allowUnicode) { initscr(); noecho(); - CRT_delay = delay; - CRT_colors = CRT_colorSchemes[colorScheme]; - CRT_colorScheme = colorScheme; + CRT_delay = &(settings->delay); + CRT_colors = CRT_colorSchemes[settings->colorScheme]; + CRT_colorScheme = settings->colorScheme; for (int i = 0; i < LAST_COLORELEMENT; i++) { unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i]; diff --git a/CRT.h b/CRT.h index 1d2ed32d..e77ec3dc 100644 --- a/CRT.h +++ b/CRT.h @@ -13,6 +13,7 @@ in the source distribution for its full text. #include "Macros.h" #include "ProvideCurses.h" +#include "Settings.h" typedef enum TreeStr_ { @@ -173,7 +174,7 @@ static inline void CRT_restorePrivileges(void) { } #endif /* HAVE_SETUID_ENABLED */ -void CRT_init(const int* delay, int colorScheme, bool allowUnicode); +void CRT_init(const Settings* settings, bool allowUnicode); void CRT_done(void); diff --git a/htop.c b/htop.c index 49e158a7..20bd9e7b 100644 --- a/htop.c +++ b/htop.c @@ -441,7 +441,7 @@ int main(int argc, char** argv) { Settings_setSortKey(settings, flags.sortKey); } - CRT_init(&(settings->delay), settings->colorScheme, flags.allowUnicode); + CRT_init(settings, flags.allowUnicode); MainPanel* panel = MainPanel_new(); ProcessList_setPanel(pl, (Panel*) panel);