diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/spac-hor.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/spac-hor.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/spac-hor.mkiv | 139 |
1 files changed, 67 insertions, 72 deletions
diff --git a/Master/texmf-dist/tex/context/base/spac-hor.mkiv b/Master/texmf-dist/tex/context/base/spac-hor.mkiv index 9f902678a4c..39edaa2ff00 100644 --- a/Master/texmf-dist/tex/context/base/spac-hor.mkiv +++ b/Master/texmf-dist/tex/context/base/spac-hor.mkiv @@ -23,8 +23,9 @@ \newdimen \ctxparindent \parindent\ctxparindent % for the show -\newif \ifindentfirstparagraph \indentfirstparagraphtrue -\chardef\indentingtoggle\zerocount +\newif\ifindentfirstparagraph \indentfirstparagraphtrue + +\newconstant\indentingtogglestate %D After a blank or comparable situation (left side floats) we %D need to check if the next paragraph has to be indented. @@ -38,35 +39,46 @@ \def\checkeverypar % currently a hack {\ifzeropt\parindent\else - \doifsometokselse\everypar\donothing{\appendtoks\checkindentation\to\everypar}% + \doifsometokselse\everypar\donothing\docheckupcomingindentation \fi} +\def\docheckupcomingindentation + {\appendtoks\checkindentation\to\everypar} + \definecomplexorsimple\setupindenting \def\complexsetupindenting[#1]% {\edef\currentindenting{#1}% - \doifsomething\currentindenting % handy when a parameter is passed - {% not here: \indentfirstparagraphtrue - % not here: \parindent\ctxparindent - % not here: \chardef\indentingtoggle\zerocount - % we use commacommand in order to catch #1 being a command (expanded parameter) - \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc - \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest - \checkeverypar % only when non-empty #1 - \ifindentfirstparagraph\else\noindentation\fi % added - \toggleindentation}} + \ifx\currentindenting\empty \else + \doapplycurrentindenting + \fi} + +\def\doapplycurrentindenting + {% not here: \indentfirstparagraphtrue + % not here: \parindent\ctxparindent + % not here: \indentingtogglestate\zerocount + % we use commacommand in order to catch #1 being a command (expanded parameter) + \processcommacommand[\currentindenting]\docomplexsetupindentingA % catch small, medium, etc + \processcommacommand[\currentindenting]\docomplexsetupindentingB % catch rest + \checkeverypar % only when non-empty #1 + \ifindentfirstparagraph\else\noindentation\fi % added + \toggleindentation} \def\docomplexsetupindentingA#1% - {\edefconvertedargument\!!stringa{#1}% can this be done differently now? - \ifcsname\??in:\!!stringa\endcsname \else + {\ifcsname\??in:#1\endcsname + % case b + \else \edef\currentindentation{#1}% \let\normalindentation\currentindentation \simplesetupindenting \fi} \def\docomplexsetupindentingB#1% - {\edefconvertedargument\!!stringa{#1}% catch #1=\somedimen - \executeifdefined{\??in:\!!stringa}\donothing} + {\ifcsname\??in:#1\endcsname + \csname\??in:#1\endcsname + \else + % case a + \fi} \def\simplesetupindenting % empty case, a it strange, needed this way? {\assigndimension\currentindentation\ctxparindent{1em}{1.5em}{2em}} @@ -89,10 +101,10 @@ \defineindentingmethod [\v!always] {\parindent\ctxparindent\relax} % no \indent ! \defineindentingmethod [\v!never] {\parindent\zeropoint\relax % no \indent ! - \chardef\indentingtoggle\zerocount} + \indentingtogglestate\zerocount} -\defineindentingmethod [\v!odd] {\chardef\indentingtoggle\plusone} -\defineindentingmethod [\v!even] {\chardef\indentingtoggle\plustwo} +\defineindentingmethod [\v!odd] {\indentingtogglestate\plusone} +\defineindentingmethod [\v!even] {\indentingtogglestate\plustwo} \defineindentingmethod [\v!normal] {\ifx\normalindentation\empty\else \let\currentindentation\normalindentation @@ -101,7 +113,7 @@ \defineindentingmethod [\v!reset] {\indentfirstparagraphtrue \parindent\zeropoint - \chardef\indentingtoggle\zerocount} + \indentingtogglestate\zerocount} \def\noindenting{\indenting[\v!no, \v!next ]} \def\doindenting{\indenting[\v!yes,\v!first]} @@ -159,7 +171,7 @@ \fi \fi} \def\toggleindentation % does not play well with noindentation - {\ifcase\indentingtoggle + {\ifcase\indentingtogglestate % nothing \or \notoggleindentation @@ -186,27 +198,15 @@ \popmacro\checkindentation \to \everypopsomestate -% we need to save the state if we want to adapt behaviour to empty lines -% -% \def\setlasthvmode -% {\global\chardef\savedhvmode\ifhmode\plusone\else\ifvmode\plustwo\else\zerocount\fi\fi} -% -% \def\resetlasthvmode -% {\global\chardef\savedhvmode\zerocount} -% -% \chardef\savedhvmode\zerocount - % This is a user requested hack (using the auto-hook). -\chardef\recheckindentationmode\zerocount +\newconditional\recheckindentationmode \def\dontrechecknextindentation - {\global\chardef\recheckindentationmode\zerocount} + {\global\setfalse\recheckindentationmode} \def\dorechecknextindentation - {\ifcase\recheckindentationmode - % nothing - \or + {\ifconditional\recheckindentationmode \dontrechecknextindentation \expandafter\doautoindentation \fi} @@ -215,7 +215,7 @@ {\doifnextcharelse\par\donothing\noindentation} \def\autoindentation - {\global\chardef\recheckindentationmode\plusone} + {\global\settrue\recheckindentationmode} %D An example of usage: %D @@ -260,7 +260,7 @@ %D \macros %D {frenchspacing,nonfrenchspacing} %D -%D Smehow \type{\frenchspacing} can lead to hyphenation between +%D Somehow \type{\frenchspacing} can lead to hyphenation between %D dashes so we now have \type {\newfrenchspacing} (moved from %D \type {syst-chr}). @@ -339,7 +339,7 @@ \unexpanded\def\nonbreakablespace{\penalty\plustenthousand\normalspaceprimitive} % no space in math -\letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later +\letcatcodecommand \ctxcatcodes \tildeasciicode \nonbreakablespace % overloaded later \def\space { } \def\removelastspace{\ifhmode\unskip\fi} @@ -347,8 +347,8 @@ \ifdefined\softhyphen \else \let\softhyphen\- \fi -\ctxlua{tex.sprint(tex.ctxcatcodes,"\string\\unexpanded\string\\def\string\\\string\n{\string\\space}")} -% \ctxlua{tex.sprint(tex.ctxcatcodes,"\string\\let\string\\\string\n=\string\\space")} +\ctxsprint{"\string\\unexpanded\string\\def\string\\\string\n{\string\\space}"} +%ctxsprint{"\string\\let\string\\\string\n=\string\\space"} % in tables we need: % @@ -361,7 +361,7 @@ \hskip\wd\scratchbox\relax} \def\fixedspaces - {\letcatcodecommand \ctxcatcodes `\~ \fixedspace} + {\letcatcodecommand \ctxcatcodes \tildeasciicode \fixedspace} \appendtoks \let~\space @@ -590,14 +590,6 @@ \newskip\leftskipadaption \newskip\rightskipadaption -\def\doadaptleftskip#1% - {\dosetleftskipadaption{#1}% - \advance\leftskip \leftskipadaption} - -\def\doadaptrightskip#1% - {\dosetrightskipadaption{#1}% - \advance\rightskip \rightskipadaption} - \setvalue{@lsa@\v!standard}{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} \setvalue{@lsa@\v!yes }{\ifdim\ctxparindent=\zeropoint\@@slleft\else\ctxparindent\fi} \letvalue{@lsa@\v!no }\zeropoint @@ -607,25 +599,11 @@ \letvalue{@rsa@\v!no }\zeropoint \letvalue{@rsa@\empty }\zeropoint -\def\dosetleftskipadaption#1% - {\edefconvertedargument\ascii{@lsa@#1}% - \leftskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} - -\def\dosetrightskipadaption#1% - {\edefconvertedargument\ascii{@rsa@#1}% - \rightskipadaption - \ifcsname\ascii\endcsname - \csname\ascii\endcsname - \else - #1% - \fi - \relax} +\def\dosetleftskipadaption #1{\leftskipadaption \ifcsname @lsa@#1\endcsname\csname @lsa@#1\endcsname\else#1\fi\relax} +\def\dosetrightskipadaption#1{\rightskipadaption\ifcsname @rsa@#1\endcsname\csname @rsa@#1\endcsname\else#1\fi\relax} + +\def\doadaptleftskip #1{\dosetleftskipadaption {#1}\advance\leftskip \leftskipadaption } +\def\doadaptrightskip#1{\dosetrightskipadaption{#1}\advance\rightskip\rightskipadaption} %D Tolerance: @@ -910,7 +888,7 @@ \normalspaces % to be sure \to \everybeforeoutput -%D A more robust variant ofthe \MKII\ one: +%D A more robust variant of the \MKII\ one: %D %D \startbuffer %D bla \TEX\autoinsertnextspace bla @@ -928,7 +906,7 @@ {\futurelet\nexttoken\doautoinsertnextspace} \def\doautoinsertnextspace - {\ctxlua{commands.autonextspace("\meaning\nexttoken")}} % todo, just consult nexttoken at the lua end + {\ctxcommand{autonextspace("\meaning\nexttoken")}} % todo, just consult nexttoken at the lua end %D Moved from bib module: @@ -943,4 +921,21 @@ \chardef\zwnj="200C \chardef\zwj ="200D +% TODO (but used in languages): + +\unexpanded\def\textormathglue#1#2#3% cleaned up one + {\begingroup + \ifmmode + \mskip#1#2% + \else + \scratchdimen#1\hspaceamount\empty{#3}% + \scratchskip\scratchdimen\!!plus.5\scratchdimen\!!minus.3\scratchdimen + \hskip\scratchskip + \fi + \endgroup} + +\def\thinglue {\textormathglue+\thinmuskip 1} +\def\medglue {\textormathglue+\medmuskip 2} +\def\thickglue{\textormathglue+\thickmuskip3} + \protect \endinput |