%D \module
%D   [       file=regi-ini,
%D        version=2000.12.27, % 1998.12.03,
%D          title=\CONTEXT\ Regime Macros,
%D       subtitle=Initialization,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

%D Messages (to be translated).

\startmessages  dutch  library: regimes
  title: regime
      1: regime --
      2: regime -- wordt geladen
      3: onbekend regime --
\stopmessages

\startmessages  english  library: regimes
  title: regime
      1: regime --
      2: regime -- is loaded
      3: unknown regime --
\stopmessages

\startmessages  german  library: regimes
  title: Kodierung
      1: Kodierung --
      2: Kodierung -- ist geladen
      3: Unbekannte Kodierung --
\stopmessages

\startmessages  czech  library: regimes
  title: kodovani
      1: kodovani --
      2: je nacteno kodovani --
      3: nezname kodovani --
\stopmessages

\startmessages  italian  library: regimes
  title: codifica
      1: codifica --
      2: codifica -- caricata
      3: codifica sconosciuta --
\stopmessages

\startmessages  norwegian  library: regimes
  title: koding
      1: koding --
      2: koding -- er lest inn
      3: ukjent koding --
\stopmessages

\startmessages  romanian  library: regimes
  title: codificari
      1: codificarea --
      2: codificarea -- este Encarcata
      3: codificarea -- este necunoscuta
\stopmessages

\startmessages  french  library: regimes
  title: encodage
      1: encodage --
      2: l'encodage -- est chargé
      3: encodage -- inconnu
\stopmessages

%D Variables.

\def\@reg@{@r@eg@} % regime prefix

%D \macros
%D   {currentregime}

\let\currentregime\empty
\let\defaultregime\s!default

%D Plugin interface.

\let\mkloadregime   \gobbleoneargument
\let\mkenableregime \gobbleoneargument
\let\mkdisableregime\relax
\let\mkshowregime   \gobbleoneargument
\let\mkwalkregime   \gobbleoneargument
\let\mkautosetregime\gobbletwoarguments

%D Some low level inheritance stuff (mkii).

\def\doautosetregime{\mkautosetregime}

%D \macros
%D   {defineregimesynonym,trueregimename}

\def\defineregimesynonym
  {\dodoubleargument\dodefineregimesynonym}

\def\dodefineregimesynonym[#1][#2]%
  {\setevalue{\@reg@:s:#1}{#2}}

\def\trueregimename#1%
  {\executeifdefined{\@reg@:s:#1}{#1}}

%D \macros
%D   {useregime}

\def\useregime[#1]%
  {\processcommalist[#1]\douseregime}

\def\douseregime#1%
  {\doifundefined{\c!file\f!regimeprefix#1}%
     {\letgvalue{\c!file\f!regimeprefix#1}\empty
      \mkloadregime{#1}}}

%D \macros
%D   {enableregime,disableregime}

\let\enabledregime\empty

\def\enableregime[#1]%
  {\edef\currentregime{\trueregimename{#1}}%
   \doifelsenothing\currentregime
     {\disableregime}
     {\douseregime\currentregime
      \mkenableregime\currentregime}}

\def\disableregime
  {\let\currentregime\empty
   \mkdisableregime}

%D \macros
%D   {protectregime, settoletterunlessactive, settocodeunlessactive}
%D
%D The next boolean is used later on to prevent unwanted
%D catcode changes. Use it with care.

\newif\ifprotectregime \protectregimetrue

\def\settoletterunlessactive#1%
  {\ifprotectregime\ifnum\catcode#1=\active\else
     \catcode#1\@@letter
   \fi\else
     \catcode#1\@@letter
   \fi}

\def\settootherunlessactive#1%
  {\ifprotectregime\ifnum\catcode#1=\active\else
     \catcode#1=\@@other
   \fi\else
     \catcode#1=\@@other
   \fi}

\def\settocodeunlessactive#1#2%
  {\ifprotectregime\ifnum\catcode#1=\active\else
     \catcode#1=#2\relax
   \fi\else
     \catcode#1=#2\relax
   \fi}

%D Sort related:

\def\dowalkregime{\mkwalkregime} % #1

%D \macros
%D   {showregime}

\def\showregime
  {\dosingleempty\doshowregime}

\def\doshowregime[#1]%
  {\mkshowregime{#1}}

%D Plugins.

\loadmarkfile{regi-ini}

\protect \endinput
