SimpleStreamsOnXTkImpl.mesa
Copyright Ó 1988, 1989, 1991, 1992 by Xerox Corporation. All rights reserved.
Christian Jacobi, August 26, 1988 11:12:22 am PDT
Christian Jacobi, April 7, 1992 12:35 pm PDT
DIRECTORY
Ascii, IO, Rope, SafeStorage, SimpleStreams, XlAsciiInput, XTkStreamWidgets, XTkShellWidgets, XTkWidgets, Xl, XTk;
SimpleStreamsOnXTkImpl:
CEDAR
MONITOR
IMPORTS IO, SimpleStreams, Xl, XlAsciiInput, XTkShellWidgets, XTkStreamWidgets, XTk
SHARES Xl <<for ConnectionRep>> =
BEGIN
PostCreate: XTk.WidgetNotifyProc = {
inh: XlAsciiInput.Handle;
inh ¬ XlAsciiInput.EnableAsciiInput[widget.connection, widget.window];
XTk.PutWidgetProp[widget, $InputHandle, inh];
};
XCreateSimpleStreams: SimpleStreams.CreateProcType = {
connection: REF ¬ NIL;
stream: XTk.Widget ~ XTkStreamWidgets.CreateStreamWidget[[geometry: XTk.G[300, 200]]];
shell: XTk.Widget ~ XTkShellWidgets.CreateShell[
windowHeader: header,
iconName: header,
className: $SimpleStreams,
child: stream
];
XTk.RegisterNotifier[stream, XTk.postWindowCreationKey, PostCreate];
XTkShellWidgets.SetFocusMethod[shell: shell, focusProtocol: false, inputHint: true];
WITH windowSystem
SELECT
FROM
c: Xl.Connection => IF Xl.Alive[c] THEN connection ¬ c;
w: XTk.Widget => connection ¬ w;
ENDCASE => {};
XTkShellWidgets.BindScreenShell[shell, connection];
XTkShellWidgets.RealizeShell[shell];
in ¬ IO.CreateStream[inputStreamProcs, stream];
out ¬ XTkStreamWidgets.CreateStream[stream];
hasEcho ¬ FALSE;
};
inputStreamProcs:
REF
IO.StreamProcs ¬
IO.CreateStreamProcs[
variety: $input,
class: $XlSimpleStreamsInput,
charsAvail: MyCharsAvail,
getChar: MyGetChar
];
MyGetChar:
PROC [self:
IO.
STREAM]
RETURNS [ch:
CHAR] = {
w: XTk.Widget ~ NARROW[self.streamData];
inh: XlAsciiInput.Handle ~ XTk.GetWidgetProp[w, $InputHandle];
IF inh=NIL OR w.state=dead THEN RETURN [ch¬4C];
ch ¬ XlAsciiInput.GetChar[inh ! XlAsciiInput.WindowDestroyed, Xl.XError => {ch¬4C; CONTINUE}];
};
MyCharsAvail:
PROC [self:
IO.
STREAM, wait:
BOOL]
RETURNS [
INT ¬ 0] = {
w: XTk.Widget ~ NARROW[self.streamData];
inh: XlAsciiInput.Handle ~ XTk.GetWidgetProp[w, $InputHandle];
IF inh#NIL AND w.state#dead THEN RETURN [XlAsciiInput.CharAvailable[inh, wait]]
};
SimpleStreams.ImplementCreate[$X, XCreateSimpleStreams];
SimpleStreams.ImplementCreate[$X11, XCreateSimpleStreams];
SimpleStreams.ImplementCreate[NEW[SafeStorage.Type ¬ CODE[Xl.ConnectionRep]], XCreateSimpleStreams];
SimpleStreams.ImplementCreate[NEW[SafeStorage.Type ¬ CODE[XTk.WidgetRep]], XCreateSimpleStreams];
END.