summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-lib.tex
blob: a068125b6750e5740bfa62314c276c67f8dd942c (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
%D \module
%D   [       file=luat-lib,
%D        version=2006.09.11,
%D          title=\CONTEXT\ Lua Macros,
%D       subtitle=Unicode Support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% \writestatus{loading}{Lua Support Macros (libs)}

%D For the moment we only load this lib.

%D This will move cq. become configurable. The XML like output is just
%D an example.

% todo \let\normaleverytoks\everytoks \newtoks\everytoke \normaleverytoks{\the\everytoks}

\chardef\statuswidth=15
\chardef\statuswrite=16

\newtoks\everywritestring

\def\writedirect  {\immediate\write\statuswrite}
\def\writeline    {\writedirect{}}
\def\writestring#1{\begingroup\the\everywritestring\writedirect{#1}\endgroup}

\ifx\normalmessage    \undefined \let\normalmessage         \message               \fi
\ifx\normalwritestatus\undefined \def\normalwritestatus#1#2{\writedirect{#1 : #2}} \fi

% this will change once we have proper write overloads

\registerctxluafile{l-string} {1.001}
\registerctxluafile{l-lpeg}   {1.001}
\registerctxluafile{l-boolean}{1.001}
\registerctxluafile{l-number} {1.001}
\registerctxluafile{l-set}    {1.001}
\registerctxluafile{l-math}   {1.001}
\registerctxluafile{l-table}  {1.001}
\registerctxluafile{l-md5}    {1.001}
\registerctxluafile{l-aux}    {1.001}
\registerctxluafile{l-io}     {1.001}
\registerctxluafile{l-os}     {1.001}
\registerctxluafile{l-file}   {1.001}
\registerctxluafile{l-dir}    {1.001}
\registerctxluafile{l-unicode}{1.001}
\registerctxluafile{l-utils}  {1.001}
\registerctxluafile{l-tex}    {1.001}
\registerctxluafile{l-url}    {1.001}
\registerctxluafile{l-xml}    {1.001}
%registerctxluafile{l-xmlctx} {1.001}

\registerctxluafile{luat-cbk} {1.001}
\registerctxluafile{luat-lib} {1.001}
\registerctxluafile{luat-inp} {1.001}
\registerctxluafile{luat-log} {1.001}
\registerctxluafile{luat-zip} {1.001}
\registerctxluafile{luat-tex} {1.001}
\registerctxluafile{luat-tre} {1.001}

\startruntimeluacode
    \edef\asciia{\ctxlua{tex.sprint(input.logmode())}}
    \edef\asciib{xml}
    \ifx\asciia\asciib % brrr
        \long\def\writebanner  #1{\writestring  {<m t='banner'>#1</m>}}
        \long\def\writestatus#1#2{\writestring  {<m t='#1'>#2</m>}}
        \long\def\message      #1{\normalmessage{<m t='message'>#1</m>}}
    \else
        \let\writebanner\writestring
        \let\writestatus\normalwritestatus
        \let\message    \normalmessage
    \fi
\stopruntimeluacode

\registerctxluafile{luat-tmp}{1.001}
\registerctxluafile{luat-crl}{1.001}
\registerctxluafile{luat-exe}{1.001}
\registerctxluafile{luat-iop}{1.001}

% trace used files (only from trees)
%
% \ctxlua{input.register_stop_actions(function() input.save_used_files_in_trees(texmf.instance) end)}
% \ctxlua{table.insert(input.stop_actions, function() input.save_used_files_in_trees(texmf.instance) end)}
% \ctxlua{function input.stop_actions.trace_used_files() input.save_used_files_in_trees(texmf.instance) end}

\endinput