syst-con.lua /size: 3080 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
syst-con
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to syst-con.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 9
local
tonumber
=
tonumber
10
local
math
=
math
11
local
utfchar
=
utf
.
char
12
local
gsub
=
string
.
gsub
13 14
converters
=
converters
or
{
}
15
local
converters
=
converters
16 17
local
context
=
context
18
local
commands
=
commands
19
local
implement
=
interfaces
.
implement
20 21
local
formatters
=
string
.
formatters
22 23
--[[ldx-- 24<p>For raw 8 bit characters, the offset is 0x110000 (bottom of plane 18) at 25the top of <l n='luatex'/>'s char range but outside the unicode range.</p> 26--ldx]]
--
27 28
function
converters
.
hexstringtonumber
(
n
)
tonumber
(
n
,
16
)
end
29
function
converters
.
octstringtonumber
(
n
)
tonumber
(
n
,
8
)
end
30 31
function
converters
.
rawcharacter
(
n
)
utfchar
(
0x110000
+
n
)
end
32 33
local
lchexnumber
=
formatters
[
"
%x
"
]
34
local
uchexnumber
=
formatters
[
"
%X
"
]
35
local
lchexnumbers
=
formatters
[
"
%02x
"
]
36
local
uchexnumbers
=
formatters
[
"
%02X
"
]
37
local
octnumber
=
formatters
[
"
%03o
"
]
38
local
nicenumber
=
formatters
[
"
%0.6F
"
]
39 40
converters
.
lchexnumber
=
lchexnumber
41
converters
.
uchexnumber
=
uchexnumber
42
converters
.
lchexnumbers
=
lchexnumbers
43
converters
.
uchexnumbers
=
uchexnumbers
44
converters
.
octnumber
=
octnumber
45
converters
.
nicenumber
=
nicenumber
46 47
implement
{
name
=
"
hexstringtonumber
"
,
actions
=
{
tonumber
,
context
}
,
arguments
=
{
"
integer
"
,
16
}
}
48
implement
{
name
=
"
octstringtonumber
"
,
actions
=
{
tonumber
,
context
}
,
arguments
=
{
"
integer
"
,
8
}
}
49 50
implement
{
name
=
"
rawcharacter
"
,
actions
=
function
(
n
)
context
(
utfchar
(
0x110000
+
n
)
)
end
,
arguments
=
"
integer
"
}
51 52
implement
{
name
=
"
lchexnumber
"
,
actions
=
{
lchexnumber
,
context
}
,
arguments
=
"
integer
"
}
53
implement
{
name
=
"
uchexnumber
"
,
actions
=
{
uchexnumber
,
context
}
,
arguments
=
"
integer
"
}
54
implement
{
name
=
"
lchexnumbers
"
,
actions
=
{
lchexnumbers
,
context
}
,
arguments
=
"
integer
"
}
55
implement
{
name
=
"
uchexnumbers
"
,
actions
=
{
uchexnumbers
,
context
}
,
arguments
=
"
integer
"
}
56
implement
{
name
=
"
octnumber
"
,
actions
=
{
octnumber
,
context
}
,
arguments
=
"
integer
"
}
57 58
implement
{
name
=
"
sin
"
,
actions
=
{
math
.
sin
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
59
implement
{
name
=
"
cos
"
,
actions
=
{
math
.
cos
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
60
implement
{
name
=
"
tan
"
,
actions
=
{
math
.
tan
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
61 62
implement
{
name
=
"
sind
"
,
actions
=
{
math
.
sind
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
63
implement
{
name
=
"
cosd
"
,
actions
=
{
math
.
cosd
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
64
implement
{
name
=
"
tand
"
,
actions
=
{
math
.
tand
,
nicenumber
,
context
}
,
arguments
=
"
number
"
}
65 66
-- only as commands
67 68
function
commands
.
format
(
fmt
,
...
)
context
(
(
gsub
(
fmt
,
"
@
"
,
"
%%
"
)
)
,
...
)
end
69 70
implement
{
71
name
=
"
formatone
"
,
72
public
=
true
,
73
protected
=
true
,
74
arguments
=
"
2 strings
"
,
75
actions
=
function
(
f
,
s
)
context
(
(
gsub
(
f
,
"
@
"
,
"
%%
"
)
)
,
s
)
end
,
76
}
77