diff options
Diffstat (limited to 'tex/context/base/core-snc.tex')
-rw-r--r-- | tex/context/base/core-snc.tex | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/tex/context/base/core-snc.tex b/tex/context/base/core-snc.tex new file mode 100644 index 000000000..81d310c95 --- /dev/null +++ b/tex/context/base/core-snc.tex @@ -0,0 +1,179 @@ +%D \module +%D [ file=core-snc, +%D version=2003.12.01, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Synchronization Support, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{Context Synchronization} + +\unprotect + +\def\definesyncpositions[#1]% + {\setcounter{num:syncpos:#1}{0}% + \doglobal\appendtoksonce\getvalue {reset:sync:#1}\to\resetsyncpositions + \doglobal\appendtoksonce\getvalue{preset:sync:#1}\to\presetsyncpositions + \setgvalue{syncpos:#1}{sync_n[#1] := 0 ;}% + \setgvalue{set:syncpos:#1}{\dosetsyncpositions{#1}}} + +\def\syncposition + {\dodoubleempty\dosyncposition} + +\def\dosyncposition[#1][#2]% + {\letgvalue{reset:sync:#1}\relax + \letgvalue{preset:sync:#1}\relax + \dontleavehmode + \dodosyncposition{#1}{#2}\s!set + \ignorespaces} + +\def\doifelselastsyncposition#1#2% + {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}} + +\def\dodosyncposition#1#2#3% + {\letgvalue{reset:sync:#1}\relax + \letgvalue{preset:sync:#1}\relax + \ifundefined{syncpos:#1}% + \strut + \else + \pluscounter{num:syncpos:#1}% + \setsyncpositions{#1}% + % option: geen w/h, alleen p 0 0 0 data + \setpositionplus + {sync:#1:\countervalue{num:syncpos:#1}}% + {#2}% + \hbox{\strut\traceposstring\llap\green{#3/\countervalue{num:syncpos:#1}/#1/#2>>}}% + \fi} + +\def\setsyncpositions#1% + {\enabletextarearegistration + \getvalue{set:syncpos:#1}% + \letgvalue{set:syncpos:#1}\relax} + +\def\dosetsyncpositions#1% + {\startnointerference % removing out of sync can best be done in mp + \!!dimena\maxdimen + \!!counta\zerocount + \!!countc\zerocount + \doloop + {\doifpositionelse{sync:#1:\recurselevel} + {\!!dimenb\MPy{sync:#1:\recurselevel}\relax + \!!countb\MPp{sync:#1:\recurselevel}\relax + \ifnum\!!countb=\!!counta % same page + \ifdim\!!dimenb>\!!dimena + \donefalse % out of order nodes + \else + \donetrue % nodes in order + \fi + \else + \donetrue % different page + \fi + \ifdone + \!!counta\!!countb + \!!dimena\!!dimenb + \advance\!!countc\plusone + \edef\!!stringc{sync:#1:\the\!!countc}% + \edef\!!stringa{[#1][\the\!!countc]}% + % + % the formal way: + % + % \setxvalue{syncpos:#1}% + % {\getsyncpositions{#1}% + % sync_p [#1][\the\!!countc] := \MPp \!!stringc ; + % sync_xy[#1][\the\!!countc] := \MPxy\!!stringc ; + % sync_w [#1][\the\!!countc] := \MPw \!!stringc ; + % sync_h [#1][\the\!!countc] := \MPh \!!stringc ; + % sync_d [#1][\the\!!countc] := \MPd \!!stringc ; + % sync_t [#1][\the\!!countc] := \MPplus{sync:#1:\recurselevel}{2}{0} ; }% + % + % less tokens: + % + \edef\!!stringa{[#1][\the\!!countc]:=}% + \setxvalue{syncpos:#1}% + {\getsyncpositions{#1}% + sync_p \!!stringa \MPp \!!stringc ; + sync_xy\!!stringa \MPxy\!!stringc ; + sync_w \!!stringa \MPw \!!stringc ; + sync_h \!!stringa \MPh \!!stringc ; + sync_d \!!stringa \MPd \!!stringc ; + sync_t \!!stringa \MPplus\!!stringc{1}{0} ; }% + \fi} + {\setxvalue{syncpos:#1}% + {\getsyncpositions{#1}% + sync_n[#1] := \the\!!countc ;} + \exitloop}}% + \stopnointerference} + +\def\getsyncpositions#1% + {\getvalue{syncpos:#1}} + +\newtoks\resetsyncpositions +\newtoks\presetsyncpositions + +\def\resyncposition {\dodoubleargument\doresyncposition} +\def\presyncposition{\dodoubleargument\dopresyncposition} + +\def\dodoresyncposition #1#2{\dodosyncposition{#1}{#2}\s!reset} +\def\dodopresyncposition#1#2{\dodosyncposition{#1}{#2}\s!preset} + +\def\doresyncposition [#1][#2]{\setxvalue{reset:sync:#1}{\noexpand\dodoresyncposition{#1}{#2}}} +\def\dopresyncposition[#1][#2]{\setxvalue{preset:sync:#1}{\noexpand\dodopresyncposition{#1}{#2}}} + +\ifx\s!preset\undefined \def\s!preset{preset} \fi + +% \appendtoks \the \resetsyncpositions \to \everypar +% \appendtoks \the\presetsyncpositions \to \everypar + +\appendtoks \the \presetsyncpositions \to \everypar +\appendtoks \the \resetsyncpositions \to \everypar + +% \explicitneverypar -> in grid snapper, eerst testen +% +% \appendtoks \the\resetsyncpositions \to \neverypar +% \appendtoks \the\presetsyncpositions \to \neverypar + +\appendtoks + \the\presetsyncpositions + \the\resetsyncpositions +\to \everyheadstart + +\def\flushsyncxxsets#1#2% + {\setbox\scratchbox\hbox{\the#1}% + \ifvoid\scratchbox\else + \smashbox\scratchbox + #2\box\scratchbox + \fi} + +\def\flushsyncresets {\flushsyncxxsets\resetsyncpositions \relax} +\def\flushsyncpresets{\flushsyncxxsets\presetsyncpositions\prewordbreak} % check prewordbreak + +\protect \endinput + +% \definesyncpositions[1] + +% \startuseMPgraphic{sync} +% StartPage ; +% \getsyncpositions{1} ; +% SyncThreshold := 2LineHeight ; % maybe 3 +% SyncLeftOffset := -.5LeftMarginDistance ; +% SetSyncThreshold(1,3,3LineHeight) ; +% SyncWidth := - (BackSpace + SyncLeftOffset + 3mm) ; +% SetSyncColor(1,1,\MPcolor{theorie:middel}) ; +% SetSyncColor(1,2,\MPcolor{praktijk:middel}) ; +% SetSyncColor(1,3,\MPcolor{samenvatting:middel}) ; +% SetSyncColor(1,4,\MPcolor{voorbeeld:middel}) ; +% PrepareSyncTasks(1,true,true,false) ; +% for i = 1 upto NOfSyncPaths : +% fill SyncPaths[i] topenlarged (LineHeight+StrutDepth) bottomenlarged LineHeight withcolor white ; +% fill SyncPaths[i] topenlarged StrutDepth withcolor TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]]) ; +% endfor ; +% setbounds currentpicture to Page ; +% StopPage ; +% \stopuseMPgraphic + +% \defineoverlay[tempoverlay][\useMPgraphic{sync}]
\ No newline at end of file |