diff options
author | Marius <mariausol@gmail.com> | 2010-11-17 14:40:15 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-11-17 14:40:15 +0200 |
commit | 49a6126dc0cc532254edaeecec129961b132cac5 (patch) | |
tree | ddf1cef4731c0ac4c4954e577a11cafeb47e7389 | |
parent | 7fc9b91bca833ba04496e8f819fb60dafd77f6e0 (diff) | |
download | context-49a6126dc0cc532254edaeecec129961b132cac5.tar.gz |
beta 2010.11.17 13:27
27 files changed, 986 insertions, 707 deletions
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua index c5976018c..701378c09 100644 --- a/scripts/context/lua/mtxrun.lua +++ b/scripts/context/lua/mtxrun.lua @@ -3693,7 +3693,7 @@ local concat = table.concat local type, next = type, next utilities = utilities or {} -utilities.merger = utilities.merger or { } +utilities.merger = utilities.merger or { } -- maybe mergers utilities.report = utilities.report or print local merger = utilities.merger @@ -3897,6 +3897,8 @@ local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +lpeg.patterns.nested = nested + local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) local key = C((1-equal-comma)^1) diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua index c5976018c..701378c09 100644 --- a/scripts/context/stubs/mswin/mtxrun.lua +++ b/scripts/context/stubs/mswin/mtxrun.lua @@ -3693,7 +3693,7 @@ local concat = table.concat local type, next = type, next utilities = utilities or {} -utilities.merger = utilities.merger or { } +utilities.merger = utilities.merger or { } -- maybe mergers utilities.report = utilities.report or print local merger = utilities.merger @@ -3897,6 +3897,8 @@ local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +lpeg.patterns.nested = nested + local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) local key = C((1-equal-comma)^1) diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index c5976018c..701378c09 100644 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -3693,7 +3693,7 @@ local concat = table.concat local type, next = type, next utilities = utilities or {} -utilities.merger = utilities.merger or { } +utilities.merger = utilities.merger or { } -- maybe mergers utilities.report = utilities.report or print local merger = utilities.merger @@ -3897,6 +3897,8 @@ local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +lpeg.patterns.nested = nested + local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) local key = C((1-equal-comma)^1) diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index f1a8e8a51..35f2191bf 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -1457,14 +1457,6 @@ \hskip-\wd\scratchbox \box\scratchbox} -\def\tabulatenormalcolumn#1% overloaded later in node-bck - {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi - &\global\tabulatetype#1&} - -\def\tabulateequalcolumn#1% overloaded - {&\tabulateequalpos - &\global\tabulatetype#1&} - \appendtoks \global\advance\noftabpositions\plusone \global\setfalse\tablehaspositions @@ -1485,16 +1477,8 @@ \gdef\doflushtabulateepos{\epos{#1}}% \fi} -\def\splitofftabulatebox % overloaded in node-bck - {\dontcomplain - \global\setbox\tabulatebox % % % global ? % % % - \vsplit\tablebox\tabulatecolumn to \lineheight - \setbox\tabulatebox\normalvbox - {\unvbox\tabulatebox}% - \setbox\tabulatebox\hbox to \wd\tabulatebox - {\hss\dotabulatehook{\box\tabulatebox}\hss}% - \donormalizetabulatesplitline - \box\tabulatebox +\def\flushtabulatesplitbox + {\box\tabulatebox \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} \appendtoks diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 56f0cc8c6..fe8efa5aa 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.11.12 18:22} +\newcontextversion{2010.11.17 13:27} %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 7748b750e..bf6826101 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -134,6 +134,8 @@ \loadmarkfile{colo-ini} \loadmarkfile{colo-ext} +\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented) + \loadmarkfile{trac-vis} \loadmarkfile{lang-mis} @@ -219,6 +221,7 @@ \loadmarkfile{page-mul} \loadmarkfile{page-set} \loadmarkfile{pack-lyr} +\loadmarkfile{pack-pos} \loadmarkfile{page-mak} \loadmarkfile{page-lin} @@ -242,8 +245,14 @@ \loadmarkfile{tabl-com} \loadmarkfile{tabl-pln} -\loadcorefile{thrd-tab} -\loadmarkfile{tabl-tab} + +\doifmodeelse{atpragma} { + \definestartstop[\v!table]{\errmessage{please usemodule m-table}} +} { + \loadcorefile{thrd-tab} + \loadmarkfile{tabl-tab} +} + \loadmarkfile{tabl-tbl} \loadmarkfile{tabl-ntb} \loadmarkfile{tabl-nte} @@ -334,8 +343,6 @@ \loadmarkfile{page-app} \loadmarkfile{meta-fig} -\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented) - \loadmarkfile{lang-spa} % will become obsolete \loadmarkfile{cldf-ini} % this can come later diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 272c2f1a4..6e467247c 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.11.12 18:22} +\edef\contextversion{2010.11.17 13:27} %D For those who want to use this: diff --git a/tex/context/base/core-env.lua b/tex/context/base/core-env.lua index 02fa4f744..d0db40b81 100644 --- a/tex/context/base/core-env.lua +++ b/tex/context/base/core-env.lua @@ -22,44 +22,64 @@ tex.constants = { } tex.conditionals = { } tex.ifs = { } -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 +setmetatable(tex.modes, { + __index = function(t,k) + local m = modes[k] + if m then + return m() else - modes[k] = function() return texcount[n] >= 1 end - return texcount[n] >= 1 + 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 -end }) +}) -setmetatable(tex.systemmodes, { __index = function(t,k) - local m = systemmodes[k] - if m then - return m() - else - local n = "mode*" .. k - if csname_id(n) == undefined then - return false +setmetatable(tex.systemmodes, { + __index = function(t,k) + local m = systemmodes[k] + if m then + return m() else - systemmodes[k] = function() return texcount[n] >= 1 end - return texcount[n] >= 1 + local n = "mode*" .. k + if csname_id(n) == undefined then + return false + else + systemmodes[k] = function() return texcount[n] >= 1 end + return texcount[n] >= 1 + end end end -end }) +}) -setmetatable(tex.constants, { __index = function(t,k) - return csname_id(k) ~= undefined and texcount[k] or 0 -end }) +setmetatable(tex.constants, { + __index = function(t,k) + return csname_id(k) ~= undefined and texcount[k] or 0 + end, +--~ __newindex = function(t,k) +--~ if csname_id(k) ~= undefined then +--~ texcount[k] = k +--~ end +--~ end +}) -setmetatable(tex.conditionals, { __index = function(t,k) -- 0 == true - return csname_id(k) ~= undefined and texcount[k] == 0 -end }) +setmetatable(tex.conditionals, { + __index = function(t,k) -- 0 == true + return csname_id(k) ~= undefined and texcount[k] == 0 + end, +--~ __newindex = function(t,k) -- not ok +--~ if csname_id(k) ~= undefined then +--~ texcount[k] = k and 0 or 1 -- 0 == true +--~ end +--~ end +}) -setmetatable(tex.ifs, { __index = function(t,k) - return csname_id(k) ~= undefined and create(k)[2] == iftrue -- inefficient, this create, we need a helper -end }) +setmetatable(tex.ifs, { + __index = function(t,k) + return csname_id(k) ~= undefined and create(k)[2] == iftrue -- inefficient, this create, we need a helper + end +}) diff --git a/tex/context/base/core-mis.mkii b/tex/context/base/core-mis.mkii index 98079830d..a412ebaf4 100644 --- a/tex/context/base/core-mis.mkii +++ b/tex/context/base/core-mis.mkii @@ -1425,12 +1425,12 @@ [\c!bet=\unknown,\c!dat=\unknown,\c!ken=\unknown, \c!from=,\c!to=,\c!ref=,#1]% % moet anders, hoort niet in 01b - \assigntranslation[\s!nl=referentie,\s!en=reference,\s!de=Referenz,\s!sp=referencia]\to\@@@kmref - \assigntranslation[\s!nl=van,\s!en=from,\s!de=Von,\s!sp=de]\to\@@@kmvan - \assigntranslation[\s!nl=aan,\s!en=to,\s!de=An,\s!sp=a]\to\@@@kmaan - \assigntranslation[\s!nl=betreft,\s!en=concerns,\s!de=Betreff,\s!sp=]\to\@@@kmbet - \assigntranslation[\s!nl=datum,\s!en=date,\s!de=Datum,\s!sp=fecha]\to\@@@kmdat - \assigntranslation[\s!nl=kenmerk,\s!en=mark,\s!de=Kennzeichen,\s!sp=]\to\@@@kmken + \assigntranslation[\s!nl=referentie,\s!en=reference,\s!de=Referenz,\s!hr=referenca,\s!sp=referencia]\to\@@@kmref + \assigntranslation[\s!nl=van,\s!en=from,\s!de=Von,\s!hr=od,\s!sp=de]\to\@@@kmvan + \assigntranslation[\s!nl=aan,\s!en=to,\s!de=An,\s!hr=za,\s!sp=a]\to\@@@kmaan + \assigntranslation[\s!nl=betreft,\s!en=concerns,\s!de=Betreff,\s!hr=predmet,\s!sp=]\to\@@@kmbet + \assigntranslation[\s!nl=datum,\s!en=date,\s!de=Datum,\s!hr=datum,\s!sp=fecha]\to\@@@kmdat + \assigntranslation[\s!nl=kenmerk,\s!en=mark,\s!de=Kennzeichen,\s!hr=oznaka,\s!sp=]\to\@@@kmken % \definetabulate[\s!dummy][|l|p|] \startdummy @@ -2697,6 +2697,7 @@ \setuplabeltext [\s!nl] [and-1=\textcomma\ , and-2= en ] \setuplabeltext [\s!en] [and-1=\textcomma\ , and-2=\textcomma\ and ] \setuplabeltext [\s!de] [and-1=\textcomma\ , and-2= und ] +\setuplabeltext [\s!hr] [and-1=\textcomma\ , and-2= i ] %D \macros %D {somekindoftab} diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv index 239af98ad..98f245e0d 100644 --- a/tex/context/base/core-mis.mkiv +++ b/tex/context/base/core-mis.mkiv @@ -1306,12 +1306,12 @@ [\c!bet=\unknown,\c!dat=\unknown,\c!ken=\unknown, \c!from=,\c!to=,\c!ref=,#1]% % moet anders, hoort niet in 01b - \assigntranslation[\s!nl=referentie,\s!en=reference,\s!de=Referenz,\s!sp=referencia]\to\@@@kmref - \assigntranslation[\s!nl=van,\s!en=from,\s!de=Von,\s!sp=de]\to\@@@kmvan - \assigntranslation[\s!nl=aan,\s!en=to,\s!de=An,\s!sp=a]\to\@@@kmaan - \assigntranslation[\s!nl=betreft,\s!en=concerns,\s!de=Betreff,\s!sp=]\to\@@@kmbet - \assigntranslation[\s!nl=datum,\s!en=date,\s!de=Datum,\s!sp=fecha]\to\@@@kmdat - \assigntranslation[\s!nl=kenmerk,\s!en=mark,\s!de=Kennzeichen,\s!sp=]\to\@@@kmken + \assigntranslation[\s!nl=referentie,\s!en=reference,\s!de=Referenz,\s!hr=referenca,\s!sp=referencia]\to\@@@kmref + \assigntranslation[\s!nl=van,\s!en=from,\s!de=Von,\s!hr=od,\s!sp=de]\to\@@@kmvan + \assigntranslation[\s!nl=aan,\s!en=to,\s!de=An,\s!hr=za,\s!sp=a]\to\@@@kmaan + \assigntranslation[\s!nl=betreft,\s!en=concerns,\s!de=Betreff,\s!hr=predmet,\s!sp=]\to\@@@kmbet + \assigntranslation[\s!nl=datum,\s!en=date,\s!de=Datum,\s!hr=datum,\s!sp=fecha]\to\@@@kmdat + \assigntranslation[\s!nl=kenmerk,\s!en=mark,\s!de=Kennzeichen,\s!hr=oznaka,\s!sp=]\to\@@@kmken % \definetabulate[\s!dummy][|l|p|] \startdummy @@ -2440,6 +2440,7 @@ \setuplabeltext [\s!nl] [and-1=\textcomma\ , and-2= en ] \setuplabeltext [\s!en] [and-1=\textcomma\ , and-2=\textcomma\ and ] \setuplabeltext [\s!de] [and-1=\textcomma\ , and-2= und ] +\setuplabeltext [\s!hr] [and-1=\textcomma\ , and-2= i ] %D \macros %D {somekindoftab} diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index eb0990ec1..91fc72e6b 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -62,13 +62,40 @@ local xheightdata = fonts.xheights fonts.ids = fontdata -- we keep this one for a while (as it is used in mk etc) + +-- todo: give parameters at the lua end a metatable + +--~ function parameters(t,k) +--~ local v = 0 +--~ if k == "x_height" then v = t.xheight +--~ elseif k == "space_stretch" then v = t.spacestretch +--~ elseif k == "space_shrink" then v = t.spaceshrink +--~ elseif k == "extra_space" then v = t.extraspace +--~ elseif k == 1 then v = t.slant +--~ elseif k == 2 then v = t.space +--~ elseif k == 3 then v = t.spacestretch +--~ elseif k == 4 then v = t.spaceshrink +--~ elseif k == 5 then v = t.xheight +--~ elseif k == 6 then v = t.quad +--~ elseif k == 7 then v = t.extraspace +--~ end +--~ t[k] = v +--~ return v +--~ end + local nulldata = { name = "nullfont", characters = { }, descriptions = { }, - parameters = { - xheight = 0, - quad = 0, + parameters = { -- lmromanregular @ 12pt + slant = 0, -- 1 + space = 256377, -- 2 + spacestretch = 128188, -- 3 + spaceshrink = 85459, -- 4 + xheight = 338952, -- 5 + quad = 786432, -- 6 + extraspace = 85459, -- 7 + }, } diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index b99d44545..7f8c374ca 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -14,6 +14,8 @@ % runtime commands will move to modules +% todo: (so that we can delay font loading to \starttext + % simplification ... we no longer deal with specific mmtfa specifications % todo: always fontclass, then less testing @@ -4046,6 +4048,16 @@ \def\dolookupgetkey #1{\ctxlua{tex.write(fonts.names.getlookupkey("#1"))}} \def\cleanfontname #1{\ctxlua{fonts.cleanname("#1")}} +% Experiment: + +\fontdimen1\nullfont 0\scaledpoint +\fontdimen2\nullfont 256377\scaledpoint +\fontdimen3\nullfont 128188\scaledpoint +\fontdimen4\nullfont 85459\scaledpoint +\fontdimen5\nullfont 338952\scaledpoint +\fontdimen6\nullfont 786432\scaledpoint +\fontdimen7\nullfont 85459\scaledpoint + \protect \endinput % \startluacode diff --git a/tex/context/base/m-units.tex b/tex/context/base/m-units.tex index 36fa45d84..a06d195ba 100644 --- a/tex/context/base/m-units.tex +++ b/tex/context/base/m-units.tex @@ -490,6 +490,21 @@ u:min=Minuten] \setuplabeltext + [\s!hr] + [u:sec=sekunda, + u:fsec=femtosekunda, + u:psec=pikosekunda, + u:nsec=nanosekunda, + u:usec=mikrosekunda, + u:msec=milisekunda, + u:year=godina, + u:month=mjesec, + u:week=tjedan, + u:day=dan, + u:hour=sat, + u:min=minuta] + +\setuplabeltext [\s!it] [u:sec=secondo, u:fsec=femtosecondo, @@ -525,6 +540,11 @@ u:deg=Gradma\SS] \setuplabeltext + [\s!hr] + [u:rad=radijani, + u:deg=kutni stupnjevi] + +\setuplabeltext [\s!it] [u:rad=radianti, u:deg=angoli sessagesimali] @@ -557,6 +577,11 @@ u:rpm=Umdrehungen pro Minute] \setuplabeltext + [\s!hr] + [u:rps=okretaji po sekundi, + u:rpm=okretaji po minuti] + +\setuplabeltext [\s!it] [u:rps=giri al secondo, u:rpm=giri al minuto] @@ -589,6 +614,10 @@ [u:u=Atomare Masseneinheit] \setuplabeltext + [\s!hr] + [u:u=unificirana atomska jedinica mase] + +\setuplabeltext [\s!it] [u:u=unit\`a di massa atomica] @@ -670,21 +699,42 @@ u:vdc=Gleichspannung] \setuplabeltext + [\s!hr] + [u:vac=izmjeni\ccaron ni napon, + u:vdc=istosmjerni napon] + +\setuplabeltext [\s!it] [u:vac=corrente alternata, u:vdc=corrente continua] -%D Computer memory is specified in Bytes: +%D Network bandwidth is specified in Bits: -\getvalue{\v!unit} [Bit] {bit} {Bit} +\getvalue{\v!unit} [Bit] {bit} {\labeltext{u:bit}} \getvalue{\v!unit} [Baud] {Bd} {Baud (Bit/s)} -\getvalue{\v!unit} [Byte] {B} {Byte} +%D Computer memory size is specified in Bytes: + +\getvalue{\v!unit} [Byte] {B} {\labeltext{u:byte}} \getvalue{\v!unit} [kByte] {\Kilo \Byte} {kilo Byte} \getvalue{\v!unit} [MByte] {\Mega \Byte} {mega Byte} \getvalue{\v!unit} [GByte] {\Giga \Byte} {giga Byte} \getvalue{\v!unit} [TByte] {\Tera \Byte} {tera Byte} +\setuplabeltext + [\s!en] + [u:bit=Bit, + u:byte=Byte] + +\setuplabeltext + [\s!hr] + [u:bit=bit, + u:byte=bajt] + +%D Telecommunication call density is specified in Erlangs: + +\getvalue{\v!unit} [Erlang] {E} {Erlang} + %D Some radiation related units: \getvalue{\v!unit} [Bequerel] {Bq} {Bequerel} @@ -709,7 +759,7 @@ \getvalue{\v!unit} [Bar] {bar} {bar (100 \Kilo \Pascal)} \getvalue{\v!unit} [EVolt] {eV} {electronvolt} \getvalue{\v!unit} [Foot] {ft} {\labeltext{u:ft}} -\getvalue{\v!unit} [Inch] {inch} {inch} +\getvalue{\v!unit} [Inch] {inch} {\labeltext{u:inch}} \getvalue{\v!unit} [Cal] {cal} {\labeltext{u:cal}} \getvalue{\v!unit} [Force] {f} {\labeltext{u:f}} \getvalue{\v!unit} [kCal] {\Kilo \Cal} {\labeltext{u:kcal}} @@ -743,9 +793,10 @@ \setuplabeltext [\s!en] - [u:at=technical atmosferic pressure, - u:atm=physical atmosferic pressure, + [u:at=technical atmospheric pressure, + u:atm=physical atmospheric pressure, u:ft=foot, + u:inch=inch, u:cal=calory, u:f=force, u:kcal=kilocalory] @@ -753,13 +804,23 @@ \setuplabeltext [\s!de] [u:at=Technischer atmosph\"arischer Druck, - u:atm=physkalischer atmosph\"arischer Druck + u:atm=physkalischer atmosph\"arischer Druck, u:ft=Fu\SS, u:cal=Kalorien, u:f=Force, u:kcal=Kilokalorien] \setuplabeltext + [\s!hr] + [u:at=tehni\ccaron ka atmosfera, + u:atm=standardna atmosfera, + u:ft=stopa, + u:inch=in\ccaron a, + u:cal=kalorija, + u:f=Force, + u:kcal=Kilokalorien] + +\setuplabeltext [\s!it] [u:at=pressione atmosferica tecnica, u:atm=pressione atmosfera fisica, diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua index 504c841fa..c97978a79 100644 --- a/tex/context/base/math-vfu.lua +++ b/tex/context/base/math-vfu.lua @@ -27,7 +27,9 @@ fonts.enc.math = mathencodings -- better is then: fonts.enc.vectors local shared = { } fonts.vf.math = fonts.vf.math or { } -fonts.vf.math.optional = false +local vfmath = fonts.vf.math + +vfmath.optional = false --~ local push, pop, back = { "push" }, { "pop" }, { "slot", 1, 0x2215 } @@ -291,7 +293,7 @@ local function stack(main,characters,id,size,unicode,u1,d12,u2) end end -function fonts.vf.math.alas(main,id,size) +function vfmath.alas(main,id,size) local characters = main.characters for i=0x7A,0x7D do make(main,characters,id,size,i,1) @@ -383,7 +385,7 @@ setmetatable ( reverse, { __index = function(t,name) return r end } ) -function fonts.vf.math.define(specification,set) +function vfmath.define(specification,set) local name = specification.name -- symbolic name local size = specification.size -- given size local fnt, lst, main = { }, { }, nil @@ -392,7 +394,7 @@ function fonts.vf.math.define(specification,set) for s=1,#set do local ss = set[s] local ssname = ss.name - if ss.optional and fonts.vf.math.optional then + if ss.optional and vfmath.optional then if trace_virtual then report_virtual("loading font %s subfont %s with name %s at %s is skipped",name,s,ssname,size) end @@ -450,7 +452,7 @@ function fonts.vf.math.define(specification,set) local ss, fs = okset[s], fnt[s] if not fs then -- skip, error - elseif ss.optional and fonts.vf.math.optional then + elseif ss.optional and vfmath.optional then -- skip, redundant else local mm, fp = main.mathparameters, fs.parameters @@ -669,7 +671,7 @@ function fonts.vf.math.define(specification,set) end lst[#lst+1] = { id = font.nextid(), size = size } if mp then -- weak catch - fonts.vf.math.alas(main,#lst,size) + vfmath.alas(main,#lst,size) end if trace_virtual or trace_timings then report_virtual("loading and virtualizing font %s at size %s took %0.3f seconds",name,size,os.clock()-start) @@ -685,7 +687,7 @@ end function mathematics.makefont(name, set) fonts.definers.methods.variants[name] = function(specification) - return fonts.vf.math.define(specification,set) + return vfmath.define(specification,set) end end @@ -898,7 +900,6 @@ mathencodings["tex-mi"] = { -- 0x7F, -- (no idea what that could be) } - mathencodings["tex-it"] = { -- [0x1D434] = 0x41, -- A [0x1D6E2] = 0x41, -- Alpha @@ -976,7 +977,7 @@ mathencodings["tex-bi"] = { } mathencodings["tex-fraktur"] = { } mathencodings["tex-fraktur-bold"] = { } -function fonts.vf.math.setletters(font_encoding, name, uppercase, lowercase) +function vfmath.setletters(font_encoding, name, uppercase, lowercase) local enc = font_encoding[name] for i = 0,25 do enc[uppercase+i] = i + 0x41 @@ -984,7 +985,7 @@ function fonts.vf.math.setletters(font_encoding, name, uppercase, lowercase) end end -function fonts.vf.math.setdigits(font_encoding, name, digits) +function vfmath.setdigits(font_encoding, name, digits) local enc = font_encoding[name] for i = 0,9 do enc[digits+i] = i + 0x30 @@ -1462,19 +1463,19 @@ mathencodings["tex-fraktur"] = { -- now that all other vectors are defined ... -fonts.vf.math.setletters(mathencodings, "tex-it", 0x1D434, 0x1D44E) -fonts.vf.math.setletters(mathencodings, "tex-ss", 0x1D5A0, 0x1D5BA) -fonts.vf.math.setletters(mathencodings, "tex-tt", 0x1D670, 0x1D68A) -fonts.vf.math.setletters(mathencodings, "tex-bf", 0x1D400, 0x1D41A) -fonts.vf.math.setletters(mathencodings, "tex-bi", 0x1D468, 0x1D482) -fonts.vf.math.setletters(mathencodings, "tex-fraktur", 0x1D504, 0x1D51E) -fonts.vf.math.setletters(mathencodings, "tex-fraktur-bold", 0x1D56C, 0x1D586) +vfmath.setletters(mathencodings, "tex-it", 0x1D434, 0x1D44E) +vfmath.setletters(mathencodings, "tex-ss", 0x1D5A0, 0x1D5BA) +vfmath.setletters(mathencodings, "tex-tt", 0x1D670, 0x1D68A) +vfmath.setletters(mathencodings, "tex-bf", 0x1D400, 0x1D41A) +vfmath.setletters(mathencodings, "tex-bi", 0x1D468, 0x1D482) +vfmath.setletters(mathencodings, "tex-fraktur", 0x1D504, 0x1D51E) +vfmath.setletters(mathencodings, "tex-fraktur-bold", 0x1D56C, 0x1D586) -fonts.vf.math.setdigits (mathencodings, "tex-ss", 0x1D7E2) -fonts.vf.math.setdigits (mathencodings, "tex-tt", 0x1D7F6) -fonts.vf.math.setdigits (mathencodings, "tex-bf", 0x1D7CE) +vfmath.setdigits (mathencodings, "tex-ss", 0x1D7E2) +vfmath.setdigits (mathencodings, "tex-tt", 0x1D7F6) +vfmath.setdigits (mathencodings, "tex-bf", 0x1D7CE) --- fonts.vf.math.setdigits (mathencodings, "tex-bi", 0x1D7CE) +-- vfmath.setdigits (mathencodings, "tex-bi", 0x1D7CE) -- todo: add ss, tt, bf etc vectors -- todo: we can make ss tt etc an option diff --git a/tex/context/base/node-bck.mkiv b/tex/context/base/node-bck.mkiv index 18149ef4d..88fb390a9 100644 --- a/tex/context/base/node-bck.mkiv +++ b/tex/context/base/node-bck.mkiv @@ -20,10 +20,19 @@ \registerctxluafile{node-bck}{1.001} +\def\doinitializeboxbackgrounds + {\ctxlua{nodes.tasks.enableaction("shipouts","nodes.handlers.backgrounds")}% + \glet\doinitializeboxbackgrounds\donothing} + %D Box helpers: +% \backgroundvbox[green] {\input tufte } \par +% \backgroundvbox[blue] {\input ward } \par +% \backgroundvbox[red] {\input knuth } \par +% \backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par + \def\doaddbackgroundtobox#1[#2]% - {\begingroup\faststartcolor[#2]% + {\begingroup\doinitializeboxbackgrounds\faststartcolor[#2]% \normalexpanded{\noexpand\faststopcolor\endgroup#1 attr \backgroundattribute \plusone attr \colormodelattribute \the\attribute\colormodelattribute @@ -63,100 +72,4 @@ % \def\backgroundvtop[#1]{\vtop \backgroundcolorattr{#1}} % \def\backgroundhbox[#1]{\hbox \backgroundcolorattr{#1}} -%D tabulate: - -\def\tabulatenormalcolumn#1% - {\doiffastoptionalcheckelse{\tabulatenormalcolumnyes#1}{\tabulatenormalcolumnnop#1}} - -\def\tabulatenormalcolumnnop#1% overloads anch-pgr - {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi&\global\tabulatetype#1&} - -\def\tabulatenormalcolumnyes#1[#2]% - {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi&\global\tabulatetype#1&% - \iftrialtypesetting\else\settabulatecolor{#2}\fi\ignorespaces} - -\newcount\maxtabularcolorcolumn - -\def\settabulatecolor#1% we could store the attributes at the cost of a lua call - {\begingroup - \global\settrue\tabulatehascolors - \ifnum\tabulatecolumn>\maxtabularcolorcolumn - \global\maxtabularcolorcolumn\tabulatecolumn - \fi - \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}% - \attribute\backgroundattribute\plusone - \faststartcolor[#1]\strut\char0\faststopcolor - \endgroup} - -\def\repeatsettabulatecolor - {\begingroup - \ifcsname\??tt:c:\the\tabulatecolumn\endcsname - \attribute\backgroundattribute\plusone - \faststartcolor[\csname\??tt:c:\the\tabulatecolumn\endcsname]\strut\char0\faststopcolor - \fi - \endgroup} - -\def\resettabulatecolors - {\ifcase\maxtabularcolorcolumn\else - \doresettabulatecolors - \fi} - -\def\doresettabulatecolors - {\dorecurse\maxtabularcolorcolumn{\letgvalue{\??tt:c:\recurselevel}\undefined}} % slow - -\appendtoks - \resettabulatecolors -\to \everyaftertabulaterow - -\def\splitofftabulatebox % overloads in anch-pgr - {\dontcomplain - \global\setbox\tabulatebox % % % global ? % % % - \vsplit\tablebox\tabulatecolumn to \lineheight - \setbox\tabulatebox\normalvbox - {\unvbox\tabulatebox}% - \setbox\tabulatebox\hbox to \wd\tabulatebox - {\iftrialtypesetting\else\ifconditional\tabulatehascolors\repeatsettabulatecolor\fi\fi - \hss\dotabulatehook{\box\tabulatebox}\hss}% - \donormalizetabulatesplitline - \box\tabulatebox - \iftrialtypesetting\else\ifconditional\tablehaspositions\doflushtabulateepos\fi\fi} - -\appendtoks - \global\setfalse\tabulatehascolors -\to \everytabulate - \protect \endinput - -% test - -\starttext - -\backgroundvbox[green] {\input tufte } \par -\backgroundvbox[blue] {\input ward } \par -\backgroundvbox[red] {\input knuth } \par -\backgroundhbox[yellow]{\rotate[rotation=45]{hello world}} \par - -\starttabulate[||p||] -\NC test \NC test \NC test \NC \NR -\NC test \NC[green] \input tufte \NC[yellow] test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC[blue] test \NC[red] test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC[gray] test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC[blue] test \NC test \NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC test \NC[magenta] test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR -\NC test \NC test \NC test \NC \NR -\NC test \NC[yellow] test \NC test \NC \NR -\stoptabulate - -\stoptext diff --git a/tex/context/base/pack-lyr.mkiv b/tex/context/base/pack-lyr.mkiv index 8b35a98a7..955381d62 100644 --- a/tex/context/base/pack-lyr.mkiv +++ b/tex/context/base/pack-lyr.mkiv @@ -639,117 +639,6 @@ [\c!background={\v!foreground,#1}, \c!frame=\v!off, \c!offset=\v!overlay,#2]} - -% The next mechanism is obsolete and will be removed in \MKIV\ (or move to -% the compatibility module. - -\newskip\xposition \newskip\yposition -\newskip\xdimension \newskip\ydimension -\newskip\xoffset \newskip\yoffset - -% already defined \newbox\positionbox - -\unexpanded\def\startpositioning - {\bgroup - \xposition \zeropoint \yposition \zeropoint - \xdimension\zeropoint \ydimension\zeropoint - \xoffset \zeropoint \yoffset \zeropoint - \hfuzz \paperwidth \vfuzz \paperheight - \setbox\positionbox\hbox\bgroup} - -\unexpanded\def\stoppositioning - {\doifnot\@@psoffset\v!yes - {\global\xoffset\zeropoint - \global\yoffset\zeropoint}% - \global\advance\xdimension \xoffset - \global\advance\ydimension \yoffset - \egroup - \vbox to \ydimension - {\vskip\yoffset - \hbox to \xdimension - {\hskip\xoffset - \box\positionbox - \hfill} - \vfill}% - \egroup} - -\def\resetpositioning - {\getparameters[\??ps] - [\c!state=\v!start,% - \c!unit=\s!cm,% - \c!factor=1,% - \c!scale=1,% - \c!xfactor=\@@psfactor,% - \c!yfactor=\@@psfactor,% - \c!xscale=\@@psscale,% - \c!yscale=\@@psscale,% - \c!xstep=\v!absolute,% - \c!ystep=\v!absolute,% - \c!xoffset=\!!zeropoint,% - \c!yoffset=\!!zeropoint]} - -\unexpanded\def\setuppositioning - {\resetpositioning - \dodoubleargument\getparameters[\??ps]} - -\def\calculateposition#1#2#3#4#5#6#7#8#9% - {\setdimensionwithunit\scratchskip{#1}\@@psunit - \scratchskip#8\scratchskip - \scratchskip#9\scratchskip - \advance\scratchskip #4\relax - \doif{#2}\v!relative - {\advance\scratchskip #3% - \let#4\!!zeropoint}% - #3\scratchskip\relax - \doifnot\@@psstate\v!overlay - {\scratchskip#5\relax - \advance\scratchskip #3\relax - \ifdim#3<-#7\relax \global#7-#3\relax \fi - \ifdim\scratchskip>#6\relax \global#6\scratchskip\relax \fi}} - -\def\position - {\dosingleempty\doposition} - -\def\doposition[#1]#2(#3,#4)% - {\dowithnextbox - {\bgroup - \getparameters[\??ps][#1]% - \dontcomplain - \calculateposition{#3}\@@psxstep\xposition - \@@psxoffset{\nextboxwd}\xdimension\xoffset - \@@psxscale\@@psxfactor - \scratchdimen\nextboxht \advance\scratchdimen \nextboxdp - \calculateposition{#4}\@@psystep\yposition - \@@psyoffset\scratchdimen\ydimension\yoffset - \@@psyscale\@@psyfactor - \vbox to \zeropoint % kan beter. - {\vskip\yposition - \hbox to \zeropoint - {\hskip\xposition - \flushnextbox - \hss} - \vss}% - \xdef\dopoppositioning - {\xposition\the\xposition - \yposition\the\yposition - \noexpand\def\noexpand\@@psxoffset{\@@psxoffset}% - \noexpand\def\noexpand\@@psyoffset{\@@psyoffset}}% - \egroup - \dopoppositioning - \ignorespaces} - \hbox} - -\resetpositioning - -\setuppositioning - [\c!unit=\s!cm, - \c!factor=1, - \c!scale=1, - \c!xstep=\v!absolute, - \c!ystep=\v!absolute, - \c!offset=\v!yes, - \c!xoffset=\!!zeropoint, - \c!yoffset=\!!zeropoint] %D Watch out, a redefinition: diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv new file mode 100644 index 000000000..42a80b5ae --- /dev/null +++ b/tex/context/base/pack-pos.mkiv @@ -0,0 +1,151 @@ +%D \module +%D [ file=pack-pos, +%D version=2010.11.17 % real old code, updated a bit +%D title=\CONTEXT\ Packaging Macros, +%D subtitle=Positioning, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=PRAGMA-ADE] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Packaging Macros / Positioning} + +\unprotect + +% An old but still usefull mechanism (updated in mkiv): +% +% \ruledvbox{\startpositioning +% \position(1,1){test} +% \position[xstep=relative](1,1){test} +% \position[ystep=relative](3,-1){test} +% \position(10,10){test} +% \stoppositioning} + +\newdimen\positioningxposition \newdimen\positioningyposition +\newdimen\positioningxdimension \newdimen\positioningydimension +\newdimen\positioningxoffset \newdimen\positioningyoffset + +\newbox\positioningbox + +\unexpanded\def\startpositioning + {\dosingleempty\dostartpositioning} + +\def\dostartpositioning[#1]% + {\bgroup + \getparameters[\??ps][#1]% + \positioningxposition \zeropoint \positioningyposition \zeropoint + \positioningxdimension\zeropoint \positioningydimension\zeropoint + \positioningxoffset \zeropoint \positioningyoffset \zeropoint + \hfuzz \paperwidth \vfuzz \paperheight + \setbox\positioningbox\hbox\bgroup + \ignorespaces} + +\unexpanded\def\stoppositioning + {\removeunwantedspaces + \doifnot\@@psoffset\v!yes + {\global\positioningxoffset\zeropoint + \global\positioningyoffset\zeropoint}% + \global\advance\positioningxdimension \positioningxoffset + \global\advance\positioningydimension \positioningyoffset + \egroup + \vbox to \positioningydimension + {\vskip\positioningyoffset + \hbox to \positioningxdimension + {\hskip\positioningxoffset + \box\positioningbox + \hfill} + \vfill}% + \egroup} + +% \def\resetpositioning +% {\getparameters[\??ps] +% [\c!state=\v!start, +% \c!unit=\s!cm, +% \c!factor=\plusone, +% \c!scale=\plusone, +% \c!xfactor=\@@psfactor, +% \c!yfactor=\@@psfactor, +% \c!xscale=\@@psscale, +% \c!yscale=\@@psscale, +% \c!xstep=\v!absolute, +% \c!ystep=\v!absolute, +% \c!xoffset=\zeropoint, +% \c!yoffset=\zeropoint]} + +\def\resetpositioning + {\let\@@psstate \v!start + \let\@@psunit \s!cm + \let\@@psfactor \plusone + \let\@@psscale \plusone + \def\@@psxfactor{\@@psfactor}% + \def\@@psyfactor{\@@psfactor}% + \def\@@psxscale {\@@psscale}% + \def\@@psyscale {\@@psscale}% + \let\@@psxstep \v!absolute + \let\@@psystep \v!absolute + \let\@@psxoffset \zeropoint + \let\@@psyoffset \zeropoint} + +\resetpositioning + +\unexpanded\def\setuppositioning + {\resetpositioning + \dodoubleargument\getparameters[\??ps]} + +\def\calculateposition#1#2#3#4#5#6#7#8#9% + {\setdimensionwithunit\scratchdimen{#1}\@@psunit + \scratchdimen#8\scratchdimen + \scratchdimen#9\scratchdimen + \advance\scratchdimen #4\relax + % == \scratchdimen\dimexpr#8\dimexpr#9\scratchdimen\relax+#4\relax + \doif{#2}\v!relative + {\advance\scratchdimen#3% + \let#4\zeropoint}% + #3\scratchdimen + \doifnot\@@psstate\v!overlay + {\scratchdimen\dimexpr#5+#3\relax + \ifdim #3<-#7\relax \global#7-#3\relax \fi + \ifdim\scratchdimen> #6\relax \global#6\scratchdimen\fi}} + +\def\position + {\dosingleempty\doposition} + +\def\doposition[#1]#2(#3,#4)% + {\removeunwantedspaces + \dowithnextbox{\dodoposition{#1}{#2}{#3}{#4}}\hbox} + +\def\dodoposition#1#2#3#4% + {\bgroup + \dontcomplain + \getparameters[\??ps][#1]% + \calculateposition{#3}\@@psxstep\positioningxposition\@@psxoffset\nextboxwd \positioningxdimension\positioningxoffset\@@psxscale\@@psxfactor + \calculateposition{#4}\@@psystep\positioningyposition\@@psyoffset\nextboxhtdp\positioningydimension\positioningyoffset\@@psyscale\@@psyfactor + \vbox to \zeropoint + {\vskip\positioningyposition + \hbox to \zeropoint + {\hskip\positioningxposition + \flushnextbox + \hss} + \vss}% + \normalexpanded + {\egroup + \positioningxposition\the\positioningxposition + \positioningyposition\the\positioningyposition + \def\noexpand\@@psxoffset{\the\dimexpr\@@psxoffset}% + \def\noexpand\@@psyoffset{\the\dimexpr\@@psyoffset}}% + \ignorespaces} + +\setuppositioning + [\c!unit=\s!cm, + \c!factor=\plusone, + \c!scale=\plusone, + \c!xstep=\v!absolute, + \c!ystep=\v!absolute, + \c!offset=\v!yes, + \c!xoffset=\zeropoint, + \c!yoffset=\zeropoint] + +\protect \endinput diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua index 0ea352656..f92d594ab 100644 --- a/tex/context/base/strc-mar.lua +++ b/tex/context/base/strc-mar.lua @@ -166,9 +166,9 @@ function marks.define(name,settings) else local dp = data[parent] if not dp then - setting.parent = false + settings.parent = false elseif dp.parent then - setting.parent = dp.parent + settings.parent = dp.parent end end setmetatable(settings, { __index = resolve } ) diff --git a/tex/context/base/strc-not.mkiv b/tex/context/base/strc-not.mkiv index 183ef65a1..518b97ec6 100644 --- a/tex/context/base/strc-not.mkiv +++ b/tex/context/base/strc-not.mkiv @@ -372,7 +372,7 @@ {% node states \setnotelocation\plusone % page \setnoteposition\plustwo % high - \normalexpanded{\noexpand\rawprocesscommalist[\noteparameter\c!location]}\dosetcheckednote + \normalexpanded{\rawprocesscommalist[\noteparameter\c!location]}\dosetcheckednote % compatibility hack %ifnum\noteparameter\s!noteloc=\plusfive \endnotestrue \else \endnotesfalse \fi \ifnum\noteparameter\s!notepos=\plustwo \bottomnotestrue \else \bottomnotesfalse \fi diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv index a419e1801..b47caca9d 100644 --- a/tex/context/base/supp-box.mkiv +++ b/tex/context/base/supp-box.mkiv @@ -614,9 +614,10 @@ %D The next couple of shortcuts saves us memory as well as %D \type {{}}'s in passing parameters. -\def\nextboxht{\ht\nextbox} -\def\nextboxwd{\wd\nextbox} -\def\nextboxdp{\dp\nextbox} +\def\nextboxht {\ht\nextbox} +\def\nextboxwd {\wd\nextbox} +\def\nextboxdp {\dp\nextbox} +\def\nextboxhtdp {\dimexpr\ht\nextbox+\dp\nextbox\relax} \def\flushnextbox{\box\nextbox} diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index 90153f006..27dfe9594 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -1028,6 +1028,7 @@ \else \@EA\dodoprocesscommaitemindeed \fi} + \def\dodoprocesscommaitemindeed {\ifx\nexttoken]% \@EA\gobbleoneargument @@ -1042,7 +1043,7 @@ %D however are treated. We have to check for the special case %D \type{[{a,b,c}]}. -\def\processcommalist[% +\unexpanded\def\processcommalist[% {\futurelet\nexttoken\docheckcommaitem} \def\docheckcommaitem @@ -1116,7 +1117,7 @@ % \def\processcommacommand[#1]% % {\expanded{\processcommalist[#1]}} -\def\processcommacommand[#1]% +\unexpanded\def\processcommacommand[#1]% {\expandafter\processcommalist\expandafter[\normalexpanded{#1}]} % \def\processcommacommand[#1]% @@ -1557,7 +1558,7 @@ \expandafter\rawprocesscommaitem#1,],% \relax \global\advance\commalevel \minusone } -\def\rawprocesscommacommand[#1]% not really needed +\unexpanded\def\rawprocesscommacommand[#1]% not really needed {\normalexpanded{\rawprocesscommalist[#1]}} % \def\rawdoifinsetelse#1#2{\doifinstringelse{,#1,}{,#2,}} diff --git a/tex/context/base/tabl-tbl.lua b/tex/context/base/tabl-tbl.lua new file mode 100644 index 000000000..dbb3cfd37 --- /dev/null +++ b/tex/context/base/tabl-tbl.lua @@ -0,0 +1,36 @@ +if not modules then modules = { } end modules ['tabl-tbl'] = { + version = 1.001, + comment = "companion to tabl-tbl.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- A couple of hacks ... easier to do in Lua than in regular +-- TeX. More will follow. + +local tonumber = tonumber +local gsub, rep, sub = string.gsub, string.rep, string.sub + +local P, C, Cc, Ct, lpegmatch = lpeg.P, lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.match + +local settexcount = tex.setcount + +local separator = P("|") +local nested = lpeg.patterns.nested +local pattern = Ct((separator * (C(nested) + Cc("")) * C((1-separator)^0))^0) + +function commands.presettabulate(preamble) + preamble = gsub(preamble, "%*(%b{})(%b{})", function(n,p) + return rep(sub(p,2,-2),tonumber(sub(n,2,-2)) or 1) + end) + local t = lpegmatch(pattern,preamble) + local m = #t - 2 + settexcount("global","noftabulatecolumns", m/2) + settexcount("global","tabulatehasfirstrulespec", t[1] == "" and 0 or 1) + settexcount("global","tabulatehaslastrulespec", t[m+1] == "" and 0 or 1) + for i=1,m,2 do + context.settabulateentry(t[i],t[i+1]) + end + context.setlasttabulateentry(t[m+1]) +end diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index afdf210e1..65da7c103 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -13,34 +13,35 @@ \writestatus{loading}{ConTeXt Table Macros / Tabulation} -% \processbetween gebruiken in head/tail macros - -% todo: \aligntab \alignmark (after 0.60 is out) - \unprotect -%D I can probably reimplement this using a \LUA||\TEX\ combination +\registerctxluafile{tabl-tbl.lua}{1.001} % experiment + +%D I can probably reimplement this using a \LUATEX\ combination %D but it does not pay of in development time. If I need something %D else I will write it from scratch anyway. +%D +%D I never really looked at the preamble code of TaBlE (at that time +%D I simply didn't look into alignments too much) but there seem to +%D be some similarities with the following code. So, maybe it's not +%D too much work to rewrite that package in a more contexty style. If +%D it makes sense to do that remains to be seen. We might as well +%D drop it. +%D +%D Be careful with changing the hsize calculation in p mode; +%D the following code works quite well: +%D +%D \starttyping +%D \setupfield [line][location=low,height=1.2\lineheight,width=\hsize] +%D \definefield [test] [line] [line] [] +%D +%D \starttabulate[|l|p|] +%D \NC test \NC \field [test] \NC \NR +%D \stoptabulate +%D \stoptyping -% watch out: don't change this model else trialtypesetting -% compatibility problems - -% watch out, cells expand pretty late on a per row basis - -% |p2|p3| 2:3 -% spanning - -% Be careful with changing the hsize calculation in p mode; -% the following code works quite well: -% -% \setupfield [line][location=low,height=1.2\lineheight,width=\hsize] -% \definefield [test] [line] [line] [] +% |p2|p3| 2:3 -> spanning % -% \starttabulate[|l|p|] -% \NC test \NC \field [test] \NC \NR -% \stoptabulate - % In-text tabbing environment % % \starttabulate[| separated template] % eg [|l|p|] or [|l|p|p|] @@ -49,7 +50,7 @@ % % with: two pass auto width calculation when no p-width % specified, even with multiple p's, see examples. - +% % TaBlE compatible specifications: % % l align column/paragraph left @@ -71,51 +72,55 @@ % i i<n> skip left of column % j i<n> skip right of column % k i<n> skip around column - +% +% C [C\L\M\R] {color} +% +% | {color,n} +% % s setups - +% % g g{char} align at char % . align at . % , align at , - +% % Still to be done - +% % N math numbers (best hook into existing digits mechanism) % n numbers (best hook into existing digits mechanism) % Q math numbers (best hook into existing digits mechanism) % q numbers (best hook into existing digits mechanism) % ~ \hskip.5em % | check - +% % nesting - +% % 10 evt auto stack; dan wel andere signal dan void nodig - +% % present but not yet 100% ok % % \FL top hrule % \ML mid hrule (with auto split) % \LL bottom hrule % \HL - -% \VL as soon as needed -% color as soon as needed - -% \EQ \RQ \HQ equal (raw, hook) -% \NC \RC \HC normal (raw, hook) +% \VL +% +% \CC \CL \CM \CR color +% +% \EQ \RQ \HQ equal (raw, hook) +% \NC \RC \HC normal (raw, hook) % % \NR - +% % \HR : rule with lineheight - +% % \autotabulaterule : with lineheight, not first/last % \autotabulateline : spaced, not first/last % \tabulaterule : with lineheight % \tabulateline : spaced - +% % tricky: align scans ahead, over # and expands ones before % while doing - +% % new: % % \starttabulate[|cg{.}|cg{,}|cg{,}|] @@ -148,43 +153,90 @@ % \NC 500 \NC \NC 20 \NC \NC 100 \NC \NR % \stoptabulate -\newtoks \tabulatepreamble -\newtoks \tabulatebefore -\newtoks \tabulateafter -\newtoks \tabulatebmath -\newtoks \tabulateemath -\newtoks \tabulatefont -\newtoks \tabulatesettings -\newtoks \tabulatedummy +\newtoks \tabulatepreamble +\newtoks \tabulatebefore +\newtoks \tabulateafter +\newtoks \tabulatebmath +\newtoks \tabulateemath +\newtoks \tabulatefont +\newtoks \tabulatesettings +\newtoks \tabulatedummy + +\newcount \nofautotabulate +\newcount \tabulatecolumns +\newcount \tabulatecolumn + +\newcount \noftabulatecolumns % set by parser + +\newcount \tabulateminplines +\newcount \tabulatemaxplines + +\newif \iftracetabulate + +\newconditional \tabulatenopbreak +\newconditional \tabulatefirstflushed +\newconditional \tabulateequal +\newconditional \tabulatesplit \settrue\tabulatesplit +\newconditional \ifautotabulate +\newconditional \tabulatehandlepbreak \settrue\tabulatehandlepbreak + +\newdimen \tabulatepwidth +\newdimen \tabulatexwidth +\newdimen \tabulatewidth +\newdimen \tabulateunit +\newdimen \tabulatemaxpheight + +\newskip \tabulatepreskip +\newskip \tabulateposskip +\newskip \firstpretabskip +\newskip \lastposttabskip + +\newbox \tabulatebox -\newcount \nofautotabulate -\newcount \tabulatecolumns -\newcount \tabulatecolumn +\newtoks \everytabulaterow +\newtoks \everytabulatepar +\newtoks \everyaftertabulaterow +\newtoks \everytabulate -\newcount \tabulateminplines -\newcount \tabulatemaxplines +\newconditional \tabulateautorulespacing \settrue\tabulateautorulespacing +\newcount \tabulatehasfirstrulespec % for the moment a count +\newcount \tabulatehaslastrulespec % for the moment a count +\newconditional \tabulatesomeamble +\newconstant \tabulatepass -\newif \ifautotabulate -\newif \ifsplittabulate \splittabulatetrue +\setnewconstant \tabulatesplitlinemode \plusone -\newif \ifhandletabulatepbreak \handletabulatepbreaktrue -\newif \iftabulatenopbreak \tabulatenopbreakfalse +\newconstant \tabulatecolorspan +\newconstant \tabulatelocalcolorspan -\newif \iftabulateequal -\newif \iftracetabulate -\newif \ifframedtabulate +\newdimen \defaulttabulatevrulethickness +\newdimen \tabulatevrulethickness +\newdimen \tabulatelocalvrulethickness -\newdimen \tabulatepwidth -\newdimen \tabulatexwidth -\newdimen \tabulatewidth -\newdimen \tabulateunit -\newdimen \tabulatemaxpheight +\newskip \tabulateseparatorskip -\newbox \tabulatebox +\newcount \maxtabularcolorcolumn + +\newif \iftolerantTABLEbreak % used in styles ! + +\newcount \tabulaterepeathead +\newcount \noftabulatelines +\newcount \totalnoftabulatelines +\newcount \minusnoftabulatelines + +\newconstant \tabulatetype + +% 0 = NC column next EQ equal column +% 1 = RC column raw RQ equal column raw +% 2 = HC column hook HQ equal column hook + +% for old times sake: + +\def\handletabulatepbreakfalse{\setfalse\tabulatehandlepbreak} % depricated % [|lg{.}|] => \NG 12.34 \NC -\gdef\handletabulatecharalign#1 % space delimited ! +\gdef\handletabulatecharalign#1 % space delimited ! (will be redone in lua) {\edef\alignmentclass{\the\tabulatecolumn}% \edef\alignmentcharacter{\csname\??tt:a:\the\tabulatecolumn\endcsname}% \ifcase\tabulatepass\or @@ -230,7 +282,7 @@ {\noalign{\dodotabulatenobreak}} \unexpanded\def\notabulatehook - {} + {} \unexpanded\def\checktabulatehook {\ifnum\tabulatetype<\plustwo @@ -242,80 +294,6 @@ \unexpanded\def\checktabulatesetups {\csname\??tt:s:\the\tabulatecolumn\endcsname} -\let\pretabrule \donothing -\let\posttabrule\donothing - -% 0 = NC column next EQ equal column -% 1 = RC column raw RQ equal column raw -% 2 = HC column hook HQ equal column hook -% some entries can be left out if we test for them being set - -% \def\dodosettabulatepreamble#1#2% -% {\ifzeropt\tabulatewidth -% \ifcase\tabulatemodus\relax -% \let\preamblebox\empty -% \else -% \def\preamblebox{\autotabulatetrue}% -% \fi -% \else -% \ifcase\tabulatemodus\relax -% \edef\preamblebox{\hbox to \the\tabulatewidth}% -% \else -% \edef\preamblebox{\hsize\the\tabulatewidth}% -% \fi -% \fi -% % -% % less bytes -% % -% %\edef\preamblebox% -% % {\ifcase\tabulatewidth -% % \ifcase\tabulatemodus\relax\else\noexpand\autotabulatetrue\fi -% % \els -% % \ifcase\tabulatemodus\relax\hbox to\else\hsize\fi\the\tabulatewidth -% % \fi}% -% % -% \@EA\appendtoks \@EA&\@EA\hskip\pretabskip\pretabrule##&\to\!!toksa -% \appendtoks \ignorespaces\to\!!toksa -% \@EA\appendtoks\@EA\global\@EA\tabulatecolumn\the\tabulatecolumns\relax\to\!!toksa -% \appendtoks \checktabulatesetups\to\!!toksa -% \appendtoks \checktabulatehook\to\!!toksa -% \@EA\appendtoks \preamblebox\to\!!toksa -% \appendtoks \bgroup\bbskip\bgroup#1\to\!!toksa -% \appendtoks\ifnum\tabulatetype=\plusone \else \to\!!toksa -% \@EA\appendtoks \the\tabulatebmath\to\!!toksa -% \@EA\appendtoks \the\tabulatefont\to\!!toksa -% \@EA\appendtoks \the\tabulatesettings\to\!!toksa -% \@EA\appendtoks \the\tabulatebefore\to\!!toksa -% \appendtoks\fi \to\!!toksa -% \appendtoks \bgroup\ignorespaces\to\!!toksa -% % -% \appendtoks \tabulatehook##\to\!!toksa -% % -% %%\doifdefinedelse{\??tt:a:\tabulatecolumns} -% %\doifdefinedelse{\??tt:a:\the\tabulatecolumns} -% % {\appendtoks\handletabulatecharalign## \to\!!toksa} -% % {\appendtoks\tabulatehook ##\to \!!toksa}% -% % waarom kan ik hier geen \xx{##} geven, om een of -% % andere reden passeert dan tex de hele regel (incl \NC's) -% % als argument; elke delimiter <> space gaat trouwens fout -% \appendtoks \unskip\unskip\ifmmode\else\endgraf\fi\egroup\to\!!toksa -% \appendtoks\ifnum\tabulatetype=1 \else \to\!!toksa -% \@EA\appendtoks \the\tabulateafter\to\!!toksa -% \@EA\appendtoks \the\tabulateemath\to\!!toksa -% \appendtoks\fi \to\!!toksa -% \appendtoks #2\egroup\egroup\to\!!toksa -% \@EA\appendtoks \@EA&\@EA\posttabrule\@EA\hskip\postabskip##\to\!!toksa -% \appendtoks\NC\to\tabulatedummy -% \let\bbskip\empty -% \def\pretabskip{.5\tabulateunit}% -% \let\postabskip\pretabskip -% \let\gettabulateexit\dogettabulateexit -% \tabulatewidth\zeropoint} -% -% speedup: - -% is grouping really needed here? - \unexpanded\def\beforetabulateentry{\ignorespaces\tabulatehook} \unexpanded\def\aftertabulateentry {\unskip\unskip\ifmmode\else\endgraf\fi} @@ -328,16 +306,77 @@ \let\dotagtabulatealign\relax +\unexpanded\def\dochecklocaltabulatecolor#1#2% + {\relax + \ifx\currenttabulatelocalcolor\empty + \gdef\currenttabulatecolor{#1}% + \else + \global\let\currenttabulatecolor\currenttabulatelocalcolor + \global\let\currenttabulatelocalcolor\empty + \fi + \ifcase\tabulatelocalcolorspan + \global\tabulatecolorspan#2\relax + \else + \global\tabulatecolorspan\tabulatelocalcolorspan + \global\tabulatelocalcolorspan\zerocount + \fi} + +\unexpanded\def\dochecklocaltabulatevrulecolor#1#2% + {\relax + \ifx\currenttabulatelocalvrulecolor\empty + \gdef\currenttabulatevrulecolor{#1}% + \else + \global\let\currenttabulatevrulecolor\currenttabulatelocalvrulecolor + \global\let\currenttabulatelocalvrulecolor\empty + \fi + \ifcase\tabulatelocalvrulethickness + \global\tabulatevrulethickness#2\relax + \else + \global\tabulatevrulethickness\tabulatelocalvrulethickness + \global\tabulatelocalvrulethickness\zeropoint + \fi} + +\unexpanded\def\dotabulatepreskip#1% + {\ifdim#1>\zeropoint + \hskip#1\relax + \else\ifnum\tabulatecolumn=\zerocount + \ifconditional\tabulateautorulespacing + \ifcase\tabulatehasfirstrulespec\else + \hskip\firstpretabskip\relax + \fi + \fi + \fi\fi} + +\unexpanded\def\dotabulatepostskip#1% + {\ifdim#1>\zeropoint + \hskip#1\relax + \else\ifnum\tabulatecolumns=\noftabulatecolumns + \ifconditional\tabulateautorulespacing + \ifcase\tabulatehaslastrulespec\else + \hskip\lastposttabskip\relax + \fi + \fi + \fi\fi} + \def\dodosettabulatepreamble#1#2% only makes sense for many tabulates - {\normalexpanded{\!!toksa{\the\!!toksa - &\hskip\pretabskip\noexpand\pretabrule##&% - % \ignorespaces + {\normalexpanded{\tabulatepreamble{\the\tabulatepreamble + \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}% + \dochecklocaltabulatecolor{\currenttabulatecolor}{\number\tabulatecolorspan}% + \dorightsidetabulatecolor + \aligntab + \dotabulatevrule + \doleftsidetabulatecolor + \dotabulatepreskip{\the\tabulatepreskip}% + \alignmark\alignmark + \aligntab + \dobothsidetabulatecolor + \global\tabulatecolorspan\zerocount \global\tabulatecolumn\the\tabulatecolumns\relax \checktabulatesetups % unexpandable \checktabulatehook % unexpandable \ifzeropt\tabulatewidth \ifcase\tabulatemodus\else - \noexpand\autotabulatetrue + \noexpand\settrue\noexpand\autotabulate \fi \else \ifnum\tabulatemodus=\zerocount @@ -350,8 +389,8 @@ \bgroup \noexpand\bbskip \bgroup % we cannot combine the if because a cell may have only one ## -\noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty -\dotagtabulatealign + \noexpand\dostarttagged\noexpand\t!tabulatecell\noexpand\empty + \dotagtabulatealign \noexpand#1% \ifcase\tabulatereshape\else \beginreshapedtabulatepar @@ -363,10 +402,10 @@ \the\tabulatebefore \noexpand\fi % grouping needs to be outside macros (or expandable), nice test - % example \NC \string & \NC which will fail otherwise (mk) + % example \NC \string \aligntab \NC which will fail otherwise (mk) \bgroup \beforetabulateentry - ##% + \alignmark\alignmark \aftertabulateentry \egroup \noexpand\ifnum\noexpand\tabulatetype=\plusone\noexpand\else @@ -377,77 +416,73 @@ \endreshapedtabulatepar \fi \noexpand#2% -\noexpand\dostoptagged + \noexpand\dostoptagged \egroup \egroup - &\noexpand\posttabrule\hskip\postabskip##% + \aligntab + \dotabulatepostskip{\the\tabulateposskip}% + \alignmark\alignmark }}% \appendtoks\NC\to\tabulatedummy - \let\bbskip\empty % ? - \def\pretabskip{.5\tabulateunit}% - \let\postabskip\pretabskip - \let\gettabulateexit\dogettabulateexit + \tabulatepreskip.5\tabulateunit\relax + \ifnum\tabulatecolumns<\numexpr\noftabulatecolumns-\plusone\relax + \tabulateposskip\tabulatepreskip + \else + \tabulateposskip\zeropoint + \fi + %\let\gettabulateexit\dogettabulateexit % still needed ? \tabulatewidth\zeropoint} -\setvalue{\??tt>\meaning x}{\let\tabulatealign\zerocount\settabulatepreamble} % internal -\setvalue{\??tt>\meaning l}{\let\tabulatealign\plusone\settabulatepreamble} -\setvalue{\??tt>\meaning r}{\let\tabulatealign\plustwo\settabulatepreamble} -\setvalue{\??tt>\meaning c}{\let\tabulatealign\plusthree\settabulatepreamble} -\setvalue{\??tt>\meaning p}{\gettabulateparagraph} -\setvalue{\??tt>\meaning s}{\gettabulatesetups} -\setvalue{\??tt>\meaning w}{\gettabulatewidth} -\setvalue{\??tt>\meaning f}{\gettabulatefont} -\setvalue{\??tt>\meaning B}{\tabulatefont{\bf}\settabulatepreamble} -\setvalue{\??tt>\meaning I}{\tabulatefont{\it}\settabulatepreamble} -\setvalue{\??tt>\meaning S}{\tabulatefont{\sl}\settabulatepreamble} -\setvalue{\??tt>\meaning T}{\tabulatefont{\tt}\settabulatepreamble} -\setvalue{\??tt>\meaning R}{\tabulatefont{\rm}\settabulatepreamble} -\setvalue{\??tt>\meaning m}{\tabulatebmath{$}\tabulateemath{$}\settabulatepreamble} -\setvalue{\??tt>\meaning M}{\tabulatebmath{$\displaystyle}\tabulateemath{$}\settabulatepreamble} -\setvalue{\??tt>\meaning h}{\gettabulatehook} -\setvalue{\??tt>\meaning b}{\gettabulatebefore} -\setvalue{\??tt>\meaning a}{\gettabulateafter} -\setvalue{\??tt>\meaning i}{\gettabulatepreskip} -\setvalue{\??tt>\meaning j}{\gettabulateposskip} -\setvalue{\??tt>\meaning k}{\gettabulatepreposskip} -\setvalue{\??tt>\meaning X}{\gettabulateexit} % internal -\setvalue{\??tt>\meaning e}{\appendtoks\global\tabulateequaltrue\to\tabulatesettings\settabulatepreamble} -\setvalue{\??tt>\meaning ~}{\appendtoks\fixedspaces\to\tabulatesettings\settabulatepreamble} -\setvalue{\??tt>\meaning g}{\gettabulatealign} -\setvalue{\??tt>\meaning .}{\gettabulatealign.} -\setvalue{\??tt>\meaning ,}{\gettabulatealign,} - -\setvalue{\??tt>\s!unknown}{\message{unknown preamble key [\meaning\next]}\settabulatepreamble} -\letvalue{\??tt>\meaning\relax}\donothing +\setvalue{\??tt>\meaning x}{\let\tabulatealign\zerocount\settabulatepreamble} % internal +\setvalue{\??tt>\meaning l}{\let\tabulatealign\plusone\settabulatepreamble} +\setvalue{\??tt>\meaning r}{\let\tabulatealign\plustwo\settabulatepreamble} +\setvalue{\??tt>\meaning c}{\let\tabulatealign\plusthree\settabulatepreamble} +\setvalue{\??tt>\meaning p}{\gettabulateparagraph} +\setvalue{\??tt>\meaning s}{\gettabulatesetups} +\setvalue{\??tt>\meaning w}{\gettabulatewidth} +\setvalue{\??tt>\meaning f}{\gettabulatefont} +\setvalue{\??tt>\meaning B}{\tabulatefont{\bf}\settabulatepreamble} +\setvalue{\??tt>\meaning I}{\tabulatefont{\it}\settabulatepreamble} +\setvalue{\??tt>\meaning S}{\tabulatefont{\sl}\settabulatepreamble} +\setvalue{\??tt>\meaning T}{\tabulatefont{\tt}\settabulatepreamble} +\setvalue{\??tt>\meaning R}{\tabulatefont{\rm}\settabulatepreamble} +\setvalue{\??tt>\meaning m}{\tabulatebmath{$}\tabulateemath{$}\settabulatepreamble} +\setvalue{\??tt>\meaning M}{\tabulatebmath{$\displaystyle}\tabulateemath{$}\settabulatepreamble} +\setvalue{\??tt>\meaning h}{\gettabulatehook} +\setvalue{\??tt>\meaning b}{\gettabulatebefore} +\setvalue{\??tt>\meaning a}{\gettabulateafter} +\setvalue{\??tt>\meaning i}{\gettabulatepreskip} +\setvalue{\??tt>\meaning j}{\gettabulateposskip} +\setvalue{\??tt>\meaning k}{\gettabulatepreposskip} +\setvalue{\??tt>\meaning e}{\appendtoks\global\settrue\tabulateequal\to\tabulatesettings\settabulatepreamble} +\setvalue{\??tt>\meaning ~}{\appendtoks\fixedspaces\to\tabulatesettings\settabulatepreamble} +\setvalue{\??tt>\meaning g}{\gettabulatealign} +\setvalue{\??tt>\meaning .}{\gettabulatealign.} +\setvalue{\??tt>\meaning ,}{\gettabulatealign,} +\setvalue{\??tt>\meaning C}{\doparsecolortabulate} +\setvalue{\??tt>\s!unknown }{\message{unknown preamble key [\meaning\next]}\settabulatepreamble} +\setvalue{\??tt>\meaning\relax}{} \def\dosettabulatepreamble {\csname\??tt>\ifcsname\??tt>\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname} -\def\dogettabulateexit - {\let\postabskip\!!zeropoint - \settabulatepreamble} - -\let\gettabulateexit\dogettabulateexit - \def\gettabulatepreskip#1% {\doifnumberelse{#1} - {\edef\pretabskip{\the\dimexpr#1\tabulateunit}\let\next\empty} - {\edef\pretabskip{\the\dimexpr.5\tabulateunit}\def\next{#1}}% + {\tabulatepreskip#1\tabulateunit\let\next\empty} + {\tabulatepreskip.5\tabulateunit\def\next{#1}}% \@EA\settabulatepreamble\next} \def\gettabulateposskip#1% {\doifnumberelse{#1} - {\edef\postabskip{\the\dimexpr#1\tabulateunit}\let\next\empty} - {\edef\postabskip{\the\dimexpr.5\tabulateunit}\def\next{#1}}% - \let\gettabulateexit\settabulatepreamble + {\tabulateposskip#1\tabulateunit\let\next\empty} + {\tabulateposskip.5\tabulateunit\def\next{#1}}% \@EA\settabulatepreamble\next} \def\gettabulatepreposskip#1% {\doifnumberelse{#1} - {\edef\pretabskip{\the\dimexpr#1\tabulateunit}\let\next\empty} - {\edef\pretabskip{\the\dimexpr.5\tabulateunit}\def\next{#1}}% - \let\postabskip\pretabskip - \let\gettabulateexit\settabulatepreamble + {\tabulatepreskip#1\tabulateunit\let\next\empty} + {\tabulatepreskip.5\tabulateunit\def\next{#1}}% + \tabulateposskip\tabulatepreskip \@EA\settabulatepreamble\next} \def\gettabulatesetups#1% @@ -503,7 +538,7 @@ [#1]% [ \v!fit=>\let\tabulatemodus\plusthree, \v!fixed=>\let\tabulatemodus\plusthree - \tabulatenopbreaktrue, + \settrue\tabulatenopbreak, \v!auto=>\let\tabulatemodus\plusthree \let\tabulatereshape\plusone, \s!unknown=>\tabulatewidth#1\relax]% @@ -550,9 +585,17 @@ \def\tabulatesetpreamblewidthsimple {\dodosettabulatepreamble\xbskip\xeskip} -\bgroup \catcode`\|=\othercatcode +\def\doparsecolortabulate#1#2% + {\gdef\currenttabulatecolor{#2}% + \global\tabulatecolorspan\if#1L\plusone\else\if#1M\plustwo\else\if#1R\plusthree\else\zerocount\fi\fi\fi\relax + \settabulatepreamble} + +\def\dotabulatevrulecommand#1% + {\doifnumberelse{#1} + {\global\tabulatevrulethickness#1\defaulttabulatevrulethickness} + {\xdef\currenttabulatevrulecolor{#1}}} -\gdef\nexttabulate#1|% +\def\settabulateentry#1#2% rulespec template {\let\tabulatealign\@@tabulatealign \let\tabulatemodus\zerocount \let\tabulatedimen\zerocount @@ -563,9 +606,19 @@ \tabulateemath\emptytoks \tabulatefont\emptytoks \tabulatesettings\emptytoks - \global\advance\tabulatecolumns\plusone + \global\let\currenttabulatecolor\empty + \global\let\currenttabulatevrulecolor\empty + \global\tabulatecolorspan\zerocount + \global\advance\tabulatecolumns\plusone % == #1 \expandafter\let\csname\??tt:s:\the\tabulatecolumns\endcsname\donothing - \settabulatepreamble#1\relax\relax % permits i without n + \edef\currenttabulatetrulespec{#1}% + \ifx\currenttabulatetrulespec\empty + \global\tabulatevrulethickness\zeropoint + \else + \global\tabulatevrulethickness\defaulttabulatevrulethickness + \rawprocesscommalist[#1]\dotabulatevrulecommand + \fi + \settabulatepreamble#2\relax\relax % permits i without n \ifcase\tabulatemodus\relax \tabulatesetpreamblewidthnormal \or % fixed width @@ -574,21 +627,20 @@ \tabulatesetpreamblewidthauto \or % simple \tabulatesetpreamblewidthsimple - \fi - \futurelet\next\donexttabulate} - -\egroup - -\def\donexttabulate - {\ifx\next\relax\else - \expandafter\nexttabulate \fi} -% \def\donormalizetabulatesplitline -% {\ht\tabulatebox\strutht -% \dp\tabulatebox\strutdp} - -\setnewconstant \tabulatesplitlinemode \plusone +\def\setlasttabulateentry#1% rulespec + {\global\let\currenttabulatevrulecolor\empty + \rawprocesscommalist[#1]\dotabulatevrulecommand + \ifx\currenttabulatetrulespec\empty + \global\tabulatevrulethickness\zeropoint + \else + \global\tabulatevrulethickness\defaulttabulatevrulethickness + \rawprocesscommalist[#1]\dotabulatevrulecommand + \fi + \normalexpanded{\tabulatepreamble{\the\tabulatepreamble + \dochecklocaltabulatevrulecolor{\currenttabulatevrulecolor}{\the\tabulatevrulethickness}% + \dotabulatevrule}}} \def\donormalizetabulatesplitline {\ifcase\tabulatesplitlinemode @@ -605,16 +657,20 @@ \fi \fi} -\def\splitofftabulatebox % overloaded in anch-pgr +\def\flushtabulatesplitbox + {\box\tabulatebox} + +\def\splitofftabulatebox % overloads in anch-pgr {\dontcomplain \global\setbox\tabulatebox % % % global ? % % % \vsplit\tablebox\tabulatecolumn to \lineheight \setbox\tabulatebox\normalvbox {\unvbox\tabulatebox}% \setbox\tabulatebox\hbox to \wd\tabulatebox - {\hss\dotabulatehook{\box\tabulatebox}\hss}% + {\iftrialtypesetting\else\ifconditional\tabulatehascolors\repeatsettabulatecolor\fi\fi + \hss\dotabulatehook{\box\tabulatebox}\hss}% \donormalizetabulatesplitline - \box\tabulatebox} + \flushtabulatesplitbox} \def\dotabulatehook {\csname\??tt:h:\the\tabulatecolumn\endcsname} \def\dotabulatealign{\csname\??tt:a:\the\tabulatecolumn\endcsname} @@ -636,8 +692,8 @@ \fi} \def\dohandletabulatepbreak - {\ifhandletabulatepbreak - \iftabulatenopbreak + {\ifconditional\tabulatehandlepbreak + \ifconditional\tabulatenopbreak \dotabulatenobreak \else\ifnum\tabulatemaxplines>\plusone \ifnum\tabulateminplines=\plusone @@ -684,12 +740,10 @@ % \starttabulate[preamble] % \starttabulate -> \starttabulate[|l|p|] -\bgroup \catcode`\|=\othercatcode - -\gdef\definetabulate +\def\definetabulate {\dotripleempty\dodefinetabulate} -\gdef\dodefinetabulate[#1][#2][#3]% +\def\dodefinetabulate[#1][#2][#3]% {\ifthirdargument \ifcsname\??tt#1::\c!unit\endcsname \else \copyparameters @@ -713,13 +767,9 @@ \definetabulate[#1][][|l|p|]% \fi\fi} -\egroup - \let\tabulateheadcontent\empty \let\tabulatetailcontent\empty -\newconditional\tabulatesomeamble - \def\processtabulateheadcontent {\TABLEnoalign{\global\settrue\tabulatesomeamble}% \csname\??tt\currenttabulate-\v!header\endcsname @@ -781,8 +831,6 @@ \setuvalue{\e!stop\v!tabulatehead}{} \setuvalue{\e!stop\v!tabulatetail}{} -\bgroup - \gdef\donormalstarttabulate[#1][#2]% {\ifsecondargument \getparameters[\??tt\v!tabulate::][#2]% @@ -794,66 +842,18 @@ \fi \next} -\egroup - % The much needed hook: -\newtoks\everytabulate - -% An example of its usage: - \appendtoks \optimizeverbatimfalse \to \everytabulate -% A status variable: - -\newconstant\tabulatepass +% Todo: proper inheritance \def\tabulateparameter#1{\csname\??tt\currenttabulate#1\endcsname} -\bgroup - \catcode`\|=\othercatcode \gdef\@@otherbar{|} - \catcode`\|=\activecatcode \gdef\@@useotherbar{\let|\@@otherbar} -\egroup - -\def\doparsetabulate - {\futurelet\next\dodoparsetabulate} - -% \def\dodoparsetabulate % \@EAEAEA gebruiken -% {\ifx\next\relax -% % exit -% \else\ifx*\next -% \let\next\dorepeatparsetabulate -% \else\ifx\bgroup\next -% \let\next\dododoparsetabulate -% \else -% \let\next\dodododoparsetabulate -% \fi\fi\fi -% \next}% - -\def\dorepeatparsetabulate*#1#2% - {\dorecurse{#1}{\!!toksb\expandafter{\the\!!toksb#2}}% \dorecurse{#1}{\appendtoks#2\to\!!toksb}% - \doparsetabulate} - -\def\dododoparsetabulate#1% - {\!!toksb\expandafter{\the\!!toksb{#1}}% \appendtoks{#1}\to\!!toksb - \doparsetabulate} - -\def\dodododoparsetabulate#1% - {\!!toksb\expandafter{\the\!!toksb#1}% \appendtoks#1\to\!!toksb - \doparsetabulate} - -\letvalue{\??tt<\meaning *}\dorepeatparsetabulate -\letvalue{\??tt<\meaning \bgroup}\dododoparsetabulate -\letvalue{\??tt<\meaning \relax}\donothing -\letvalue{\??tt<\s!unknown }\dodododoparsetabulate - -\def\dodoparsetabulate - {\csname\??tt<\ifcsname\??tt<\meaning\next\endcsname\meaning\next\else\s!unknown\fi\endcsname} - -\setvalue{\??tt:\c!split:\v!yes }{\splittabulatetrue} -\setvalue{\??tt:\c!split:\v!repeat}{\splittabulatetrue} -\setvalue{\??tt:\c!split:\v!no }{\splittabulatefalse} -\setvalue{\??tt:\c!split:\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\splittabulatefalse\fi\fi} +\setvalue{\??tt:\c!split:\v!yes }{\settrue\tabulatesplit} +\setvalue{\??tt:\c!split:\v!repeat}{\settrue\tabulatesplit} +\setvalue{\??tt:\c!split:\v!no }{\setfalse\tabulatesplit} +\setvalue{\??tt:\c!split:\v!auto }{\ifinsidefloat\ifinsidesplitfloat\else\setfalse\tabulatesplit\fi\fi} \def\dofinalstarttabulate[#1][#2][#3]% identifier sub preamble {\edef\currenttabulate{#1::#2}% @@ -865,7 +865,7 @@ \resetcharacteralign % todo: spacing around tabulate when bodyfont is set % expansion en test needed ? - \splittabulatetrue + \settrue\tabulatesplit \csname\??tt:\c!split:\tabulateparameter\c!split\endcsname \doifvaluesomething{\??tt\currenttabulate\c!bodyfont} {\expanded{\switchtobodyfont[\tabulateparameter\c!bodyfont]}}% @@ -879,42 +879,140 @@ {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent+\parindent}}% \ctxparindent {\edef\tabulateindent{\the\dimexpr\leftskip+\hangindent }}% \global\tabulatecolumn\zerocount - \!!toksb\emptytoks - \bgroup - \@@useotherbar - \normalexpanded{\egroup\noexpand\doparsetabulate#3\relax}% - \processcontent - {\e!stop#1}% \currenttabulate} - \tabulatecontent - {\@EA\processtabulate\@EA[\the\!!toksb]}} + \processcontent{\e!stop#1}\tabulatecontent{\processtabulate[#3]}} % \currenttabulate -\newconstant\tabulatetype +\def\tabulateEQ + {\ifconditional\tabulatefirstflushed\else\tabulateparameter{EQ}\fi + \global\setfalse\tabulateequal} -% 0 = NC column next EQ equal column -% 1 = RC column raw RQ equal column raw -% 2 = HC column hook HQ equal column hook +% The next ones will be token registers -\newif\iftabulatefirstflushed +\let\tabulatenormalpos\relax +\let\tabulateequalpos \relax -\def\tabulateEQ - {\iftabulatefirstflushed\else\tabulateparameter{EQ}\fi - \global\tabulateequalfalse} +% color columns -% \def\tabulatenormalcolumn#1% -% {&\iftabulateequal\tabulateEQ\fi&\global\tabulatetype#1&} -% -% \def\tabulateequalcolumn#1% -% {&\tabulateEQ&\global\tabulatetype#1&} -% -% however, \unskip en \ignorespaces permit usage in complex XML/\starttabulate +\glet\previoustabulatecolor \empty +\glet\currenttabulatecolor \empty +\glet\currenttabulatelocalcolor \empty +\glet\currenttabulatevrulecolor \empty +\glet\currenttabulatelocalvrulecolor\empty + +\appendtoks + \glet\previoustabulatecolor \empty + \glet\currenttabulatecolor \empty + \glet\currenttabulatelocalcolor \empty + \glet\currenttabulatevrulecolor \empty + \glet\currenttabulatelocalvrulecolor\empty + \global\tabulatelocalvrulethickness \zeropoint +\to \everytabulaterow + +\unexpanded\def\dorightsidetabulatecolor + {\iftrialtypesetting\else + \ifx\previoustabulatecolor\empty \else + \settabulatecolor\previoustabulatecolor + \glet\previoustabulatecolor\empty + \fi + \fi} + +\unexpanded\def\doleftsidetabulatecolor + {\iftrialtypesetting\else + \ifx\currenttabulatecolor\empty \else + \ifcase\tabulatecolorspan + \or + \settabulatecolor\currenttabulatecolor + \or + \settabulatecolor\currenttabulatecolor + \fi + \fi + \fi} + +\unexpanded\def\dobothsidetabulatecolor + {\iftrialtypesetting\else + \ifx\currenttabulatecolor\empty \else + \settabulatecolor\currenttabulatecolor + \ifcase\tabulatecolorspan + %\glet\previoustabulatecolor\empty + \or + \glet\previoustabulatecolor\empty + \or + \glet\previoustabulatecolor\currenttabulatecolor + \or + \glet\previoustabulatecolor\currenttabulatecolor + \fi + \fi + \fi} + +\def\tabulatecolorcolumn#1% overloaded + {\unskip + \doiffastoptionalcheckelse{\tabulatecolorcolumnyes#1}{\tabulatecolorcolumnnop#1}} + +\def\tabulatecolorcolumnnop + {\tabulatenormalcolumn} + +\def\tabulatecolorcolumnyes#1[#2]% + {\xdef\currenttabulatelocalcolor{#2}% + \tabulatenormalcolumn#1} + +% normal columns: \def\tabulatenormalcolumn#1% - {\unskip&\iftabulateequal\tabulateEQ\fi&\global\tabulatetype#1&% - \ignorespaces} + {\unskip + \aligntab + \ifconditional\tabulateequal\tabulateequalpos\else\tabulatenormalpos\fi + \aligntab + \global\tabulatetype#1% + \aligntab} + +% equal columns + +\def\tabulateequalcolumn#1% overloaded + {\unskip + \aligntab + \tabulateequalpos + \aligntab\global\tabulatetype#1% + \aligntab} + +% ruled columns + +\def\tabulatevruledcolumn#1% + {\unskip % 0-n + \ifnum\tabulatecolumn=\plusone + \global\tabulatehasfirstrulespec\plusone + \else\ifnum\tabulatecolumn=\noftabulatecolumns + \global\tabulatehaslastrulespec\plusone + \fi\fi + \global\let\currenttabulatelocalvrulecolor\empty + \global\tabulatelocalvrulethickness\defaulttabulatevrulethickness + \doiffastoptionalcheckelse{\tabulatevruledcolumnyes#1}{\tabulatevruledcolumnnop#1}} -\def\tabulateequalcolumn#1% - {\unskip&\tabulateEQ&\global\tabulatetype#1&% - \ignorespaces} +\def\tabulatevruledcolumnnop + {\tabulatenormalcolumn} + +\def\dotabulatevrulelocalcommand#1% + {\doifnumberelse{#1} + {\global\tabulatelocalvrulethickness#1\defaulttabulatevrulethickness} + {\xdef\currenttabulatelocalvrulecolor{#1}}} + +\def\tabulatevruledcolumnyes#1[#2]% + {\rawprocesscommalist[#2]\dotabulatevrulelocalcommand + \tabulatenormalcolumn#1} + +\unexpanded\def\dotabulatevrule + {\ifcase\tabulatevrulethickness\else + \iftrialtypesetting + \vrule\!!width\tabulatevrulethickness\relax + \else\ifx\currenttabulatevrulecolor\empty + \vrule\!!width\tabulatevrulethickness\relax + \else + \faststartcolor[\currenttabulatevrulecolor]% + \vrule\!!width\tabulatevrulethickness\relax + \faststopcolor + \fi\fi + \fi + \global\tabulatevrulethickness\zeropoint} % nils second one + +% auto columns \def\tabulateautocolumn {\tabulatenormalcolumn\zerocount @@ -928,34 +1026,42 @@ {\let#1\tabulateautocolumn \let\\\tabulateautocolumn} +\setvalue{\??tt:rs:\v!blank }{\tabulateseparatorskip\bigskipamount} +\setvalue{\??tt:rs:\v!depth }{\tabulateseparatorskip\strutdp} +\setvalue{\??tt:rs:\v!small }{\def\factor{.25}} +\setvalue{\??tt:rs:\v!medium}{\def\factor{.5}} +\setvalue{\??tt:rs:\v!big }{} +\setvalue{\??tt:rs:\v!none }{\tabulateseparatorskip\zeropoint\def\factor{0}} +\setvalue{\??tt:rs:\v!grid }{\tabulateseparatorskip\zeropoint\def\factor{0}} + +\def\dodotabulateruleseperator#1% + {\ifcsname\??tt:rs:#1\endcsname + \csname\??tt:rs:#1\endcsname + \else + \tabulateseparatorskip#1\relax + \fi} + \def\dotabulateruleseperator % can be sped up (will do when used frequently) {\bgroup - \let\factor\!!plusone - \scratchskip\strutdp - \ExpandFirstAfter\processallactionsinset - [\tabulateparameter\c!distance] - [ \v!blank=>\scratchskip\bigskipamount, - \v!depth=>\scratchskip\strutdp, - \v!small=>\def\factor{.25}, - \v!medium=>\def\factor{.5}, - \v!big=>, - \v!none=>\scratchskip\zeropoint\def\factor{0}, - \v!grid=>\scratchskip\zeropoint\def\factor{0}, - \s!unknown=>\scratchskip\commalistelement]% - \scratchdimen\factor\scratchskip - \ifconditional\tabulatesomeamble\kern\else\vskip\fi\scratchdimen % new + \edef\tabulateseparatordistance{\tabulateparameter\c!distance}% + \tabulateseparatorskip\strutdp + \ifx\tabulateseparatordistance\empty\else + \let\factor\!!plusone + \normalexpanded{\processcommalist[\tabulateparameter\c!distance]}\dodotabulateruleseperator + \tabulateseparatorskip\factor\tabulateseparatorskip + \fi + \ifconditional\tabulatesomeamble\kern\else\vskip\fi\tabulateseparatorskip % new \egroup} \def\dodotabulaterule#1% - {\color + {\color % fastcolor ? [\tabulateparameter\c!rulecolor] {\scratchdimen\tabulateparameter\c!rulethickness#1}} \def\dotabulaterule {\dodotabulaterule {\hrule\!!height.5\scratchdimen\!!depth.5\scratchdimen\relax - \doifvalue{\??tt\currenttabulate\c!distance}\v!grid - {\kern-\scratchdimen}}} % experimental tm-prikkels + \doifvalue{\??tt\currenttabulate\c!distance}\v!grid{\kern-\scratchdimen}}} % experimental tm-prikkels \def\dotabulatelinerule {\multispan\totaltabulatecolumns % \multispan is a plain macro @@ -971,9 +1077,68 @@ \leaders\hrule\!!height\!!heighta\!!depth\!!deptha\hfill}% \cr} -%D When set to true, no (less) break optimization is done. +%D Color: + +% \starttabulate[||p||] +% \NC test \NC test \NC test \NC \NR +% \NC test \NC[green] \input tufte \NC[yellow] test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC[blue] test \NC[red] test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC[gray] test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC[blue] test \NC test \NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC test \NC[magenta] test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC[cyan] \dorecurse{10}{\input ward }\NC test \NC \NR +% \NC test \NC test \NC test \NC \NR +% \NC test \NC[yellow] test \NC test \NC \NR +% \stoptabulate -\newif\iftolerantTABLEbreak % used in styles ! +\unexpanded\def\settabulatecolor#1% we could store the attributes at the cost of a lua call + {\begingroup + \doinitializeboxbackgrounds + \global\settrue\tabulatehascolors + \ifnum\tabulatecolumn>\maxtabularcolorcolumn + \global\maxtabularcolorcolumn\tabulatecolumn + \fi + \setxvalue{\??tt:c:\the\tabulatecolumn}{#1}% + \attribute\backgroundattribute\plusone + \faststartcolor[#1]\strut\char0\faststopcolor + \endgroup} + +\def\repeatsettabulatecolor + {\begingroup + \ifcsname\??tt:c:\the\tabulatecolumn\endcsname + \attribute\backgroundattribute\plusone + \faststartcolor[\csname\??tt:c:\the\tabulatecolumn\endcsname]\strut\char0\faststopcolor + \fi + \endgroup} + +\def\resettabulatecolors + {\ifcase\maxtabularcolorcolumn\else + \doresettabulatecolors + \fi} + +\def\doresettabulatecolors + {\dorecurse\maxtabularcolorcolumn{\letgvalue{\??tt:c:\recurselevel}\undefined}} % slow + +\appendtoks + \resettabulatecolors +\to \everyaftertabulaterow + +\appendtoks + \global\setfalse\tabulatehascolors +\to \everytabulate + +%D When set to true, no (less) break optimization is done. %D The main processing macro is large but splitting it up %D would make things less clear. @@ -994,8 +1159,6 @@ \glet\registertabulateparoptions\doregistertabulateparoptions \to \everytabulate -\newtoks\everytabulaterow - \appendtoks \registertabulateparoptions \to \everytabulaterow @@ -1021,11 +1184,6 @@ %D cum suis, since \TEX's hard coded noalign lookahead fails %D on it! I mistakenly added this for a while. -\newcount\tabulaterepeathead -\newcount\noftabulatelines -\newcount\totalnoftabulatelines -\newcount\minusnoftabulatelines - \setvalue{\??tt:\c!align:\v!normal}{0} \setvalue{\??tt:\c!align:\v!right }{1} \setvalue{\??tt:\c!align:\v!left }{2} @@ -1034,8 +1192,6 @@ \setvalue{\??tt:\c!header:\v!repeat}{\plusone} \setvalue{\??tt:\c!header:\v!text }{\plustwo} -\newtoks\everyaftertabulaterow - \def\tabulatebskipone {\setbox\tabulatebox\vbox\bgroup\glet\tabulatehook\notabulatehook} \def\tabulateeskipone {\par\egroup\glet\tabulatehook\dotabulatehook} \def\tabulatexbskipone{\hbox\bgroup\vbox\bgroup\glet\tabulatehook\notabulatehook} @@ -1043,27 +1199,31 @@ \def\tabulatebaselinecorrection {\def\dobaselinecorrection % todo: mkiv - {\vskip-\prevdepth - \vskip\strutdp - \vskip\strutdp}% + {\vskip-\prevdepth+\strutdp+\strutdp\relax}% \baselinecorrection} -\unexpanded\def\tabulateNCone{\tabulatenormalcolumn0} -\unexpanded\def\tabulateRCone{\tabulatenormalcolumn1} -\unexpanded\def\tabulateHCone{\tabulatenormalcolumn2} -\unexpanded\def\tabulateEQone{\tabulateequalcolumn 0} -\unexpanded\def\tabulateRQone{\tabulateequalcolumn 1} -\unexpanded\def\tabulateHQone{\tabulateequalcolumn 2} +\unexpanded\def\tabulateVLone{\tabulatevruledcolumn\zerocount} +\unexpanded\def\tabulateNCone{\tabulatenormalcolumn\zerocount} +\unexpanded\def\tabulateRCone{\tabulatenormalcolumn\plusone} +\unexpanded\def\tabulateHCone{\tabulatenormalcolumn\plustwo} +\unexpanded\def\tabulateEQone{\tabulateequalcolumn \zerocount} +\unexpanded\def\tabulateRQone{\tabulateequalcolumn \plusone} +\unexpanded\def\tabulateHQone{\tabulateequalcolumn \plustwo} \unexpanded\def\tabulateNGone{\NC\handletabulatecharalign} \unexpanded\def\tabulateNNone{\NC\handletabulatedigits} % new, undocumented, test first \unexpanded\def\tabulateNDone{\NC\handletabulatedigits} % same, for old times sake \unexpanded\def\tabulateHRone{\doHR\zerocount} \unexpanded\def\tabulateHLone{\doHL\zerocount} +\unexpanded\def\tabulateCCone{\global\tabulatelocalcolorspan\zerocount\tabulatecolorcolumn\zerocount} +\unexpanded\def\tabulateCLone{\global\tabulatelocalcolorspan\plusone \tabulatecolorcolumn\zerocount} +\unexpanded\def\tabulateCMone{\global\tabulatelocalcolorspan\plustwo \tabulatecolorcolumn\zerocount} +\unexpanded\def\tabulateCRone{\global\tabulatelocalcolorspan\plusthree\tabulatecolorcolumn\zerocount} + \unexpanded\def\tabulateNRone % next row {\global\advance\noftabulatelines\plusone - \global\tabulatefirstflushedfalse - \global\tabulateequalfalse + \global\setfalse\tabulatefirstflushed + \global\setfalse\tabulateequal \global\tabulatecolumn\zerocount \resettabulatepheight \unskip\unskip\crcr\flushtabulated @@ -1091,7 +1251,7 @@ \fi\fi \fi \fi - \global\tabulatefirstflushedfalse} + \global\setfalse\tabulatefirstflushed} \def\tabulatebbskiptwo {\ifvoid\tablebox\tabulatecolumn @@ -1112,7 +1272,7 @@ \global\setbox\tablebox\tabulatecolumn\vbox \bgroup \glet\tabulatehook\notabulatehook - \ifautotabulate\hsize\tabulatewidth\fi + \ifconditional\autotabulate\hsize\tabulatewidth\fi % \begstrut % interferes with pre-\pars % evt: \appendtoks\begstrut\to\everypar \ignorespaces @@ -1136,7 +1296,7 @@ {\ifvoid\tablebox\recurselevel\else \gdef\flushtabulatedindeed{\the\tabulatedummy}% \fi}% - \global\tabulatefirstflushedtrue} + \global\settrue\tabulatefirstflushed} \def\tabulateflushtabulatedtwo {\TABLEnoalign{\dotabulateflushtabulatedtwo}% @@ -1144,7 +1304,7 @@ \def\tabulatebskipthree {\vtop\bgroup - \ifautotabulate\hsize\tabulatewidth\fi + \ifconditional\autotabulate\hsize\tabulatewidth\fi % \begstrut % interferes with pre-\pars % evt: \appendtoks\begstrut\to\everypar \ignorespaces} @@ -1267,24 +1427,28 @@ \let\tabulateBLfive\tabulateTLfive - \def\tabulaterule {\HR}% a rule with lineheight \def\tabulateline {\HL}% just a spaced rule \def\tabulateautorule{\doHR\plusone}% \def\tabulateautoline{\doHL\plusone}% -\newtoks\everytabulatepar - -\bgroup \catcode`\|=\othercatcode +% When support for vertical rules we needed a way to pick up the +% specification for the final rule and a \type {|{}} interface was +% chosen. As a result parsing had to become more complex and I was +% not in the mood for messing up the code too much. Therefore from +% now on the preamble is split by \LUA. There are definitely more +% places where we can use \LUA\ code (for instance in alignment of +% numbers. The repeat parser is replace at the \LUA\ end as well. -\gdef\processtabulate[|#1|]% in the process of optimizing +\gdef\processtabulate[#1]% in the process of optimizing {\tabulateunit\tabulateparameter\c!unit \checkfulltabulatecontent - \globallet\tabulateruledepth \!!zeropoint - \globallet\tabulateruleheight\!!zeropoint + \defaulttabulatevrulethickness\tabulateparameter\c!rulethickness \edef\@@tabulatealign{\executeifdefined{\??tt:\c!align:\tabulateparameter\c!align}0}% - \let\pretabskip\!!zeropoint - \def\postabskip{.5\tabulateunit}% + \tabulateposskip.5\tabulateunit + \tabulatepreskip\zeropoint + \firstpretabskip\tabulateposskip + \lastposttabskip\tabulateposskip \global\tabulatecolumns\zerocount \global\nofautotabulate\zerocount \global\noftabulatelines\zerocount @@ -1292,7 +1456,7 @@ \minusnoftabulatelines\noftabulatelines \global\tabulatepwidth\zeropoint \global\tabulatexwidth\zeropoint - \global\tabulateequalfalse + \global\setfalse\tabulateequal \resettabulatepheight \ifinsidesplitfloat \donetrue @@ -1304,6 +1468,7 @@ \ifdone \tabulaterepeathead\executeifdefined{\??tt:\c!header:\tabulateparameter\c!header}\zerocount \fi + \let\VL\tabulateVLone \let\NC\tabulateNCone \let\RC\tabulateRCone \let\HC\tabulateHCone @@ -1316,6 +1481,10 @@ \let\HR\tabulateHRone \let\HL\tabulateHLone \let\NR\tabulateNRone + \let\CC\tabulateCCone + \let\CL\tabulateCLone + \let\CM\tabulateCMone + \let\CR\tabulateCRone \let\HL\empty % not needed ? ? ? \let\SR\NR \let\AR\NR \let\FL\empty \let\FR\NR @@ -1328,19 +1497,21 @@ \glet\flushtabulated\empty \tabskip\zeropoint \ifdim\tabulateparameter\c!margin>\zeropoint - \!!toksa{&\flushtabulateindent\strut##\tabskip\tabulateparameter\c!margin\strut&##\tabskip\zeropoint}% + \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\tabskip\tabulateparameter\c!margin\strut\aligntab\alignmark\alignmark\tabskip\zeropoint}% \else - \!!toksa{&\flushtabulateindent\strut##&##\tabskip\zeropoint}% + \tabulatepreamble{\aligntab\flushtabulateindent\strut\alignmark\alignmark\aligntab\alignmark\alignmark\tabskip\zeropoint}% \fi \tabulatewidth\zeropoint - \nexttabulate #1X|\relax + \ctxlua{commands.presettabulate("\detokenize{#1}")}% \edef\totaltabulatecolumns{\the\numexpr3*\tabulatecolumns+4}% \tabulatewidth\zeropoint \initializetableboxes\tabulatecolumns - \appendtoks&##\global\advance\tabulatecolumn\plusone\to\!!toksa + \appendtoks\aligntab\alignmark\alignmark\global\advance\tabulatecolumn\plusone\to\tabulatepreamble \appendtoks\NC\unskip\unskip\crcr\flushtabulated\to\tabulatedummy % no count \global\tabulatecolumn\zerocount \resettabulatepheight + \let\bbskip\empty + %\let\eeskip\empty \let\bskip \tabulatebskipone \let\eskip \tabulateeskipone \let\xbskip\tabulatexbskipone @@ -1359,7 +1530,7 @@ {\notesenabledfalse \let\tabulateindent\!!zeropoint \settrialtypesetting % very important - \@EA\halign\@EA{\the\!!toksa\crcr\fulltabulatecontent\crcr}}% + \@EA\halign\@EA{\the\tabulatepreamble\crcr\fulltabulatecontent\crcr}}% \ifnum\nofautotabulate>\zerocount % so, even if the natural size is larger, in the final % run, we force the calculated width @@ -1370,7 +1541,7 @@ \fi \let\xbskip\tabulatexbskiptwo \let\xeskip\tabulatexeskiptwo - \ifsplittabulate + \ifconditional\tabulatesplit \splittopskip\strutht \glet\flushtabulatedindeed\empty \let\bbskip\tabulatebbskiptwo @@ -1411,7 +1582,7 @@ \dostarttagged\t!tabulate\empty \dostarttagged\t!tabulaterow\empty \appendtoks\dostoptagged\dostarttagged\t!tabulaterow\empty\to\everycr - \@EA\halign\@EA{\the\!!toksa\crcr\fulltabulatecontent\crcr}% + \@EA\halign\@EA{\the\tabulatepreamble\crcr\fulltabulatecontent\crcr}% \dostoptagged \dostoptagged \prevdepth\strutdp % nog eens beter, temporary hack @@ -1433,7 +1604,7 @@ \fi \egroup} -\egroup +% \egroup % \setuptabulate[split=yes,header=text,title=Vervolg van Tabel] % diff --git a/tex/context/base/util-mrg.lua b/tex/context/base/util-mrg.lua index 79e83541f..8b09d4ee6 100644 --- a/tex/context/base/util-mrg.lua +++ b/tex/context/base/util-mrg.lua @@ -13,7 +13,7 @@ local concat = table.concat local type, next = type, next utilities = utilities or {} -utilities.merger = utilities.merger or { } +utilities.merger = utilities.merger or { } -- maybe mergers utilities.report = utilities.report or print local merger = utilities.merger diff --git a/tex/context/base/util-prs.lua b/tex/context/base/util-prs.lua index 17a10201f..6ca7c3396 100644 --- a/tex/context/base/util-prs.lua +++ b/tex/context/base/util-prs.lua @@ -35,6 +35,8 @@ local nobrace = 1 - (lbrace+rbrace) local nested = P { lbrace * (nobrace + V(1))^0 * rbrace } local spaces = space^0 +lpeg.patterns.nested = nested + local value = P(lbrace * C((nobrace + nested)^0) * rbrace) + C((nested + (1-comma))^0) local key = C((1-equal-comma)^1) diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 795ddb515..7f68a8d8d 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 11/12/10 18:22:36 +-- merge date : 11/17/10 13:27:36 do -- begin closure to overcome local limits and interference diff --git a/tex/generic/context/luatex-mplib.lua b/tex/generic/context/luatex-mplib.lua index b3ab97b2c..c6628acb3 100644 --- a/tex/generic/context/luatex-mplib.lua +++ b/tex/generic/context/luatex-mplib.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['supp-mpl'] = { +if not modules then modules = { } end modules ['luatex-mplib'] = { version = 1.001, comment = "companion to luatex-mplib.tex", author = "Hans Hagen & Taco Hoekwater", @@ -248,15 +248,10 @@ else local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1 local function pen_characteristics(object) - if mplib.pen_info then - local t = mplib.pen_info(object) - rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty - divider = sx*sy - rx*ry - return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width - else - rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1 - return false, 1 - end + local t = mplib.pen_info(object) + rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty + divider = sx*sy - rx*ry + return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width end local function concat(px, py) -- no tx, ty here |