diff options
author | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-04-08 00:43:40 +0000 |
commit | 824f7b0903de8ad7f6ee3d7656005e4c59155e06 (patch) | |
tree | abfc8673ef9916f3ab7074e811207384c301492b /Master/texmf-dist/tex/context/base/cldf-bas.lua | |
parent | 689aefb0727676ed3cddf331337b4be226495e72 (diff) |
context import for TL13, from www.pragma-ade.com/context/beta/cont-tmf.zip
git-svn-id: svn://tug.org/texlive/trunk@29731 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/cldf-bas.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/cldf-bas.lua | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/context/base/cldf-bas.lua b/Master/texmf-dist/tex/context/base/cldf-bas.lua index 30a9265bce4..298b374f045 100644 --- a/Master/texmf-dist/tex/context/base/cldf-bas.lua +++ b/Master/texmf-dist/tex/context/base/cldf-bas.lua @@ -1,4 +1,4 @@ -if not modules then modules = { } end modules ['cldf-ini'] = { +if not modules then modules = { } end modules ['cldf-bas'] = { version = 1.001, comment = "companion to cldf-ini.mkiv", author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", @@ -22,6 +22,8 @@ if not modules then modules = { } end modules ['cldf-ini'] = { -- flush(ctxcatcodes,"}") -- end +-- maybe use context.generics + local type = type local format = string.format local utfchar = utf.char @@ -32,13 +34,16 @@ 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 - -- for i=1,#k do - -- context(format([[\char%s\relax]],k[i])) - -- end - context([[\char%s\relax]],concat(k,[[\relax\char]])) + 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 elseif k then context([[\char%s\relax]],k) end @@ -66,6 +71,10 @@ function context.egroup() context("}") end +function context.space() + context(" ") +end + function context.hrule(w,h,d,dir) if type(w) == "table" then context(new_rule(w.width,w.height,w.depth,w.dir)) @@ -98,22 +107,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\\bgroup",n) + context([[\setbox%s\hbox{]],n) else - context("\\setbox\\%s\\hbox\\bgroup",n) + context([[\setbox\%s\hbox{]],n) end end function context.startvboxregister(n) if type(n) == "number" then - context("\\setbox%s\\vbox\\bgroup",n) + context([[\setbox%s\vbox{]],n) else - context("\\setbox\\%s\\vbox\\bgroup",n) + context([[\setbox\%s\vbox{]],n) end end @@ -122,19 +131,36 @@ 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\\bgroup") -- we can do \bvbox ... \evbox (less tokens) + context([[\vbox{]]) -- we can do \bvbox ... \evbox (less tokens) end function context.beginhbox() - context("\\hbox\\bgroup") -- todo: use fast one + context([[\hbox{]]) -- 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 |