st.h.orig 3.4 KB

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