From 0e9875dc02be12d84c42ff6458172cfac8cf7e07 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 19 Dec 2011 11:54:31 +0100 Subject: new titlo code; not yet generalized --- .../third/cyrillicnumbers/t-cyrillicnumbers.mkiv | 142 +++++++++++++++++---- 1 file changed, 115 insertions(+), 27 deletions(-) (limited to 'tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv') diff --git a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv index 79a47e6..600bee4 100644 --- a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv +++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv @@ -16,14 +16,29 @@ \unprotect +\startinterface all + \setinterfacevariable {cyrillicnumerals} {cyrillicnumerals} + \setinterfacevariable {Cyrillicnumerals} {Cyrillicnumerals} + \setinterfacevariable {cyrnum} {cyrnum} + \setinterfacevariable {dots} {dots} + \setinterfacevariable {dotsymbol} {dotsymbol} + \setinterfacevariable {penwidth} {penwidth} + \setinterfacevariable {preferhundredk} {preferhundredk} + \setinterfacevariable {titlolocation} {titlolocation} + \setinterfacevariable {titlomode} {titlomode} + \setinterfacevariable {titlospan} {titlospan} + \setinterfacevariable {titlo} {titlo} +\stopinterface + \definenamespace [cyrnum] [ - name=cyrnum, - type=module, - setup=list, - parent=cyrnum, - style=no, - version=hg-tip, - comment=cyrillic numbers, + command=\v!yes, + comment=cyrillic numbers, + \s!name=\v!cyrnum, + \s!parent=\v!cyrnum, + setup=\v!list, + style=\v!no, + type=module, + version=hg-tip, ] \registerctxluafile{cyrillicnumbers} @@ -31,25 +46,25 @@ \def\cyrnumsetvariables{% \startluacode local tc = thirddata.cyrnum - tc.placetitlo = "\cyrnumparameter{titlo}" - tc.titlospan = tonumber("\cyrnumparameter{titlospan}") or false - tc.titlolocation = tc.last_synonyms["\cyrnumparameter{titlolocation}"] and "l" or "m" - tc.drawdots = tc. yes_synonyms["\cyrnumparameter{dots}"] or false - tc.dotsymbol = "\cyrnumparameter{dotsymbol}" + tc.placetitlo = "\cyrnumparameter{\v!titlo}" + tc.titlolocation = tc.last_synonyms["\cyrnumparameter{\v!titlolocation}"] and "l" or "m" + tc.prefer100k = tc. yes_synonyms["\cyrnumparameter{\v!preferhundredk}"] or false + tc.drawdots = tc. yes_synonyms["\cyrnumparameter{\v!dots}"] or false + tc.dotsymbol = "\cyrnumparameter{\v!dotsymbol}" + + local span = "\cyrnumparameter{\v!titlospan}" + local num = tonumber(span) + if num then + tc.titlotype = true + tc.titlospan = num + elseif span == "all" then + tc.titlotype = false + end \stopluacode% } -\appendtoks \cyrnumsetvariables \to \everysetupcyrnum - -\setupcyrnum[ - titlo=mp, % font|mp|no - titlospan=3, % n|all - titlolocation=middle, % final|middle -- only effective if using the font’s titlo - dots=\v!yes, % yes|no - dotsymbol=·, - penwidth=3, - titlomode=5, -] +\appendtoks \setuevalue{\currentcyrnum}{\do_cyrnum[\currentcyrnum]} \to \everydefinecyrnum +\appendtoks \cyrnumsetvariables \to \everysetupcyrnum \startmoduletestsection \ctxlua{thirddata.cyrnum.debug = true} @@ -269,17 +284,90 @@ \let\cyrnumdrawtitlo\cyrnum_titloframe %% for protected context %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% Interfacing with the Lua functions. +%D \subject{Interfacing with the Lua functions} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\def\cyrillicnumerals#1{\ctxcommand{cyrillicnumerals(\number#1)}} -\def\Cyrillicnumerals#1{\ctxcommand{Cyrillicnumerals(\number#1)}} +%D \macros +%D {definecyrnum} +%D +%D User interface to the main conversion routines. The definition +%D macro autogenerates the primary user-level macro, which in turn +%D relies \type{\setupcyrnum} for argument processing (see above on +%D \at{Page}[setupdef]). +%D +%D Example usage: +%D +%D \starttyping +%D \definecyrnum[titlofree] +%D \setupcyrnum [titlofree][titlo=no] +%D \starttext +%D \titlofree{42} +%D \stoptext +%D \stoptyping + +\unexpanded\def\do_cyrnum[#1]{% + \edef\currentcyrnum{#1}% + \dosingleempty\dodo_cyrnum% +} + +\def\dodo_cyrnum[#1]{% + \iffirstargument + \doifassignmentelse{#1}{\setupcyrnum[\currentcyrnum][#1]}\relax + \else + \setupcyrnum + \fi + \dododo_cyrnum% +} + +\def\dododo_cyrnum#1{% + \ctxcommand{cyrillicnumerals(\number#1)}% +} + +%D \macros +%D {setupcyrnum} +%D +%D The \type{\setupcyrnum} and \type{\definecyrnum} macros are +%D autogenerated via the namespace. + +\setupcyrnum[ + \v!dots=\v!yes, % yes|no + \v!dotsymbol=·, + \v!penwidth=.66pt, + \v!preferhundredk=no, + \v!titlolocation=\v!middle, % final|middle -- only effective if using the font’s titlo + \v!titlomode=5, + \v!titlospan=3, % n|all + \v!titlo=\v!mp, % font|mp|no +] + +%D \macros +%D {cyrillicnumerals,Cyrillicnumerals} +%D +%D Conforming to the standard \CONTEXT\ naming scheme as employed +%D with number conversion macros, we define two macros for use with +%D conversions. As there is no definition for uppercase conversion, +%D the macro \type{\Cyrillicnumerals} exists only for compatibility +%D reasons. +%D +%D Also, we setup two corresponding conversions \type{cyr} and +%D \type{Cyr} for use with e.g. enumerations, headings, counters +%D {\italic\letterampersand}c. + +\definecyrnum[\v!cyrillicnumerals] +\definecyrnum[\v!Cyrillicnumerals] \defineconversion[cyrillicnumerals][\cyrillicnumerals] \defineconversion[Cyrillicnumerals][\Cyrillicnumerals] \defineconversion[cyr] [\cyrillicnumerals] \defineconversion[Cyr] [\Cyrillicnumerals] +%D \macros +%D {cyrnum} +%D +%D The default user macro is defined as \type{\cyrnum}. + +\definecyrnum[\v!cyrnum] + \unprotect \endinput -% vi:ft=context:fo=co:ts=4:expandtab:sw=4 +% vi:ft=context:fo=co:ts=2:expandtab:sw=2 -- cgit v1.2.3