SlateSessionsImpl.mesa
Copyright Ó 1993 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 2, 1993 2:03:48 pm PDT
Christian Jacobi, July 2, 1993 2:55 pm PDT
DIRECTORY
Commander,
IO,
RefTab,
Rope,
Slate,
SymTab;
SlateSessionsImpl: CEDAR MONITOR
IMPORTS Commander, IO, RefTab, Rope, Slate, SymTab ~
BEGIN
sessionTable: SymTab.Ref ~ SymTab.Create[case: FALSE]; -- associates: name -> session
namesTable: RefTab.Ref ~ RefTab.Create[]; -- associates: session -> name
WatchSessionEvent: Slate.EventProc = {
--Called on new sessions or renamed sessions
--
--Remove old existence
WITH RefTab.Fetch[namesTable, session].val SELECT FROM
name: Rope.ROPE => [] ¬ SymTab.Delete[sessionTable, name];
ENDCASE => {};
[] ¬ RefTab.Delete[namesTable, session];
--Introduce new existence
IF session#NIL THEN {
newName: Rope.ROPE ¬ Slate.SessionName[session];
IF ~Rope.IsEmpty[newName] THEN {
[] ¬ RefTab.Store[namesTable, session, newName];
[] ¬ SymTab.Store[sessionTable, newName, session];
};
};
};
FindSessionEvent: Slate.EventProc = {
--Called on create instance to find a named session
WITH callData SELECT FROM
rra: REF REF ANY =>
WITH rra­ SELECT FROM
r: Rope.ROPE => {
WITH SymTab.Fetch[sessionTable, r].val SELECT FROM
s: Slate.Session => rra­ ¬ s;
ENDCASE => {};
};
ENDCASE => {};
ENDCASE => {};
};
SlateSessionsCommand: Commander.CommandProc = {
Each: SymTab.EachPairAction = {
IO.PutRope[cmd.out, key]; IO.PutChar[cmd.out, '\n]
};
[] ¬ SymTab.Pairs[sessionTable, Each];
};
Slate.RegisterGlobalEventProc[$NewSession, WatchSessionEvent];
Slate.RegisterGlobalEventProc[$SessionRenamed0, WatchSessionEvent];
Slate.RegisterGlobalEventProc[$FindSession, FindSessionEvent];
Commander.Register["SlateSessions", SlateSessionsCommand, "list active slate sessions\n"];
END.