s-pages-statistics.mkiv /size: 5158 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-pages-statistics, % s-otr-01,
3%D        version=2012.02.02,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Page Statistics,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16\defineframed
17  [otrstatistics]
18  [\c!offset=\bodyfontsize,
19   \c!background=\v!color,
20   \c!strut=\v!no,
21   \c!backgroundcolor=white,
22   \c!frame=\v!off,
23   \c!align=\v!middle]
24
25\definecombination
26  [otrstatistics]
27  [\c!nx=2,
28   \c!ny=2,
29   \c!location=\v!top]
30
31% expansion is neeed because tabulate sets some penalties
32
33\startsetups system:page:otr:statistics
34    \normalexpanded {
35        \startcombination[otrstatistics] {
36                \otrstatistics {
37                    \starttabulate[|Tw(10em)|Trw(8em)|]
38                        \NC \string\textwidth           \NC \the\textwidth           \NC \NR
39                        \NC \string\textheight          \NC \the\textheight          \NC \NR
40                        \NC \string\lineheight          \NC \the\lineheight          \NC \NR
41                        \NC \string\strutheight         \NC \strutheight             \NC \NR
42                        \NC \string\strutdepth          \NC \strutdepth              \NC \NR
43                     %  \NC \string\vsize               \NC \the\vsize               \NC \NR
44                        \NC \string\topskip             \NC \the\topskip             \NC \NR
45                    \stoptabulate
46                }
47            } {}
48            {
49                \otrstatistics {
50                    \starttabulate[|Tw(10em)|Trw(8em)|]
51                        \NC \string\pagegoal            \NC \the\pagegoal            \NC \NR
52                        \NC \string\pagetotal           \NC \the\pagetotal           \NC \NR
53                        \NC \string\pagedepth           \NC \the\pagedepth           \NC \NR
54                        \NC \string\pageshrink          \NC \the\pageshrink          \NC \NR
55                        \NC \string\pagestretch         \NC \the\pagestretch         \NC \NR
56                        \NC \string\pagefilstretch      \NC \the\pagefilstretch      \NC \NR
57                        \NC \string\pagefillstretch     \NC \the\pagefillstretch     \NC \NR
58                        \NC \string\pagefilllstretch    \NC \the\pagefilllstretch    \NC \NR
59                    \stoptabulate
60                }
61            } {}
62            {
63                \otrstatistics {
64                    \starttabulate[|Tw(10em)|Trw(8em)|]
65                        \NC \string\widowpenalty        \NC \the\widowpenalty        \NC \NR
66                        \NC \string\clubpenalty         \NC \the\clubpenalty         \NC \NR
67                        \NC \string\displaywidowpenalty \NC \the\displaywidowpenalty \NC \NR
68                        \NC \string\brokenpenalty       \NC \the\brokenpenalty       \NC \NR
69                        \NC \string\interlinepenalty    \NC \the\interlinepenalty    \NC \NR
70                    \stoptabulate
71                }
72            } {}
73            {
74                \otrstatistics[\c!foregroundcolor=darkred] {
75                    \starttabulate[|Tw(10em)|Trw(8em)|]
76                        \NC page  \NC \the\realpageno        \NC \NR
77                        \NC delta \NC \the\dimexpr\pagegoal-\pagetotal\relax \NC \NR
78                    \stoptabulate
79                }
80            } {}
81        \stopcombination
82    }
83\stopsetups
84
85\definecolor[system:page:otr:statistics][t=.8,a=1]
86
87\defineoverlay
88  [system:page:otr:statistics]
89  [{\starttransparent[system:page:otr:statistics]%
90    \framed
91      [\c!offset=\bodyfontsize,
92       \c!background=\v!color,
93       \c!strut=\v!no,
94      %\c!frame=\v!off,
95       \c!framecolor=white,
96       \c!frameoffset=\onepoint,
97       \c!rulethickness=2\onepoint,
98       \c!backgroundcolor=darkblue,
99       \c!align=\v!middle]
100      {\forgetall
101       \insidefloattrue
102       \setups{system:page:otr:statistics}}%
103   \stoptransparent}]
104
105\unexpanded\def\page_one_command_package_show_state_indeed
106  {\scratchheight\ht\b_page_one_contents
107   \scratchdepth \dp\b_page_one_contents
108   \setbox\b_page_one_contents\vbox\framed
109     [\c!offset=\v!overlay,
110      \c!framecolor=darkred,
111      \c!rulethickness=\onepoint,
112      \c!background={\v!foreground,system:page:otr:statistics}]
113     {\lower\scratchdepth\box\b_page_one_contents}%
114   \ht\b_page_one_contents\scratchheight
115   \dp\b_page_one_contents\scratchdepth}
116
117\let\page_one_command_package_show_state\relax
118
119\unexpanded\def\showpageproperties
120  {\let\page_one_command_package_show_state\page_one_command_package_show_state_indeed}
121
122\protect
123
124\continueifinputfile{s-pages-statistics.mkiv}
125
126\setupbodyfont[dejavu,11pt] \dontcomplain \showpageproperties
127
128\starttext
129
130\dorecurse {100} { \input tufte
131
132    \startitemize[packed,intro]
133        \startitem test \stopitem \startitem test \stopitem
134        \startitem test \stopitem \startitem test \stopitem
135    \stopitemize
136}
137
138\stoptext
139