diff options
Diffstat (limited to 'tex/context/base/core-snc.tex')
-rw-r--r-- | tex/context/base/core-snc.tex | 132 |
1 files changed, 67 insertions, 65 deletions
diff --git a/tex/context/base/core-snc.tex b/tex/context/base/core-snc.tex index 81d310c95..e80fd1613 100644 --- a/tex/context/base/core-snc.tex +++ b/tex/context/base/core-snc.tex @@ -15,19 +15,24 @@ \unprotect +\ifx\s!set \undefined \def\s!set {set} \fi +\ifx\s!reset \undefined \def\s!reset {reset} \fi +\ifx\s!preset \undefined \def\s!preset {preset} \fi +\ifx\s!syncpos\undefined \def\s!syncpos{syncpos} \fi + \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}}} + {\setcounter{\s!num:\s!syncpos:#1}{0}% + \doglobal\appendtoksonce\getvalue {\s!reset:\s!syncpos:#1}\to\resetsyncpositions + \doglobal\appendtoksonce\getvalue{\s!preset:\s!syncpos:#1}\to\presetsyncpositions + \setgvalue{\s!syncpos:#1}{sync_n[#1] := 0 ;}% + \setgvalue{\s!set:\s!syncpos:#1}{\dosetsyncpositions{#1}}} \def\syncposition {\dodoubleempty\dosyncposition} \def\dosyncposition[#1][#2]% - {\letgvalue{reset:sync:#1}\relax - \letgvalue{preset:sync:#1}\relax + {\letgvalue{\s!reset:\s!syncpos:#1}\relax + \letgvalue{\s!preset:\s!syncpos:#1}\relax \dontleavehmode \dodosyncposition{#1}{#2}\s!set \ignorespaces} @@ -36,24 +41,24 @@ {\doifelse{\lastsyncclass\lastsyncposition}{#1#2}} \def\dodosyncposition#1#2#3% - {\letgvalue{reset:sync:#1}\relax - \letgvalue{preset:sync:#1}\relax - \ifundefined{syncpos:#1}% + {\letgvalue{\s!reset:\s!syncpos:#1}\relax + \letgvalue{\s!preset:\s!syncpos:#1}\relax + \ifundefined{\s!syncpos:#1}% \strut \else - \pluscounter{num:syncpos:#1}% + \pluscounter{\s!num:\s!syncpos:#1}% \setsyncpositions{#1}% % option: geen w/h, alleen p 0 0 0 data \setpositionplus - {sync:#1:\countervalue{num:syncpos:#1}}% + {\s!syncpos:#1:\countervalue{\s!num:\s!syncpos:#1}}% {#2}% - \hbox{\strut\traceposstring\llap\green{#3/\countervalue{num:syncpos:#1}/#1/#2>>}}% + \hbox{\strut\traceposstring\llap\green{#3/\countervalue{\s!num:\s!syncpos:#1}/#1/#2>>}}% \fi} \def\setsyncpositions#1% {\enabletextarearegistration - \getvalue{set:syncpos:#1}% - \letgvalue{set:syncpos:#1}\relax} + \getvalue {\s!set:\s!syncpos:#1}% + \letgvalue{\s!set:\s!syncpos:#1}\relax} \def\dosetsyncpositions#1% {\startnointerference % removing out of sync can best be done in mp @@ -61,9 +66,9 @@ \!!counta\zerocount \!!countc\zerocount \doloop - {\doifpositionelse{sync:#1:\recurselevel} - {\!!dimenb\MPy{sync:#1:\recurselevel}\relax - \!!countb\MPp{sync:#1:\recurselevel}\relax + {\doifpositionelse{\s!syncpos:#1:\recurselevel} + {\!!dimenb\MPy{\s!syncpos:#1:\recurselevel}\relax + \!!countb\MPp{\s!syncpos:#1:\recurselevel}\relax \ifnum\!!countb=\!!counta % same page \ifdim\!!dimenb>\!!dimena \donefalse % out of order nodes @@ -77,40 +82,26 @@ \!!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}% + \edef\!!stringc{\s!syncpos:#1:\the\!!countc}% + \edef\!!stringd{\MPplus\!!stringc{1}{0}}% + \setxvalue{\s!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} ; }% + \ifx\!!stringd\empty \else sync_t \!!stringa \MPplus\!!stringc{1}{0} ; \fi}% \fi} - {\setxvalue{syncpos:#1}% + {\setxvalue{\s!syncpos:#1}% {\getsyncpositions{#1}% sync_n[#1] := \the\!!countc ;} \exitloop}}% \stopnointerference} \def\getsyncpositions#1% - {\getvalue{syncpos:#1}} + {\getvalue{\s!syncpos:#1}} \newtoks\resetsyncpositions \newtoks\presetsyncpositions @@ -121,10 +112,8 @@ \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 +\def\doresyncposition [#1][#2]{\setxvalue{\s!reset:\s!syncpos:#1}{\noexpand\dodoresyncposition{#1}{#2}}} +\def\dopresyncposition[#1][#2]{\setxvalue{\s!preset:\s!syncpos:#1}{\noexpand\dodopresyncposition{#1}{#2}}} % \appendtoks \the \resetsyncpositions \to \everypar % \appendtoks \the\presetsyncpositions \to \everypar @@ -154,26 +143,39 @@ \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 +\starttext + +\setupcolors[state=start] + +\definesyncpositions[1] + +\startuseMPgraphic{sync} + StartPage ; + \getsyncpositions{1} ; + SyncThreshold := 2LineHeight ; + SyncLeftOffset := -.5LeftMarginDistance ; + % SetSyncThreshold(1,3,3LineHeight) ; + SyncWidth := - (BackSpace + SyncLeftOffset) ; + SetSyncColor(1,1,\MPcolor{red}) ; + SetSyncColor(1,2,\MPcolor{green}) ; + SetSyncColor(1,3,\MPcolor{blue}) ; + SetSyncColor(1,4,\MPcolor{yellow}) ; + PrepareSyncTasks(1,true,true,false) ; + for i = 1 upto NOfSyncPaths : + fill SyncPaths[i] + withcolor TheSyncColor(CurrentSyncClass,sync_t[CurrentSyncClass][SyncTasks[i]]) ; + endfor ; + setbounds currentpicture to Page ; + StopPage ; +\stopuseMPgraphic + +\defineoverlay[tempoverlay][\useMPgraphic{sync}] + +\setupbackgrounds[page][background=tempoverlay] + +\syncposition[1][1] \input ward \endgraf +\syncposition[1][2] \input ward \endgraf +\syncposition[1][3] \input ward \endgraf +\syncposition[1][4] \input ward \endgraf + +\stoptext
\ No newline at end of file |