spacing.dart
2.12 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
import 'size.dart';
import 'style.dart';
import 'syntax_tree.dart';
const thinspace = Measurement(value: 3, unit: Unit.mu);
const mediumspace = Measurement(value: 4, unit: Unit.mu);
const thickspace = Measurement(value: 5, unit: Unit.mu);
const Map<AtomType, Map<AtomType, Measurement>> _spacings = {
AtomType.ord: {
AtomType.op: thinspace,
AtomType.bin: mediumspace,
AtomType.rel: thickspace,
AtomType.inner: thinspace,
},
AtomType.op: {
AtomType.ord: thinspace,
AtomType.op: thinspace,
AtomType.rel: thickspace,
AtomType.inner: thinspace,
},
AtomType.bin: {
AtomType.ord: mediumspace,
AtomType.op: mediumspace,
AtomType.open: mediumspace,
AtomType.inner: mediumspace,
},
AtomType.rel: {
AtomType.ord: thickspace,
AtomType.op: thickspace,
AtomType.open: thickspace,
AtomType.inner: thickspace,
},
AtomType.open: {},
AtomType.close: {
AtomType.op: thinspace,
AtomType.bin: mediumspace,
AtomType.rel: thickspace,
AtomType.inner: thinspace,
},
AtomType.punct: {
AtomType.ord: thinspace,
AtomType.op: thinspace,
AtomType.rel: thickspace,
AtomType.open: thinspace,
AtomType.close: thinspace,
AtomType.punct: thinspace,
AtomType.inner: thinspace,
},
AtomType.inner: {
AtomType.ord: thinspace,
AtomType.op: thinspace,
AtomType.bin: mediumspace,
AtomType.rel: thickspace,
AtomType.open: thinspace,
AtomType.punct: thinspace,
AtomType.inner: thinspace,
},
AtomType.spacing: {},
};
const Map<AtomType, Map<AtomType, Measurement>> _tightSpacings = {
AtomType.ord: {
AtomType.op: thinspace,
},
AtomType.op: {
AtomType.ord: thinspace,
AtomType.op: thinspace,
},
AtomType.bin: {},
AtomType.rel: {},
AtomType.open: {},
AtomType.close: {
AtomType.op: thinspace,
},
AtomType.punct: {},
AtomType.inner: {
AtomType.op: thinspace,
},
AtomType.spacing: {},
};
Measurement getSpacingSize(AtomType left, AtomType right, MathStyle style) =>
(style <= MathStyle.script
? (_tightSpacings[left]?[right])
: _spacings[left]?[right]) ??
Measurement.zero;