summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/spac-ali.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/spac-ali.mkiv')
-rw-r--r--tex/context/base/mkiv/spac-ali.mkiv134
1 files changed, 29 insertions, 105 deletions
diff --git a/tex/context/base/mkiv/spac-ali.mkiv b/tex/context/base/mkiv/spac-ali.mkiv
index fbcf45caa..4362ff250 100644
--- a/tex/context/base/mkiv/spac-ali.mkiv
+++ b/tex/context/base/mkiv/spac-ali.mkiv
@@ -27,7 +27,7 @@
%
% but that also means myoption gets frozen due to caching.
-\registerctxluafile{spac-ali}{}
+\registerctxluafile{spac-ali}{optimize}
\definesystemattribute[realign] [public] % might be combined with the next one
\definesystemattribute[alignstate][public] % will make a single attributes for several states
@@ -61,16 +61,6 @@
\newtoks\everyresetalign % todo
-%D We will not use bodydir and pagedir so we disable them. That way we get
-%D normal hyperlink support. We back on it (too hard to fake \type {\the}).
-
-\unexpanded\def\syst_fatal_dir_error#1%
- {\writestatus{fatal error}{\string#1\space is forbidden}%
- \wait}
-
-\def\pagedir {\syst_fatal_dir_error\pagedir} \let\normalpagedir\pagedir
-\def\bodydir {\syst_fatal_dir_error\bodydir} \let\normalbodydir\bodydir
-
% This will become a more advanced layout controller soon:
\newconditional\layoutlefttoright \settrue\layoutlefttoright
@@ -94,63 +84,23 @@
\unexpanded\def\spac_directions_lefttoright_vmode
{\settrue\displaylefttoright
\settrue\inlinelefttoright
- \textdir TLT\relax
- \pardir TLT\relax}
+ \textdirection\directionlefttoright
+ \pardirection \directionlefttoright}
\unexpanded\def\spac_directions_righttoleft_vmode
{\setfalse\displaylefttoright
\setfalse\inlinelefttoright
- \textdir TRT\relax
- \pardir TRT\relax}
-
-% % keep this as reference
-%
-% \unexpanded\def\spac_directions_lefttoright_hmode
-% {\textdir TLT\relax
-% \settrue\inlinelefttoright}
-%
-% \unexpanded\def\spac_directions_righttoleft_hmode
-% {\textdir TRT\relax
-% \setfalse\inlinelefttoright}
-%
-% \unexpanded\def\spac_directions_lefttoright_hmode
-% {\ifzeropt\lastskip
-% \textdir TLT\relax
-% \else
-% \scratchskip\lastskip
-% \unskip
-% \textdir TLT\relax
-% \hskip\scratchskip
-% \fi
-% \settrue\inlinelefttoright}
-%
-% \unexpanded\def\spac_directions_righttoleft_hmode
-% {\ifzeropt\lastskip
-% \textdir TRT\relax
-% \else
-% \scratchskip\lastskip
-% \unskip
-% \textdir TRT\relax
-% \hskip\scratchskip
-% \fi
-% \setfalse\inlinelefttoright}
+ \textdirection\directionrighttoleft
+ \pardirection \directionrighttoleft}
\unexpanded\def\spac_directions_lefttoright_hmode
- {\linedir TLT\relax % linedir keeps subtype of skip
+ {\linedirection\directionlefttoright % linedir keeps subtype of skip
\settrue\inlinelefttoright}
\unexpanded\def\spac_directions_righttoleft_hmode
- {\linedir TRT\relax % linedir keeps subtype of skip
+ {\linedirection\directionrighttoleft % linedir keeps subtype of skip
\setfalse\inlinelefttoright}
-% \def\currentdirectionparameters
-% {\ifconditional\inlinelefttoright \else
-% idir {r2l}%
-% \fi
-% \ifconditional\displaylefttoright \else
-% ddir {r2l}%
-% \fi}
-
\unexpanded\def\synchronizelayoutdirection
{\ifconditional\layoutlefttoright
\spac_directions_synchronize_lr
@@ -167,16 +117,17 @@
\def\spac_directions_synchronize_lr
{\settrue\inlinelefttoright
- \textdir TLT\relax
- \pardir TLT\relax}
+ \textdirection\directionlefttoright
+ \pardirection \directionlefttoright}
\def\spac_directions_synchronize_rl
{\setfalse\inlinelefttoright
- \textdir TRT\relax
- \pardir TRT\relax}
+ \textdirection\directionrighttoleft
+ \pardirection \directionrighttoleft}
\unexpanded\def\synchronizeinlinedirection
- {\textdir T\ifconditional\inlinelefttoright L\else R\fi T\relax}
+ {% why not \linedirection here
+ \textdirection\ifconditional\inlinelefttoright\directionlefttoright\else\directionrighttoleft\fi}
\unexpanded\def\checkedlefttoright
{\ifvmode
@@ -210,49 +161,20 @@
\unexpanded\def\usebidiparameter#1%
{\begincsname\??bidi#1\c!bidi\endcsname}
-% maybe some day:
-%
-% \newcount\postdirpenalty % \zerocount
-% \newcount\predirpenalty % \zerocount
-%
-% \def\spac_directions_post_break
-% {\ifhmode
-% \removeunwantedspaces
-% \penalty\postdirpenalty
-% \fi}
-%
-% \def\spac_directions_pre_break
-% {\ifhmode
-% \penalty\predirpenalty
-% \ignorespaces
-% \fi}
-%
-% \unexpanded\def\spac_directions_lefttoright_hmode
-% {\settrue\inlinelefttoright
-% \textdir TLT\relax
-% \aftergroup\spac_directions_post_break
-% \spac_directions_pre_break}
-%
-% \unexpanded\def\spac_directions_righttoleft_hmode
-% {\textdir TRT\relax
-% \setfalse\inlinelefttoright
-% \aftergroup\spac_directions_post_break
-% \spac_directions_pre_break}
-
\unexpanded\def\showdirections
{\dontleavehmode
- \begingroup\infofont\textdir TLT[\space
- layout:\ifconditional \layoutlefttoright l2r\else r2l\fi\space
- display:\ifconditional\displaylefttoright l2r\else r2l\fi\space
- inline:\ifconditional \inlinelefttoright l2r\else r2l\fi\space
+ \begingroup\infofont\textdirection\directionlefttoright[\space
+ layout: \ifconditional\layoutlefttoright l2r\else r2l\fi\space
+ display: \ifconditional\displaylefttoright l2r\else r2l\fi\space
+ inline: \ifconditional\inlinelefttoright l2r\else r2l\fi\space
]\endgroup}
-\unexpanded\def\righttolefthbox#1#{\normalhbox dir TRT #1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox
-\unexpanded\def\lefttorighthbox#1#{\normalhbox dir TLT #1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox
-\unexpanded\def\righttoleftvbox#1#{\normalvbox dir TRT #1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox
-\unexpanded\def\lefttorightvbox#1#{\normalvbox dir TLT #1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox
-\unexpanded\def\righttoleftvtop#1#{\normalvtop dir TRT #1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop
-\unexpanded\def\lefttorightvtop#1#{\normalvtop dir TLT #1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop
+\unexpanded\def\righttolefthbox#1#{\reversehbox#1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox
+\unexpanded\def\lefttorighthbox#1#{\naturalhbox#1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox
+\unexpanded\def\righttoleftvbox#1#{\reversevbox#1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox
+\unexpanded\def\lefttorightvbox#1#{\naturalvbox#1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox
+\unexpanded\def\righttoleftvtop#1#{\reversevtop#1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop
+\unexpanded\def\lefttorightvtop#1#{\naturalvtop#1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop
\unexpanded\def\autodirhbox#1#{\hbox#1\bgroup\synchronizeinlinedirection\let\next}
\unexpanded\def\autodirvbox#1#{\vbox#1\bgroup\synchronizeinlinedirection\let\next} % maybe also pardir or maybe just a \vbox
@@ -355,7 +277,8 @@
\newconstant\c_spac_align_state_par_fill
\def\v_spac_align_fill_amount {\plusone fil}
-\def\v_spac_align_fill_amount_hard {\plusone fill}
+\def\v_spac_align_fill_amount_hard {\plusone fill}
+\def\v_spac_align_fill_amount_extreme {\plustenthousand filll}
\def\v_spac_align_fill_amount_negative {\minusone fil}
\def\v_spac_align_fill_amount_double {\plustwo fil}
\def\v_spac_align_fill_amount_space {\plustwo fil} % can be added to xspace if we have a key
@@ -479,7 +402,8 @@
\spaceskip \zeropoint\relax
\xspaceskip \zeropoint\relax
\parfillskip \zeropoint
- \parfillleftskip\zeropoint\s!plus\v_spac_align_fill_amount_hard\relax
+ \parfillleftskip\zeropoint\s!plus\v_spac_align_fill_amount_extreme\relax
+ \parfillleftmode\plustwo % \plusone checks for multiple lines
\parindent \zeropoint
\relax}
@@ -643,8 +567,8 @@
}}% kept, nice for tracing
\edef\raggedcommand {\the\t_spac_align_collected }%
\edef\updateraggedskips{\spac_align_flush_horizontal}%
- \global\expandafter\let\csname\??alignmentnormalcache\m_spac_align_asked\endcsname\raggedcommand
- \global\expandafter\let\csname\??alignmentraggedcache\m_spac_align_asked\endcsname\updateraggedskips}
+ \expandafter\glet\csname\??alignmentnormalcache\m_spac_align_asked\endcsname\raggedcommand
+ \expandafter\glet\csname\??alignmentraggedcache\m_spac_align_asked\endcsname\updateraggedskips}
\def\spac_align_collect#1%
{\csname\??aligncommand#1\endcsname}