diff options
author | Karl Berry <karl@freefriends.org> | 2009-02-08 01:34:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-02-08 01:34:22 +0000 |
commit | 78e0b5cdb7417d4eda384d0f665c9ad93e2dd374 (patch) | |
tree | 76dd113086efe7a4fa05ea72e9cd905efb178c62 /Master/texmf-dist/tex/context | |
parent | 8c1c7db1c85efb2df1308f5e67702ff5f47d8636 (diff) |
context-account update (7feb09)
git-svn-id: svn://tug.org/texlive/trunk@12116 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context')
6 files changed, 402 insertions, 109 deletions
diff --git a/Master/texmf-dist/tex/context/third/account/t-account.mkii b/Master/texmf-dist/tex/context/third/account/t-account.mkii new file mode 100755 index 00000000000..ae4785a9af7 --- /dev/null +++ b/Master/texmf-dist/tex/context/third/account/t-account.mkii @@ -0,0 +1,38 @@ +%D \module
+%D [ file=t-account,
+%D version=2007.01.15, % last change: 2008.02.13
+%D title=\CONTEXT\ User Module,
+%D subtitle=Miscelaneous,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\unprotect
+
+\defineXMLpickup [account] [name=TACCOUNT]
+ {\startACCOUNT
+ [\XMLpar{account}{name}{TACCOUNT}]
+ [calculate=\XMLpar{account}{calculate}{no},
+ left=\XMLpar{account}{left}{},
+ middle=\XMLpar{account}{middle}{},
+ right=\XMLpar{account}{right}{},
+ background=\XMLpar{account}{background}{},
+ rule=\XMLpar{account}{rule}{on},
+ framecolor=\XMLpar{account}{framecolor}{black}]}
+ {\stopACCOUNT}
+
+\defineXMLpickup [debits]
+ \startDEBITS
+ \stopDEBITS
+
+\defineXMLpickup [credits]
+ \startCREDITS
+ \stopCREDITS
+
+\defineXMLsingular [debit] {\debit[\XMLpar{debit}{text}{}]{\XMLpar{debit}{value}{}}}
+
+\defineXMLsingular [credit] {\credit[\XMLpar{credit}{text}{}]{\XMLpar{credit}{value}{}}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/account/t-account.mkiv b/Master/texmf-dist/tex/context/third/account/t-account.mkiv new file mode 100755 index 00000000000..6beb50b3eed --- /dev/null +++ b/Master/texmf-dist/tex/context/third/account/t-account.mkiv @@ -0,0 +1,84 @@ +%D \module
+%D [ file=t-account,
+%D version=2007.01.15, % last change: 2008.02.13
+%D title=\CONTEXT\ User Module,
+%D subtitle=Miscelaneous,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\unprotect
+
+\startxmlsetups xml:account
+ \xmlsetsetup{\xmldocument}{account|debits|credits|debit|credit}{*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:account}
+
+\startxmlsetups account
+
+ \bgroup
+
+ \startcollecting
+
+ \startcollect\startACCOUNT\stopcollect
+ \doifelsenothing{\xmlatt{#1}{name}}
+ {\startcollect[TACCOUNT]\stopcollect}
+ {\startexpandedcollect[\xmlatt{#1}{name}]\stopexpandedcollect}
+ \startcollect[\stopcollect
+ \doifsomething{\xmlatt{#1}{background}}{\startexpandedcollect background=\xmlatt{#1}{background},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{backgroundcolor}}{\startexpandedcollect backgroundcolor=\xmlatt{#1}{backgroundcolor},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{backgroundoffset}}{\startexpandedcollect backgroundoffset=\xmlatt{#1}{backgroundoffset},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{backgroundscreen}}{\startexpandedcollect backgroundscreen=\xmlatt{#1}{backgroundscreen},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{frame}}{\startexpandedcollect frame=\xmlatt{#1}{frame},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{framecolor}}{\startexpandedcollect framecolor=\xmlatt{#1}{framecolor},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{offset}}{\startexpandedcollect offset=\xmlatt{#1}{offset},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{calculate}}{\startexpandedcollect calculate=\xmlatt{#1}{calculate},\stopexpandedcollect}
+ \doifsomething{\xmlatt{#1}{rule}}{\startexpandedcollect rule=\xmlatt{#1}{rule},\stopexpandedcollect}
+ \startcollect]\stopcollect
+
+ \xmlflush{#1}
+
+ \startcollect\stopACCOUNT\stopcollect
+
+ \stopcollecting
+
+ \egroup
+
+\stopxmlsetups
+
+\startxmlsetups debits
+
+ \startcollect\startDEBITS\stopcollect
+ \xmlflush{#1}
+ \startcollect\stopDEBITS\stopcollect
+
+\stopxmlsetups
+
+\startxmlsetups debit
+
+ \startexpandedcollect
+ \noexpand\debit[\xmlatt{#1}{text}]{\xmlatt{#1}{value}}
+ \stopexpandedcollect
+
+\stopxmlsetups
+
+\startxmlsetups credits
+
+ \startcollect\startCREDITS\stopcollect
+ \xmlflush{#1}
+ \startcollect\stopCREDITS\stopcollect
+
+\stopxmlsetups
+
+\startxmlsetups credit
+
+ \startexpandedcollect
+ \noexpand\credit[\xmlatt{#1}{text}]{\xmlatt{#1}{value}}
+ \stopexpandedcollect
+
+\stopxmlsetups
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/account/t-account.tex b/Master/texmf-dist/tex/context/third/account/t-account.tex index a39aa0c2344..afc73faebee 100644 --- a/Master/texmf-dist/tex/context/third/account/t-account.tex +++ b/Master/texmf-dist/tex/context/third/account/t-account.tex @@ -1,11 +1,13 @@ %D \module %D [ file=t-account, -%D version=2007.01.15, +%D version=2007.01.15, % last change: 2009.02.06 %D title=\CONTEXT\ User Module, %D subtitle=Miscelaneous, %D author=Wolfgang Schuster, %D date=\currentdate, -%D copyright=Public Domain] +%D copyright=Wolfgang Schuster, +%D email=schuster.wolfgang@googlemail.com, +%D license=Public Domain] %M \usemodule [account] %M \loadsetups[t-account.xml] @@ -14,7 +16,9 @@ \unprotect -\def\????ac{@@@@ac} % ACcount +\usemodule[floatnumber] + +\def\????ac{@@@@ac} % Account %D This is the second version of my T-Account module. If I want %D to be true I wrote this module the n-th time but the current @@ -28,8 +32,11 @@ %D from the \tex{debit} and \tex{credit} macros. You can output %D the values at the end of the account. -\newcount\!!creditsum -\newcount\!!debitsum +\definefloatnumber[creditvalue][\c!command=\accountparameter\c!numbercommand] +\definefloatnumber[debitvalue] [\c!command=\accountparameter\c!numbercommand] + +\definefloatnumber[creditsum][\c!command=\accountparameter\c!numbercommand] +\definefloatnumber[debitsum] [\c!command=\accountparameter\c!numbercommand] %D The following dimens are needed to save the textwidth in the %D first run with my account parser and feed these values into @@ -96,14 +103,14 @@ \fi \edef\accountwidth {\accountparameter\c!width}% \edef\accountdistance {\accountparameter\c!distance}% - \!!creditsum\zeropoint - \!!debitsum\zeropoint - \def\creditsum{\the\!!creditsum}% - \def\debitsum {\the\!!debitsum}% + \resetfloatnumber[creditsum]% + \resetfloatnumber[debitsum]% + \def\creditsum{\getfloatnumber[creditsum]}% + \def\debitsum {\getfloatnumber[debitsum]}% \doifvaluesomething{\accountparameter\c!bodyfont} {\expanded{\switchtobodyfont [\accountparameter\c!bodyfont]}}% - \parseACCOUNT{#3} + \parseACCOUNT{#3}% \doifnot\accountwidth\v!fit {\global\!!accountwidth\the\dimexpr\accountwidth\relax \global\advance\!!accountwidth-\accountdistance @@ -165,40 +172,7 @@ \egroup \egroup} -%D To draw background for the account environment with commands in -%D \METAPOST\ style and the the \TEX\ style with backslashes you can -%D you se following synonyms in your graphics. The way ti define -%D these commands were taken from \mono{meta-ini.tex}. - -\startMPextensions - color AccountRuleColor; -\stopMPextensions - -\startMPinitializations - AccountRuleColor:=\MPcolor{\accountparameter\c!framecolor}; - % - AccountMaxWidth:=\MPaccountmaxwidth; - AccountMaxHeight:=\MPaccountmaxheight; - % - AccountTextWidth:=\MPaccounttextwidth; - AccountNumberWidth:=\MPaccountnumberwidth; - % - AccountWidth:=\MPaccountwidth; - AccountHeight:=\MPaccountheight; - % - AccountHeaderHeight:=\MPaccountheaderheight; - AccountFooterHeight:=\MPaccountfooterheight; - % - AccountDebitHeight:=\MPaccountdebitheight; - AccountCreditHeight:=\MPaccountcreditheight; - % - AccountRuleWidth:=\the\dimexpr\accountparameter\c!rulethickness\relax; -\stopMPinitializations - - -\defineoverlay - [account] - [\useMPgraphic{account}] +\defineoverlay[account][\useMPgraphic{account}] %D We are not limited to simple rules with \TEX\ primitives. %D The following \METAPOST\ example graphic shows one way to @@ -206,48 +180,49 @@ %D use thus as an example for your own backgrounds. \startuseMPgraphic{account} - AccountNumberGap=0.5*AccountMaxWidth-AccountWidth; + AccountNumberGap := 0.5*\MPaccountmaxwidth-\MPaccountwidth ; + AccountRuleWidth := \the\dimexpr\accountparameter\c!rulethickness\relax ; - z11 = (0,AccountMaxHeight-AccountHeaderHeight) ; - z12 = (AccountMaxWidth,AccountMaxHeight-AccountHeaderHeight) ; + z11 = (0,\MPaccountmaxheight-\MPaccountheaderheight) ; + z12 = (\MPaccountmaxwidth,\MPaccountmaxheight-\MPaccountheaderheight) ; - z21 = (AccountWidth-AccountNumberWidth-AccountNumberGap,AccountMaxHeight-AccountHeaderHeight-AccountDebitHeight) ; - z22 = (0.5*AccountMaxWidth,AccountMaxHeight-AccountHeaderHeight-AccountDebitHeight) ; - z23 = (AccountMaxWidth-AccountNumberWidth-AccountNumberGap,AccountMaxHeight-AccountHeaderHeight-AccountCreditHeight) ; - z24 = (AccountMaxWidth,AccountMaxHeight-AccountHeaderHeight-AccountCreditHeight) ; + z21 = (\MPaccountwidth-\MPaccountnumberwidth-AccountNumberGap,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountdebitheight) ; + z22 = (0.5*\MPaccountmaxwidth,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountdebitheight) ; + z23 = (\MPaccountmaxwidth-\MPaccountnumberwidth-AccountNumberGap,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountcreditheight) ; + z24 = (\MPaccountmaxwidth,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountcreditheight) ; - z31 = (AccountWidth-AccountNumberWidth-AccountNumberGap,AccountFooterHeight) ; - z32 = (0.5*AccountMaxWidth-AccountNumberGap,AccountFooterHeight) ; - z33 = (AccountMaxWidth-AccountNumberWidth-AccountNumberGap,AccountFooterHeight) ; - z34 = (AccountMaxWidth,AccountFooterHeight) ; + z31 = (\MPaccountwidth-\MPaccountnumberwidth-AccountNumberGap,\MPaccountfooterheight) ; + z32 = (0.5*\MPaccountmaxwidth-AccountNumberGap,\MPaccountfooterheight) ; + z33 = (\MPaccountmaxwidth-\MPaccountnumberwidth-AccountNumberGap,\MPaccountfooterheight) ; + z34 = (\MPaccountmaxwidth,\MPaccountfooterheight) ; - z41 = (0.5*AccountMaxWidth,AccountMaxHeight-AccountHeaderHeight) ; - z42 = (0.5*AccountMaxWidth,0) ; + z41 = (0.5*\MPaccountmaxwidth,\MPaccountmaxheight-\MPaccountheaderheight) ; + z42 = (0.5*\MPaccountmaxwidth,0) ; z43 = whatever[z41,z42]=whatever[z22,z23] ; - z44 = (0.5*AccountMaxWidth,AccountFooterHeight) ; + z44 = (0.5*\MPaccountmaxwidth,\MPaccountfooterheight) ; - z51 = (0,AccountFooterHeight) ; - z52 = (AccountNumberWidth,AccountFooterHeight) ; - z53 = (0.5*AccountMaxWidth-AccountNumberWidth-AccountNumberGap,AccountMaxHeight-AccountHeaderHeight-AccountDebitHeight) ; - z54 = (0.5*AccountMaxWidth-AccountNumberGap,AccountMaxHeight-AccountHeaderHeight-AccountDebitHeight) ; + z51 = (0,\MPaccountfooterheight) ; + z52 = (\MPaccountnumberwidth,\MPaccountfooterheight) ; + z53 = (0.5*\MPaccountmaxwidth-\MPaccountnumberwidth-AccountNumberGap,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountdebitheight) ; + z54 = (0.5*\MPaccountmaxwidth-AccountNumberGap,\MPaccountmaxheight-\MPaccountheaderheight-\MPaccountdebitheight) ; - z61 = (AccountWidth-AccountNumberWidth-AccountNumberGap,0) ; - z62 = (0.5*AccountMaxWidth-AccountNumberGap,0) ; - z63 = (AccountMaxWidth-AccountNumberWidth-AccountNumberGap,0) ; - z64 = (AccountMaxWidth,0) ; + z61 = (\MPaccountwidth-\MPaccountnumberwidth-AccountNumberGap,0) ; + z62 = (0.5*\MPaccountmaxwidth-AccountNumberGap,0) ; + z63 = (\MPaccountmaxwidth-\MPaccountnumberwidth-AccountNumberGap,0) ; + z64 = (\MPaccountmaxwidth,0) ; - drawoptions (withpen pencircle scaled AccountRuleWidth withcolor AccountRuleColor) ; + drawoptions (withpen pencircle scaled AccountRuleWidth withcolor \MPcolor{\accountparameter\c!framecolor}) ; linecap := butt ; % no round end of the lines draw z11--z12 ; draw z33--z34 ; - if AccountFooterHeight>0pt: + if \MPaccountfooterheight>0pt: draw z61--z62 ; draw z63--z64 ; fi - if AccountCreditHeight>AccountDebitHeight: + if \MPaccountcreditheight>\MPaccountdebitheight: draw z31--z32 ; draw z41--z44 ; draw z51--z52--z53--z54 ; @@ -256,7 +231,7 @@ draw z41--z43 ; fi - setbounds currentpicture to unitsquare xyscaled (AccountMaxWidth,AccountMaxHeight) ; + setbounds currentpicture to unitsquare xyscaled (\MPaccountmaxwidth,\MPaccountmaxheight) ; \stopuseMPgraphic %D \showsetup{startdebits} @@ -270,13 +245,13 @@ \permitspacesbetweengroups \dosinglegroupempty\dododebit}% \def\dodododebit[##1]##2% - {\setbox\scratchbox\hbox{\doifsomething{##2}{\global\advance\!!debitsum##2}}% - \hbox\!!to\hsize{\strut##1\hfill##2}}% + {\setfloatnumber[debitvalue]{##2}% + \incrementfloatnumber[debitsum]{\rawfloatnumber[debitvalue]}% + \hbox\!!to\hsize{\strut##1\hfill\getfloatnumber[debitvalue]}}% \global\setbox\debitbox\vtop{\hsize\!!accountwidth#1}% \!!debitheight\ht\debitbox \advance\!!debitheight\dp\debitbox \xdef\MPaccountdebitheight{\the\!!debitheight}% - %\xdef\MPaccountdebitwidth {\the\wd\debitbox}% \egroup} %D \showsetup{startcredits} @@ -290,17 +265,19 @@ \permitspacesbetweengroups \dosinglegroupempty\dodocredit}% \def\dododocredit[##1]##2% - {\setbox\scratchbox\hbox{\doifsomething{##2}{\global\advance\!!creditsum##2\relax}}% - \hbox\!!to\hsize{\strut##1\hfill##2}}% + {\setfloatnumber[creditvalue]{##2}% + \incrementfloatnumber[creditsum]{\rawfloatnumber[creditvalue]}% + \hbox\!!to\hsize{\strut##1\hfill\getfloatnumber[creditvalue]}}% \global\setbox\creditbox\vtop{\hsize\!!accountwidth#1}% \!!creditheight\ht\creditbox \advance\!!creditheight\dp\creditbox \xdef\MPaccountcreditheight{\the\!!creditheight}% - %\xdef\MPaccountcreditwidth {\the\wd\creditbox}% \egroup} \long\def\parseACCOUNT#1% {\bgroup + \resetfloatnumber[creditsum]% + \resetfloatnumber[debitsum]% \def\startCREDITS##1\stopCREDITS {\def\credit{\dosingleempty\docredit}% \def\docredit[####1]% @@ -308,11 +285,10 @@ \permitspacesbetweengroups \dosinglegroupempty\dodocredit}% \def\dododocredit[####1]####2% - {\setbox\scratchbox\hbox{####1}\!!dimena\wd\scratchbox - \setbox\scratchbox\hbox{####2}\!!dimenb\wd\scratchbox - \compareaccountdimen\!!credittextwidth\!!dimena - \compareaccountdimen\!!creditnumberwidth\!!dimenb}% - ##1\removeunwantedspaces} + {\incrementfloatnumber[creditsum]{####2}% + \setbox\scratchbox\hbox{####1}\!!dimena\wd\scratchbox + \compareaccountdimen\!!credittextwidth\!!dimena}% + ##1\removeunwantedspaces}% \def\startDEBITS##1\stopDEBITS {\def\debit{\dosingleempty\dodebit}% \def\dodebit[####1]% @@ -320,20 +296,31 @@ \permitspacesbetweengroups \dosinglegroupempty\dododebit}% \def\dodododebit[####1]####2% - {\setbox\scratchbox\hbox{####1}\!!dimena\wd\scratchbox - \setbox\scratchbox\hbox{####2}\!!dimenb\wd\scratchbox - \compareaccountdimen\!!debittextwidth\!!dimena - \compareaccountdimen\!!debitnumberwidth\!!dimenb}% - ##1\removeunwantedspaces} + {\incrementfloatnumber[debitsum]{####2}% + \setbox\scratchbox\hbox{####1}\!!dimena\wd\scratchbox + \compareaccountdimen\!!debittextwidth\!!dimena}% + ##1\removeunwantedspaces}% #1\removeunwantedspaces + \compareACCOUNTnumberwidth \compareaccountdimen\!!debittextwidth\!!credittextwidth - \compareaccountdimen\!!debitnumberwidth\!!creditnumberwidth \global\!!accountwidth\!!debittextwidth - \global\advance\!!accountwidth\!!debitnumberwidth + \global\advance\!!accountwidth\dimexpr\MPaccountnumberwidth\relax \global\advance\!!accountwidth\accountparameter\c!columndistance - \xdef\MPaccounttextwidth {\the\!!debittextwidth}% - \xdef\MPaccountnumberwidth{\the\!!debitnumberwidth}% - \xdef\MPaccountwidth {\the\!!accountwidth}% + \xdef\MPaccounttextwidth{\the\!!debittextwidth}% + \xdef\MPaccountwidth {\the\!!accountwidth}% + \resetfloatnumber[creditsum]% + \resetfloatnumber[debitsum]% + \egroup} + +\def\compareACCOUNTnumberwidth + {\bgroup + \setbox\plusone\hbox{\getfloatnumber[debitsum]}% + \setbox\plustwo\hbox{\getfloatnumber[creditsum]}% + \ifdim\wd\plusone>\wd\plustwo + \xdef\MPaccountnumberwidth{\the\wd\plusone}% + \else + \xdef\MPaccountnumberwidth{\the\wd\plustwo}% + \fi \egroup} \def\compareaccountdimen#1#2% @@ -344,11 +331,6 @@ \def\checkACCOUNT {\bgroup \compareaccountdimen\!!debitheight\!!creditheight - %\ifdim\!!debitheight>\!!creditheight\relax - % \global\!!accountheight\!!debitheight - %\else - % \global\!!accountheight\!!creditheight - %\fi \xdef\MPaccountheight{\the\!!debitheight}% \egroup} @@ -377,7 +359,7 @@ %D \showsetup{setupaccount} \def\setupACCOUNT - {\dodoubleempty\dosetupACCOUNT} + {\dodoubleargument\dosetupACCOUNT} \def\dosetupACCOUNT[#1][#2]% {\getparameters[\????ac#1][#2]% @@ -412,8 +394,10 @@ \c!rulethickness=\linewidth, \c!width=\v!fit, \c!strut=\v!yes, - #2] - \processbetween{#1}{\ACCOUNT[#1]}} + \c!numbercommand=\integerrounding, + #2]% + \processbetween{#1}{\ACCOUNT[#1]}% + \setvalue{\e!setup#1\e!endsetup}{\dodoubleargument\setupACCOUNT[#1]}} \def\ACCOUNT[#1]#2% {\startACCOUNT[#1]#2\stopACCOUNT} @@ -425,16 +409,18 @@ %D \subject{Example} %D %D \startbuffer -%D \startTACCOUNT[left=S,middle=Bilanz,right=H] -%D \startDEBITS -%D \debit [Auto] {2000} -%D \debit [Bus] {5000} -%D \stopDEBITS -%D \startCREDITS -%D \credit [Bank] {1000} -%D \credit [Kasse] {200} -%D \credit [Kasse] {200} -%D \stopCREDITS +%D \startTACCOUNT[left=S,middle=Retained Earnings,right=H] +%D \startTACCOUNT +%D \startDEBITS +%D \debit [Rent Expense] {2200} +%D \debit [Salaries Expense] {1650} +%D \debit [Interest Expense] {3950} +%D \debit [Dividends] {2000} +%D \stopDEBITS +%D \startCREDITS +%D \credit [Sales Revenue] {8500} +%D \credit [Interest Revenue] {1300} +%D \stopCREDITS %D \stopTACCOUNT %D \stopbuffer %D @@ -448,4 +434,6 @@ %D \getbuffer %D \stoplinecorrection +\loadmarkfile{t-account} + \protect \endinput diff --git a/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkii b/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkii new file mode 100755 index 00000000000..18ce3b92af8 --- /dev/null +++ b/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkii @@ -0,0 +1,68 @@ +%D \module
+%D [ file=floatnumber,
+%D version=2008.02.11,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Float Numbers,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\writestatus{loading}{Context User Module / Float Numbers}
+
+\unprotect
+
+\def\@@floatnumber@@v{@@floatnumber@@v}
+\def\@@floatnumber@@s{@@floatnumber@@s}
+
+% namespace is already dealt with in the frontend
+
+% \def\@@floatnumber@@v{v:}
+% \def\@@floatnumber@@s{s:}
+
+\def\makefloatcounter#1%
+ {\global\@EA\let\csname\@@floatnumber@@v#1\endcsname\zeropoint
+ \global\@EA\let\csname\@@floatnumber@@s#1\endcsname\zeropoint}
+
+\def\floatcountervalue#1%
+ {\ifcsname\@@floatnumber@@v#1\endcsname
+ \@EA\withoutpt\the\dimexpr\csname\@@floatnumber@@v#1\endcsname\relax
+ \fi}
+
+\def\plusfloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname+#2\points\relax}}
+
+\def\minusfloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname-#2\points\relax}}
+
+\def\multiplyfloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname*\integerrounding{\@EA\withoutpt\the\dimexpr#2\points*\plushundred\relax}/\plushundred\relax}}
+
+\def\multiplyfloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname*\numexpr\number\dimexpr#2\points\relax*\plushundred/\maxcard\relax/\plushundred\relax}}
+
+\def\dividefloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname*\plushundred/\integerrounding{\@EA\withoutpt\the\dimexpr#2\points*\plushundred\relax}\relax}}
+
+\def\dividefloatcounter#1#2%
+ {\@EA\xdef\csname\@@floatnumber@@v#1\endcsname
+ {\the\dimexpr\csname\@@floatnumber@@v#1\endcsname*\plushundred/\numexpr\number\dimexpr#2\points\relax*\plushundred/\maxcard\relax\relax}}
+
+\let\resetfloatcounter\makefloatcounter
+
+\def\setfloatcounter#1#2%
+ {\global\@EA\xdef\csname\@@floatnumber@@v#1\endcsname{\the\dimexpr#2\points\relax}}
+
+\def\savefloatcounter#1%
+ {\global\@EA\xdef\csname\@@floatnumber@@s#1\endcsname{\the\dimexpr\csname\@@floatnumber@@v#1\endcsname\relax}}
+
+\def\restorefloatcounter#1%
+ {\global\@EA\xdef\csname\@@floatnumber@@v#1\endcsname{\the\dimexpr\csname\@@floatnumber@@s#1\endcsname\relax}}
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkiv b/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkiv new file mode 100755 index 00000000000..bbd5e379164 --- /dev/null +++ b/Master/texmf-dist/tex/context/third/account/t-floatnumber.mkiv @@ -0,0 +1,37 @@ +%D \module
+%D [ file=floatnumber,
+%D version=2008.02.11,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Float Numbers,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\writestatus{loading}{Context User Module / Float Numbers}
+
+\unprotect
+
+\startluacode
+ thirddata = thirddata or { }
+ thirddata.floatnumbers = thirddata.floatnumbers or { }
+ thirddata.floatnumbers.data = thirddata.floatnumbers.data or { }
+ thirddata.floatnumbers.saved = thirddata.floatnumbers.saved or { }
+\stopluacode
+
+\def\makefloatcounter #1{\ctxlua{thirddata.floatnumbers.data ["#1"] = 0 thirddata.floatnumbers.saved["#1"] = 0}}
+\def\setfloatcounter #1#2{\ctxlua{thirddata.floatnumbers.data ["#1"] = #2}}
+
+\def\plusfloatcounter #1#2{\ctxlua{thirddata.floatnumbers.data ["#1"] = thirddata.floatnumbers.data ["#1"] + #2}}
+\def\minusfloatcounter #1#2{\ctxlua{thirddata.floatnumbers.data ["#1"] = thirddata.floatnumbers.data ["#1"] - #2}}
+\def\multiplyfloatcounter#1#2{\ctxlua{thirddata.floatnumbers.data ["#1"] = thirddata.floatnumbers.data ["#1"] * #2}}
+\def\dividefloatcounter #1#2{\ctxlua{thirddata.floatnumbers.data ["#1"] = thirddata.floatnumbers.data ["#1"] / #2}}
+\def\savefloatcounter #1{\ctxlua{thirddata.floatnumbers.saved["#1"] = thirddata.floatnumbers.data ["#1"]}}
+\def\restorefloatcounter #1{\ctxlua{thirddata.floatnumbers.data ["#1"] = thirddata.floatnumbers.saved["#1"]}}
+
+\def\floatcountervalue #1{\ctxlua{tex.print(thirddata.floatnumbers.data["#1"])}}
+
+\let\resetfloatcounter\makefloatcounter
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/account/t-floatnumber.tex b/Master/texmf-dist/tex/context/third/account/t-floatnumber.tex new file mode 100755 index 00000000000..30a1efe0d21 --- /dev/null +++ b/Master/texmf-dist/tex/context/third/account/t-floatnumber.tex @@ -0,0 +1,78 @@ +%D \module +%D [ file=t-floatnumber, +%D version=2008.02.11, +%D title=\CONTEXT\ User Module, +%D subtitle=Float Numbers, +%D author=Wolfgang Schuster, +%D date=\currentdate, +%D copyright=Wolfgang Schuster, +%D email=schuster.wolfgang@googlemail.com, +%D license=Public Domain] + +\writestatus{loading}{Context User Module / Float Numbers} + +\unprotect + +% Commands for floatnumbers: +% +% \definefloatnumber[name] +% \setfloatnumber[name]{value} +% \resetfloatnumber[name] +% \incrementfloatnumber[name]{value} +% \decrementfloatnumber[name]{value} +% \multiplyfloatnumber[name]{value} +% \dividefloatnumber[name]{value} +% \savefloatnumber[name] +% \restorefloatnumber[name] +% \getfloatnumber[name] + +\def\setupfloatnumber + {\dodoubleargument\dosetupfloatnumber} + +\def\dosetupfloatnumber[#1][#2]% + {\getparameters[\s!float\s!number#1][#2]} + +\def\definefloatnumber + {\dodoubleempty\dodefinefloatnumber} + +\def\dodefinefloatnumber[#1][#2]% + {\setupfloatnumber + [#1] + [\c!command=\twodigitrounding, + #2]% + \makefloatcounter{\s!float\s!number#1}} + +\def\setfloatnumber[#1]#2% + {\setfloatcounter{\s!float\s!number#1}{#2}} + +\def\resetfloatnumber[#1]% + {\resetfloatcounter{\s!float\s!number#1}} + +\def\incrementfloatnumber[#1]#2% + {\plusfloatcounter{\s!float\s!number#1}{#2}} + +\def\decrementfloatnumber[#1]#2% + {\minusfloatcounter{\s!float\s!number#1}{#2}} + +\def\multiplyfloatnumber[#1]#2% + {\multiplyfloatcounter{\s!float\s!number#1}{#2}} + +\def\dividefloatnumber[#1]#2% + {\dividefloatcounter{\s!float\s!number#1}{#2}} + +\def\savefloatnumber[#1]% + {\savefloatcounter{\s!float\s!number#1}} + +\def\restorefloatnumber[#1]% + {\restorefloatcounter{\s!float\s!number#1}} + +\def\getfloatnumber[#1]% + {\csname\s!float\s!number#1\c!command\endcsname + {\floatcountervalue{\s!float\s!number#1}}} + +\def\rawfloatnumber[#1]% + {\floatcountervalue{\s!float\s!number#1}} + +\loadmarkfile{t-floatnumber} + +\protect \endinput |