diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/meta-tex.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-tex.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/meta-tex.mkiv | 117 |
1 files changed, 113 insertions, 4 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-tex.mkiv b/Master/texmf-dist/tex/context/base/meta-tex.mkiv index e35f9538567..2496440c700 100644 --- a/Master/texmf-dist/tex/context/base/meta-tex.mkiv +++ b/Master/texmf-dist/tex/context/base/meta-tex.mkiv @@ -11,6 +11,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. +\registerctxluafile{meta-tex}{1.001} + \unprotect % Ok, we support this in MkIV because Mojca kept the pressure on. It @@ -47,12 +49,119 @@ % draw \sometxt[framed]{black} rotated 45 ; % \stopMPcode -\unexpanded\def\definetextext[#1]#2{\setvalue{@@st@@[#1]}{#2}\setvalue{@@st@@[#1] }{#2}} % we don't grab spaces after [#1] +% \unexpanded\def\definetextext[#1]#2{\setvalue{@@st@@[#1]}{#2}\setvalue{@@st@@[#1] }{#2}} % we don't grab spaces after [#1] +% \long\def\sometxt #1#{\dosometxt{#1}} % grab optional [args] +% \long\def\dosometxt #1#2{textext.drt("\ifcsname @@st@@#1\endcsname\csname @@st@@#1\endcsname{#2}\else#2\fi")} + +% But Mojca wanted more! Two arguments. +% +% \definetextext[framed]{\framed} +% +% \startMPcode +% draw \sometxt{This is for} rotated 45 ; +% draw \sometxt[framed][ss,16pt]{Mojca's}; +% draw \sometxt[framed]{eyes only!} rotated -45 ; +% \stopMPcode + +% a tex one: +% +% \unexpanded\def\definetextext [#1]#2{\setvalue{@@st@@#1}{#2}} +% \def\sometxt #1#{\dosometxt{#1}} +% \def\dosometxt #1#2{textext.drt("\dodosometxt#1{#2}")} +% +% \unexpanded\def\dodosometxt {\doifnextoptionalelse\dododosometxt\relax} +% \def\dododosometxt [#1]{\dodododosometxt{#1}} +% \def\dodododosometxt #1{\doifnextoptionalelse{\dododododosometxt{#1}}{\getsometxt{#1}}} +% \def\dododododosometxt #1[#2]{\switchtobodyfont[#2]\getsometxt{#1}} +% \def\getsometxt #1#2{\csname @@st@@#1\endcsname{#2}} +% +% or: +% +% \unexpanded\def\dodosometxt {\dodoubleempty\dododosometxt} +% \def\dododosometxt {\ifsecondargument +% \expandafter\dododosometxtA +% \else\iffirstargument +% \expandafter\expandafter\expandafter\dododosometxtB +% \else +% \expandafter\expandafter\expandafter\dododosometxtC +% \fi\fi} +% \def\dododosometxtA[#1][#2]#3{\getsometxt{#1}{\switchtobodyfont[#2]#3}} +% \def\dododosometxtB[#1][#2]#3{\getsometxt{#1}{#3}} +% \def\dododosometxtC[#1][#2]#3{#3} +% \def\getsometxt #1#2{\csname @@st@@#1\endcsname{#2}} +% +% a nicer variant: + +\unexpanded\def\definetextext[#1]% + {\def\currenttextext{#1}% + \dosingleempty\dodefinetextext} + +\def\dodefinetextext + {\iffirstargument + \expandafter\dodefinetextextone + \else + \expandafter\dodefinetextextzero + \fi} -\long\def\sometxt#1#{\dosometxt{#1}} % grab optional [args] +\def\dodefinetextextone {\setvalue{@@st@@one\currenttextext}} +\def\dodefinetextextzero[#1]{\setvalue{@@st@@zero\currenttextext}} -\long\def\dosometxt#1#2% - {textext.drt("\ifcsname @@st@@#1\endcsname\csname @@st@@#1\endcsname{#2}\else#2\fi")} +\def\sometxt#1#% + {\dosometxt{#1}} + +\def\dosometxt#1#2% we need to capture embedded quotes (a bit messy as later on textext is filtered + {textext.drt("\dodosometxt#1{\ctxlua{metapost.escaped(\!!bs#2\!!es)}}")} + +\unexpanded\def\dodosometxt + {\dosingleempty\dododosometxt} + +\def\dododosometxt + {\iffirstargument + \expandafter\dosometxtsome + \else + \expandafter\dosometxtzero + \fi} + +\def\dosometxtsome[#1]% + {\def\currenttextext{#1}% + \csname @@st@@% + \ifcsname @@st@@one#1\endcsname one\else + \ifcsname @@st@@zero#1\endcsname zero\else + none\fi\fi + \endcsname} + +\def\dosometxtzero[#1]% + {} + +\def\@@st@@one {\dosingleempty\do@@st@@one} +\def\do@@st@@one{\csname @@st@@one\currenttextext\endcsname} +\def\@@st@@zero {\csname @@st@@zero\currenttextext\endcsname} +\def\@@st@@none {} + +% \definetextext[framed][#1]#2{\framed[width=4cm]{\switchtobodyfont[#1]#2}} +% \definetextext[simple]{\framed[width=8cm]} +% +% \starttext +% +% \startMPcode +% draw \sometxt{This is for} rotated 45 ; +% draw \sometxt [framed] [ss,16pt] {Mojca's}; +% draw \sometxt[framed]{eyes only!} rotated -45 ; +% draw \sometxt[simple]{Quotes "indeed" work!} rotated 180 ; +% \stopMPcode +% +% \stoptext +% +% a lua one: +% +% \unexpanded\def\definetextext[#1]#2{\setvalue{@@st@@#1}{#2}} +% +% \long\def\sometxt #1#{\dosometxt{#1}} % grab optional [args] +% \long\def\dosometxt #1#2{\ctxlua{metapost.sometxt(\!!bs#1\!!es,\!!bs#2\!!es)}} +% +% \def\sometxta #1{textext.drt("#1")} +% \def\sometxtb #1#2{textext.drt("\getvalue{@@st@@#1}{#2}")} +% \def\sometxtc #1#2#3{textext.drt("\getvalue{@@st@@#1}{\switchtobodyfont[#2]#3}")} % Best use the mp macro instead since it provides positioning. % |