tested and fixed the module 'format'

This commit is contained in:
root committed 2026-10-05 23:46:12 +02:00
1 parent 1327ff8b0e
commit 38130ab1d9
2 files changed
+114 -85

No files matched your search

+28 -76
View File
@@ -7,88 +7,40 @@
#ifndef __FORMAT_H
#define __FORMAT_H
/* -- type definitions */
typedef struct {
unsigned char black;
unsigned char red;
unsigned char green;
unsigned char yellow;
unsigned char blue;
unsigned char magenta;
unsigned char cyan;
unsigned char white;
unsigned char extended;
unsigned char normal;
} colours_t;
#include "stdint.h"
typedef struct {
unsigned char bold;
unsigned char dim;
unsigned char italic;
unsigned char underlined;
unsigned char blinking;
unsigned char reversed;
unsigned char invisible;
unsigned char strikethrough;
/* -- defines */
#define NUMBER_STYLES ( ( int )8 )
#define NUMBER_COLOURS ( ( int )9 )
#define ESCAPE "\x1b"
#define SEQUENCE_PREFIX ESCAPE"["
#define SEQUENCE_SUFFIX "m"
/* -- type definitions */
typedef enum {
style_bold = 0u,
style_dim,
style_italic,
style_underlined,
style_blinking,
style_reversed,
style_invisible,
style_strikethrough
} style_t;
/* -- constant definitions */
const char* ESCAPE = "\x1b";
const char* SEQUENCE_PREFIX = "\x1b[";
const char* SEQUENCE_SUFFIX = "m";
const style_t STYLE_SET = {
.bold = 1u,
.dim = 2u,
.italic = 3u,
.underlined = 4u,
.blinking = 5u,
.reversed = 7u,
.invisible = 8u,
.strikethrough = 9u,
};
const style_t STYLE_RESET = {
.bold = 22u,
.dim = 22u,
.italic = 23u,
.underlined = 24u,
.blinking = 25u,
.reversed = 27u,
.invisible = 28u,
.strikethrough = 29u,
};
const colours_t COLOUR_FG = {
.black = 30u,
.red = 31u,
.green = 32u,
.yellow = 33u,
.blue = 34u,
.magenta = 35u,
.cyan = 36u,
.white = 37u,
.extended = 38u,
.normal = 39u,
};
const colours_t COLOUR_BG = {
.black = 40u,
.red = 41u,
.green = 42u,
.yellow = 43u,
.blue = 44u,
.magenta = 45u,
.cyan = 46u,
.white = 47u,
.extended = 48u,
.normal = 49u,
};
extern const uint8_t STYLE_SET[ NUMBER_STYLES ];
extern const uint8_t STYLE_RESET[ NUMBER_STYLES ];
/* -- function prototypes */
void format_reset( void );
void format_set_style( unsigned char style );
void format_reset_style( unsigned char style );
void format_clear( void );
void format_set_style( style_t* styles, uint8_t number_styles );
void format_reset_style( style_t* styles, uint8_t number_styles );
void format_set_fg_colour( uint32_t colour );
void format_set_bg_colour( uint32_t colour );
void format_clear_fg_colour( void );
void format_clear_bg_colour( void );
#endif