OSDN Git Service

Forgot to commit lltjp-listings.sty
[luatex-ja/luatexja.git] / src / patches / lltjp-listings.sty
index 253bf5b..ee3c3aa 100644 (file)
@@ -1,10 +1,9 @@
 %
-% lltjp-listings.sty
+% lltjp-listings.sty 2020-03-23
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-listings}[2016/03/02 Patch to listings for LuaTeX-ja]
-\RequirePackage{listings,luatexbase-cctb}
+\RequirePackage{etoolbox,listings,luatexbase-cctb}
 
 %%%%%%%%%%%%%%%% Japanese support
 %% whether letter-space in a fixed mode box is doubled or not
 % override \lst@FillFixed@
 % \ltj@hst@hss is \ltj@lst@hss@ivs or \ltj@lst@hss@normal,
 % according to vsraw = true or not.
+\def\lst@FillFixed#1{{\null#1\null}\lst@FillFixed@}
 \def\lst@FillFixed@#1{%
-  \ifx\@empty#1\else\ltj@lst@hss#1\expandafter\lst@FillFixed@\fi}
+  \ifx\@empty#1\else\ltj@lst@hss{\null#1\null}\expandafter\lst@FillFixed@\fi}
+\let\lst@FillOutputBox\lst@FillFixed
+% [space/full]flexiblemode (not much useful...)
+\def\ltj@lst@FillFlex#1\@empty{\null#1\null}
+\patchcmd\lst@column@flexible
+  {\let\lst@FillOutputBox\@empty}{\let\lst@FillOutputBox\ltj@lst@FillFlex}{}{}
+\patchcmd\lst@column@fullflexible
+  {\let\lst@FillOutputBox\@empty}{\let\lst@FillOutputBox\ltj@lst@FillFlex}{}{}
+\patchcmd\lst@column@spaceflexible
+  {\let\lst@FillOutputBox\@empty}{\let\lst@FillOutputBox\ltj@lst@FillFlex}{}{}
+
 
 \directlua{
   local cat_str = luatexbase.catcodetables['string']
   \else
     \ltj@lst@setletterflag
   \fi
-  \lst@Append#1}
+  \lst@Append#1%
+}
 
 % 半角カナ処理命令
 \def\ltj@lst@ProcessJALetterHalf#1{%
   \expandafter\expandafter\expandafter\lst@InsideConvert%
   \expandafter{\the\@temptokena}\lst@arg\lst@DeInit\egroup}
 
+%%%%%%%%%%%%%%%% \lstMakeShortInline
+\patchcmd\lstMakeShortInline@{\lst@shortinlinedef#1}{\lst@shortinlinedef~}{}{}
+
 % We redefine \lst@BeginDropInput, since now we have
 % two additional `process macros'.
 \def\lst@BeginDropInput#1{%
          #3\catcode\ltjlineendcomment=9\lst@escapebegin\expandafter\lst@next%"
          \fi}%
         {}}
+\def\ltj@lst@emptygrp{{}}
 \def\ltj@lst@escape@setup#1{%
   \begingroup\lccode`\~=`#1\lowercase{%
   \gdef\lst@next##1~{%
      \let\lst@arg\@empty\ltj@lst@remove@jacmd{##1}%
-     \expandafter\expandafter\expandafter\scantokens\expandafter{\lst@arg}%
+     \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
+          \scantokens\expandafter\expandafter\expandafter{\expandafter\ltj@lst@emptygrp\lst@arg\empty}%
      ~}%
   }\endgroup
 }
     \fi}}
 \endgroup
 
+%%%%%%%%%%%%%%%% texcl
+\lst@AddToHook{AfterBeginComment}
+   {\ifnum\lst@mode=\lst@TeXLmode
+      \catcode`\^^M=13\relax
+      \catcode\ltjlineendcomment=9\relax
+    \fi}
+
 %%%%%%%%%%%%%%%%
 \lstloadaspects{writefile}
 \begingroup \catcode`\^^I=11
     \fi}
 \endgroup
 
-
 %    \begin{修正事項}{1.3} from jlisting.sty
 % ちょっとした修正
 \gdef\lst@breakProcessOther#1{\lst@ProcessOther#1}