1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\ifdefined\ShowNamedUsage \endinput \fi
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32\definecolor[usage:line] [darkred]
33\definecolor[usage:time] [darkblue]
34\definecolor[usage:frame][darkgray]
35
36\ctxloadluafile{tractim.lmt}
37
38\startluacode
39local progress = moduledata.progress
40
41function progress.show(filename,names,other)
42 if not filename or filename == "" then
43 filename = progress.defaultfilename or ""
44 end
45 for n, name in pairs(progress.names(filename)) do
46 if string.find(name,names) and name ~= other and name ~= "variables: lasttime" then
47 context.ShowNamedUsage(filename,name or "",other or "")
48 end
49 end
50end
51\stopluacode
52
53\startnotmode[notiming]
54 \appendtoks\ctxlua{moduledata.progress.store()}\to\everystarttext
55 \appendtoks\ctxlua{moduledata.progress.store()}\to\everyshipout
56 \ctxlua{luatex.registerstopactions(function() moduledata.progress.save() end)}
57\stopnotmode
58
59\permanent\protected\def\ShowNamedUsage#1#2#3
60 {\setbox\scratchbox\vbox\bgroup
61 \startMPcode{doublefun}
62 begingroup ; save p, q, b, h, w ;
63 path p, q, b ; numeric h, w ;
64 p := \cldcontext{moduledata.progress.path("#1","#2")} ;
65
66 if bbwidth(p) > 0 :
67 h := 100 ; w := 2 h ;
68 w := \the\textwidth-3pt ;
69 p := p xstretched w ;
70 b := boundingbox (llcorner p -- llcorner p shifted (w,h)) ;
71 pickup pencircle scaled 3pt ; linecap := butt ;
72 draw b withcolor \MPcolor{usage:frame} ;
73 draw p withcolor \MPcolor{usage:line} ;
74 if ("#3" <> "") and ("#3" <> "#2") :
75 q := \cldcontext{moduledata.progress.path("#1","#3")} ;
76
77 if bbwidth(q) > 1 :
78 q := q xstretched w ;
79 pickup pencircle scaled 1.5pt ; linecap := butt ;
80 draw q withcolor \MPcolor{usage:time} ;
81 fi ;
82 fi ;
83 fi ;
84 endgroup ;
85 \stopMPcode
86 \egroup
87 \scratchdimen\wd\scratchbox
88 \ifdim\scratchdimen>\zeropoint
89 \startlinecorrection[blank]
90 \box\scratchbox \endgraf
91 \hbox to \scratchdimen\bgroup
92 \tttf\strut\detokenize{#2}\hss
93 \scratchcounter =\cldcontext{moduledata.progress.set("#1","\detokenize{#2}")}\relax
94 \scratchcounterone =\cldcontext{moduledata.progress.bot("#1","\detokenize{#2}")}\relax
95 \scratchcountertwo =\cldcontext{moduledata.progress.top("#1","\detokenize{#2}")}\relax
96 \scratchcounterthree=\numexpr\scratchcountertwo\scratchcounterone\relax
97 \ifnum\scratchcounter >\zerocount set:\the\scratchcounter \quad\fi
98 \ifnum\scratchcounterthree>\zerocount inc:\the\scratchcounterthree\quad\fi
99 \ifnum\scratchcounterone >\zerocount min:\the\scratchcounterone \quad\fi
100 \ifnum\scratchcountertwo >\zerocount max:\the\scratchcountertwo \quad\fi
101 pages:\cldcontext{moduledata.progress.pages("#1")}
102 \egroup
103 \stoplinecorrection
104 \fi}
105
106\permanent\protected\def\LoadUsage #1{\ctxlua{moduledata.progress.convert("#1")}}
107\permanent\protected\def\ShowUsage #1{\ctxlua{moduledata.progress.show("#1",".*", "variables: elapsed")}}
108\permanent\protected\def\ShowMemoryUsage #1{\ctxlua{moduledata.progress.show("#1","memory:.*","variables: elapsed")}}
109\permanent\protected\def\ShowNodeUsage #1{\ctxlua{moduledata.progress.show("#1","nodes:.*", "variables: elapsed")}}
110\permanent\protected\def\ShowFilteredUsage#1#2{\ctxlua{moduledata.progress.show("#1","#2", "variables: elapsed")}}
111\permanent\protected\def\ShowSimpleUsage #1#2{\ctxlua{moduledata.progress.show("#1","#2")}}
112
113\endinput
114 |