summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/page-inf.mkxl
blob: 4865d5990cb8ddc3f916bcf562b040825fecd8fc (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%D \module
%D   [       file=page-inf,   % moved from page-ini
%D        version=2011.12.07, % 2000.10.20,
%D          title=\CONTEXT\ Page Macros,
%D       subtitle=Tracing Info,
%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 Page Macros / Tracing Info}

% This needs a real cleanup .. will be a more detailed list.

\unprotect

\installcorenamespace{layoutinfo}

\newtoks\everyresetversion
\newtoks\everysetupversion

\mutable\lettonothing\currentversioninfo
\mutable\lettonothing\currentversiontext

\let\page_info_add_to_box\gobbleoneargument

\permanent\tolerant\protected\def\setupversion[#1]%
  {\the\everyresetversion
   \ifhastok={#1}%
     \getdummyparameters[\c!alternative=,\c!text=,#1]%
     \edef\currentversioninfo{\dummyparameter\c!alternative}%
     \edef\currentversiontext{\dummyparameter\c!text}%
   \else
     \edef\currentversioninfo{#1}%
     \lettonothing\currentversiontext
   \fi
   \ifcsname\??layoutinfo\currentversioninfo\endcsname
     \let\page_info_add_to_box\page_info_add_to_box_indeed
   \else
     \lettonothing\currentversioninfo
     \let\page_info_add_to_box\gobbleoneargument
   \fi
   \the\everysetupversion}

\aliased\let\version\setupversion

\protected\def\page_info_place_info % at the bottom of the page
  {\begincsname\??layoutinfo\currentversioninfo\endcsname}

\permanent\protected\def\installversioninfo#1#2%
  {\defcsname\??layoutinfo#1\endcsname{#2}}

\permanent\protected\def\includeversioninfo#1%
  {\begincsname\??layoutinfo#1\endcsname}

\installversioninfo\v!final
  {\lettonothing\currentversioninfo
   \let\page_info_add_to_box\gobbleoneargument}

\installversioninfo\v!concept
  {\vskip6\points
   \hbox to \makeupwidth
     {\infofont
      \rlap{\v!concept:\space\currentdate}%
      \hss
      \currentversiontext
      \hss
      \llap{\page_adapts_status_info}}}

\installversioninfo\v!file
  {\vskip6\points
   \hbox to \makeupwidth
     {\infofont
      \getmessage\m!system{27}:\space\currentdate\quad
      \donefalse
      \doif\currentproject\currentproduct{\doif\currentproduct\currentcomponent\donetrue}%
      \ifdone
        \donefalse
      \else
        \ifempty\currentproject   \else \space\v!project  :\space\currentproject  \space \donetrue \fi
        \ifempty\currentproduct   \else \space\v!product  :\space\currentproduct  \space \donetrue \fi
        \ifempty\currentcomponent \else \space\v!component:\space\currentcomponent\space \donetrue \fi
      \fi
        \ifdone                   \else \space\v!file     :\space\jobname         \space           \fi
      \hss
      \currentversiontext
      \quad
      \page_adapts_status_info}}

\installversioninfo\v!temporary
  {\includeversioninfo\v!file}

\appendtoks
    \overfullrule\zeropoint
\to \everyresetversion

\appendtoks
    \ifx\currentversioninfo\v!temporary
        \overfullrule5\points
    \fi
\to \everysetupversion

\newbox\b_page_versions

\def\page_info_add_to_box_indeed#1%
  {\scratchdimen\wd#1%
   \setbox\b_page_versions\vpack to \ht#1%
     {\vfill
      \settexthoffset
      \hsize\dimexpr\scratchdimen-2\texthoffset\relax
      \hkern\texthoffset % brrrr
      \vbox to \zeropoint{\vss\page_info_place_info}%
      \vkern\bodyfontsize}%
   \dp\b_page_versions\zeropoint
   \wd\b_page_versions\scratchdimen
   \setbox#1\hpack{\box#1\hkern-\scratchdimen\box\b_page_versions}}

\setupversion % resets
  [\v!final]

\let\page_info_add_to_box\gobbleoneargument

\protect \endinput