Merge branch 'todo' of cgzones/htop

Make CRT_init get an instance of Settings instead of a separate colorScheme
This commit is contained in:
Daniel Lange 2021-01-28 07:36:14 +01:00
commit 92fb69f5a0
4 changed files with 7 additions and 9 deletions

View File

@ -361,7 +361,6 @@ Htop_Reaction Action_follow(State* st) {
static Htop_Reaction actionSetup(State* st) { static Htop_Reaction actionSetup(State* st) {
Action_runSetup(st); Action_runSetup(st);
// TODO: shouldn't need this, colors should be dynamic
int headerHeight = Header_calculateHeight(st->header); int headerHeight = Header_calculateHeight(st->header);
Panel_move(st->panel, 0, headerHeight); Panel_move(st->panel, 0, headerHeight);
Panel_resize(st->panel, COLS, LINES-headerHeight-1); Panel_resize(st->panel, COLS, LINES-headerHeight-1);

10
CRT.c
View File

@ -687,14 +687,12 @@ void CRT_restorePrivileges() {
static struct sigaction old_sig_handler[32]; static struct sigaction old_sig_handler[32];
// TODO: pass an instance of Settings instead. void CRT_init(const Settings* settings, bool allowUnicode) {
void CRT_init(const int* delay, int colorScheme, bool allowUnicode) {
initscr(); initscr();
noecho(); noecho();
CRT_delay = delay; CRT_delay = &(settings->delay);
CRT_colors = CRT_colorSchemes[colorScheme]; CRT_colors = CRT_colorSchemes[settings->colorScheme];
CRT_colorScheme = colorScheme; CRT_colorScheme = settings->colorScheme;
for (int i = 0; i < LAST_COLORELEMENT; i++) { for (int i = 0; i < LAST_COLORELEMENT; i++) {
unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i]; unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i];

3
CRT.h
View File

@ -13,6 +13,7 @@ in the source distribution for its full text.
#include "Macros.h" #include "Macros.h"
#include "ProvideCurses.h" #include "ProvideCurses.h"
#include "Settings.h"
typedef enum TreeStr_ { typedef enum TreeStr_ {
@ -173,7 +174,7 @@ static inline void CRT_restorePrivileges(void) { }
#endif /* HAVE_SETUID_ENABLED */ #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); void CRT_done(void);

2
htop.c
View File

@ -441,7 +441,7 @@ int main(int argc, char** argv) {
Settings_setSortKey(settings, flags.sortKey); Settings_setSortKey(settings, flags.sortKey);
} }
CRT_init(&(settings->delay), settings->colorScheme, flags.allowUnicode); CRT_init(settings, flags.allowUnicode);
MainPanel* panel = MainPanel_new(); MainPanel* panel = MainPanel_new();
ProcessList_setPanel(pl, (Panel*) panel); ProcessList_setPanel(pl, (Panel*) panel);