diff options
author | Hans Hagen <pragma@wxs.nl> | 2023-03-10 12:42:42 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2023-03-10 12:42:42 +0100 |
commit | 250c5684b9ee44ac972db51f87289ef935182c53 (patch) | |
tree | 4d2001bfc9e9575367c9f23c7d182b8c31d83d77 /tex/context/base/mkxl/strc-itm.lmt | |
parent | c677baac37632308600b5108b586f80246056c74 (diff) | |
download | context-250c5684b9ee44ac972db51f87289ef935182c53.tar.gz |
2023-03-10 12:17:00
Diffstat (limited to 'tex/context/base/mkxl/strc-itm.lmt')
-rw-r--r-- | tex/context/base/mkxl/strc-itm.lmt | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/strc-itm.lmt b/tex/context/base/mkxl/strc-itm.lmt new file mode 100644 index 000000000..f9153c98e --- /dev/null +++ b/tex/context/base/mkxl/strc-itm.lmt @@ -0,0 +1,64 @@ +if not modules then modules = { } end modules ['strc-itm'] = { + version = 1.001, + comment = "companion to strc-itm.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local structures = structures +local itemgroups = structures.itemgroups +local jobpasses = job.passes + +local implement = interfaces.implement + +local setvariable = jobpasses.save +local getvariable = jobpasses.getfield + +local texsetcount = tex.setcount +local texsetdimen = tex.setdimen + +local f_stamp = string.formatters["itemgroup:%s:%s"] +local counts = table.setmetatableindex("number") + +local c_strc_itemgroups_max_items = tex.iscount("c_strc_itemgroups_max_items") +local d_strc_itemgroups_max_width = tex.isdimen("d_strc_itemgroups_max_width") + +-- We keep the counter at the Lua end so we can group the items within +-- an itemgroup which in turn makes for less passes when one itemgroup +-- entry is added or removed. + +local trialtypesetting = context.trialtypesetting + +local function analyzeitemgroup(name,level) + local n = counts[name] + if level == 1 then + n = n + 1 + counts[name] = n + end + local stamp = f_stamp(name,n) + texsetcount(c_strc_itemgroups_max_items,getvariable(stamp,level,1,0)) + texsetdimen(d_strc_itemgroups_max_width,getvariable(stamp,level,2,0)) +end + +local function registeritemgroup(name,level,nofitems,maxwidth) + local n = counts[name] + if not trialtypesetting() then + -- no trialtypsetting + setvariable(f_stamp(name,n), { nofitems, maxwidth }, level) + elseif level == 1 then + counts[name] = n - 1 + end +end + +implement { + name = "analyzeitemgroup", + actions = analyzeitemgroup, + arguments = { "string", "integer" } +} + +implement { + name = "registeritemgroup", + actions = registeritemgroup, + arguments = { "string", "integer", "integer", "dimen" } +} |