1 /* See LICENSE for license details. */
7 #define MIN(a, b) ((a) < (b) ? (a) : (b))
8 #define MAX(a, b) ((a) < (b) ? (b) : (a))
9 #define LEN(a) (sizeof(a) / sizeof(a)[0])
10 #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
11 #define OUT(x, a, b) ((a) <= (x) || (x) <= (b))
12 #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
13 #define DEFAULT(a, b) (a) = (a) ? (a) : (b)
14 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
15 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
17 #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
18 (t1.tv_nsec-t2.tv_nsec)/1E6)
19 #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
21 #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
22 #define IS_TRUECOL(x) (1 << 24 & (x))
24 enum glyph_attribute {
29 ATTR_UNDERLINE = 1 << 3,
31 ATTR_REVERSE = 1 << 5,
32 ATTR_INVISIBLE = 1 << 6,
36 ATTR_WDUMMY = 1 << 10,
37 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
56 typedef unsigned char uchar;
57 typedef unsigned int uint;
58 typedef unsigned long ulong;
59 typedef unsigned short ushort;
61 typedef uint_least32_t Rune;
65 Rune u; /* character code */
66 ushort mode; /* attribute flags */
67 uint32_t fg; /* foreground */
68 uint32_t bg; /* background */
81 void die(const char *, ...);
85 void newterm(const Arg *);
86 void printscreen(const Arg *);
87 void printsel(const Arg *);
88 void sendbreak(const Arg *);
89 void toggleprinter(const Arg *);
93 void tresize(int, int);
94 void tsetdirtattr(int);
96 int ttynew(char *, char *, char *, char **);
98 void ttyresize(int, int);
99 void ttywrite(const char *, size_t, int);
101 void resettitle(void);
105 void selstart(int, int, int);
106 void selextend(int, int, int, int);
107 int selected(int, int);
110 size_t utf8encode(Rune, char *);
112 void *xmalloc(size_t);
113 void *xrealloc(void *, size_t);
114 char *xstrdup(char *);
116 /* config.h globals */
119 extern char *stty_args;
121 extern wchar_t *worddelimiters;
122 extern int allowaltscreen;
123 extern int allowwindowops;
124 extern char *termname;
125 extern unsigned int tabspaces;
126 extern unsigned int defaultfg;
127 extern unsigned int defaultbg;