InputNotify: ViewerClasses.NotifyProc = {
[self: ViewerClasses.Viewer, input: LIST OF REF ANY]
queue: InputQueue ~ NARROW[ImagerViewer.ClientDataFromViewer[self]];
mx: INT ¬ 0;
my: INT ¬ 0;
ctrlshift: INT ¬ 0;
includeCtrlShift: BOOL ¬ FALSE;
button: ATOM ¬ NIL;
Button: PROC [atom: ATOM] ~ { IF button = NIL THEN button ¬ atom ELSE bogus ¬ TRUE };
action: ATOM ¬ NIL;
Action: PROC [atom: ATOM] ~ { IF action = NIL THEN action ¬ atom ELSE bogus ¬ TRUE };
bogus: BOOL ¬ FALSE;
FOR tail:
LIST
OF
REF ¬ input, tail.rest
UNTIL tail =
NIL
DO
WITH tail.first
SELECT
FROM
z: ScreenCoordsTypes.TIPScreenCoords => {
mx ¬ z.mouseX;
my ¬ z.mouseY;
};
atom:
ATOM => {
SELECT atom
FROM
$Ctrl => { ctrlshift ¬ ctrlshift + 2 };
$Shift => { ctrlshift ¬ ctrlshift + 1 };
$Red => { Button[$left] };
$Yellow => { Button[$middle] };
$Blue => { Button[$right] };
$Track => {
Action[$mouseto];
includeCtrlShift ¬ TRUE;
};
$Down => {
Action[$buttondown];
includeCtrlShift ¬ TRUE;
};
$Up => {
Action[$buttonup];
includeCtrlShift ¬ TRUE;
};
ENDCASE => { Action[atom] };
};
ENDCASE => { bogus ¬ TRUE };
ENDLOOP;
IF action = NIL THEN bogus ¬ TRUE;
IF bogus
THEN
Enqueue[queue, [action: $bogus, args: Reverse[Reverse[input]]]]
ELSE
Enqueue[queue, [action: action, button: button, mx: mx, my: my,
args: IF includeCtrlShift THEN Cons[MakeFixnum[ctrlshift], NIL] ELSE NIL]];
};
RegisterImagerViewers:
PROC [env: Environment] ~ {
DefinePrimitive[name: "color-context", nArgs: 0, optional: 0, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$colorcontext], doc: "get an Imager context for the color display"];
DefinePrimitive[name: "viewer-context", nArgs: 1, optional: 0, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$viewercontext], doc: "make an ImagerViewer named a"];
DefinePrimitive[name: "open-viewer", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$openViewer, env], doc: "([context]) Open the viewer associated with this context"];
DefinePrimitive[name: "viewer-open?", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$viewerOpenP, env], doc: "([context]) Is the viewer associated with this context open?"];
DefinePrimitive[name: "reset-viewer", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$resetViewer, env], doc: "([context]) Reset this context to its inital state"];
DefinePrimitive[name: "erase-viewer", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$eraseViewer, env], doc: "([context]) Clear the viewer associated with this context"];
DefinePrimitive[name: "viewer-read", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$viewerread, env], doc: "([context]) get mouse input associated with an ImagerViewer"];
DefinePrimitive[name: "viewer-input-ready?", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$viewerinputready, env], doc: "([context]) test to see if ImagerViewer mouse input is available"];
DefinePrimitive[name: "bw-display-context", nArgs: 0, optional: 0, dotted: FALSE, proc: ImagerPrim, env: env, data: D[$bwdisplaycontext, env], doc: "make an Imager context for the entire bw display (bypassing the window system)"];
DefinePrimitive[name: "display-screen->pixelmap", nArgs: 1, optional: 1, dotted: FALSE, proc: ImagerPrim, doc: "Make a pixelmap from the display screen of the machine", env: env, data: D[$displayscreentopixelmap, env]];
};