trac-brk.mkxl /size: 3433 b    last modification: 2025-02-21 11:03
1%D \module
2%D   [       file=trac-brk,
3%D        version=2023.05.23,
4%D          title=\CONTEXT\ Tracing Macros,
5%D       subtitle=Linebreaks,
6%D         author=Hans Hagen & Mikael Sundqvist,
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% these will become runtime commands
15
16% \ifdefined\showbreakpoints \endinput \fi
17
18\writestatus{loading}{ConTeXt Tracing Macros / Breakpoints}
19
20\registerctxluafile{trac-brk}{}
21
22% \linebreakchecks : currently a bitset but maybe just values
23%
24% 1 : trace
25% 2 : twins
26
27% option (list of):
28%
29% margin
30% simple   (only badness)
31% compact  (no ref counts)
32
33%D We only support one at a time.
34
35\unprotect
36
37\newcount\c_line_break_check
38\newcount\c_balance_check
39
40\gdef\trac_start_show_breakpoints#1#2#3%
41  {\begingroup
42   \getdummyparameters[\c!option=,\c!list=,\c!offset=\zeropoint,\c!level=0,#1]%
43   \ctxlua{tracers.breakpoints.start {
44        option = "\dummyparameter\c!option",
45        level  = "\dummyparameter\c!level",
46        list   = "\dummyparameter\c!list",
47        offset = \number\dimexpr\dummyparameter\c!offset\relax,
48    }}%
49   \endgroup
50   #2#3%
51   #3\plusone}
52
53\gdef\trac_stop_show_breakpoints#1#2%
54  {\par
55   #2#1%
56   \ctxlua{tracers.breakpoints.stop()}}
57
58\gdef\trac_show_breakpoints#1%
59  {\begingroup
60   \getdummyparameters[\c!option=,#1]%
61   \switchtobodyfont[6pt]%
62   \dorecurse{\cldcontext{tracers.breakpoints.nofresults()}} {
63     \startcolumns[\c!n=3,\c!notes=\v!no,#1,\c!option=]%
64       \ctxlua{tracers.breakpoints.typesetresult(##1,"\dummyparameter\c!option")}%
65     \stopcolumns
66   }%
67  %\ctxlua{tracers.breakpoints.reset()}%
68   \endgroup}
69
70\gdef\trac_draw_breakpoints#1%
71  {\begingroup
72   \getdummyparameters[%
73     \c!dx=3fs,%
74     \c!dy=2fs,%
75     \c!sx=1.5fs,%
76     \c!sy=1.125fs,%
77     \c!rulethickness=0.15fs,%
78     #1]%
79   \startMPcode
80        lua.mp.show_breakpoints(
81            \todimension{\dummyparameter\c!dx},%
82            \todimension{\dummyparameter\c!dy},%
83            \todimension{\dummyparameter\c!sx},%
84            \todimension{\dummyparameter\c!sy},%
85            \todimension{\dummyparameter\c!rulethickness}%
86        ) ;
87   \stopMPcode
88   \endgroup}
89
90% \gdef\trac_reset_breakpoints
91%   {\ctxlua{tracers.breakpoints.reset()}}
92
93\permanent\tolerant\protected\gdef\startshowbreakpoints[#1]%
94  {\trac_start_show_breakpoints{#1}\c_line_break_check\linebreakchecks}
95
96\permanent\protected\gdef\stopshowbreakpoints
97  {\trac_stop_show_breakpoints\c_line_break_check\linebreakchecks}
98
99\permanent\tolerant\protected\gdef\showbreakpoints[#1]%
100  {\trac_show_breakpoints{#1}}
101
102\permanent\tolerant\protected\gdef\drawbreakpoints[#1]%
103  {\trac_draw_breakpoints{#1}}
104
105% \permanent\protected\gdef\resetbreakpoints
106%   {\trac_reset_breakpoints}
107
108% Also here:
109
110\permanent\tolerant\protected\gdef\startshowbalancepoints[#1]%
111  {\trac_start_show_breakpoints{#1,\c!level=1}\c_balance_check\balancechecks}
112
113\permanent\protected\gdef\stopshowbalancepoints
114  {\trac_stop_show_breakpoints\c_balance_check\balancechecks}
115
116\permanent\tolerant\protected\gdef\showbalancepoints[#1]%
117  {\trac_show_breakpoints{#1}}
118
119\permanent\tolerant\protected\gdef\drawbalancepoints[#1]%
120  {\trac_draw_breakpoints{#1}}
121
122% \permanent\protected\gdef\resetbalancepoints
123%   {\trac_reset_breakpoints}
124
125\protect \endinput
126