X11SelectionRemoved.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Christian Jacobi, January 30, 1991 1:02:46 pm PST
Christian Jacobi, March 22, 1991 11:13 am PST
Stuff which was used in X1Seletion, implemented but then removed.
It might get useful once again
AddXAtomToList: PROC [list: LIST OF Xl.XAtom, atom: Xl.XAtom] RETURNS [LIST OF Xl.XAtom] = {
--Check whether atom already contained in list
FOR l: LIST OF Xl.XAtom ¬ list, l.rest WHILE l#NIL DO
IF l.first=atom THEN RETURN [list];
ENDLOOP;
RETURN [CONS[atom, list]]
};
GetSupportedTargets: PROC [c: Xl.Connection, ac: REF READONLY ApplicationClassRec] RETURNS [supp: LIST OF Xl.XAtom ¬ NIL] = {
cod: ConnectionOData ¬ GetConnectionOData[c];
FOR l: LIST OF Rope.ROPE ¬ ac.supportedTargets, l.rest WHILE l#NIL DO
supp ¬ AddXAtomToList[supp, Xl.MakeAtom[c, l.first]];
supp ¬ AddXAtomToList[supp, cod.multipleXAtom];
supp ¬ AddXAtomToList[supp, cod.timeStampXAtom];
supp ¬ AddXAtomToList[supp, cod.targetsXAtom];
ENDLOOP;
};
XAtomListToSequence: PROC [list: LIST OF Xl.XAtom] RETURNS [sq: REF Xl.Card32Sequence] = {
Count: PROC [l: LIST OF Xl.XAtom, limit: INT ¬ 20] RETURNS [n: INT¬0] = {
WHILE l#NIL DO
IF n>=limit THEN ERROR;
l ¬ l.rest; n ¬ n+1;
ENDLOOP
};
m: INT ¬ 0;
n: INT ¬ Count[list];
sq ¬ NEW[Xl.Card32Sequence[n]];
FOR l: LIST OF Xl.XAtom ¬ list, l.rest WHILE l#NIL DO
sq[m] ¬ l.first;
m ¬ m+1;
ENDLOOP;
};
LongChangeProperty: PROC [
A ChangeProperty implementation which eventually uses multiple requests.
--Standard X arguments
c: Xl.Connection, w: Xl.Window, property: Xl.XAtom, type: Xl.XAtom,
mode: Xl.ChangePropertyMode ¬ replace, --prepend not yet implemented: November 15, 1990
--Data to be used
data: REF ¬ NIL, -- data in standard types like in Xl.ChangeProperty
start: INT ¬ 0, --index of first unit in data
num: INT ¬ INT.LAST, --limits number of units
--Control arguments
maxPieceWords: INT ¬ INT.LAST, --extra limit for maximum words used in single request
mustBeSingleRequest: BOOL ¬ FALSE, --error if requested and data too large
synch: BOOL ¬ FALSE --enables returning eventual errors as Mesa SIGNAL's
];
synchDetails: Xl.Details ¬ NEW[Xl.DetailsRec ¬ [synchronous: TRUE]];
LongChangeProperty: PUBLIC PROC [
--standard X arguments
c: Xl.Connection, w: Xl.Window, property: Xl.XAtom, type: Xl.XAtom,
mode: Xl.ChangePropertyMode ¬ replace, --prepend not yet implemented: November 15, 1990
--data to be used
data: REF ¬ NIL, -- data in standard types like in Xl.ChangeProperty
start: INT ¬ 0, --index of first unit in data
num: INT ¬ INT.LAST, --limits number of units
--control arguments
maxPieceWords: INT ¬ INT.LAST, --extra limit for maximum words used in single request
mustBeSingleRequest: BOOL ¬ FALSE, --error if requested and data too large
synch: BOOL ¬ FALSE --enables returning eventual errors as Mesa SIGNAL's
] = {
requestMaxLength: INT ¬ Xl.Info[c].maxRequestLength;
availableNum: INT; --actual but not used number of units
pu: INT; --pieces per unit
pieceStart: INT ¬ start; --start position of next piece
pieceNum: INT; --number of units per piece
IF mode=prepend THEN ERROR; --NOT YET IMPL (I doubt its usefullness)
[availableNum, pu] ¬ Xl.XPropInfo[data];
pieceNum ¬ MIN[requestMaxLength, maxPieceWords]*pu;
num ¬ MIN[availableNum-start, num];
IF mustBeSingleRequest AND num>pieceNum THEN Xl.ClientError[$RequestToLong];
DO
Xl.ChangeProperty[c: c, w: w, property: property, type: type, mode: mode, data: data, start: pieceStart, num: MIN[num, pieceNum], details: IF synch THEN synchDetails ELSE NIL];
IF num<=pieceNum THEN EXIT;
num ¬ num - pieceNum;
pieceStart ¬ pieceStart + pieceNum;
mode ¬ append;
ENDLOOP
};