1if not modules then modules = { } end modules ['spac-hor'] = {
2 version = 1.001,
3 comment = "companion to spac-hor.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local chardata = characters.data
10local peekchar = tokens.scanners.peekchar
11local ctx_space = context.space
12
13local nuts = nodes.nuts
14local tonut = nodes.tonut
15local texgetnest = tex.getnest
16local traverseglue = nuts.traversers.glue
17local setwidth = nodes.nuts.setwidth
18local indentskip_code <const> = nodes.gluecodes.indentskip
19
20local can_have_space = characters.can_have_space
21
22interfaces.implement {
23 name = "autoinsertnextspace",
24 protected = true,
25 public = true,
26 actions = function()
27 local char = peekchar()
28 if char then
29 local d = chardata[char]
30 if d and can_have_space[d.category] then
31 ctx_space()
32 end
33 end
34 end,
35}
36
37local function lateindent(amount)
38 local head = tonut(texgetnest("top","head"))
39 if head then
40 for n, s in traverseglue, head do
41 if s == indentskip_code then
42 setwidth(n,amount or 0)
43 end
44 end
45 end
46end
47
48interfaces.implement {
49 name = "lateindent",
50 public = true,
51 protected = "true",
52 arguments = "dimension",
53 actions = lateindent,
54}
55interfaces.implement {
56 name = "lateundent",
57 public = true,
58 protected = "true",
59 actions = lateindent,
60}
61 |