1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Packaging Macros Anchoring}
15
16\registerctxluafile{packori}{autosuffix}
17
18\unprotect
19
20
21
22
23
24
25
26
27
28\installcorenamespace{orientation}
29\installcorenamespace{orientations}
30
31\installcommandhandler \??orientation {orientation} \??orientation
32
33\setuporientation
34 [\c!orientation=\v!normal,
35 \c!horizontal=\v!normal,
36 \c!vertical=\v!normal]
37
38\appendtoks
39 \expandafter\integerdef\csname\??orientations\currentorientation\endcsname\toorientation
40 orientation {\orientationparameter\c!orientation}
41 horizontal {\orientationparameter\c!horizontal}
42 vertical {\orientationparameter\c!vertical}
43 \relax\relax
44\to \everydefineorientation
45
46\defineorientation[\v!normal]
47
48\defineorientation[\v!up] [\c!orientation=\v!up]
49\defineorientation[\v!down] [\c!orientation=\v!down]
50\defineorientation[\v!left] [\c!orientation=\v!left]
51\defineorientation[\v!right] [\c!orientation=\v!right]
52\defineorientation[\v!top] [\c!orientation=\v!top]
53\defineorientation[\v!bottom][\c!orientation=\v!bottom]
54\defineorientation[\v!line] [\c!orientation=\v!line]
55
56
57
58\permanent\def\theorientation#1
59 {\numexpr
60 \ifcsname\??orientations#1\endcsname
61 \lastnamedcs
62 \else
63 \zerocount
64 \fi
65 \relax}
66
67\permanent\def\autoorientation#1
68 {\numexpr
69 \ifcsname\??orientations#1\endcsname
70 \lastnamedcs
71 \else
72 \auto_orientation{#1}
73 \fi
74 \relax}
75
76
77
78
79
80
81
82
83\def\auto_orientation#1
84 {\beginlocalcontrol\global\expandafter\chardef\csname\??orientations#1\endcsname\stringtoorientation{#1}\endlocalcontrol
85
86 \csname\??orientations#1\endcsname}
87
88\permanent\protected\def\doifelseorientation#1
89 {\ifcsname\??orientations#1\endcsname
90 \expandafter\firstoftwoarguments
91 \else
92 \expandafter\secondoftwoarguments
93 \fi}
94
95
96
97\protect \endinput
98 |