diff options
author | Hans Hagen <pragma@wxs.nl> | 2010-10-14 13:14:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2010-10-14 13:14:00 +0200 |
commit | ce89840000bacc1d01ad2b4a2a799901d825eb12 (patch) | |
tree | 2a87a70772589daeb5649391fe2ff79a95d355db /tex/context | |
parent | 7d23b83135ba030f2cbded0d4637de9b3e5553e5 (diff) | |
download | context-ce89840000bacc1d01ad2b4a2a799901d825eb12.tar.gz |
beta 2010.10.14 13:14
Diffstat (limited to 'tex/context')
-rw-r--r-- | tex/context/base/back-ini.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.mkiv | 3 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/core-env.lua | 46 | ||||
-rw-r--r-- | tex/context/base/core-env.mkiv | 79 | ||||
-rw-r--r-- | tex/context/base/font-ctx.lua | 25 |
7 files changed, 116 insertions, 43 deletions
diff --git a/tex/context/base/back-ini.mkiv b/tex/context/base/back-ini.mkiv index 12c41d169..a3cf2ca54 100644 --- a/tex/context/base/back-ini.mkiv +++ b/tex/context/base/back-ini.mkiv @@ -137,7 +137,7 @@ \def\jobsuffix{pdf} -\ifdefined\resetsystemmode \else +\ifdefined\resetsystemmode \else % can't happen \let\setsystemmode \gobbleoneargument \let\resetsystemmode\gobbleoneargument \fi diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 716dcf694..5cf80f8fc 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2010.10.13 14:39} +\newcontextversion{2010.10.14 13:14} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 03b56943a..fd9251caf 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -85,6 +85,7 @@ %loadmarkfile{node-pag} \loadmarkfile{core-var} +\loadmarkfile{core-env} \loadmarkfile{back-ini} @@ -92,8 +93,6 @@ \loadmarkfile{attr-lay} \loadmarkfile{attr-eff} -\loadmarkfile{core-env} - \loadmarkfile{trac-tex} \loadmarkfile{trac-deb} diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index aa609e378..48f31836c 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2010.10.13 14:39} +\edef\contextversion{2010.10.14 13:14} %D For those who want to use this: diff --git a/tex/context/base/core-env.lua b/tex/context/base/core-env.lua new file mode 100644 index 000000000..0122f6bee --- /dev/null +++ b/tex/context/base/core-env.lua @@ -0,0 +1,46 @@ +if not modules then modules = { } end modules ['core-env'] = { + version = 1.001, + comment = "companion to core-env.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- maybe this will move to the context name space although the +-- plurals are unlikely to clash with future tex primitives +-- +-- if tex.modes['xxxx'] then .... else .... end + +local csname_id, texcount = token.csname_id, tex.count + +local undefined = csname_id("*undefined*crap*") + +tex.modes = { } local modes = { } +tex.constants = { } local constants = { } + +setmetatable(tex.modes, { __index = function(t,k) + local m = modes[k] + if m then + return m() + else + local n = "mode" .. k + if csname_id(n) == undefined then + return false + else + modes[k] = function() return texcount[n] >= 1 end + return texcount[n] >= 1 + end + end +end }) + +setmetatable(tex.constants, { __index = function(t,k) + local m = constants[k] + if m then + return m() + elseif csname_id(k) == undefined then + return false + else + constants[k] = function() return texcount[k] >= 1 end + return texcount[k] >= 1 + end +end }) diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv index 33b9c8607..b5631f151 100644 --- a/tex/context/base/core-env.mkiv +++ b/tex/context/base/core-env.mkiv @@ -13,6 +13,8 @@ \writestatus{loading}{ConTeXt Core Macros / Environments} +\registerctxluafile{core-env}{1.001} + \unprotect %D Modes: @@ -39,68 +41,89 @@ %D considered a permanent disabling on forehand. \def\@mode@{@md@} +\def\@mode@{mode} \def\systemmodeprefix{*} -\def\disabledmode {0} % no chardefs -\def\enabledmode {1} -\def\preventedmode{2} +% todo: check prevent mode, also at the lua end + +\setnewconstant\disabledmode \zerocount +\setnewconstant\enabledmode \plusone +\setnewconstant\preventedmode\plustwo % fast internal ones -\def\setmode #1{\@EA\let\csname\@mode@#1\endcsname\enabledmode } -\def\resetmode#1{\@EA\let\csname\@mode@#1\endcsname\disabledmode} +\def\donewmode#1% + {\@EA\newcount\csname\@mode@#1\endcsname} + +\def\newmode#1% + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi} + +\def\setmode#1% + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi + \csname\@mode@#1\endcsname\enabledmode} + +\def\resetmode#1% + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi + \csname\@mode@#1\endcsname\disabledmode} -\def\setsystemmode #1{\@EA\let\csname\@mode@\systemmodeprefix#1\endcsname\enabledmode } -\def\resetsystemmode#1{\@EA\let\csname\@mode@\systemmodeprefix#1\endcsname\disabledmode} +\def\newsystemmode#1% + {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi} + +\def\setsystemmode#1% + {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi + \csname\@mode@\systemmodeprefix#1\endcsname\enabledmode} + +\def\resetsystemmode#1% + {\ifcsname\@mode@\systemmodeprefix#1\endcsname\else\donewmode{\systemmodeprefix#1}\fi + \csname\@mode@\systemmodeprefix#1\endcsname\disabledmode} % user ones -\def\preventmode{\unprotect\dopreventmode} -\def\enablemode {\unprotect\doenablemode } -\def\disablemode{\unprotect\dodisablemode} +\unexpanded\def\preventmode{\unprotect\dopreventmode} +\unexpanded\def\enablemode {\unprotect\doenablemode } +\unexpanded\def\disablemode{\unprotect\dodisablemode} + +\let\definemode\disablemode % nicer \def\dopreventmode[#1]{\protect\rawprocesscommacommand[#1]\dodopreventmode} \def\doenablemode [#1]{\protect\rawprocesscommacommand[#1]\dodoenablemode } \def\dodisablemode[#1]{\protect\rawprocesscommacommand[#1]\dododisablemode} \def\dodopreventmode#1% - {\@EA\let\csname\@mode@#1\endcsname\preventedmode} + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi + \csname\@mode@#1\endcsname\preventedmode} -\def\dodoenablemode#1% mode can be relax - {\ifcase0\csname\@mode@#1\endcsname\relax - \@EA\let\csname\@mode@#1\endcsname\enabledmode +\def\dodoenablemode#1% we can speed it up by moving the new outside + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi + \ifnum\csname\@mode@#1\endcsname=\preventedmode \else + \csname\@mode@#1\endcsname\enabledmode \fi} \def\dododisablemode#1% - {\ifcase0\csname\@mode@#1\endcsname\or - \@EA\let\csname\@mode@#1\endcsname\disabledmode + {\ifcsname\@mode@#1\endcsname\else\donewmode{#1}\fi + \ifnum\csname\@mode@#1\endcsname=\preventedmode \else + \csname\@mode@#1\endcsname\disabledmode \fi} % handy for mp -\def\booleanmodevalue#1% can be \relax - {\expandafter\ifx\csname\@mode@#1\endcsname\relax - fals% - \else\ifnum0\csname\@mode@#1\endcsname=0 - fals% - \else - tru% - \fi\fi e} +\def\booleanmodevalue#1% + {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname fals\else tru\fi\else fals\fi e} % check macros \newif\ifcheckedmode \def\dodocheckformode#1% - {\ifcase0\csname\@mode@#1\endcsname\or\checkedmodetrue\fi} + {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname\else\checkedmodetrue\fi\fi} \def\docheckformode#1#2#3% will be sped up with a quit {\protect\checkedmodefalse\rawprocesscommacommand[#3]\dodocheckformode \ifcheckedmode\@EA#1\else\@EA#2\fi} \def\dodocheckforallmodes#1% - {\ifcase0\csname\@mode@#1\endcsname\relax\checkedmodefalse\or\or\checkedmodefalse\fi} + {\ifcsname\@mode@#1\endcsname\ifcase\csname\@mode@#1\endcsname\checkedmodefalse\fi\else\checkedmodefalse\fi} \def\docheckforallmodes#1#2#3% will be sped up with a quit {\protect\checkedmodetrue\rawprocesscommacommand[#3]\dodocheckforallmodes @@ -164,7 +187,7 @@ %D Lets now set a mode: -\enablemode[mkiv] \setsystemmode{mkiv} +\enablemode[mkiv] \newsystemmode{mkiv} \setsystemmode{mkiv} %D Setups: @@ -301,7 +324,7 @@ \def\dostartlocalsetupsA {\the\everydefinelocalsetups\dodoubleempty\dostartlocalsetups} % [ ] delimited \def\dostartsetupsA {\the\everydefinesetups \dodoubleempty\dostartsetups} % [ ] delimited - % empty preserves inner {} (is removed by the \@EA{#3}) +% empty preserves inner {} (is removed by the \@EA{#3}) \def\dostartluasetupsB #1 {\the\everydefineluasetups \dodostartluasetups \empty{#1}\empty} % space delimited \def\dostartxmlsetupsB #1 {\the\everydefinexmlsetups \dodostartxmlsetups \empty{#1}\empty} % space delimited diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index e5da6e868..b6c0dd3f3 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -470,20 +470,25 @@ function definers.define(specification) -- -- following calls expect a few properties to be set: -- - specification.lookup = specification.lookup or "file" - specification.specification = "" -- not used - specification.size = specification.size or 655260 - specification.sub = specification.sub or "" - specification.method = specification.method or "*" - specification.detail = specification.detail or "" - specification.resolved = "" - specification.forced = "" - specification.features = { } -- via detail + local lookup, name, sub, method, detail = getspecification(name or "") + -- + specification.name = (name ~= "" and name) or specification.name + -- + specification.lookup = specification.lookup or (lookup ~= "" and lookup) or "file" + specification.size = specification.size or 655260 + specification.sub = specification.sub or (sub ~= "" and sub) or "" + specification.method = specification.method or (method ~= "" and method) or "*" + specification.detail = specification.detail or (detail ~= "" and detail) or "" + -- + specification.specification = "" -- not used + specification.resolved = "" + specification.forced = "" + specification.features = { } -- via detail -- -- we don't care about mathsize textsize goodies fallbacks -- if specification.cs == "" then - specification.cs = nil + specification.cs = nil specification.global = false elseif specification.global == nil then specification.global = false |