%D \module
%D   [       file=node-ini,
%D        version=2006.08.20,
%D          title=\CONTEXT\ Character Macros,
%D       subtitle=Node Support (Initialization),
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA]
%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}{Node Support (initialization)}

\registerctxluafile{node-seq}{1.001}
\registerctxluafile{node-ini}{1.001}

% \appendtoks
%     \ctxlua {
%       callbacks.push('hpack_filter')
%       callbacks.push('vpack_filter')
%       callbacks.push('buildpage_filter')
%       callbacks.push('pre_linebreak_filter')
%       callbacks.push('pre_output_filter')
%     }%
% \to \everybeforeoutput
% \appendtoks
%     \ctxlua {
%       callbacks.pop('hpack_filter')
%       callbacks.pop('vpack_filter')
%       callbacks.pop('buildpage_filter')
%       callbacks.pop('pre_linebreak_filter')
%       callbacks.pop('pre_output_filter')
%     }%
% \to \everyafteroutput

\newcount\shownodescounter

\def\shownextnodes     {\afterassignment\doshownodes\shownextnodescounter}
\def\showflatnodes     {\afterassignment\doshownodes\showflatnodescounter}
\def\doshownextnodes   {\ctxlua{texio.write_nl('log',nodes.serializebox(\number\shownodescounter,false,true))}}
\def\doshowflatnodes   {\ctxlua{texio.write_nl('log',nodes.serializebox(\number\shownodescounter,true, true))}}
\def\visualizenextnodes{\dowithnextbox{\ctxlua{nodes.visualizebox(\number\nextbox,false,true)}}}
\def\visualizeflatnodes{\dowithnextbox{\ctxlua{nodes.visualizebox(\number\nextbox,true,true)}}}

\def\starttracingnodes[#1]{\ctxlua{nodes.tracers.characters.start("#1")}}
\def\stoptracingnodes     {\ctxlua{nodes.tracers.characters.stop()}}

% \starttext
%     \starttracingnodes[characters]
%         \input tufte \par
%         \input tufte \par
%     \stoptracingnodes
% \stoptext

\endinput
