summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty
blob: 5059ef9d53e80723b4dc1a28b7e4a5e76d0e0071 (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
%
% lltjp-listings.sty
%

\NeedsTeXFormat{LaTeX2e}
\def\filedate{2012/02/02}
\def\fileversion{0.51}
\ProvidesPackage{lltjp-listings}[\filedate\space\fileversion]
\RequirePackage{listings,luatexbase-cctb}

% catcode 対策
\newluatexcatcodetable\CatcodeTableLTJlistings
\setluatexcatcodetable\CatcodeTableLTJlistings{
  \luatexcatcodetable\CatcodeTableLaTeXAtLetter
  \catcode"FFFFF=9%"
  \setcatcoderange{"2000}{"FFFF}{13}%
  \setcatcoderange{"20000}{"2FFFF}{13}}

% lowest level
\def\lst@ProcessJALetter{\lst@whitespacefalse \lst@AppendJALetter}
\def\lst@AppendJALetter{%
    \lst@ifletter \lst@Output\else\lst@OutputOther\fi\lst@lettertrue
    \advance\lst@length\@ne\lst@Append}
\def\lst@ProcessJALetterHalf{\lst@whitespacefalse \lst@AppendJALetterHalf}
\def\lst@AppendJALetterHalf{%
    \lst@ifletter \lst@Output\else\lst@OutputOther\fi\lst@lettertrue
    \lst@Append}

% loading lltjp-listing-jpt.tex
\def\ltj@@listing@jpset#1#2{% fast: #2-#1+1 must be a multiple of 16
  \@tempcnta=#1 \@tempcntb=#2 \@temptokena{}%
  \loop\relax\ifnum\@tempcnta<\@tempcntb\relax
    \ltj@@listing@jpset@\global\advance\@tempcnta\sixt@@n\repeat
  \expandafter\edef\csname ltj@@listing@jpcmd@i#1\endcsname{\the\@temptokena}%
  \toks@\expandafter\expandafter\expandafter\expandafter%
  \expandafter\expandafter\expandafter{\expandafter\expandafter%
  \expandafter\the\expandafter\toks@\csname ltj@@listing@jpcmd@i#1\endcsname}%
}
\def\ltj@@listing@jpsetN#1#2#3{%
  \@tempcnta=#1 \@tempcntb=#2 \@temptokena{}%
  \loop \global\advance\@tempcnta\@ne\ifnum\@tempcnta<\@tempcntb\relax
    \ltj@@listing@jpsetN@#3\repeat
  \expandafter\edef\csname ltj@@listing@jpcmd@i#1\endcsname{\the\@temptokena}%
  \toks@\expandafter\expandafter\expandafter\expandafter%
  \expandafter\expandafter\expandafter{\expandafter\expandafter%
  \expandafter\the\expandafter\toks@\csname ltj@@listing@jpcmd@i#1\endcsname}%
}

\begingroup
\catcode`\^^a0=13\catcode`\^^a1=13\catcode`\^^a2=13\catcode`\^^a3=13
\catcode`\^^a4=13\catcode`\^^a5=13\catcode`\^^a6=13\catcode`\^^a7=13
\catcode`\^^a8=13\catcode`\^^a9=13\catcode`\^^aa=13\catcode`\^^ab=13
\catcode`\^^ac=13\catcode`\^^ad=13\catcode`\^^ae=13\catcode`\^^af=13
\catcode`\^^b0=12\catcode`\^^b1=12\catcode`\^^b2=12\catcode`\^^b3=12
\catcode`\^^b4=12\catcode`\^^b5=12\catcode`\^^b6=12\catcode`\^^b7=12
\catcode`\^^b8=12\catcode`\^^b9=12\catcode`\^^ba=12\catcode`\^^bb=12
\catcode`\^^bc=12\catcode`\^^bd=12\catcode`\^^be=12\catcode`\^^bf=12
\gdef\ltj@@listing@jpset@{%
   {\lccode`\^^a0=\@tempcnta \lccode`\^^b0=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a1=\@tempcnta \lccode`\^^b1=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a2=\@tempcnta \lccode`\^^b2=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a3=\@tempcnta \lccode`\^^b3=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a4=\@tempcnta \lccode`\^^b4=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a5=\@tempcnta \lccode`\^^b5=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a6=\@tempcnta \lccode`\^^b6=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a7=\@tempcnta \lccode`\^^b7=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a8=\@tempcnta \lccode`\^^b8=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^a9=\@tempcnta \lccode`\^^b9=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^aa=\@tempcnta \lccode`\^^ba=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^ab=\@tempcnta \lccode`\^^bb=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^ac=\@tempcnta \lccode`\^^bc=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^ad=\@tempcnta \lccode`\^^bd=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^ae=\@tempcnta \lccode`\^^be=\@tempcnta
    \advance\@tempcnta\@ne\lccode`\^^af=\@tempcnta \lccode`\^^bf=\@tempcnta
    \lowercase{\gdef\@temp{%
      \gdef^^a0{\lst@ProcessJALetter^^b0}\gdef^^a1{\lst@ProcessJALetter^^b1}%
      \gdef^^a2{\lst@ProcessJALetter^^b2}\gdef^^a3{\lst@ProcessJALetter^^b3}%
      \gdef^^a4{\lst@ProcessJALetter^^b4}\gdef^^a5{\lst@ProcessJALetter^^b5}%
      \gdef^^a6{\lst@ProcessJALetter^^b6}\gdef^^a7{\lst@ProcessJALetter^^b7}%
      \gdef^^a8{\lst@ProcessJALetter^^b8}\gdef^^a9{\lst@ProcessJALetter^^b9}%
      \gdef^^aa{\lst@ProcessJALetter^^ba}\gdef^^ab{\lst@ProcessJALetter^^bb}%
      \gdef^^ac{\lst@ProcessJALetter^^bc}\gdef^^ad{\lst@ProcessJALetter^^bd}%
      \gdef^^ae{\lst@ProcessJALetter^^be}\gdef^^af{\lst@ProcessJALetter^^bf}%
    }}%\message{\meaning\@temp}%
  }%
  \@temptokena\expandafter\expandafter\expandafter\expandafter%
  \expandafter\expandafter\expandafter{\expandafter\expandafter%
  \expandafter\the\expandafter\@temptokena\@temp}%
}
\gdef\ltj@@listing@jpsetN@#1{{%
    \lccode`\~=\@tempcnta \lccode`\/=\@tempcnta
    \lowercase{\gdef\@temp{\gdef~{#1/}}}}%
  \@temptokena\expandafter\expandafter\expandafter\expandafter%
  \expandafter\expandafter\expandafter{\expandafter\expandafter%
  \expandafter\the\expandafter\@temptokena\@temp}%
}
\endgroup


\toks@{}
\input lltjp-listings-jpt.tex
\edef\ltj@@listing@jpcmd{\the\toks@}
\toks@{}
\lst@AddToHook{Init}{%
  \luatexcatcodetable\CatcodeTableLTJlistings
  \ltj@@listing@jpcmd}


% 白線対策
\def\lst@OutputToken{%
    \lst@TrackNewLines \lst@OutputLostSpace
    \lst@ifgobbledws
        \lst@gobbledwhitespacefalse
        \lst@@discretionary
    \fi
    \lst@CheckMerge
    {\lst@thestyle{\lst@FontAdjust
     \setbox\@tempboxa\lst@hbox
        {\lsthk@OutputBox
         \lst@lefthss
         \expandafter\lst@FillOutputBox\the\lst@token\@empty
         \lst@righthss}%
     \ht\@tempboxa=0pt\dp\@tempboxa=0pt
     \lst@CalcLostSpaceAndOutput}}%
    \lst@ResetToken}


%    \begin{修正事項}{1.3} from jlisting.sty
% ちょっとした修正
\gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
% ソースコード目次における文字と番号の空き
\let \l@lstlisting = \l@figure
% キャプションとソースコード目次に対する日本語対応
\def\lstlistingname{ソースコード}
\def\lstlistlistingname{ソースコード目次}
%    \end{修正事項}
\endinput