summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/strc-ren.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/strc-ren.mkiv')
-rw-r--r--tex/context/base/mkiv/strc-ren.mkiv201
1 files changed, 151 insertions, 50 deletions
diff --git a/tex/context/base/mkiv/strc-ren.mkiv b/tex/context/base/mkiv/strc-ren.mkiv
index 6bdd05de9..132f0f115 100644
--- a/tex/context/base/mkiv/strc-ren.mkiv
+++ b/tex/context/base/mkiv/strc-ren.mkiv
@@ -82,24 +82,24 @@
\def\headreferenceattributes
{\iflocation
- % \ctxlua{structures.lists.taglocation(\nextinternalreference)}% maybe ... tags entry as used
+ % \ctxlua{structures.lists.taglocation(\the\locationcount)}% maybe ... tags entry as used
attr \destinationattribute \currentstructureattribute
attr \referenceattribute \currentstructurereferenceattribute
- % attr \internalattribute \nextinternalreference
+ % attr \internalattribute \locationcount
\fi}
\def\setinlineheadreferenceattributes
{\ifconditional\headisdisplay \else \iflocation
\attribute\destinationattribute\currentstructureattribute
\attribute\referenceattribute \currentstructurereferenceattribute
- % \attribute\internalattribute \nextinternalreference
+ % \attribute\internalattribute \locationcount
\fi \fi}
\def\docheckheadreference
{\edef\currentheadinteraction{\headparameter\c!interaction}%
\ifx\currentheadinteraction\v!list
% setuphead[<section>][interaction=list,...]
- \strc_references_get_simple_reference{*\nextinternalreference}%
+ \strc_references_get_simple_reference{*\the\locationcount}%
\let\currentstructurereferenceattribute\currentreferenceattribute
\else\ifx\currentheadinteraction\v!reference
% setuphead[<section>][interaction=reference,...] start<section>[backreference=abc,...]
@@ -167,18 +167,6 @@
% helpers
-% \defineinmargin [ChapterInMargin] [outer] [normal] [distance=0.3em]
-%
-% \defineheadplacement[MyTest][horizontal]#1#2%
-% {\startlocalheadsetup
-% %\ChapterInMargin{\headhbox{\strut#2}}% proper destination, ref okay
-% \ChapterInMargin{\strut#2}% zero destination, ref okay
-% \stoplocalheadsetup}
-%
-% \setuphead
-% [chapter]
-% [alternative=MyTest]
-
\unexpanded\def\headhbox{\hbox\headreferenceattributes}
\unexpanded\def\headvbox{\vbox\headreferenceattributes}
@@ -320,28 +308,88 @@
\d_strc_rendering_hang_height\zeropoint
\fi}
+% \def\strc_rendering_stop_placement
+% {\n_strc_rendering_hang_lines\zerocount
+% \ifconditional\headisdisplay
+% \strc_rendering_initialize_line_hang
+% % kind of special, we want to snap heads also according to local specs local
+% \ifgridsnapping
+% \hbox\bgroup % extra hbox will trigger global snapper on top of local
+% \edef\p_grid{\headparameter\c!grid}%
+% \ifconditional\headisdisplay
+% \ifx\p_grid\empty\else
+% \useheadstyleandcolor\c!style\c!color
+% \setupinterlinespace
+% \useheadstyleandcolor\c!textstyle\c!textcolor
+% \setupinterlinespace
+% \fi
+% \fi
+% \snaptogrid[\p_grid]\hbox
+% {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+% \egroup
+% \else
+% \hbox
+% {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+% \fi
+% \flushnotes % new, not really needed
+% \endgraf
+% \ifvmode
+% \ifnum\n_strc_rendering_hang_lines>\zerocount
+% \dorecurse\n_strc_rendering_hang_lines{\nointerlineskip\dosomebreak\nobreak\strut\endgraf}% to be checked
+% \fi
+% \nointerlineskip
+% \dosomebreak\nobreak
+% \fi
+% \getheadsyncs
+% \else
+% % somehow this goes ok even when we push in the margin probably because we gobble pars
+% % in the process of collecting index entries etc
+% \strut
+% \flushnotes % new, here since we're in par mode
+% \unhbox\b_strc_rendering_head
+% \getheadsyncs
+% \ifconditional\headissomewhere
+% % nothing special
+% \else
+% %\hskip\headnumberdistance\s!plus\headnumberdistance\s!minus.25\dimexpr\headnumberdistance\relax
+% \hskip\headtextdistance\relax
+% \strc_sectioning_inject_continuous_signal
+% \fi
+% \fi
+% \ifconditional\headisdisplay
+% \ifvmode
+% \ifgridsnapping % important, font related depth, see comment
+% \prevdepth\strutdp
+% \else
+% \prevdepth\d_strc_rendering_local_depth
+% \fi
+% \fi
+% \fi
+% \egroup
+% \egroup
+% \ifconditional\headisdisplay
+% \useindentnextparameter\headparameter
+% \else
+% \nonoindentation % recently added, was a bug
+% \fi}
+
\def\strc_rendering_stop_placement
{\n_strc_rendering_hang_lines\zerocount
\ifconditional\headisdisplay
\strc_rendering_initialize_line_hang
% kind of special, we want to snap heads also according to local specs local
+ \setbox\b_strc_rendering_head\hbox
+ {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax
+ \box\b_strc_rendering_head}%
\ifgridsnapping
- \hbox\bgroup % extra hbox will trigger global snapper on top of local
- \edef\p_grid{\headparameter\c!grid}%
- \ifconditional\headisdisplay
- \ifx\p_grid\empty\else
- \useheadstyleandcolor\c!style\c!color
- \setupinterlinespace
- \useheadstyleandcolor\c!textstyle\c!textcolor
- \setupinterlinespace
- \fi
- \fi
- \snaptogrid[\p_grid]\hbox
- {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
- \egroup
+ \applygridmethod
+ {\headparameter\c!grid}%
+ {\ifconditional\headisdisplay
+ \strc_rendering_initialize_style_and_color_display\c!textstyle\c!textcolor
+ \fi}%
+ {\box\b_strc_rendering_head}
\else
- \hbox
- {\hskip\dimexpr\d_strc_rendering_local_leftoffset+\headparameter\c!margin\relax\box\b_strc_rendering_head}%
+ \box\b_strc_rendering_head
\fi
\flushnotes % new, not really needed
\endgraf
@@ -354,12 +402,19 @@
\fi
\getheadsyncs
\else
+ % somehow this goes ok even when we push in the margin probably because we gobble pars
+ % in the process of collecting index entries etc
\strut
\flushnotes % new, here since we're in par mode
\unhbox\b_strc_rendering_head
\getheadsyncs
- \hskip\headnumberdistance\s!plus\headnumberdistance\s!minus.25\dimexpr\headnumberdistance\relax
- \strc_sectioning_inject_continuous_signal
+ \ifconditional\headissomewhere
+ % nothing special
+ \else
+ %\hskip\headnumberdistance\s!plus\headnumberdistance\s!minus.25\dimexpr\headnumberdistance\relax
+ \hskip\headtextdistance\relax
+ \strc_sectioning_inject_continuous_signal
+ \fi
\fi
\ifconditional\headisdisplay
\ifvmode
@@ -453,6 +508,7 @@
\newdimen\headwidth
\newdimen\headtextwidth
+\newskip \headtextdistance
\newdimen\headnumberdistance
\newdimen\headnumberwidth
@@ -470,16 +526,22 @@
\let\currentheadrenderingalternative\v!vertical
\fi
\ifx\currentheadrenderingalternative\v!horizontal
- \global\setfalse\headisdisplay % global
+ \global\setfalse\headisdisplay % global
+ \global\setfalse\headissomewhere % global
+ \else\ifx\currentheadrenderingalternative\v!somewhere
+ \global\setfalse\headisdisplay % global
+ \global\settrue \headissomewhere % global
\else
- \global\settrue\headisdisplay % global
- \fi}
+ \global\settrue \headisdisplay % global
+ \global\setfalse\headissomewhere % global
+ \fi\fi}
\unexpanded\def\strc_rendering_initialize_dimensions
- {\headwidth \headparameter\c!width \relax % \zeropoint == unset
- \headnumberwidth \headparameter\c!numberwidth\relax % \zeropoint == unset
- \headnumberdistance\headparameter\c!distance \relax
- \headtextwidth \headparameter\c!textwidth \relax} % \zeropoint == unset
+ {\headwidth \headparameter\c!width \relax % \zeropoint == unset
+ \headnumberwidth \headparameter\c!numberwidth \relax % \zeropoint == unset
+ \headnumberdistance\headparameter\c!distance \relax
+ \headtextdistance \headparameter\c!textdistance\relax
+ \headtextwidth \headparameter\c!textwidth \relax} % \zeropoint == unset
\unexpanded\def\headtextcontent
{\begingroup
@@ -626,23 +688,57 @@
[\c!alternative=\v!vertical,
\c!renderingsetup=\??headrenderings:\v!inmargin]
+% \startsetups[\??headrenderings:\v!inmargin]
+% \vbox {
+% \headsetupspacing
+% \begstrut % use one \strut here!
+% \dontleavehmode % in case there is no strut, else side effects with llap
+% \ifconditional\headshownumber
+% \llap {
+% \signalrightpage
+% \hbox {
+% \hfill
+% \headnumbercontent
+% \doifelserightpage{
+% \scratchdistance\leftmargindistance
+% } {
+% \scratchdistance\rightmargindistance
+% }
+% \hskip\dimexpr\d_strc_rendering_local_leftoffset+\scratchdistance\relax
+% }
+% }
+% \else
+% \fakeheadnumbercontent % will also be done in the other ones (force consistency with numbered)
+% \fi
+% \headtextcontent
+% }
+% \stopsetups
+
\startsetups[\??headrenderings:\v!inmargin]
\vbox {
\headsetupspacing
- \begstrut % use one \strut here!
\dontleavehmode % in case there is no strut, else side effects with llap
+ \begstrut % use one \strut here!
\ifconditional\headshownumber
- \llap {
- \signalrightpage
- \hbox {
- \hfill
+ \doifelsesomething {\headparameter\c!location} {
+ % kind of new
+ \margindata [\headparameter\c!location] {
\headnumbercontent
- \doifelserightpage{
- \scratchdistance\leftmargindistance
- } {
- \scratchdistance\rightmargindistance
+ }
+ } {
+ % normal backward compatible variant
+ \llap {
+ \signalrightpage
+ \hbox {
+ \hfill
+ \headnumbercontent
+ \doifelserightpage{
+ \scratchdistance\leftmargindistance
+ } {
+ \scratchdistance\rightmargindistance
+ }
+ \hskip\dimexpr\d_strc_rendering_local_leftoffset+\scratchdistance\relax
}
- \hskip\dimexpr\d_strc_rendering_local_leftoffset+\scratchdistance\relax
}
}
\else
@@ -786,4 +882,9 @@
\fi
\stopsetups
+% see typo-mar.mkiv:
+%
+% \defineheadalternative
+% [\v!margintext]
+
\protect \endinput