Text preview for : WManControl.mesa_Oct77.pdf part of xerox WManControl.mesa Oct77 xerox mesa 3.0_1977 listing WManControl.mesa_Oct77.pdf
Back to : WManControl.mesa_Oct77.pd | Home
WManControl.mesa 26-0CT-77 15:24:43 Page 1
--File: WManControl.mesa
--Edited by Sandman October 7. 1977 9:14 AM
DIRECTORY
AltoDafs: FROM "altodefs".
ControlDefs: FROM "controldefs".
DoubleDefs: FROM "doubledefs".
SegmentDefs: FROM "segmentdefs".
SystemDefs: FROM "systemdefs".
StringOefs: FROM "stringdefs".
StreamOefs: FROM "streamdefs".
InlineDefs: FROM "inlinedefs".
IODefs: FROM "iodefs".
KeyDefs: FROM "keydefs".
MenuDefs: FROM "menudefs".
RectangleDefs: FROM "rectangledefs".
WindowDefs: FROM "windowdefs".
WManagerDefs: FROM "wmanagerdefs";
DEFINITIONS FROM MenuDefs. StreamDefs. RectangleDefs. WindowDefs. WManagerDefs;
WManControl: PROGRAM
IMPORTS DoubleDefs, SegmentOefs, SystemDefs, StringDefs, StreamDefs, RectangleDefs,
WindowDefs, WManagerDefs
EXPORTS WManagerDefs
SHARES WManagerDefs, StreamDefs, MenuDefs =
BEGIN
WMState: WMDataHandle;
--external proc
--global data
CursorA. CursorB, CursorC, CursorD, CursorE,
CursorF, CursorG, CursorH, CursorI: ARRAY[O .. 15] OF INTEGER;
-- Window Manager Main Control Routine
WindowManager: PUBLIC PROCEDURE =
BEGIN OPEN WMState;
-- Declare Locals
x, y,i: INTEGER;
k: KeySet;
char: UNSPECIFIED;
mousewindow: WindowHandle;
buttons: AMouseButton;
cw: WindowHandle ~ GetCurrentDisplayWindow[];
ds: DisplayHandle;
-- check if need to service KeyStream
IF cw.ks # defaultks AND NOT cw.ks.endof[cw.ks] THEN
FOR i IN [0 .. maxscraLch) DO ENABLE StreamDefs.StreamError =) EXIT;
IF scratchfiles[i] = cw.file THEN
BEGIN
ReadEditChar[cw.ks.get[cw.ks], cw];
EXIT ;
END;
ENDLOOP;
cw ~ GetCurrentDisplayWindow[]:
-- check if some part of cursor is in jump bar
[x, y] ~ CursorToRectangleCoords[cw.rectangle. xcursorloc t , ycursorloc t ]:
IF x+slop ) a AND x (; JumpStrip + CursorXAdjust[]
AND y+slop ) a AND y-slop (= cw.rectangle.ch TH[N SetJumpStripe[cw, TRUE]
ELSE SetJumpStripe[cw, FALSE]:
-- check mouse buttons
buttons ~ GetMouseButton[]:
-- look at the mouse and flip from one to the other
cw ~ GetCurrentDisplayWindow[ I StreamOefs.StreamError ;) CONTINUE];
[mousewindow. x. y] ~ findDisplayWindow[xcursorloct. ycursorloc t
! SlreamDefs.Streamfrror ;) CONTINU[];
H cw # mousewindow AND mousewindow # NIL AND buttons # None THEN
BrGIN
SetCurrentDisplayWindow[mousewindow
I SegmentOefs.InvalidrP ;)
BEGIN
SetFileforWindow[mousewindow, mousewindow.name
I SegmenlDefs.FileNameError =)
B[GIN
WManControl.mesa 25-0CT-77 15:24:43 Page 2
AlterWindowType[mousewindow, mousewindow.type, NIL];
CONTINUE;
END
];
RETRY;
END
];
OpenKeyStream[mousewindow.ks I StreamDefs.StreamError =) CONTINUE];
END
ELSE IF buttons = None THEN
BEGIN
IF useKeyset AND (k ~ GetKeySet[]) # a THEN
SELECT k FROM
1B =) StuffSel[cw];
2B =) PutChar[IODefs.CR];
3B =) BEGIN PutChar[IODefs.CR]; StuffSel[cw]; END;
4B =) PutChar[IODefs.ESC];
lOB =) PutChar[IODefs.DEL];
20B =) PutChar[IODefs.BS];
ENDCASE
ELSE IF FL4Down[] THEN
BEGIN StufFSel[cw]; WHILE FL4Down[] DO NULL ENDLOOP; END;
END
ELSE
BEGIN
THROUGH [0 .. 700) DO NULL ENDLOOP; -- Debounce Mouse
ButtonProcArray[GetMouseButton[]][cw, xcursorloc~,ycursorloc~
StreamDefs.StreamError =) CONTINUE];
END;
END;
ReadEditChar: PROCEDURE
[char: CHARACTER, w: WindowHandle]=
BEGIN
--declare locals
index: StreamIndex;
fixup: BOOLE~N ~ FALSE;
firstchar: BOOLEAN ~ TRUE;
ch: CHARACTER;
controlA: CHARACTER lC;
controlH: CHARACTER = laC;
controlW: CHARACTER = 27C;
controlQ: CHARACTER = 21C;
Space: CHARACTER = 40C;
--do editing like ReadEditString
SELECT char FROM
controlA, controlH =)
BEGIN
IF w.ds.charx # leftmargin THEN
BEGIN
index ~ Getlndex[w.file];
w.eoFindex ~ index;
index ~ ModifyIndex[index, -1];
IF EqualIndex[w.selection.rightindex. index] THEN
BEGIN
MarkSelection[w];
Fixup ~ TRUE;
END;
SetIndex[w.file. index];
ch ~ w.File.get[w.file];
StreamDefs.ClearDisplayChar[w.ds. ch);
IF fixup THEN
BEGIN
w.selection.righLx ~ w.ds.charx;
index ~ Modifylndex[index. -1]:
w.selection.righlindex ~ index:
MarkSeleclion[w):
fixup ~ rALSE:
END:
END:
[NO;
controlW. controlQ =)
flrGIN
DO
rr w.ds.charx = leftmurgin THrN EXIT;
index ~ GeLlndex[w.file]:
WManControl.mesa 25-0CT-77 15:24:43 Page 3
index ~ ModifyIndex[index. -1];
IF EqualIndex[w.selection.rightindex. index] THEN
BEGIN
MarkSelection[w];
fixup ~ TRUE;
END;
SetIndex[w.file. index];
w.eofindex ~ index;
ch ~ w.file.get[w.file
I StreamError => EXIT];
IF ch = Space AND NOT firstchar THEN EXIT
ELSE IF ch # Space THEN firstchar ~ FALSE;
StreamDefs.ClearDisplayChar[w.ds. ch];
ENDLOOP:
IF f ixup THEN
BEGIN
index ~ ModifyIndex(index. -1];
w.selection.rightindex ~ index;
w.selection.rightx ~ w.ds.charx:
MarkSelection[w];
fixup ~ FALSE;
END:
END;
ENDCASE =>
MakeOrExtendSelection(w. char]:
END;
MakeOrExtendSelection: PROCEDURE[w: WindowHandle, char: CHARACTER] =
BEGIN OPEN WMState:
-- declare locals
ds: Disp1ayHand1e ~ w.ds;
sel: Selection:
index: StreamIndex ~ GetIndex(w.file]:
-- now make/extend the current selection
IF NOT ds.charx = w.selection.rightx OR EqualIndex[originindex, index] THEN
BEGIN --make this char the current selection
w.ds.put[w.ds, char]:
sel ~ Selection[
1eftx: ds.charx - ComputeCharWidth[char, ds.pfont].
leftline: ds.1ine.
1eftindex: ,index,
rightx: ds.charx.
rightline: ds.1ine,
rightindex: index
]:
END
ELSE
BEGIN -- extend it to include this char
w.ds.put[w.ds, char]:
se1 ~ Se1ection[
1eftx: w.se1ection.1eftx,
1eftline: w.se1ection.leftline.
leftindex: w.se1ection.leftindex,
rightx: ds.charx,
rightline: ds.1ine,
rightindex: index
] ;
END:
MakeSe1ection[w. @se1];
END;
SetJumpStripe: PUBLIC PROCfDURE[w: WindowHand1e, flag: BOOLEAN]
BEGIN OPEN WMState;
-- Declare Locals
r: Rptr = w.rectang1e;
y: yCoord;
bytepos. eof: In1ineDefs.LongCARDINAL;
barhe ight: INTEGER = r.ch-defau1 tl ineheight-2;
barwidlh: INTEGfR = leftmargin-l;
current index: SlreamIndex;
gray: GrayArray ~ [125252B. 52525B, 125252B, 52525B];
grayarray: GrayPtr = @gray;
zeros: GrayArray ~ [0,0.0,0];
zeroarray: GrayPtr = @zeros;
-- check if visible
IF (w.,