ST patched with stuff from https://st.suckless.org/patches/ to work as a lighter alternative to XTerm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
2.9 KiB

  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 != (b).mode || (a).fg != (b).fg || \
  13. (a).bg != (b).bg)
  14. #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
  15. (t1.tv_nsec-t2.tv_nsec)/1E6)
  16. #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
  17. #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
  18. #define IS_TRUECOL(x) (1 << 24 & (x))
  19. #define HISTSIZE 2000
  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_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
  34. };
  35. enum selection_mode {
  36. SEL_IDLE = 0,
  37. SEL_EMPTY = 1,
  38. SEL_READY = 2
  39. };
  40. enum selection_type {
  41. SEL_REGULAR = 1,
  42. SEL_RECTANGULAR = 2
  43. };
  44. enum selection_snap {
  45. SNAP_WORD = 1,
  46. SNAP_LINE = 2
  47. };
  48. typedef unsigned char uchar;
  49. typedef unsigned int uint;
  50. typedef unsigned long ulong;
  51. typedef unsigned short ushort;
  52. typedef uint_least32_t Rune;
  53. #define Glyph Glyph_
  54. typedef struct {
  55. Rune u; /* character code */
  56. ushort mode; /* attribute flags */
  57. uint32_t fg; /* foreground */
  58. uint32_t bg; /* background */
  59. } Glyph;
  60. typedef Glyph *Line;
  61. typedef union {
  62. int i;
  63. uint ui;
  64. float f;
  65. const void *v;
  66. const char *s;
  67. } Arg;
  68. void die(const char *, ...);
  69. void redraw(void);
  70. void draw(void);
  71. void printscreen(const Arg *);
  72. void printsel(const Arg *);
  73. void sendbreak(const Arg *);
  74. void toggleprinter(const Arg *);
  75. int tattrset(int);
  76. int tisaltscr(void);
  77. void tnew(int, int);
  78. void tresize(int, int);
  79. void tsetdirtattr(int);
  80. void ttyhangup(void);
  81. int ttynew(const char *, char *, const char *, char **);
  82. size_t ttyread(void);
  83. void ttyresize(int, int);
  84. void ttywrite(const char *, size_t, int);
  85. void resettitle(void);
  86. void selclear(void);
  87. void selinit(void);
  88. void selstart(int, int, int);
  89. void selextend(int, int, int, int);
  90. int selected(int, int);
  91. char *getsel(void);
  92. size_t utf8encode(Rune, char *);
  93. void *xmalloc(size_t);
  94. void *xrealloc(void *, size_t);
  95. char *xstrdup(const char *);
  96. /* config.h globals */
  97. extern char *utmp;
  98. extern char *scroll;
  99. extern char *stty_args;
  100. extern char *vtiden;
  101. extern wchar_t *worddelimiters;
  102. extern int allowaltscreen;
  103. extern int allowwindowops;
  104. extern char *termname;
  105. extern unsigned int tabspaces;
  106. extern unsigned int defaultfg;
  107. extern unsigned int defaultbg;
  108. extern unsigned int defaultcs;