From 7107640dca11d91726c59920b368e66aa4f2f72e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Bartoszkiewicz?= Date: Sat, 27 Nov 2010 00:44:58 +0100 Subject: [PATCH] =?utf8?q?Uniezale=C5=BCnienie=20si=C4=99=20od=20ncurses.h?= =?utf8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- choinka.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/choinka.c b/choinka.c index b10f073..26f6c43 100644 --- a/choinka.c +++ b/choinka.c @@ -1,28 +1,38 @@ -#include #include #include #include #include +#define A_POGRUBIONY (1 << 0) + +#define KOLOR_CZARNY 0 +#define KOLOR_CZERWONY 1 +#define KOLOR_ZIELONY 2 +#define KOLOR_BRAZOWY 3 +#define KOLOR_NIEBIESKI 4 +#define KOLOR_MAGENTA 5 +#define KOLOR_CYJAN 6 +#define KOLOR_BIALY 7 + typedef struct { int attr; int kolor; } atrybut; atrybut const bombki[] = { - {A_BOLD, COLOR_RED}, - {A_BOLD, COLOR_BLUE}, - {A_BOLD, COLOR_YELLOW}, - {A_BOLD, COLOR_MAGENTA}, - {A_BOLD, COLOR_CYAN}, - {A_BOLD, COLOR_WHITE}, + {A_POGRUBIONY, KOLOR_CZERWONY}, + {A_POGRUBIONY, KOLOR_NIEBIESKI}, + {A_POGRUBIONY, KOLOR_BRAZOWY}, + {A_POGRUBIONY, KOLOR_MAGENTA}, + {A_POGRUBIONY, KOLOR_CYJAN}, + {A_POGRUBIONY, KOLOR_BIALY}, }; int const ile_b = sizeof bombki / sizeof *bombki; -atrybut const choinka = {0, COLOR_GREEN}; -atrybut const podstawa = {0, COLOR_YELLOW}; -atrybut const podpis = {A_BOLD, COLOR_RED}; -atrybut const gwiazdka = {A_BOLD, COLOR_YELLOW}; +atrybut const choinka = {0, KOLOR_ZIELONY}; +atrybut const podstawa = {0, KOLOR_BRAZOWY}; +atrybut const podpis = {A_POGRUBIONY, KOLOR_CZERWONY}; +atrybut const gwiazdka = {A_POGRUBIONY, KOLOR_BRAZOWY}; void inicjuj_rng() { @@ -57,10 +67,9 @@ void ustaw(atrybut const* attr) static atrybut ostatni = {-1, -1}; if (ostatni.attr == attr->attr && ostatni.kolor == attr->kolor) return; ostatni = *attr; - if (attr->attr & A_BOLD) { + putp(exit_attribute_mode); + if ((attr->attr & A_POGRUBIONY) != 0) { putp(enter_bold_mode); - } else { - putp(exit_attribute_mode); } putp(tparm(set_a_foreground, attr->kolor)); } -- 2.43.2