CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
constyle.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "console.h"
7
8CX_C_BEGIN
9
13
16#define CON_ColorDefault 0u
17
25#define CON_Idx(n) (0x01000000u | (uint32)(uint8)(n))
26
31#define CON_RGB(r, g, b) \
32 (0x02000000u | ((uint32)(uint8)(r) << 16) | ((uint32)(uint8)(g) << 8) | (uint32)(uint8)(b))
33
36#define CON_Black CON_Idx(0)
37#define CON_Red CON_Idx(1)
38#define CON_Green CON_Idx(2)
39#define CON_Yellow CON_Idx(3)
40#define CON_Blue CON_Idx(4)
41#define CON_Magenta CON_Idx(5)
42#define CON_Cyan CON_Idx(6)
43#define CON_White CON_Idx(7)
44#define CON_BrightBlack CON_Idx(8)
45#define CON_BrightRed CON_Idx(9)
46#define CON_BrightGreen CON_Idx(10)
47#define CON_BrightYellow CON_Idx(11)
48#define CON_BrightBlue CON_Idx(12)
49#define CON_BrightMagenta CON_Idx(13)
50#define CON_BrightCyan CON_Idx(14)
51#define CON_BrightWhite CON_Idx(15)
53
57 CON_Bold = 0x01,
58 CON_Dim = 0x02,
59 CON_Italic = 0x04,
60 CON_Underline = 0x08,
61 CON_Blink = 0x10,
62 CON_Reverse = 0x20,
63 CON_Strike = 0x40,
64};
65
68typedef struct ConStyle {
69 uint32 fg;
70 uint32 bg;
71 flags_t attr;
73
77#define CONSTYLE(fg, attr) ((ConStyle) { (fg), CON_ColorDefault, (attr) })
78
82#define CONSTYLE2(fg, bg, attr) ((ConStyle) { (fg), (bg), (attr) })
83
89void conSetStyle(_In_ ConStream* con, ConStyle style);
90
94void conResetStyle(_In_ ConStream* con);
95
100void conGetStyle(_In_ ConStream* con, _Out_ ConStyle* out);
101
109bool conWriteS(_In_ ConStream* con, ConStyle style, _In_reads_bytes_(sz) const void* buf,
110 size_t sz);
111
119bool conPutsS(_In_ ConStream* con, ConStyle style, _In_opt_ strref s);
120
127bool conPutszS(_In_ ConStream* con, ConStyle style, _In_opt_z_ const char* sz);
128
135bool conPutcS(_In_ ConStream* con, ConStyle style, int32 codepoint);
136
152bool _conFmtS(_In_ ConStream* con, ConStyle style, _In_ strref fmt, int n, _In_ stvar* args);
153#define conFmtS(con, style, fmt, ...) \
154 _conFmtS(con, style, fmt, count_macro_args(__VA_ARGS__), (stvar[]) { __VA_ARGS__ })
155
157
158CX_C_END
void conSetStyle(ConStream *con, ConStyle style)
bool _conFmtS(ConStream *con, ConStyle style, strref fmt, int n, stvar *args)
CON_ATTR_FLAGS
Definition constyle.h:56
bool conPutszS(ConStream *con, ConStyle style, const char *sz)
bool conPutcS(ConStream *con, ConStyle style, int32 codepoint)
void conGetStyle(ConStream *con, ConStyle *out)
bool conPutsS(ConStream *con, ConStyle style, strref s)
void conResetStyle(ConStream *con)
bool conWriteS(ConStream *con, ConStyle style, const void *buf, size_t sz)
#define stvar(typen, val)
Definition stvar.h:162
flags_t attr
Bitwise OR of CON_ATTR_FLAGS.
Definition constyle.h:71
uint32 fg
CON_ColorDefault, CON_Idx(n), or CON_RGB(r,g,b)
Definition constyle.h:69
uint32 bg
CON_ColorDefault, CON_Idx(n), or CON_RGB(r,g,b)
Definition constyle.h:70