summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/strc-not.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-02-17 10:31:56 +0100
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-02-17 10:31:56 +0100
commitb14f992ef5f4e868c9959b174278c86516d60dbc (patch)
tree28587bb46c025ea7b0d27ba93f09c93dcf53c73a /tex/context/base/mkiv/strc-not.lua
parent95a1799032dc61dbca4a11e495be34b4397c8fec (diff)
downloadcontext-b14f992ef5f4e868c9959b174278c86516d60dbc.tar.gz
2017-02-17 10:23:00
Diffstat (limited to 'tex/context/base/mkiv/strc-not.lua')
-rw-r--r--tex/context/base/mkiv/strc-not.lua32
1 files changed, 27 insertions, 5 deletions
diff --git a/tex/context/base/mkiv/strc-not.lua b/tex/context/base/mkiv/strc-not.lua
index c54cd442e..1464c7f73 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
@@ -451,23 +457,39 @@ 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
------ texsetglue = tex.setglue
+local texsetglue = tex.setglue
-function notes.check_spacing(n,i)
+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
+ local gi, pi, mi = 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
- -- texsetglue(0,gt,pt,mt) -- for the moment we use skip register 0
return gt, pt, mt
end
-callback.register("build_page_insert", notes.check_spacing)
+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)