💾 Archived View for gemini.rmf-dev.com › repo › Vaati › Menkar › files › 9d04b6696e90b47260816f63c69… captured on 2023-04-19 at 23:19:24. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-03-20)

➡️ Next capture (2023-09-08)

-=-=-=-=-=-=-

0 /* See LICENSE for license details. */

1

2 #include <stdint.h>

3 #include <sys/types.h>

4

5 /* macros */

6 #define MIN(a, b) ((a) < (b) ? (a) : (b))

7 #define MAX(a, b) ((a) < (b) ? (b) : (a))

8 #define LEN(a) (sizeof(a) / sizeof(a)[0])

9 #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))

10 #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))

11 #define DEFAULT(a, b) (a) = (a) ? (a) : (b)

12 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)

13 #define ATTRCMP(a, b) ((a).mode != (b).mode || (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

19 #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))

20 #define IS_TRUECOL(x) (1 << 24 & (x))

21

22 enum glyph_attribute {

23 ATTR_NULL = 0,

24 ATTR_BOLD = 1 << 0,

25 ATTR_FAINT = 1 << 1,

26 ATTR_ITALIC = 1 << 2,

27 ATTR_UNDERLINE = 1 << 3,

28 ATTR_BLINK = 1 << 4,

29 ATTR_REVERSE = 1 << 5,

30 ATTR_INVISIBLE = 1 << 6,

31 ATTR_STRUCK = 1 << 7,

32 ATTR_WRAP = 1 << 8,

33 ATTR_WIDE = 1 << 9,

34 ATTR_WDUMMY = 1 << 10,

35 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,

36 };

37

38 enum selection_mode {

39 SEL_IDLE = 0,

40 SEL_EMPTY = 1,

41 SEL_READY = 2

42 };

43

44 enum selection_type {

45 SEL_REGULAR = 1,

46 SEL_RECTANGULAR = 2

47 };

48

49 enum selection_snap {

50 SNAP_WORD = 1,

51 SNAP_LINE = 2

52 };

53

54 typedef unsigned char uchar;

55 typedef unsigned int uint;

56 typedef unsigned long ulong;

57 typedef unsigned short ushort;

58

59 typedef uint_least32_t Rune;

60

61 #define Glyph Glyph_

62 typedef struct {

63 Rune u; /* character code */

64 ushort mode; /* attribute flags */

65 uint32_t fg; /* foreground */

66 uint32_t bg; /* background */

67 } Glyph;

68

69 typedef Glyph *Line;

70

71 typedef union {

72 int i;

73 uint ui;

74 float f;

75 const void *v;

76 const char *s;

77 } Arg;

78

79 void die(const char *, ...);

80 void redraw(void);

81 void draw(void);

82

83 void kscrolldown(const Arg *);

84 void kscrollup(const Arg *);

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 int tisaltscr(void);

92 void tnew(int, int);

93 void tresize(int, int);

94 void tsetdirtattr(int);

95 void ttyhangup(void);

96 int ttynew(const char *, char *, const char *, char **);

97 size_t ttyread(void);

98 void ttyresize(int, int);

99 void ttywrite(const char *, size_t, int);

100

101 void resettitle(void);

102

103 void selclear(void);

104 void selinit(void);

105 void selstart(int, int, int);

106 void selextend(int, int, int, int);

107 int selected(int, int);

108 char *getsel(void);

109

110 size_t utf8encode(Rune, char *);

111

112 void *xmalloc(size_t);

113 void *xrealloc(void *, size_t);

114 char *xstrdup(const char *);

115

116 /* config.h globals */

117 extern char *utmp;

118 extern char *scroll;

119 extern char *stty_args;

120 extern char *vtiden;

121 extern wchar_t *worddelimiters;

122 extern int allowaltscreen;

123 extern int allowwindowops;

124 extern char *termname;

125 extern unsigned int tabspaces;

126 extern unsigned int defaultfg;

127 extern unsigned int defaultbg;

128