From ce2e37059c21803606557e44fe872174fed3772c Mon Sep 17 00:00:00 2001
From: =?utf8?q?Micha=C5=82=20Bartoszkiewicz?= <mbartoszkiewicz@gmail.com>
Date: Sat, 21 Dec 2013 11:44:49 +0100
Subject: [PATCH] Nie kolorujemy spacji

---
 choinka.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/choinka.c b/choinka.c
index c02dc72..b117972 100644
--- a/choinka.c
+++ b/choinka.c
@@ -5,6 +5,7 @@
 
 #define A_POGRUBIONY (1 << 0)
 
+#define KOLOR_BRAK -1
 #define KOLOR_CZARNY 0
 #define KOLOR_CZERWONY 1
 #define KOLOR_ZIELONY 2
@@ -29,6 +30,7 @@ static atrybut const bombki[] = {
 };
 static int const ile_b = sizeof bombki / sizeof *bombki;
 
+static atrybut const spacja = {0, KOLOR_BRAK};
 static atrybut const choinka = {0, KOLOR_ZIELONY};
 static atrybut const podstawa = {0, KOLOR_BRAZOWY};
 static atrybut const podpis = {A_POGRUBIONY, KOLOR_CZERWONY};
@@ -71,7 +73,9 @@ static void ustaw(atrybut const* attr)
   if ((attr->attr & A_POGRUBIONY) != 0) {
     putp(enter_bold_mode);
   }
-  putp(tparm(set_a_foreground, attr->kolor));
+  if (attr->kolor != KOLOR_BRAK) {
+    putp(tparm(set_a_foreground, attr->kolor));
+  }
 }
 
 int main()
@@ -86,6 +90,7 @@ int main()
     if (c >= 'a' && c <= 'z') akt = &podpis;
     if (c == '.') akt = &bombki[rand() % ile_b];
     if (c == '*') akt = &gwiazdka;
+    if (c == ' ' || c == '\n') akt = &spacja;
     if (c == ']') kolor = &choinka;
     ustaw(akt);
     putchar(c);
-- 
2.49.0