diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/xassoccnt')
-rw-r--r-- | Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty | 881 |
1 files changed, 737 insertions, 144 deletions
diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty index db0ebec8c2f..63119ca1d62 100644 --- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty +++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty @@ -1,9 +1,9 @@ -%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05) +%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18) %% Source file for xassoccnt.sty %% %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de> +%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -19,22 +19,40 @@ %% %% -\def\xassoccntpackageversion{0.9} +\def\xassoccntpackageversion{1.0} \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{xassoccnt}[2016/06/19 - v\xassoccntpackageversion] -\RequirePackage{graphicx} +\ProvidesPackage{xassoccnt}[2016/07/28 - v\xassoccntpackageversion] \RequirePackage{xcolor} \RequirePackage{xparse} \RequirePackage{l3keys2e} + \ExplSyntaxOn +\newif\ifexplversionnew +\explversionnewfalse + +% Some variants of standard expl3 contributions + +\cs_generate_variant:Nn \seq_remove_all:Nn { cV, NV } +\cs_generate_variant:Nn \seq_gremove_all:Nn { cV, NV } +\cs_generate_variant:Nn \seq_gput_right:cn {cx}% +\cs_generate_variant:Nn \prop_put:Nnn {cxx} +\cs_generate_variant:Nn \prop_remove:Nn {cx,Nx} +\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx} +\cs_generate_variant:Nn \int_set:Nn {NV,Nx} + + % First some local or global values \bool_new:N \l__xassoccnt_hyperrefpackage_loaded_bool +\ifexplversionnew \str_const:Nn \c__xassoccnt_modulename_str {xassoccnt} +\else +\tl_const:Nn \c__xassoccnt_modulename_str {xassoccnt} % Only a wrapper +\fi \bool_new:N \l__xassoccnt_calcpackage_loaded @@ -102,6 +120,15 @@ } +\prop_new:N \g_xassoccnt_module_data_prop + +\prop_put:Nnn \g_xassoccnt_module_data_prop {scratchname} {scratch} +\prop_put:Nnn \g_xassoccnt_module_data_prop {backupfeaturename} {backupcounters} + +\cs_new:Nn \xassoccnt_extract_moduledata:n {% + \prop_item:Nn \g_xassoccnt_module_data_prop {#1} +} + \keys_define:nn {xassoccnt} { @@ -168,7 +195,6 @@ resetbackup .bool_set:N={\l__xassoccnt_resetbackupcounters_bool }, -% resetperiodic .bool_set:N={ \l_xassoccnt_resetperiodiccounters_bool } } \keys_define:nn {xassoccnt_periodiccounter} {% @@ -176,6 +202,17 @@ wrap .bool_set:N={ \l_xassoccnt_wrapperiodiccounters_bool } } + +\cs_new:Nn \generate_unique_countergroup_value:n {% + \seq_set_from_clist:Nn \l_tmpa_seq {#1} + \tl_clear:N \l_tmpa_tl% + \seq_map_inline:Nn \l_tmpa_seq {% + \tl_put_right:Nn \l_tmpa_tl {\use:c{the##1}:}% + }% + \prop_put:NnV \g_xassoccnt_module_data_prop {currentid} {\l_tmpa_tl} +} + + \keys_set:nn{xassoccnt}{nonumberofruns} \ProcessKeysOptions{xassoccnt} @@ -214,6 +251,9 @@ ---~#1~--- } + + + \msg_new:nnn{xassoccnt}{clearcoupledcountergroupundefined}{% Warning:~There~is~no~coupled~counter~group~named~#2~\\ The~clearing~operation~is~ignored!\\ @@ -228,14 +268,52 @@ } +\msg_new:nnn{xassoccnt}{emptybackupcountergroup}{% + Warning:~The~backup~counter~group~name~is~empty!\\ + Using~the~default~name:~"\xassoccnt_extract_moduledata:n{scratchname}"!\\ + ---~#1~--- +} + + +\msg_new:nnn{xassoccnt}{addbackupcountergroupundefined}{% + Warning:~There~is~no~backup~counter~group~named~#2~\\ + The~addition~operation~is~ignored!\\ + ---~#1~--- +} + +\msg_new:nnn{xassoccnt}{backupcountergroupundefined}{% + Warning:~There~is~no~backup~counter~group~named~#2~\\ + The~restore~operation~is~ignored!\\ + ---~#1~--- +} + + +\msg_new:nnn{xassoccnt}{restorebackupcountergroupundefined}{% + Warning:~There~is~no~backup~counter~group~named~#2~\\ + The~restoring~operation~is~ignored!\\ + ---~#1~--- +} + +\msg_new:nnn{xassoccnt}{nobackupid}{% + Error:~Backup~ID~for~group~"#1"~not~given!\\ + ---~#2~--- +} + +\msg_new:nnn{xassoccnt}{norestoreid}{% + Error:~Restore~ID~for~group~"#1"~not~given!\\ + ---~#2~--- +} +\msg_new:nnn{xassoccnt}{duplicatebackupid}{% + Error:~Backup~ID~"#1"~for~group~"#2"~is~already~defined!\\ + ---~#3~--- +} \msg_new:nnn{xassoccnt}{backupcollectionundefined}{% Error:~Backup~collection~#1~not~defined\\ Use~\DeclareBackupCollection~to~define~the~collection } - \msg_new:nnn{xassoccnt}{incompatiblepackagenonfatal}{% Warning:~Package~"#1"~is~loaded~--~this~is~not~recommended~for~\c__xassoccnt_modulename_str\\ } @@ -270,6 +348,98 @@ } + +\cs_new:Nn \xassoccnt_bootstrap_fullreset_list:n {% + \begingroup + \def\@elt##1{\seq_gput_right:cn {#1_fullresetlist_seq} {##1}} + \use:c{cl@#1} + \endgroup +} + +\cs_new:Nn \xassoccnt_local_list:nn {% + \begingroup + \def\@elt##1{\seq_gput_right:cn {#1} {##1}} + \use:c{cl@#2} + \endgroup +} + + +\cs_new:Nn \xassoccnt_full_reset_list_recursive:nn { + \seq_clear:N \l_tmpa_seq + \xassoccnt_local_list:nn {l_tmpa_seq} {#2} + \seq_map_inline:Nn \l_tmpa_seq {% + \seq_gput_right:cn {#1_fullresetlist_seq} {##1}% + \seq_remove_duplicates:c {#1_fullresetlist_seq } % Remove the duplicates + \xassoccnt_full_reset_list_recursive:nn {#1} {##1}% Recursive call + } +} + + +\cs_new:Nn \__xassoccnt_get_full_reset_list:n{% + \cs_if_exist:cTF {c@#1} {% + \seq_if_exist:cTF {#1_fullresetlist_seq} {% + \seq_gclear:c {#1_fullresetlist_seq} + }{% + \seq_new:c {#1_fullresetlist_seq}% + }% + \xassoccnt_bootstrap_fullreset_list:n {#1} + \seq_map_inline:cn {#1_fullresetlist_seq} {% + \xassoccnt_full_reset_list_recursive:nn {#1}{##1}% + }% + }{% + \msg_fatal:nnn{xassoccnt}{nameisnocounter}{#1}% + }% +} + + +\NewDocumentCommand{\CounterFullResetList}{m}{% + \__xassoccnt_get_full_reset_list:n{#1}% +} + + + +\NewDocumentCommand{\RemoveFromReset}{mm}{% + \xassoccnt_local_list:nn {l_tmpa_seq} {#2} + \seq_set_from_clist:Nn \l_tmpb_seq {#1} + \seq_map_inline:Nn \l_tmpb_seq {% + \seq_remove_all:Nn \l_tmpa_seq {##1}% + }% + \expandafter\xdef\csname cl@#2\endcsname{\empty}% + \seq_map_inline:Nn \l_tmpa_seq {% + \@addtoreset{##1}{#2}% + } +} + +\NewDocumentCommand{\RemoveFromFullReset}{mm}{% + \__xassoccnt_get_full_reset_list:n{#2}% + \seq_set_from_clist:Nn \l_tmpb_seq {#1} + \seq_map_inline:Nn \l_tmpb_seq {% + \__xassoccnt_get_full_reset_list:n{##1}% + \seq_map_inline:cn {##1_fullresetlist_seq } {% + \seq_gremove_all:cn {#2_fullresetlist_seq} {####1}% + } + \seq_gremove_all:cn {#2_fullresetlist_seq} {##1}% + }% + \expandafter\xdef\csname cl@#2\endcsname{\empty}% + \seq_map_inline:cn {#2_fullresetlist_seq} {% + \@addtoreset{##1}{#2}% + }% +} + +\NewDocumentCommand{\AddToReset}{mm}{% + \__xassoccnt_latexcounter_exists:nTF {#2} { + \seq_set_from_clist:Nn \l_tmpa_seq {#1} + \seq_map_inline:Nn \l_tmpa_seq {% + \@addtoreset{##1}{#2}% + } + }{% + \msg_fatal:nnn{xassoccnt}{nameisnocounter}{#1}% + }% +} + +%%%% The original counter related routines! + + \cs_set_eq:NN \xassoccnt_standardstepcounter \stepcounter \cs_set_eq:NN \xassoccnt_standardrefstepcounter \refstepcounter \cs_set_eq:NN \xassoccnt_standardaddtocounter \addtocounter @@ -295,7 +465,7 @@ }{} \AtEndOfPackage{ - \PackageInfo{xassoccnt}{2016/06/19 - v\xassoccntpackageversion -- stepping counters simultaneously and other features} + \PackageInfo{xassoccnt}{2016/07/28 - v\xassoccntpackageversion -- stepping counters simultaneously and other features} \@ifpackageloaded{calc}{% \msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{calc}% Warning \bool_set_true:N \l__xassoccnt_calcpackage_loaded @@ -328,19 +498,30 @@ g_xassoccnt_#1cnt_seq% } +\clist_new:N \__g_xassoccnt_countercontainer_clist + +\ifexplversionnew + \str_const:Nn \c_xassoccnt_undefined_str {undefined} \str_const:Nn \c_xassoccnt_mastername_str {master} \str_const:Nn \c_xassoccnt_associatedname_str {associated} \str_const:Nn \c_xassoccnt_suspendedname_str {suspended} -\clist_new:N \__g_xassoccnt_countercontainer_clist -\clist_set:Nn \__g_xassoccnt_countercontainer_clist {% +\else +\tl_const:Nn \c_xassoccnt_mastername_str {master}% +\tl_const:Nn \c_xassoccnt_associatedname_str {associated}% +\tl_const:Nn \c_xassoccnt_suspendedname_str {suspended}% +\tl_const:Nn \c_xassoccnt_undefined_str {undefined}% +\fi + +\clist_gset:Nn \__g_xassoccnt_countercontainer_clist {% \c_xassoccnt_undefined_str, \c_xassoccnt_mastername_str, \c_xassoccnt_associatedname_str, \c_xassoccnt_suspendedname_str } + % Now generate the containers and the accessing functions \clist_map_function:NN \__g_xassoccnt_countercontainer_clist \xassoccnt_counter_container:n @@ -504,11 +685,13 @@ }% } + +\ifexplversionnew \cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{% \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1} - \str_set:Nx \l_tmpa_str {#3} + \str_set:Nx \l_tmpa_str {#3}% \__xassoccnt_latexcounter_exists:nTF{#2}{% - \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{ + \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{% \msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning } }{% @@ -517,10 +700,27 @@ }{% \newcounter{#2}[#3]% }% + \xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}% + } +} +\else +\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{% + \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1} + \tl_set:Nx \l_tmpa_tl {#3} + \__xassoccnt_latexcounter_exists:nTF{#2}{% + \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{ + \msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning + } + }{% + \tl_if_empty:NTF \l_tmpa_tl {% + \newcounter{#2}% + }{% + \newcounter{#2}[#3]% + }% \xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int} } } - +\fi @@ -863,12 +1063,11 @@ } -%%% - - %% More generic macros (hidding the internal features of the lists) +\prop_new:N \g_xassoccnt_feature_prop + \cs_new_nopar:Nn \xassoccnt_container_property: {prop} \cs_new_nopar:Nn \xassoccnt_container_datatype: {seq} @@ -961,7 +1160,7 @@ \cs_new:Nn \xassoccnt_container_remove_by_clist:Nn {% \clist_set:Nn \l_tmpa_tl {#2} - \clist_map_inline:Nn \l_tmpa_tl { + \clist_map_inline:Nn \l_tmpa_tl {% \xassoccnt_container_remove_all:Nn #1 {##1} } } @@ -988,7 +1187,6 @@ \prg_new_conditional:Nnn \xassoccnt_container_if_exist:N {TF,T,F}% { -% \__xassoccnt_construct_cs:n{_if_exist:NTF} #1 \seq_if_exist:NTF #1 {\prg_return_true:} {\prg_return_false:} @@ -996,7 +1194,6 @@ \prg_new_conditional:Nnn \xassoccnt_container_if_exist:c {TF,T,F}% { -% \__xassoccnt_construct_cs:n{_if_exist:NTF} #1 \seq_if_exist:cTF {#1} {\prg_return_true:} {\prg_return_false:} @@ -1006,7 +1203,6 @@ \prg_new_conditional:Nnn \xassoccnt_container_if_in:Nn {TF,T,F}% { - % \seq_if_in:NnTF #1 {#2} \__xassoccnt_construct_cs:n{_if_in:NnTF} #1 {#2} {\prg_return_true:} {\prg_return_false:} @@ -1074,14 +1270,42 @@ \bool_new:N \l__xassoccnt_feature_bool \bool_new:N \l__xassoccnt_sublists_bool +\bool_new:N \xassoccnt_cascading_bool + +\bool_new:N \xassoccnt_keep_after_restore_bool + +\tl_new:N \__xassoccnt_featurename_tl + +\tl_new:N \__xassoccnt_backup_id_tl +\tl_new:N \__xassoccnt_restore_id_tl + +\cs_new_nopar:Nn \xassoccnt_featurename_prop:{% + xassoccnt_feature_\__xassoccnt_featurename_tl _prop% +} + +\cs_new:Nn \xassoccnt_feature_prop_setkey:nn {% + \prop_gput:cnn {\xassoccnt_featurename_prop:} {#1} {#2}% +} + \keys_define:nn {xassoccnt_container} { feature .bool_set:N=\l__xassoccnt_feature_bool, sublists .bool_set:N=\l__xassoccnt_sublists_bool, name .tl_set:N=\l__xassoccnt_countergroup_name_tl, + multiple .bool_set:N=\l__xassoccnt_multiple_bool, - featurename .tl_set:N=\l__xassoccnt_feature_name_tl + featurename .tl_set:N=\l__xassoccnt_feature_name_tl, + .code:n={ \xassoccnt_feature_prop_setkey:nn{featurename}{##1}}, + publicname .code:n={\xassoccnt_feature_prop_setkey:nn{publicname}{##1}}, + cascading .bool_set:N={\xassoccnt_cascading_bool}, + resetbackup .bool_set:N={ \l__xassoccnt_resetbackupcounters_bool }, + backup-id .tl_set:N={ \__xassoccnt_backup_id_tl }, + restore-id .tl_set:N={ \__xassoccnt_restore_id_tl }, + keep-after-restore .bool_set:N= {\xassoccnt_keep_after_restore_bool } } + + + \seq_new:N \g__xassoccnt_feature_seq % The master control !!!! \seq_new:N \g__xassoccnt_sublists_seq @@ -1102,6 +1326,8 @@ %% Multiple counters may occur in the per - feature - specific container list \cs_new:Nn \xassoccnt_add_feature:nn {% + \tl_set:Nn \__xassoccnt_featurename_tl {#2}% + \prop_clear_new:c {\xassoccnt_featurename_prop:}% \keys_set:nn {xassoccnt_container} {#1} \seq_if_exist:NT \g__xassoccnt_feature_seq {% Unique addition of a feature only! \seq_if_in:NnF \g__xassoccnt_feature_seq {#2} {% @@ -1177,14 +1403,13 @@ \cs_new:Nn \xassoccnt_feature_add_to_subcontainer:nnn {% \keys_set:nn{xassoccnt_container} {multiple=false,#1} \clist_set:Nx \l_tmpa_clist {#3} - \clist_map_inline:Nn \l_tmpa_clist {% \xassoccnt_container_if_in:cnTF {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1} {% \bool_if:NT \l__xassoccnt_multiple_bool {% Add only if `multiple=true` was specified \xassoccnt_container_put_right:cn {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1} } - }{ % + }{% \xassoccnt_container_put_right:cn {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1} } } % End of map_inline @@ -1216,17 +1441,461 @@ \xassoccnt_remove_feature:nn {#1} {#2} } +\NewDocumentCommand{\NewContainer}{m}{% + \xassoccnt_create_container:nc {feature=false} {#1} +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% New Backup Counter features -\NewDocumentCommand{\NewContainer}{m}{% - \xassoccnt_create_container:nc {feature=false} {#1} + +\cs_new:Nn \xassoccnt_backup_id_seq:n {% + l_backupcounters_#1_id_seq% +} + +\cs_new:Nn \__xassoccnt_declare_countergroupname:nn {% + \xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{#1}{#2} } + {% + \xassoccnt_feature_add_to_group_container:nn{multiple=false,featurename=#1}{#2}% + \seq_new:c { l_#1_#2_id_seq}% + \prop_new:c { l_#1_#2_prop }% Setup a feature property sub list for values + } } +\cs_new:Nn \xassoccnt_declare_backupcountersgroupname:n {% + \xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{backupcounters}{#1} } + { + \prop_new:c { l_backupcounters_#1_prop } + \seq_new:c { \xassoccnt_backup_id_seq:n{#1}} % + \xassoccnt_feature_add_to_group_container:nn{multiple=false,featurename=backupcounters}{#1}% + } +} -\bool_new:N \l__xassoccnt_is_coupledcounter_bool + +\NewDocumentCommand{\DeclareBackupCountersGroupName}{m}{% + \__xassoccnt_declare_countergroupname:nn{backupcounters}{#1}% +} + +\cs_new:Nn \xassoccnt_assign_backupcounters_to_group:nn {% + \keys_set:nn {xassoccnt_container} {name={},multiple=false,#1} + \tl_if_empty:NT \l__xassoccnt_countergroup_name_tl {% + \msg_warning:nnn{xassoccnt}{emptybackupcountergroup}{xassoccnt_assign_backupcounters_to_group}{}% + \keys_set:nn {xassoccnt_container} {multiple=false,#1,name={\xassoccnt_extract_moduledata:n{scratchname}}} + } + % Check first if the counter group name is already registered + \xassoccnt_container_if_exist:cF { \xassoccnt_feature_subcontainer:nn{backupcounters}{\l__xassoccnt_countergroup_name_tl} } + {% + \xassoccnt_declare_backupcountersgroupname:n{\l__xassoccnt_countergroup_name_tl}% + }% + \xassoccnt_feature_add_to_subcontainer:nnn{multiple=false,#1,featurename=backupcounters}{\l__xassoccnt_countergroup_name_tl}{#2}% +} + + +% This macro assigns counters to a backup group% +\NewDocumentCommand{\AssignBackupCounters}{O{}m}{% + \keys_set:nn{xassoccnt_container} {#1} + \xassoccnt_assign_backupcounters_to_group:nn {#1}{#2}% + \bool_if:NTF \xassoccnt_cascading_bool {% + % Set the starter counter name to the list defined by `name=...` + \AddBackupCounters[#1]{#2}% + % Ok, let's get the all counters in the reset list of #2 + \CounterFullResetList{#2}% + \seq_if_empty:cF {#2_fullresetlist_seq} {% + \seq_map_inline:cn { #2_fullresetlist_seq} {\AddBackupCounters[#1]{##1} }% + }% + }{% + \AddBackupCounters[#1]{#2}% + } + +} +\NewDocumentCommand{\AddBackupCounters}{O{}m}{% + \keys_set:nn {xassoccnt_container} {multiple=false,#1} + \xassoccnt_container_if_exist:cTF { \xassoccnt_feature_subcontainer:nn{backupcounters}{\l__xassoccnt_countergroup_name_tl } } {% + \xassoccnt_feature_add_to_subcontainer:nnn{#1,featurename=backupcounters}{\l__xassoccnt_countergroup_name_tl}{#2}% + }{% + \msg_warning:nnxx{xassoccnt}{addbackupcountergroupundefined}{AddBackupCounters}{\l__xassoccnt_countergroup_name_tl}% Warning about undefined counter group + }% +} + + + +\bool_new:N \l__xassoccnt_is_backupcounter_bool + +\prg_new_conditional:Nnn \__xassoccnt_is_backupcounter:n {TF,T,F} {% + \xassoccnt_container_map_inline:cn { \xassoccnt_feature_group_container:n{backupcounters} } {% + \bool_set_false:N \l__xassoccnt_is_backupcounter_bool + \xassoccnt_container_if_in:cxT { \xassoccnt_feature_subcontainer:nn{backupcounters}{##1} } {#1} + { + \bool_set_true:N \l__xassoccnt_is_backupcounter_bool + \xassoccnt_container_map_break: + } + } + \bool_if:NTF \l__xassoccnt_is_backupcounter_bool + {\prg_return_true:} + {\prg_return_false:} +} + + + +\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nTF {c } +\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nT { c } +\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nF { c } + +\cs_new:Nn \xassoccnt_is_backupcounter:nTF { % + \__xassoccnt_is_backupcounter:nTF {#1} {#2} {#3} +} + +\cs_new:Nn \xassoccnt_is_backupcounter:nT { % + \__xassoccnt_is_backupcounter:nT {#1} {#2}% +} + +\cs_new:Nn \xassoccnt_is_backupcounter:nF { % + \__xassoccnt_is_backupcounter:nF {#1} {#2}% +} + + + +%%%% + +\cs_new:Nn \__xassoccnt_backup_renew_theHmacros:nn {% + \bool_if:NT \l__xassoccnt_hyperrefpackage_loaded_bool {% + \cs_if_exist:cT {theH#1} {% + \cs_gset_eq:cc {xassoccnt_#2_theH#1} {theH#1}% + \expandafter\renewcommand\csname theH#1\endcsname{xassoccnt.#1_#2.\use:c{the#1}}% + }% + } +} +\cs_new:Nn \__xassoccnt_backup_restore_theHmacros:nn {% + \bool_if:NT \l__xassoccnt_hyperrefpackage_loaded_bool {% + \cs_if_exist:cT {theH#1} {% + \expandafter\renewcommand\csname theH#1\endcsname{xassoccnt.#1_#2.\use:c{the#1}}% + }% + }% +} + + + + + +\cs_new:Nn \__xassoccnt_prepare_backupid:nn{% + #1#2 +} + +\cs_new:Nn \__xassoccnt_prepare_backupid:nnn{% + #1#2#3 +} + +\cs_new:Nn \xassoccnt_feature_subproplist:nn {% + l_#1_#2_prop% +} + + +\cs_new:Nn \xassoccnt_backup_subproplist:n {% + l_\xassoccnt_extract_moduledata:n{backupfeaturename}_#1_prop% +} + + + +\cs_new:Nn \xassoccnt_backupstore_property:cnn{% + \prop_gput:cnn {\xassoccnt_feature_subproplist:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#1}} { #2 } {#3}% Must be expanded +} + + + +\cs_generate_variant:Nn \xassoccnt_backup_subproplist:n {V} +\cs_generate_variant:Nn \xassoccnt_backupstore_property:cnn {cxx} % +\cs_generate_variant:Nn \__xassoccnt_backup_restore_theHmacros:nn {nx,cn,cx} + + +\NewDocumentCommand{\BackupCounterValues}{O{}m}{% + \keys_set:nn {xassoccnt_container} {backup-id={}, + restore_id={}, + resetbackup=true, + cascading=false, + multiple=false, + name={\xassoccnt_extract_moduledata:n {scratchname}}, + #1 + } + \tl_if_empty:NT \__xassoccnt_backup_id_tl {% + \msg_fatal:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error + } + \tl_if_empty:NT \__xassoccnt_restore_id_tl {% + \msg_fatal:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error + } + % Prevent multiple usages of the same backup id per counter group + \seq_if_in:cVTF {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}} { \__xassoccnt_backup_id_tl } {% + \msg_fatal:nnxxx{xassoccnt}{duplicatebackupid}{\__xassoccnt_backup_id_tl}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error + }{% + \seq_put_right:cV {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}} { \__xassoccnt_backup_id_tl }% + \seq_remove_duplicates:c {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}} + } + \bool_if:NTF \xassoccnt_cascading_bool {% + % Set the starter counter name to the list defined by `name=...` + \AddBackupCounters[#1]{#2}% + % Ok, let's get the all counters in the reset list of #2 + \CounterFullResetList{#2}% + \seq_if_empty:cF {#2_fullresetlist_seq} {% + \seq_map_inline:cn { #2_fullresetlist_seq} {\AddBackupCounters[#1]{##1} }% + }% + }{% + \AddBackupCounters[#1]{#2}% + } + \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{\l__xassoccnt_countergroup_name_tl }} {% + \xassoccnt_backupstore_property:cxx {\l_xassoccnt_countergroup_name_tl}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}} {\number\value{##1}}% Must be expanded! + \__xassoccnt_backup_renew_theHmacros:nn {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}% + \bool_if:NT \l__xassoccnt_resetbackupcounters_bool {% + \setcounter{##1}{\c_zero}% + } + }% +} + + +\NewDocumentCommand{\BackupCounterGroup}{O{}m}{% + \keys_set:nn {xassoccnt_container} {backup-id={}, + restore-id={}, + resetbackup=true, + cascading=false, + multiple=false, + name={}, + #1 + } + \tl_if_empty:NT \__xassoccnt_backup_id_tl {% + \msg_fatal:nnxx{xassoccnt}{nobackupid}{#2}{BackupCounterGroup}% Fatal Error + } + % Prevent multiple usages of the same backup id per counter group + \seq_if_in:cVTF {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl } {% + \msg_fatal:nnxxx{xassoccnt}{duplicatebackupid}{\__xassoccnt_backup_id_tl}{#2}{BackupCounterGroup}% Fatal Error + }{% + \seq_put_right:cV {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl }% + \seq_remove_duplicates:c {\xassoccnt_backup_id_seq:n{#2}} + } + \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {% + \xassoccnt_backupstore_property:cxx {#2}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}} {\number\value{##1}}% Must be expanded! + \__xassoccnt_backup_renew_theHmacros:nn {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}% + \bool_if:NT \l__xassoccnt_resetbackupcounters_bool {% + \setcounter{##1}{\c_zero}% + }% + }% +} + + + + +\NewDocumentCommand{\RestoreBackupCounterGroup}{O{}m}{% + \keys_set:nn {xassoccnt_container} {keep-after-restore=false,backup-id={},restore-id={},multiple=false,#1} + % + % Test whether counter group #2 exists: + \seq_if_in:cnTF {\xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}}} {#2} {% + \tl_if_empty:NT \__xassoccnt_backup_id_tl {% + \msg_error:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{RestoreBackupCounterGroup}% Fatal Error + }% + \tl_if_empty:NT \__xassoccnt_restore_id_tl {% + \tl_set_eq:NN \__xassoccnt_restore_id_tl \__xassoccnt_backup_id_tl + } + % Test first if the backup id is valid! + \seq_if_in:cVT {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl } {% + \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2 }} {% + \__xassoccnt_backup_restore_theHmacros:nx {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_restore_id_tl}}%\__xassoccnt_restore_id_tl}}% + \tl_set:Nx \l_tmpa_tl {\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}} + \int_set:Nx \l_tmpa_int {\prop_item:cV {\xassoccnt_backup_subproplist:n{#2} } {\l_tmpa_tl}}% + \setcounter{##1}{\int_use:N \l_tmpa_int}% + } + \bool_if:NF \xassoccnt_keep_after_restore_bool {% + \seq_gremove_all:cV {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl } + \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {% + \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}% + } + } + } + }{% + \msg_warning:nnxx{xassoccnt}{backupcountergroupundefined}{RestoreBackupCounterGroup}{#2}% Warning, rest is ignored! + }% +} + + +%%%% Clearing, removing counters from a group and deleting the counter group + + +\cs_new:Nn \xassoccnt_backup_removecounter_from_group:nnn {% + % Check whether the counter group #2 exists + \seq_set_from_clist:Nn \l_tmpa_seq {#3}% + \xassoccnt_container_if_in:cnT {\xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}}} {#2} {% + \seq_map_inline:Nn \l_tmpa_seq {% + % Remove the property value(s) connected with this counter! -> must loop over all backup-ids + \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2}} {% + \seq_map_inline:cn { \xassoccnt_backup_id_seq:n{#2} } {% + \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2}} {\__xassoccnt_prepare_backupid:nn{##1}{####1} } + }% + }% + % Remove the name ##1 from the counter group #2 + \xassoccnt_container_gremove_all:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {##1} + }% + }% +} + + + +\cs_new:Nn \xassoccnt_backup_clear_countergroup:nn {% + \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2}} {% + \seq_clear:c {\xassoccnt_backup_id_seq:n{#2}}% + \cs_undefine:c {\xassoccnt_backup_id_seq:n{#2}}% + } + % Delete the property list connected to the current counter group + \prop_clear:c { \xassoccnt_backup_subproplist:n{#2} } + % Remove the names from the counter group% + \xassoccnt_container_clear:c { \xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2} } +} + + +\cs_new:Nn \xassoccnt_backup_delete_countergroup:nn{% + \xassoccnt_backup_clear_countergroup:nn{#1}{#2}% + \xassoccnt_container_remove_all:cn {\xassoccnt_feature_group_container:n{backupcounters}}{#2}% +} + +\cs_new:Nn \__xassoccnt_backup_remove_prop_value:nn { + \prop_remove:Nn #1 {#2} +} + + + +\cs_new:Nn \xassoccnt_backup_clear_counterbackupstate:nnn {% + \xassoccnt_container_if_exist:cT { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} } + {% Is it a valid backup-id at all? -> check + \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2} } + {% + \seq_if_in:cVT { \xassoccnt_backup_id_seq:n{#2}} {#1} + {% + \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{#3}{#1} }% + }% + }% + }% +} + + +\cs_new:Nn \xassoccnt_backup_clear_backupstate:nn {% + \xassoccnt_container_if_exist:cT { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} } + {% Is it a valid backup-id at all? -> check + \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2} } + {% + \seq_if_in:cVT { \xassoccnt_backup_id_seq:n{#2}} {#1} + {% + \seq_map_inline:cn { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} } {% + \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{##1}{#1} } + }% + \seq_remove_all:cV { \xassoccnt_backup_id_seq:n{#2} } {#1}% + }% + }% + }% +} + + + +\NewDocumentCommand{\ClearCounterBackupState}{O{}mm}{% + \keys_set:nn {xassoccnt_container} {backup-id={},#1} + \xassoccnt_backup_clear_counterbackupstate:nnn {\__xassoccnt_backup_id_tl} { #2 } { #3 } +} + + +\NewDocumentCommand{\ClearBackupState}{O{}m}{% + \keys_set:nn {xassoccnt_container} {backup-id={},#1} + \xassoccnt_backup_clear_backupstate:nn { \__xassoccnt_backup_id_tl } {#2} + \prop_map_inline:cn {\xassoccnt_backup_subproplist:n{#2}} {##1->##2\par}% +} + + + +\NewDocumentCommand{\ClearBackupCounterGroups}{O{}m}{% + \seq_set_from_clist:Nn \l_tmpa_seq {#2}% + \seq_map_inline:Nn \l_tmpa_seq {% + \xassoccnt_backup_clear_countergroup:nn{#1}{##1}% + }% +} + +\NewDocumentCommand{\RemoveCountersFromBackupGroup}{O{}mm}{% + \xassoccnt_backup_removecounter_from_group:nnn {#1} {#2} {#3}% +} + +\NewDocumentCommand{\DeleteBackupCounterGroups}{O{}m}{% + \seq_set_from_clist:Nn \l_tmpa_seq {#2}% + \seq_map_inline:Nn \l_tmpa_seq {% + \xassoccnt_backup_delete_countergroup:nn {#1} {##1}% + }% +} + + + + +%%% Query routines + +\prg_new_conditional:Nnn \__xassoccnt_is_backupcountergroup:n {TF,T,F} {% + \xassoccnt_container_if_in:cnTF { \xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}} } {#1} + {\prg_return_true:} + {\prg_return_false:} +} + +\prg_new_conditional:Nnn \__xassoccnt_is_backupstate:nn {TF,T,F} {% + \xassoccnt_container_if_exist:cTF { \xassoccnt_feature_subcontainer:nn{backupcounters}{#1} } + {% Is it a valid backup-id at all? -> check + \seq_if_exist:cTF {\xassoccnt_backup_id_seq:n{#1} } + {% + \seq_if_in:cnTF { \xassoccnt_backup_id_seq:n{#1}} {#2} + {\prg_return_true:} + {\prg_return_false:} + }{\prg_return_false:} + }{\prg_return_false:} +} + + +\NewDocumentCommand{\IsBackupCounterGroupTF}{m+m+m}{% + \__xassoccnt_is_backupcountergroup:nTF {#1} {#2} {#3}% +} + +\NewDocumentCommand{\IsBackupCounterGroupT}{m+m}{% + \__xassoccnt_is_backupcountergroup:nT {#1} {#2} +} + +\NewDocumentCommand{\IsBackupCounterGroupF}{m+m}{% + \__xassoccnt_is_backupcountergroup:nF {#1} {#2}% +} + + +\NewDocumentCommand{\IsBackupStateTF}{mm+m+m}{% + \__xassoccnt_is_backupstate:nnTF {#1} {#2} {#3} {#4}% +} + +\NewDocumentCommand{\IsBackupStateT}{mm+m}{% + \__xassoccnt_is_backupstate:nnT {#1} {#2} {#3}% +} + +\NewDocumentCommand{\IsBackupStateF}{mm+m}{% + \__xassoccnt_is_backupstate:nnF {#1} {#2} {#3}% +} + + +\NewDocumentCommand{\IsBackupCounterTF}{m+m+m}{% + \xassoccnt_is_backupcounter:nTF {#1} {#2} {#3} +} + +\NewDocumentCommand{\IsBackupCounterT}{m+m}{% + \xassoccnt_is_backupcounter:nT {#1} {#2} +} + +\NewDocumentCommand{\IsBackupCounterF}{m+m}{% + \xassoccnt_is_backupcounter:nF {#1} {#2} +} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%% Coupled Counter features + +\bool_new:N \l__xassoccnt_is_coupledcounter_bool + \prg_new_conditional:Nnn \__xassoccnt_is_coupledcounter:n {TF,T,F} { \xassoccnt_container_map_inline:cn { \xassoccnt_feature_group_container:n{coupledcounters} } {% @@ -1259,12 +1928,6 @@ } - -\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nTF { c } -\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nT { c } -\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nF { c } - - % Declaring a new coupled counters group \cs_new:Nn \xassoccnt_declare_coupledcountersgroup:n {% \xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{coupledcounters}{#1} } @@ -1417,6 +2080,15 @@ \xassoccnt_remove_periodiccounter:nn{#1} {#2} } + +\NewDocumentCommand{\RemoveAllPeriodicCounters}{O{}}{% + \seq_map_inline:Nn \g_xassoccnt_periodiccounter_container_seq {\xassoccnt_remove_periodiccounter:nn {#1} {##1}} +% \cs_new:Nn \xassoccnt_remove_periodiccounter:nn {% + \seq_gclear:N \g_xassoccnt_periodiccounter_container_seq + \prop_gclear:N \g_xassoccnt_periodiccounter_prop +} + + \NewDocumentCommand{\AddPeriodicCounter}{O{}mm}{% \xassoccnt_add_periodiccounter:nnn {#1} {#2} {#3} } @@ -1442,73 +2114,6 @@ -\NewDocumentCommand{\stepcounteroldnototal}{m}{% - \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}% - \xassoccnt_is_suspendedcounter:nF{#1}{% - \xassoccnt_is_coupledcounter:nTF {#1} - { \xassoccnt_stepcounter_coupledcounters:n{#1} } - {% No, not a coupled counter! - \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}% - \xassoccnt_countersinresetlist:n{\l_tmpa_tl}% - \__xassoccnt_getresetlist:n {\l_tmpa_tl}% - \seq_if_empty:NTF \l__xassoccnt_counterreset_seq - {% - \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}% Use the original one! - \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}% - \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} - }{ % reset list is not empty! - % This is the replacement of \csname cl@#1\endcsname - \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one} - \seq_map_inline:Nn \l__xassoccnt_counterreset_seq {% - \xassoccnt_is_drivercounter:nTF{##1}{% - \csname c@##1\endcsname\c_zero % Reset but do not increase - }{% - \csname c@##1\endcsname\c_minus_one - \xassoccnt_standardstepcounter{##1}% - } - } - \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters - }% End of not empty reset list - }% End of coupled counters - } % end of not suspended counter -} - - - -\NewDocumentCommand{\stepcounterTotal}{m}{% - \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}% - \xassoccnt_is_suspendedcounter:nF{#1}{% - \xassoccnt_is_coupledcounter:nTF {#1} - { \xassoccnt_stepcounter_coupledcounters:n{#1} } - {% No, not a coupled counter! - \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}% - \xassoccnt_countersinresetlist:n{\l_tmpa_tl}% - \__xassoccnt_getresetlist:n {\l_tmpa_tl}% - \seq_if_empty:NTF \l__xassoccnt_counterreset_seq - {% - \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}% Use the original one! - \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}% - \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} - }{ % reset list is not empty! - % This is the replacement of \csname cl@#1\endcsname - \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one} - \seq_map_inline:Nn \l__xassoccnt_counterreset_seq {% - \xassoccnt_is_drivercounter:nTF{##1}{% - \csname c@##1\endcsname\c_zero % Reset but do not increase - }{% - \csname c@##1\endcsname\c_minus_one - \xassoccnt_standardstepcounter{##1}% - } - } - \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters - }% End of not empty reset list - }% End of coupled counters - } % end of not suspended counter - \__xassoccnt_is_totalcounter:nT {#1} {% - \__xassoccnt_store_totalcounter_value:n {#1}% - } -} - \RenewDocumentCommand{\stepcounter}{m}{% \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}% @@ -1728,9 +2333,6 @@ } - - - \NewDocumentCommand{\NewDocumentCounter}{O{initial=\c_zero}mo}{% \IfValueTF{#3}{% \__xassoccnt_newcounter_ltx:nnn{#1}{#2}{#3} @@ -1739,8 +2341,6 @@ } } - - \NewDocumentCommand{\CopyDocumentCounters}{O{}mm}{% \__xassoccnt_copycounters:nnn{#1}{#2}{#3}% } @@ -1749,7 +2349,7 @@ \__xassoccnt_swapcounters:nnn{#1}{#2}{#3}% } - +%%%%%%%%%%%%%%% Reset list related stuff \newcommand{\countersresetlistcount}[1]{% \int_zero:N \l_xassoccnt_resetlist_counter% @@ -1850,6 +2450,7 @@ \cs_new:Nn \__xassoccnt_store_totalcounter_value:n {% \prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1} {\number\value{\__xassoccnt_expand_totalcountername:n{#1}}} + \prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1name} {\__xassoccnt_expand_totalcountername:n{#1}} } \cs_new:Nn \__xassoccnt_registertotaldocumentcounter:nn {% @@ -1878,28 +2479,11 @@ } +% Expandable version \newcommand{\TotalValue}[1]{% -% \seq_use:Nn \g__xassoccnt_totalcounter_container {\par}% - \tl_set:Nx \l_tmpa_tl {\__xassoccnt_expand_totalcountername:n{#1}} - \tl_set:Nx \l_tmpb_tl {#1}% - \seq_if_in:NnTF \g__xassoccnt_supertotalcounter_container {\l_tmpb_tl }{% - \tl_set:Nx \l_tmpa_tl {\__xassoccnt_expand_totalcountername:n{#1}} - }{% - \seq_if_in:NVF \g__xassoccnt_totalcounter_container {\l_tmpa_tl }{% - \tl_set:NV \l_tmpa_tl {#1}% - } - } - \number\value{\tl_use:N \l_tmpa_tl}% -} - -\renewcommand{\TotalValue}[1]{% \prop_item:Nn \g_xassoccnt_totalcounter_prop {#1}% } -%\newcommand{\loadstore} - - - \cs_new:Nn \__xassoccnt_writetotalcounters:nn {% \immediate\write\@mainaux {% \string\IfIsDocumentCounterF\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}{\string\DeclareDocumentCounter\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}} @@ -1915,6 +2499,10 @@ } } +\NewDocumentCommand{\TotalCounterInternalNameExp}{m}{% + \prop_item:Nn \g_xassoccnt_totalcounter_prop {#1name}% +} + \NewDocumentCommand{\TotalCounterInternalName}{m}{% @@ -2088,17 +2676,17 @@ } -\NewDocumentCommand{\BackupCounterValues}{O{resetbackup=true}m}{% - \keys_set:nn{xassoccnt}{#1} +\NewDocumentCommand{\FormerBackupCounterValues}{O{resetbackup=true}m}{% + \keys_set:nn{xassoccnt}{#1}% \int_incr:N \g__xassoccnt_backupcalls_int \int_zero:N \l_tmpa_int - \seq_clear:N \l__xassoccnt_countervaluesbackup_seq - \seq_clear:N \l__xassoccnt_backupresetlist_seq + \seq_gclear:N \l__xassoccnt_countervaluesbackup_seq + \seq_gclear:N \l__xassoccnt_backupresetlist_seq \__xassoccnt_addbackupcounter:nnn {#1}{}{#2}% - \seq_clear:N \l__xassoccnt_backupresetlist_seq% + \seq_gclear:N \l__xassoccnt_backupresetlist_seq% } -\NewDocumentCommand{\RemoveBackupCounterInternal}{sO{}m}{% +\NewDocumentCommand{\FormerRemoveBackupCounterInternal}{sO{}m}{% \tl_set:Nn \l_tmpa_tl {#3} \int_zero:N \l_tmpa_int% \int_zero:N \l_tmpb_int% @@ -2125,19 +2713,19 @@ -\NewDocumentCommand{\RemoveBackupCounters}{sO{}m}{% +\NewDocumentCommand{\FormerRemoveBackupCounters}{sO{}m}{% \clist_set:Nn \l_tmpa_clist {#3} % Loop through the list \clist_map_inline:Nn \l_tmpa_clist {% \IfBooleanTF{#1}{% - \RemoveBackupCounterInternal*{##1}% + \FormerRemoveBackupCounterInternal*{##1}% }{% - \RemoveBackupCounterInternal*{##1}% + \FormerRemoveBackupCounterInternal{##1}% } } } -\NewDocumentCommand{\RestoreAllCounterValues}{O{}}{% +\NewDocumentCommand{\FormerRestoreAllCounterValues}{O{}}{% \__xassoccnt_restorecountervalues:n {l__xassoccnt_counternamesbackup_seq } \seq_clear:N \l__xassoccnt_countervaluesbackup_seq % clear the value list \seq_clear:N \l__xassoccnt_counternamesbackup_seq % clear the name list @@ -2145,7 +2733,7 @@ % \Restore is \Remove with restoring (of course) -\NewDocumentCommand{\RestoreCounterValues}{O{}m}{% +\NewDocumentCommand{\FormerRestoreCounterValues}{O{}m}{% \clist_set:Nn \l_tmpa_clist {#2} \clist_map_inline:Nn \l_tmpa_clist {% \RemoveBackupCounterInternal{##1}% @@ -2161,7 +2749,7 @@ } -\NewDocumentCommand{\AddBackupCounter}{O{}m}{% +\NewDocumentCommand{\FormerAddBackupCounter}{O{}m}{% \clist_set:Nx \l_tmpa_clist {#2} \clist_map_inline:Nn \l_tmpa_clist {% \__xassoccnt_removestarsinglevalue:n{##1}% @@ -2202,16 +2790,21 @@ \clist_map_inline:Nn \l_tmpa_clist { #2{##1} } } - +\NewDocumentCommand{\LoopFullCounterResetList}{m+m}{% + \__xassoccnt_get_full_reset_list:n {#1}% + \seq_if_exist:cT {#1_fullresetlist_seq } { + \seq_map_inline:cn {#1_fullresetlist_seq} {% + #2{##1}% + } + }% +} %%%% %% Counter-Values-Mapping-To-Something-Different - Macros - - - +%%% To be done! %%%%%%%%%%%%%%%%%%%% @@ -2248,7 +2841,6 @@ }{#2} } - \NewDocumentCommand{\DeclareDocumentCounter}{O{initial={0}}mo}{% \IfValueTF{#3}{% \xassoccnt_declaredocumentcounteropt:nnn{#1}{#2}{#3}% @@ -2259,8 +2851,6 @@ \ExplSyntaxOff - - \EnableNumberofrunsTF{% \NewTotalDocumentCounter[supertotal=true]{numberofruns} \AtBeginDocument{% @@ -2284,6 +2874,9 @@ \@onlypreamble{\DeclareDocumentCounter} \@onlypreamble{\DeclareCoupledCounters} +\AtBeginDocument{% + \DeclareBackupCountersGroupName{scratch}% +} %%% Colour output routines @@ -2297,8 +2890,8 @@ -\AddFeature[sublists=true]{coupledcounters} % New style, not fully implemented so far -\AddFeature[sublists=false]{periodiccounters} % New style, not fully implemented so far +\AddFeature[sublists=true,publicname={Coupled Counters Feature}]{coupledcounters} +\AddFeature[sublists=true,publicname={Backup Counters Feature}]{backupcounters} % New style, not fully implemented so far % Some more to be done |