---
title: "🎉 Цветной выхлоп на Си"
date: 2022-07-26T22:43:46+03:00
draft: false
tags: [development, c]
---

Лучи благодарности [LINUXTALKS-CO](https://linuxtalks.co/people/LINUXTALKS-CO/profile)/
[LINUX-ORG-RU](https://www.linux.org.ru/people/LINUX-ORG-RU/profile).

```c
#include <stdio.h>

/*--------------Тут просто кишки----------------*/

/*просто цвета*/
#ifndef color_off
    #define cired()  "\x1B[31m"
    #define cigre()  "\x1B[32m"
    #define ciyel()  "\x1B[33m"
    #define ciaqu()  "\x1B[36m"
    #define cidef()  "\x1B[39m"
#else
    #define cired()
    #define cigre()
    #define ciyel()
    #define ciaqu()
    #define cidef()
#endif

/*цвета + начертания - жирно*/
#ifndef bold_off
    #define b_cired()  "\x1B[1;31m"
    #define b_cigre()  "\x1B[1;32m"
    #define b_ciyel()  "\x1B[1;33m"
    #define b_ciaqu()  "\x1B[1;36m"
    #define b_cidef()  "\x1B[1;39m"
    #define boldoff()  "\x1B[0m"
#else
    #define b_cired()  cired()
    #define b_cigre()  cigre()
    #define b_ciyel()  ciyel()
    #define b_ciaqu()  ciaqu()
    #define b_cidef()  cidef()
#endif

/*цвета + начернтание - курсив*/
#ifndef cur_off
    #define c_cired()  "\x1B[3;31m"
    #define c_cigre()  "\x1B[3;32m"
    #define c_ciyel()  "\x1B[3;33m"
    #define c_ciaqu()  "\x1B[3;36m"
    #define c_cidef()  "\x1B[3;39m"
    #define cursoff()  "\x1B[0m"
#else
    #define c_cired()  cired()
    #define c_cigre()  cigre()
    #define c_ciyel()  ciyel()
    #define c_ciaqu()  ciaqu()
    #define c_cidef()  cidef()
#endif

/*---------------------тут API само-----------------------*/

#define red(message) cired() message cidef()
#define gre(message) cigre() message cidef()
#define def(message) cidef() message cidef()
#define yel(message) ciyel() message cidef()
#define aqu(message) ciaqu() message cidef()

#define b_red(message) b_cired() message cidef() boldoff() 
#define b_gre(message) b_cigre() message cidef() boldoff() 
#define b_def(message) b_cidef() message cidef() boldoff() 
#define b_yel(message) b_ciyel() message cidef() boldoff() 
#define b_aqu(message) b_ciaqu() message cidef() boldoff() 

#define c_red(message) c_cired() message cidef() cursoff() 
#define c_gre(message) c_cigre() message cidef() cursoff() 
#define c_def(message) c_cidef() message cidef() cursoff() 
#define c_yel(message) c_ciyel() message cidef() cursoff() 
#define c_aqu(message) c_ciaqu() message cidef() cursoff()

enum
{
    RED     = 31,
    GREEN   = 32,
    YELLOW  = 33,
    BLUE    = 34,
    PURPULE = 35,
    AQUA    = 36,
    DEFAULT = 39,
};
static void colorset(int color)
{
  printf("\x1B[%dm",color);
}

int main(int argc, char *argv[])
{
    const char text[] = aqu("А я томат!");

    printf( b_red("Это ") gre("разноцветный ") c_yel("текст. %s\n"), text);


    printf("В этом "b_red("ЖИРНОМ")" царстве-государстве всё красное и "c_red("курсивное!")" иногда\n");

    printf(yel("А в этом всё" b_red(" не ") c_aqu("жёлтое") " и обычное!\n"));

    printf(c_gre("А ") b_gre("в ") c_aqu("остальных по обычному ")c_gre("!\n"));
    return 0;
}
```

![preview](https://i.ibb.co/jJXn8S6/2022-06-05-18-55-42.png)

[Ссылка на оригинал](https://linuxtalks.co/forum/development/474?cid=615)
