summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/core-lmt.lmt
blob: ccbdcc0dff6ef79d717b61d56928f05610c83155 (plain)
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
if not modules then modules = { } end modules ['core-lmt'] = {
    version   = 1.001,
    comment   = "companion to core-lmt.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- Kind of obsolete ... old school directions.

local implement   = interfaces.implement
local scankeyword = tokens.scanners.keyword
local scaninteger = tokens.scanners.integer

local settextdir  = tex.settextdir
local setlinedir  = tex.setlinedir
local setpardir   = tex.setpardir
local setboxdir   = tex.setboxdir

local gettextdir  = tex.gettextdir
local getlinedir  = tex.getlinedir
local getpardir   = tex.getpardir
local getboxdir   = tex.getboxdir

local none_code   = tokens.values.none

local context     = context

local function scandir()
    if scankeyword("tlt") then
        return 0
    elseif scankeyword("trt") then
        return 1
    else
        return 0
    end
end

local function showdir(d)
    context(d == 1 and "TRT" or "LTL")
    return none_code
end

implement {
    name    = "textdir",
    public  = true,
    usage   = "value",
    actions = function(what)
        if what == "value" then
            showdir(gettextdir())
        else
            settextdir(scandir())
        end
    end
}

implement {
    name    = "linedir",
    public  = true,
    usage   = "value",
    actions = function(what)
        if what == "value" then
            return showdir(getlinedir())
        else
            setlinedir(scandir())
        end
    end
}

implement {
    name    = "pardir",
    public  = true,
    usage   = "value",
    actions = function(what)
        if what == "value" then
            return showdir(getpardir())
        else
            setpardir(scandir())
        end
    end
}

implement {
    name    = "boxdir",
    public  = true,
    usage   = "value",
    actions = function(what)
        local n = scaninteger()
        if what == "value" then
            return showdir(getboxdir(n))
        else
            setboxdir(n,scandir())
        end
    end
}