/*******************************************
* Online Commander v0.3.Test               *
* Keypressed test example                  *
********************************************/
? include "ocmdapi.h--"

byte Result = 1;
char szHdr  = "\027[0;1m\027[2;3HExternal module/process demo\027[0m";
char szPos  = "\027[4;3H\027[K";
char szKey  = "[   ] key";
char buf[80];

void TRANSLATE_CHAR()
{
$ PUSH AX; FARCALL(F_OUT_SZ,#szPos); $ POP  AX
$ OR   AL,AL
$ JZ   XTRN
COUT:
  IF(AL==AH) { Result=0; FARCALL(F_OUT_SZ,"\n\nDone.\n");} ELSE
  IF(AL<32)    FARCALL(F_OUT_SZ,"Control char");
       ELSE  { DSBYTE[#szKey+2]=AL; FARCALL(F_OUT_SZ,#szKey); }
$ JMP QT
XTRN:
$ CMP  AH,'H'; $ JE  UP
$ CMP  AH,'P'; $ JE  DN
$ CMP  AH,'K'; $ JE  LT
$ CMP  AH,'M'; $ JE  RT
$ PUSH AX; FARCALL(F_OUT_SZ,"Xtern ");
$ POP  AX; AH><AL; $ JMP COUT
UP:
  FARCALL(F_OUT_SZ,"Up");   $ JMP SHORT ARR
DN:
  FARCALL(F_OUT_SZ,"Down"); $ JMP SHORT ARR
LT:
  FARCALL(F_OUT_SZ,"Left"); $ JMP SHORT ARR
RT:
  FARCALL(F_OUT_SZ,"Right");
ARR:
  FARCALL(F_OUT_SZ," arrow");
QT:
}

void main()
{ IF(AL==M_INIT) { FARCALL(F_OUT_ANSF,#buf,"ans\\demo.ans");
                   FARCALL(F_OUT_SZ,#szHdr);
                 } ELSE
  IF(AL==M_CHAR) { AX><BX; TRANSLATE_CHAR(); }
  AL = Result;
}