summaryrefslogtreecommitdiff
path: root/tex/context/base/trac-vis.mkiv
blob: 0e4993853fb851d0924ff7711b25438d78f37d86 (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
127
128
129
%D \module
%D   [       file=trac-vis, % replaces supp-vis plus some s-* modules
%D        version=2112.06.23, % 1996.10.21,
%D          title=\CONTEXT\ Tracing Macros,
%D       subtitle=Visualization,
%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.

%D The old visual debugger dates from 1996 and started out as joke. In practice
%D it's not used that often although the \type {\ruledhbox} cum suis macros come
%D in handy when writing code. In the process of luafication some additional
%D tracing options were tested, for instance showing font kerns. As part of the
%D \MKIV\ cleanup the decision was made to reimplement, reintegrate and reconsider
%D all these features. The old code is gone and the new code will get extended
%D when needed. We still provide placeholders for some old visualization commands
%D but they might go away.
%D
%D Control over what gets visualized happens with the tracker command:
%D
%D \enabletrackers[visualizer.*]
%D
%D Possible values are: \type {fontkern}, \type {kern}, \type {glue}, \type
%D {penalty}, \type {hbox}, \type {vbox}, \type {all}, \type {reset}, \type
%D {makeup}, \type {whatsit}, \type{glyph}.
%D
%D In due time some special visualzation of math will move here as well.

\writestatus{loading}{ConTeXt Tracing Macros / Visualization}

\registerctxluafile{trac-vis}{1.001}

\unprotect

\definesystemattribute[visual][public,global]

%D We only provide box visualizers as they can come in handy for testing
%D macros. In due time we will move some of the m-visual code here too.

\let\syst_visualizers_hbox\hbox
\let\syst_visualizers_vbox\vbox
\let\syst_visualizers_vtop\vtop

\unexpanded\def\ruledhbox{\syst_visualizers_hbox attr \visualattribute \ctxcommand{visual("simplehbox")} }
\unexpanded\def\ruledvbox{\syst_visualizers_vbox attr \visualattribute \ctxcommand{visual("simplevbox")} }
\unexpanded\def\ruledvtop{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("simplevtop")} } % special case
\unexpanded\def\ruledtopv{\syst_visualizers_vtop attr \visualattribute \ctxcommand{visual("vtop")} }

\unexpanded\def\showmakeup
  {\ctxcommand{setvisual("makeup")}%
   \let\normalvtop\ruledtopv
   \let\vtop      \ruledtopv}

\unexpanded\def\showallmakeup
  {\ctxcommand{setvisual("all")}%
   \let\normalvtop\ruledtopv
   \let\vtop      \ruledtopv
   \showstruts}

\unexpanded\def\showboxes
  {\ctxcommand{setvisual("boxes")}%
   \let\normalvtop\ruledtopv
   \let\vtop      \ruledtopv}

\unexpanded\def\showglyphs
  {\ctxcommand{setvisual("glyph")}}

\unexpanded\def\showfontkerns
  {\ctxcommand{setvisual("fontkern")}}

\unexpanded\def\setvisualizerfont
  {\dosingleempty\syst_visualizers_setfont}

\def\syst_visualizers_setfont[#1]% somename at 4pt
  {\begingroup
   \doifelsenothing{#1}{\definedfont[Mono at 4pt]}{\definedfont[#1]}%
   \ctxlua{nodes.visualizers.setfont()}%
   \endgroup}

%D Overload:

% \def\spac_struts_vide_hbox
%   {\hbox attr \visualattribute \ctxcommand{visual("strut")} }

\def\spac_struts_vide_hbox
  {\edef\spac_struts_vide_hbox{\hbox attr \visualattribute \ctxcommand{visual("strut")} }%
   \spac_struts_vide_hbox}

%D We keep this one:

\unexpanded\def\dontinterfere
  {\reseteverypar
   \parindent\zeropoint
   \parskip  \zeropoint
   \leftskip \zeropoint
   \rightskip\zeropoint
   \relax}

%D We keep these for a while:

\let\ruledvcenter   \vcenter
\let\ruledhss       \hss
\let\ruledhfil      \hfil
\let\ruledhfill     \hfill
\let\ruledhfilll    \hfilll
\let\ruledhfilneg   \hfilneg
\let\ruledhfillneg  \hfillneg
\let\ruledhfilllneg \hfilllneg
\let\ruledvss       \vss
\let\ruledvfil      \vfil
\let\ruledvfill     \vfill
\let\ruledvfilll    \vfilll
\let\ruledvfilneg   \vfilneg
\let\ruledvfillneg  \vfillneg
\let\ruledvfilllneg \vfilllneg
\let\ruledhskip     \hskip
\let\ruledvskip     \vskip
\let\ruledkern      \kern
\let\ruledhglue     \hglue
\let\ruledvglue     \vglue
\let\ruledmkern     \mkern
\let\ruledmskip     \mskip
\let\ruledpenalty   \penalty

\protect \endinput