1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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")
|