Text preview for : WManPosition.mesa_Oct77.pdf part of xerox WManPosition.mesa Oct77 xerox mesa 3.0_1977 listing WManPosition.mesa_Oct77.pdf



Back to : WManPosition.mesa_Oct77.p | Home

WManPosition.mesa 25-0CT-77 15:24:43 Page 1


--File: WManPosition.mesa
--Edited by Sandman October 7, 1977 12:34 PM
DIRECTORY
AltoDefs: FROM "altodefs",
DoubleDefs: FROM "doubledefs",
InlineDefs: FROM "inlinedefs",
StreamDefs: FROM "streamdefs",
MenuDefs: FROM "menudefs",
RectangleDefs: FROM "rectangledefs",
WindowDefs: FROM "windowdefs".
WManagerDefs: FROM "wmanagerdefs";
DEFINITIONS FROM StreamDefs. MenuDefs, RectangleDefs. WindowDefs. WManagerDefs;
WManPos it i on: PROGRAM[WMSta te: WMDataHand 1e]
IMPORTS DoubleDefs, StreamDefs, RectangleDefs, WindowDefs, WManagerOefs
EXPORTS WManagerDefs
SHARES StreamDefs. WManagerDefs =
BEGIN
OPEN WMState;
CR: CHARACTER = 15C;
Space: CHARACTER = 40C;
PositionFile: PUBLIC PROCEDURE[w: WindowHandle. x: xCoord. y: yCoord]=
BEGIN OPEN DoubleDefs;
-- Declare Locals
height: CARDINAL;
bytepos, eof: LongCARDINAL;
index: StreamIndex;
-- compute position in file and set it
SetCursor[arrow];
ButtonWait;
SetCursor[hourglass];
x ~ xcursorloc~; y ~ ycursorloc~;
[x. y] ~ Curs~rToRectangleCoords[w.rectangle. x. y];
-- if out of jump bar then no scrolling
IF NOT CheckForSlop[w. x. y] THEN
BEGIN
SetJumpStripe[w. FALSE];
RETURN;
END;
IF y < default1ineheight+l OR w.eofindex.byte = 177777B THEN index ~ [0. 0]
ELSE
BEGIN OPEN InlineDefs, AltoDefs;
height ~ w.rectang1e.ch-(defaultlineheight+l};
y ~ MIN[LOOPHOLE[y-(defaultlineheight+l}. CARDINAL]. height];
IF y = height THEN index ~ w.eofindex
ELSE
BEGIN
eof ~ DAdd[LongMult[w.eofindex.page. BytesPerPage].
LongCARDINAL[w.eofindex.byte. 0]];
bytepos ~ DDivide[DMultip1y[eof. LongCARDINAL[y. 0]].
LongCAROINAL[height, O]].quotient;
[index.page, index.byte] ~ LongDivMod[bytepos. BytesPerPage] ;
IF index.page > w.eofindex.page OR (index.page w.eofindex.page
AND index.byte > w.eofindex.byte) THEN index .. w.eofindex:
END;
END;
DoTheScroll[w, index];
END;
ScrollUpFile: PUBLIC PROCEOURE[w: Windowlland1e, x: xCoord, y: yCoord]=
BfGIN
-- Declare Locals
index: StreamIndex;
line: INTEGER;
-- compute position in file and set it
SetCursor[uparrow];
ButtonWait;
SetCursor[hourg1ass];
x ~ xcursorloct: y ~ ycursorloc t :
[1 ine . . . index] ~ Reso1veAugToPosition[w. x. y]:
[x. y] ~ CursorToRectangleCoords[w.reclangle, x, y];
-- if out of Jump bar then no scroll in9
W~anPosition,mesa 25-0CT-77 15:24:43 Page 2


IF NOT CheckForSlop[w. x. y] OR line = 1 THEN
BEGIN
SetJumpStripe[w. FALSE];
RETURN;
END;
DoTheScroll[w. index];
END;
ScrollDownFile: PUBLIC PROCEDURE[w: WindowHandle. x: xCoord. y: yCoord]=
BEGIN OPEN OoubleOefs. InlineDefs;
-- Declare Locals
index. posindex: StreamIndex;
maxbackup,pos: LongCARDINAL;
line,nlines: CARDINAL;
nlines ~ (w,rectangle.ch/w.ds.lineheight)-l;
-- compute position in file and set it
SetCursor[downarrowJ;
ButtonWait;
SetCursor[hourglassJ;
x ~ xcursorloc~; y ~ ycursorloc t ;
[x, y] ~ CursorToRectangleCoords[w.rectangle, x, y];
line ~ MIN[lOOPHOlE[MAX[l, y/w.ds.lineheight],CARDINALJ, nlines]:
posindex ~ SELECT w.type FROM
scratch, scriptfile =)
IF w.tempindex = nullindex THEN w.fileindex ELSE w.tempindex,
file =) w.fileindex,
ENDCASE =) originindex;
pos ~ DAdd[longMult[posindex.page, AltoDefs.BytesPerPageJ, [posindex.byte, OJJ:
-- if out of jump bar or first window then nop
IF NOT CheckForSlop[w, x, y] OR EqualIndex[posindex, originindex] THEN
BEGIN
SetJumpStripe[w, FALSE]:
RETURN:
END:
maxbackup ~ longMult[w.rectangle.cw/ComputeCharWidth[Space,w.ds.pfontJ, line]:
IF DCompare[pos, maxbackup] = Comparison[greater] THEN
BEGIN
maxbackup ~ DSub[pos, maxbackup]:
[index. page, index.byte] ~ LongDivMod[maxbackup, AltoDefs.BytesPerPageJ:
END
ELSE index ~ originindex:
index ~ GenerateLineTable[w,index,posindex, line,nlines]:
DoTheScroll[w, index]:
END:
NormalizeSelection: PUBLIC PROCEDURE[w: WindowHandle, x: xCoord, y: yCoord]=
BEGIN OPEN DoubleDefs, InlineDefs:
--Declare locals
linestarts: DESCRIPTOR FOR ARRAY OF StreamIndex:
maxbackup,pos: LongCARDINAL:
index: StreamIndex;
line: INTEGER:
nl ines: CARDINAL:
nlines ~ (w.rectangle.ch/w.ds. lineheight)-1:
linestarts ~ DESCRIPTOR[GetLineTable(], nlines+1]:
-- compute position in file and set it
SetCursor(norm]:
ButtonWait:
SetCursor(hourglass]:
x ~ xcursorlocf; y ~ ycursorloc t :
[x, y] ~ CursorToRectangleCoords[w.rectangle, x, y];
line ~ MIN[MAX[l. y/w.ds.lineheight], nlines]:
-- if out of jump bar then nop
IF NOT CheckForSlop[w, x, yJ THEN
REGIN
SetJumpStripe[w, FALSE];
RETURN;
END;
--if no selection or no scroll, simply move to beginning of file
IF [qualTndex[w.selection.leftindex. null index]
OR (Equallndex[l inestarts[O], ori9 inindex]
AND line> w.selectiofl.leftline)
TllfN index .. originindex
-- selection visible and below bug
FLS[ IF w.selection.leftl ine 1/ 0 AND
(Grfquallndex[w.selection.leftindex, 1 inestarts[l ine-l]]
WManPosition.mesa 25-0CT-77 15:24:43 Page 3


OR l1ne <= 2