st-noxz

[fork] suckless st - personal fork
git clone https://noxz.tech/git/st-noxz.git
Log | Files | README | LICENSE

st.h
1/* See LICENSE for license details. */
2
3#include <stdint.h>
4#include <sys/types.h>
5
6/* macros */
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 DIVCEIL(n, d)		(((n) + ((d) - 1)) / (d))
12#define DEFAULT(a, b)		(a) = (a) ? (a) : (b)
13#define LIMIT(x, a, b)		(x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
14#define ATTRCMP(a, b)		((a).mode != (b).mode || (a).fg != (b).fg || \
15				(a).bg != (b).bg)
16#define TIMEDIFF(t1, t2)	((t1.tv_sec-t2.tv_sec)*1000 + \
17				(t1.tv_nsec-t2.tv_nsec)/1E6)
18#define MODBIT(x, set, bit)	((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
19
20#define TRUECOLOR(r,g,b)	(1 << 24 | (r) << 16 | (g) << 8 | (b))
21#define IS_TRUECOL(x)		(1 << 24 & (x))
22
23enum glyph_attribute {
24	ATTR_NULL       = 0,
25	ATTR_BOLD       = 1 << 0,
26	ATTR_FAINT      = 1 << 1,
27	ATTR_ITALIC     = 1 << 2,
28	ATTR_UNDERLINE  = 1 << 3,
29	ATTR_BLINK      = 1 << 4,
30	ATTR_REVERSE    = 1 << 5,
31	ATTR_INVISIBLE  = 1 << 6,
32	ATTR_STRUCK     = 1 << 7,
33	ATTR_WRAP       = 1 << 8,
34	ATTR_WIDE       = 1 << 9,
35	ATTR_WDUMMY     = 1 << 10,
36	ATTR_BOXDRAW    = 1 << 11,
37	ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
38	ATTR_DIRTYUNDERLINE = 1 << 15,
39};
40
41enum drawing_mode {
42    DRAW_NONE = 0,
43    DRAW_BG = 1 << 0,
44    DRAW_FG = 1 << 1,
45};
46
47enum selection_mode {
48	SEL_IDLE = 0,
49	SEL_EMPTY = 1,
50	SEL_READY = 2
51};
52
53enum selection_type {
54	SEL_REGULAR = 1,
55	SEL_RECTANGULAR = 2
56};
57
58enum selection_snap {
59	SNAP_WORD = 1,
60	SNAP_LINE = 2
61};
62
63typedef unsigned char uchar;
64typedef unsigned int uint;
65typedef unsigned long ulong;
66typedef unsigned short ushort;
67
68typedef uint_least32_t Rune;
69
70#define Glyph Glyph_
71typedef struct {
72	Rune u;           /* character code */
73	ushort mode;      /* attribute flags */
74	uint32_t fg;      /* foreground  */
75	uint32_t bg;      /* background  */
76	int ustyle;	  /* underline style */
77	int ucolor[3];    /* underline color */
78} Glyph;
79
80typedef Glyph *Line;
81
82typedef union {
83	int i;
84	uint ui;
85	float f;
86	const void *v;
87	const char *s;
88} Arg;
89
90void die(const char *, ...);
91void redraw(void);
92void draw(void);
93
94void printscreen(const Arg *);
95void printsel(const Arg *);
96void sendbreak(const Arg *);
97void toggleprinter(const Arg *);
98
99int tattrset(int);
100void tnew(int, int);
101void tresize(int, int);
102void tsetdirtattr(int);
103void ttyhangup(void);
104int ttynew(const char *, char *, const char *, char **);
105size_t ttyread(void);
106void ttyresize(int, int);
107void ttywrite(const char *, size_t, int);
108
109void resettitle(void);
110
111void selclear(void);
112void selinit(void);
113void selstart(int, int, int);
114void selextend(int, int, int, int);
115int selected(int, int);
116char *getsel(void);
117
118size_t utf8encode(Rune, char *);
119
120void *xmalloc(size_t);
121void *xrealloc(void *, size_t);
122char *xstrdup(const char *);
123
124int isboxdraw(Rune);
125ushort boxdrawindex(const Glyph *);
126#ifdef XFT_VERSION
127/* only exposed to x.c, otherwise we'll need Xft.h for the types */
128void boxdraw_xinit(Display *, Colormap, XftDraw *, Visual *);
129void drawboxes(int, int, int, int, XftColor *, XftColor *, const XftGlyphFontSpec *, int);
130#endif
131
132/* config.h globals */
133extern char *utmp;
134extern char *scroll;
135extern char *stty_args;
136extern char *vtiden;
137extern wchar_t *worddelimiters;
138extern int allowaltscreen;
139extern int allowwindowops;
140extern char *termname;
141extern unsigned int tabspaces;
142extern unsigned int defaultfg;
143extern unsigned int defaultbg;
144extern unsigned int defaultcs;
145extern const int boxdraw, boxdraw_bold, boxdraw_braille;