5 \NeedsTeXFormat{LaTeX2e}
6 \def\filedate{2012/09/22}
8 \ProvidesPackage{lltjp-listings}[\filedate\space\fileversion]
9 \RequirePackage{listings,luatexbase-cctb}
12 \newluatexcatcodetable\CatcodeTableLTJlistings
13 \setluatexcatcodetable\CatcodeTableLTJlistings{
14 \luatexcatcodetable\CatcodeTableLaTeXAtLetter
16 \setcatcoderange{"0080}{"FFFF}{13}% BMP
17 \setcatcoderange{"20000}{"2FFFF}{13}% SIP
21 \def\lst@kanjitrue{\let\lst@ifkanji\iftrue}
22 \def\lst@kanjifalse{\let\lst@ifkanji\iffalse}
23 \lst@AddToHook{InitVars}{\lst@kanjifalse}
25 \def\lst@AppendOther{%
26 \lst@ifletter\lst@Output\lst@letterfalse\fi\lst@kanjifalse
27 \futurelet\lst@lastother\lst@Append}
29 \def\ltj@lst@setletterflag{%
31 \lst@ifkanji\lst@Output\lst@kanjifalse\fi
33 \lst@lettertrue\lst@ifkanji\lst@kanjifalse\else\lst@OutputOther\fi
36 \def\ltj@lst@setkanjiflag{%
40 \lst@ifkanji\else\lst@OutputOther\fi\lst@lettertrue
43 \def\ltj@lst@setopenflag{%
45 \lst@letterfalse\lst@Output
47 \lst@ifkanji\else\lst@OutputOther\fi
50 \def\ltj@lst@setcloseflag{%
51 \lst@ifletter\else\lst@lettertrue\fi\lst@kanjitrue}
53 \def\lst@ProcessLetter#1{%
55 \ifnum\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{`#1}}=0
56 \ifnum\ltjgetparameter{postbreakpenalty}{`#1}>0
57 \ltj@lst@setopenflag % 開き括弧類
59 \ifnum\ltjgetparameter{prebreakpenalty}{`#1}>0
60 \ltj@lst@setcloseflag % 閉じ括弧類,句読点
62 \ltj@lst@setkanjiflag % 通常の和文文字
64 \advance\lst@length\@ne % 和文文字は通常の2倍の幅
66 \ltj@lst@setletterflag
70 \def\lst@ProcessJALetterHalf#1{%
72 \ifnum\ltjgetparameter{jacharrange}{\ltjgetparameter{chartorange}{`#1}}=0
73 \ifnum\ltjgetparameter{postbreakpenalty}{`#1}>0
74 \ltj@lst@setopenflag % 開き括弧類
76 \ifnum\ltjgetparameter{prebreakpenalty}{`#1}>0
77 \ltj@lst@setcloseflag % 閉じ括弧類
79 \ltj@lst@setkanjiflag % 通常の和文文字
81 \advance\lst@length\@ne % 半角カナは欧文文字と同じ幅
83 \ltj@lst@setletterflag
88 % loading lltjp-listing-jpt.tex
89 \def\ltj@@listing@jpset#1#2{% fast: #2-#1+1 must be a multiple of 16
90 \@tempcnta=#1 \@tempcntb=#2 \@temptokena{}%
91 \loop\relax\ifnum\@tempcnta<\@tempcntb\relax
92 \ltj@@listing@jpset@\global\advance\@tempcnta\sixt@@n\repeat
93 \ltj@@listing@jpset@after{#1}
95 \def\ltj@@listing@jpsetN#1#2#3{% for (not large) range
96 \@tempcnta=#1 \@tempcntb=\numexpr 1+#2\relax \@temptokena{}%
97 \loop \global\advance\@tempcnta\@ne\ifnum\@tempcnta<\@tempcntb\relax
98 \ltj@@listing@jpsetN@{\@tempcnta}{#3}\repeat
99 \ltj@@listing@jpset@after{#1}
102 \def\ltj@@listing@jpset@after#1{%
103 \expandafter\edef\csname ltj@@listing@jpcmd@i#1\endcsname{\the\@temptokena}%
104 \toks@\expandafter\expandafter\expandafter\expandafter%
105 \expandafter\expandafter\expandafter{\expandafter\expandafter%
106 \expandafter\the\expandafter\toks@\csname ltj@@listing@jpcmd@i#1\endcsname}%
111 \catcode`\^^a0=13\catcode`\^^a1=13\catcode`\^^a2=13\catcode`\^^a3=13
112 \catcode`\^^a4=13\catcode`\^^a5=13\catcode`\^^a6=13\catcode`\^^a7=13
113 \catcode`\^^a8=13\catcode`\^^a9=13\catcode`\^^aa=13\catcode`\^^ab=13
114 \catcode`\^^ac=13\catcode`\^^ad=13\catcode`\^^ae=13\catcode`\^^af=13
115 \catcode`\^^b0=12\catcode`\^^b1=12\catcode`\^^b2=12\catcode`\^^b3=12
116 \catcode`\^^b4=12\catcode`\^^b5=12\catcode`\^^b6=12\catcode`\^^b7=12
117 \catcode`\^^b8=12\catcode`\^^b9=12\catcode`\^^ba=12\catcode`\^^bb=12
118 \catcode`\^^bc=12\catcode`\^^bd=12\catcode`\^^be=12\catcode`\^^bf=12
119 \gdef\ltj@@listing@jpset@{%
120 {\lccode`\^^a0=\@tempcnta \lccode`\^^b0=\@tempcnta
121 \advance\@tempcnta\@ne\lccode`\^^a1=\@tempcnta \lccode`\^^b1=\@tempcnta
122 \advance\@tempcnta\@ne\lccode`\^^a2=\@tempcnta \lccode`\^^b2=\@tempcnta
123 \advance\@tempcnta\@ne\lccode`\^^a3=\@tempcnta \lccode`\^^b3=\@tempcnta
124 \advance\@tempcnta\@ne\lccode`\^^a4=\@tempcnta \lccode`\^^b4=\@tempcnta
125 \advance\@tempcnta\@ne\lccode`\^^a5=\@tempcnta \lccode`\^^b5=\@tempcnta
126 \advance\@tempcnta\@ne\lccode`\^^a6=\@tempcnta \lccode`\^^b6=\@tempcnta
127 \advance\@tempcnta\@ne\lccode`\^^a7=\@tempcnta \lccode`\^^b7=\@tempcnta
128 \advance\@tempcnta\@ne\lccode`\^^a8=\@tempcnta \lccode`\^^b8=\@tempcnta
129 \advance\@tempcnta\@ne\lccode`\^^a9=\@tempcnta \lccode`\^^b9=\@tempcnta
130 \advance\@tempcnta\@ne\lccode`\^^aa=\@tempcnta \lccode`\^^ba=\@tempcnta
131 \advance\@tempcnta\@ne\lccode`\^^ab=\@tempcnta \lccode`\^^bb=\@tempcnta
132 \advance\@tempcnta\@ne\lccode`\^^ac=\@tempcnta \lccode`\^^bc=\@tempcnta
133 \advance\@tempcnta\@ne\lccode`\^^ad=\@tempcnta \lccode`\^^bd=\@tempcnta
134 \advance\@tempcnta\@ne\lccode`\^^ae=\@tempcnta \lccode`\^^be=\@tempcnta
135 \advance\@tempcnta\@ne\lccode`\^^af=\@tempcnta \lccode`\^^bf=\@tempcnta
136 \lowercase{\gdef\@temp{%
137 \gdef^^a0{\lst@ProcessLetter^^b0}\gdef^^a1{\lst@ProcessLetter^^b1}%
138 \gdef^^a2{\lst@ProcessLetter^^b2}\gdef^^a3{\lst@ProcessLetter^^b3}%
139 \gdef^^a4{\lst@ProcessLetter^^b4}\gdef^^a5{\lst@ProcessLetter^^b5}%
140 \gdef^^a6{\lst@ProcessLetter^^b6}\gdef^^a7{\lst@ProcessLetter^^b7}%
141 \gdef^^a8{\lst@ProcessLetter^^b8}\gdef^^a9{\lst@ProcessLetter^^b9}%
142 \gdef^^aa{\lst@ProcessLetter^^ba}\gdef^^ab{\lst@ProcessLetter^^bb}%
143 \gdef^^ac{\lst@ProcessLetter^^bc}\gdef^^ad{\lst@ProcessLetter^^bd}%
144 \gdef^^ae{\lst@ProcessLetter^^be}\gdef^^af{\lst@ProcessLetter^^bf}%
145 }}%\message{\meaning\@temp}%
147 \@temptokena\expandafter\expandafter\expandafter\expandafter%
148 \expandafter\expandafter\expandafter{\expandafter\expandafter%
149 \expandafter\the\expandafter\@temptokena\@temp}%
151 \gdef\ltj@@listing@jpsetN@#1#2{{%
152 \@tempcnta=#1 \lccode`\~=\@tempcnta \lccode`\/=\@tempcnta
153 \lowercase{\gdef\@temp{\gdef~{#2/}}}}%
154 \@temptokena\expandafter\expandafter\expandafter\expandafter%
155 \expandafter\expandafter\expandafter{\expandafter\expandafter%
156 \expandafter\the\expandafter\@temptokena\@temp}%
162 \input lltjp-listings-jpt.tex
163 \edef\ltj@@listing@jpcmd{\the\toks@}
165 \lst@AddToHook{Init}{%
166 \luatexcatcodetable\CatcodeTableLTJlistings
171 \def\lst@OutputToken{%
172 \lst@TrackNewLines \lst@OutputLostSpace
174 \lst@gobbledwhitespacefalse
178 {\lst@thestyle{\lst@FontAdjust
179 \setbox\@tempboxa\lst@hbox
182 \expandafter\lst@FillOutputBox\the\lst@token\@empty
184 \ht\@tempboxa=0pt\dp\@tempboxa=0pt
185 \lst@CalcLostSpaceAndOutput}}%
189 % \begin{修正事項}{1.3} from jlisting.sty
191 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
192 % ソースコード目次における文字と番号の空き
193 \let \l@lstlisting = \l@figure
194 % キャプションとソースコード目次に対する日本語対応
195 \def\lstlistingname{ソースコード}
196 \def\lstlistlistingname{ソースコード目次}