]> git.bzium.org - embe/choinka.git/commitdiff
Nie kolorujemy spacji
authorMichał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
Sat, 21 Dec 2013 10:44:49 +0000 (11:44 +0100)
committerMichał Bartoszkiewicz <mbartoszkiewicz@gmail.com>
Sat, 21 Dec 2013 10:44:49 +0000 (11:44 +0100)
choinka.c

index c02dc72d5069fd15b88f3c13820c736796ea0c08..b117972281f325bb341ccf914f85202cf741fbce 100644 (file)
--- a/choinka.c
+++ b/choinka.c
@@ -5,6 +5,7 @@
 
 #define A_POGRUBIONY (1 << 0)
 
 
 #define A_POGRUBIONY (1 << 0)
 
+#define KOLOR_BRAK -1
 #define KOLOR_CZARNY 0
 #define KOLOR_CZERWONY 1
 #define KOLOR_ZIELONY 2
 #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 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};
 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);
   }
   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()
 }
 
 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 >= '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);
     if (c == ']') kolor = &choinka;
     ustaw(akt);
     putchar(c);