aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2019-09-13 00:37:33 +0200
committerache <ache@ache.one>2019-09-13 00:37:33 +0200
commit8b0aa8e2b552f57aaf8c6c9dfa164219aa85932d (patch)
tree8f94a84a42a2afd8ecdad76b773a759cad809f95
parentSearch in conv feature (diff)
Fix color message bug
-rw-r--r--main.c9
-rw-r--r--messageWind.c3
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 <assert.h>
#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]) {