st.h (1618B)
1 /* See LICENSE for license details. */ 2 /* Requires: stdint.h, size_t, util.h */ 3 4 #define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ 5 (a).bg != (b).bg) 6 #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) 7 #define IS_TRUECOL(x) (1 << 24 & (x)) 8 9 enum glyph_attribute { 10 ATTR_NULL = 0, 11 ATTR_BOLD = 1 << 0, 12 ATTR_FAINT = 1 << 1, 13 ATTR_ITALIC = 1 << 2, 14 ATTR_UNDERLINE = 1 << 3, 15 ATTR_BLINK = 1 << 4, 16 ATTR_REVERSE = 1 << 5, 17 ATTR_INVISIBLE = 1 << 6, 18 ATTR_STRUCK = 1 << 7, 19 ATTR_WRAP = 1 << 8, 20 ATTR_WIDE = 1 << 9, 21 ATTR_WDUMMY = 1 << 10, 22 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, 23 }; 24 25 enum selection_mode { 26 SEL_IDLE = 0, 27 SEL_EMPTY = 1, 28 SEL_READY = 2 29 }; 30 31 enum selection_type { 32 SEL_REGULAR = 1, 33 SEL_RECTANGULAR = 2 34 }; 35 36 enum selection_snap { 37 SNAP_WORD = 1, 38 SNAP_LINE = 2 39 }; 40 41 #define Glyph Glyph_ 42 typedef struct { 43 Rune u; /* character code */ 44 ushort mode; /* attribute flags */ 45 uint32_t fg; /* foreground */ 46 uint32_t bg; /* background */ 47 } Glyph; 48 49 typedef Glyph *Line; 50 51 void redraw(void); 52 void draw(void); 53 54 void ttogprinter(void); 55 void tdump(void); 56 void tdumpsel(void); 57 void tsendbreak(void); 58 int tattrset(int); 59 void tnew(int, int); 60 void tresize(int, int); 61 void tsetdirtattr(int); 62 void ttyhangup(void); 63 int ttynew(const char *, char *, const char *, char **); 64 size_t ttyread(void); 65 void ttyresize(int, int); 66 void ttywrite(const char *, size_t, int); 67 68 void selclear(void); 69 void selinit(void); 70 void selstart(int, int, int); 71 void selextend(int, int, int, int); 72 int selected(int, int); 73 char *getsel(void);