summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-06-23 00:16:18 +0000
committerKarl Berry <karl@freefriends.org>2009-06-23 00:16:18 +0000
commita6f953f4816835c3e6460c8623361f6cc7978ee5 (patch)
treebebd23f3118698497ca50f1ac3b6f7fcbc49ac4e /Master/texmf-dist/tex/luatex/luatextra/luatextra.sty
parentb3e52d29b04fed8c4f0a8695fbca2b113a36d4ad (diff)
new luatex package luatextra
git-svn-id: svn://tug.org/texlive/trunk@13902 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatextra/luatextra.sty')
-rw-r--r--Master/texmf-dist/tex/luatex/luatextra/luatextra.sty237
1 files changed, 237 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty b/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty
new file mode 100644
index 00000000000..3b86be22d90
--- /dev/null
+++ b/Master/texmf-dist/tex/luatex/luatextra/luatextra.sty
@@ -0,0 +1,237 @@
+%%
+%% This is file `luatextra.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% luatextra.dtx (with options: `package')
+%% This is a generated file.
+%%
+%% Copyright (C) 2009 by Elie Roux <elie.roux@telecom-bretagne.eu>
+%%
+%% This work is under the CC0 license.
+%%
+%% This work consists of the main source file luainputenc.dtx
+%% and the derived files
+%% luatextra.sty, luatextra.lua, luatextra-latex.tex, luatextra.pdf
+%%
+\csname ifluatextraloaded\endcsname
+\let\ifluatextraloaded\endinput
+
+
+\expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \expandafter\ifx\csname ifluatex\endcsname\relax
+ \input ifluatex.sty
+ \fi
+\else
+ \RequirePackage{ifluatex}
+\fi
+
+\expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \ifluatex\else
+ \immediate\write16{}
+ \errmessage{Package luatextra Error: This package must be used with LuaTeX}
+ \fi
+ \def\luaRequireModule#1#2{\luadirect{luatextra.require_module([[#1]], [[#2]])}}
+\else
+ \ifluatex\else
+ \PackageError{luatextra}{This package must be used with LuaTeX.}
+ \fi
+ \NeedsTeXFormat{LaTeX2e}
+ \ProvidesPackage{luatextra}
+ [2009/04/15 v0.93 LuaTeX extra low-level macros]
+ \RequirePackage{environ}
+ \NewEnviron{luacode}{\luadirect{\BODY}}
+ \newcommand\luaRequireModule[2][0]{\luadirect{luatextra.require_module([[#2]], [[#1]])}}
+ \RequirePackage{etex}[1998/03/26]%
+ \input luatextra-latex.tex
+\fi
+
+
+\def\LuaTeX{Lua\TeX }
+\def\LuaLaTeX{Lua\LaTeX }
+
+
+\ifnum\luatexversion<36
+ \def\directlua{\pdfprimitive\directlua0}
+ \def\latelua{\pdfprimitive\latelua0}
+ \def\luadirect{\pdfprimitive\directlua0}
+ \def\lualate{\pdfprimitive\latelua0}
+ \def\luaattribute{\attribute}
+ \def\luaattributedef{\attributedef}
+ \def\luaclearmarks{\pdfprimitive\luaclearmarks}
+ \def\luaformatname{\pdfprimitive\formatname}
+ \def\luascantexttokens{\pdfprimitive\scantexttokens}
+ \def\luacatcodetable{\catcodetable}
+\else
+ \directlua{tex.enableprimitives('lua', {'attribute'})}
+ \directlua{tex.enableprimitives('lua', {'attributedef'})}
+ \directlua{tex.enableprimitives('lua', {'clearmarks'})}
+ \directlua{tex.enableprimitives('lua', {'formatname'})}
+ \directlua{tex.enableprimitives('lua', {'scantexttokens'})}
+ \directlua{tex.enableprimitives('lua', {'catcodetable'})}
+ \def\luadirect{\pdfprimitive\directlua}
+ \def\lualate{\pdfprimitive\latelua}
+\fi
+
+\def\initluacatcodetable{\pdfprimitive\initcatcodetable}
+\def\saveluacatcodetable{\pdfprimitive\savecatcodetable}
+\def\luaclose{\pdfprimitive\closelua}
+
+
+\luadirect{dofile(kpse.find_file("luatextra.lua"))}
+
+
+\def\ltxtra@RegisterFontCallback{
+ \luadirect{luatextra.register_font_callback()}
+}
+
+
+
+\def\luaModuleError#1#2{%
+ \errorcontextlines=0\relax
+ \immediate\write16{}%
+ \errmessage{Module #1 error: #2^^J^^J%
+See the module #1 documentation for explanation.^^J ...^^J}%
+}
+
+\def\luaUseModule#1{\luadirect{luatextra.use_module([[#1]])}}
+
+
+\newcount\luaattdefcounter
+\luaattdefcounter = 1
+
+\def\newluaattribute#1{%
+ \ifnum\luaattdefcounter<65535\relax %
+ \global\advance\luaattdefcounter by 1\relax %
+ \allocationnumber\luaattdefcounter %
+ \ifluatex %
+ \global\luaattributedef#1=\allocationnumber %
+ \fi %
+ \wlog{\string#1=\string\attribute\the\allocationnumber}%
+ \luadirect{%
+ luatextra.attributedef_from_tex([[\noexpand#1]], '\number\allocationnumber')}%
+ \else %
+ \errmessage{No room for a new \string\attribute}%
+ \fi %
+}
+
+
+\def\setluaattribute#1#2{%
+ #1=\numexpr#2\relax %
+}
+
+\def\unsetluaattribute#1{%
+ \ifnum\luatexversion<37\relax %
+ #1=-1\relax %
+ \else %
+ #1=-"7FFFFFFF\relax %
+ \fi %
+}
+
+
+\newcount\luacatcodetabledefcounter
+
+\luacatcodetabledefcounter = 1
+
+\def\newluacatcodetable#1{%
+ \ifnum\luacatcodetabledefcounter<1114110\relax % 0x10FFFF is maximal \chardef
+ \global\advance\luacatcodetabledefcounter by 1\relax %
+ \allocationnumber=\luacatcodetabledefcounter %
+ \global\chardef#1=\allocationnumber %
+ \luadirect{%
+ luatextra.catcodetabledef_from_tex([[\noexpand#1]], '\number\allocationnumber')}%
+ \wlog{\string#1=\string\catcodetable\the\allocationnumber}%
+ \else %
+ \errmessage{No room for a new \string\catcodetable}%
+ \fi %
+}
+
+
+\expandafter\edef\csname ltxtra@AtEnd\endcsname{%
+ \catcode64 \the\catcode64\relax
+}
+
+\catcode 64=11\relax
+
+\expandafter\ifx\csname @tempcnta\endcsname\relax
+ \csname newcount\endcsname\@tempcnta
+\fi
+\expandafter\ifx\csname @tempcntb\endcsname\relax
+ \csname newcount\endcsname\@tempcntb
+\fi
+
+
+\def\luasetcatcoderange#1#2#3{%
+ \edef\luaSCR@temp{%
+ \noexpand\@tempcnta=\the\@tempcnta
+ \noexpand\@tempcntb=\the\@tempcntb
+ \noexpand\count@=\the\count@
+ \relax
+ }%
+ \@tempcnta=#1\relax
+ \@tempcntb=#2\relax
+ \count@=#3\relax
+ \loop\unless\ifnum\@tempcnta>\@tempcntb
+ \catcode\@tempcnta=\count@
+ \advance\@tempcnta by 1\relax
+ \repeat
+ \luaSCR@temp
+}
+
+
+\newluacatcodetable\CatcodeTableIniTeX
+\newluacatcodetable\CatcodeTableString
+\newluacatcodetable\CatcodeTableOther
+\newluacatcodetable\CatcodeTableLaTeX
+\initluacatcodetable\CatcodeTableIniTeX
+
+\expandafter\ifx\csname @firstofone\endcsname\relax
+ \long\def\@firstofone#1{#1}%
+\fi
+
+\begingroup
+ \def\@makeother#1{\catcode#1=12\relax}%
+ \@firstofone{%
+ \luacatcodetable\CatcodeTableIniTeX
+ \begingroup
+ \luasetcatcoderange{0}{8}{15}%
+ \catcode9=10 % tab
+ \catcode11=15 %
+ \catcode12=13 % form feed
+ \luasetcatcoderange{14}{31}{15}%
+ \catcode35=6 % hash
+ \catcode36=3 % dollar
+ \catcode38=4 % ampersand
+ \catcode94=7 % circumflex
+ \catcode95=8 % underscore
+ \catcode123=1 % brace left
+ \catcode125=2 % brace right
+ \catcode126=13 % tilde
+ \catcode127=15 %
+ \saveluacatcodetable\CatcodeTableLaTeX
+ \endgroup
+ \@makeother{0}% nul
+ \@makeother{13}% carriage return
+ \@makeother{37}% percent
+ \@makeother{92}% backslash
+ \@makeother{127}%
+ \luasetcatcoderange{65}{90}{12}% A-Z
+ \luasetcatcoderange{97}{122}{12}% a-z
+ \saveluacatcodetable\CatcodeTableString
+ \@makeother{32}% space
+ \saveluacatcodetable\CatcodeTableOther
+ \endgroup
+}
+
+
+\expandafter\ifx\csname ProvidesPackage\endcsname\relax
+ \input luaotfload.sty
+\else
+ \RequirePackage{luaotfload}
+\fi
+
+\ltxtra@AtEnd
+\endinput
+%%
+%% End of file `luatextra.sty'.