OSDN Git Service

Add test code for unicode-math (test/test07-math-unicode.tex).
[luatex-ja/luatexja.git] / doc / lltjlisting.sty
1 % lltjlisting.sty: modified from jlisting.sty (by Thor) for
2 % LuaTeX-ja. 
3
4 \NeedsTeXFormat{LaTeX2e}
5 \def\filedate{2006/02/20}
6 \def\fileversion{0.2}
7 \ProvidesPackage{lltjlisting}[\filedate\space\fileversion\space(Thor)]
8 %
9 \newcount\lst@nextchar
10 \let\lst@@ProcessSpace\lst@ProcessSpace
11 \def\lst@ProcessSpace#1{%
12    \lst@check@chartype{#1}%
13       \lst@@ProcessSpace
14       \lst@whitespacetrue}
15 \let\lst@@ProcessLetter\lst@ProcessLetter
16 \def\lst@ProcessLetter#1#2{%
17    \lst@check@chartype{#2}%
18       {\lst@@ProcessLetter{#1}}%
19       \relax}
20 \let\lst@@ProcessDigit\lst@ProcessDigit
21 \def\lst@ProcessDigit#1#2{%
22    \lst@check@chartype{#2}%
23       {\lst@@ProcessDigit{#1}}%
24       \relax}
25 \let\lst@@ProcessOther\lst@ProcessOther
26 \def\lst@ProcessOther#1#2{%
27    \lst@check@chartype{#2}%
28       {\lst@@ProcessOther{#1}}%
29       \relax}
30 \let\lst@@ProcessTabulator\lst@ProcessTabulator
31 \def\lst@ProcessTabulator#1{%
32    \lst@check@chartype{#1}%
33       \lst@@ProcessTabulator
34       \relax}
35 \def\lst@check@chartype#1#2#3{%
36    \edef\@tempa{\lst@nextchar=`\string#1\relax}%
37    \afterassignment\remove@to@nnil
38    \@tempa\@nnil
39    #2%
40    \ifnum\lst@nextchar<\@cclvi
41       #3%
42    \else
43       \lst@ifletter \else \lst@OutputOther \fi
44       \lst@whitespacefalse
45       \expandafter\lst@AppendJchar
46    \fi
47    #1}
48 \def\lst@AppendJchar#1#2{%
49    \lst@check@chartype{#2}%
50       {\advance\lst@length\@ne\lst@Append{#1}}%
51       \relax}
52 \def\lst@check@chartype@BOL#1{%
53    \edef\@tempa{\lst@nextchar=`\string#1\relax}%
54    \afterassignment\remove@to@nnil
55    \@tempa\@nnil
56    \ifnum\lst@nextchar<\@cclvi\else
57       \lst@whitespacefalse
58       \expandafter\lst@AppendJchar
59    \fi
60    #1}
61 \def\lst@InputListing#1{%
62    \begingroup
63       \lsthk@PreSet \gdef\lst@intname{#1}%
64       \expandafter\lstset\expandafter{\lst@set}%
65       \lsthk@DisplayStyle
66       \catcode\active=\active
67       \lst@Init\relax \let\lst@gobble\z@
68       \lst@SkipToFirst
69       \lst@ifprint \def\lst@next{\lst@get@filecontents{#1}}%
70       \else        \let\lst@next\@empty
71       \fi
72       \catcode"FFFFF=12%"
73       \lst@next
74       \lst@DeInit
75    \endgroup}
76 \newread\lst@inputfile
77 \def\lst@get@filecontents#1{%
78    \let\lst@filecontents\@empty
79    \openin\lst@inputfile=#1\relax
80    \let\@lst@get@filecontents@prevline\relax
81    \lst@get@filecontents@loop
82    \closein\lst@inputfile
83    \lst@filecontents\empty}
84 \def\lst@get@filecontents@loop{%
85    \read\lst@inputfile to\@lst@get@filecontents@currline
86    \ifx\@lst@get@filecontents@prevline\relax\else
87       \expandafter\expandafter\expandafter\def
88       \expandafter\expandafter\expandafter\lst@filecontents
89       \expandafter\expandafter\expandafter{%
90          \expandafter\lst@filecontents\@lst@get@filecontents@prevline}%
91    \fi
92    \let\@lst@get@filecontents@prevline\@lst@get@filecontents@currline
93    \ifeof\lst@inputfile\else
94       \expandafter\lst@get@filecontents@loop
95    \fi}
96 %%% [この処理も,相当強引です.]
97 \def\lst@BOLGobble{%
98    \ifnum\lst@gobble>\z@
99       \@tempcnta\lst@gobble\relax
100       \expandafter\lst@BOLGobble@
101    \else
102       \expandafter\lst@check@chartype@BOL
103    \fi}
104 \def\lst@BOLGobble@#1{%
105    \let\lst@next#1%
106    \ifx \lst@next\relax\else
107    \ifx \lst@next\lst@MProcessListing\else
108    \ifx \lst@next\lst@ProcessFormFeed\else
109    \ifx \lst@next\lstenv@backslash
110       \let\lst@next\lstenv@BOLGobble@@
111    \else
112       \let\lst@next\lst@BOLGobble@@
113       \ifx #1\lst@ProcessTabulator
114          \advance\@tempcnta-\lst@tabsize\relax
115          \ifnum\@tempcnta<\z@
116             \lst@length-\@tempcnta \lst@PreGotoTabStop
117          \fi
118       \else
119          \edef\@tempa{\lst@nextchar=`\string#1\relax}%
120          \@tempa
121          \ifnum\lst@nextchar<\@cclvi\else
122             \advance\@tempcnta\m@ne
123          \fi
124          \advance\@tempcnta\m@ne
125       \fi
126    \fi \fi \fi \fi
127    \lst@next}
128 \def\lst@BOLGobble@@{%
129    \ifnum\@tempcnta>\z@
130       \expandafter\lst@BOLGobble@
131    \else
132       \expandafter\lst@check@chartype@BOL
133    \fi
134 }
135
136 %
137 %    \begin{修正事項}{1.3}
138 % ちょっとした修正
139 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
140 % ソースコード目次における文字と番号の空き
141 \let \l@lstlisting = \l@figure
142 % キャプションとソースコード目次に対する日本語対応
143 \def\lstlistingname{ソースコード}
144 \def\lstlistlistingname{ソースコード目次}
145 %    \end{修正事項}
146
147
148 % Changes for LuaTeX-ja:
149 % 1. \char"FFFFF は通常行末用コメント文字として使われる.
150 %    だが,それはソースコードの組版には邪魔ものとなる.
151 %\lst@AddToHook{Init}{\catcode"FFFFF=9 }
152 %\lst@AddToHook{DeInit}{\catcode"FFFFF=14 }
153 %\lst@Def{1048575}{}
154
155 % 2. listing な環境の処理中に \DeclareFontShape の (s)sub が実行されると,なぜか
156 %        ! Use of set@size@funct@args@ doesn't match its definition.
157 %    のエラーが出る.
158 %    \ifnot@nil #1-> \def\reserved@a{#1}... の \reserved@a=\set@size@funct@args@
159 %    がなぜか実行される?
160 %    ad hoc な対策として事前に必要な (s)sub は実行しておくことにする.
161 \lst@AddToHook{Init}{\begingroup\itshape\bfseries\upshape\endgroup}
162 \endinput