summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keyreader
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-01-13 00:08:31 +0000
committerKarl Berry <karl@freefriends.org>2010-01-13 00:08:31 +0000
commit1af5c8773983ef7a0aa17ab1c46e8ecc5d333bb7 (patch)
treec82a29a0d2e46757d149d5c2aff5bc96e8426413 /Master/texmf-dist/tex/latex/keyreader
parent8ef4b34298b082adaed9714c182beb730e8aafeb (diff)
new latex package keyreader 0.1 (11jan10)
git-svn-id: svn://tug.org/texlive/trunk@16692 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keyreader')
-rw-r--r--Master/texmf-dist/tex/latex/keyreader/keyreader.sty204
1 files changed, 204 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/keyreader/keyreader.sty b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty
new file mode 100644
index 00000000000..f240c803946
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/keyreader/keyreader.sty
@@ -0,0 +1,204 @@
+%+++++++++++++++++++++++++++++++++++++ LICENSE ++++++++++++++++++++++++++++++++++++++%
+% %
+% This is file 'keyreader.sty', version 0.1. %
+% %
+% This package reads multiple keys to be defined by xkeyval.sty. %
+% %
+% This work may be distributed and/or modified under the conditions of the LaTeX %
+% Project Public License, either version 1.3 of this license or any later version. %
+% The latest version of this license is in http://www.latex-project.org/lppl.txt %
+% and version 1.3 or later is part of all distributions of LaTeX version %
+% 2005/12/01 or later. %
+% %
+% The LPPL maintenance status of this software is 'author-maintained'. %
+% %
+% This software is provided 'as it is', without warranty of any kind, either %
+% expressed or implied, including, but not limited to, the implied warranties of %
+% merchantability and fitness for a particular purpose. %
+% %
+% Copyright (c) 2010 Ahmed Musa (a.musa@rocketmail.com). %
+% %
+%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
+
+\begingroup
+\catcode064 11% @
+\catcode123 01% {
+\catcode125 02% }
+\def\x{\endgroup
+ \edef\kr@restorecodes{%
+ \catcode035 \the\catcode035% #
+ \catcode064 \the\catcode064% @
+ \catcode123 \the\catcode123% {
+ \catcode125 \the\catcode125% }
+ \catcode061 \the\catcode061% =
+ }%
+}
+\x
+\@makeother{\=}%
+\catcode035=06% #
+\catcode064=11% @
+\catcode123=01% {
+\catcode125=02% }
+\def\kr@ensurecode#1#2{%
+ \edef\kr@restorecodes{%
+ \kr@restorecodes
+ \catcode#1=\the\catcode#1\relax
+ }%
+ \catcode#1=#2\relax
+}
+\AtEndOfPackage{\kr@restorecodes}
+\kr@ensurecode{044}{12}% ,
+\kr@ensurecode{058}{12}% :
+\kr@ensurecode{059}{12}% ;
+\kr@ensurecode{038}{03}% &
+\ProvidesPackage{keyreader}%
+ [2010/01/01 v0.1 Read multiple keys for the xkeyval parser (AM)]
+\NeedsTeXFormat{LaTeX2e}[1996/12/01]
+\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}[2008/08/13]}
+\protected\long\def\kr@warn#1{\PackageWarningNoLine{keyreader}{#1}}
+\protected\long\def\kr@err#1{\PackageError{keyreader}{#1}{\@ehc}}
+\protected\long\def\kr@afterfi#1\fi{\fi#1}
+\def\kr@CommandListParser#1{%
+ \long\def\define@keylist##1{%
+ \mathchardef\kr@cntb=\z@
+ \kr@readlist##1#1&
+ }%
+ \long\def\cmddefine@keylist##1{%
+ \mathchardef\kr@cntb=\z@%
+ \expandafter\kr@readlist##1#1&
+ }%
+ \long\def\kr@readlist##1#1##2&{%
+ \kr@ifblank{##1}{}%
+ {%
+ \edef\@i{\detokenize{##1}}%
+ \edef\@ii{\detokenize{\stopread}}%
+ \ifx\@i\@ii
+ \mathchardef\kr@cntb=\@ne
+ \stopread##2&
+ \else
+ \kr@define@key##1&
+ \fi
+ }%
+ \ifnum\kr@cntb=\z@
+ \kr@ifblank{##2}{}{\kr@readlist##2&}%
+ \fi
+ }%
+}
+\define@cmdkey[KV]{keyreader}[kr@]{parser}[;]{%
+ \if\kr@parser,\kr@afterfi\kr@err{Parser can't be comma}\fi
+ \kr@CommandListParser{#1}%
+}
+\define@cmdkey[KV]{keyreader}[kr@]{keyprefix}[KV]{}
+\define@cmdkey[KV]{keyreader}[kr@]{keyfamily}[fam]{}
+\define@cmdkey[KV]{keyreader}[kr@]{macroprefix}[mp@]{}
+\DeclareOptionX*{\kr@warn{Unknown option '\CurrentOption' ignored}}
+\ExecuteOptionsX[KV]<keyreader>{parser,keyprefix,keyfamily,macroprefix}
+\ProcessOptionsX*[KV]<keyreader>\relax
+\newcommand\krsetup[1]{\setkeys[KV]{keyreader}{#1}}
+\def\kr@namedef#1{%
+ \ifcsname#1\endcsname
+ \def\reserved@a{#1}%
+ \@notdefinable
+ \else
+ \expandafter\def\csname#1\expandafter\endcsname
+ \fi
+}
+\def\kr@nameuse#1{%
+ \ifcsname#1\endcsname\csname#1\expandafter\endcsname\fi
+}
+\long\def\kr@ifnextchar#1#2#3{% \new@ifnextchar
+ \let\tmp@d=#1\def\tmp@a{#2}\def\tmp@b{#3}%
+ \futurelet\@let@token\kr@ifnch
+}
+\long\def\kr@ifnch{\ifx\@let@token\tmp@d\let\tmp@b\tmp@a\fi\tmp@b}
+\long\def\kr@testopt#1#2{\kr@ifnextchar[{#1}{#1[{#2}]}}
+\long\def\kr@ifstar#1#2{\kr@ifnextchar*{\def\tmp@a*{#1}\tmp@a}{#2}}
+\long\def\kr@ifblank#1{\kr@ifbl@nk#1&&\@secondoftwo\@firstoftwo:}
+\long\def\kr@ifbl@nk#1#2&#3#4#5:{#4}
+\long\def\kr@expandonce#1{\unexpanded\expandafter{#1}}
+\long\def\kr@csexpandonce#1{\expandafter\kr@expandonce\csname#1\endcsname}
+\@ifdefinable\stopread{\long\def\stopread#1&{\long\def\kr@remainder{#1}}}
+\long\def\kr@inputerr#1#2{\kr@err{Erroneous value '#1' for key '#2'}}
+\mathchardef\kr@cnta=\z@\mathchardef\kr@cntb=\z@\mathchardef\kr@cntc=\z@
+\let\kr@altlist\@empty
+\def\kr@define@key#1,#2,#3,#4&{%
+ \begingroup
+ \protected@edef\x{\endgroup
+ \ifcase#1\relax
+ \mathchardef\kr@cntc=\@ne
+ \or
+ \noexpand\define@key[\kr@keyprefix]{\kr@keyfamily}%
+ {#2}[#3]{\kr@expandonce{#4}}%
+ \or
+ \noexpand\define@cmdkey[\kr@keyprefix]{\kr@keyfamily}%
+ [\kr@macroprefix]{#2}[#3]{\kr@expandonce{#4}}%
+ \or
+ \noexpand\define@boolkey+[\kr@keyprefix]{\kr@keyfamily}%
+ [\kr@macroprefix]{#2}[#3]{\kr@expandonce{#4}}%
+ {\unexpanded{\kr@inputerr{##1}{#2}}}%
+ \or
+ \ifx\kr@altlist\@empty
+ \mathchardef\kr@cnta=\@ne
+ \fi
+ \noexpand\define@choicekey*+[\kr@keyprefix]{\kr@keyfamily}{#2}%
+ [\unexpanded{\kr@val\kr@nr}]{\kr@altlist}[#3]%
+ {\kr@expandonce{#4}}{\unexpanded{\kr@inputerr{##1}{#2}}}%
+ \else
+ \mathchardef\kr@cntc=\@ne\relax
+ \fi
+ }\x
+ \ifnum\kr@cnta=\@ne\kr@afterfi
+ \kr@err{'\string\kr@altlist' is empty: choicekey can't be defined.
+ \MessageBreak You need to first define '\string\kr@altlist'
+ \MessageBreak as a nonempty set. It is the list of
+ \MessageBreak alternates values for your choicekey.}%
+ \fi
+ \ifnum\kr@cntc=\@ne\kr@afterfi
+ \kr@err{Unknown key type/identifier '#1'}%
+ \fi
+}
+\def\define@comp@boolkeys{\kr@testopt{\kr@comp@opta}{KV}}
+\def\kr@comp@opta[#1]#2{\kr@testopt{\kr@define@comp@boolkeys[#1]{#2}}{mp@}}
+\def\kr@define@comp@boolkeys[#1]#2[#3]#4[#5]#6#7#8{%
+ \kr@namedef{comp@#2@#4}{\kr@nameuse{if#3#4}\kr@nameuse{#3#6false}\fi}%
+ \kr@namedef{comp@#2@#6}{\kr@nameuse{if#3#6}\kr@nameuse{#3#4false}\fi}%
+ \kr@namedef{func@#2@#4}{#7}%
+ \kr@namedef{func@#2@#6}{#8}%
+ \begingroup\protected@edef\x{\endgroup
+ \unexpanded{\define@boolkey+[#1]{#2}[#3]{#4}[#5]{%
+ \kr@nameuse{comp@#2@#4}\kr@nameuse{func@#2@#4}}%
+ {\kr@inputerr{##1}{#4}}%
+ }%
+ \unexpanded{\define@boolkey+[#1]{#2}[#3]{#6}[#5]{%
+ \kr@nameuse{comp@#2@#6}\kr@nameuse{func@#2@#6}}%
+ {\kr@inputerr{##1}{#6}}%
+ }%
+ }\x
+}
+\def\disabledkeyerr{%
+ \kr@err{Key '\disabledkey' has been disabled.\MessageBreak
+ You can't set or reset it at this late stage.\MessageBreak
+ You should have set it earlier in the\MessageBreak
+ \string\documentclass\space or \string\usepackage}%
+}
+\def\krdisable@keys{\XKV@testoptb\kr@dis@ble@keys}
+\long\def\kr@dis@ble@keys#1{%
+ \XKV@checksanitizeb{#1}\kr@tempa
+ \XKV@for@o\kr@tempa\kr@tempa{%
+ \XKV@ifundefined{\XKV@header\kr@tempa}{%
+ \kr@warn{Key '\kr@tempa' undefined: can't be disabled}%
+ }{%
+ \global\let\disabledkey\kr@tempa
+ }%
+ \XKV@ifundefined{\XKV@header\kr@tempa @default}{%
+ \edef\kr@tempc{\noexpand\XKV@define@key{\kr@tempa}}%
+ }{%
+ \edef\kr@tempc{\noexpand\XKV@define@key{\kr@tempa}[]}%
+ }%
+ \expandafter\kr@tempc\expandafter{\disabledkeyerr}%
+ }%
+}
+
+\endinput
+
+%%% End of file keyreader.sty %%% \ No newline at end of file