6 #define A_POGRUBIONY (1 << 0)
 
   9 #define KOLOR_CZERWONY 1
 
  10 #define KOLOR_ZIELONY 2
 
  11 #define KOLOR_BRAZOWY 3
 
  12 #define KOLOR_NIEBIESKI 4
 
  13 #define KOLOR_MAGENTA 5
 
  22 static atrybut const bombki[] = {
 
  23   {A_POGRUBIONY, KOLOR_CZERWONY},
 
  24   {A_POGRUBIONY, KOLOR_NIEBIESKI},
 
  25   {A_POGRUBIONY, KOLOR_BRAZOWY},
 
  26   {A_POGRUBIONY, KOLOR_MAGENTA},
 
  27   {A_POGRUBIONY, KOLOR_CYJAN},
 
  28   {A_POGRUBIONY, KOLOR_BIALY},
 
  30 static int const ile_b = sizeof bombki / sizeof *bombki;
 
  32 static atrybut const choinka = {0, KOLOR_ZIELONY};
 
  33 static atrybut const podstawa = {0, KOLOR_BRAZOWY};
 
  34 static atrybut const podpis = {A_POGRUBIONY, KOLOR_CZERWONY};
 
  35 static atrybut const gwiazdka = {A_POGRUBIONY, KOLOR_BRAZOWY};
 
  37 static void inicjuj_rng()
 
  40   FILE* f = fopen("/dev/urandom", "rb");
 
  43     if (fread(&nowe_ziarno, sizeof nowe_ziarno, 1, f) == 1) {
 
  54 static char const rysunek[] =
 
  65 static void ustaw(atrybut const* attr)
 
  67   static atrybut ostatni = {-1, -1};
 
  68   if (ostatni.attr == attr->attr && ostatni.kolor == attr->kolor) return;
 
  70   putp(exit_attribute_mode);
 
  71   if ((attr->attr & A_POGRUBIONY) != 0) {
 
  72     putp(enter_bold_mode);
 
  74   putp(tparm(set_a_foreground, attr->kolor));
 
  80   setupterm(NULL, 1, NULL);
 
  81   atrybut const* kolor = &choinka;
 
  82   for (int i = 0; rysunek[i] != '\0'; i++) {
 
  84     if (c == '[') kolor = &podstawa;
 
  85     atrybut const* akt = kolor;
 
  86     if (c >= 'a' && c <= 'z') akt = &podpis;
 
  87     if (c == '.') akt = &bombki[rand() % ile_b];
 
  88     if (c == '*') akt = &gwiazdka;
 
  89     if (c == ']') kolor = &choinka;
 
  93   putp(exit_attribute_mode);