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