diff --git a/.gitignore b/.gitignore index 87ca7d5..497082c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build/ # compile_commands.json symlink +compile_commands.json diff --git a/src/st/macros.h b/src/st/macros.h new file mode 100644 index 0000000..a272a2f --- /dev/null +++ b/src/st/macros.h @@ -0,0 +1,20 @@ +#ifndef MACROS_H +#define MACROS_H + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#define LEN(a) (sizeof(a) / sizeof(a)[0]) +#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) +#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) +#define DEFAULT(a, b) (a) = (a) ? (a) : (b) +#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) +#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ + (a).bg != (b).bg) +#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ + (t1.tv_nsec-t2.tv_nsec)/1E6) +#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) + +#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) +#define IS_TRUECOL(x) (1 << 24 & (x)) + +#endif diff --git a/src/st/st.c b/src/st/st.c index 5758702..44bfd1d 100644 --- a/src/st/st.c +++ b/src/st/st.c @@ -18,6 +18,7 @@ #include #include "st.h" +#include "macros.h" #include "../win.h" #if defined(__linux) diff --git a/src/st/st.h b/src/st/st.h index 1750b14..19924bd 100644 --- a/src/st/st.h +++ b/src/st/st.h @@ -7,23 +7,6 @@ #include #include -/* macros */ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) < (b) ? (b) : (a)) -#define LEN(a) (sizeof(a) / sizeof(a)[0]) -#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) -#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) -#define DEFAULT(a, b) (a) = (a) ? (a) : (b) -#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) -#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ - (a).bg != (b).bg) -#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ - (t1.tv_nsec-t2.tv_nsec)/1E6) -#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) - -#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) -#define IS_TRUECOL(x) (1 << 24 & (x)) - enum glyph_attribute { ATTR_NULL = 0, ATTR_BOLD = 1 << 0, diff --git a/src/x.c b/src/x.c index f973a1d..c93f126 100644 --- a/src/x.c +++ b/src/x.c @@ -18,6 +18,7 @@ char *argv0; #include "arg.h" #include "st/st.h" +#include "st/macros.h" #include "win.h" /* types used in config.h */