-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdat.h
More file actions
154 lines (136 loc) · 1.8 KB
/
dat.h
File metadata and controls
154 lines (136 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <bio.h>
#include "ipc.h"
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
enum
{
LangEN = 0x14,
LangJP = 0x0e,
LangJPK = 0x0b,
LangKO = 0x13,
LangEMOJI = 0x05,
LangVI = 0x16,
Fontsz = 32,
Fontbase = 4,
Nglyphs = 0x20000,
};
enum
{
Maxclients = 64,
Maxkouho = 32,
Maxdisp = 8,
Imgw = 512,
Imgh = Maxdisp * Fontsz + 8,
Colfg = 0x000000,
Colbg = 0xffffff,
Colsel = 0xcccccc,
};
typedef struct Str Str;
struct Str
{
Rune r[64];
int n;
};
typedef struct Emit Emit;
struct Emit
{
int eat;
Str s;
Str next;
Str dict;
};
typedef struct Hnode Hnode;
struct Hnode
{
int filled;
int next;
char *key;
int klen;
char *val;
int vlen;
};
typedef struct Tnode Tnode;
struct Tnode
{
int child;
int sibling;
char c;
char *val;
int vlen;
};
typedef struct Trie Trie;
struct Trie
{
int root;
Tnode *nodes;
int n;
int cap;
};
typedef struct Hmap Hmap;
struct Hmap
{
int nbs;
int nsz;
int len;
int cap;
uchar *nodes;
};
typedef struct Lang Lang;
typedef struct Im Im;
struct Lang
{
int lang;
char *mapname;
char *dictname;
Emit (*trans)(Im*, Rune);
void (*back)(Im*);
void (*dictq)(Im*);
Trie *map;
Hmap *dict;
};
struct Im
{
Lang *l;
Str pre;
Str kouho[Maxkouho];
int nkouho;
int sel;
};
typedef struct Drawcmd Drawcmd;
struct Drawcmd
{
Str pre;
Str kouho[Maxdisp];
int nkouho;
int sel;
};
typedef struct Keyreq Keyreq;
struct Keyreq
{
int fd;
u32int ks;
u32int mod;
};
typedef struct Dictreq Dictreq;
struct Dictreq
{
Str key;
Str pre;
int lang;
};
typedef struct Dictres Dictres;
struct Dictres
{
Str key;
Str kouho[Maxkouho];
int nkouho;
};
extern Lang langs[];
extern int nlang;
extern Channel *drawc;
extern Channel *keyc;
extern Channel *dictreqc;
extern Channel *dictresc;