-- JunoKeyboardImpl, coded by Greg Nelson & Donna Auguste, -- December 7, 1982 11:51 am DIRECTORY ViewerClasses, TIPUser, JunoKeyboard; JunoKeyboardImpl: MONITOR EXPORTS JunoKeyboard = BEGIN OPEN JunoKeyboard; x, y, oldx, oldy : PUBLIC INT _ 0; event : PUBLIC EventType; button : PUBLIC ButtonType; char: PUBLIC CHAR; status : PUBLIC ARRAY ButtonType OF StatusType; nonFull, nonEmpty: CONDITION; Quit : PUBLIC SIGNAL = CODE; ignoredCount: NAT _ 0; queueMax : INTEGER = 1000; queue : ARRAY [0..queueMax) OF REF ANY; queueLeft, queueRight : INT _ 0; -- the active range of the queue is [queueLeft..queueRight), wrapped -- entries are added to the right of the queue, and removed from the left. --ENTERANDNOTIFY EnterAndNotify : PUBLIC ENTRY PROC [self : ViewerClasses.Viewer, input : LIST OF REF ANY] = { WHILE input # NIL DO WHILE (queueRight + 1) MOD queueMax = queueLeft DO -- WAIT nonFull ignoredCount _ ignoredCount + 1; RETURN ENDLOOP; queue[queueRight] _ input.first; queueRight _ (queueRight + 1) MOD queueMax; BROADCAST nonEmpty; input _ input.rest ENDLOOP; }; --NEXT (will pop off an entry) Next : PUBLIC ENTRY PROC = { WHILE (queueLeft = queueRight) DO WAIT nonEmpty ENDLOOP; WITH queue[queueLeft] SELECT FROM coords : TIPUser.TIPScreenCoords => { event _ roll; oldx _ x; oldy _ y; -- x _ coords.x; (cedar 3.1) -- y _ coords.y (cedar 3.1) x _ coords.mouseX; y _ coords.mouseY }; text : REF CHAR => { event _ keyDown; char _ text^ }; clickAtom: ATOM =>{ SELECT clickAtom FROM $Destroy => { event _ keyDown; char _ 33C; SIGNAL Quit[ ]}; -- if the event was $Destroy, act as though is was an ESC, so that JunoTop -- will treat is as the Select Quit & ESC sequence. $RedUp => {status[red] _ up; event _ clickUp; button _ red}; $RedDown => {status[red] _ down; event _ clickDown; button _ red}; $BlueUp => {status[blue] _ up; event _ clickUp; button _ blue}; $BlueDown => {status[blue] _ down; event _ clickDown; button _ blue}; $YellowUp => {status[yellow] _ up; event _ clickUp; button _ yellow}; $YellowDown => {status[yellow] _ down; event _ clickDown; button _ yellow} ENDCASE => ERROR; } ENDCASE => ERROR; queueLeft _ (queueLeft + 1) MOD queueMax; BROADCAST nonFull }; END.