1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus { loading }{ ConTeXt Packing Macros Misc Commands }
15
16\unprotect
17
18
19
20
21
22
23
24
25\installcorenamespace { placement }
26
27\installcommandhandler \??placement { placement } \??placement
28
29\appendtoks
30 \setuevalue { \e!place \currentplacement }{ \pack_placement { \currentplacement }}
31\to \everydefineplacement
32
33\setupplacement
34 [ \c!left = \hss ,
35 \c!right = \hss ,
36 \c!linecorrection = \v!off ,
37 \c!depthcorrection = \v!off ,
38 \c!grid = \v!middle ,
39
40
41 \c!margin = \v!standard ]
42
43\unexpanded \def \placement [# tag ]
44 { \pack_placement { # tag }}
45
46\unexpanded \def \pack_placement # tag
47 { \bgroup
48 \edef \currentplacement { # tag }
49 \doifelsenextoptionalcs \pack_placement_yes \pack_placement_nop }
50
51\def \pack_placement_yes [# settings ]
52 { \setupcurrentplacement [# settings ]
53 \pack_placement_nop }
54
55\def \pack_placement_nop
56 { \dowithnextboxcontentcs\forgetall \pack_placement_flush \vbox }
57
58\def \pack_placement_flush
59 { \setlocalhsize
60 \placementparameter \c!before
61 \begingroup
62 \disableparpositions
63 \setbox \nextbox \hbox to \localhsize
64 { \placementparameter \c!left
65 \flushnextbox
66 \placementparameter \c!right }
67
68
69
70\flushnotes
71 \ifgridsnapping
72 \pack_placement_flush_grid_yes
73 \else
74 \pack_placement_flush_grid_nop
75 \fi
76 \endgroup
77 \placementparameter \c!after
78 \egroup }
79
80\def \pack_placement_flush_grid_yes
81 { \edef \p_grid { \placementparameter \c!grid }
82 \ifx \p_grid \empty
83 \let \p_grid \v!middle
84 \fi
85 \pack_placement_flush_grid_noindent
86 \snaptogrid [ \p_grid ] \hbox { \box \nextbox }}
87
88\def \pack_placement_flush_grid_nop
89 { \edef \p_linecorrection { \placementparameter \c!linecorrection }
90 \edef \p_depthcorrection { \placementparameter \c!depthcorrection }
91 \ifx \p_linecorrection \v!on
92 \startbaselinecorrection
93 \fi
94 \pack_placement_flush_grid_noindent
95 \box \nextbox
96 \ifx \p_depthcorrection \v!on
97 \baselinecorrection
98 \fi
99 \ifx \p_linecorrection \v!on
100 \stopbaselinecorrection
101 \fi }
102
103\def \pack_placement_flush_grid_noindent
104 { \edef \p_margin { \placementparameter \c!margin }
105 \ifx \p_margin \v!standard
106 \noindent
107 \else\ifx \p_margin \v!yes
108 \noindent
109 \fi\fi }
110
111\protect \endinput
112
113 |