diff options
Diffstat (limited to 'tex/context/base/spac-ali.mkiv')
-rw-r--r-- | tex/context/base/spac-ali.mkiv | 559 |
1 files changed, 249 insertions, 310 deletions
diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv index 34cddf952..943de1617 100644 --- a/tex/context/base/spac-ali.mkiv +++ b/tex/context/base/spac-ali.mkiv @@ -37,21 +37,22 @@ \installcorenamespace{aligncommand} \installcorenamespace{alignhorizontal} \installcorenamespace{alignvertical} -\installcorenamespace{alignmentcache} +\installcorenamespace{alignmentnormalcache} +\installcorenamespace{alignmentraggedcache} \newtoks\everyresetalign % todo % We will not use bodydir and pagedir so we disable them. That way we get % normal hyperlink support. -\let\saved_normal_body_dir\normalbodydir -\let\saved_normal_page_dir\normalpagedir +\let\spac_directions_normal_body_dir\normalbodydir +\let\spac_directions_normal_page_dir\normalpagedir -\unexpanded\def\bodydir{\afterassignment\bodydir_indeed\saved_normal_body_dir} \let\normalbodydir\bodydir -\unexpanded\def\pagedir{\afterassignment\pagedir_indeed\saved_normal_page_dir} \let\normalpagedir\pagedir +\unexpanded\def\bodydir{\afterassignment\spac_directions_bodydir_indeed\spac_directions_normal_body_dir} \let\normalbodydir\bodydir +\unexpanded\def\pagedir{\afterassignment\spac_directions_pagedir_indeed\spac_directions_normal_page_dir} \let\normalpagedir\pagedir -\def\bodydir_indeed{\saved_normal_body_dir TLT\relax} -\def\pagedir_indeed{\saved_normal_page_dir TLT\relax} +\def\spac_directions_bodydir_indeed{\spac_directions_normal_body_dir TLT\relax} +\def\spac_directions_pagedir_indeed{\spac_directions_normal_page_dir TLT\relax} % This will become a more advanced layout controller soon: @@ -61,35 +62,35 @@ \unexpanded\def\lefttoright {\ifvmode - \lefttoright_vmode + \spac_directions_lefttoright_vmode \else - \lefttoright_hmode + \spac_directions_lefttoright_hmode \fi} -\unexpanded\def\lefttoright_vmode +\unexpanded\def\spac_directions_lefttoright_vmode {\settrue\displaylefttoright \settrue\inlinelefttoright \textdir TLT\relax \pardir TLT\relax} -\unexpanded\def\lefttoright_hmode +\unexpanded\def\spac_directions_lefttoright_hmode {\settrue\inlinelefttoright \textdir TLT\relax} \unexpanded\def\righttoleft {\ifvmode - \righttoleft_vmode + \spac_directions_righttoleft_vmode \else - \righttoleft_hmode + \spac_directions_righttoleft_hmode \fi} -\unexpanded\def\righttoleft_vmode +\unexpanded\def\spac_directions_righttoleft_vmode {\setfalse\displaylefttoright \setfalse\inlinelefttoright \textdir TRT\relax \pardir TRT\relax} -\unexpanded\def\righttoleft_hmode +\unexpanded\def\spac_directions_righttoleft_hmode {\textdir TRT\relax \setfalse\inlinelefttoright} @@ -103,24 +104,24 @@ \unexpanded\def\synchronizelayoutdirection {\ifconditional\layoutlefttoright - \synchronizedirection_lr + \spac_directions_synchronize_lr \else - \synchronizedirection_rl + \spac_directions_synchronize_rl \fi} \unexpanded\def\synchronizedisplaydirection {\ifconditional\displaylefttoright - \synchronizedirection_lr + \spac_directions_synchronize_lr \else - \synchronizedirection_rl + \spac_directions_synchronize_rl \fi} -\def\synchronizedirection_lr +\def\spac_directions_synchronize_lr {\settrue\inlinelefttoright \textdir TLT\relax \pardir TLT\relax} -\def\synchronizedirection_rl +\def\spac_directions_synchronize_rl {\setfalse\inlinelefttoright \textdir TRT\relax \pardir TRT\relax} @@ -165,22 +166,23 @@ \let\dohyphens\relax -\newcount\c_spacing_minimum_tolerance \c_spacing_minimum_tolerance = 1500 -\newcount\c_spacing_normal_tolerance \c_spacing_normal_tolerance = 3000 -\newcount\c_spacing_extreme_tolerance \c_spacing_extreme_tolerance = 4500 +\newconstant\c_spac_tolerance_default \c_spac_tolerance_default = 1500 % shouldn't that be 200 +\newconstant\c_spac_tolerance_minimum \c_spac_tolerance_minimum = 1500 +\newconstant\c_spac_tolerance_normal \c_spac_tolerance_normal = 3000 +\newconstant\c_spac_tolerance_extreme \c_spac_tolerance_extreme = 4500 -\def\spacing_raggedness_left {\plustwo\bodyfontsize} -\def\spacing_raggedness_right {\plustwo\bodyfontsize} -\def\spacing_raggedness_middle{\plussix\bodyfontsize} % overloaded below +\def\spac_align_set_raggedness_left {\plustwo\bodyfontsize} +\def\spac_align_set_raggedness_right {\plustwo\bodyfontsize} +\def\spac_align_set_raggedness_middle{\plussix\bodyfontsize} % overloaded below % oeps, hsize can be 0pt in which case we get a strange division % was: 6\bodyfontsize, fails on: \placefigure{x $x=x$ x}{} -\def\spacing_raggedness_middle{\ifdim\hsize=\zeropoint\plussix\bodyfontsize\else.5\hsize\fi} +\def\spac_align_set_raggedness_middle{\ifdim\hsize=\zeropoint\plussix\bodyfontsize\else.5\hsize\fi} \unexpanded\def\setraggedness#1% tricky .. we keep the global tolerance otherwise ... to be reconsidered - {\ifnum\tolerance<\c_spacing_minimum_tolerance - \tolerance\c_spacing_minimum_tolerance % small values have unwanted side effects + {\ifnum\tolerance<\c_spac_tolerance_minimum + \tolerance\c_spac_tolerance_minimum % small values have unwanted side effects \else % todo: take set value or none .. better done elsewhere (200 is normal) \fi @@ -188,44 +190,44 @@ \hyphenpenalty\dimexpr2.8\hsize/\dimexpr#1\relax\relax % 50 in raggedright/raggedleft \fi} -\unexpanded\def\ragged_command_tolerant - {\tolerance\c_spacing_normal_tolerance} +\unexpanded\def\spac_align_set_tolerant + {\tolerance\c_spac_tolerance_normal} -\unexpanded\def\ragged_command_very_tolerant - {\tolerance\c_spacing_extreme_tolerance} +\unexpanded\def\spac_align_set_very_tolerant + {\tolerance\c_spac_tolerance_extreme} -\unexpanded\def\ragged_command_stretch +\unexpanded\def\spac_align_set_stretch {\emergencystretch\bodyfontsize} % Vertical -\newconstant\c_spacing_state_vertical +\newconstant\c_spac_align_state_vertical -\unexpanded\def\spacing_vertical_none +\unexpanded\def\spac_align_set_vertical_none {\let\raggedtopcommand \relax \let\raggedbottomcommand\relax} -\unexpanded\def\spacing_vertical_lohi +\unexpanded\def\spac_align_set_vertical_lohi {\let\raggedtopcommand \vfilll \let\raggedbottomcommand\vfilll} -\unexpanded\def\spacing_vertical_low +\unexpanded\def\spac_align_set_vertical_low {\let\raggedtopcommand \vfilll \let\raggedbottomcommand\relax} -\unexpanded\def\spacing_vertical_high +\unexpanded\def\spac_align_set_vertical_high {\let\raggedtopcommand \relax \let\raggedbottomcommand\vfilll} -\def\spacing_flush_vertical - {\ifcase\c_spacing_state_vertical - \spacing_vertical_none +\def\spac_align_flush_vertical + {\ifcase\c_spac_align_state_vertical + \spac_align_set_vertical_none \or - \spacing_vertical_lohi + \spac_align_set_vertical_lohi \or - \spacing_vertical_low + \spac_align_set_vertical_low \or - \spacing_vertical_high + \spac_align_set_vertical_high \fi} % Horizontal @@ -236,193 +238,194 @@ \newconstant\raggedstatus % public -\newconstant\c_spacing_state_horizontal -\newconstant\c_spacing_state_broad +\newconstant\c_spac_align_state_horizontal +\newconstant\c_spac_align_state_broad -\def\spacing_ragged_fill_amount {\plusone fil} -\def\spacing_ragged_fill_amount_negative {\minusone fil} -\def\spacing_ragged_fill_amount_double {\plustwo fil} -\def\spacing_ragged_fill_amount_space {\plustwo fil} % can be added to xspace if we have a key -\def\spacing_ragged_fill_amount_half {.5fil} -\let\spacing_ragged_space_amount \interwordspace -\def\spacing_ragged_space_amount_x {.5\emwidth} +\def\v_spac_align_fill_amount {\plusone fil} +\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 +\def\v_spac_align_fill_amount_half {.5fil} +\let\v_spac_align_space_amount \interwordspace +\def\v_spac_align_space_amount_x {.5\emwidth} \newskip\s_zero_plus_one_fil \s_zero_plus_one_fil = 0pt plus 1fil \newskip\s_zero_plus_zero \s_zero_plus_zero = 0pt plus 0pt % \!!plus ... slower than inline -\unexpanded\def\spacing_horizontal_none +\unexpanded\def\spac_align_set_horizontal_none % should also relax \updateraggedskips {\raggedstatus\zerocount \attribute\alignstateattribute\attributeunsetvalue \leftskip \plusone\leftskip \rightskip \plusone\rightskip \spaceskip \zeropoint \xspaceskip \zeropoint - \parfillskip\s_zero_plus_one_fil} % new + \parfillskip\s_zero_plus_one_fil % new + \let\updateraggedskips\relax} % no need for adaption -\unexpanded\def\spacing_horizontal_left - {\setraggedness\spacing_raggedness_left +\unexpanded\def\spac_align_set_horizontal_left + {\setraggedness\spac_align_set_raggedness_left \raggedstatus\plusone \attribute\alignstateattribute\plusone - \leftskip \plusone\leftskip \!!plus\spacing_raggedness_left + \leftskip \plusone\leftskip \!!plus\spac_align_set_raggedness_left \rightskip \plusone\rightskip\!!plus\zeropoint - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_center - {\setraggedness\spacing_raggedness_middle +\unexpanded\def\spac_align_set_horizontal_center + {\setraggedness\spac_align_set_raggedness_middle \raggedstatus\plustwo \attribute\alignstateattribute\plustwo - \leftskip \plusone\leftskip \!!plus\spacing_raggedness_middle - \rightskip \plusone\rightskip\!!plus\spacing_raggedness_middle - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \leftskip \plusone\leftskip \!!plus\spac_align_set_raggedness_middle + \rightskip \plusone\rightskip\!!plus\spac_align_set_raggedness_middle + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_right - {\setraggedness\spacing_raggedness_right +\unexpanded\def\spac_align_set_horizontal_right + {\setraggedness\spac_align_set_raggedness_right \raggedstatus\plusthree \attribute\alignstateattribute\plusthree \leftskip \plusone\leftskip \!!plus\zeropoint - \rightskip \plusone\rightskip\!!plus\spacing_raggedness_right - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \rightskip \plusone\rightskip\!!plus\spac_align_set_raggedness_right + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_one_fil %\parindent \parindent \relax} -\unexpanded\def\spacing_horizontal_very_left +\unexpanded\def\spac_align_set_horizontal_very_left {\raggedstatus\plusone \attribute\alignstateattribute\plusone - \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount + \leftskip \plusone\leftskip \!!plus\v_spac_align_fill_amount \rightskip \plusone\rightskip\!!plus\zeropoint - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_very_center +\unexpanded\def\spac_align_set_horizontal_very_center {\raggedstatus\plustwo \attribute\alignstateattribute\plustwo - \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount - \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \leftskip \plusone\leftskip \!!plus\v_spac_align_fill_amount + \rightskip \plusone\rightskip\!!plus\v_spac_align_fill_amount + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_very_right +\unexpanded\def\spac_align_set_horizontal_very_right {\raggedstatus\plusthree \attribute\alignstateattribute\plusthree \leftskip \plusone\leftskip \!!plus\zeropoint - \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \rightskip \plusone\rightskip\!!plus\v_spac_align_fill_amount + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero %\parindent \parindent \relax} -\unexpanded\def\spacing_horizontal_wide_center - {\setraggedness\spacing_raggedness_middle +\unexpanded\def\spac_align_set_horizontal_wide_center + {\setraggedness\spac_align_set_raggedness_middle \raggedstatus\plustwo \attribute\alignstateattribute\plustwo - \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount_half - \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount_half - \spaceskip \spacing_ragged_space_amount - \xspaceskip \spacing_ragged_space_amount_x + \leftskip \plusone\leftskip \!!plus\v_spac_align_fill_amount_half + \rightskip \plusone\rightskip\!!plus\v_spac_align_fill_amount_half + \spaceskip \v_spac_align_space_amount + \xspaceskip \v_spac_align_space_amount_x \parfillskip\s_zero_plus_zero \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_centered_last_line +\unexpanded\def\spac_align_set_horizontal_centered_last_line {\raggedstatus\zerocount \attribute\alignstateattribute\attributeunsetvalue - \leftskip \plusone\leftskip \!!plus\spacing_ragged_fill_amount\relax - \rightskip \plusone\rightskip\!!plus\spacing_ragged_fill_amount_negative\relax + \leftskip \plusone\leftskip \!!plus\v_spac_align_fill_amount\relax + \rightskip \plusone\rightskip\!!plus\v_spac_align_fill_amount_negative\relax \spaceskip \zeropoint\relax \xspaceskip \zeropoint\relax - \parfillskip\zeropoint\!!plus\spacing_ragged_fill_amount_double\relax + \parfillskip\zeropoint\!!plus\v_spac_align_fill_amount_double\relax \parindent \zeropoint \relax} -\unexpanded\def\spacing_horizontal_right_tt % a plain command +\unexpanded\def\spac_align_set_horizontal_right_tt % a plain command {\tttf % brrr \raggedstatus\plusthree \attribute\alignstateattribute\plusthree \leftskip \plusone\leftskip \!!plus\zeropoint\relax - \rightskip \plusone\rightskip\!!plus\spacing_raggedness_right\relax + \rightskip \plusone\rightskip\!!plus\spac_align_set_raggedness_right\relax \spaceskip \zeropoint\relax \xspaceskip \zeropoint\relax \parfillskip\s_zero_plus_zero %\parindent \parindent \relax} -\unexpanded\def\spacing_horizontal_extra - {\xspaceskip\zeropoint\!!plus\spacing_ragged_fill_amount_space\relax} +\unexpanded\def\spac_align_set_horizontal_extra + {\xspaceskip\zeropoint\!!plus\v_spac_align_fill_amount_space\relax} -\def\spacing_flush_horizontal - {\ifcase\c_spacing_state_horizontal +\def\spac_align_flush_horizontal + {\ifcase\c_spac_align_state_horizontal % 0 - \spacing_horizontal_none + \spac_align_set_horizontal_none \or % 1 center - \ifcase\c_spacing_state_broad - \spacing_horizontal_center + \ifcase\c_spac_align_state_broad + \spac_align_set_horizontal_center \or - \spacing_horizontal_very_center + \spac_align_set_horizontal_very_center \or - \spacing_horizontal_wide_center + \spac_align_set_horizontal_wide_center \fi \or % 2 flush left - \ifcase\c_spacing_state_broad - \spacing_horizontal_right + \ifcase\c_spac_align_state_broad + \spac_align_set_horizontal_right \else - \spacing_horizontal_very_right + \spac_align_set_horizontal_very_right \fi \or % 3 flush right - \ifcase\c_spacing_state_broad - \spacing_horizontal_left + \ifcase\c_spac_align_state_broad + \spac_align_set_horizontal_left \else - \spacing_horizontal_very_left + \spac_align_set_horizontal_very_left \fi \or % 4 inner \ifdoublesided \signalinnerrealign \fi - \rightorleftpageaction\spacing_horizontal_right\spacing_horizontal_left + \rightorleftpageaction\spac_align_set_horizontal_right\spac_align_set_horizontal_left \or % 5 outer \ifdoublesided \signalouterrealign \fi - \rightorleftpageaction\c_spacing_state_horizontal_left\spacing_horizontal_right + \rightorleftpageaction\c_spac_align_state_horizontal_left\spac_align_set_horizontal_right \or % 6 oneliner - \ifcase\c_spacing_state_broad - \spacing_horizontal_right + \ifcase\c_spac_align_state_broad + \spac_align_set_horizontal_right \else - \spacing_horizontal_very_right + \spac_align_set_horizontal_very_right \fi \parfillskip\zeropoint \or % 7 centered last line - \spacing_horizontal_centered_last_line + \spac_align_set_horizontal_centered_last_line \fi} % Page spacing: -\newconstant\c_spacing_state_page +\newconstant\c_spac_align_state_page \def\bottomalignlimit{\plusthree\lineheight} @@ -446,8 +449,8 @@ {\bottomraggednessmode#1% \settopskip} -\def\spacing_flush_page - {\ifcase\c_spacing_state_page +\def\spac_align_flush_page + {\ifcase\c_spac_align_state_page % keep state \or \raggedbottom @@ -459,10 +462,10 @@ % Directions -\newconstant\c_spacing_state_direction +\newconstant\c_spac_align_state_direction -\def\spacing_flush_direction - {\ifcase\c_spacing_state_direction +\def\spac_align_flush_direction + {\ifcase\c_spac_align_state_direction % keep state \or \lefttoright @@ -474,192 +477,150 @@ % and as we cache we seldom call that one now so one can debate the % speedup. -\newtoks\t_spacing_set_alignment +\newtoks\t_spac_align_collected \let\raggedcommand \relax \let\updateraggedskips\relax -% \unexpanded\def\spacing_set_text_align#1% beware: #1=empty is ignored, keep that! assumes \forgetall ... needs checking -% {\edef\askedraggedalign{#1}% -% \ifx\askedraggedalign\empty -% \spacing_set_text_align_nop -% \else -% \spacing_set_text_align_yes -% \fi} - -% \def\spacing_set_text_align_nop % as we cache (empty) anyway, this one can go -% {%\let\raggedtopcommand \relax -% %\let\raggedbottomcommand\relax -% \let\raggedbox \relax % why -% \t_spacing_set_alignment -% {\resetrealignsignal -% \setfalse\raggedonelinerstate -% \let\raggedtopcommand \relax -% \let\raggedbottomcommand\relax}} - -% \def\spacing_set_text_align_yes % hm, we could hash settings ! nice experiment -% {%\let\raggedtopcommand\empty -% %\let\raggedbottomcommand\empty -% \let\raggedbox\relax % why -% % we inherit hyphenation and tolerance -% \t_spacing_set_alignment \emptytoks -% \c_spacing_state_broad \zerocount -% \c_spacing_state_horizontal\zerocount -% \c_spacing_state_vertical \zerocount -% \c_spacing_state_direction \zerocount % what is default ? -% \c_spacing_state_page \zerocount -% \ifcsname\??aligncommand\askedraggedalign\endcsname -% \csname\??aligncommand\askedraggedalign\endcsname -% \else -% \rawprocesscommacommand[\askedraggedalign]\spacing_set_text_align_collect -% \fi -% \normalexpanded{\t_spacing_set_alignment -% {\resetrealignsignal % can go as it is alway set -% \setfalse\raggedonelinerstate % bad -% \the\t_spacing_set_alignment -% \spacing_flush_horizontal -% \spacing_flush_vertical -% \spacing_flush_direction -% \spacing_flush_page -% }}} % kept - -\unexpanded\def\spacing_set_text_align#1% what to do with empty (and forgetall) +\def\spac_align_add_to_cache#1% {\edef\askedraggedalign{#1}% \let\raggedbox\relax % why % we inherit hyphenation and tolerance - \t_spacing_set_alignment \emptytoks - \c_spacing_state_broad \zerocount - \c_spacing_state_horizontal\zerocount - \c_spacing_state_vertical \zerocount - \c_spacing_state_direction \zerocount % what is default ? - \c_spacing_state_page \zerocount + \t_spac_align_collected \emptytoks + \c_spac_align_state_broad \zerocount + \c_spac_align_state_horizontal\zerocount + \c_spac_align_state_vertical \zerocount + \c_spac_align_state_direction \zerocount % what is default ? + \c_spac_align_state_page \zerocount \ifcsname\??aligncommand\askedraggedalign\endcsname \csname\??aligncommand\askedraggedalign\endcsname % not much gain in new method \else - \rawprocesscommacommand[\askedraggedalign]\spacing_set_text_align_collect + \rawprocesscommacommand[\askedraggedalign]\spac_align_collect \fi - \normalexpanded{\t_spacing_set_alignment - {\resetrealignsignal % can go as it is alway set + \normalexpanded{\t_spac_align_collected + {% \resetrealignsignal % can go as it is alway set \setfalse\raggedonelinerstate % bad - \the\t_spacing_set_alignment - \spacing_flush_horizontal - \spacing_flush_vertical - \spacing_flush_direction - \spacing_flush_page - }}} % kept - -\def\spacing_set_text_align_collect#1% + \the\t_spac_align_collected + \spac_align_flush_horizontal + \spac_align_flush_vertical + \spac_align_flush_direction + \spac_align_flush_page + }}% kept, nice for tracing + \edef\raggedcommand {\the\t_spac_align_collected }% + \edef\updateraggedskips{\spac_align_flush_horizontal}% + \global\expandafter\let\csname\??alignmentnormalcache#1\endcsname\raggedcommand + \global\expandafter\let\csname\??alignmentraggedcache#1\endcsname\updateraggedskips} + +\def\spac_align_collect#1% {\csname\??aligncommand#1\endcsname} -\def\spacing_alignment_add_to_cache#1% - {\spacing_set_text_align{#1} - \edef\raggedcommand{\the\t_spacing_set_alignment}% - \global\expandafter\let\csname\??alignmentcache#1\endcsname\raggedcommand} +% The local (key driven) setter: + +\unexpanded\def\spac_align_prepare#1% deferred + {\expandafter\let\expandafter\raggedcommand\csname\??alignmentnormalcache#1\endcsname + \ifx\raggedcommand\relax + \spac_align_add_to_cache{#1}% + \else + \expandafter\let\expandafter\updateraggedskips\csname\??alignmentraggedcache#1\endcsname + \fi} + +\let\dosetraggedcommand\spac_align_prepare % sort of public % The regular align setter: \unexpanded\def\setupalign - {\dosingleempty\spacing_setup_align} + {\dosingleempty\spac_align_setup} -\def\spacing_setup_align[#1]% immediate - {\expandafter\let\expandafter\raggedcommand\csname\??alignmentcache#1\endcsname +\def\spac_align_setup[#1]% immediate + {\expandafter\let\expandafter\raggedcommand\csname\??alignmentnormalcache#1\endcsname \ifx\raggedcommand\relax - \spacing_alignment_add_to_cache{#1}% + \spac_align_add_to_cache{#1}% + \else + \expandafter\let\expandafter\updateraggedskips\csname\??alignmentraggedcache#1\endcsname \fi - \let\updateraggedskips\raggedcommand \raggedcommand} -% the local (key driven) setter: - -\unexpanded\def\spacing_setup_aligned#1% deferred - {\expandafter\let\expandafter\raggedcommand\csname\??alignmentcache#1\endcsname - \ifx\raggedcommand\relax - \spacing_alignment_add_to_cache{#1}% - \fi - \let\updateraggedskips\raggedcommand} - -\let\dosetraggedcommand\spacing_setup_aligned % sort of public - % The keywords: \unexpanded\def\installalign#1#2% beware: commands must be unexpandable! {\ifcsname\??aligncommand#1\endcsname \else - \setvalue{\??aligncommand#1}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment#2}}% + \setvalue{\??aligncommand#1}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected#2}}% \fi} \letvalue{\??aligncommand\empty }\empty -\setvalue{\??aligncommand\v!broad }{\c_spacing_state_broad \plusone } -\setvalue{\??aligncommand\v!wide }{\c_spacing_state_broad \plustwo } +\setvalue{\??aligncommand\v!broad }{\c_spac_align_state_broad \plusone } +\setvalue{\??aligncommand\v!wide }{\c_spac_align_state_broad \plustwo } -\setvalue{\??aligncommand\v!bottom }{\c_spacing_state_page \plusone } -\setvalue{\??aligncommand\v!height }{\c_spacing_state_page \plustwo } -\setvalue{\??aligncommand\v!line }{\c_spacing_state_page \plusthree +\setvalue{\??aligncommand\v!bottom }{\c_spac_align_state_page \plusone } +\setvalue{\??aligncommand\v!height }{\c_spac_align_state_page \plustwo } +\setvalue{\??aligncommand\v!line }{\c_spac_align_state_page \plusthree % this will become another keyword (undocumented anyway) - \t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\settrue\raggedonelinerstate}} - -\setvalue{\??aligncommand\v!high }{\c_spacing_state_vertical \plusthree} -\setvalue{\??aligncommand\v!low }{\c_spacing_state_vertical \plustwo } -\setvalue{\??aligncommand\v!lohi }{\c_spacing_state_vertical \plusone } - -\setvalue{\??aligncommand\v!flushright }{\c_spacing_state_horizontal\plusthree} -\setvalue{\??aligncommand\v!flushleft }{\c_spacing_state_horizontal\plustwo } -\setvalue{\??aligncommand\v!middle }{\c_spacing_state_horizontal\plusone } -\setvalue{\??aligncommand\v!no }{\c_spacing_state_horizontal\plustwo } -\setvalue{\??aligncommand\v!yes }{\c_spacing_state_horizontal\zerocount} -\setvalue{\??aligncommand\v!width }{\c_spacing_state_horizontal\zerocount} -\setvalue{\??aligncommand\v!normal }{\c_spacing_state_horizontal\zerocount} -\setvalue{\??aligncommand\v!reset }{\c_spacing_state_page \zerocount - \c_spacing_state_horizontal\zerocount} -\setvalue{\??aligncommand\v!inner }{\c_spacing_state_horizontal\plusfour } -\setvalue{\??aligncommand\v!outer }{\c_spacing_state_horizontal\plusfive } -\setvalue{\??aligncommand\v!flushinner }{\c_spacing_state_horizontal\plusfive } -\setvalue{\??aligncommand\v!flushouter }{\c_spacing_state_horizontal\plusfour } -\setvalue{\??aligncommand\v!right }{\c_spacing_state_horizontal\plustwo } -\setvalue{\??aligncommand\v!left }{\c_spacing_state_horizontal\plusthree} -\setvalue{\??aligncommand\v!center }{\c_spacing_state_horizontal\plusone - \c_spacing_state_broad \plustwo } -\setvalue{\??aligncommand\v!disable }{\c_spacing_state_horizontal\plussix } -\setvalue{\??aligncommand\v!last }{\c_spacing_state_horizontal\plusseven} - - -\setvalue{\??aligncommand\v!lefttoright }{\c_spacing_state_direction \plusone } -\setvalue{\??aligncommand\v!righttoleft }{\c_spacing_state_direction \plustwo } -\setvalue{\??aligncommand l2r}{\c_spacing_state_direction \plusone } -\setvalue{\??aligncommand r2l}{\c_spacing_state_direction \plustwo } - -\setvalue{\??aligncommand\v!table }{\c_spacing_state_vertical \plusthree - \c_spacing_state_broad \plusone - \c_spacing_state_horizontal\plustwo } - -\setvalue{\??aligncommand\v!lesshyphenation}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\lesshyphens}} -\setvalue{\??aligncommand\v!morehyphenation}{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\morehyphens}} - -\setvalue{\??aligncommand\v!hanging }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_protruding_enable }} -\setvalue{\??aligncommand\v!nothanging }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_protruding_disable}} -\setvalue{\??aligncommand\v!hz }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_expansion_enable }} -\setvalue{\??aligncommand\v!nohz }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\fonts_expansion_disable }} -\setvalue{\??aligncommand\v!spacing }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\enablespacehandling \enablekernhandling }} -\setvalue{\??aligncommand\v!nospacing }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\disablespacehandling\disablekernhandling}} -\setvalue{\??aligncommand\v!hyphenated }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\dohyphens}} -\setvalue{\??aligncommand\v!nothyphenated }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\nohyphens}} - -\setvalue{\??aligncommand\v!tolerant }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_tolerant}} -\setvalue{\??aligncommand\v!verytolerant }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_very_tolerant}} -\setvalue{\??aligncommand\v!stretch }{\t_spacing_set_alignment\expandafter{\the\t_spacing_set_alignment\ragged_command_stretch}} + \t_spac_align_collected\expandafter{\the\t_spac_align_collected\settrue\raggedonelinerstate}} + +\setvalue{\??aligncommand\v!high }{\c_spac_align_state_vertical \plusthree} +\setvalue{\??aligncommand\v!low }{\c_spac_align_state_vertical \plustwo } +\setvalue{\??aligncommand\v!lohi }{\c_spac_align_state_vertical \plusone } + +\setvalue{\??aligncommand\v!flushright }{\c_spac_align_state_horizontal\plusthree} +\setvalue{\??aligncommand\v!flushleft }{\c_spac_align_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!middle }{\c_spac_align_state_horizontal\plusone } +\setvalue{\??aligncommand\v!no }{\c_spac_align_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!yes }{\c_spac_align_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!width }{\c_spac_align_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!normal }{\c_spac_align_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!reset }{\c_spac_align_state_page \zerocount + \c_spac_align_state_horizontal\zerocount} +\setvalue{\??aligncommand\v!inner }{\c_spac_align_state_horizontal\plusfour } +\setvalue{\??aligncommand\v!outer }{\c_spac_align_state_horizontal\plusfive } +\setvalue{\??aligncommand\v!flushinner }{\c_spac_align_state_horizontal\plusfive } +\setvalue{\??aligncommand\v!flushouter }{\c_spac_align_state_horizontal\plusfour } +\setvalue{\??aligncommand\v!right }{\c_spac_align_state_horizontal\plustwo } +\setvalue{\??aligncommand\v!left }{\c_spac_align_state_horizontal\plusthree} +\setvalue{\??aligncommand\v!center }{\c_spac_align_state_horizontal\plusone + \c_spac_align_state_broad \plustwo } +\setvalue{\??aligncommand\v!disable }{\c_spac_align_state_horizontal\plussix } +\setvalue{\??aligncommand\v!last }{\c_spac_align_state_horizontal\plusseven} + + +\setvalue{\??aligncommand\v!lefttoright }{\c_spac_align_state_direction \plusone } +\setvalue{\??aligncommand\v!righttoleft }{\c_spac_align_state_direction \plustwo } +\setvalue{\??aligncommand l2r}{\c_spac_align_state_direction \plusone } +\setvalue{\??aligncommand r2l}{\c_spac_align_state_direction \plustwo } + +\setvalue{\??aligncommand\v!table }{\c_spac_align_state_vertical \plusthree + \c_spac_align_state_broad \plusone + \c_spac_align_state_horizontal\plustwo } + +\setvalue{\??aligncommand\v!lesshyphenation}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\lesshyphens}} +\setvalue{\??aligncommand\v!morehyphenation}{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\morehyphens}} + +\setvalue{\??aligncommand\v!hanging }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_protruding_enable }} +\setvalue{\??aligncommand\v!nothanging }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_protruding_disable}} +\setvalue{\??aligncommand\v!hz }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_expansion_enable }} +\setvalue{\??aligncommand\v!nohz }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\font_expansion_disable }} +\setvalue{\??aligncommand\v!spacing }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\enablespacehandling \enablekernhandling }} +\setvalue{\??aligncommand\v!nospacing }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\disablespacehandling\disablekernhandling}} +\setvalue{\??aligncommand\v!hyphenated }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\dohyphens}} +\setvalue{\??aligncommand\v!nothyphenated }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\nohyphens}} + +\setvalue{\??aligncommand\v!tolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_tolerant}} +\setvalue{\??aligncommand\v!verytolerant }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_very_tolerant}} +\setvalue{\??aligncommand\v!stretch }{\t_spac_align_collected\expandafter{\the\t_spac_align_collected\spac_align_set_stretch}} % Visible commands: -\let\notragged \spacing_horizontal_none -\let\forgetragged \spacing_horizontal_none -\let\raggedleft \spacing_horizontal_left -\let\raggedcenter \spacing_horizontal_center -\let\raggedright \spacing_horizontal_right -\let\veryraggedleft \spacing_horizontal_very_left -\let\veryraggedcenter\spacing_horizontal_very_center -\let\veryraggedright \spacing_horizontal_very_right -\let\raggedwidecenter\spacing_horizontal_wide_center -\let\centeredlastline\spacing_horizontal_centered_last_line -\let\ttraggedright \spacing_horizontal_right_tt % a plain command +\let\notragged \spac_align_set_horizontal_none +\let\raggedleft \spac_align_set_horizontal_left +\let\raggedcenter \spac_align_set_horizontal_center +\let\raggedright \spac_align_set_horizontal_right +\let\veryraggedleft \spac_align_set_horizontal_very_left +\let\veryraggedcenter\spac_align_set_horizontal_very_center +\let\veryraggedright \spac_align_set_horizontal_very_right +\let\raggedwidecenter\spac_align_set_horizontal_wide_center +\let\centeredlastline\spac_align_set_horizontal_centered_last_line +\let\ttraggedright \spac_align_set_horizontal_right_tt % a plain command + +\let\forgetragged \spac_align_set_horizontal_none % Box commands. @@ -668,7 +629,7 @@ \forgetall \let\\=\endgraf \ifdoublesided\signalinnerrealign\fi - \doifrightpageelse\spacing_horizontal_right\spacing_horizontal_left + \doifrightpageelse\spac_align_set_horizontal_right\spac_align_set_horizontal_left \let\next} \unexpanded\def\obox#1#2#3% @@ -676,26 +637,26 @@ \forgetall \let\\=\endgraf \ifdoublesided\signalouterrealign\fi - \doifrightpageelse\c_spacing_state_horizontal_left\spacing_horizontal_right + \doifrightpageelse\c_spac_align_state_horizontal_left\spac_align_set_horizontal_right \let\next} \let\raggedbox\relax \def\dosetraggedvbox#1% can be more keys {\let\raggedbox\vbox - \processcommacommand[#1]\dodosetraggedvbox} + \processcommacommand[#1]\spac_align_set_ragged_box} \def\dosetraggedhbox#1% can be more keys {\let\raggedbox\hbox - \processcommacommand[#1]\dodosetraggedhbox} + \processcommacommand[#1]\spac_align_set_ragged_hbox} -\def\dodosetraggedvbox#1% +\def\spac_align_set_ragged_box#1% {\ifcsname\??alignvertical#1\endcsname \csname\??alignvertical#1\endcsname \quitcommalist \fi} -\def\dodosetraggedhbox#1% +\def\spac_align_set_ragged_hbox#1% {\ifcsname\??alignhorizontal#1\endcsname \csname\??alignhorizontal#1\endcsname \quitcommalist @@ -709,7 +670,7 @@ \setvalue{\??alignvertical \v!flushleft }{\let\raggedbox\rbox} \setvalue{\??alignvertical \v!flushright}{\let\raggedbox\lbox} \setvalue{\??alignvertical \v!center }{\let\raggedbox\cbox} -\setvalue{\??alignvertical \v!no }{\def\raggedbox{\vbox\bgroup\spacing_horizontal_right\let\next=}]} +\setvalue{\??alignvertical \v!no }{\def\raggedbox{\vbox\bgroup\spac_align_set_horizontal_right\let\next=}]} % maybe \let's @@ -746,16 +707,16 @@ % tracing: -\def\spacing_show_par_data#1% +\def\spac_show_par_data#1% {\ifx#1\relax\else \hbox{\string#1: \the#1}\endgraf - \expandafter\spacing_show_par_data + \expandafter\spac_show_par_data \fi} \unexpanded\def\showpardata {\edef\thepardata {\hbox{font: \fontname\font}\endgraf - \spacing_show_par_data + \spac_show_par_data \interwordspace \interwordstretch \interwordshrink \emwidth \exheight \extraspace \hsize \vsize \leftskip \rightskip @@ -898,9 +859,9 @@ % so, no funny boxing here \unexpanded\def\wordright - {\dosingleempty\spacing_word_right} + {\dosingleempty\spac_word_right} -\def\spacing_word_right[#1]% +\def\spac_word_right[#1]% {% don't change \groupedcommand {\removeunwantedspaces @@ -962,25 +923,3 @@ {\dodoubleargument\dodefinehbox} \protect \endinput - -% \newskip\@@raggedskipa -% \newskip\@@raggedskipb -% -% \newcount\c_spacing_minimum_tolerance \c_spacing_minimum_tolerance = 1500 -% -% \unexpanded\def\setraggedness#1% -% {\ifnum\tolerance<\c_spacing_minimum_tolerance % small values have -% \tolerance\c_spacing_minimum_tolerance % unwanted side effects -% \fi -% \ifx\dohyphens\relax -% % this code will be reconsidered / kind of fuzzy (and old) -% \@@raggedskipa 2.5\hsize -% \@@raggedskipb #1\relax -% \divide\@@raggedskipa \@@raggedskipb -% \hyphenpenalty\@@raggedskipa -% \fi} - -% \installalign \v!inner {\setraggedparagraphmode\spacing_align_rl\spacing_align_rr} -% \installalign \v!outer {\setraggedparagraphmode\spacing_align_rr\spacing_align_rl} -% \installalign \v!flushouter {\setraggedparagraphmode\spacing_horizontal_left \spacing_horizontal_right} -% \installalign \v!flushinner {\setraggedparagraphmode\spacing_horizontal_right\spacing_horizontal_left } |