%D \module
%D   [       file=m-gamma,
%D        version=2002.05.15,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=Basic \OMEGA\ Support,
%D         author={Idris Samawi Hamid, Hans Hagen},
%D           date=\currentdate,
%D      copyright={PRAGMA-ADE, Idris Samawi Hamid}]
%D
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Most of this module is written by Idris Samawi Hamid.

%D We define a couple of symbolic \OTP\ filters and
%D sequences. First the filters:
%D
%D Todo: better names, no funny abbreviations.

\definefiltersynonym [utf8 to unicode16]  [inutf8]
\definefiltersynonym [IdOCP]              [id]
\definefiltersynonym [BasicLatinTexUni]   [lat2uni]
\definefiltersynonym [BasicLatinUniToFont][uni2lat]
\definefiltersynonym [GrTexUni]           [grpo2uni]
\definefiltersynonym [GrUniToFont]        [uni2greek]
\definefiltersynonym [ArabUni]            [7arb2uni]
\definefiltersynonym [BerberUni]          [7ber2uni]
\definefiltersynonym [UrduUni]            [7urd2uni]
\definefiltersynonym [AfghaPashtoUni]     [7pas2uni]
\definefiltersynonym [PakiPashtoUni]      [7pap2uni]
\definefiltersynonym [SindhiUni]          [7snd2uni]
\definefiltersynonym [TifinaghUni]        [7tbe2uni]
\definefiltersynonym [LatinBerberUni]     [7lbe2uni]
\definefiltersynonym [UniCUni]            [uni2cuni]
\definefiltersynonym [CUniArab]           [cuni2oar]
\definefiltersynonym [NoKeshidehCUniArab] [cuni2nar]

%D Next we define the sequences.

\definefiltersequence
  [NilOCP]
  [IdOCP]

\definefiltersequence
  [BasicLatinOCP]
  [BasicLatinTexUni,BasicLatinUniToFont]

\definefiltersequence
  [GreekOCP]
  [GrTexUni,GrUniToFont]

\definefiltersequence
  [ArabicOCP]
  [ArabUni,UniCUni,CUniArab]

\definefiltersequence
  [ArabicNoKeshidehOCP]
  [ArabUni,UniCUni,NoKeshidehCUniArab]

\definefiltersequence
  [ArabicBerberOCP]
  [BerberUni,UniCUni,CUniArab]

\definefiltersequence
  [TifinaghOCP]
  [TifinaghUni,BasicLatinUniToFont]

\definefiltersequence
  [LatinBerberOCP]
  [LatinBerberUni,BasicLatinUniToFont]

\definefiltersequence
  [UrduOCP]
  [UrduUni,UniCUni,CUniArab]

\definefiltersequence
  [UrduNoKeshidehOCP]
  [UrduUni,UniCUni,NoKeshidehCUniArab]

\definefiltersequence
  [AfghaPashtoOCP]
  [AfghaPashtoUni,UniCUni,CUniArab]

\definefiltersequence
  [PakiPashtoOCP]
  [PakiPashtoUni,UniCUni,CUniArab]

\definefiltersequence
  [SindhiOCP]
  [SindhiUni,UniCUni,CUniArab]

%D We wrap a couple of languages in environmen tmacros.
%D beware: this solution is far from perfect!
%D
%D Todo: better interface to directional primitives.
%D
%D Todo: proper language support (labels etc).

\definestartstop
  [latin]
  [commands=%
    {\usefiltersequence[BasicLatinOCP]%
     \switchtobodyfont[omlgc]}]

\definestartstop
  [greek]
  [commands=%
    {\usefiltersequence[GreekOCP]%
     \switchtobodyfont[omlgc]%
     \language=3\lefthyphenmin2\righthyphenmin=2}]

\definestartstop
  [arab]
  [commands=%
    {\usefiltersequence[ArabicOCP]
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [smallarab]
  [commands=%
    {\usefiltersequence[ArabicNoKeshidehOCP]
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [latberber]
  [commands=%
    {\usefiltersequence[LatinBerberOCP]
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [tifinagh]
  [commands=%
    {\usefiltersequence[TifinaghOCP]
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [berber]
  [commands=%
    {\usefiltersequence[ArabicBerberOCP]
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [urdu]
  [commands=%
    {\usefiltersequence[UrduOCP]%
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [smallurdu]
  [commands=%
    {\usefiltersequence[UrduNoKeshidehOCP]%
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [pashto]
  [commands=%
    {\usefiltersequence[AfghaPashtoOCP]%
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [pashtop]
  [commands=%
    {\usefiltersequence[PakiPashtoOCP]%
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]

\definestartstop
  [sindhi]
  [commands=%
    {\usefiltersequence[SindhiOCP]%
     \switchtobodyfont[omarb]%
     \textdir TRT\pardir TRT}]


\let\typeout\message \input grlccode.tex

%D We (pre)define a couple of fonts:

\usetypescriptfile[type-omg]

\usetypescript[OmegaArab]
\usetypescript[OmegaLGC]

%D Dangerous definitions:

\startencoding[omega]

  \definecharacter textbraceleft  {^^^^f07b}
  \definecharacter textbraceright {^^^^f07d}
  \definecharacter textbackslash  {^^^^f05c}
  \definecharacter textbullet     {{\clearocplists\mm\sy\char"0F}}
  \definecharacter dotlessi       {^^^^0131}
  \definecharacter ssharp         {^^^^00df}

\stopencoding

\enableencoding [omega]

%D Some logo's:

\unexpanded \def\OMEGA {{\switchtobodyfont[omlgc]^^^^03a9}}
\unexpanded \def\OTP   {\OMEGA TP}

%D A few funny definitions:

\def\#{^^^^f023}
\def\${^^^^f024}
\def\%{^^^^f025}
\def\&{^^^^f026}

%D I have no idea what this has to do with omega:

\def\heshe {\lohi{he} {she}}
\def\himher{\lohi{him}{her}}
\def\hisher{\lohi{his}{her}}

% Brrr

\setuptolerance [verytolerant]

\endinput
