-- JaMTSInfoImpl.mesa
-- Last changed by Paxton, October 4, 1982 2:34 pm

DIRECTORY
  JaMTSInfo,
  Atom,
  JaMOps USING [MakeName],
  JaMInternal USING [Frame],
  JaMTypeScript USING [MouseProc];
 
JaMTSInfoImpl: MONITOR
 LOCKS tsi USING tsi:TSInfo
 IMPORTS Atom, JaMOps
 EXPORTS JaMTSInfo = { OPEN JaMTSInfo;

Create: PUBLIC PROC RETURNS [tsi: TSInfo] = {
  RETURN [NEW[TSInfoRec]] };

WaitForSomethingToDo: PUBLIC ENTRY PROC [tsi: TSInfo] = { OPEN tsi;
  ENABLE UNWIND => NULL;
  WHILE state=idle DO WAIT somethingToDo ENDLOOP };

NotifyReadyForMore: PUBLIC ENTRY PROC [tsi: TSInfo] = { OPEN tsi;
  ENABLE UNWIND => NULL;
  state ← idle; BROADCAST readyForInput };
  
Do: PUBLIC ENTRY PROC [obj: Object, tsi: TSInfo] = { OPEN tsi;
  ENABLE UNWIND => NULL;
  UNTIL state=idle DO WAIT readyForInput ENDLOOP;
  objectToDo ← obj; state ← busy; NOTIFY somethingToDo;
  UNTIL state=idle DO WAIT readyForInput ENDLOOP;
  };

lastAtom: ATOM;
lastName: name Object;

GetName: PROC [atom: ATOM] RETURNS [name: name Object] = {
	IF atom = lastAtom THEN RETURN [lastName];
	lastName ← name ← JaMOps.MakeName[LOOPHOLE[Atom.GetPName[atom],LONG STRING]];
	lastAtom ← atom };

DoButton: PUBLIC ENTRY PROC[
  tsi: TSInfo, frame: JaMInternal.Frame,
  buttonName: ATOM, x,y: REAL,
  mouseProc: JaMTypeScript.MouseProc] = { OPEN tsi;
  ENABLE UNWIND => NULL;
  IF state#idle THEN RETURN; -- ignore buttons if not idle
  mouseProc[frame,x,y]; -- push transformed coordinates
  objectToDo ← GetName[buttonName];
  state ← busy; NOTIFY somethingToDo;
  };

DoAtom: PUBLIC ENTRY PROC[
  tsi: TSInfo, frame: JaMInternal.Frame, atom: ATOM] = { OPEN tsi;
  ENABLE UNWIND => NULL;
  IF state#idle THEN RETURN; -- ignore if not idle
  objectToDo ← GetName[atom];
  state ← busy; NOTIFY somethingToDo;
  };

}...