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 can_have_space = characters.can_have_space
14
15interfaces.implement {
16 name = "autoinsertnextspace",
17 protected = true,
18 public = true,
19 actions = function()
20 local char = peekchar()
21 if char then
22 local d = chardata[char]
23 if d and can_have_space[d.category] then
24 ctx_space()
25 end
26 end
27 end,
28}
29
30local nuts = nodes.nuts
31local tonut = nodes.tonut
32local traverseglue = nuts.traversers.glue
33local setwidth = nodes.nuts.setwidth
34local indentskip_code = nodes.gluecodes.indentskip
35local texgetnest = tex.getnest
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 |