st

simple terminal with alpha focus highlight and selenized colorscheme
git clone https://git.beauhilton.com/st.git
Log | Files | Refs | README | LICENSE

st.h (2932B)


      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 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 || \
     16 				(a).bg != (b).bg)
     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)))
     20 
     21 #define TRUECOLOR(r,g,b)	(1 << 24 | (r) << 16 | (g) << 8 | (b))
     22 #define IS_TRUECOL(x)		(1 << 24 & (x))
     23 
     24 enum glyph_attribute {
     25 	ATTR_NULL       = 0,
     26 	ATTR_BOLD       = 1 << 0,
     27 	ATTR_FAINT      = 1 << 1,
     28 	ATTR_ITALIC     = 1 << 2,
     29 	ATTR_UNDERLINE  = 1 << 3,
     30 	ATTR_BLINK      = 1 << 4,
     31 	ATTR_REVERSE    = 1 << 5,
     32 	ATTR_INVISIBLE  = 1 << 6,
     33 	ATTR_STRUCK     = 1 << 7,
     34 	ATTR_WRAP       = 1 << 8,
     35 	ATTR_WIDE       = 1 << 9,
     36 	ATTR_WDUMMY     = 1 << 10,
     37 	ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
     38 };
     39 
     40 enum selection_mode {
     41 	SEL_IDLE = 0,
     42 	SEL_EMPTY = 1,
     43 	SEL_READY = 2
     44 };
     45 
     46 enum selection_type {
     47 	SEL_REGULAR = 1,
     48 	SEL_RECTANGULAR = 2
     49 };
     50 
     51 enum selection_snap {
     52 	SNAP_WORD = 1,
     53 	SNAP_LINE = 2
     54 };
     55 
     56 typedef unsigned char uchar;
     57 typedef unsigned int uint;
     58 typedef unsigned long ulong;
     59 typedef unsigned short ushort;
     60 
     61 typedef uint_least32_t Rune;
     62 
     63 #define Glyph Glyph_
     64 typedef struct {
     65 	Rune u;           /* character code */
     66 	ushort mode;      /* attribute flags */
     67 	uint32_t fg;      /* foreground  */
     68 	uint32_t bg;      /* background  */
     69 } Glyph;
     70 
     71 typedef Glyph *Line;
     72 
     73 typedef union {
     74 	int i;
     75 	uint ui;
     76 	float f;
     77 	const void *v;
     78 	const char *s;
     79 } Arg;
     80 
     81 void die(const char *, ...);
     82 void redraw(void);
     83 void draw(void);
     84 
     85 void printscreen(const Arg *);
     86 void printsel(const Arg *);
     87 void sendbreak(const Arg *);
     88 void toggleprinter(const Arg *);
     89 
     90 int tattrset(int);
     91 void tnew(int, int);
     92 void tresize(int, int);
     93 void tsetdirtattr(int);
     94 void ttyhangup(void);
     95 int ttynew(char *, char *, char *, char **);
     96 size_t ttyread(void);
     97 void ttyresize(int, int);
     98 void ttywrite(const char *, size_t, int);
     99 
    100 void resettitle(void);
    101 
    102 void selclear(void);
    103 void selinit(void);
    104 void selstart(int, int, int);
    105 void selextend(int, int, int, int);
    106 int selected(int, int);
    107 char *getsel(void);
    108 
    109 size_t utf8encode(Rune, char *);
    110 
    111 void *xmalloc(size_t);
    112 void *xrealloc(void *, size_t);
    113 char *xstrdup(char *);
    114 
    115 /* config.h globals */
    116 extern char *utmp;
    117 extern char *scroll;
    118 extern char *stty_args;
    119 extern char *vtiden;
    120 extern wchar_t *worddelimiters;
    121 extern int allowaltscreen;
    122 extern char *termname;
    123 extern unsigned int tabspaces;
    124 extern unsigned int defaultfg;
    125 extern unsigned int defaultbg;
    126 extern float alpha, alphaUnfocused;