summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/register/register.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/register/register.sty')
-rw-r--r--Master/texmf-dist/tex/latex/register/register.sty96
1 files changed, 93 insertions, 3 deletions
diff --git a/Master/texmf-dist/tex/latex/register/register.sty b/Master/texmf-dist/tex/latex/register/register.sty
index 938d0c357c2..7e3d63a5e50 100644
--- a/Master/texmf-dist/tex/latex/register/register.sty
+++ b/Master/texmf-dist/tex/latex/register/register.sty
@@ -22,7 +22,7 @@
-\ProvidesPackage{register} [2018/05/19 v1.6.1 Register macros with
+\ProvidesPackage{register} [2018/08/18 v1.7 Register macros with
hyperref/LyX support]
\RequirePackage{ifthen}[1997/11/02]
@@ -33,6 +33,7 @@ hyperref/LyX support]
\DeclareOption{hyperref}{\setboolean{RegisterHyperref}{true}}
\DeclareOption{TRflags}{\setboolean{RegisterTRFlags}{true}}
\DeclareOption{TRboxed}{\setboolean{RegisterTRBoxed}{true}}
+\DeclareOption{color}{\setboolean{RegisterColors}{true}}
\DeclareOption*{% Emit a warning for other options
\PackageWarning{register}{Unknown option '\CurrentOption'}%
@@ -42,13 +43,16 @@ hyperref/LyX support]
\newboolean{RegisterHyperref}
\newboolean{RegisterTRFlags}
\newboolean{RegisterTRBoxed}
+\newboolean{RegisterColors}
\setboolean{RegisterLyX}{false}
\setboolean{RegisterHyperref}{false}
\setboolean{RegisterTRFlags}{false}
\setboolean{RegisterTRBoxed}{false}
+\setboolean{RegisterColors}{false}
\ProcessOptions\relax % Process package options
+\ifthenelse{\boolean{RegisterColors}}{\RequirePackage{xcolor}[2007/01/21]}{}
\newboolean{RegisterContext}
\setboolean{RegisterContext}{false}
\floatstyle{plaintop} \@ifundefined{chapter}
@@ -62,6 +66,9 @@ hyperref/LyX support]
\newlength{\regResetDepth}
\newlength{\regResetDrop}
\newlength{\regDescSkip}
+\newlength{\regRsvdHeight}
+\newlength{\regRsvdDrop}
+\newlength{\regFboxSep}
\setlength{\regWidth}{0.95\textwidth}
\newcommand{\regBitWidth}{32}
\newcommand{\regResetName}{Reset}
@@ -171,6 +178,10 @@ hyperref/LyX support]
% the end is effectively the separation between the bit position
% box and the reset value box.
\setlength{\regResetDrop}{\regResetHeight + 2\fboxsep - 2\fboxrule + 3pt}%
+ % New lengths to support colorbox use, when fboxsep gets set to 0
+ \setlength{\regRsvdDrop}{\regResetDrop + \fboxsep}%
+ \setlength{\regRsvdHeight}{\regResetHeight + 2\fboxsep}%
+ \setlength{\regFboxSep}{\fboxsep}%
}
\newcommand{\regMakeFieldName}[1]{%
% Create box to hold label
@@ -197,7 +208,7 @@ hyperref/LyX support]
% surrounding the reset field
{\regResetSize \rule[-1\regResetDepth]{0pt}{\regResetHeight}\regSpread{#1}}}}%
}
-\newcommand{\regfield}[4]{%
+\newcommand{\regfieldNoColor}[4]{%
% Compute overall field length
\setRegLengths%
\setlength{\regFieldLen}{#2\regFieldLen + \fboxrule}%
@@ -214,7 +225,7 @@ hyperref/LyX support]
\typesetRegBits{#2}%
\hspace{-1\fboxrule}%
}
-\newcommand{\regfieldb}[3]{%
+\newcommand{\regfieldbNoColor}[3]{%
% Compute overall field length
\setRegLengths%
\setlength{\regFieldLen}{#2\regFieldLen + \fboxrule}%
@@ -231,6 +242,85 @@ hyperref/LyX support]
\typesetRegBits{#2}%
\hspace{-1\fboxrule}%
}
+\ifthenelse{\boolean{RegisterColors}}{%
+\newcommand{\typesetRegColorBits}[2]{%
+ \ifthenelse{#2 > 1}%
+ {\setlength\fboxsep{0pt}%
+ \colorbox{#1}{%
+ \framebox[\regFieldLen][c]%
+ {\regBitSize \rule[-1\regResetDepth - \regFboxSep]{0pt}%
+ {\regResetHeight + 2\regFboxSep}%
+ \regBitFamily\hspace{\regFboxSep}%
+\arabic{upperbit} \hfill \arabic{lowerbit}%
+\hspace{\regFboxSep}}}}%
+ {\setlength\fboxsep{0pt}%
+ \colorbox{#1}{%
+ \framebox[\regFieldLen][c]%
+ {\regBitSize \rule[-1\regResetDepth - \regFboxSep]{0pt}%
+ {\regResetHeight + 2\regFboxSep}%
+ \regBitFamily\arabic{lowerbit}}}}%
+ \setlength\fboxsep{\regFboxSep}%
+}
+\newcommand{\typesetRegColorReset}[2]{%
+ % Typeset reset value in a framebox
+ \makebox[0pt][l]{\raisebox{-1\regRsvdDrop}{%
+ \setlength\fboxsep{0pt}%
+ \colorbox{#1}{\framebox[\regFieldLen][c]%
+ % Place an invisible rule to control the box surrounding the reset field
+ {\regResetSize \rule[-1\regResetDepth]{0pt}{\regRsvdHeight}%
+ \raisebox{\regFboxSep}{\makebox[\regFieldLen]%
+ {\hspace{\regFboxSep}\regSpread{#2}\hspace{\regFboxSep}}}}}%
+}}}
+\newcommand{\regfieldColor}[5]{%
+ % Compute overall field length
+ \setRegLengths%
+ \setlength{\regFieldLen}{#3\regFieldLen + \fboxrule}%
+ % Figure out bit positions
+ \setcounter{lowerbit}{#4}%
+ \setcounter{upperbit}{#4 + #3 - 1}%
+ \regMakeFieldName{#2}%
+ % Figure out how far over to place label, accounting for height
+ \setlength{\regLabelAdjust}{0.5\regFieldLen - 0.707107\ht\Label}%
+ % Now, rotate and type the label
+ \regRotateFieldName%
+ \typesetRegColorReset{#1}{#5}%
+ % Typeset bit positions in a framebox
+ \typesetRegColorBits{#1}{#3}%
+ \hspace{-1\fboxrule}%
+}
+\newcommand{\regfieldbColor}[4]{%
+ % Compute overall field length
+ \setRegLengths%
+ \setlength{\regFieldLen}{#3\regFieldLen + \fboxrule}%
+ % Figure out bit positions
+ \setcounter{lowerbit}{#4}%
+ \setcounter{upperbit}{#4 + #3 - 1}%
+ % Create box to hold label
+ \regMakeFieldName{#2}%
+ % Figure out how far over to place label, accounting for height
+ \setlength{\regLabelAdjust}{0.5\regFieldLen - 0.707107\ht\Label}%
+ % Now, rotate and typeset the label
+ \regRotateFieldName%
+ % Typeset bit positions
+ \typesetRegColorBits{#1}{#3}%
+ \hspace{-1\fboxrule}%
+}
+}{}
+\ifthenelse{\boolean{RegisterColors}}{
+ \newcommand{\regfield}[5][]{%
+ \ifthenelse{\equal{#1}{}}{%
+ \regfieldNoColor{#2}{#3}{#4}{#5}}%
+ {\regfieldColor{#1}{#2}{#3}{#4}{#5}}}
+ \newcommand{\regfieldb}[4][]{%
+ \ifthenelse{\equal{#1}{}}{%
+ \regfieldbNoColor{#2}{#3}{#4}}%
+ {\regfieldbColor{#1}{#2}{#3}{#4}}}
+}{
+ \newcommand{\regfield}[5][]{%
+ \regfieldNoColor{#2}{#3}{#4}{#5}}%
+ \newcommand{\regfieldb}[4][]{%
+ \regfieldbNoColor{#2}{#3}{#4}}%
+}
\newcommand{\regbits}[3]{%
% Compute overall field length
\setRegLengths%