summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/typo-syn.mkxl
blob: adb3603d5efca8665948cad0b9620242c52bcb5d (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
%D \module
%D   [       file=typo-syn,
%D        version=2022.01.06,
%D          title=\CONTEXT\ Typesetting Macros,
%D       subtitle=synchronizers,
%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.

% Musical timestamp: this code was written when I start relistening my whole
% digitized cd collection with the (new) r2r soekris dac in my setup.


%D Yet another experiment (triggered by a question / demand from Ton Otten.)
%D
%D \starttyping
%D \setupsynchronize [paralleltext] [color=darkblue]
%D % \setupsynchronize [paralleltext] [style=\tx,color=darkred]
%D % \setupsynchronize [paralleltext] [style=\txx,color=darkgreen]
%D
%D \dorecurse{10}{%
%D     \paralleltext
%D         {[een allereerste zinnetje]}
%D         {[een tweede      zinnetje]}%
%D     \space
%D     \paralleltext
%D         {[een derde zin]}
%D         {[een vierde zinnetje]}
%D     \space
%D } \removeunwantedspaces
%D \par test line \page
%D
%D \paralleltext
%D     {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
%D     {[\samplefile{ward}\removeunwantedspaces]}%
%D \par test line \page
%D
%D \paralleltext
%D     {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
%D     {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}%
%D \par test line \page
%D
%D \paralleltext
%D     {[\ignorespaces\samplefile{ward}\removeunwantedspaces]}%
%D     {[\ignorespaces\samplefile{tufte}\removeunwantedspaces]}
%D \par test line \page
%D \stoptyping

\writestatus{loading}{ConTeXt Typesetting Macros / Synchronizers}

\registerctxluafile{typo-syn}{autosuffix}

\unprotect

\definesystemattribute[synchronize][public]

\installcorenamespace {synchronize}

\installcommandhandler \??synchronize {synchronize} \??synchronize

\tolerant\protected\def\typo_synchronize#1#*[#2]#:#3#4%
  {\dontleavehmode
   \begingroup
   \def\currentsynchronize{#1}%
   \setupcurrentsynchronize[#2]%
   \dontcomplain
   \setbox\scratchboxtwo\hbox\bgroup
     \usesynchronizestyleandcolor\c!style\c!color
     \setstrut
     \strut
     \ignorespaces#4\removeunwantedspaces
   \egroup
   \scratchdimentwo\wd\scratchboxtwo
   \clf_registersynchronize
     \strutht
     \strutdp
     \box\scratchboxtwo
   \relax
   \setbox\scratchboxone\hbox{#3}%
   \scratchdimenone\wd\scratchboxone
   \unhbox\scratchboxone
   \advance\scratchdimentwo-\scratchdimenone
   \ifdim\scratchdimentwo>\zeropoint
     \wordboundary
     \novrule
   % \vrule
        \s!width  \scratchdimentwo
        \s!height \exheight
        \s!depth  \zeropoint
     \relax
   \fi
   \endgroup}

\appendtoks
    \protected\instance\edefcsname\currentsynchronize\endcsname{\typo_synchronize{\currentsynchronize}}%
\to \everydefinesynchronize

% \setupsynchronize
%   [\c!alternative=\v!horizontal]

\definesynchronize
  [paralleltext]

\protect \endinput