From 8b0aa8e2b552f57aaf8c6c9dfa164219aa85932d Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 13 Sep 2019 00:37:33 +0200 Subject: Fix color message bug --- main.c | 9 ++++++--- messageWind.c | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 791c6b2..d5e5156 100644 --- a/main.c +++ b/main.c @@ -24,11 +24,13 @@ #include #endif -const int color[] = { +const int colors[] = { COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE}; + + #define MAX_PATH 1024 #define EVENT_SIZE ( sizeof (struct inotify_event) ) #define EVENT_BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) ) @@ -181,8 +183,9 @@ int main(int argc, char* argv[]){ CHECK(wrefresh, sep_win); init_readline(); - for(int i = 0 ; i < 9 ; i++) { - init_pair( i+1, i, COLOR_BLACK); + const int nbColor = sizeof colors / sizeof *colors; + for(int i = 2 ; i < nbColor ; i++) { + init_pair( i, colors[i], COLOR_BLACK); } // inotify stuff diff --git a/messageWind.c b/messageWind.c index 5b71b5e..2c788a5 100644 --- a/messageWind.c +++ b/messageWind.c @@ -69,7 +69,8 @@ int show1SMS(sms* S, int y_base, int* hasFinish) { *hasFinish = 1; - attrset( COLOR_PAIR( (rand()%8) + 2) | A_BOLD); + int nbColors = 7 - 1; + attrset( COLOR_PAIR( (rand() % nbColors) + 2) | A_BOLD); while( S->text[iS] ) { x = 0; while( x < w_WMessageSMS-1 && S->text[iS]) { -- cgit v1.2.3