OSDN Git Service

Small fix on lltjp-listings.sty etc.
[luatex-ja/luatexja.git] / src / patches / lltjp-listings.sty
1 %
2 % lltjp-listings.sty
3 %
4
5 \NeedsTeXFormat{LaTeX2e}
6 \def\filedate{2012/02/01}
7 \def\fileversion{0.5}
8 \ProvidesPackage{lltjp-listings}[\filedate\space\fileversion]
9 \RequirePackage{listings,luatexbase-cctb}
10
11 % catcode 対策
12 \newluatexcatcodetable\CatcodeTableLTJlistings
13 \setluatexcatcodetable\CatcodeTableLTJlistings{
14   \luatexcatcodetable\CatcodeTableLaTeXAtLetter
15   \catcode"FFFFF=9%"
16   \setcatcoderange{"3000}{"65535}{13}}
17
18 % lower level
19 \def\lst@ProcessJALetter{\lst@whitespacefalse \lst@AppendJALetter}
20 \def\lst@AppendJALetter{%
21     \lst@ifletter \lst@Output\else\lst@OutputOther\fi\lst@lettertrue
22     \advance\lst@length\@ne\lst@Append}
23 \def\lst@ProcessJALetterHalf{\lst@whitespacefalse \lst@AppendJALetterHalf}
24 \def\lst@AppendJALetterHalf{%
25     \lst@ifletter \lst@Output\else\lst@OutputOther\fi\lst@lettertrue
26     \lst@Append}
27
28 % loading lltjp-listing-jpt.tex
29 \def\ltj@@listing@jpset#1#2{%
30   \@tempcnta=#1 \@tempcntb=#2 \@temptokena{}%
31   \loop \global\advance\@tempcnta8\ifnum\@tempcnta<\@tempcntb\relax
32     \ltj@@listing@jpset@\repeat
33   \expandafter\edef\csname ltj@@listing@jpcmd@i#1\endcsname{\the\@temptokena}%
34   \toks@\expandafter\expandafter\expandafter\expandafter%
35   \expandafter\expandafter\expandafter{\expandafter\expandafter%
36   \expandafter\the\expandafter\toks@\csname ltj@@listing@jpcmd@i#1\endcsname}%
37 }
38 \def\ltj@@listing@jpsetN#1#2#3{%
39   \@tempcnta=#1 \@tempcntb=#2 \@temptokena{}%
40   \loop \global\advance\@tempcnta\@ne\ifnum\@tempcnta<\@tempcntb\relax
41     \ltj@@listing@jpsetN@#3\repeat
42   \expandafter\edef\csname ltj@@listing@jpcmd@i#1\endcsname{\the\@temptokena}%
43   \toks@\expandafter\expandafter\expandafter\expandafter%
44   \expandafter\expandafter\expandafter{\expandafter\expandafter%
45   \expandafter\the\expandafter\toks@\csname ltj@@listing@jpcmd@i#1\endcsname}%
46 }
47
48 \begingroup
49 \catcode`\^^A=13\catcode`\^^B=13\catcode`\^^C=13
50 \catcode`\^^D=13\catcode`\^^E=13\catcode`\^^F=13\catcode`\^^G=13
51 \gdef\ltj@@listing@jpset@{%
52   {\lccode`\~=\@tempcnta \lccode`\/=\@tempcnta
53     \advance\@tempcnta\@ne\lccode`\^^A=\@tempcnta \lccode`0=\@tempcnta
54     \advance\@tempcnta\@ne\lccode`\^^B=\@tempcnta \lccode`2=\@tempcnta
55     \advance\@tempcnta\@ne\lccode`\^^C=\@tempcnta \lccode`3=\@tempcnta
56     \advance\@tempcnta\@ne\lccode`\^^D=\@tempcnta \lccode`4=\@tempcnta
57     \advance\@tempcnta\@ne\lccode`\^^E=\@tempcnta \lccode`5=\@tempcnta
58     \advance\@tempcnta\@ne\lccode`\^^F=\@tempcnta \lccode`6=\@tempcnta
59     \advance\@tempcnta\@ne\lccode`\^^G=\@tempcnta \lccode`7=\@tempcnta
60     \lowercase{\gdef\@temp{%
61       \gdef~{\lst@ProcessJALetter/}\gdef^^A{\lst@ProcessJALetter0}%
62       \gdef^^B{\lst@ProcessJALetter2}\gdef^^C{\lst@ProcessJALetter3}%
63       \gdef^^D{\lst@ProcessJALetter4}\gdef^^E{\lst@ProcessJALetter5}%
64       \gdef^^F{\lst@ProcessJALetter6}\gdef^^G{\lst@ProcessJALetter7}}}%
65   }%
66   \@temptokena\expandafter\expandafter\expandafter\expandafter%
67   \expandafter\expandafter\expandafter{\expandafter\expandafter%
68   \expandafter\the\expandafter\@temptokena\@temp}%
69 }
70 \gdef\ltj@@listing@jpsetN@#1{{%
71     \lccode`\~=\@tempcnta \lccode`\/=\@tempcnta
72     \lowercase{\gdef\@temp{\gdef~{#1/}}}}%
73   \@temptokena\expandafter\expandafter\expandafter\expandafter%
74   \expandafter\expandafter\expandafter{\expandafter\expandafter%
75   \expandafter\the\expandafter\@temptokena\@temp}%
76 }
77 \endgroup
78
79
80 \input lltjp-listings-jpt.tex
81 \edef\ltj@@listing@jpcmd{\the\toks@}
82 \toks@{}
83 \lst@AddToHook{Init}{%
84   \luatexcatcodetable\CatcodeTableLTJlistings
85   \ltj@@listing@jpcmd}
86
87
88 % 白線対策
89 \def\lst@OutputToken{%
90     \lst@TrackNewLines \lst@OutputLostSpace
91     \lst@ifgobbledws
92         \lst@gobbledwhitespacefalse
93         \lst@@discretionary
94     \fi
95     \lst@CheckMerge
96     {\lst@thestyle{\lst@FontAdjust
97      \setbox\@tempboxa\lst@hbox
98         {\lsthk@OutputBox
99          \lst@lefthss
100          \expandafter\lst@FillOutputBox\the\lst@token\@empty
101          \lst@righthss}%
102      \ht\@tempboxa=0pt\dp\@tempboxa=0pt
103      \lst@CalcLostSpaceAndOutput}}%
104     \lst@ResetToken}
105
106
107 %    \begin{修正事項}{1.3} from jlisting.sty
108 % ちょっとした修正
109 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
110 % ソースコード目次における文字と番号の空き
111 \let \l@lstlisting = \l@figure
112 % キャプションとソースコード目次に対する日本語対応
113 \def\lstlistingname{ソースコード}
114 \def\lstlistlistingname{ソースコード目次}
115 %    \end{修正事項}
116 \endinput