X11SchemeServer.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Christian Jacobi, April 24, 1991 5:26 pm PDT
Christian Jacobi, May 10, 1991 12:23 pm PDT
DIRECTORY
Commander, CommanderOps, IO, Rope, Scheme, X11EvalServer;
X11SchemeServer: CEDAR PROGRAM
IMPORTS Commander, CommanderOps, IO, Rope, Scheme, X11EvalServer ~
BEGIN
CreateListenerCommand: Commander.CommandProc ~ {
success: BOOL; message: Rope.ROPE;
display: Rope.ROPE ¬ NIL;
selection: Rope.ROPE ¬ "CedarScheme";
userEnv: Scheme.Environment ¬ Scheme.NewEnvironmentStructure[];
DO
arg: Rope.ROPE ¬ CommanderOps.NextArgument[cmd];
IF arg=NIL THEN EXIT;
SELECT TRUE FROM
Rope.Equal[arg, "-display", FALSE] => display ¬ CommanderOps.NextArgument[cmd];
Rope.Equal[arg, "-selection", FALSE] => selection ¬ CommanderOps.NextArgument[cmd];
ENDCASE => CommanderOps.Failed["unknown argument"];
ENDLOOP;
[success, message] ¬ X11EvalServer.Create[server: display, selection: selection, proc: CommandProc, environment: userEnv];
IF success
THEN msg ¬ "ok"
ELSE {
msg ¬ Rope.Concat["selection ownership not established ", message];
result ¬ $Failure
};
};
CommandProc: PROC [in: Rope.ROPE, environment: REF] RETURNS [out: Rope.ROPE ¬ NIL, result: REF ¬ NIL] = {
inStream, outStream: IO.STREAM;
userEnv: Scheme.Environment ¬ NARROW[environment];
inStream ¬ IO.RIS[in];
outStream ¬ IO.ROS[];
Scheme.ReadEvalPrintLoop[inStream, outStream, userEnv];
out ¬ IO.RopeFromROS[outStream];
};
Commander.Register["X11SchemeServer", CreateListenerCommand, "create an interop scheme listener"];
END.