%D \module
%D   [       file=strc-flt,
%D        version=2008.10.20,
%D          title=\CONTEXT\ Structure Macros,
%D       subtitle=Initialization \& Helpers,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA-ADE / Hans Hagen]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Structure Macros / Initialization & Helpers}

\registerctxluafile{strc-ini}{1.001}

\unprotect

% \def\zerosection{0}
% \def\resetsectionmarks{}
% \setuppagenumbering

% maybe use structurecomponent more consistently as name below

% segments: 0:100 2:3 chapter:subsection 3 (=self+2)        (alternative: sectionset)

% section   : [sectionnumber(s)]
%             sectionseparatorset (default) sectionconversionset (default) sectionstopper ()  sectionset sectionsegments

% lists     : [sectionnumber(s)] [text] [prefix(es)[separator]][pagenumber(s)]
%             sectionseparatorset (default) sectionconversionset (default) sectionstopper     sectionset sectionsegments
%             prefixseparatorset  (default) prefixconversionset  (default) prefixstopper  (.) prefixset  prefixsegments
%             pageseparatorset    (default) pageconversionset    (default) pagestopper    ()             pagesegments
%             prefix (no)

% counter   : [prefix(es)[separator]][number(s)]
%             prefixseparatorset  (default) prefixconversionset  (default) prefixstopper  (.) prefixset  prefixsegments
%             numberseparatorset  (default) numberconversionset  (default) numberstopper  ()             numbersegments
%             prefix (no)

% pagenumber: [prefix(es)[separator]][pagenumber(s)]
%             prefixseparatorset  (default) prefixconversionset  (default) prefixstopper  (.) prefixset  prefixsegments
%             pageseparatorset    (default) pageconversionset    (default) pagestopper    ()
%             prefix (no)

%               text  mark  reference  list
% section       P     P     P          P
% float         P.N         P.N        P.N
% itemize       P.N         P.N
% enumerate     P.N         P.N        P.N
% formula       P.N         P.N
% footnote      P.N         P.N        P.N
% number        P.N         P.N

% number prefix section page

% [text|marking|reference|list]:[number|prefix|pagenumber|pageprefix]:[separatorset|conversionset|conversion|stopper|set|segments|resetset|order]

% figure caption  : text:number:* text:prefix:* -> \setupcaption[figure][...]; stores defaults
% figure list     : list:number:* list:prefix:* list:pagenumber:* list:pageprefix:* -> \setuplist[figure][...]; takes stored defaults for number and pagenumber]
% figure reference: reference:number:* reference:prefix:* reference:pagenumber:* reference:pageprefix:* -> \setupreference[figure]]...]; takes stored defaults

% This module deals with structure: section headers, list and
% numbering and eventually cross referencing. These components are
% rather interwoven and therefore an inbetween layer is used.
% Eventually this will replace the corresponding code in core-sec,
% core-lst, core-num and core-ref.

% We collect operations that deal with things like formatting on each
% level of a number in sets. This is all handles at the \LUA\ end.
% References to such sets travel with the multipass information.

\def\definestructureresetset     {\dotripleempty\dodefinestructureresetset}
\def\definestructureseparatorset {\dotripleempty\dodefinestructureseparatorset}
\def\definestructureconversionset{\dotripleempty\dodefinestructureconversionset}
\def\definestructureprefixset    {\dotripleempty\dodefinestructureprefixset}

\def\dodefinestructureresetset     [#1][#2][#3]{\ctxlua{structure.sets.define("structure:resets",     "#1","\luaescapestring{\detokenize{#2}}","\luaescapestring{\detokenize{#3}}",true)}}
\def\dodefinestructureseparatorset [#1][#2][#3]{\ctxlua{structure.sets.define("structure:separators", "#1","\luaescapestring{\detokenize{#2}}","\luaescapestring{\detokenize{#3}}")}}
\def\dodefinestructureconversionset[#1][#2][#3]{\ctxlua{structure.sets.define("structure:conversions","#1","\luaescapestring{\detokenize{#2}}","\luaescapestring{\detokenize{#3}}")}}
\def\dodefinestructureprefixset    [#1][#2][#3]{\ctxlua{structure.sets.define("structure:prefixes",   "#1","\luaescapestring{\detokenize{#2}}","\luaescapestring{\detokenize{#3}}")}}

% \definestructureseparatorset [weird][!,?,*][:]                                  % tex content
% \definestructureconversionset[weird][numbers,characters,romannumerals][numbers] % symbolic names
% \definestructureresetset     [weird][0,0,1][0]                                  % numbers

\protect \endinput
