From 69d2352af4b60929b37fc49f3bdb263977016244 Mon Sep 17 00:00:00 2001
From: Marius
We reserve this one as we really want it to be always set (faster).
---ldx]]-- - -names[0], numbers["fontdynamic"] = "fontdynamic", 0 - --[[ldx--We can use the attributes in the range 127-255 (outside user space). These
are only used when no attribute is set at the \TEX\ end which normally
happens in
The
The next code is an adaptation of code from Wolfgang Schuster @@ -62,9 +62,9 @@ local high = Cc("\\high{%s}") * superscript * content local justtext = (1 - somescript)^1 local parser = Cs((csname + lowhigh + highlow + low + high + sign + any)^0) -chemistry.moleculeparser = parser -- can be used to avoid functioncall +chemicals.moleculeparser = parser -- can be used to avoid functioncall -function chemistry.molecule(str) +function chemicals.molecule(str) return lpegmatch(parser,str) end diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua index db1849c5a..fb325ccea 100644 --- a/tex/context/base/chem-str.lua +++ b/tex/context/base/chem-str.lua @@ -1,15 +1,12 @@ if not modules then modules = { } end modules ['chem-str'] = { version = 1.001, comment = "companion to chem-str.mkiv", - author = "Hans Hagen and Alan Braslau", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", copyright = "PRAGMA ADE / ConTeXt Development Team", license = "see context related readme files" } --- The original \PPCHTEX\ code was written in pure \TEX\, although later we made --- the move from \PICTEX\ to \METAPOST\. The current implementation is a mix between --- \TEX\, \LUA\ and \METAPOST. Although the first objective is to get a compatible --- but better implementation, later versions might provide more, +-- This module in incomplete and experimental. -- We can push snippets into an mp instance. @@ -29,12 +26,12 @@ local P, R, S, C, Cs, Ct, Cc = lpeg.P, lpeg.R, lpeg.S, lpeg.C, lpeg.Cs, lpeg.Ct, local variables = interfaces.variables local context = context -chemistry = chemistry or { } -local chemistry = chemistry +chemicals = chemicals or { } +local chemicals = chemicals -chemistry.instance = "metafun" -- "ppchtex" -chemistry.format = "metafun" -chemistry.structures = 0 +chemicals.instance = "metafun" -- "ppchtex" +chemicals.format = "metafun" +chemicals.structures = 0 local remapper = { ["+"] = "p", @@ -55,9 +52,7 @@ local common_keys = { mid = "fixed", mids = "fixed", midz = "text", z = "text", rz = "text", mrz = "text", prz = "text", crz = "text", rt = "text", rtt = "text", rbt = "text", zt = "text", zn = "number", - zbt = "text", zbn = "number", ztt = "text", ztn = "number", - mov = "transform", rot = "transform", adj = "transform", sub = "transform", - off = "transform", + mov = "transform", rot = "transform", adj = "transform", dir = "transform", sub = "transform", } local front_keys = { @@ -65,11 +60,9 @@ local front_keys = { sb = "line", msb = "line", psb = "line", r = "line", pr = "line", mr = "line", z = "text", mrz = "text", prz = "text", - zt = "text", zn = "number", } local one_keys = { - b = "line", msb = "line", psb = "line", sb = "line", db = "line", tb = "line", ep = "line", es = "line", ed = "line", et = "line", sd = "line", ldd = "line", rdd = "line", @@ -88,16 +81,15 @@ local syntax = { one = { n = 1, max = 8, keys = one_keys, align = { - -- z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, - -- z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, + z = { { "r", "r_b", "b", "l_b", "l", "l_t", "t", "r_t" } }, +--~ z = { { "r", "r", "b", "l", "l", "l", "t", "r" } }, } }, three = { n = 3, max = 3, keys = common_keys, align = { mrz = { { "r","b","l" }, { "b","l","t" }, { "l","t","r" }, { "t","r","b" } }, - rz = { { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" }, { "auto","auto","auto" } }, - -- rz = { { "r_t","r_b","l" }, { "r_b","l_b","t" }, { "l_b","l_t","r" }, { "l_t","r_t","b" } }, + rz = { { "r","l_b","l_t" }, { "b","l_t","r_t" }, { "l","r_t","r_b" }, { "t","r_b","l_b" } }, prz = { { "r","l","t" }, { "b","t","r" }, { "l","r","b" }, { "t","b","l" } }, } }, @@ -105,8 +97,7 @@ local syntax = { n = 4, max = 4, keys = common_keys, align = { mrz = { { "t","r","b","l" }, { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" } }, - rz = { { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" }, { "auto","auto","auto","auto" } }, - -- rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, + rz = { { "r_t","r_b","l_b","l_t" }, { "r_b","l_b","l_t","r_t" }, { "l_b","l_t","r_t","r_b" }, { "l_t","r_t","r_b","l_b" } }, prz = { { "r","b","l","t" }, { "b","l","t","r" }, { "l","t","r","b" }, { "t","r","b","l" } }, } }, @@ -114,8 +105,7 @@ local syntax = { n = 5, max = 5, keys = common_keys, align = { mrz = { { "t","r","b","b","l" }, { "r","b","l","l","t" }, { "b","l","t","r","r" }, { "l","t","r","r","b" } }, - rz = { { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, + rz = { { "r","r","b","l","t" }, { "b","b","l","t","r" }, { "l","l","t","r","b" }, { "t","t","r","b","l" } }, prz = { { "r","b","l","t","t" }, { "b","l","t","r","r" }, { "l","t","r","b","b" }, { "t","r","b","l","l" } }, } }, @@ -123,8 +113,7 @@ local syntax = { n = 6, max = 6, keys = common_keys, align = { mrz = { { "t","t","r","b","b","l" }, { "r","b","b","l","t","t" }, { "b","b","l","t","t","r" }, { "l","t","t","r","b","b" } }, - rz = { { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, + rz = { { "r","r","b","l","l","t" }, { "b","b","l","t","t","r" }, { "l","l","t","r","r","b" }, { "t","t","r","b","b","l" } }, prz = { { "r","b","l","l","t","r" }, { "b","l","t","t","r","b" }, { "l","t","r","r","b","l" }, { "t","r","b","b","l","t" } }, } }, @@ -132,8 +121,7 @@ local syntax = { n = 8, max = 8, keys = common_keys, align = { -- todo mrz = { { "t","r","r","b","b","l","l","t" }, { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" } }, - rz = { { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" }, { "auto","auto","auto","auto","auto","auto","auto","auto" } }, - -- rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, + rz = { { "r","r","b","b","l","l","t","t" }, { "b","b","l","l","t","t","r","r" }, { "l","l","t","t","r","r","b","b" }, { "t","t","r","r","b","b","l","l" } }, prz = { { "r","b","b","l","l","t","t","r" }, { "b","l","l","t","t","r","r","b" }, { "l","t","t","r","r","b","b","l" }, { "t","r","r","b","b","l","l","t" } }, } }, @@ -159,11 +147,11 @@ local syntax = { local definitions = { } -function chemistry.undefine(name) +function chemicals.undefine(name) definitions[lower(name)] = nil end -function chemistry.define(name,spec,text) +function chemicals.define(name,spec,text) name = lower(name) local dn = definitions[name] if not dn then dn = { } definitions[name] = dn end @@ -174,7 +162,7 @@ function chemistry.define(name,spec,text) end local metacode, variant, keys, bonds, max, txt, textsize, rot, pstack -local molecule = chemistry.molecule -- or use lpegmatch(chemistry.moleculeparser,...) +local molecule = chemicals.molecule -- or use lpegmatch(chemicals.moleculeparser,...) local function fetch(txt) local st = stack[txt] @@ -208,46 +196,35 @@ local text = (equal * C(P(1)^0)) + Cc(false) local pattern = (amount + Cc(1)) * - Cs(operation/lower) * - Cs(special/lower) * ( --- operation * --- special * ( + operation * + special * ( range * Cc(false) * text + Cc(false) * Cc(false) * set * text + single * Cc(false) * Cc(false) * text + Cc(false) * Cc(false) * Cc(false) * text ) --- local n, operation, index, upto, set, text = lpegmatch(pattern,"RZ1357") +--~ local n, operation, index, upto, set, text = lpegmatch(pattern,"RZ1357") --- print(lpegmatch(pattern,"RZ=x")) -- 1 RZ false false false x --- print(lpegmatch(pattern,"RZ1=x")) -- 1 RZ 1 false false x --- print(lpegmatch(pattern,"RZ1..3=x")) -- 1 RZ 1 3 false x --- print(lpegmatch(pattern,"RZ13=x")) -- 1 RZ false false table x +--~ print(lpegmatch(pattern,"RZ=x")) 1 RZ false false false x +--~ print(lpegmatch(pattern,"RZ1=x")) 1 RZ 1 false false x +--~ print(lpegmatch(pattern,"RZ1..3=x")) 1 RZ 1 3 false x +--~ print(lpegmatch(pattern,"RZ13=x")) 1 RZ false false table x local function process(spec,text,n,rulethickness,rulecolor,offset) insert(stack,{ spec=spec, text=text, n=n }) local txt = #stack local m = #metacode for i=1,#spec do - local step = spec[i] - local s = lower(step) + local s = spec[i] local d = definitions[s] if d then - if trace_structure then - report_chemistry("%s => definition: %s",step,s) - end for i=1,#d do local di = d[i] process(di.spec,di.text,1,rulethickness,rulecolor) end else - local rep, operation, special, index, upto, set, text = lpegmatch(pattern,step) - if trace_structure then - local set = set and concat(set," ") or "-" - report_chemistry("%s => rep: %s, operation: %s, special: %s, index: %s, upto: %s, set: %s, text: %s", - step,rep or "-",operation or "-",special and special ~= "" or "-",index or "-",upto or "-",set or "-",text or "-") - end + local rep, operation, special, index, upto, set, text = lpegmatch(pattern,s) if operation == "pb" then insert(pstack,variant) m = m + 1 ; metacode[m] = syntax.pb.direct @@ -362,8 +339,7 @@ local function process(spec,text,n,rulethickness,rulecolor,offset) if not t then txt, t = fetch(txt) end if t then t = molecule(processor_tostring(t)) - m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"\\chemicaltext{%s}");',operation,bonds,index,t) - -- m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) + m = m + 1 ; metacode[m] = format('chem_%s_zero("\\chemicaltext{%s}");',operation,t) end elseif index then local t = text @@ -412,8 +388,8 @@ end -- -- rulethickness in points -function chemistry.start(settings) - chemistry.structures = chemistry.structures + 1 +function chemicals.start(settings) + chemicals.structures = chemicals.structures + 1 local textsize, rulethickness, rulecolor = settings.size, settings.rulethickness, settings.rulecolor local width, height, scale, offset = settings.width or 0, settings.height or 0, settings.scale or "medium", settings.offset or 0 local l, r, t, b = settings.left or 0, settings.right or 0, settings.top or 0, settings.bottom or 0 @@ -469,73 +445,63 @@ function chemistry.start(settings) scale = 0.75 * scale/625 -- metacode[#metacode+1] = format("chem_start_structure(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) ;", - chemistry.structures, + chemicals.structures, l/25, r/25, t/25, b/25, scale, tostring(settings.axis == variables.on), tostring(width), tostring(height), tostring(offset) ) -- - -- variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } - variant, keys, bonds, stack, rot, pstack = "one", { }, 1, { }, 1, { } + variant, keys, bonds, stack, rot, pstack = "six", { }, 6, { }, 1, { } end -function chemistry.stop() +function chemicals.stop() metacode[#metacode+1] = "chem_stop_structure ;" -- local mpcode = concat(metacode,"\n") if trace_structure then report_chemistry("metapost code:\n%s", mpcode) end - metapost.graphic(chemistry.instance,chemistry.format,mpcode) + metapost.graphic(chemicals.instance,chemicals.format,mpcode) metacode = nil end -function chemistry.component(spec,text,settings) +function chemicals.component(spec,text,settings) rulethickness, rulecolor, offset = settings.rulethickness, settings.rulecolor --- local spec = settings_to_array(lower(spec)) - local spec = settings_to_array(spec) + local spec = settings_to_array(lower(spec)) local text = settings_to_array(text) metacode[#metacode+1] = "chem_start_component ;" process(spec,text,1,rulethickness,rulecolor) metacode[#metacode+1] = "chem_stop_component ;" end -statistics.register("chemical formulas", function() - if chemistry.structures > 0 then - return format("%s chemical structure formulas",chemistry.structures) -- no timing needed, part of metapost - end -end) - --- interfaces - -commands.undefinechemical = chemistry.undefine -commands.definechemical = chemistry.define -commands.startchemical = chemistry.start -commands.stopchemical = chemistry.stop -commands.chemicalcomponent = chemistry.component - --- todo: top / bottom - local inline = { ["single"] = "\\chemicalsinglebond", ["-"] = "\\chemicalsinglebond", - ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", -- also =? and unicode triple? + ["double"] = "\\chemicaldoublebond", ["--"] = "\\chemicaldoublebond", ["triple"] = "\\chemicaltriplebond", ["---"] = "\\chemicaltriplebond", ["gives"] = "\\chemicalgives", ["->"] = "\\chemicalgives", ["equilibrium"] = "\\chemicalequilibrium", ["<->"] = "\\chemicalequilibrium", ["mesomeric"] = "\\chemicalmesomeric", ["<>"] = "\\chemicalmesomeric", - ["plus"] = "\\chemicalplus", ["+"] = "\\chemicalplus", - ["minus"] = "\\chemicalminus", - ["space"] = "\\chemicalspace", + ["plus"] = "\\chemicalsplus", ["+"] = "\\chemicalsplus", + ["minus"] = "\\chemicalsminus", + ["space"] = "\\chemicalsspace", } -function commands.inlinechemical(spec) +-- todo: top / bottom + +function chemicals.inline(spec) local spec = settings_to_array(spec) for i=1,#spec do local s = spec[i] local inl = inline[lower(s)] if inl then - context(inl) -- could be a fast context.sprint + context(inl) else context.chemicalinline(molecule(s)) end end end + +statistics.register("chemical formulas", function() + if chemicals.structures > 0 then + return format("%s chemical structure formulas",chemicals.structures) -- no timing needed, part of metapost + end +end) diff --git a/tex/context/base/chem-str.mkiv b/tex/context/base/chem-str.mkiv index c4b03dd1e..1d60a293e 100644 --- a/tex/context/base/chem-str.mkiv +++ b/tex/context/base/chem-str.mkiv @@ -2,7 +2,7 @@ %D [ file=chem-ini, %D version=2009.05.13, %D subtitle=Chemistry, -%D author=Hans Hagen \& Alan Braslau, +%D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C @@ -10,10 +10,8 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D The original \PPCHTEX\ code was written in pure \TEX\, although later we made -%D the move from \PICTEX\ to \METAPOST\. The current implementation is a mix between -%D \TEX\, \LUA\ and \METAPOST. Although the first objective is to get a compatible -%D but better implementation, later versions might provide more, +%D This module in incomplete and experimental. Eventually this code +%D will replace \PPCHTEX. \writestatus{loading}{ConTeXt Chemistry Macros / Structure} @@ -28,24 +26,24 @@ % Here we use chemicalformula instead, so no longer a mix: % % \startchemicalformula -% \chemical{2H_2}{top}{bottom} +% \chemical{H_2}{top}{bottom} % \chemical{PLUS}{top}{bottom} -% \chemical{O_2}{top}{bottom} +% \chemical{O}{top}{bottom} % \chemical{GIVES}{top}{bottom} -% \chemical{2H_2O}{top}{bottom} +% \chemical{H_2O}{top}{bottom} % \stopchemicalformula % % \startchemicalformula -% \chemical{2H_2} +% \chemical{H_2} % \chemical{PLUS} -% \chemical{O_2} +% \chemical{O} % \chemical{GIVES} -% \chemical{2H_2O} +% \chemical{H_2O} % \stopchemicalformula % % The inline variant has only one argument: % -% \chemical{2H_2,PLUS,O_2,GIVES,2H_2O} +% \chemical{H_2,PLUS,O,GIVES,H_2O} % todo: seven | eight | frontsix | fontfive | carbon | newmans | chair @@ -60,17 +58,11 @@ \let\setupchemicals\setupchemical -%D We use a dedicated framed macro instead of inheriting one. This is both -%D a historical and practical reason (like shared keys with different meaning -%D that could clash, e.g.\ align). - -\defineframed - [\??chemicalframed] - [\c!align=\v!normal, - \c!strut=\v!no] - \unexpanded\def\setupchemicalframed - {\setupframed[\??chemicalframed]} + {\dosingleempty\dosetupchemicalframed} + +\def\dosetupchemicalframed + {\getparameters[\??chemicalframed]} \unexpanded\def\definechemical % is global (so we don't use the commandhandler) {\dosingleargument\chem_define} @@ -79,7 +71,7 @@ {\startnointerference \edef\currentdefinedchemical{#1}% \let\chemical\chem_chemical_nested - \ctxcommand{undefinechemical("#1")}% + \ctxlua{chemicals.undefine("#1")}% #2% flush \stopnointerference} @@ -87,7 +79,7 @@ {\dodoubleempty\chem_chemical_nested_indeed} \def\chem_chemical_nested_indeed[#1][#2]% - {\ctxcommand{definechemical("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} + {\ctxlua{chemicals.define("\currentdefinedchemical",\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es)}} % chemical symbols @@ -98,15 +90,20 @@ {\setvalue{\??chemicalsymbol#1}{#2}} \unexpanded\def\chemicalsymbol[#1]% - {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname#1\else\s!unknown\fi\endcsname} + {\csname\??chemicalsymbol\ifcsname\??chemicalsymbol#1\endcsname\s!unknown\else#1\fi\endcsname} -\definechemicalsymbol[\s!unknown][] % \char"FFFD empty +\definechemicalsymbol[\s!unknown][] % empty % size (small medium big) \edef\chemicaltoplocation{t} \edef\chemicalbotlocation{b} +% \unexpanded\def\chemicaltext#1% in ppchtex we had a more clever alignment +% {\usechemicalstyleandcolor\c!style\c!color +% \strut +% #1} % maybe also \setstrut + \unexpanded\def\chemicaltext#1% {\mathematics {\usechemicalstyleandcolor\c!style\c!color @@ -150,7 +147,7 @@ \fi\fi \the\everystructurechemical \setbox\b_chem_result\hbox\bgroup - \ctxcommand{startchemical { + \ctxlua{chemicals.start { width = "\chemicalparameter\c!width", height = "\chemicalparameter\c!height", left = \chemicalparameter\c!left, @@ -165,7 +162,7 @@ \unexpanded\def\stopchemical {\stopnointerference - \ctxcommand{stopchemical()}% + \ctxlua{chemicals.stop()}% \egroup \d_chem_width \wd\b_chem_result \d_chem_height\ht\b_chem_result @@ -174,16 +171,15 @@ \doifelsenothing{\chemicalparameter\c!frame}\chem_framed_nop\chem_framed_yes \egroup} -\unexpanded\def\chem_framed_yes - {\localframedwithsettings +\def\chem_framed_yes + {\localframed% [\??chemicalframed]% - [\c!frame=\chemicalparameter\c!frame]% - {\vbox{\box\b_chem_result\vss}}} % remove depth + [\c!frame=\chemicalparameter\c!frame,\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth -\unexpanded\def\chem_framed_nop - {\directlocalframed +\def\chem_framed_nop + {\localframed% [\??chemicalframed]% - {\vbox{\box\b_chem_result\vss}}} % remove depth + [\c!align=\v!normal,\c!strut=\v!no]{\vbox{\box\b_chem_result\vss}}} % remove depth \let\startstructurechemical\startchemical \let\stopstructurechemical \stopchemical @@ -204,14 +200,14 @@ \def\strc_chem_indeed_three[#1][#2][#3]% {\writestatus\m!chemicals{hyperlinked chemicals not yet supported}% todo reference, for the moment ignored - \ctxcommand{chemicalcomponent(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way + \ctxlua{chemicals.component(\!!bs#2\!!es, \!!bs\detokenize{#3}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points rulecolor = "\MPcolor{\chemicalparameter\c!rulecolor}" % we can precalculate this for speedup } ) }% \ignorespaces} \def\strc_chem_indeed_two[#1][#2]% - {\ctxcommand{chemicalcomponent(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way + {\ctxlua{chemicals.component(\!!bs#1\!!es,\!!bs\detokenize{#2}\!!es, { % maybe also pass first two args this way rulethickness = "\the\dimexpr\chemicalparameter\c!rulethickness\relax", % todo: scaled points rulecolor = "\MPcolor{\chemicalparameter\c!rulecolor}" % we can precalculate this for speedup } ) }% @@ -293,8 +289,8 @@ \def\chem_arrow_construct#1#2#3% {\enspace \mathematics{#1% - {\strut\hbox \s!spread 2\emwidth{\hss\ctxcommand{inlinechemical(\!!bs#3\!!es)}\hss}}% {\strut\hbox \s!spread 2em{\hss#3\hss}}}% - {\strut\hbox \s!spread 2\emwidth{\hss\ctxcommand{inlinechemical(\!!bs#2\!!es)}\hss}}}% {\strut\hbox \s!spread 2em{\hss#2\hss}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#2\!!es)}\hss}}% {\strut\hbox \!!spread 2em{\hss#2\hss}}% + {\strut\hbox \!!spread 2\emwidth{\hss\ctxlua{chemicals.inline(\!!bs#3\!!es)}\hss}}}% {\strut\hbox \!!spread 2em{\hss#3\hss}}}% \enspace} % special macros (probably needs some more work) @@ -432,9 +428,9 @@ \usechemicalstyleandcolor\c!style\c!color \ifthirdargument \ifsecondargument - \halign{\aligntab\hss\alignmark\alignmark\hss\cr#2\cr\molecule{#1}\cr#3\cr}% + \halign{&\hss##\hss\cr#2\cr\molecule{#1}\cr#3\cr}% \else - \halign{\aligntab\hss\alignmark\alignmark\hss \cr\molecule{#1}\cr#2\cr}% + \halign{&\hss##\hss\cr\molecule{#1}\cr#2\cr}% \fi \else \hbox{\molecule{#1}}% @@ -444,30 +440,30 @@ \unexpanded\def\inlinechemical#1% {\dontleavehmode - \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxcommand{inlinechemical(\!!bs#1\!!es)}}} + \hbox{\usechemicalstyleandcolor\c!style\c!color\ctxlua{chemicals.inline(\!!bs#1\!!es)}}} \unexpanded\def\chemicalbondrule - {\hbox{\vrule\s!height.75\exheight\s!depth-\dimexpr.75\exheight-\linewidth\relax\s!width\emwidth\relax}} + {\hbox{\vrule\!!height.75ex\!!depth-\dimexpr.75ex-\linewidth\relax\!!width1em\relax}} \definechemicalsymbol[i:space] [\enspace\quad\enspace] \definechemicalsymbol[i:plus] [\enspace\mathematics{+}\enspace] \definechemicalsymbol[i:minus] [\enspace\mathematics{-}\enspace] \definechemicalsymbol[i:gives] [\enspace\mathematics{\xrightarrow{}{}}\enspace] -\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightoverleftarrow{}{}}\enspace] +\definechemicalsymbol[i:equilibrium] [\enspace\mathematics{\xrightpverleftarrow{}{}}\enspace] \definechemicalsymbol[i:mesomeric] [\enspace\mathematics{\xleftrightarrow{}{}}\enspace] \definechemicalsymbol[i:single] [\chemicalbondrule] -\definechemicalsymbol[i:double] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] -\definechemicalsymbol[i:triple] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] +\definechemicalsymbol[i:tripple] [\hbox{\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] +\definechemicalsymbol[i:double] [\hbox{\chemicalbondrule\hskip-1em\lower.5ex\chemicalbondrule\hskip-1em\raise.5ex\chemicalbondrule}] \unexpanded\def\chemicalsinglebond {\chemicalsymbol[i:single]} -\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:double]} -\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:triple]} +\unexpanded\def\chemicaldoublebond {\chemicalsymbol[i:tripple]} +\unexpanded\def\chemicaltriplebond {\chemicalsymbol[i:double]} \unexpanded\def\chemicalgives {\chemicalsymbol[i:gives]} \unexpanded\def\chemicalmesomeric {\chemicalsymbol[i:mesomeric]} \unexpanded\def\chemicalequilibrium{\chemicalsymbol[i:equilibrium]} -\unexpanded\def\chemicalplus {\chemicalsymbol[i:plus]} -\unexpanded\def\chemicalminus {\chemicalsymbol[i:minus]} -\unexpanded\def\chemicalspace {\chemicalsymbol[i:space]} +\unexpanded\def\chemicalsplus {\chemicalsymbol[i:plus]} +\unexpanded\def\chemicalsminus {\chemicalsymbol[i:minus]} +\unexpanded\def\chemicalsspace {\chemicalsymbol[i:space]} \unexpanded\def\chemicalinline #1{#1} % display @@ -495,133 +491,61 @@ \setfalse\c_chem_has_bot} \unexpanded\def\stopchemicalformula - {\tabskip\emwidth\relax + {\tabskip1em\relax \nointerlineskip \ifconditional\c_chem_has_top \ifconditional\c_chem_has_bot - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_top\cr\the\t_chem_mid\cr}% \fi \else \ifconditional\c_chem_has_bot - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr\the\t_chem_bot\cr}% \else - \halign{\aligntab\hss\usechemicalstyleandcolor\c!style\c!color\alignmark\alignmark\hss\cr\the\t_chem_mid\cr}% + \halign{&\hss\usechemicalstyleandcolor\c!style\c!color##\hss\cr\the\t_chem_mid\cr}% \fi \fi \egroup} -% for the moment we have a special set - -\definechemicalsymbol[d:space] [\enspace\quad\enspace] -\definechemicalsymbol[d:plus] [\enspace+\enspace] -\definechemicalsymbol[d:minus] [\enspace-\enspace] -\definechemicalsymbol[d:gives] [\rightarrowfill] % \chem_arrow_construct\xrightarrow -\definechemicalsymbol[d:equilibrium] [\rightoverleftarrowfill] % \chem_arrow_construct\xrightoverleftarrow -\definechemicalsymbol[d:mesomeric] [\leftarrowfill] % \chem_arrow_construct\xleftrightarrow -\definechemicalsymbol[d:opencomplex] [\mathematics{\Bigg[}] % not yet ok -\definechemicalsymbol[d:closecomplex][\mathematics{\Bigg]}] % not yet ok - -\definechemicalsymbol[d:SPACE] [{\chemicalsymbol[d:space]}] -\definechemicalsymbol[d:PLUS] [{\chemicalsymbol[d:plus]}] -\definechemicalsymbol[d:MINUS] [{\chemicalsymbol[d:minus]}] -\definechemicalsymbol[d:GIVES] [{\chemicalsymbol[d:gives]}] -\definechemicalsymbol[d:EQUILIBRIUM] [{\chemicalsymbol[d:equilibrium]}] -\definechemicalsymbol[d:MESOMERIC] [{\chemicalsymbol[d:mesomeric]}] -\definechemicalsymbol[d:OPENCOMPLEX] [{\chemicalsymbol[d:opencomplex]}] -\definechemicalsymbol[d:CLOSECOMPLEX][{\chemicalsymbol[d:closecomplex]}] - \unexpanded\def\formulachemical {\relax\dotriplegroupempty\chem_formula} -% \def\chem_formula#1#2#3% we could do hboxes and measure -% {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname -% \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% -% \else -% \ifthirdargument -% \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% -% \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% -% \else\ifsecondargument -% \chem_formula_top_nop -% \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% -% \else -% \chem_formula_top_nop -% \chem_formula_bot_nop -% \fi\fi -% \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}\aligntab}% -% \fi} - \def\chem_formula#1#2#3% we could do hboxes and measure - {\ifthirdargument - \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% - \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% - \else\ifsecondargument - \chem_formula_top_nop - \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% + {\ifcsname\??chemicalsymbol\detokenize{#1}\endcsname + \t_chem_mid\expandafter{\the\t_chem_mid\chem_formula_mid{#1}{#2}{#3}}% \else - \chem_formula_top_nop - \chem_formula_bot_nop - \fi\fi - \ifcsname\??chemicalsymbol d:\detokenize{#1}\endcsname - \t_chem_mid\expandafter{\the\t_chem_mid\chemicalsymbol[d:#1]\aligntab}% - \else - \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}\aligntab}% + \ifthirdargument + \doifelsenothing{#2}\chem_formula_top_nop{\chem_formula_top_yes{#2}}% + \doifelsenothing{#3}\chem_formula_bot_nop{\chem_formula_bot_yes{#3}}% + \else\ifsecondargument + \chem_formula_top_nop + \doifelsenothing{#2}\chem_formula_bot_nop{\chem_formula_bot_yes{#2}}% + \else + \chem_formula_top_nop + \chem_formula_bot_nop + \fi\fi + \t_chem_mid\expandafter{\the\t_chem_mid\molecule{#1}&}% \fi} \def\chem_formula_mid#1% {\csname\??chemicalsymbol\detokenize{#1}\endcsname} -\def\chem_formula_top_nop {\t_chem_top\expandafter{\the\t_chem_top\aligntab}} -\def\chem_formula_bot_nop {\t_chem_bot\expandafter{\the\t_chem_bot\aligntab}} -\def\chem_formula_top_yes#1{\t_chem_top\expandafter{\the\t_chem_top\chem_formula_top_indeed{#1}\aligntab}\settrue\c_chem_has_top} -\def\chem_formula_bot_yes#1{\t_chem_bot\expandafter{\the\t_chem_bot\chem_formula_bot_indeed{#1}\aligntab}\settrue\c_chem_has_bot} +\def\chem_formula_top_nop {\t_chem_top\expandafter{\the\t_chem_top&}} +\def\chem_formula_bot_nop {\t_chem_bot\expandafter{\the\t_chem_bot&}} +\def\chem_formula_top_yes#1{\t_chem_top\expandafter{\the\t_chem_top\chem_formula_top_indeed{#1}&}\settrue\c_chem_has_top} +\def\chem_formula_bot_yes#1{\t_chem_bot\expandafter{\the\t_chem_bot\chem_formula_bot_indeed{#1}&}\settrue\c_chem_has_bot} \def\chem_formula_top_indeed#1{\strut#1} \def\chem_formula_bot_indeed#1{\strut#1} -% Experimental: defaults might change. - -\definefloat - [\v!chemical] - [\v!chemicals] - -\setuplabeltext - [\v!chemical=] - -\setupfloat - [\v!chemical] - [\c!location=\v!here, - \c!inner=\hsize.8\textwidth\dontleavehmode, % brr - \c!align={\v!flushleft,\v!lohi}] - -\setupcaption - [\v!chemical] - [\c!location=\v!right, - \c!distance=\zeropoint, - \c!width=.2\textwidth, - \c!align=\v!flushright] - -% Can be used as for displayed math: \startplaceformula... to display a chemical formula -% or a chemical structure: -% -% \startplacechemical -% \startchemicalformula -% \chemical{2H_2} -% \chemical{PLUS} -% \chemical{O_2} -% \chemical{GIVES} -% \chemical{2H_2O} -% \stopchemicalformula -% \stopplacechemical - % gone: state option resolution offset (now frame offset) alternative \setupchemicalframed [\c!align=\v!normal, \c!strut=\v!no, \c!offset=\v!overlay, - \c!frame=\v!off] + \c!frame=off] \setupchemical [\c!frame=, diff --git a/tex/context/base/cldf-bas.lua b/tex/context/base/cldf-bas.lua index 9cf8dcd4a..30a9265bc 100644 --- a/tex/context/base/cldf-bas.lua +++ b/tex/context/base/cldf-bas.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['cldf-bas'] = { +if not modules then modules = { } end modules ['cldf-ini'] = { version = 1.001, comment = "companion to cldf-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -22,8 +22,6 @@ if not modules then modules = { } end modules ['cldf-bas'] = { -- flush(ctxcatcodes,"}") -- end --- maybe use context.generics - local type = type local format = string.format local utfchar = utf.char @@ -34,16 +32,13 @@ local generics = context.generics local variables = interfaces.variables local new_rule = nodes.pool.rule -local texcount = tex.count function context.char(k) -- used as escape too, so don't change to utf if type(k) == "table" then - local n = #k - if n == 1 then - context([[\char%s\relax]],k[1]) - elseif n > 0 then - context([[\char%s\relax]],concat(k,[[\relax\char]])) - end + -- for i=1,#k do + -- context(format([[\char%s\relax]],k[i])) + -- end + context([[\char%s\relax]],concat(k,[[\relax\char]])) elseif k then context([[\char%s\relax]],k) end @@ -103,22 +98,22 @@ context.vrule = context.hrule -- not yet used ... but will get variant at the tex end as well -function context.sethboxregister(n) context([[\setbox %s\hbox]],n) end -function context.setvboxregister(n) context([[\setbox %s\vbox]],n) end +function context.sethboxregister (n) context("\\setbox %s\\hbox",n) end +function context.setvboxregister (n) context("\\setbox %s\\vbox",n) end function context.starthboxregister(n) if type(n) == "number" then - context([[\setbox%s\hbox{]],n) + context("\\setbox%s\\hbox\\bgroup",n) else - context([[\setbox\%s\hbox{]],n) + context("\\setbox\\%s\\hbox\\bgroup",n) end end function context.startvboxregister(n) if type(n) == "number" then - context([[\setbox%s\vbox{]],n) + context("\\setbox%s\\vbox\\bgroup",n) else - context([[\setbox\%s\vbox{]],n) + context("\\setbox\\%s\\vbox\\bgroup",n) end end @@ -127,36 +122,19 @@ context.stopvboxregister = context.egroup function context.flushboxregister(n) if type(n) == "number" then - context([[\box%s ]],n) + context("\\box%s ",n) else - context([[\box\%s]],n) + context("\\box\\%s",n) end end function context.beginvbox() - context([[\vbox{]]) -- we can do \bvbox ... \evbox (less tokens) + context("\\vbox\\bgroup") -- we can do \bvbox ... \evbox (less tokens) end function context.beginhbox() - context([[\hbox{]]) -- todo: use fast one + context("\\hbox\\bgroup") -- todo: use fast one end context.endvbox = context.egroup context.endhbox = context.egroup - -local function allocate(name,what,cmd) - local a = format("c_syst_last_allocated_%s",what) - local n = texcount[a] + 1 - if n <= texcount.c_syst_max_allocated_register then - texcount[a] = n - end - context("\\global\\expandafter\\%sdef\\csname %s\\endcsname %s\\relax",cmd or what,name,n) - return n -end - -function context.newdimen (name) return allocate(name,"dimen") end -function context.newskip (name) return allocate(name,"skip") end -function context.newcount (name) return allocate(name,"count") end -function context.newmuskip(name) return allocate(name,"muskip") end -function context.newtoks (name) return allocate(name,"toks") end -function context.newbox (name) return allocate(name,"box","mathchar") end diff --git a/tex/context/base/cldf-com.lua b/tex/context/base/cldf-com.lua index d9062594e..bacbbeafd 100644 --- a/tex/context/base/cldf-com.lua +++ b/tex/context/base/cldf-com.lua @@ -11,8 +11,8 @@ local context = context local generics = context.generics -- needs documentation local variables = interfaces.variables -generics.starttabulate = "starttabulate" -- "start" .. variables.tabulate -- todo: e!start -generics.stoptabulate = "stoptabulate" -- "stop" .. variables.tabulate -- todo: e!stop +generics.starttabulate = "start" .. variables.tabulate -- todo: e!start +generics.stoptabulate = "stop" .. variables.tabulate -- todo: e!stop local NC, NR = context.NC, context.NR diff --git a/tex/context/base/cldf-ini.lua b/tex/context/base/cldf-ini.lua index ad5f14855..ed86c2923 100644 --- a/tex/context/base/cldf-ini.lua +++ b/tex/context/base/cldf-ini.lua @@ -25,7 +25,7 @@ local tex = tex context = context or { } local context = context -local format, find, gmatch, gsub, validstring = string.format, string.find, string.gmatch, string.gsub, string.valid +local format, find, gmatch, gsub = string.format, string.find, string.gmatch, string.gsub local next, type, tostring, tonumber, setmetatable = next, type, tostring, tonumber, setmetatable local insert, remove, concat = table.insert, table.remove, table.concat local lpegmatch, lpegC, lpegS, lpegP, lpegCc = lpeg.match, lpeg.C, lpeg.S, lpeg.P, lpeg.Cc @@ -40,14 +40,12 @@ local isnode = node.is_node -- after 0.65 just node.type local writenode = node.write local copynodelist = node.copy_list -local catcodenumbers = catcodes.numbers - -local ctxcatcodes = catcodenumbers.ctxcatcodes -local prtcatcodes = catcodenumbers.prtcatcodes -local texcatcodes = catcodenumbers.texcatcodes -local txtcatcodes = catcodenumbers.txtcatcodes -local vrbcatcodes = catcodenumbers.vrbcatcodes -local xmlcatcodes = catcodenumbers.xmlcatcodes +local ctxcatcodes = tex.ctxcatcodes +local prtcatcodes = tex.prtcatcodes +local texcatcodes = tex.texcatcodes +local txtcatcodes = tex.txtcatcodes +local vrbcatcodes = tex.vrbcatcodes +local xmlcatcodes = tex.xmlcatcodes local flush = texsprint local flushdirect = texprint @@ -346,9 +344,9 @@ end local methodhandler = resolvers.methodhandler -function context.viafile(data,tag) +function context.viafile(data) if data and data ~= "" then - local filename = resolvers.savers.byscheme("virtual",validstring(tag,"viafile"),data) + local filename = resolvers.savers.byscheme("virtual","viafile",data) -- context.startregime { "utf" } context.input(filename) -- context.stopregime() @@ -412,11 +410,7 @@ local function writer(parent,command,first,...) -- already optimized before call done = true end end - if done then - flush(currentcatcodes,"]") - else - flush(currentcatcodes,"[]") - end + flush(currentcatcodes,"]") elseif tn == 1 then -- some 20% faster than the next loop local tj = ti[1] if type(tj) == "function" then diff --git a/tex/context/base/cldf-int.lua b/tex/context/base/cldf-int.lua index 6cbfd666f..55db9fa0b 100644 --- a/tex/context/base/cldf-int.lua +++ b/tex/context/base/cldf-int.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['cldf-int'] = { +if not modules then modules = { } end modules ['mult-clm'] = { version = 1.001, comment = "companion to mult-clm.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -14,12 +14,9 @@ if not modules then modules = { } end modules ['cldf-int'] = { local format, insert, remove, concat = string.format, table.insert, table.remove, table.concat local unpack = unpack or table.unpack -local catcodenumbers = catcodes.numbers - -local ctxcatcodes = catcodenumbers.ctxcatcodes -local vrbcatcodes = catcodenumbers.vrbcatcodes - -local contextsprint = context.sprint +local contextsprint = context.sprint +local ctxcatcodes = tex.ctxcatcodes +local vrbcatcodes = tex.vrbcatcodes local trace_define = false trackers.register("context.define", function(v) trace_define = v end) diff --git a/tex/context/base/cldf-ver.lua b/tex/context/base/cldf-ver.lua index b48fd253a..237078157 100644 --- a/tex/context/base/cldf-ver.lua +++ b/tex/context/base/cldf-ver.lua @@ -6,10 +6,6 @@ if not modules then modules = { } end modules ['cldf-ver'] = { license = "see context related readme files" } --- We have better verbatim: context.verbatim so that needs to be looked --- into. We can also directly store in buffers although this variant works --- better when used mixed with other code (synchronization issue). - local concat, tohandle = table.concat, table.tohandle local find, splitlines = string.find, string.splitlines local tostring, type = tostring, type @@ -45,7 +41,7 @@ table .tocontext = t_tocontext string .tocontext = s_tocontext boolean.tocontext = b_tocontext -function context.tocontext(first,...) +function tocontext(first,...) local t = type(first) if t == "string" then s_tocontext(first,...) diff --git a/tex/context/base/colo-ext.mkiv b/tex/context/base/colo-ext.mkiv index 8878da485..af6c3830e 100644 --- a/tex/context/base/colo-ext.mkiv +++ b/tex/context/base/colo-ext.mkiv @@ -29,10 +29,18 @@ %D %D will negate the colors in box zero. +% \unexpanded\def\negatecolorbox#1% +% {\setbox#1\hbox +% {\startnegative % might change +% \startcolor[\s!white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor +% \hskip-\wd#1% +% \box#1% +% \stopnegative}} + \unexpanded\def\negatecolorbox#1% {\setbox#1\hbox {\startnegative % might change - % \startcolor[\s!white]\vrule\s!height\ht#1\s!depth\dp#1\s!width\wd#1\stopcolor +% \startcolor[\s!white]\vrule\!!height\ht#1\!!depth\dp#1\!!width\wd#1\stopcolor \blackrule[\c!color=\s!white,\c!height=\ht#1,\c!depth=\dp#1,\c!width=\wd#1]% \hskip-\wd#1% \box#1% diff --git a/tex/context/base/colo-icc.lua b/tex/context/base/colo-icc.lua index 4ab28eb68..904d42143 100644 --- a/tex/context/base/colo-icc.lua +++ b/tex/context/base/colo-icc.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['colo-icc'] = { +if not modules then modules = { } end modules ['colo-ini'] = { version = 1.000, comment = "companion to colo-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index e08f3d387..747e2116f 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -16,8 +16,7 @@ local trace_define = false trackers.register("colors.define",function(v) trace_ local report_colors = logs.reporter("colors","defining") -local attributes, backends, storage = attributes, backends, storage -local context, commands = context, commands +local attributes, context, commands = attributes, context, commands local settings_to_hash_strict = utilities.parsers.settings_to_hash_strict @@ -667,51 +666,83 @@ function colors.defineintermediatecolor(name,fraction,c_one,c_two,a_one,a_two,sp end end -local function f(i,colors,fraction) - local otf = 0 - for c=1,#colors do - otf = otf + (tonumber(fraction[c]) or 1) * colors[c][i] - end - if otf > 1 then - otf = 1 +--~ local function f(one,two,i,fraction_one,fraction_two) +--~ local otf = fraction_one * one[i] + fraction_two * two[i] +--~ if otf > 1 then +--~ otf = 1 +--~ end +--~ return otf +--~ end + +--~ function colors.defineduocolor(name,fraction_one,c_one,fraction_two,c_two,global,freeze) +--~ local one, two = colorvalues[c_one], colorvalues[c_two] +--~ if one and two then +--~ fraction_one = tonumber(fraction_one) or 1 +--~ fraction_two = tonumber(fraction_two) or 1 +--~ local csone, cstwo = one[1], two[1] +--~ local ca +--~ if csone == 2 then +--~ ca = register_color(name,'gray',f(one,two,2,fraction_one,fraction_two)) +--~ elseif csone == 3 then +--~ ca = register_color(name,'rgb', f(one,two,3,fraction_one,fraction_two), +--~ f(one,two,4,fraction_one,fraction_two), +--~ f(one,two,5,fraction_one,fraction_two)) +--~ elseif csone == 4 then +--~ ca = register_color(name,'cmyk',f(one,two,6,fraction_one,fraction_two), +--~ f(one,two,7,fraction_one,fraction_two), +--~ f(one,two,8,fraction_one,fraction_two), +--~ f(one,two,9,fraction_one,fraction_two)) +--~ else +--~ ca = register_color(name,'gray',f(one,two,2,fraction_one,fraction_two)) +--~ end +--~ definecolor(name,ca,global,freeze) +--~ end +--~ end + + local function f(i,colors,fraction) + local otf = 0 + for c=1,#colors do + otf = otf + (tonumber(fraction[c]) or 1) * colors[c][i] + end + if otf > 1 then + otf = 1 + end + return otf end - return otf -end -function colors.definemixcolor(name,fractions,cs,global,freeze) - local values = { } - for i=1,#cs do -- do fraction in here - local v = colorvalues[cs[i]] - if not v then - return + function colors.definemixcolor(name,fractions,cs,global,freeze) + local values = { } + for i=1,#cs do -- do fraction in here + local v = colorvalues[cs[i]] + if not v then + return + end + values[i] = v end - values[i] = v - end - local csone = values[1][1] - local ca - if csone == 2 then - ca = register_color(name,'gray',f(2,values,fractions)) - elseif csone == 3 then - ca = register_color(name,'rgb', f(3,values,fractions), - f(4,values,fractions), - f(5,values,fractions)) - elseif csone == 4 then - ca = register_color(name,'cmyk',f(6,values,fractions), - f(7,values,fractions), - f(8,values,fractions), - f(9,values,fractions)) - else - ca = register_color(name,'gray',f(2,values,fractions)) + local csone = values[1][1] + local ca + if csone == 2 then + ca = register_color(name,'gray',f(2,values,fractions)) + elseif csone == 3 then + ca = register_color(name,'rgb', f(3,values,fractions), + f(4,values,fractions), + f(5,values,fractions)) + elseif csone == 4 then + ca = register_color(name,'cmyk',f(6,values,fractions), + f(7,values,fractions), + f(8,values,fractions), + f(9,values,fractions)) + else + ca = register_color(name,'gray',f(2,values,fractions)) + end + definecolor(name,ca,global,freeze) end - definecolor(name,ca,global,freeze) -end -- for the moment downward compatible local patterns = { "colo-imp-%s.mkiv", "colo-imp-%s.tex", "colo-%s.mkiv", "colo-%s.tex" } local function action(name,foundname) - -- could be one command context.startreadingfile() context.startcolorset { name } context.input(foundname) @@ -846,22 +877,3 @@ end -- context.popcatcodes() -- end --- handy - -local models = storage.allocate { "all", "gray", "rgb", "cmyk", "spot" } - -colors.models = models -- check for usage elsewhere - -function colors.spec(name) - local l = attributes_list[a_color] - local t = colorvalues[l[name]] or colorvalues[l.black] - return { - model = models[t[1]] or models[1], - s = t[2], - r = t[3], g = t[4], b = t[5], - c = t[6], m = t[7], y = t[8], k = t[9], - } -end - --- inspect(attributes.colors.spec("red")) --- inspect(attributes.colors.spec("red socks")) diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index 629f2b96a..5721bb513 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -242,8 +242,8 @@ \setfalse\c_colo_convert_gray \getvalue{\??colorconversions\directcolorsparameter\c!conversion}% could be a nice \ifcsname % too often: - \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi - \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi + \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors9\v!rgb \fi + \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors9\v!cmyk\fi \colo_helpers_set_current_model \ifproductionrun \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}% @@ -357,26 +357,16 @@ \normalexpanded{\colo_palets_define[#1][\csname\??colorpaletspecification#2\endcsname]}% \fi}} -% \def\colo_palets_define_one#1#2% get rid of { } in #2 -% {\colo_palets_define_two{#1}[#2]}% - -\def\colo_palets_define_one#1#2% get rid of { } - {\doifassignmentelse{#2} % catch empty entries - {\colo_palets_define_two{#1}[#2]} - {\colo_palets_define_three{#1}{#2}}} +\def\colo_palets_define_one#1#2% get rid of { } in #2 + {\colo_palets_define_two{#1}[#2]}% \def\colo_palets_define_two#1[#2=#3]% {\edef\m_colo_palets_tmp{\ifx\m_colo_palets_tmp\empty\else\m_colo_palets_tmp,\fi#2}% \colo_palets_define_set{#1}{#2}{#3}}% -\def\colo_palets_define_three#1#2% - {\ifcsname\??colorpaletspecification#2\endcsname - \processcommacommand[\csname\??colorpaletspecification#2\endcsname]{\colo_palets_define_one{#1}}% - \fi} - \let\paletsize\!!zerocount -\unexpanded\def\getpaletsize[#1]% only works for valid k=v definitions +\def\getpaletsize[#1]% {\getcommacommandsize[\csname\??colorpaletspecification#1\endcsname]% \edef\paletsize{\number\commalistsize}} @@ -812,19 +802,9 @@ \def\defaulttextcolor {black} \def\s!themaintextcolor{themaintextcolor} -\unexpanded\def\inheritmaintextcolor - {\ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi} - -\unexpanded\def\onlyinheritmaintextcolor - {\ifx\maintextcolor\empty - \deactivatecolor - \else - \colo_helpers_activate\maintextcolor - \fi} - \appendtoks \deactivatecolor % public? - \inheritmaintextcolor + \ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi \to \everybeforeoutput \def\colo_helpers_switch_to_maintextcolor#1% @@ -981,7 +961,7 @@ % ignores in attribute handler % -% \def\forcecolorhack{\vrule\s!width\zeropoint\s!height\zeropoint\s!depth\zeropoint} +% \def\forcecolorhack{\vrule\!!width\zeropoint\!!height\zeropoint\!!depth\zeropoint} % \normal added else fails in metafun manual (leaders do a hard scan) diff --git a/tex/context/base/colo-run.lua b/tex/context/base/colo-run.lua index 27f7c6b12..4f1916d5a 100644 --- a/tex/context/base/colo-run.lua +++ b/tex/context/base/colo-run.lua @@ -6,10 +6,8 @@ if not modules then modules = { } end modules ['colo-run'] = { license = "see context related readme files" } --- For historic reasons the core has a couple of tracing features. Nowadays --- these would end up in modules. - -local colors, commands, context, utilities = colors, commands, context, utilities +-- For historic reasons the core has a couple of tracing +-- features. Nowadays these would end up in modules. local colors= attributes.colors diff --git a/tex/context/base/colo-run.mkiv b/tex/context/base/colo-run.mkiv index 5084fdd35..c330accf3 100644 --- a/tex/context/base/colo-run.mkiv +++ b/tex/context/base/colo-run.mkiv @@ -42,9 +42,9 @@ %D Palets \unexpanded\gdef\showpalet - {\dodoubleargument\colo_show_palet} + {\dodoubleargument\doshowpalet} -\gdef\colo_show_palet[#1][#2]% +\gdef\doshowpalet[#1][#2]% {\ifcsname\??colorpalet#1\endcsname \doifinsetelse\v!vertical{#2} \colo_palets_show_vertical \colo_palets_show_horizontal [#1][#2]% \fi} @@ -59,8 +59,8 @@ \tabskip\zeropoint \def\colo_palets_show_palet##1% {\doifinsetelse\v!number{#2}{##1\hskip.5em}{}& - \color[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}% - \graycolor[##1]{\vrule\s!width3em\s!height\strutht\s!depth\strutdp}& + \color[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}% + \graycolor[##1]{\vrule\!!width3em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{##1}}\crcr} \halign {\hss##&\hss##\hss#\cr @@ -92,11 +92,11 @@ \colo_palets_process[#1]\colo_palets_show_palet}\cr \doifinset\v!name{#2}{#1\hskip.5em}% \def\colo_palets_show_palet##1% - {&\strut\color[##1]{\vrule\s!width\!!widtha\s!height\strutht\s!depth\zeropoint}}% + {&\strut\color[##1]{\vrule\!!width\!!widtha\!!height\strutht\!!depth\zeropoint}}% \colo_palets_process[#1]\colo_palets_show_palet\crcr \noalign{\vskip-\strutdepth}% \def\colo_palets_show_palet##1% - {&\graycolor[##1]{\vrule\s!width\!!widtha\s!height\zeropoint\s!depth\strutdp}}% + {&\graycolor[##1]{\vrule\!!width\!!widtha\!!height\zeropoint\!!depth\strutdp}}% \colo_palets_process[#1]\colo_palets_show_palet\crcr \doifinset\v!value{#2} {\def\colo_palets_show_palet##1% @@ -137,13 +137,13 @@ \def\colo_palets_compare##1% {\hbox {\setbox0\hbox - {#1[##1]{\vrule\s!width\hsize\s!height3ex}}% + {#1[##1]{\vrule\!!width\hsize\!!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize {\def\colo_palets_compare####1% {\hbox to \!!widtha - {\hss#1[####1]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}% + {\hss#1[####1]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}% \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} \endgraf} \processcommacommand[\getvalue{\??colorpalet#2}]\colo_palets_compare}} @@ -171,8 +171,8 @@ {\halign {\hss####\hss\cr \doifinset\v!number{#2}{\strut##1}\cr - \color[#1:##1]{\vrule\s!width4em\s!height\strutht\s!depth\zeropoint}\cr - \graycolor[#1:##1]{\vrule\s!width4em\s!height\zeropoint\s!depth\strutdp}\cr + \color[#1:##1]{\vrule\!!width4em\!!height\strutht\!!depth\zeropoint}\cr + \graycolor[#1:##1]{\vrule\!!width4em\!!height\zeropoint\!!depth\strutdp}\cr \doifinset\v!value{#2}{\colorvalue{#1:##1}\strut}\crcr}}}}% \hbox {\doifinset\v!name{#2} @@ -195,8 +195,8 @@ \def\colo_groups_show_group##1% {\doifcolor{#1:##1} {\doifinset\v!number{#2}{##1\hskip.5em}& - \color[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}% - \graycolor[#1:##1]{\vrule\s!width2.5em\s!height\strutht\s!depth\strutdp}& + \color[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}% + \graycolor[#1:##1]{\vrule\!!width2.5em\!!height\strutht\!!depth\strutdp}& \doifinset\v!value{#2}{\hskip.5em\colorvalue{#1:##1}}\crcr}}% \halign {\hss##&\hss##\hss#\hss\cr @@ -228,11 +228,11 @@ \def\colo_groups_compare_step#1#2#3% {\hbox to \hsize {\setbox0\hbox - {#1[#2:#3]{\vrule\s!width\hsize\s!height3ex}}% + {#1[#2:#3]{\vrule\!!width\hsize\!!height3ex}}% \wd0\zeropoint \box0 \hbox to \hsize - {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\s!width.5\!!widtha\s!height2.25ex\s!depth-.75ex}\hss}}} + {\hss\dorecurse\!!counta{#1[#2:\recurselevel]{\vrule\!!width.5\!!widtha\!!height2.25ex\!!depth-.75ex}\hss}}} \endgraf} \protect \endinput diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 5d4133143..67647920d 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -118,7 +118,7 @@ \logofont} \def\syst_logos_meta_hyphen % there is no hyphenchar in this font - {\discretionary{\vrule\s!height.33em\s!depth-.27em\s!width.33em}{}{}} + {\discretionary{\vrule\!!height.33em\!!depth-.27em\!!width.33em}{}{}} \unexpanded\def\MetaFont {\dontleavehmode @@ -270,12 +270,4 @@ \unexpanded\def\MPII{MpII} \unexpanded\def\MPIV{MpIV} -\appendtoks - \def\ConTeXt {ConTeXt}% - \def\MetaPost{MetaPost}% - \def\MetaFont{MetaFont}% - \def\MetaFun {MetaFun}% - \def\TeX {TeX}% -\to \everysimplifycommands - \protect \endinput diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 2a2e12ba8..b4958762f 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.10.17 22:49} +\newcontextversion{2012.05.30 11:26} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 9f3d8cbc2..5a28f8e29 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,60 +11,515 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.10.17 22:49} +\newcontextversion{2012.05.30 11:26} -%D This file is loaded at runtime, thereby providing an excellent place for -%D hacks, patches, extensions and new features. +%D This file is loaded at runtime, thereby providing an +%D excellent place for hacks, patches, extensions and new +%D features. \unprotect \writestatus\m!system{beware: some patches loaded from cont-new.mkiv} -%D Maybe: +\def\dividedsize#1#2#3% size gap n + {\dimexpr + \ifnum\dimexpr#1\relax>\plusone + (\dimexpr#1\relax-\numexpr#3-1\relax\dimexpr#2\relax)/#3\else#1% + \fi + \relax} + +\def\singlewidened #1{\hbox spread 1em{\hss#1\hss}} +\def\complexwidened[#1]#2{\hbox spread #1{\hss#2\hss}} -\unexpanded\def\tightvbox{\dowithnextbox{\dp\nextbox\zeropoint\box\nextbox}\vbox} -\unexpanded\def\tightvtop{\dowithnextbox{\ht\nextbox\zeropoint\box\nextbox}\vtop} +\definecomplexorsimple\widened + +\let\active\activecatcode % for a while (tikz) + +% todo +% +% \def\definelocation{\dodoubleargument\dodefinelocation} +% \def\dodefinelocation[#1][#2]{\setvalue{loc:#1}{#2}} +% +% \definelocation[lt] [\v!left\v!top] +% \definelocation[tl] [\v!left\v!top] +% \definelocation[\v!top\v!left][\v!left\v!top] +% +% \def\getlocation#1{\executeifdefined{loc:#1}{#1}} + +% \let\cs\getvalue % no, we want \cs to be czech + +% experimental so this may change -%D Needs some work: +\def\startdescriptions + {\dosingleempty\dostartdescriptions} -\unexpanded\def\startgridcorrection - {\dosingleempty\spac_grid_correction_start} +\def\dostartdescriptions[#1]% + {\begingroup + \def\item{\getvalue{#1}}% + \let\dostoppairdescription \donothing + \let\@@description \dostartpairdescription + \let\@@startsomedescription\dostartsomedescription} -\def\spac_grid_correction_start[#1]% +\def\stopdescriptions + {\dostoppairdescription + \endgroup} + +\def\dostartpairdescription[#1][#2]% + {\dostoppairdescription + \def\dostoppairdescription{\@@stopdescription{#1}}% + \bgroup + \def\currentdescription{#1}% + \doifelse{\descriptionparameter{\s!do\c!state}}\v!start + {\@@makedescription{#1}[#2]{}} + {\@@makedescription{#1}[#2]}} + +\def\dostartsomedescription% #1[#2]#3% + {\bgroup + \@@makedescription} % {#1}[#2]{#3}} + +% \starttext +% +% \definedescription[test] +% +% \startdescriptions +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \test{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \startdescriptions +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \starttest{Foo} Bar bar bar \stoptest +% \stopdescriptions +% +% \startdescriptions[test] +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \item{Foo} Bar bar bar +% \stopdescriptions +% +% \stoptext + +% this will be activated when +% +% \newinsert\thispageinsert % <- installinsertion +% +% \def\flushatthispage +% {\bgroup +% \dowithnextbox{\insert\thispageinsert{\box\nextbox}\egroup}% +% \hbox} +% +% \appendtoks +% \ifvoid\thispageinsert\else\hbox{\smashedbox\thispageinsert}\fi +% \to \everyshipout + +% \definemarkedpage[nobackgrounds] +% \markpage[nobackgrounds] +% \doifmarkedpageelse{nobackgrounds} + +% Just a simple and fast hanger, for usage in macros. + +\def\setuphanging + {\dodoubleempty\getparameters[\??ha]} + +\setuphanging + [\c!distance=.5em] + +\def\starthanging + {\noindent\bgroup + \dowithnextbox + {\setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \hangindent\nextboxwd + \hangafter\plusone + \flushnextbox\ignorespaces} + \hbox} + +\def\stophanging + {\endgraf + \egroup} + +% experimental + +\def\stophangaround + {\endgraf + \egroup} + +\def\starthangaround + {\noindent\bgroup + \dowithnextbox + {\ifdim\nextboxht>\strutht\setbox\nextbox\tbox{\flushnextbox}\fi + \setbox\nextbox\hbox{\flushnextbox\hskip\@@hadistance}% + \getboxheight\scratchdimen\of\box\nextbox + \getnoflines\scratchdimen + \nextboxht\strutht + \nextboxdp\strutdp + \hangindent\nextboxwd + \hangafter-\noflines + \llap{\flushnextbox}\ignorespaces} + \hbox} + +\def\modevalue#1#2#3% + {\@EA\ifx\csname\@mode@\systemmodeprefix#1\endcsname\endcsname\enabledmode#2\else#2\fi} + +\def\systemmodevalue#1% + {\modevalue{\systemmodeprefix#1}} + +% new, still to be improved +% +% \dorecurse{10} +% {\input thuan +% \placefigure{}{\framed[height=1.5cm]{test}} +% \placefloatplaceholder} + +\def\placefloatplaceholder + {\ifroomforfloat \else + \scratchdimen\pagegoal + \advance\scratchdimen-\pagetotal + \advance\scratchdimen-3\lineheight + \ifdim\scratchdimen>\zeropoint + \startlinecorrection[blank] + \mhbox{\inframed{\labeltexts{placeholder}{\lastcaptiontag}}}% + \stoplinecorrection + \else + \allowbreak + \fi + \fi} + +\setuplabeltext + [placeholder={, moved}] + +% move to support module, and then use context(...) + +\startluacode + function commands.percentageof(str,dim) + local n = str:match("^(.*)%%$") + context.sprint(tex.ctxcatcodes,(n and (tonumber(n)/100)*dim .. "sp") or str) + end +\stopluacode + +\gdef\setpercentdimen#1#2% + {#1=\ctxcommand{percentageof("#2",\number#1)}\relax} + +% \scratchdimen=100pt \setpercentdimen\scratchdimen{10\letterpercent} \the\scratchdimen +% \scratchdimen=100pt \setpercentdimen\scratchdimen{5pt} \the\scratchdimen + +\bgroup \permitcircumflexescape + +\obeylines % don't remove %'s ! + +\gdef\collapsedspace#1% + {\ifx#1^^M% + \expandafter\collapsedspace + \else + \space + \expandafter#1% + \fi} + +\gdef\collapsespaces + {\prependtoksonce\relax\to\everyeof% + \ignorelines% + \ignoretabs% + \let\obeyedspace\collapsedspace% + \obeyspaces} + +\egroup + +\def\inlinedbox + {\bgroup + \dowithnextbox + {\scratchdimen\nextboxht + \advance\scratchdimen\nextboxdp + \advance\scratchdimen-\lineheight + \divide\scratchdimen\plustwo + \advance\scratchdimen\strutdepth + \setbox\nextbox\hbox{\lower\scratchdimen\flushnextbox}% + \nextboxht\strutht + \nextboxdp\strutdp + \flushnextbox + \egroup}% + \hbox} + +\def\dimenratio#1#2% etex only + {\withoutpt\the\dimexpr2\dimexpr(#1)/\dimexpr(#2)/32768\relax\relax} + +\def\doxprecurse#1#2% + {\ifnum#1=\zerocount % no \ifcase + \expandafter\gobblethreearguments + \else + #2\expandafter\expandafter\expandafter\doxprecurse\expandafter + \fi\expandafter{\the\numexpr#1-1\relax}{#2}} + +\def\buttonframed{\dodoubleempty\localframed[\??bt]} % goodie + +\unexpanded\def\asciistr#1{\dontleavehmode{\defconvertedargument\ascii{#1}\verbatimfont\ascii}} + +\def\shapefill{\vskip\zeropoint\!!plus\lineheight\!!minus\lineheight\relax} + +% \ruledhbox +% {\startignorespaces +% \def\oeps{a} +% \startignorespaces +% \def\oeps{a} +% \stopignorespaces +% \def\oeps{a} +% \stopignorespaces +% \oeps} + +\newsignal\boissignal +\newcount \boislevel + +\long\def\startignorespaces + {\advance\boislevel\plusone + \ifcase\boislevel\or \ifhmode + \hskip\boissignal + \fi \fi + \ignorespaces} + +\long\def\stopignorespaces + {\ifcase\boislevel\or \ifhmode + \doloop + {\ifdim\lastskip=\zeropoint + \exitloop + \else\ifdim\lastskip=\boissignal + \unskip + \exitloop + \else + \unskip + \fi\fi}% + \fi \fi + \advance\boislevel\minusone} + +\def\minimalhbox#1#% + {\dowithnextbox + {\bgroup + \setbox\scratchbox\hbox#1{\hss}% + \ifdim\nextboxwd<\wd\scratchbox\nextboxwd\wd\scratchbox\fi + \flushnextbox + \egroup} + \hbox} + +\def\gobbleuntilempty#1\empty{} + +\def\dodimchoice#1#2#3% + {\ifdim#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\donumchoice#1#2#3% + {\ifnum#1#2% + #3\@EA\gobbleuntilempty + \else + \@EA\dodimchoice + \fi{#1}} + +\def\dimchoice#1#2{\dodimchoice{#1}#2{=#1}{#1}\empty} +\def\numchoice#1#2{\donumchoice{#1}#2{=#1}{#1}\empty} + +% \the\dimexpr(\dimchoice {7pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{11pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) +% \the\dimexpr(\dimchoice{14pt}{{<10pt}{8pt}{<12pt}{9pt}{<15pt}{10pt}{=11pt}{12pt}}) + +\def\tabulaterule % to be redone, not correct + {\dotabulaterule + {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax + \doifvalue{\??tt\currenttabulate\c!distance}\v!grid + {\kern-\scratchdimen}}} % experimental tm-prikkels +% so far + +% between alignment lines certain rules apply, and even a +% simple test can mess up a table, which is why we have a +% special test facility +% +% \ruledvbox +% {\starttabulate[|l|p|] +% \NC 1test \NC test \NC \NR +% \tableifelse{\doifelse{a}{a}}{\NC Xtest \NC test \NC \NR}{}% +% \stoptabulate} + +\long\def\tableifelse#1% + {\tablenoalign + {#1% + {\aftergroup \firstoftwoarguments}% + {\aftergroup\secondoftwoarguments}}} + +\long \def\tableiftextelse#1{\tableifelse{\doiftextelse{#1}}} + +\def\tightvbox{\dowithnextbox{\nextboxdp\zeropoint\flushnextbox}\vbox} +\def\tightvtop{\dowithnextbox{\nextboxht\zeropoint\flushnextbox}\vtop} + +% what is this stupid macro meant for: + +\def\hyphenationpoint + {\hskip\zeropoint} + +\def\hyphenated#1% + {\bgroup + \!!counta\zerocount + \def\hyphenated##1{\advance\!!counta\plusone}% + \handletokens#1\with\hyphenated + \!!countb\plusone + \def\hyphenated##1% + {##1% + \advance\!!countb\plusone\relax + \ifnum\!!countb>2 \ifnum\!!countb<\!!counta + \hyphenationpoint + \fi\fi}% + \handletokens#1\with\hyphenated + \egroup} + +\def\obeysupersubletters + {\let\super\normalsuper + \let\suber\normalsuber + \let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\obeysupersubmath + {\let\normalsuper\letterhat + \let\normalsuber\letterunderscore + \enablesupersub} + +\def\startgridcorrection + {\dosingleempty\dostartgridcorrection} + +\def\dostartgridcorrection[#1]% {\ifgridsnapping \snaptogrid[#1]\vbox\bgroup \else \startbaselinecorrection \fi} -\unexpanded\def\stopgridcorrection +\def\stopgridcorrection {\ifgridsnapping \egroup \else \stopbaselinecorrection \fi} - -\unexpanded\def\checkgridsnapping + +\def\checkgridsnapping {\lineskip\ifgridsnapping\zeropoint\else\normallineskip\fi} + +\def\startplaatsen + {\dosingleempty\dostartplaatsen} -%D Probably obsolete: +\def\dostartplaatsen[#1]% tzt n*links etc + {\endgraf + \noindent\bgroup + \setlocalhsize + \hbox to \localhsize\bgroup + \doifnot{#1}\v!left\hss + \def\stopplaatsen + {\unskip\unskip\unskip + \doifnot{#1}\v!right\hss + \egroup + \egroup + \endgraf}% + \gobblespacetokens} -\unexpanded\def\startcolumnmakeup % don't change +% \startplaatsen[links] bla \stopplaatsen + +\def\startcolumnmakeup % don't change {\bgroup - \getrawnoflines\textheight % raw as we cna have topskip - \setbox\scratchbox\vbox to \dimexpr\noflines\lineheight-\lineheight+\topskip\relax - \bgroup - \forgetall} + \getrawnoflines\textheight % teksthoogte kan topskip hebben, dus raw + \scratchdimen\noflines\lineheight + \advance\scratchdimen-\lineheight + \advance\scratchdimen\topskip + \setbox\scratchbox + \ifcase\showgridstate\vbox\else\ruledvbox\fi to \scratchdimen\bgroup + \forgetall} % ! don't change -\unexpanded\def\stopcolumnmakeup +\def\stopcolumnmakeup {\egroup \dp\scratchbox\zeropoint \wd\scratchbox\textwidth \box\scratchbox \egroup \page_otr_command_synchronize_hsize} + +\long\def\startexternalfigure + {\dotripleempty\dostartexternalfigure} + +\long\def\dostartexternalfigure[#1][#2][#3]#4\stopexternalfigure + {\gdef\figuredescription{#4}% + \externalfigure[#1][#2][#3]% + \globallet\figuredescription\empty} + +\let\figuredescription\empty + +% incomplete, will be a special case of float placement + +\def\startfixed{\dosingleempty\dostartfixed} + +\def\dostartfixed[#1]% + {\expanded{\dowithnextbox{\noexpand\dodofixed{\ifhmode0\else1\fi}{#1}}}% + \vbox\bgroup + \setlocalhsize} + +\def\stopfixed + {\egroup} + +\def\dodofixed#1#2% + {\ifcase#1\relax + \processaction + [#2] + [ \v!high=>\bbox {\flushnextbox}, + \v!low=>\tbox {\flushnextbox}, + \v!middle=>\vcenter{\flushnextbox}, + \v!lohi=>\vcenter{\flushnextbox}, + \s!unknown=>\tbox {\flushnextbox}, + \s!default=>\tbox {\flushnextbox}]% + \else + \startbaselinecorrection + \noindent\flushnextbox + \stopbaselinecorrection + \fi} + +% \startitemize +% +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% \item \externalfigure[koe][height=2cm] +% +% \page +% +% \item \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \page +% +% \item test \par \startfixed \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[high]\externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[low] \externalfigure[koe][height=2cm]\stopfixed +% \item test \par \startfixed[lohi]\externalfigure[koe][height=2cm]\stopfixed +% +% \stopitemize + +\def\obeyfollowingtoken{{}} % end \cs scanning + +% potential new defaults: +% +% \setbreakpoints[compound] -%D Till we fixed all styles: +% till we fixed all styles: \let\\=\crlf diff --git a/tex/context/base/cont-nop.mkiv b/tex/context/base/cont-nop.mkiv deleted file mode 100644 index c8188503e..000000000 --- a/tex/context/base/cont-nop.mkiv +++ /dev/null @@ -1,22 +0,0 @@ -%D \module -%D [ file=cont-nop, -%D version=2012.06.01, -%D title=\CONTEXT\ Miscellaneous Macros, -%D subtitle=Startup Dummy, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\unprotect - -\writestatus\m!system{loading dummy replacement for jobname} - -\protect - -\finishjob - -\endinput diff --git a/tex/context/base/cont-yes.mkiv b/tex/context/base/cont-yes.mkiv deleted file mode 100644 index 2a032fc0b..000000000 --- a/tex/context/base/cont-yes.mkiv +++ /dev/null @@ -1,80 +0,0 @@ -%D \module -%D [ file=cont-yes, -%D version=2012.06.01, -%D title=\CONTEXT\ Miscellaneous Macros, -%D subtitle=Startup Stub, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -% At some point I will reconsider the \starttext .. \stoptext -% wraping as we can assume proper styling. It's a left-over from -% mkii that we need to get rid of. - -\startluacode - - -- When a style is loaded there is a good change that we never enter - -- this code. - - environment.initializefilenames() - - local arguments = environment.arguments - local suffix = environment.suffix - local filename = environment.filename - - if suffix == "xml" or arguments.forcexml then - - -- Maybe we should move the preamble parsing here as it - -- can be part of (any) loaded (sub) file. The \starttext - -- wrapping might go away. - - context.starttext() - context.xmlprocess("main",filename,"") - context.stoptext() - - elseif suffix == "cld" or arguments.forcecld then - - context.runfile(filename) - - elseif suffix == "lua" or arguments.forcelua then - - -- The wrapping might go away. Why is is it there in the - -- first place. - - context.starttext() - context.ctxlua(string.format('dofile("%s")',filename)) - context.stoptext() - - elseif suffix == "mp" or arguments.forcemp then - - context.starttext() - context.processMPfigurefile(filename) - context.stoptext() - - -- elseif suffix == "prep" then - -- - -- -- Why do we wrap here. Because it can be xml? Let's get rid - -- -- of prepping in general. - -- - -- context.starttext() - -- context.input(filename) - -- context.stoptext() - - else - - -- We have a regular tex file so no \starttext yet as we can - -- load fonts. - - context.input(filename) - - end - - context.finishjob() - -\stopluacode - -\endinput diff --git a/tex/context/base/context-base.lmx b/tex/context/base/context-base.lmx index 2b093c3e1..09817463b 100644 --- a/tex/context/base/context-base.lmx +++ b/tex/context/base/context-base.lmx @@ -19,9 +19,7 @@ + diff --git a/tex/context/base/context-help.lmx b/tex/context/base/context-help.lmx index 939b70cb6..5401fb65d 100644 --- a/tex/context/base/context-help.lmx +++ b/tex/context/base/context-help.lmx @@ -19,7 +19,6 @@