PCRCmdImpl.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Demers, July 26, 1990 9:53 am PDT
Michael Plass, August 22, 1991 9:33 am PDT
DIRECTORY
Commander,
CommanderOps,
IO,
PCRCmdGlue,
Rope,
UXStrings
;
PCRCmdImpl: CEDAR PROGRAM
IMPORTS Commander, CommanderOps, PCRCmdGlue, IO, Rope, UXStrings
EXPORTS
~ {
CString: TYPE ~ UXStrings.CString;
PCRCmd Command in PCedar Commander
PCRCmdCommandProc: Commander.CommandProc -- [cmd] RETURNS [result, msg] -- ~ {
rawCmdString: CString;
ans: CString;
PutIt: PCRCmdGlue.PutProc -- [msg, nBytes] -- ~ {
IO.PutRope[cmd.out, UXStrings.ToRope[msg, nBytes]];
};
rawCmdString ¬ UXStrings.Create[cmd.commandLine];
ans ¬ PCRCmdGlue.Execute[rawCmdString, PutIt];
IF ans = NIL
THEN RETURN [$Success, NIL]
ELSE RETURN [$Failure, UXStrings.ToRope[ans]];
};
RegisterPCRCmd: PROC ~ {
doc: Rope.ROPE ¬ "PCRCmd expression ; ...\n Execute command in PCR interpreter";
Commander.Register["PCRCmd", PCRCmdCommandProc, doc, NIL, FALSE];
};
PCedarCmd in PCR command loop
PCedarCmdProc: PCRCmdGlue.CommandLineProc -- [cmdLine, putProc, data] RETURNS [result] -- ~ {
cmdLineRope, outRope: Rope.ROPE;
outString: CString;
cmdLineRope ¬ UXStrings.ToRope[cmdLine];
[outRope, result] ¬ CommanderOps.DoCommandRope[cmdLineRope, NIL, NIL];
outString ¬ UXStrings.Create[outRope];
putProc[outString, Rope.Length[outRope]];
};
RegisterPCedarCmdWithPCR: PROC ~ {
[] ¬ PCRCmdGlue.RegisterWithPCRCommandLoop[PCedarCmdProc, NIL, UXStrings.Create["PCedarCmd"], UXStrings.Create[""], UXStrings.Create["pcedar-command -- execute pcedar-command in a PCedar Commander"]];
};
Main line code
RegisterPCRCmd[];
RegisterPCedarCmdWithPCR[];
}.