1%D \module 2%D [ file=anch-snc, 3%D version=2003.12.01, % actually 1999 so real old 4%D title=\CONTEXT\ Anchoring Macros, 5%D subtitle=Synchronization, 6%D author=Hans Hagen, 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%D This is a rather old mechanism that we once needed in an actually nice design. 15%D Those were the times that processing a rather complex xml file with \PDFTEX\ into 16%D a 400 page document took 45 minutes (a few runs) while nowadays with luatex and 17%D \MKIV\ (and \LMTX) we express runtime in seconds. 18%D 19%D In retrospect it was a waste of time (and money) to invest in all these 20%D mechanisms because the publishers we were dealign with were far from ready for 21%D dealing with xml and let alone automatic rendering. But, as the code still worked 22%D well after nearly two decades I decided to revive it .. maybe some curious 23%D \CONTEXT\ user can benefit from it after all. 24%D 25%D The logic is mostly the same as in \MKII\ but some work is now delegated to \LUA\ 26%D so that we save memory and gain some runtime. As this was not really a used 27%D module the interface also was upgraded. As we know the bottlenecks in \METAPOST\ 28%D we also work around those a bit. It made sense too change the interface to use 29%D the new \LMTX\ mechanisms for passing parameters. The old interface can be found 30%D in the \MKII\ and \MKIV\ files. 31 32%D TODO: bleed | autobleed 33 34\writestatus{loading}{ConTeXt Anchoring Macros / Synchronization} 35 36\registerctxluafile{anch-snc}{} 37\registerctxluafile{mlib-snc}{} 38 39%D \stoptyping 40%D \starttext 41%D 42%D \setuplayout[location=middle] 43%D \setupbodyfont[dejavu] 44%D 45%D \definesyncpositions[1] 46%D \definesyncpositions[2] 47%D 48%D % \startuseMPgraphic{sync1} 49%D % StartPage ; 50%D % lmt_synchronizer [ ... ] ; 51%D % clip currentpicture to Page ; 52%D % setbounds currentpicture to Page ; 53%D % StopPage ; 54%D % \stopuseMPgraphic 55%D 56%D \startuseMPgraphic{sync1} 57%D lmt_synchronizer [ 58%D % page = "yes", 59%D index = 1, 60%D hoffset = 0, 61%D width = BackSpace - LeftMarginDistance, 62%D extend = false, 63%D prune = true, 64%D draw = false, 65%D fill = true, 66%D ] ; 67%D \stopuseMPgraphic 68%D 69%D \startuseMPgraphic{sync2} 70%D lmt_synchronizer [ 71%D index = 2, 72%D region = OverlayRegion, 73%D hoffset = -1cm, 74%D width = 1cm, 75%D extend = true, 76%D prune = false, 77%D draw = false, 78%D fill = true, 79%D ] ; 80%D clip currentpicture to OverlayBox leftenlarged 1cm; 81%D setbounds currentpicture to OverlayBox ; 82%D \stopuseMPgraphic 83%D 84%D \defineoverlay[tempoverlay1][\useMPgraphic{sync1}] 85%D \defineoverlay[tempoverlay2][\useMPgraphic{sync2}] 86%D 87%D \setupbackgrounds[page][background=tempoverlay1] 88%D 89%D \framed[region=yes,background=tempoverlay2,width=14cm,align=normal]{% 90%D \syncposition[2][1]\samplefile{ward}\endgraf 91%D \syncposition[2][2]\samplefile{ward}\endgraf 92%D \syncposition[2][3]\samplefile{ward}\endgraf 93%D } 94%D 95%D \vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=16cm,align=normal]{% 96%D \syncposition[2][1]\samplefile{ward}\endgraf 97%D \syncposition[2][2]\samplefile{ward}\endgraf 98%D \syncposition[2][3]\samplefile{ward}\endgraf 99%D } 100%D 101%D \vskip1cm \hskip1cm \framed[region=yes,background=tempoverlay2,width=10cm,align=normal]{% 102%D \syncposition[2][1]\samplefile{ward}\endgraf 103%D \syncposition[2][2]\samplefile{ward}\endgraf 104%D \syncposition[2][3]\samplefile{ward}\endgraf 105%D } 106%D 107%D \dorecurse {100} { 108%D \startchapter[title={Test #1}] 109%D \syncposition[1][1,reset]\dorecurse{20}{\samplefile{ward}\endgraf} 110%D \syncposition[1][2]\dorecurse {4}{\samplefile{ward}\endgraf} 111%D \syncposition[1][3]\dorecurse {7}{\samplefile{ward}\endgraf} 112%D \syncposition[1][4]\dorecurse {3}{\samplefile{ward}\endgraf} 113%D \stopchapter 114%D } 115%D 116%D \dorecurse {100} { 117%D \startchapter[title={Test #1}] 118%D \syncposition[1][1]\dorecurse{1}{\samplefile{ward}\endgraf} 119%D \syncposition[1][2]\dorecurse{1}{\samplefile{ward}\endgraf} 120%D \syncposition[1][3]\dorecurse{1}{\samplefile{ward}\endgraf} 121%D \syncposition[1][4]\dorecurse{1}{\samplefile{ward}\endgraf} 122%D \stopchapter 123%D } 124%D 125%D \stoptext 126%D \stoptyping 127 128%D We could actually use par positions but in \LMTX\ we have syncpos entries 129%D somewhat optimized. 130 131\unprotect 132 133\installcorenamespace{syncposcounter} 134 135\let\c_sync_n\relax 136 137\permanent\protected\def\definesyncpositions[#1]% 138 {\ifcsname\??syncposcounter:#1\endcsname \else 139 \expandafter\newinteger\csname\??syncposcounter:#1\endcsname 140 \fi} 141 142\permanent\tolerant\protected\def\syncposition[#1]#*[#2]% 143 {\dontleavehmode 144 \ifcsname\??syncposcounter:#1\endcsname 145 \let\c_sync_n\lastnamedcs 146 \global\advanceby\c_sync_n\plusone 147 \enabletextarearegistration 148 \setpositionplus{\s!syncpos:#1:\the\c_sync_n}{#2}\hpack{\strut}% 149 \else 150 \strut 151 \fi 152 \ignorespaces} 153 154\protect 155 |