diff options
author | Karl Berry <karl@freefriends.org> | 2020-10-24 20:27:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-10-24 20:27:41 +0000 |
commit | 8d132bd21f6b766eddaf605a00c4ef5b4e0fcc19 (patch) | |
tree | e0bc1adf1d456a8d581423d3d8543c6227c345f9 /Master/texmf-dist/tex/latex | |
parent | 2aef12d4ddaa67c815a67c0d7f3d236292a8899c (diff) |
bytefield (24oct20)
git-svn-id: svn://tug.org/texlive/trunk@56749 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/bytefield/bytefield.sty | 231 |
1 files changed, 158 insertions, 73 deletions
diff --git a/Master/texmf-dist/tex/latex/bytefield/bytefield.sty b/Master/texmf-dist/tex/latex/bytefield/bytefield.sty index 79972b59f2e..69067e54d8e 100644 --- a/Master/texmf-dist/tex/latex/bytefield/bytefield.sty +++ b/Master/texmf-dist/tex/latex/bytefield/bytefield.sty @@ -8,7 +8,7 @@ %% %% This is a generated file. %% -%% Copyright (C) 2017 by Scott Pakin <scott+bf@pakin.org> +%% Copyright (C) 2000-2020 by Scott Pakin <scott+bf@pakin.org> %% %% This file may be distributed and/or modified under the conditions of %% the LaTeX Project Public License, either version 1.3a of this license @@ -22,7 +22,7 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{bytefield} - [2017/09/15 v2.4 Network protocol diagrams] + [2020/10/22 v2.5 Network protocol diagrams] \RequirePackage{calc}[1998/07/07] \RequirePackage{keyval} \def\bf@newdimen#1{\advance\count11 by 1 @@ -46,7 +46,8 @@ \newlength{\bytefield@height@increment} \DeclareRobustCommand{\inc@bytefield@height}[1]{% \setlength{\bytefield@height@increment}{#1}% - \global\advance\bytefield@height by \bytefield@height@increment} + \global\advance\bytefield@height by \bytefield@height@increment +} \newsavebox{\entire@bytefield@picture} \newenvironment{bytefield}[2][]{% \bf@bytefieldsetup{#1}% @@ -70,7 +71,8 @@ }{% \amp\show@wordlabelr\cr\egroup\egroup \end{lrbox}% - \usebox{\entire@bytefield@picture}} + \usebox{\entire@bytefield@picture}% +} \newcommand*{\bf@bitformatting}{\tiny} \newcommand*{\bf@boxformatting}{\centering} \newlength{\bf@bitwidth} @@ -79,28 +81,68 @@ \setlength{\bf@bitheight}{4ex} \newlength{\units@wide} \newlength{\units@tall} -\DeclareRobustCommand{\bitbox}[3][lrtb]{% - \setlength{\units@wide}{\bf@bitwidth * #2}% - \bf@parse@bitbox@arg{#1}% - \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\bf@bitheight}{#3}} -\DeclareRobustCommand{\wordbox}[3][lrtb]{% - \setlength{\units@wide}{\bf@bitwidth * \bits@wide}% - \setlength{\units@tall}{\bf@bitheight * #2}% - \bf@parse@bitbox@arg{#1}% - \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\units@tall}{#3}} +\newcommand*{\bf@call@box@cmd}[1]{% + \def\bf@call@box@func{#1}% + \bf@call@box@cmd@i +} +\newcommand*{\bf@call@box@cmd@i}[2][lrtb]{% + \def\bf@call@box@arg@i{#1}% + \def\bf@call@box@arg@ii{#2}% + \bf@call@box@cmd@ii +} +\newcommand*{\bf@call@box@cmd@ii}[2][]{% + \def\bf@call@box@arg@iii{#1}% + \def\bf@call@box@arg@iv{#2}% + \bf@call@box@func +} +\DeclareRobustCommand{\bitbox}{\bf@call@box@cmd{\bf@bitbox}} +\def\bf@bitbox{% + \bgroup + \expandafter\bf@parse@bitbox@arg\expandafter{\bf@call@box@arg@i}% + \setlength{\units@wide}{\bf@bitwidth * \bf@call@box@arg@ii}% + \expandafter\bf@bytefieldsetup\expandafter{\bf@call@box@arg@iii}% + \@ifundefined{bf@bgcolor}{% + }{% + \rlap{% + \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\bf@bitheight}{% + \color{\bf@bgcolor}% + \rule{\width}{\height}% + }% + }% + }% + \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\bf@bitheight}{% + \bf@call@box@arg@iv + }% + \egroup + \ignorespaces +} +\DeclareRobustCommand{\wordbox}{\bf@call@box@cmd{\bf@wordbox}} +\def\bf@wordbox{% + \bgroup + \expandafter\bf@parse@bitbox@arg\expandafter{\bf@call@box@arg@i}% + \setlength{\units@wide}{\bf@bitwidth * \bits@wide}% + \setlength{\units@tall}{\bf@bitheight * \bf@call@box@arg@ii}% + \expandafter\bf@bytefieldsetup\expandafter{\bf@call@box@arg@iii}% + \@ifundefined{bf@bgcolor}{% + }{% + \rlap{% + \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\units@tall}{% + \color{\bf@bgcolor}% + \rule{\width}{\height}% + }% + }% + }% + \draw@bit@picture{\strip@pt\units@wide}{\strip@pt\units@tall}{% + \bf@call@box@arg@iv + }% + \@ifundefined{bf@per@word}{}{\bf@invoke@per@word{\bf@call@box@arg@ii}}% + \egroup + \ignorespaces +} \DeclareRobustCommand{\draw@bit@picture}[3]{% \begin{picture}(#1,#2)% \put(0,0){\makebox(#1,#2){\parbox{#1\unitlength}{% - \bf@newdimen\height - \bf@newdimen\depth - \bf@newdimen\totalheight - \bf@newdimen\width - \height=#2\unitlength - \depth=0pt% - \totalheight=#2\unitlength - \width=#1\unitlength - \def\widthunits{#1}% - \def\heightunits{#2}% + \bf@set@user@dimens{#1}{#2}% \bf@boxformatting{#3\par}}}}% \ifbitbox@top \put(0,#2){\line(1,0){#1}}% @@ -119,56 +161,90 @@ \inc@bytefield@height{\unitlength * \real{#2}}% \global\counting@wordsfalse \fi - \ignorespaces} +} +\newcommand{\bf@invoke@per@word}[1]{% + \begin{picture}(0,0)% + \@tempcnta=0 + \@tempdima=#1\bf@bitheight + \bf@set@user@dimens{\strip@pt\units@wide}{\strip@pt\units@tall}% + \loop + \advance\@tempdima by -\bf@bitheight + \bgroup + \put(-\strip@pt\units@wide, \strip@pt\@tempdima){% + \expandafter\bf@per@word\expandafter{\the\@tempcnta}{#1}% + }% + \egroup + \advance\@tempcnta by 1\relax + \ifnum#1>\@tempcnta + \repeat + \end{picture}% +} +\newcommand{\bf@set@user@dimens}[2]{% + \bf@newdimen\width + \bf@newdimen\height + \bf@newdimen\depth + \bf@newdimen\totalheight + \width=#1\unitlength + \height=#2\unitlength + \depth=0pt% + \totalheight=#2\unitlength + \def\widthunits{#1}% + \def\heightunits{#2}% +} \DeclareRobustCommand{\bitboxes}{% - \@ifstar\bf@bitboxes@star\bf@bitboxes@no@star + \@ifstar + {\bf@call@box@cmd{\bf@bitboxes@star}}% + {\bf@call@box@cmd{\bf@bitboxes@no@star}}% } \def\bf@relax{\relax} -\newcommand{\bf@bitboxes@no@star}[3][lrtb]{% - \def\bf@bitboxes@no@star@i##1{% - \def\bf@bitboxes@arg{##1}% - \ifx\bf@bitboxes@arg\bf@relax - \let\next=\relax - \else - \bitbox[#1]{#2}{##1}% - \let\next=\bf@bitboxes@no@star@i - \fi - \next - }% - \bf@bitboxes@no@star@i#3\relax +\def\bf@bitboxes@no@star{% + \expandafter\bf@bitboxes@no@star@i\bf@call@box@arg@iv\relax \ignorespaces } -\newcommand{\bf@bitboxes@star}[3][lrtb]{% - \def\bf@bitboxes@star@i##1##2{% - \def\bf@bitboxes@arg{##2}% - \ifx\bf@bitboxes@arg\bf@relax - \bitbox[#1]{#2}{##1}% - \let\next=\relax - \else - \bitbox[#1R]{#2}{##1}% - \def\next{\bf@bitboxes@star@ii{##2}}% - \fi - \next - }% - \def\bf@bitboxes@star@ii##1##2{% - \def\bf@bitboxes@arg@i{##1}% - \def\bf@bitboxes@arg@ii{##2}% - \ifx\bf@bitboxes@arg@ii\bf@relax - \def\bf@bitboxes@sides{#1L}% - \else - \def\bf@bitboxes@sides{#1LR}% - \fi - \ifx\bf@bitboxes@arg@i\bf@relax - \let\next=\relax - \else - \expandafter\bitbox\expandafter[\bf@bitboxes@sides]{#2}{##1}% - \def\next{\bf@bitboxes@star@ii{##2}}% - \fi - \next - }% - \bf@bitboxes@star@i#3\relax\relax +\def\bf@bitboxes@no@star@i#1{% + \def\bf@call@box@arg@iv{#1}% + \ifx\bf@call@box@arg@iv\bf@relax + \let\next=\relax + \else + \bf@bitbox + \let\next=\bf@bitboxes@no@star@i + \fi + \next +} +\def\bf@bitboxes@star{% + \edef\bf@bitboxes@sides{\bf@call@box@arg@i}% + \expandafter\bf@bitboxes@star@i\bf@call@box@arg@iv\relax\relax \ignorespaces } +\def\bf@bitboxes@star@i#1#2{% + \def\bf@call@box@arg@iv{#1}% + \def\bf@bitboxes@arg@ii{#2}% + \ifx\bf@bitboxes@arg@ii\bf@relax + \bf@bitbox + \let\next=\relax + \else + \edef\bf@call@box@arg@i{\bf@bitboxes@sides R}% + \bf@bitbox + \def\next{\bf@bitboxes@star@ii{#2}}% + \fi + \next +} +\def\bf@bitboxes@star@ii#1#2{% + \def\bf@call@box@arg@iv{#1}% + \def\bf@bitboxes@arg@ii{#2}% + \ifx\bf@bitboxes@arg@ii\bf@relax + \edef\bf@call@box@arg@i{\bf@bitboxes@sides L}% + \else + \edef\bf@call@box@arg@i{\bf@bitboxes@sides LR}% + \fi + \ifx\bf@call@box@arg@iv\bf@relax + \let\next=\relax + \else + \bf@bitbox + \def\next{\bf@bitboxes@star@ii{#2}}% + \fi + \next +} \newif\ifbitbox@top \newif\ifbitbox@bottom \newif\ifbitbox@left @@ -178,7 +254,8 @@ \bitbox@bottomfalse \bitbox@leftfalse \bitbox@rightfalse - \bf@parse@bitbox@sides#1X} + \bf@parse@bitbox@sides#1X% +} \def\bf@parse@bitbox@sides#1{% \ifx#1X% \else @@ -216,7 +293,8 @@ \fi \fi \expandafter\bf@parse@bitbox@sides - \fi} + \fi +} \newlength{\units@high} \DeclareRobustCommand{\skippedwords}[1][2ex]{% \setlength{\units@wide}{\bf@bitwidth * \bits@wide}% @@ -234,7 +312,8 @@ \ifcounting@words \inc@bytefield@height{\unitlength * \real{\num@tall}}% \global\counting@wordsfalse - \fi} + \fi +} \newcommand*{\bf@bit@endianness}{l} \newcommand*{\bf@first@bit}{0} \DeclareRobustCommand{\bitheader}[2][]{% @@ -251,13 +330,15 @@ \inc@bytefield@height{\unitlength * \real{\strip@pt\units@tall}}% \global\counting@wordsfalse \fi - \ignorespaces} + \ignorespaces +} \def\bf@parse@range@list#1,{% \ifx X#1 \else \bf@parse@range#1-#1-#1\relax \expandafter\bf@parse@range@list - \fi} + \fi +} \newlength{\header@xpos} \newcounter{header@val} \newcounter{max@header@val} @@ -276,7 +357,8 @@ \makebox(\strip@pt\bf@bitwidth,\strip@pt\units@tall){% \bf@bitformatting{\theheader@val}}} \addtocounter{header@val}{1} - \repeat} + \repeat +} \newcommand*{\bf@process@bitheader@opts}{% \let\KV@bytefield@l=\KV@bitheader@l \let\KV@bytefield@b=\KV@bitheader@b @@ -428,7 +510,8 @@ \hspace*{\bf@leftcurlyspace}} \end{picture}% \def\@currenvir{leftwordgroup}% - \ignorespaces} + \ignorespaces +} \newlength{\label@box@width} \newlength{\label@box@height} \newsavebox{\word@label@box} @@ -545,6 +628,8 @@ \fi } \define@key{bytefield}{lsb}{\def\bf@first@bit{#1}} +\define@key{bytefield}{bgcolor}{\def\bf@bgcolor{#1}} +\define@key{bytefield}{perword}{\def\bf@per@word{#1}} \newcommand{\bf@bytefieldsetup}{\setkeys{bytefield}} \let\bytefieldsetup=\bf@bytefieldsetup \DeclareOption{compat1}{\bf@enter@compatibility@mode@i} |