summaryrefslogtreecommitdiff
path: root/tex/context/base/scrp-ini.mkiv
blob: d0ee8770dfd8f319cd2a64e3f2b8badfea0073b5 (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
%D \module
%D   [       file=scrp-ini,
%D        version=2009.02.06,
%D          title=\CONTEXT\ Script Macros,
%D       subtitle=Initialization,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% here we collect code from other places (was organized differently)

\registerctxluafile{scrp-ini}{1.001}
\registerctxluafile{scrp-cjk}{1.001}
\registerctxluafile{scrp-eth}{1.001}

\definesystemattribute[preproc][public]
\definesystemattribute[prestat][public]

%D Since scripts need specific \LUA\ code we use hard coded attribute
%D values, but we might have more tricks at some time, so we use a
%D proper define macro too.

\unprotect

\installcommandhandler\??ls{script}\??ls

% presets are global and are currently defined in lua

\appendtoks
    \setuevalue\currentscript{\setscript[\currentscript]}%
\to \everydefinescript

\unexpanded\def\dosetscript
  {\ctxlua{scripts.set("\currentscript","\scriptparameter\c!method","\scriptparameter\c!preset")}}

\unexpanded\def\setscript[#1]%
  {\edef\currentscript{#1}%
   \dosetscript}

\unexpanded\def\resetscript
  {\ctxlua{scripts.reset()}}

\unexpanded\def\startscript[#1]%
  {\begingroup
   \edef\currentscript{#1}%
   \dosetscript}

\unexpanded\def\stopscript
  {\endgroup}

% \setscript[hangul] \hangul \startscript[hangul]

\definescript[hangul]   [\c!method=hangul]
\definescript[hanzi]    [\c!method=hanzi]

\definescript[ethiopic] [\c!method=ethiopic]

\definescript[latin]    [\c!method=]        %  resets the attribute (also currentscript)

\protect \endinput