]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
curses: convert magic numbers to an enum list
authorSami Kerola <kerolasa@iki.fi>
Sat, 8 Oct 2016 22:24:46 +0000 (23:24 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
This improves readability.  It is eaasier to read what is the color rather
refer a lookup map near by.

curses.c

index 5a0c8bc5633d78af0148325aea112a18e99944a8..f1935eb228fd864153267149edaabe6bf4ffa1e6 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -512,18 +512,17 @@ static void mtr_curses_init(void) {
        block_map[NUM_FACTORS-1] = '>';
 }
 
-
-static int block_col[NUM_FACTORS+1] =
-{      /* 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white */
-        COLOR_PAIR(2)|A_BOLD,
+enum { black = 1, red, green, yellow, blue, magenta, cyan, white };
+static const int block_col[NUM_FACTORS + 1] = {
+        COLOR_PAIR(red)|A_BOLD,
        A_NORMAL,
-       COLOR_PAIR(3),
-       COLOR_PAIR(3)|A_BOLD,
-       COLOR_PAIR(4)|A_BOLD,
-       COLOR_PAIR(6)|A_BOLD,
-       COLOR_PAIR(6),
-       COLOR_PAIR(2),
-       COLOR_PAIR(2)|A_BOLD
+       COLOR_PAIR(green),
+       COLOR_PAIR(green)|A_BOLD,
+       COLOR_PAIR(yellow)|A_BOLD,
+       COLOR_PAIR(magenta)|A_BOLD,
+       COLOR_PAIR(magenta),
+       COLOR_PAIR(red),
+       COLOR_PAIR(red)|A_BOLD
 };
 
 static void mtr_print_scaled(int ms)