diff options
author | Karl Berry <karl@freefriends.org> | 2015-05-15 21:47:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-05-15 21:47:05 +0000 |
commit | ff006c2d366e4f0f3503a131959ab1ae04ea5e5f (patch) | |
tree | 5bd1fb5973b570c58af7743d199882d28b2a17fd /Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty | |
parent | da5eaf8777934443b5a33ff8ed1d8c195c1e3034 (diff) |
xecjk (15may15)
git-svn-id: svn://tug.org/texlive/trunk@37409 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty | 106 |
1 files changed, 64 insertions, 42 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty index e8f62332b2f..2ff396c76be 100644 --- a/Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty +++ b/Master/texmf-dist/tex/xelatex/xecjk/xeCJK-listings.sty @@ -6,8 +6,6 @@ %% %% xeCJK.dtx (with options: `listings') %% -%% $Id: xeCJK.dtx 750 2014-12-26 08:13:35Z sobenlee@gmail.com $ -%% $URL: https://ctex-kit.googlecode.com/svn/trunk/xeCJK/xeCJK.dtx $ %% ----------------------------------------------------------------- %% Author: %% Wenchang Sun <sunwch@nankai.edu.cn> @@ -15,9 +13,9 @@ %% Leo Liu <leoliu.pku@gmail.com> %% Qing Lee <sobenlee@gmail.com> %% -%% Copyright (C) 2007--2014 Wenchang Sun -%% (C) 2009--2014 Leo Liu -%% (C) 2012--2014 Qing Lee +%% Copyright (C) 2007--2015 Wenchang Sun +%% (C) 2009--2015 Leo Liu +%% (C) 2012--2015 Qing Lee %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -33,11 +31,11 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: xeCJK.dtx 750 2014-12-26 08:13:35Z sobenlee@gmail.com $ +\GetIdInfo$Id: xeCJK.dtx 7321d12 2015-05-15 23:07:58 +0800 Qing Lee <sobenlee@gmail.com> $ {xeCJK patch file for listings} \ProvidesExplPackage {xeCJK-listings} - {\ExplFileDate}{3.3.0}{\ExplFileDescription} + {\ExplFileDate}{3.3.2}{\ExplFileDescription} \DeclareOption* { \PassOptionsToPackage { \CurrentOption } { xeCJK } } \ProcessOptions \scan_stop: \RequirePackage { xeCJK } @@ -48,47 +46,58 @@ { \tl_set_eq:NN \l_xeCJK_punct_style_tl \c__xeCJK_punct_style_plain_tl \l__xeCJK_restore_listings_toks_tl - \__xeCJK_listings_output_IVS: + \__xeCJK_listings_output_CM: } \lst@AddToHook { PreSet } { \bool_set_true:N \l__xeCJK_listings_env_bool } \cs_new_protected_nopar:Npn \__xeCJK_listings_initial_hook: { \tex_noindent:D - \bool_gset_false:N \g__xeCJK_listings_IVS_bool + \bool_gset_false:N \g__xeCJK_listings_CM_bool \tl_put_left:Nn \lst@numberstyle { \l__xeCJK_restore_listings_toks_tl } \xeCJK_add_to_shipout:n { \l__xeCJK_restore_listings_toks_tl } \lst@ifbreaklines \cs_set_eq:NN \__xeCJK_listings_CJK_toks_hook: \__xeCJK_listings_breaklines_toks: + \tl_if_empty:NF \lst@prebreak + { \tl_put_left:Nn \lst@prebreak { \l__xeCJK_restore_listings_toks_tl } } + \tl_if_empty:NF \lst@postbreak + { \tl_put_left:Nn \lst@postbreak { \l__xeCJK_restore_listings_toks_tl } } \fi: + \int_set:Nn \l__xeCJK_listings_max_char_int + { \lst@ifec 255 \else: 127 \fi: } } +\int_new:N \l__xeCJK_listings_max_char_int \cs_new_protected_nopar:Npn \__xeCJK_listings_toks_hook: { - \tl_set:Nx \l__xeCJK_restore_listings_toks_tl + \tl_clear:N \l__xeCJK_restore_listings_toks_tl + \seq_map_function:NN + \g__xeCJK_class_seq \__xeCJK_backup_inter_class_toks:n + \seq_map_inline:Nn \g__xeCJK_non_CJK_class_seq { - \__xeCJK_backup_inter_class_toks:nn { Boundary } { Default } - \__xeCJK_backup_inter_class_toks:nn { Boundary } { CJK } - \__xeCJK_backup_inter_class_toks:nn { Boundary } { IVS } - \__xeCJK_backup_inter_class_toks:nn { Boundary } { HangulJamo } - \__xeCJK_backup_inter_class_toks:nn { Boundary } { FullLeft } - \__xeCJK_backup_inter_class_toks:nn { Boundary } { FullRight } - } - \seq_map_inline:Nn \g__xeCJK_CJK_sub_class_seq - { - \tl_put_right:Nx \l__xeCJK_restore_listings_toks_tl - { \__xeCJK_backup_inter_class_toks:nn { Boundary } { CJK/##1 } } + \str_if_eq:nnF { ##1 } { Boundary } + { + \xeCJK_inter_class_toks:nnn { Boundary } { ##1 } + { \__xeCJK_listings_process_Default:nN { ##1 } } + } } - \xeCJK_inter_class_toks:nnn { Boundary } { Default } - { \__xeCJK_listings_process_Default:N } - \xeCJK_inter_class_toks:nnn { Boundary } { IVS } - { \__xeCJK_listings_process_IVS:nN { \c_zero } } + \xeCJK_inter_class_toks:nnn { Boundary } { CM } + { \__xeCJK_listings_process_CM:nN { \c_zero } } \__xeCJK_listings_CJK_toks_hook: } -\tl_new:N \l__xeCJK_restore_listings_toks_tl -\cs_new_nopar:Npn \__xeCJK_backup_inter_class_toks:nn #1#2 +\cs_new_protected_nopar:Npn \__xeCJK_backup_inter_class_toks:n #1 { - \xeCJK_inter_class_toks:nnn {#1} {#2} - { \xeCJK_get_inter_class_toks:nn {#1} {#2} } + \tl_set:Nx \l__xeCJK_tmp_tl + { \xeCJK_get_inter_class_toks:nn { Boundary } {#1} } + \tl_put_right:Nx \l__xeCJK_restore_listings_toks_tl + { + \xeCJK_inter_class_toks:nnn { Boundary } {#1} + { + \tl_if_empty:NTF \l__xeCJK_tmp_tl + { \exp_not:N \prg_do_nothing: } + { \exp_not:o \l__xeCJK_tmp_tl } + } + } } +\tl_new:N \l__xeCJK_restore_listings_toks_tl \cs_new_protected_nopar:Npn \__xeCJK_listings_CJK_toks_hook: { \xeCJK_inter_class_toks:nnn { Boundary } { CJK } @@ -121,11 +130,24 @@ { \__xeCJK_listings_process_breaklines_CJK:nN { \c_two } } } } -\cs_new_protected_nopar:Npn \__xeCJK_listings_process_Default:N #1 +\cs_new_protected_nopar:Npn \__xeCJK_listings_process_Default:nN #1#2 + { + \int_compare:nNnTF + { \xeCJK_token_value_charcode:N #2 } > \l__xeCJK_listings_max_char_int + { + \token_if_letter:NTF #2 + { \lst@ProcessLetter #2 } + { \lst@ProcessOther #2 } + } + { \__xeCJK_listings_output_Default:nN {#1} #2 } + } +\cs_new_protected_nopar:Npn \__xeCJK_listings_output_Default:nN #1#2 { - \token_if_letter:NTF #1 - { \lst@ProcessLetter #1 } - { \lst@ProcessOther #1 } + \group_begin: + \xeCJK_clear_inter_class_toks:nn { Boundary } {#1} + \xeCJK_inter_class_toks:nnn {#1} { Boundary } { \group_end: } + #2 + \scan_stop: } \cs_new_protected_nopar:Npn \__xeCJK_listings_process_CJK:nN #1#2 { @@ -240,25 +262,25 @@ \lst@ifbreaklines \int_zero:N \l__xeCJK_listings_flag_int \fi: \tex_futurelet:D \lst@lastother \lst@Append } -\cs_new_protected_nopar:Npn \__xeCJK_listings_process_IVS:nN +\cs_new_protected_nopar:Npn \__xeCJK_listings_process_CM:nN { \reverse_if:N \lst@ifflexible - \bool_gset_true:N \g__xeCJK_listings_IVS_bool + \bool_gset_true:N \g__xeCJK_listings_CM_bool \fi: \__xeCJK_listings_process_letter:nN } -\cs_new_protected_nopar:Npn \__xeCJK_listings_output_IVS: +\cs_new_protected_nopar:Npn \__xeCJK_listings_output_CM: { \reverse_if:N \lst@ifflexible - \bool_if:NT \g__xeCJK_listings_IVS_bool + \bool_if:NT \g__xeCJK_listings_CM_bool { - \bool_gset_false:N \g__xeCJK_listings_IVS_bool + \bool_gset_false:N \g__xeCJK_listings_CM_bool \xeCJK_cs_clear:N \lst@FillOutputBox \cs_set_eq:NN \CJKglue \tex_hss:D } \fi: } -\bool_new:N \g__xeCJK_listings_IVS_bool +\bool_new:N \g__xeCJK_listings_CM_bool \cs_new_protected:Npn \__xeCJK_listings_peek_active_loop:TF #1#2#3 { \token_if_active:NTF #3 @@ -267,7 +289,7 @@ \token_if_cs:NTF #3 { #2#3 } { - \int_compare:nNnTF { `#3 } > { \lst@ifec 255 \else: 127 \fi: } + \int_compare:nNnTF { `#3 } > { \l__xeCJK_listings_max_char_int } { \__xeCJK_listings_peek_active_loop:TF { #1#3 } { #2#3 } } { #2#3 } } @@ -284,7 +306,7 @@ \cs_new_protected_nopar:Npn \__xeCJK_listings_inline_group:w { \exp_after:wN \__xeCJK_listings_inline_group:n - \exp_after:wN { \if_false: } \fi: + \exp_after:wN { \if_int_compare:w `} = \c_zero \fi: } \cs_set_eq:NN \lst@InlineGJ \__xeCJK_listings_inline_group:w \cs_new_protected:Npn \__xeCJK_listings_inline_group:n #1 @@ -330,7 +352,7 @@ %% xeCJK-example-CJKfntef.tex, %% xeCJK-example-punctstyle.tex, %% xeCJK-example-verbatim.tex, -%% xeCJK-example-IVS.tex, +%% xeCJK-example-CM.tex, %% xeCJK-example-listings.tex, %% xunicode-symbols.tex, %% xunicode-commands.tex, |