-
Notifications
You must be signed in to change notification settings - Fork 1
/
block_sym.c
62 lines (54 loc) · 1.43 KB
/
block_sym.c
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
#include "block_sym.h"
Block *
bracket(int height, const char *bracket) {
Block *block;
switch(bracket[0]) {
case '(': block = oparen(height); break;
case ')': block = cloparen(height); break;
case '[': block = obracket(height); break;
case ']': block = clobracket(height); break;
case '{': block = obrace(height); break;
case '}': block = clobrace(height); break;
}
return block;
}
Block *
oparen(int height) {
if(height == 1) return single("(");
return stretch3v(height, "⎛", "⎜", "⎝");
}
Block *
cloparen(int height) {
if(height == 1) return single(")");
return stretch3v(height, "⎞", "⎟", "⎠");
}
Block *
obracket(int height) {
if(height == 1) return single("[");
return stretch3v(height, "⎡", "⎢", "⎣");
}
Block *
clobracket(int height) {
if(height == 1) return single("]");
return stretch3v(height, "⎤", "⎥", "⎦");
}
Block *
obrace(int height) {
if(height == 1) return single("{");
if(height == 2) return concath(single("⎰"), single("⎱"));
if(height % 2 == 0) {
return stretch5v(height, "⎧", "⎪", "⎭", "⎫", "⎩");
} else {
return stretch4v(height, "⎧", "⎪", "⎨", "⎩");
}
}
Block *
clobrace(int height) {
if(height == 1) return single("}");
if(height == 2) return concath(single("⎱"), single("⎰"));
if(height % 2 == 0) {
return stretch5v(height,"⎫", "⎪", "⎩", "⎧", "⎭");
} else {
return stretch4v(height, "⎫", "⎪", "⎬", "⎭");
}
}