summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3box.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3box.dtx295
1 files changed, 212 insertions, 83 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
index 6dc66cd9c85..ff71f36659d 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3box.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3box.dtx 2896 2011-10-09 20:36:50Z joseph $
+\GetIdInfo$Id: l3box.dtx 2960 2011-11-15 08:50:21Z joseph $
{L3 Experimental boxes}
%</driver|package>
%<*driver>
@@ -212,45 +212,40 @@
%
% \section{Measuring and setting box dimensions}
%
-% \begin{function}[EXP]{\box_dp:N, \box_dp:c}
+% \begin{function}{\box_dp:N, \box_dp:c}
% \begin{syntax}
% \cs{box_dp:N} \meta{box}
% \end{syntax}
% Calculates the depth (below the baseline) of the \meta{box}
-% and leaves this in the input stream. The output of this function
-% is suitable for use in a \meta{dimension expression} for
-% calculations.
+% in a form suitable for use in a \meta{dimension expression}.
% \begin{texnote}
% This is the \TeX{} primitive \tn{dp}.
% \end{texnote}
% \end{function}
%
-% \begin{function}[EXP]{\box_ht:N, \box_ht:c}
+% \begin{function}{\box_ht:N, \box_ht:c}
% \begin{syntax}
% \cs{box_ht:N} \meta{box}
% \end{syntax}
% Calculates the height (above the baseline) of the \meta{box}
-% and leaves this in the input stream. The output of this function
-% is suitable for use in a \meta{dimension expression} for
-% calculations.
+% in a form suitable for use in a \meta{dimension expression}.
% \begin{texnote}
% This is the \TeX{} primitive \tn{ht}.
% \end{texnote}
% \end{function}
%
-% \begin{function}[EXP]{\box_wd:N, \box_wd:c}
+% \begin{function}{\box_wd:N, \box_wd:c}
% \begin{syntax}
% \cs{box_wd:N} \meta{box}
% \end{syntax}
-% Calculates the width of the \meta{box} and leaves this in the
-% input stream. The output of this function is suitable for use in a
-% \meta{dimension expression} for calculations.
+% Calculates the width of the \meta{box} in a form
+% suitable for use in a \meta{dimension expression}.
% \begin{texnote}
% This is the \TeX{} primitive \tn{wd}.
% \end{texnote}
% \end{function}
%
-% \begin{function}{\box_set_dp:Nn, \box_set_dp:cn}
+% \begin{function}[updated = 2011-10-22]{\box_set_dp:Nn, \box_set_dp:cn}
% \begin{syntax}
% \cs{box_set_dp:Nn} \meta{box} \Arg{dimension expression}
% \end{syntax}
@@ -258,7 +253,7 @@
% the \Arg{dimension expression}. This is a global assignment.
% \end{function}
%
-% \begin{function}{\box_set_ht:Nn, \box_set_ht:cn}
+% \begin{function}[updated = 2011-10-22]{\box_set_ht:Nn, \box_set_ht:cn}
% \begin{syntax}
% \cs{box_set_ht:Nn} \meta{box} \Arg{dimension expression}
% \end{syntax}
@@ -266,7 +261,7 @@
% the \Arg{dimension expression}. This is a global assignment.
% \end{function}
%
-% \begin{function}{\box_set_wd:Nn, \box_set_wd:cn}
+% \begin{function}[updated = 2011-10-22]{\box_set_wd:Nn, \box_set_wd:cn}
% \begin{syntax}
% \cs{box_set_wd:Nn} \meta{box} \Arg{dimension expression}
% \end{syntax}
@@ -298,10 +293,10 @@
% \textbf{This function is experimental}
% \end{function}
%
-% \begin{function}[added = 2011-09-02]
+% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
% {\box_resize_to_ht_plus_dp:Nn, \box_resize_to_ht_plus_dp:cn}
% \begin{syntax}
-% \cs{box_resize_to_ht_plus_dp:Nnn} \meta{box} \Arg{y-size}
+% \cs{box_resize_to_ht_plus_dp:Nn} \meta{box} \Arg{y-size}
% \end{syntax}
% Resize the \meta{box} to \meta{y-size} vertically, scaling the horizontal
% size by the same amount (\meta{y-size} is a dimension expression).
@@ -316,7 +311,7 @@
% \textbf{This function is experimental}
% \end{function}
%
-% \begin{function}[added = 2011-09-02]
+% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
% {\box_resize_to_wd:Nn, \box_resize_to_wd:cn}
% \begin{syntax}
% \cs{box_resize_to_wd:Nnn} \meta{box} \Arg{x-size}
@@ -332,7 +327,8 @@
% \textbf{This function is experimental}
% \end{function}
%
-% \begin{function}[added = 2011-09-02]{\box_rotate:Nn, \box_rotate:cn}
+% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
+% {\box_rotate:Nn, \box_rotate:cn}
% \begin{syntax}
% \cs{box_rotate:Nn} \meta{box} \Arg{angle}
% \end{syntax}
@@ -347,7 +343,8 @@
% \textbf{This function is experimental}
% \end{function}
%
-% \begin{function}[added = 2011-09-02]{\box_scale:Nnn, \box_scale:cnn}
+% \begin{function}[added = 2011-09-02, updated = 2011-10-22]
+% {\box_scale:Nnn, \box_scale:cnn}
% \begin{syntax}
% \cs{box_scale:Nnn} \meta{box} \Arg{x-scale} \Arg{y-scale}
% \end{syntax}
@@ -362,6 +359,63 @@
% \textbf{This function is experimental}
% \end{function}
%
+% \section{Viewing part of a box}
+%
+% \begin{function}[added = 2011-11-13]{\box_clip:N, \box_clip:c}
+% \begin{syntax}
+% \cs{box_clip:N} \meta{box}
+% \end{syntax}
+% Clips the \meta{box} in the output so that only material inside the
+% bounding box is displayed in the output. The updated \meta{box} will be an
+% hbox, irrespective of the nature of the \meta{box} before the clipping is
+% applied. The clipping applies within the current \TeX{} group level.
+%
+% \textbf{This function is experimental}
+% \begin{texnote}
+% Clipping is implemented by the driver, and as such the full content of
+% the box is places in the output file. Thus clipping does not remove
+% any information from the raw output, and hidden material can therefore
+% be viewed by direct examination of the file.
+% \end{texnote}
+% \end{function}
+%
+% \begin{function}[added = 2011-11-13]
+% {\box_trim:Nnnnn, \box_trim:cnnnn}
+% \begin{syntax}
+% \cs{box_trim:Nnnnn} \meta{box} \Arg{left} \Arg{bottom} \Arg{right} \Arg{top}
+% \end{syntax}
+% Adjusts the bounding box of the \meta{box} \meta{left} is removed from
+% the left-hand edge of the bounding box, \meta{right} from the right-hand
+% edge and so fourth. All adjustments are \meta{dimension expressions}.
+% Material output of the bounding box will still be displayed in the output
+% unless \cs{box_clip:N} is subsequently applied.
+% The updated \meta{box} will be an
+% hbox, irrespective of the nature of the \meta{box} before the viewport
+% operation is applied. The clipping applies within the current \TeX{}
+% group level.
+%
+% \textbf{This function is experimental}
+% \end{function}
+%
+% \begin{function}[added = 2011-11-13]
+% {\box_viewport:Nnnnn, \box_viewport:cnnnn}
+% \begin{syntax}
+% \cs{box_viewport:Nnnnn} \meta{box} \Arg{llx} \Arg{lly} \Arg{urx} \Arg{ury}
+% \end{syntax}
+% Adjusts the bounding box of the \meta{box} such that it has lower-left
+% co-ordinates (\meta{llx}, \meta{lly}) and upper-right co-ordinates
+% (\meta{urx}, \meta{ury}). All four co-ordinate positions are
+% \meta{dimension expressions}. Material output of the bounding box will
+% still be displayed in the output unless \cs{box_clip:N} is
+% subsequently applied.
+% The updated \meta{box} will be an
+% hbox, irrespective of the nature of the \meta{box} before the viewport
+% operation is applied. The clipping applies within the current \TeX{}
+% group level.
+%
+% \textbf{This function is experimental}
+% \end{function}
+%
% \section{Box conditionals}
%
% \begin{function}[EXP,pTF]{\box_if_empty:N, \box_if_empty:c}
@@ -389,7 +443,7 @@
% \end{function}
%
% \section{The last box inserted}
-%
+%
% \begin{function}
% {
% \box_set_to_last:N, \box_set_to_last:c,
@@ -404,17 +458,6 @@
% it is not possible to recover the last added item.
% \end{function}
%
-% \begin{variable}{\l_last_box}
-% This is a box containing the last item added to the current partial
-% list, except in the case of the main vertical list (main galley), in
-% which case this box is always void. Notice that although this is
-% not a constant, it is \emph{not} settable by the programmer but is
-% instead varied by \TeX{}.
-% \begin{texnote}
-% This is the \TeX{} primitive \tn{lastbox} renamed.
-% \end{texnote}
-% \end{variable}
-%
% \section{Constant boxes}
%
% \begin{variable}{\c_empty_box}
@@ -714,7 +757,7 @@
% where the \meta{content} may not be a simple argument.
% \end{function}
%
-% \begin{function}{\vbox_set_split_to_ht:NNn}
+% \begin{function}[updated = 2011-10-22]{\vbox_set_split_to_ht:NNn}
% \begin{syntax}
% \cs{vbox_set_split_to_ht:NNn} \meta{box1} \meta{box2} \Arg{dimexpr}
% \end{syntax}
@@ -837,9 +880,9 @@
% \testfile*
% Clear a \meta{box} register.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_clear:N #1
+\cs_new_protected:Npn \box_clear:N #1
{ \box_set_eq:NN #1 \c_empty_box }
-\cs_new_protected_nopar:Npn \box_gclear:N #1
+\cs_new_protected:Npn \box_gclear:N #1
{ \box_gset_eq:NN #1 \c_empty_box }
\cs_generate_variant:Nn \box_clear:N { c }
\cs_generate_variant:Nn \box_gclear:N { c }
@@ -852,13 +895,13 @@
% \testfile*
% Clear or new.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_clear_new:N #1
+\cs_new_protected:Npn \box_clear_new:N #1
{
\cs_if_exist:NTF #1
{ \box_set_eq:NN #1 \c_empty_box }
{ \box_new:N #1 }
}
-\cs_new_protected_nopar:Npn \box_gclear_new:N #1
+\cs_new_protected:Npn \box_gclear_new:N #1
{
\cs_if_exist:NTF #1
{ \box_gset_eq:NN #1 \c_empty_box }
@@ -878,9 +921,9 @@
% \testfile*
% Assigning the contents of a box to be another box.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_set_eq:NN #1#2
+\cs_new_protected:Npn \box_set_eq:NN #1#2
{ \tex_setbox:D #1 \tex_copy:D #2 }
-\cs_new_protected_nopar:Npn \box_gset_eq:NN
+\cs_new_protected:Npn \box_gset_eq:NN
{ \tex_global:D \box_set_eq:NN }
\cs_generate_variant:Nn \box_set_eq:NN { cN , Nc , cc }
\cs_generate_variant:Nn \box_gset_eq:NN { cN , Nc , cc }
@@ -903,9 +946,9 @@
% Assigning the contents of a box to be another box.
% This clears the second box globally (that's how \TeX{} does it).
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_set_eq_clear:NN #1#2
+\cs_new_protected:Npn \box_set_eq_clear:NN #1#2
{ \tex_setbox:D #1 \tex_box:D #2 }
-\cs_new_protected_nopar:Npn \box_gset_eq_clear:NN
+\cs_new_protected:Npn \box_gset_eq_clear:NN
{ \tex_global:D \box_set_eq_clear:NN }
\cs_generate_variant:Nn \box_set_eq_clear:NN { cN , Nc , cc }
\cs_generate_variant:Nn \box_gset_eq_clear:NN { cN , Nc , cc }
@@ -938,11 +981,11 @@
% Measuring is easy: all primitive work. These primitives are not
% expandable, so the derived functions are not either.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_set_dp:Nn #1#2
+\cs_new_protected:Npn \box_set_dp:Nn #1#2
{ \box_dp:N #1 \dim_eval:w #2 \dim_eval_end: }
-\cs_new_protected_nopar:Npn \box_set_ht:Nn #1#2
+\cs_new_protected:Npn \box_set_ht:Nn #1#2
{ \box_ht:N #1 \dim_eval:w #2 \dim_eval_end: }
-\cs_new_protected_nopar:Npn \box_set_wd:Nn #1#2
+\cs_new_protected:Npn \box_set_wd:Nn #1#2
{ \box_wd:N #1 \dim_eval:w #2 \dim_eval_end: }
\cs_generate_variant:Nn \box_set_ht:Nn { c }
\cs_generate_variant:Nn \box_set_dp:Nn { c }
@@ -1038,21 +1081,14 @@
%
% \subsection{The last box inserted}
%
-% \begin{variable}{\l_last_box}
-% A different name for this read-only primitive.
-% \begin{macrocode}
-\cs_new_eq:NN \l_last_box \tex_lastbox:D
-% \end{macrocode}
-% \end{variable}
-%
% \begin{macro}{\box_set_to_last:N, \box_set_to_last:c}
% \begin{macro}{\box_gset_to_last:N, \box_gset_to_last:c}
% \testfile*
% Set a box to the previous box.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_set_to_last:N #1
- { \tex_setbox:D #1 \l_last_box }
-\cs_new_protected_nopar:Npn \box_gset_to_last:N
+\cs_new_protected:Npn \box_set_to_last:N #1
+ { \tex_setbox:D #1 \tex_lastbox:D }
+\cs_new_protected:Npn \box_gset_to_last:N
{ \tex_global:D \box_set_to_last:N }
\cs_generate_variant:Nn \box_set_to_last:N { c }
\cs_generate_variant:Nn \box_gset_to_last:N { c }
@@ -1104,7 +1140,7 @@
% \testfile{m3box002.lvt}
% Put a horizontal box directly into the input stream.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \hbox:n { \tex_hbox:D \scan_stop: }
+\cs_new_protected:Npn \hbox:n { \tex_hbox:D \scan_stop: }
% \end{macrocode}
% \end{macro}
%
@@ -1113,7 +1149,7 @@
% \testfile*
% \begin{macrocode}
\cs_new_protected:Npn \hbox_set:Nn #1#2 { \tex_setbox:D #1 \tex_hbox:D {#2} }
-\cs_new_protected_nopar:Npn \hbox_gset:Nn { \tex_global:D \hbox_set:Nn }
+\cs_new_protected:Npn \hbox_gset:Nn { \tex_global:D \hbox_set:Nn }
\cs_generate_variant:Nn \hbox_set:Nn { c }
\cs_generate_variant:Nn \hbox_gset:Nn { c }
% \end{macrocode}
@@ -1127,7 +1163,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \hbox_set_to_wd:Nnn #1#2#3
{ \tex_setbox:D #1 \tex_hbox:D to \dim_eval:w #2 \dim_eval_end: {#3} }
-\cs_new_protected_nopar:Npn \hbox_gset_to_wd:Nnn
+\cs_new_protected:Npn \hbox_gset_to_wd:Nnn
{ \tex_global:D \hbox_set_to_wd:Nnn }
\cs_generate_variant:Nn \hbox_set_to_wd:Nnn { c }
\cs_generate_variant:Nn \hbox_gset_to_wd:Nnn { c }
@@ -1142,9 +1178,9 @@
% Storing material in a horizontal box. This type is useful in
% environment definitions.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \hbox_set:Nw #1
+\cs_new_protected:Npn \hbox_set:Nw #1
{ \tex_setbox:D #1 \tex_hbox:D \c_group_begin_token }
-\cs_new_protected_nopar:Npn \hbox_gset:Nw
+\cs_new_protected:Npn \hbox_gset:Nw
{ \tex_global:D \hbox_set:Nw }
\cs_generate_variant:Nn \hbox_set:Nw { c }
\cs_generate_variant:Nn \hbox_gset:Nw { c }
@@ -1218,8 +1254,8 @@
% \TestFiles{m3box003.lvt}
% Put a vertical box directly into the input stream.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \vbox:n { \tex_vbox:D \scan_stop: }
-\cs_new_protected_nopar:Npn \vbox_top:n { \tex_vtop:D \scan_stop: }
+\cs_new_protected:Npn \vbox:n { \tex_vbox:D \scan_stop: }
+\cs_new_protected:Npn \vbox_top:n { \tex_vtop:D \scan_stop: }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1242,7 +1278,7 @@
% Storing material in a vertical box with a natural height.
% \begin{macrocode}
\cs_new_protected:Npn \vbox_set:Nn #1#2 { \tex_setbox:D #1 \tex_vbox:D {#2} }
-\cs_new_protected_nopar:Npn \vbox_gset:Nn { \tex_global:D \vbox_set:Nn }
+\cs_new_protected:Npn \vbox_gset:Nn { \tex_global:D \vbox_set:Nn }
\cs_generate_variant:Nn \vbox_set:Nn { c }
\cs_generate_variant:Nn \vbox_gset:Nn { c }
% \end{macrocode}
@@ -1257,7 +1293,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \vbox_set_top:Nn #1#2
{ \tex_setbox:D #1 \tex_vtop:D {#2} }
-\cs_new_protected_nopar:Npn \vbox_gset_top:Nn
+\cs_new_protected:Npn \vbox_gset_top:Nn
{ \tex_global:D \vbox_set_top:Nn }
\cs_generate_variant:Nn \vbox_set_top:Nn { c }
\cs_generate_variant:Nn \vbox_gset_top:Nn { c }
@@ -1272,7 +1308,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \vbox_set_to_ht:Nnn #1#2#3
{ \tex_setbox:D #1 \tex_vbox:D to \dim_eval:w #2 \dim_eval_end: {#3} }
-\cs_new_protected_nopar:Npn \vbox_gset_to_ht:Nnn
+\cs_new_protected:Npn \vbox_gset_to_ht:Nnn
{ \tex_global:D \vbox_set_to_ht:Nnn }
\cs_generate_variant:Nn \vbox_set_to_ht:Nnn { c }
\cs_generate_variant:Nn \vbox_gset_to_ht:Nnn { c }
@@ -1287,9 +1323,9 @@
% Storing material in a vertical box. This type is useful in
% environment definitions.
% \begin{macrocode}
-\cs_new_nopar:Npn \vbox_set:Nw #1
+\cs_new:Npn \vbox_set:Nw #1
{ \tex_setbox:D #1 \tex_vbox:D \c_group_begin_token }
-\cs_new_protected_nopar:Npn \vbox_gset:Nw
+\cs_new_protected:Npn \vbox_gset:Nw
{ \tex_global:D \vbox_set:Nw }
\cs_generate_variant:Nn \vbox_set:Nw { c }
\cs_generate_variant:Nn \vbox_gset:Nw { c }
@@ -1336,7 +1372,7 @@
% \testfile*
% Splitting a vertical box in two.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \vbox_set_split_to_ht:NNn #1#2#3
+\cs_new_protected:Npn \vbox_set_split_to_ht:NNn #1#2#3
{ \tex_setbox:D #1 \tex_vsplit:D #2 to \dim_eval:w #3 \dim_eval_end: }
% \end{macrocode}
% \end{macro}
@@ -1420,7 +1456,7 @@
% cosine. There is then a check to avoid doing any real work for the
% trivial rotation.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_rotate:Nn #1#2
+\cs_new_protected:Npn \box_rotate:Nn #1#2
{
\hbox_set:Nn #1
{
@@ -1442,7 +1478,7 @@
% always be at zero. Rotation of the four edges then takes place: this is
% most efficiently done on a quadrant by quadrant basis.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_rotate_aux:N #1
+\cs_new_protected:Npn \box_rotate_aux:N #1
{
\dim_set:Nn \l_box_top_dim { \box_ht:N #1 }
\dim_set:Nn \l_box_bottom_dim { -\box_dp:N #1 }
@@ -1534,7 +1570,7 @@
% A simple conversion from degrees to radians followed by calculation
% of the sine and cosine.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_rotate_set_sin_cos:
+\cs_new_protected:Npn \box_rotate_set_sin_cos:
{
\fp_set_eq:NN \l_box_tmp_fp \l_box_angle_fp
\fp_div:Nn \l_box_tmp_fp { 180 }
@@ -1552,7 +1588,7 @@
% the equivalent function in the \pkg{l3coffins} module, where both parts
% are needed.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_rotate_x:nnN #1#2#3
+\cs_new_protected:Npn \box_rotate_x:nnN #1#2#3
{
\fp_set_from_dim:Nn \l_box_x_fp {#1}
\fp_set_from_dim:Nn \l_box_y_fp {#2}
@@ -1563,7 +1599,7 @@
\fp_sub:Nn \l_box_x_new_fp { \l_box_tmp_fp }
\dim_set:Nn #3 { \fp_to_dim:N \l_box_x_new_fp }
}
-\cs_new_protected_nopar:Npn \box_rotate_y:nnN #1#2#3
+\cs_new_protected:Npn \box_rotate_y:nnN #1#2#3
{
\fp_set_from_dim:Nn \l_box_x_fp {#1}
\fp_set_from_dim:Nn \l_box_y_fp {#2}
@@ -1583,7 +1619,7 @@
% this by hand means a lot less calculating and avoids lots of
% comparisons.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_rotate_quadrant_one:
+\cs_new_protected:Npn \box_rotate_quadrant_one:
{
\box_rotate_y:nnN \l_box_right_dim \l_box_top_dim
\l_box_top_new_dim
@@ -1594,7 +1630,7 @@
\box_rotate_x:nnN \l_box_right_dim \l_box_bottom_dim
\l_box_right_new_dim
}
-\cs_new_protected_nopar:Npn \box_rotate_quadrant_two:
+\cs_new_protected:Npn \box_rotate_quadrant_two:
{
\box_rotate_y:nnN \l_box_right_dim \l_box_bottom_dim
\l_box_top_new_dim
@@ -1605,7 +1641,7 @@
\box_rotate_x:nnN \l_box_left_dim \l_box_bottom_dim
\l_box_right_new_dim
}
-\cs_new_protected_nopar:Npn \box_rotate_quadrant_three:
+\cs_new_protected:Npn \box_rotate_quadrant_three:
{
\box_rotate_y:nnN \l_box_left_dim \l_box_bottom_dim
\l_box_top_new_dim
@@ -1616,7 +1652,7 @@
\box_rotate_x:nnN \l_box_left_dim \l_box_top_dim
\l_box_right_new_dim
}
-\cs_new_protected_nopar:Npn \box_rotate_quadrant_four:
+\cs_new_protected:Npn \box_rotate_quadrant_four:
{
\box_rotate_y:nnN \l_box_left_dim \l_box_top_dim
\l_box_top_new_dim
@@ -1726,7 +1762,7 @@
% both parts is needed (as this allows the same internal code to be used as
% for the general case).
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_resize_to_ht_plus_dp:Nn #1#2
+\cs_new_protected:Npn \box_resize_to_ht_plus_dp:Nn #1#2
{
\hbox_set:Nn #1
{
@@ -1747,7 +1783,7 @@
}
}
\cs_generate_variant:Nn \box_resize_to_ht_plus_dp:Nn { c }
-\cs_new_protected_nopar:Npn \box_resize_to_wd:Nn #1#2
+\cs_new_protected:Npn \box_resize_to_wd:Nn #1#2
{
\hbox_set:Nn #1
{
@@ -1781,7 +1817,7 @@
% the \TeX{} mechanism as it avoids needing to use \texttt{fp}
% operations.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_scale:Nnn #1#2#3
+\cs_new_protected:Npn \box_scale:Nnn #1#2#3
{
\hbox_set:Nn #1
{
@@ -1803,7 +1839,7 @@
}
}
\cs_generate_variant:Nn \box_scale:Nnn { c }
-\cs_new_protected_nopar:Npn \box_scale_aux:Nnn #1#2#3
+\cs_new_protected:Npn \box_scale_aux:Nnn #1#2#3
{
\fp_compare:NNNTF \l_box_scale_y_fp > \c_zero_fp
{
@@ -1827,7 +1863,7 @@
% The main resize function places in input into a box which will start
% of with zero width, and includes the handles for engine rescaling.
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \box_resize_common:N #1
+\cs_new_protected:Npn \box_resize_common:N #1
{
\hbox_set:Nn \l_box_tmp_box
{
@@ -1862,7 +1898,100 @@
}
}
% \end{macrocode}
-%\end{macro}
+% \end{macro}
+%
+% \subsection{Viewing part of a box}
+%
+% \begin{macro}{\box_clip:N, \box_clip:c}
+% A wrapper around the driver-dependent code.
+% \begin{macrocode}
+\cs_new_protected:Npn \box_clip:N #1
+ { \hbox_set:Nn #1 { \driver_box_use_clip:N #1 } }
+\cs_generate_variant:Nn \box_clip:N { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\box_trim:Nnnnn, \box_trim:cnnnn}
+% Trimming from the left- and right-hand edges of the box is easy. The total
+% width is set to remove from the right, and a skip will shift the material
+% to remove from the left.
+% \begin{macrocode}
+\cs_new_protected:Npn \box_trim:Nnnnn #1#2#3#4#5
+ {
+ \box_set_wd:Nn #1 { \box_wd:N #1 - \dim_eval:n {#4} - \dim_eval:n {#2} }
+ \hbox_set:Nn #1
+ {
+ \skip_horizontal:n { - \dim_eval:n {#2} }
+ \box_use:N #1
+ }
+% \end{macrocode}
+% For the height and depth, there is a need to watch the baseline is
+% respected. Material always has to stay on the correct side, so trimming
+% has to check that there is enough material to trim.
+% \begin{macrocode}
+ \dim_compare:nNnTF { \box_dp:N #1 } > {#3}
+ { \box_set_dp:Nn #1 { \box_dp:N #1 - \dim_eval:n {#3} } }
+ {
+ \hbox_set:Nn #1
+ {
+ \box_move_down:nn { \dim_eval:n {#3} - \box_dp:N #1 }
+ { \box_use:N #1 }
+ }
+ \box_set_dp:Nn #1 \c_zero_dim
+ }
+ \dim_compare:nNnTF { \box_ht:N #1 } > {#5}
+ { \box_set_ht:Nn #1 { \box_ht:N #1 - \dim_eval:n {#5} } }
+ {
+ \hbox_set:Nn #1
+ {
+ \box_move_up:nn { \dim_eval:n {#5} - \box_ht:N #1 }
+ { \box_use:N #1 }
+ }
+ \box_set_ht:Nn #1 \c_zero_dim
+ }
+ }
+\cs_generate_variant:Nn \box_trim:Nnnnn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\box_viewport:Nnnnn, \box_viewport:cnnnn}
+% The same general logic as for clipping, but with absolute dimensions.
+% Thus again width is easy and height is harder.
+% \begin{macrocode}
+\cs_new_protected:Npn \box_viewport:Nnnnn #1#2#3#4#5
+ {
+ \box_set_wd:Nn #1 { \dim_eval:n {#4} - \dim_eval:n {#2} }
+ \hbox_set:Nn #1
+ {
+ \skip_horizontal:n { - \dim_eval:n {#2} }
+ \box_use:N #1
+ }
+ \dim_compare:nNnTF {#3} > \c_zero_dim
+ {
+ \hbox_set:Nn #1 { \box_move_down:nn {#3} { \box_use:N #1 } }
+ \box_set_dp:Nn #1 \c_zero_dim
+ }
+ { \box_set_dp:Nn #1 { - \dim_eval:n {#3} } }
+ \dim_compare:nNnTF {#5} > \c_zero_dim
+ { \box_set_ht:Nn #1 {#5} }
+ {
+ \hbox_set:Nn #1
+ { \box_move_up:nn { -\dim_eval:n {#5} } { \box_use:N #1 } }
+ \box_set_ht:Nn #1 \c_zero_dim
+ }
+ }
+\cs_generate_variant:Nn \box_viewport:Nnnnn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Deprecated functions}
+%
+% \begin{variable}{\l_last_box}
+% Deprecated 2011-11-13, for removal by 2012-02-28.
+% \begin{macrocode}
+\cs_new_eq:NN \l_last_box \tex_lastbox:D
+% \end{macrocode}
+% \end{variable}
%
% \begin{macrocode}
%</initex|package>