summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-05-02 23:56:09 +0000
committerKarl Berry <karl@freefriends.org>2016-05-02 23:56:09 +0000
commit5feb9fd1afef1dc215799e36d9a96ef2f4ed47ac (patch)
tree25b3d1656a239bc6784ccea166f8c602c3775ac6 /Master/texmf-dist/tex/latex
parent18e1e0676806d75d5accc5104cc3ab13865bda21 (diff)
shdoc (29apr16)
git-svn-id: svn://tug.org/texlive/trunk@40848 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r--Master/texmf-dist/tex/latex/shdoc/shdoc.sty398
1 files changed, 272 insertions, 126 deletions
diff --git a/Master/texmf-dist/tex/latex/shdoc/shdoc.sty b/Master/texmf-dist/tex/latex/shdoc/shdoc.sty
index 8bb5283f5d4..491c4544fa1 100644
--- a/Master/texmf-dist/tex/latex/shdoc/shdoc.sty
+++ b/Master/texmf-dist/tex/latex/shdoc/shdoc.sty
@@ -23,32 +23,17 @@
%% The Current Maintainer of this work is S. M. Laube
%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{shdoc}[2015/05/24 v2.0 Package for documenting terminal operations]
+\ProvidesPackage{shdoc}[2015/05/24 v2.1 Package for documenting shell operations]
\RequirePackage[dvipsnames]{xcolor}
\RequirePackage{float}
\RequirePackage{caption}
\RequirePackage{mdframed}
\RequirePackage{kvoptions}
+\RequirePackage{relsize}
+\RequirePackage{stringstrings}
+\RequirePackage{ifthen}
+\makeatletter
-\begin{sh}
- \shuser{simon}
- \shmachine{linuxmint}
- \begin{shbox}
- \shline{}{cd Desktop/}
- \shline{Desktop/}{xsensors -help}
- \shoutput{}{}
- \shoutput{}{\underline{Options:}}
- \shoutput{}{}
- \shoutput{-f} {Display all temperatures in Fahrenheit.}
- \shoutput{-h} {Display this help text and exit.}
- \shoutput{-c} {+filename Specify the libsensors configuration file.}
- \shoutput{-i} {+filename Specify the image file to use as a theme.}
- \shoutput{-t} {+time Specify the update time in number of seconds.}
- \shoutput{-v} {Display version number.}
- \end{shbox}
- \caption{The options of \textit{xsensors}}
- \label{sh:xsensor}
-\end{sh}
\DeclareStringOption[gray!70]{backgroundcolor}
\DeclareStringOption[green!80!yellow]{usernamecolor}
\DeclareStringOption[green!80!yellow]{machinenamecolor}
@@ -58,122 +43,283 @@
\DeclareStringOption[white!60!gray]{optioncolor}
\DeclareStringOption[black]{textcolor}
\DeclareStringOption[\$]{indicatorsymbol}
-\DeclareStringOption[\~]{rootpathsymbol}
+\DeclareStringOption[\~]{defaultpath}
\DeclareStringOption[@]{separatorsymbol}
\ProcessKeyvalOptions*
-\def\shpreset#1{\csname sh@preset@#1\endcsname}
-\def\shpresetdef#1#2{
-\expandafter\gdef\csname sh@preset@#1\endcsname{\shpreset{default} #2}
-}
-\def\shchangecolor#1#2{\expandafter\gdef\csname shdoc@#1\endcsname{#2}}
-\let\shchangesymbol\shchangecolor
-\def\sh@preset@default{
-\shchangecolor{backgroundcolor}{gray!70}
-\shchangecolor{usernamecolor}{green!80!yellow}
-\shchangecolor{machinenamecolor}{green!80!yellow}
-\shchangecolor{pathcolor}{RoyalBlue}
-\shchangecolor{indicatorcolor}{RoyalBlue}
-\shchangecolor{separatorcolor}{green!80!yellow}
-\shchangecolor{optioncolor}{white!60!gray}
-\shchangecolor{textcolor}{black}
-\shchangesymbol{indicatorsymbol}{\$}
-\shchangesymbol{rootpathsymbol}{\~}
-\shchangesymbol{separatorsymbol}{@}
-}
-\shpresetdef{mint}{\shpreset{default}}
-\shpresetdef{arrows}{
-\shchangecolor{usernamecolor}{red}
-\shchangecolor{machinenamecolor}{green!80!yellow}
-\shchangecolor{separatorcolor}{white}
-\shchangecolor{indicatorsymbol}{$\gg$}
-\shchangecolor{indicatorcolor}{green!80!yellow}
-\shchangecolor{backgroundcolor}{black}
-\shchangecolor{textcolor}{white}
-\shchangecolor{optioncolor}{gray}
-}
-\shpresetdef{darkblue}{
-\definecolor{shdarkblue}{RGB}{7,75,138}
-\shchangecolor{backgroundcolor}{shdarkblue}
-\shchangecolor{textcolor}{white}
-\shchangecolor{separatorcolor}{white}
-\shchangecolor{usernamecolor}{orange}
-\shchangecolor{machinenamecolor}{orange}
-\shchangecolor{pathcolor}{green!60!black}
-\shchangecolor{optioncolor}{SkyBlue!80!black}
+\def\shpreset#1{\csname sh@preset@#1\endcsname}%
+\def\shpresetdef#1#2{%
+\expandafter\gdef\csname sh@preset@#1\endcsname{\shpreset{default} #2}%
+}%
+\def\shchange#1#2{\expandafter\gdef\csname shdoc@#1\endcsname{#2}}
+\let\shchangesymbol\shchange%
+\let\shchangecolor\shchange%
+\def\sh@preset@default{%
+\shchangecolor{backgroundcolor}{gray!70}%
+\shchangecolor{usernamecolor}{green!80!yellow}%
+\shchangecolor{machinenamecolor}{green!80!yellow}%
+\shchangecolor{pathcolor}{RoyalBlue}%
+\shchangecolor{indicatorcolor}{RoyalBlue}%
+\shchangecolor{separatorcolor}{green!80!yellow}%
+\shchangecolor{optioncolor}{white!60!gray}%
+\shchangecolor{textcolor}{black}%
+\shchangesymbol{indicatorsymbol}{\$}%
+\shchangesymbol{defaultpath}{\~}%
+\shchangesymbol{separatorsymbol}{@}%
+}%
+\shpresetdef{mint}{\shpreset{default}}%
+\shpresetdef{arrows}{%
+\shchangecolor{usernamecolor}{red}%
+\shchangecolor{machinenamecolor}{green!80!yellow}%
+\shchangecolor{separatorcolor}{white}%
+\shchangecolor{indicatorsymbol}{$\gg$}%
+\shchangecolor{indicatorcolor}{green!80!yellow}%
+\shchangecolor{backgroundcolor}{black}%
+\shchangecolor{textcolor}{white}%
+\shchangecolor{optioncolor}{gray}%
+}%
+\shpresetdef{darkblue}{%
+\definecolor{shdarkblue}{RGB}{7,75,138}% xcolor syntax
+\shchangecolor{backgroundcolor}{shdarkblue}%
+\shchangecolor{textcolor}{white}%
+\shchangecolor{separatorcolor}{white}%
+\shchangecolor{usernamecolor}{orange}%
+\shchangecolor{machinenamecolor}{orange}%
+\shchangecolor{pathcolor}{green!60!black}%
+\shchangecolor{optioncolor}{SkyBlue!80!black}%
}
-\shpresetdef{blackwhite}{
-\shchangecolor{backgroundcolor}{gray!30}
-\shchangecolor{textcolor}{black}
-\shchangecolor{separatorcolor}{black}
-\shchangecolor{usernamecolor}{gray}
-\shchangecolor{machinenamecolor}{gray}
-\shchangecolor{pathcolor}{gray!50!black}
-\shchangecolor{optioncolor}{white}
-\shchangecolor{indicatorcolor}{white}
+\shpresetdef{blackwhite}{%
+\shchangecolor{backgroundcolor}{gray!30}%
+\shchangecolor{textcolor}{black}%
+\shchangecolor{separatorcolor}{black}%
+\shchangecolor{usernamecolor}{gray}%
+\shchangecolor{machinenamecolor}{gray}%
+\shchangecolor{pathcolor}{gray!50!black}%
+\shchangecolor{optioncolor}{white}%
+\shchangecolor{indicatorcolor}{white}%
}
-\shpresetdef{airy}{
-\shchangecolor{backgroundcolor}{SkyBlue!15}
-\shchangecolor{usernamecolor}{Emerald}
-\shchangecolor{machinenamecolor}{Emerald}
-\shchangecolor{pathcolor}{orange!70}
-\shchangecolor{indicatorcolor}{orange!70}
-\shchangecolor{separatorcolor}{Emerald}
-\shchangecolor{optioncolor}{Emerald!30}
+\shpresetdef{airy}{%
+\shchangecolor{backgroundcolor}{SkyBlue!15}%
+\shchangecolor{usernamecolor}{Emerald}%
+\shchangecolor{machinenamecolor}{Emerald}%
+\shchangecolor{pathcolor}{orange!70}%
+\shchangecolor{indicatorcolor}{orange!70}%
+\shchangecolor{separatorcolor}{Emerald}%
+\shchangecolor{optioncolor}{Emerald!30}%
}
-\newcounter{shlinenumber}
-\setcounter{shlinenumber}{0}
-\let\@shlistname\relax
-\gdef\shlistname#1{\gdef\@shlistname{#1}}
-\shlistname{List of Terminal Sessions}
-\newfloat{sh}{tbph}{lsh}
-\restylefloat*{sh}
-\floatstyle{plain}
-\let\@shfloatname\relax
-\gdef\shfloatname#1{\gdef\@shfloatname{#1}}
-\shfloatname{Terminal~Session}
-\floatname{sh}{\@shfloatname}
-\captionsetup[sh]{position=bottom}
-\def\listofsh{\listof{sh}{\@shlistname}}
-\makeatletter
-\let\@shuser\relax
-\let\@shmachine\relax
-\def\shuser#1{\gdef\@shuser{#1}}
-\def\shmachine#1{\gdef\@shmachine{#1}}
+\newcounter{shlinenumber}% def new counter
+\setcounter{shlinenumber}{0}% set counter to 0
+\let\@shlistname\relax%
+\gdef\shlistname#1{\gdef\@shlistname{#1}}%
+\shlistname{List of Terminal Sessions}% set default value
+\newfloat{sh}{tbph}{lsh}% define new float
+\restylefloat*{sh}%
+\floatstyle{plain}% set style
+
+\let\@shfloatname\relax%
+\gdef\shfloatname#1{\gdef\@shfloatname{#1}}%
+\shfloatname{Terminal~Session}% default float name
+\floatname{sh}{\@shfloatname}%
+
+\captionsetup[sh]{position=bottom}%
+\def\listofsh{\listof{sh}{\@shlistname}}%
+\let\@shuser\relax%
+\let\@shmachine\relax%
+\def\shuser#1{\gdef\@shuser{#1}}%
+\def\shmachine#1{\gdef\@shmachine{#1}}%
+\def\@default@shuser{root}%
+\def\@default@shmachine{linux}%
+\shuser{\@default@shuser}%
+\shmachine{\@default@shmachine}%
+\def\sh@lnscale{.7}% default number scaling
+\def\sh@fontcheck{% if fontsize < 6pt
+\ifthenelse{\f@size<6}{%
+\gdef\sh@lnscale{1}% factor = 1
+}{% elif fontsize < 8pt
+\ifthenelse{\f@size<8}{%
+\gdef\sh@lnscale{.84}% factor = 0.84
+}{% else: nothing
+}%
+}%
+}%
+\newlength{\sh@linenumberwidth}%
\long\def\shline#1#2{
-\ttfamily\noindent\scriptsize
-\ifnum\value{shlinenumber}<10
-\textcolor{\shdoc@textcolor}{0\theshlinenumber}
-\else
-\textcolor{\shdoc@textcolor}{\theshlinenumber}
-\fi
-\normalsize\ \ \textcolor{\shdoc@usernamecolor}{\@shuser}\ignorespaces
-\textcolor{\shdoc@separatorcolor}{\shdoc@separatorsymbol}\ignorespaces
-\textcolor{\shdoc@machinenamecolor}{\@shmachine}\ignorespaces
-\ \ifx&#1&\ignorespaces
-\textcolor{\shdoc@pathcolor}{\shdoc@rootpathsymbol\ }\ignorespaces
+\ttfamily\sh@fontcheck\noindent%
+\ifnum\value{shlinenumber}<10%
+\textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}0\theshlinenumber}%
+\settowidth{\sh@linenumberwidth}{%
+\relscale{\sh@lnscale}0\theshlinenumber%
+}%
+\else%
+\textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}\theshlinenumber}%
+\settowidth{\sh@linenumberwidth}{%
+\relscale{\sh@lnscale}\theshlinenumber%
+}%
+\fi\hspace{\sh@linenumberwidth}%
+\hangindent=2\sh@linenumberwidth%
+\textcolor{\shdoc@usernamecolor}{\@shuser}%
+\textcolor{\shdoc@separatorcolor}{\shdoc@separatorsymbol}%
+\textcolor{\shdoc@machinenamecolor}{\@shmachine}%
+\ \ifx&#1&%
+\textcolor{\shdoc@pathcolor}{\shdoc@defaultpath\ }%
\textcolor{\shdoc@indicatorcolor}{\shdoc@indicatorsymbol}
-\else\ignorespaces
-\textcolor{\shdoc@pathcolor}{#1\ }\ignorespaces
-\textcolor{\shdoc@indicatorcolor}{\shdoc@indicatorsymbol}\ignorespaces
-\fi\ \textcolor{\shdoc@textcolor}{#2}
+\else%
+\textcolor{\shdoc@pathcolor}{#1\ }%
+\textcolor{\shdoc@indicatorcolor}{\shdoc@indicatorsymbol}%
+\fi\ \textcolor{\shdoc@textcolor}{#2}%
\stepcounter{shlinenumber}\par
}
+\newlength{\sh@optionboxwidth}
\long\def\shoutput#1#2{
-\ttfamily\noindent\scriptsize
-\ifnum\value{shlinenumber}<10
-\textcolor{\shdoc@textcolor}{0\theshlinenumber}
-\else
-\textcolor{\shdoc@textcolor}{\theshlinenumber}
-\fi
-\normalsize
-\ifx&#1&
-\textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}
-\else
-\fcolorbox{\shdoc@optioncolor}{\shdoc@optioncolor}{\textcolor{\shdoc@textcolor}{[#1]}}
-\begin{tabular}{l l}
-& \textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}
-\end{tabular}
-\fi\par
+\ttfamily\sh@fontcheck\noindent%
+\ifnum\value{shlinenumber}<10%
+\textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}0\theshlinenumber}%
+\settowidth{\sh@linenumberwidth}{%
+\relscale{\sh@lnscale}0\theshlinenumber%
+}%
+\else%
+\textcolor{\shdoc@textcolor}{\relscale{\sh@lnscale}\theshlinenumber}%
+\settowidth{\sh@linenumberwidth}{%
+\relscale{\sh@lnscale}\theshlinenumber%
+}%
+\fi\hspace{\sh@linenumberwidth}%
+\hangindent=2\sh@linenumberwidth%
+\ifx&#1&%
+\textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}%
+\settowidth{\sh@optionboxwidth}{0cm}%
+\else%
+\fcolorbox{\shdoc@optioncolor}%
+{\shdoc@optioncolor}{\textcolor{\shdoc@textcolor}{[#1]}}\ %
+\settowidth{\sh@optionboxwidth}{%
+\fcolorbox{\shdoc@optioncolor}%
+{\shdoc@optioncolor}{\textcolor{\shdoc@textcolor}{[#1]}}\ }%
+\addtolength{\hangindent}{\sh@optionboxwidth}%
+\textcolor{\shdoc@textcolor}{#2}\stepcounter{shlinenumber}%
+\fi\par%
+}
+\let\sh@autoformat\relax%
+\def\shautoformat#1{\gdef\sh@autoformat{#1}}%
+\shautoformat{false}%
+
+\let\sh@autopath\relax%
+\def\shautopath#1{\gdef\sh@autopath{#1}}%
+\shautopath{false}%
+\def\shpath{%
+\immediate\write18{pwd >shpath.tmp 2>&1}%
+\newread\sh@pathfile%
+\openin\sh@pathfile=shpath.tmp%
+\endlinechar=-1%
+\readline\sh@pathfile to \sh@path%
+\sh@path%
+\closein\sh@pathfile
+}
+\def\shread#1#2{%
+\newread\sh@inputfile%
+\openin\sh@inputfile=#2%
+
+\endlinechar=-1% hide the endlinechar (-1 is invalid, thus not printed)
+\begin{shbox}%
+\ifthenelse{\equal{#1}{}}{}% empty: do not print
+{%
+\ifthenelse{\equal{\sh@autopath}{true}}{%
+\shline{\shpath}{#1}%
+}{%
+\ifthenelse{\equal{\sh@autopath}{false}}{}%
+{\typeout{-----------------------------------------------}%
+\typeout{ Package shdoc info: I don't know what you}%
+\typeout{ mean when passing '\sh@autopath' to autopath}%
+\typeout{ and I'm going to ignore it and restore the}%
+\typeout{default 'false'} %
+\typeout{-----------------------------------------------}%
+\shautopath{false}}%
+\shline{}{#1}%
+}%
+}
+\loop\unless\ifeof\sh@inputfile%
+\readline\sh@inputfile to \sh@fileline%
+\ifeof\sh@inputfile% again check of eof prevents last blank line
+\else%
+\shoutput{}{\sh@fileline}%
+\fi%
+\repeat%
+\end{shbox}%
+\closein\sh@inputfile%
+}
+\def\shrun#1{%
+\ifthenelse{\equal{\sh@autoformat}{true}}{%
+\immediate\write18{#1 >shrun.tmp 2>&1}%
+\immediate\write18{./shreformat.sh}%
+\shread{#1}{shrun-formatted.tmp}%
+}{%
+\ifthenelse{\equal{\sh@autoformat}{false}}{}%
+{\typeout{-----------------------------------------------}%
+\typeout{ Package shdoc info: I don't know what you}%
+\typeout{ mean when passing '\sh@autoformat' to autoformat}%
+\typeout{ and I'm going to ignore it and restore the}%
+\typeout{default 'false'}%
+\typeout{-----------------------------------------------}%
+\shautoformat{false}}%
+\immediate\write18{#1 >shrun.tmp 2>&1}%
+\shread{#1}{shrun.tmp}%
+}%
+}%
+\def\shautoread#1#2{%
+\newread\sh@inputfile%
+\openin\sh@inputfile=#2%
+\endlinechar=-1%
+\begin{shbox}
+\ifthenelse{\equal{#1}{}}{%
+}{%
+\ifthenelse{\equal{\sh@autopath}{true}}{%
+\shline{\shpath}{#1}%
+}{%
+\ifthenelse{\equal{\sh@autopath}{false}}{}%
+{\typeout{-----------------------------------------------}%
+\typeout{ Package shdoc info: I don't know what you}%
+\typeout{ mean when passing '\sh@autopath' to autopath}%
+\typeout{ and I'm going to ignore it and restore the}%
+\typeout{default 'false'}%
+\typeout{-----------------------------------------------}%
+\shautopath{false}}%
+\shline{}{#1}%
+}%
+}%
+\loop\unless\ifeof\sh@inputfile%
+\readline\sh@inputfile to \sh@fileline%
+\ifeof\sh@inputfile%
+\else%
+\getnextword[e]{\sh@fileline}%
+\findchars[q]{\thestring}{-}%
+\ifthenelse{\equal{\theresult}{1}}{%
+\shoutput{\thestring}%
+{\stringlength[e]{\thestring}\gobblechars[v]{\sh@fileline}{\theresult}}%
+}{%
+\shoutput{}{\sh@fileline}%
+}%
+\fi%
+\repeat%
+\end{shbox}%
+\closein\sh@inputfile%
+}%
+\def\shautorun#1{
+\ifthenelse{\equal{\sh@autoformat}{true}}{%
+\immediate\write18{#1 >shrun.tmp 2>&1}%
+\immediate\write18{./shreformat.sh}%
+\shautoread{#1}{shrun-formatted.tmp}%
+}{%
+\ifthenelse{\equal{\sh@autoformat}{false}}{}%
+{\typeout{-----------------------------------------------}%
+\typeout{ Package shdoc info: I don't know what you}%
+\typeout{ mean when passing '\sh@autoformat' to autoformat}%
+\typeout{ and I'm going to ignore it and restore the}%
+\typeout{default 'false'}%
+\typeout{-----------------------------------------------}%
+\shautoformat{false}}%
+\immediate\write18{#1 >shrun.tmp 2>&1}%
+\shautoread{#1}{shrun.tmp}%
+}%
+}
+\def\shclearfiles{
+\immediate\write18{rm shrun.tmp; rm shrun-formatted.tmp; rm shpath.tmp}
}
\newmdenv[linecolor=white,backgroundcolor=\shdoc@backgroundcolor,
settings=\setcounter{shlinenumber}{1}]{shbox}