-- TSJaM.mesa
-- Typescript - JaM
-- Written by Werner Winiger, August, 1981.
-- last edited by Paxton, 13-Aug-81 10:21:44

DIRECTORY
  JaMIODefs USING [DirectUserOutput, ResetCommand, AppendUserLine, UserInput],
  JaMControlDefs USING [Announce, InterpreteCommand],
  ViewerMenus USING [Close],
  Rope USING [Ref],
  TypeScript USING [Typescript, TSLineProc, CreateTypescript, ClientPutChar, ClientPutRope];
  
TSJaM: PROGRAM
IMPORTS JaMIODefs, JaMControlDefs, ViewerMenus, TypeScript = {

JaMTS: TypeScript.Typescript;

-- the output procedure's to be called from JaM:
PutChar: PROC[ch: CHARACTER] = {TypeScript.ClientPutChar[JaMTS, ch]};
PutRope: PROC [r: Rope.Ref] = {TypeScript.ClientPutRope[JaMTS, r]};

-- the input procedure to be called from the typescript:
TakeLine: TypeScript.TSLineProc = {
  balanced: BOOLEAN ← JaMIODefs.AppendUserLine[line];
  IF balanced THEN {
    quitted: BOOLEAN ← JaMControlDefs.InterpreteCommand[JaMIODefs.UserInput[]];
    IF quitted THEN ViewerMenus.Close[JaMTS];
    JaMIODefs.ResetCommand[];
    };
  };
  
-- main code --
JaMIODefs.DirectUserOutput[PutChar,PutRope];
JaMTS ← TypeScript.CreateTypescript[line: TakeLine, name: "*J*a*M*", iconic: TRUE, fork: TRUE];
JaMControlDefs.Announce;
}.