Cached and buffers colors !
Cached and buffers colors !

--- a/src/freec.c
+++ b/src/freec.c
@@ -175,18 +175,24 @@
 void
 work_central(struct meminfo *mem, struct conf_info *conf)
 {
-	unsigned int worker;
 
 	mem->mem_used = mem->mem_total -
-	                 mem->mem_free; //FIXME not the exact formula
-
-	worker = (mem->mem_used * conf->bar_length) / mem->mem_total;
-	mem->pixels_mem_used = worker;
-	printf("I have: %u / %u * %u = %u\n", mem->mem_used, mem->mem_total, conf->bar_length, worker);
-
-	worker = (mem->mem_free * conf->bar_length) / mem->mem_total;
-	mem->pixels_mem_free = worker;
-	printf("I have: %u / %u * %u = %u\n", mem->mem_free , mem->mem_total, conf->bar_length, worker);
+	                mem->mem_free -
+	                mem->buffers -
+	                mem->cached;
+	/*Well, theoreticaly, buffers and cache are "memused", but we want to
+	display them, so count them off */
+	mem->pixels_mem_used =
+	  proportionality(mem->mem_used, mem->mem_total, conf->bar_length);
+
+	mem->pixels_mem_free =
+	  proportionality(mem->mem_free, mem->mem_total, conf->bar_length);
+
+	mem->pixels_mem_buffers =
+	  proportionality(mem->buffers, mem->mem_total, conf->bar_length);
+
+	mem->pixels_mem_cached =
+	  proportionality(mem->cached, mem->mem_total, conf->bar_length);
 }
 
 void
@@ -208,6 +214,16 @@
 	while(i-->0)
 		putchar('u');
 
+	fputs(COLOR_BUFFERS, stdout);
+	i = mem->pixels_mem_buffers;
+	while(i-->0)
+		putchar('b');
+
+	fputs(COLOR_CACHED, stdout);
+	i = mem->pixels_mem_cached;
+	while(i-->0)
+		putchar('c');
+
 	fputs(COLOR_FREE, stdout);
 	i = mem->pixels_mem_free;
 	while(i-->0)
@@ -227,7 +243,14 @@
 	fputs(COLOR_NORMAL "]\n", stdout);
 }
 
-
+void
+print_usage(char **argv)
+{
+	fprintf(stderr, "Usage: %s blah blah\n", argv[0]);
+	exit(EXIT_FAILURE);
+}
+
+/* UTILS */
 
 void
 get_tty_info(struct conf_info *conf)
@@ -295,10 +318,9 @@
 	}
 }
 
-void
-print_usage(char **argv)
-{
-	fprintf(stderr, "Usage: %s blah blah\n", argv[0]);
-	exit(EXIT_FAILURE);
-}
-
+int
+proportionality(int have, int total, int ratio)
+{
+	return (have * ratio)/total;
+}
+

--- a/src/freec.h
+++ b/src/freec.h
@@ -12,9 +12,11 @@
 #define NORMAL "\033[;m"
 
 /* Which ones do you want ? */
-#define COLOR_USED   RED 
-#define COLOR_FREE   GREEN
-#define COLOR_NORMAL NORMAL
+#define COLOR_USED    RED 
+#define COLOR_BUFFERS YELLOW
+#define COLOR_CACHED  PURPLE
+#define COLOR_FREE    GREEN
+#define COLOR_NORMAL  NORMAL
 
 
 
@@ -66,9 +68,9 @@
 	unsigned int cached;
 
 	int pixels_mem_used;
-	int pixels_mem_buffered;
+	int pixels_mem_free;
+	int pixels_mem_buffers;
 	int pixels_mem_cached;
-	int pixels_mem_free;
 #define SWAP_TAG "Swap:"
 #define FREEC_SWAP_TOTAL "swaptotal:"
 	unsigned int swap_total;
@@ -115,5 +117,8 @@
 
 void
 print_usage(char **argv);
+
+int
+proportionality(int have, int total, int ratio);
 #endif