Browse code

Define ANSI color values

John Hawthorn authored on 04/08/2014 08:01:43
Showing 2 changed files

  • fzy.c index f1f1659..56cf66f 100644
  • tty.h index aa59d2e..11e3590 100644
... ...
@@ -98,6 +98,8 @@ void clear(tty_t *tty){
98 98
 	fprintf(tty->fout, "%c%c0G", 0x1b, '[');
99 99
 }
100 100
 
101
+#define TTY_COLOR_HIGHLIGHT TTY_COLOR_YELLOW
102
+
101 103
 void draw_match(tty_t *tty, const char *choice, int selected){
102 104
 	int n = strlen(search);
103 105
 	size_t positions[n + 1];
... ...
@@ -111,10 +113,10 @@ void draw_match(tty_t *tty, const char *choice, int selected){
111 113
 
112 114
 	for(size_t i = 0, p = 0; choice[i] != '\0'; i++){
113 115
 		if(positions[p] == i){
114
-			tty_setfg(tty, 3);
116
+			tty_setfg(tty, TTY_COLOR_HIGHLIGHT);
115 117
 			p++;
116 118
 		}else{
117
-			tty_setfg(tty, 9);
119
+			tty_setfg(tty, TTY_COLOR_NORMAL);
118 120
 		}
119 121
 		fprintf(tty->fout, "%c", choice[i]);
120 122
 	}
... ...
@@ -18,5 +18,14 @@ void tty_setfg(tty_t *tty, int fg);
18 18
 void tty_setinvert(tty_t *tty);
19 19
 void tty_setnormal(tty_t *tty);
20 20
 
21
+#define TTY_COLOR_BLACK   0
22
+#define TTY_COLOR_RED     1
23
+#define TTY_COLOR_GREEN   2
24
+#define TTY_COLOR_YELLOW  3
25
+#define TTY_COLOR_BLUE    4
26
+#define TTY_COLOR_MAGENTA 5
27
+#define TTY_COLOR_CYAN    6
28
+#define TTY_COLOR_WHITE   7
29
+#define TTY_COLOR_NORMAL  9
21 30
 
22 31
 #endif