summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt')
-rw-r--r--Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt96
1 files changed, 96 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt b/Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt
new file mode 100644
index 00000000000..005d1b32ecb
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/mkxl/typo-par.lmt
@@ -0,0 +1,96 @@
+if not modules then modules = { } end modules ['typo-par'] = {
+ version = 1.001,
+ comment = "companion to node-ini.mkiv",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- Just some experimental stuff .. trying to improve some ancient metafun manual
+-- hackery that has been on the angenda for too long already. Names might names
+-- anyway.
+
+local insert, remove = table.insert, table.remove
+
+local texget = tex.get
+local texset = tex.set
+local shiftparshape = tex.shiftparshape
+
+local sequencers = utilities.sequencers
+local appendaction = sequencers.appendaction
+local enableaction = sequencers.enableaction
+local disableaction = sequencers.disableaction
+
+local implement = interfaces.implement
+
+local stack = { }
+local top = nil
+local enabled = false
+
+local trace = false trackers.register("paragraphs.tweaks",function(v) trace = v end)
+
+local report = logs.reporter("paragraphs","tweaks")
+
+implement {
+ name = "pushparagraphtweak",
+ public = true,
+ protected = true,
+ arguments = "string",
+ actions = function(t)
+ insert(stack,top)
+ if not enabled then
+ if trace then
+ report("enabling")
+ end
+ enableaction("paragraphcontext","builders.checkparcontext")
+ enabled = true
+ end
+ top = t
+ end
+}
+
+implement {
+ name = "popparagraphtweak",
+ public = true,
+ protected = true,
+ actions = function()
+ top = remove(stack)
+ if enabled and not top then
+ if trace then
+ report("disabling")
+ end
+ disableaction("paragraphcontext","builders.checkparcontext")
+ enabled = false
+ end
+ end
+}
+
+function builders.checkparcontext(where)
+ if top and where == "normal" then
+ if top == "cycle" then
+ local s = texget("parshape",true)
+ if s then
+ local p = texget("prevgraf")
+ while p > s do
+ p = p - s
+ end
+ if trace then
+ report("cycling %i",s)
+ end
+ shiftparshape(p,true)
+ return true
+ end
+ elseif top == "shift" then
+ local s = texget("parshape",true)
+ if s then
+ if trace then
+ report("shifting %i", s)
+ end
+ shiftparshape(texget("prevgraf"))
+ return true
+ end
+ end
+ end
+end
+
+appendaction("paragraphcontext","system","builders.checkparcontext")