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
|
%D \module
%D [ file=pack-ori, % was experimental
%D version=2019.07.30,
%D title=\CONTEXT\ Packaging Macros,
%D subtitle=Anchoring,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Packaging Macros / Anchoring}
\registerctxluafile{pack-ori}{autosuffix}
\unprotect
%D Possible options are:
%D
%D \starttabulate[|T|T|]
%D \NC orientation \NC up left down right top bottom
%D \NC vertical \NC line top bottom middle
%D \NC horizontal \NC middle flushleft flushright left right
%D \stoptabulate
\installcorenamespace{orientation}
\installcorenamespace{orientations}
\installcommandhandler \??orientation {orientation} \??orientation
\setuporientation
[\c!orientation=\v!normal,
\c!horizontal=\v!normal,
\c!vertical=\v!normal]
\appendtoks
\expandafter\chardef\csname\??orientations\currentorientation\endcsname\toorientation
orientation {\orientationparameter\c!orientation}
horizontal {\orientationparameter\c!horizontal}
vertical {\orientationparameter\c!vertical}
\relax\relax
\to \everydefineorientation
\defineorientation[\v!normal]
\defineorientation[\v!up] [\c!orientation=\v!up]
\defineorientation[\v!down] [\c!orientation=\v!down]
\defineorientation[\v!left] [\c!orientation=\v!left]
\defineorientation[\v!right] [\c!orientation=\v!right]
\defineorientation[\v!top] [\c!orientation=\v!top]
\defineorientation[\v!bottom][\c!orientation=\v!bottom]
%D There will be some more helpers here.
\permanent\def\theorientation#1%
{\numexpr
\ifcsname\??orientations#1\endcsname
\lastnamedcs
\else
\zerocount
\fi
\relax}
\permanent\def\autoorientation#1%
{\numexpr
\ifcsname\??orientations#1\endcsname
\lastnamedcs
\else
\auto_orientation{#1}%
\fi
\relax}
%D The \type {\immediateassignment} and \type {\immediateassigned} primitives that
%D are in \LUATEX\ are obsolete in \LUAMETATEX. Local scanning is, although it is
%D a bit slower, more general. We didn't really need and use these primitives in
%D \CONTEXT\ anyway, apart from some playing around with some full expansion, which
%D made no sense in the end so it was dropped. When things get that hairy it's often
%D a good reason to look into \LUA\ variants.
\def\auto_orientation#1%
{\beginlocalcontrol\global\expandafter\chardef\csname\??orientations#1\endcsname\stringtoorientation{#1}\endlocalcontrol % good enough
%{\localcontrolled{\global\expandafter\chardef\csname\??orientations#1\endcsname\stringtoorientation{#1}}% % a bit slower
\csname\??orientations#1\endcsname}
\permanent\protected\def\doifelseorientation#1%
{\ifcsname\??orientations#1\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
% \def\iforientationcsname#1{\ifcsname\??orientations}
\protect \endinput
|