diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-05-14 19:58:50 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-05-14 19:58:50 +0200 |
commit | fd0c4577a4b6e85ca2db664906e1a03807ce133f (patch) | |
tree | fa23fcc04248d03ff82e34634b8ef1bb9cf28acb /tex/context/base/mkiv/strc-not.lua | |
parent | db581096187dc2d3cbdbe4cdc39d247c168b1607 (diff) | |
download | context-fd0c4577a4b6e85ca2db664906e1a03807ce133f.tar.gz |
2017-05-14 19:15:00
Diffstat (limited to 'tex/context/base/mkiv/strc-not.lua')
-rw-r--r-- | tex/context/base/mkiv/strc-not.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/strc-not.lua b/tex/context/base/mkiv/strc-not.lua index ddbd2ae06..eff357eea 100644 --- a/tex/context/base/mkiv/strc-not.lua +++ b/tex/context/base/mkiv/strc-not.lua @@ -26,8 +26,11 @@ local counterspecials = counters.specials local texgetcount = tex.getcount local texgetbox = tex.getbox +-- todo: allocate + notes.states = notes.states or { } lists.enhancers = lists.enhancers or { } +notes.numbers = notes.numbers or { } storage.register("structures/notes/states", notes.states, "structures.notes.states") @@ -143,6 +146,8 @@ end notes.setstate = setstate notes.getstate = getstate + + implement { name = "setnotestate", actions = setstate, @@ -157,6 +162,7 @@ implement { function notes.define(tag,kind,number) local state = setstate(tag,kind) + notes.numbers[number] = state state.number = number end @@ -448,3 +454,42 @@ function notes.internalid(tag,n) return r.internal end end + +-- for the moment here but better in some builder modules + +-- gets register "n" and location "i" (where 1 is before) + +-- this is an experiment, we will make a more general handler instead +-- of the current note one + +local report_insert = logs.reporter("pagebuilder","insert") +local trace_insert = false trackers.register("pagebuilder.insert",function(v) trace_insert = v end) + +local texgetglue = tex.getglue +local texsetglue = tex.setglue + +local function check_spacing(n,i) + local gn, pn, mn = texgetglue(n) + local gi, pi, mi = texgetglue(i > 1 and "s_strc_notes_inbetween" or "s_strc_notes_before") + local gt, pt, mt = gn+gi, pn+pi, mn+mi + if trace_insert then + report_insert("%s %i: %p plus %p minus %p","always ",n,gn,pn,mn) + report_insert("%s %i: %p plus %p minus %p",i > 1 and "inbetween" or "before ",n,gi,pi,mi) + report_insert("%s %i: %p plus %p minus %p","effective",n,gt,pt,mt) + end + return gt, pt, mt +end + +notes.check_spacing = check_spacing + +callback.register("build_page_insert", function(n,i) + local state = notes.numbers[n] + if state then + -- only notes, kind of hardcoded .. bah + local gt, pt, mt = check_spacing(n,i) + texsetglue(0,gt,pt,mt) -- for the moment we use skip register 0 + return 0 + else + return n + end +end) |