diff options
Diffstat (limited to 'tex/context/base/strc-lnt.mkvi')
-rw-r--r-- | tex/context/base/strc-lnt.mkvi | 127 |
1 files changed, 116 insertions, 11 deletions
diff --git a/tex/context/base/strc-lnt.mkvi b/tex/context/base/strc-lnt.mkvi index f07ce7839..4160360d2 100644 --- a/tex/context/base/strc-lnt.mkvi +++ b/tex/context/base/strc-lnt.mkvi @@ -27,11 +27,20 @@ {\dotripleempty\strc_linenotes_define} \def\strc_linenotes_define[#1][#2][#3]% - {\definenote[#1][#2][#3]% - \expandafter\let\csname\??linenote#1\expandafter\endcsname\csname#1\endcsname % use copy command - \setuevalue {#1}{\strc_linenotes_direct{#1}}% - \setuevalue{\e!start#1}{\strc_linenotes_start {#1}}% - \setuevalue{\e!stop #1}{\strc_linenotes_stop }} + {\ifcsname\??linenote#1\endcsname + % there might be files that define the default 'linenote' + \ifthirdargument + \setupnote[#1][#3]% + \else\ifsecondargument + \setupnote[#1][#2]% + \fi\fi + \else + \definenote[#1][#2][#3]% + \expandafter\let\csname\??linenote#1\expandafter\endcsname\csname#1\endcsname % use copy command + \setuevalue {#1}{\strc_linenotes_direct{#1}}% + \setuevalue{\e!start#1}{\strc_linenotes_start {#1}}% + \setuevalue{\e!stop #1}{\strc_linenotes_stop }% + \fi} \unexpanded\def\strc_linenotes_direct#1#2% {\global\advance\c_strc_linenotes\plusone @@ -41,6 +50,7 @@ \unexpanded\def\strc_linenotes_start#1[#2]#3% {\global\advance\c_strc_linenotes\plusone + \keepunwantedspaces \strc_linenotes_indeed{#1}{#2}{#3}% \strc_linenotes_traced{#2}% \startline[#2]} @@ -48,19 +58,109 @@ \unexpanded\def\strc_linenotes_stop[#1]% {\stopline[#1]} -\unexpanded\def\strc_linenotes_indeed#1#2#3% will be redone +\let\m_page_lines_previous_to \relax +\let\m_page_lines_previous_from\relax + +\let\m_page_lines_current_to \relax +\let\m_page_lines_current_from \relax + +\newconditional\c_page_lines_current_to +\newconditional\c_page_lines_current_from + +\installcorenamespace{linenotespreviousfrom} +\installcorenamespace{linenotespreviousto} + +\letvalue\??linenotespreviousfrom\empty +\letvalue\??linenotespreviousto \empty + +\def\page_lines_in_from{\in[lr:b:\currentlinenotereference]} +\def\page_lines_in_to {\in[lr:e:\currentlinenotereference]} + +\unexpanded\def\strc_linenotes_range_normal#1% order + {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + \ifconditional\c_page_lines_current_from + \xdef\m_page_lines_current_from{\currentreferencelinenumber}% + \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \ifconditional\c_page_lines_current_to + \xdef\m_page_lines_current_to{\currentreferencelinenumber}% + \page_lines_in_from + \ifx\m_page_lines_current_from\m_page_lines_current_to \else + \endash + \page_lines_in_to + \fi + \else + \page_lines_in_from + \fi + \else + \page_lines_in_from + \fi} + +\unexpanded\def\strc_linenotes_range_sparse#1% order + {\doifreferencefoundelse{lr:b:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_from + \ifconditional\c_page_lines_current_from + \xdef\m_page_lines_current_from{\currentreferencelinenumber}% + \doifreferencefoundelse{lr:e:\currentlinenotereference}\settrue\setfalse\c_page_lines_current_to + \ifconditional\c_page_lines_current_to + \xdef\m_page_lines_current_to{\currentreferencelinenumber}% + \ifx\m_page_lines_previous_from\m_page_lines_current_from + \ifx\m_page_lines_previous_to\m_page_lines_current_to + \notationparameter\c!compressseparator + \else + \page_lines_in_from + \fi + \else + \page_lines_in_from + \ifx\m_page_lines_current_from\m_page_lines_current_to + \else + \endash + \page_lines_in_to + \fi + \fi + \else + \page_lines_in_from + \fi + \else + \ifx\m_page_lines_previous_from\m_page_lines_current_from + \notationparameter\c!compressseparator + \else + \page_lines_in_from + \fi + \fi} + +\let\currentlinenotereference\empty + +\unexpanded\def\strc_linenotes_indeed#1#2#3% {\begingroup % we keep things local so we can use it as regular note too - \unexpanded\def\linenotelinenumber##1{\inlinerange[#2]}% ##1 == order -% \setupnotation[#1][\c!numbercommand=\linenotelinenumber]% todo: deep hook -% \setupnote[#1][\c!textcommand=\gobbleoneargument]% todo: deep hook \edef\currentnotation{#1}% + \edef\currentlinenotereference{#2}% + \xdef\m_page_lines_previous_from{\csname\??linenotespreviousfrom\ifcsname\??linenotespreviousfrom\currentnotation\endcsname\currentnotation\fi\endcsname}% + \xdef\m_page_lines_previous_to {\csname\??linenotespreviousto \ifcsname\??linenotespreviousto \currentnotation\endcsname\currentnotation\fi\endcsname}% + \doifelse{\notationparameter\c!compress}\v!yes + {\let\linenotelinenumber\strc_linenotes_range_sparse}% + {\let\linenotelinenumber\strc_linenotes_range_normal}% \let\currentnote\currentnotation \letnotationparameter\c!numbercommand\linenotelinenumber% todo: deep hook \letnoteparameter \c!textcommand \gobbleoneargument % todo: deep hook - \relax\getvalue{\??linenote#1}{#3}% + \getvalue{\??linenote\currentnotation}{#3}% + \expandafter\glet\csname\??linenotespreviousfrom\currentnotation\endcsname\m_page_lines_current_from + \expandafter\glet\csname\??linenotespreviousto \currentnotation\endcsname\m_page_lines_current_to \endgroup} +% where to hook this one in? resetcounter has no hook: + +\unexpanded\def\doresetlinenotecompression#1% \strc_linenotes_reset_previous + {\expandafter\glet\csname\??linenotespreviousfrom#1\endcsname\empty + \expandafter\glet\csname\??linenotespreviousto #1\endcsname\empty} + +\definesymbol + [\v!compressseparator] + [\space\hbox{\vl\thinspace\vl}] + +\setupnotations + [%c\compress=\v!no, + \c!compressseparator=\symbol\v!compressseparator] + \let\strc_linenotes_traced\gobbleoneargument \def\strc_linenotes_traced_indeed#1% @@ -79,9 +179,14 @@ \unexpanded\def\tracelinenotes {\let\strc_linenotes_traced\strc_linenotes_traced_indeed} +%D Use these when not properly nested: + +\let\fromlinenote\startlinenote +\let\tolinenote \stoplinenote + % We predefine one, namely \type {\linenote} cum suis. -% \definelinenote[\v!linenote] +\definelinenote[\v!linenote] % beware: line numbers are added later on so grouping setups is a bad idea % |