diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-rul.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/node-rul.mkiv | 261 |
1 files changed, 138 insertions, 123 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-rul.mkiv b/Master/texmf-dist/tex/context/base/node-rul.mkiv index 90bcd9e403f..1f1ac20ec01 100644 --- a/Master/texmf-dist/tex/context/base/node-rul.mkiv +++ b/Master/texmf-dist/tex/context/base/node-rul.mkiv @@ -5,7 +5,7 @@ %D subtitle=Bars, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -15,8 +15,6 @@ \writestatus{loading}{ConTeXt Core Macros / Bars} -%D The name of this file might change. - %D \macros %D {underbar,underbars, %D overbar,overbars, @@ -36,11 +34,9 @@ %D %D \typebuffer %D -%D \startvoorbeeld %D \startlines %D \getbuffer %D \stoplines -%D \stopvoorbeeld %D %D The next macros are derived from the \PLAIN\ \TEX\ one, but %D also supports nesting. The \type{$} keeps us in horizontal @@ -54,9 +50,15 @@ %D \showsetup{overstrikes} %D %D \showsetup{setupunderbar} +%D +%D Nested bars can be configured by appending \type {:<index>} to the +%D category. -%D todo: mkvi this file ... no redefine, just pass all parameters, too messy now -%D (due to grouping) so better hash settings at the lua end +%D As with many early usage of \LUA\ in \MKIV\ this mechanism explores a way +%D to deal with local settings at the \TEX\ end and remembering parameters +%D at the \LUA\ end. We might do things differently now, but as settings normally +%D don't change that often, we're not in a hurry to do that now. The problem at +%D the \LUA\ end is that we don't know when to clean up. \unprotect @@ -65,40 +67,42 @@ \registerctxluafile{node-rul}{1.001} -\installcommandhandler \??on {bar} \??on +\installcorenamespace{bar} +\installcorenamespace{barindex} +\installcorenamespace{barattribute} +\installcorenamespace{barstack} + +\installcommandhandler \??bar {bar} \??bar -\newtoks\checkalldefinedbars +\newtoks\t_node_rules_checklist + +\let\c_node_rules_index\relax % temporary synonym +\let\p_node_rules_color\empty \let\setupbars\setupbar \appendtoks - \ifsecondargument - \dodefinebarindeed\currentbar - \else - \the\checkalldefinedbars - \fi + \ifsecondargument + \node_rules_define + \else + \the\t_node_rules_checklist + \fi \to \everysetupbar \appendtoks - \ifcsname\??on:\currentbar:c\endcsname - \csname\??on:\currentbar:c\endcsname\zerocount - \else - \expandafter\newcount\csname\??on:\currentbar:c\endcsname - \fi - \normalexpanded{\checkalldefinedbars{\doredefinebar{\currentbar}\the\checkalldefinedbars}}% - \dodefinebarindeed\currentbar - \setuevalue\currentbar{\doruled{\currentbar}}% + \ifcsname\??barindex\currentbar\endcsname + \csname\??barindex\currentbar\endcsname\zerocount + \else + \expandafter\newcount\csname\??barindex\currentbar\endcsname + \fi + \normalexpanded{\t_node_rules_checklist{\node_rules_redefine{\currentbar}\the\t_node_rules_checklist}}% + \node_rules_define + \setuevalue\currentbar{\node_rules_direct{\currentbar}}% \to \everydefinebar -\unexpanded\def\dodefinebarindeed#1% - {\begingroup - \edef\currentbar{#1}% - \doifsomethingelse{\barparameter\c!color} - {\donetrue\colored[\barparameter\c!color]} - {\donefalse}% - \normalexpanded - {\endgroup - \scratchcounter\ctxlua{nodes.rules.define { +\unexpanded\def\node_rules_define + {\edef\p_node_rules_color{\barparameter\c!color}% + \setevalue{\??barattribute\currentbar}{\number\ctxlua{nodes.rules.define { method = \barparameter\c!method, offset = \barparameter\c!offset, continue = "\barparameter\c!continue", @@ -107,50 +111,51 @@ unit = "\barparameter\c!unit", order = "\barparameter\c!order", max = \barparameter\c!max, - ma = \ifdone\the\attribute\colormodelattribute \else0\fi, - ca = \ifdone\the\attribute\colorattribute \else0\fi, - ta = \ifdone\the\attribute\transparencyattribute\else0\fi - }}}% - \setevalue{\??on#1:a}{\the\scratchcounter}} - -\let\doredefinebar\dodefinebarindeed - -\unexpanded\def\doruled#1% - {\groupedcommand{\dodoruled{#1}}\relax} - -\def\dodoruled - {\ctxlua{nodes.rules.enable()}% - \glet\dodoruled\dodoruledindeed - \dodoruled} - -\def\dodoruledindeed#1% maybe reverse the 1000 - {\advance\csname\??on:#1:c\endcsname\plusone % local ? - \scratchcounter\csname\??on:#1:c\endcsname + ma = \thecolormodelattribute, + ca = \thecolorattribute\p_node_rules_color, + ta = \thetransparencyattribute\p_node_rules_color + }}}} + +\unexpanded\def\node_rules_redefine#1% + {\def\currentbar{#1}\node_rules_define} + +\unexpanded\def\node_rules_direct#1% + {\groupedcommand{\node_rules_set{#1}}\relax} + +\def\node_rules_set + {\ctxlua{nodes.rules.enable()}% will be moved to lua + \glet\node_rules_set\node_rules_set_indeed + \node_rules_set} + +\def\node_rules_set_indeed#1% maybe reverse the 1000 (also maybe use more attributes instead of settings) + {\edef\currentbar{#1}% + \expandafter\let\expandafter\c_node_rules_index\csname\??barindex#1\endcsname + \advance\c_node_rules_index\plusone + \usebarstyleandcolor\c!foregroundstyle\c!foregroundcolor \attribute\ruledattribute\numexpr - 1000*\scratchcounter - +\csname\??on#1\ifcsname\??on#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname + \plusthousand*\c_node_rules_index + +\csname\??barattribute#1\ifcsname\??bar#1:\number\c_node_rules_index\s!parent\endcsname:\number\c_node_rules_index\fi\endcsname \relax} -% ungrouped - \unexpanded\def\startbar[#1]% {\begingroup - \dodoruled{#1}} + \node_rules_set{#1}} \unexpanded\def\stopbar {\endgroup} -\newcount\currentbarnesting % todo: same as colors +% ungrouped + +\newcount\c_node_rules_nesting % todo: same as colors \unexpanded\def\pushbar[#1]% - {\global\advance\currentbarnesting\plusone - \expandafter\edef\csname\??on:s:\number\currentbarnesting\endcsname - {\attribute\ruledattribute\the\attribute\ruledattribute}% stack - \dodoruled{#1}} + {\global\advance\c_node_rules_nesting\plusone + \expandafter\edef\csname\??barstack\number\c_node_rules_nesting\endcsname{\attribute\ruledattribute\the\attribute\ruledattribute}% + \node_rules_set{#1}} \unexpanded\def\popbar - {\csname\??on:s:\number\currentbarnesting\endcsname - \global\advance\currentbarnesting\minusone} + {\csname\??barstack\number\c_node_rules_nesting\endcsname + \global\advance\c_node_rules_nesting\minusone} \setupbars [\c!method=0, % new: 0=center nested, 1=stack nested @@ -158,6 +163,7 @@ \c!offset=0, % upwards, replaces: topoffset bottomoffset \c!dy=0, \c!max=3, + \c!style=, \c!rulethickness=.1, \c!order=\v!foreground, \c!unit=ex, % so now we are relative @@ -166,13 +172,23 @@ % \definebar[touchbar] [\c!method=0,\c!dy=-0.4,\c!offset=-0.0] % \definebar[touchbars] [touchbar] [\c!continue=\v!yes] -\definebar[\v!overstrike] [\c!method=0,\c!dy= 0.4,\c!offset= 0.5,\c!continue=\v!yes] -\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes] -\definebar[\v!overbar] [\c!method=1,\c!dy= 0.4,\c!offset= 1.8,\c!continue=\v!yes] +\definebar[\v!overstrike][\c!method=0,\c!dy=0.4,\c!offset=0.5,\c!continue=\v!yes] +\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes] +\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes] + +\definebar + [\v!understrike] + [\c!method=0, + \c!offset=1.375, + \c!rulethickness=2.5, + \c!continue=\v!yes, + \c!order=\v!background, + \c!color=lightgray] \definebar[\v!overstrikes] [\v!overstrike] [\c!continue=\v!no] \definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no] \definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no] +\definebar[\v!understrikes][\v!understrike][\c!continue=\v!no] % we want these always so ... @@ -188,82 +204,75 @@ %D This will move: (a bit duplicated) -\installcommandhandler \??ra {shift} \??ra +\installcorenamespace{shift} +\installcorenamespace{shiftindex} +\installcorenamespace{shiftattribute} + +\installcommandhandler \??shift {shift} \??shift + +\newtoks\t_node_shifts_checklist -\newtoks\checkalldefinedshifts +\let\c_node_shifts_index\relax % temporary synonym \let\setupshifts\setupshift \appendtoks - \ifsecondargument - \dodefineshiftindeed\currentshift - \else - \the\checkalldefinedshifts - \fi + \ifsecondargument + \node_shifts_define + \else + \the\t_node_shifts_checklist + \fi \to \everysetupshift \appendtoks - \ifcsname\??ra:\currentshift:c\endcsname - \csname\??ra:\currentshift:c\endcsname\zerocount - \else - \expandafter\newcount\csname\??ra:\currentshift:c\endcsname - \fi - \normalexpanded{\checkalldefinedshifts{\doredefineshift{\currentshift}\the\checkalldefinedshifts}}% - \dodefineshiftindeed{\currentshift}% - \setuevalue\currentshift{\doshifted{\currentshift}}% + \ifcsname\??shiftindex\currentshift\endcsname + \csname\??shiftindex\currentshift\endcsname\zerocount + \else + \expandafter\newcount\csname\??shiftindex\currentshift\endcsname + \fi + \normalexpanded{\t_node_shifts_checklist{\node_shifts_redefine{\currentshift}\the\t_node_shifts_checklist}}% + \node_shifts_define + \setuevalue\currentshift{\node_shifts_direct{\currentshift}}% \to \everydefineshift -\unexpanded\def\dodefineshiftindeed#1% - {\begingroup - \edef\currentshift{#1}% - \normalexpanded - {\endgroup - \scratchcounter\ctxlua{nodes.shifts.define { +\unexpanded\def\node_shifts_define + {\setevalue{\??shiftattribute\currentshift}{\number\ctxlua{nodes.shifts.define { method = \shiftparameter\c!method, continue = "\shiftparameter\c!continue", dy = \shiftparameter\c!dy, unit = "\shiftparameter\c!unit", - }}}% - \setevalue{\??ra#1:a}{\the\scratchcounter}} - -\let\doredefineshift\dodefineshiftindeed + }}}} -% \unexpanded\def\doshifted#1% -% {\groupedcommand{\dodoshifted{#1}}\relax} +\unexpanded\def\node_shifts_redefine#1% + {\def\currentshift{#1}\node_shifts_define} -\def\dodoshifted +\unexpanded\def\node_shifts_set {\ctxlua{nodes.shifts.enable()}% - \glet\dodoshifted\dodoshiftedindeed - \dodoshifted} + \glet\node_shifts_set\node_shifts_set_indeed + \node_shifts_set} -\def\dostartisolation{\signalcharacter} -\def\dostopisolation {\signalcharacter} -\def\doisolator {\signalcharacter} +% \unexpanded\def\node_shifts_direct#1% +% {\doisolatedgroupedalign{\node_shifts_set{#1}}\donothing} -\def\doisolatedgroupedalign#1#2% +\unexpanded\def\node_shifts_direct#1% {\groupedcommand - {\begingroup\dostartisolation\begingroup#1} - {#2\endgroup\dostopisolation\endgroup}} + {\begingroup\dostartisolation\begingroup\node_shifts_set{#1}} + {\endgroup\dostopisolation\endgroup}} -\def\dosetupisolatedalign#1% - {\doisolator - \setupalign[#1]\relax} - -\def\dodoshiftedindeed#1% +\def\node_shifts_set_indeed#1% todo: check parent ! {\def\currentshift{#1}% - \advance\csname\??ra:#1:c\endcsname\plusone - \scratchcounter\csname\??ra:#1:c\endcsname - \attribute\shiftedattribute\numexpr1000*\scratchcounter - +\csname\??ra#1\ifcsname\??ra#1:\number\scratchcounter\s!parent\endcsname:\number\scratchcounter\fi:a\endcsname - \dosetshiftattributes\c!style\c!color + \expandafter\let\expandafter\c_node_shifts_index\csname\??shiftindex#1\endcsname + \advance\c_node_shifts_index\plusone + \attribute\shiftedattribute\numexpr + \plusthousand*\c_node_shifts_index + +\csname\??shiftattribute#1\ifcsname\??shift#1:\number\c_node_shifts_index\s!parent\endcsname:\number\c_node_shifts_index\fi\endcsname + \relax + \useshiftstyleandcolor\c!style\c!color \dosetupisolatedalign{\shiftparameter\c!align}} -\unexpanded\def\doshifted#1% - {\doisolatedgroupedalign{\dodoshifted{#1}}{}} - \unexpanded\def\startshift[#1]% {\begingroup - \dodoshifted{#1}} + \node_shifts_set{#1}} \unexpanded\def\stopshift {\endgroup} @@ -288,13 +297,19 @@ \expandafter\let\expandafter\shiftup \csname\v!shiftup \endcsname \expandafter\let\expandafter\shiftdown \csname\v!shiftdown \endcsname -\protect \endinput +% This is a weird helper: -% obsolete: +\unexpanded\def\dostartisolation{\signalcharacter} +\unexpanded\def\dostopisolation {\signalcharacter} +\unexpanded\def\doisolator {\signalcharacter} -\setupunderbar - [\c!alternative=a, - \c!rulethickness=\linewidth, - \c!bottomoffset=1.5pt, - \c!topoffset=2.5pt, - \c!rulecolor=] +\unexpanded\def\dosetupisolatedalign#1% + {\doisolator + \setupalign[#1]\relax} + +\unexpanded\def\doisolatedgroupedalign#1#2% + {\groupedcommand + {\begingroup\dostartisolation\begingroup#1} + {#2\endgroup\dostopisolation\endgroup}} + +\protect \endinput |