4 % Modified from jlisting.sty (by Thor) for LuaTeX-ja.
7 \NeedsTeXFormat{LaTeX2e}
8 \def\filedate{2006/02/20}
10 \ProvidesPackage{lltjp-listings}[\filedate\space\fileversion\space(Thor)]
11 \RequirePackage{listings}
12 \newcount\lst@nextchar
13 \let\lst@@ProcessSpace\lst@ProcessSpace
14 \def\lst@ProcessSpace#1{%
15 \lst@check@chartype{#1}%
18 \let\lst@@ProcessLetter\lst@ProcessLetter
19 \def\lst@ProcessLetter#1#2{%
20 \lst@check@chartype{#2}%
21 {\lst@@ProcessLetter{#1}}%
23 \let\lst@@ProcessDigit\lst@ProcessDigit
24 \def\lst@ProcessDigit#1#2{%
25 \lst@check@chartype{#2}%
26 {\lst@@ProcessDigit{#1}}%
28 \let\lst@@ProcessOther\lst@ProcessOther
29 \def\lst@ProcessOther#1#2{%
30 \lst@check@chartype{#2}%
31 {\lst@@ProcessOther{#1}}%
33 \let\lst@@ProcessTabulator\lst@ProcessTabulator
34 \def\lst@ProcessTabulator#1{%
35 \lst@check@chartype{#1}%
36 \lst@@ProcessTabulator
38 \def\lst@check@chartype#1#2#3{%
39 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
40 \afterassignment\remove@to@nnil
43 \ifnum\lst@nextchar<\@cclvi
46 \lst@ifletter \else \lst@OutputOther \fi
48 \expandafter\lst@AppendJchar
51 \def\lst@AppendJchar#1#2{%
52 \lst@check@chartype{#2}%
53 {\advance\lst@length\@ne\lst@Append{#1}}%
55 \def\lst@check@chartype@BOL#1{%
56 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
57 \afterassignment\remove@to@nnil
59 \ifnum\lst@nextchar<\@cclvi\else
61 \expandafter\lst@AppendJchar
64 \def\lst@InputListing#1{%
66 \lsthk@PreSet \gdef\lst@intname{#1}%
67 \expandafter\lstset\expandafter{\lst@set}%
69 \catcode\active=\active
70 \lst@Init\relax \let\lst@gobble\z@
72 \lst@ifprint \def\lst@next{\lst@get@filecontents{#1}}%
73 \else \let\lst@next\@empty
79 \newread\lst@inputfile
80 \def\lst@get@filecontents#1{%
81 \let\lst@filecontents\@empty
82 \openin\lst@inputfile=#1\relax
83 \let\@lst@get@filecontents@prevline\relax
84 \lst@get@filecontents@loop
85 \closein\lst@inputfile
86 \lst@filecontents\empty}
87 \def\lst@get@filecontents@loop{%
88 \read\lst@inputfile to\@lst@get@filecontents@currline
89 \ifx\@lst@get@filecontents@prevline\relax\else
90 \expandafter\expandafter\expandafter\def
91 \expandafter\expandafter\expandafter\lst@filecontents
92 \expandafter\expandafter\expandafter{%
93 \expandafter\lst@filecontents\@lst@get@filecontents@prevline}%
95 \let\@lst@get@filecontents@prevline\@lst@get@filecontents@currline
96 \ifeof\lst@inputfile\else
97 \expandafter\lst@get@filecontents@loop
101 \ifnum\lst@gobble>\z@
102 \@tempcnta\lst@gobble\relax
103 \expandafter\lst@BOLGobble@
105 \expandafter\lst@check@chartype@BOL
107 \def\lst@BOLGobble@#1{%
109 \ifx \lst@next\relax\else
110 \ifx \lst@next\lst@MProcessListing\else
111 \ifx \lst@next\lst@ProcessFormFeed\else
112 \ifx \lst@next\lstenv@backslash
113 \let\lst@next\lstenv@BOLGobble@@
115 \let\lst@next\lst@BOLGobble@@
116 \ifx #1\lst@ProcessTabulator
117 \advance\@tempcnta-\lst@tabsize\relax
119 \lst@length-\@tempcnta \lst@PreGotoTabStop
122 \edef\@tempa{\lst@nextchar=`\string#1\relax}%
124 \ifnum\lst@nextchar<\@cclvi\else
125 \advance\@tempcnta\m@ne
127 \advance\@tempcnta\m@ne
131 \def\lst@BOLGobble@@{%
133 \expandafter\lst@BOLGobble@
135 \expandafter\lst@check@chartype@BOL
142 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}
143 % ソースコード目次における文字と番号の空き
144 \let \l@lstlisting = \l@figure
145 % キャプションとソースコード目次に対する日本語対応
146 \def\lstlistingname{ソースコード}
147 \def\lstlistlistingname{ソースコード目次}
151 % Changes for LuaTeX-ja:
152 % 1. \char"FFFFF は通常行末用コメント文字として使われる.
153 % だが,それはソースコードの組版には邪魔ものとなる.
154 %\lst@AddToHook{Init}{\catcode"FFFFF=9 }
155 %\lst@AddToHook{DeInit}{\catcode"FFFFF=14 }
158 % 2. listing な環境の処理中に \DeclareFontShape の (s)sub が実行されると,なぜか
159 % ! Use of set@size@funct@args@ doesn't match its definition.
161 % \ifnot@nil #1-> \def\reserved@a{#1}... の \reserved@a=\set@size@funct@args@
163 % ad hoc な対策として事前に必要な (s)sub は実行しておくことにする.
164 \lst@AddToHook{Init}{\begingroup\itshape\bfseries\upshape\endgroup}