<> <> <> DIRECTORY ClassIncreek USING [ActionBody, ActionKind, GetAction, GetPositionFrom, Increek, NewStdIncreek, Release, ViewPosition], Commander USING [CommandProc, Register], CommandTool USING [ArgumentVector, Failed, Parse], Cursors USING [CursorType, NewCursor, SetCursor], Interminal USING [KeyState], Process USING [Detach], Rope USING [Equal, ROPE], TerminalDefs USING [KeyName], VisibleMouseClicks USING [Visibility]; VisibleMouseClicksImpl: CEDAR MONITOR IMPORTS ClassIncreek, Commander, CommandTool, Cursors, Process, Rope EXPORTS VisibleMouseClicks = { <> visibility: VisibleMouseClicks.Visibility _ off; <> On: PUBLIC ENTRY PROCEDURE [] RETURNS [was: VisibleMouseClicks.Visibility] = { was _ visibility; SELECT visibility FROM on => { NULL; }; off => { visibility _ on; TRUSTED { Process.Detach[FORK ReadMouseClicks[]]; }; }; ENDCASE => ERROR; }; Off: PUBLIC ENTRY PROCEDURE [] RETURNS [was: VisibleMouseClicks.Visibility] = { was _ visibility; SELECT visibility FROM on => { visibility _ off; }; off => { NULL; }; ENDCASE => ERROR; }; <> ReadMouseClicks: PROCEDURE [] RETURNS [] = { <> increek: ClassIncreek.Increek; viewPosition: ClassIncreek.ViewPosition; actionBody: ClassIncreek.ActionBody; TRUSTED { increek _ ClassIncreek.NewStdIncreek[NIL]; <> viewPosition _ ClassIncreek.GetPositionFrom[increek]; <> }; UNTIL visibility = off DO TRUSTED { actionBody _ ClassIncreek.GetAction[self: increek, acceptance: clicks]; <> }; IF visibility = on THEN { WITH action: actionBody SELECT FROM keyDown => { SELECT action.value FROM Red => { SELECT GetCtrlShiftState[viewPosition.keyState] FROM neither => Cursors.SetCursor[neitherRed]; ctrl => Cursors.SetCursor[ctrlRed]; shift => Cursors.SetCursor[shiftRed]; ctrlShift => Cursors.SetCursor[ctrlShiftRed]; ENDCASE => ERROR; }; Yellow => { SELECT GetCtrlShiftState[viewPosition.keyState] FROM neither => Cursors.SetCursor[neitherYellow]; ctrl => Cursors.SetCursor[ctrlYellow]; shift => Cursors.SetCursor[shiftYellow]; ctrlShift => Cursors.SetCursor[ctrlShiftYellow]; ENDCASE => ERROR; }; Blue => { SELECT GetCtrlShiftState[viewPosition.keyState] FROM neither => Cursors.SetCursor[neitherBlue]; ctrl => Cursors.SetCursor[ctrlBlue]; shift => Cursors.SetCursor[shiftBlue]; ctrlShift => Cursors.SetCursor[ctrlShiftBlue]; ENDCASE => ERROR; }; ENDCASE => { NULL; }; }; keyUp => { NULL; <> }; allUp => { NULL; <> }; ENDCASE => NULL; }; ENDLOOP; TRUSTED { increek _ ClassIncreek.Release[increek]; }; }; <> ctrlShiftState: TYPE = { neither, ctrl, shift, ctrlShift }; GetCtrlShiftState: PROCEDURE [keyState: Interminal.KeyState] RETURNS [ctrlShiftState] = { IF keyState.bits[LeftShift] = down OR keyState.bits[RightShift] = down THEN IF keyState.bits[Ctrl] = down OR keyState.bits[Spare3] = down THEN RETURN [ctrlShift] ELSE RETURN [shift] ELSE IF keyState.bits[Ctrl] = down OR keyState.bits[Spare3] = down THEN RETURN [ctrl] ELSE RETURN [neither] }; <> Init: PROCEDURE [] RETURNS [] = { Commander.Register[key: "VisibleMouseClicks", proc: VisibleMouseClicksCommand, doc: "on => enable visible mouse clicks, off => disable visible mouse clicks", clientData: NIL, interpreted: TRUE]; }; VisibleMouseClicksCommand: Commander.CommandProc = { argv: CommandTool.ArgumentVector; argv _ CommandTool.Parse[cmd: cmd ! CommandTool.Failed => { GO TO Failed; }]; SELECT argv.argc FROM 2 => { SELECT TRUE FROM Rope.Equal[s1: argv[1], s2: "on", case: FALSE] => { IF On[] = on THEN msg _ "VisibleMouseClicks already on" ELSE msg _ NIL; }; Rope.Equal[s1: argv[1], s2: "off", case: FALSE] => { IF Off[] = off THEN msg _ "VisibleMouseClicks already off" ELSE msg _ NIL; }; ENDCASE => { msg _ "VisibleMouseClicks {on | off}"; }; }; ENDCASE => { SELECT visibility FROM on => { msg _ "VisibleMouseClicks {on | off} -- currently on"; }; off => { msg _ "VisibleMouseClicks {on | off} -- currently off"; }; ENDCASE => { msg _ "VisibleMouseClicks {on | off}"; }; }; EXITS Failed => { result _ $Failure; msg _ "failed"; }; }; <> <> neitherRed: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 027250B, 027250B, 027250B, 027250B, 027250B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; ctrlRed: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 167250B, 167250B, 167250B, 167250B, 167250B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; shiftRed: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 027250B, 027250B, 027250B, 027250B, 027250B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; ctrlShiftRed: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 167250B, 167250B, 167250B, 167250B, 167250B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; neitherYellow: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 025650B, 025650B, 025650B, 025650B, 025650B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; ctrlYellow: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 165650B, 165650B, 165650B, 165650B, 165650B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; shiftYellow: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 025650B, 025650B, 025650B, 025650B, 025650B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; ctrlShiftYellow: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 165650B, 165650B, 165650B, 165650B, 165650B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; neitherBlue: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 025350B, 025350B, 025350B, 025350B, 025350B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; ctrlBlue: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 165350B, 165350B, 165350B, 165350B, 165350B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 020010B, 037770B]]; shiftBlue: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 025350B, 025350B, 025350B, 025350B, 025350B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; ctrlShiftBlue: Cursors.CursorType _ Cursors.NewCursor[bits: [ 037770B, 020010B, 165350B, 165350B, 165350B, 165350B, 165350B, 020010B, 020010B, 160010B, 160010B, 160010B, 160010B, 160010B, 020010B, 037770B]]; <> Init[]; }.