<<>> <> <> <> <> DIRECTORY Commander, CommanderOps, IO, PCRCmdGlue, Rope, UXStrings ; PCRCmdImpl: CEDAR PROGRAM IMPORTS Commander, CommanderOps, PCRCmdGlue, IO, Rope, UXStrings EXPORTS ~ { CString: TYPE ~ UXStrings.CString; <> 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]; }; <> 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"]]; }; <
> RegisterPCRCmd[]; RegisterPCedarCmdWithPCR[]; }.