CursorsImpl.mesa; written by S. McGregor
Last Edited by McGregor, July 21, 1983 2:18 pm
Last Edited by: Maxwell, January 3, 1983 1:55 pm
Last Edited by: Wyatt, October 31, 1983 11:18 am
DIRECTORY
Cursors,
Inline USING[BITNOT, BITOR],
Interminal USING [SetCursorOffset, SetCursorPattern];
CursorsImpl: CEDAR MONITOR
IMPORTS Inline, Interminal
EXPORTS Cursors
= BEGIN OPEN Cursors;
global variables and types
globalInfo: PUBLIC CursorInfo ← [last, 0, 0, FALSE];
globalBits: CursorArray;
lastUsedCursor: CursorType ← LAST[PredefinedCursor];
cursors: ARRAY CursorType OF CursorHandle ← ALL[NIL];
procedures
InitializePredefinedCursors: PROC = {
DefineCursor: ENTRY PROC[info: CursorInfo, bits: CursorArray] = {
type: CursorType = info.type;
IF type NOT IN PredefinedCursor OR cursors[type]#NIL THEN ERROR;
cursors[type] ← NEW[CursorRec ← [info, bits]];
};
DefineCursor[info: [bullseye, -7,-7, FALSE],
bits: [
003700B, 007740B, 014060B, 030030B,
060014B, 140006B, 141606B, 141606B,
141606B, 140006B, 060014B, 030030B,
014060B, 007740B, 003700B, 000000B] ];
DefineCursor[info: [hourGlass, -7,-7, FALSE],
bits: [
177777B, 100001B, 040002B, 034034B,
017170B, 007560B, 003740B, 001700B,
001100B, 002440B, 04220B, 010610B,
021704B, 047762B, 177777B, 177777B] ];
DefineCursor[info: [menu, 0,-7, FALSE],
bits: [
000000B, 000000B, 000000B, 001000B,
003001B, 007003B, 036007B, 177776B,
177776B, 036007B, 007003B, 003001B,
001000B, 000000B, 000000B, 000000B] ];
DefineCursor[info: [scrollUpDown, -7,-7, FALSE],
bits: [
000400B, 001600B, 003700B, 007740B,
017760B, 001600B, 001600B, 001600B,
001600B, 001600B, 001600B, 017760B,
007740B, 003700B, 001600B, 000400B] ];
DefineCursor[info: [textPointer, 0,0, FALSE],
bits: [
100000B, 140000B, 160000B, 170000B,
174000B, 176000B, 177000B, 170000B,
154000B, 114000B, 006000B, 006000B,
003000B, 003000B, 001400B, 001400B] ];
DefineCursor[info: [activate, -7,-7, FALSE],
bits: [
177777B, 177777B, 140003B, 140003B,
140003B, 140003B, 140003B, 140003B,
140003B, 140003B, 140003B, 140003B,
140003B, 140003B, 177777B, 177777B] ];
DefineCursor[info: [blank, 0,0, FALSE],
bits: [
000000B, 000000B, 000000B, 000000B,
000000B, 000000B, 000000B, 000000B,
000000B, 000000B, 000000B, 000000B,
000000B, 000000B, 000000B, 000000B] ];
DefineCursor[info: [confirm, 0,0, FALSE],
bits: [
000000B, 000000B, 167227B, 105324B,
105326B, 105264B, 167224B, 000000B,
000000B, 073642B, 022266B, 023652B,
022442B, 072242B, 000000B, 000000B] ];
DefineCursor[info: [crossHairsCircle, -7,-7, FALSE],
bits: [
001700B, 007760B, 014630B, 030614B,
060606B, 040602B, 140603B, 177177B,
177177B, 140603B, 040602B, 060606B,
030614B, 014630B, 007760B, 001700B] ];
DefineCursor[info: [ftp, -7,-7, FALSE],
bits: [
000177B, 076077B, 040037B, 040017B,
070007B, 043703B, 040401B, 040400B,
000400B, 100436B, 140421B, 160421B,
170036B, 174020B, 176020B, 177020B] ];
DefineCursor[info: [typeKey, -7,-7, FALSE],
bits: [
002000B, 074000B, 140000B, 012767B,
012525B, 053566B, 111113B, 163100B,
000000B, 000000B, 154000B, 053520B,
062520B, 053360B, 155440B, 000140B] ];
DefineCursor[info: [move, -7,-7, FALSE],
bits: [
000000B, 000000B, 000000B, 014030B,
016070B, 017170B, 017770B, 015730B,
014630B, 014030B, 014030B, 014030B,
014030B, 000000B, 000000B, 000000B] ];
DefineCursor[info: [mouseBlue, -2,0, FALSE],
bits: [
037770B, 020010B, 025350B, 025350B,
025350B, 025350B, 025350B, 020010B,
020010B, 020010B, 020010B, 020010B,
020010B, 020010B, 020010B, 037770B] ];
DefineCursor[info: [mouseRed, -2,0, FALSE],
bits: [
037770B, 020010B, 027250B, 027250B,
027250B, 027250B, 027250B, 020010B,
020010B, 020010B, 020010B, 020010B,
020010B, 020010B, 020010B, 037770B] ];
DefineCursor[info: [mouseYellow, -2,0, FALSE],
bits: [
037770B, 020010B, 025650B, 025650B,
025650B, 025650B, 025650B, 020010B,
020010B, 020010B, 020010B, 020010B,
020010B, 020010B, 020010B, 037770B] ];
DefineCursor[info: [grow, 0,0, FALSE],
bits: [
000000B, 000000B, 000000B, 003740B,
007760B, 006060B, 014000B, 014370B,
014370B, 014030B, 006060B, 007760B,
003740B, 000000B, 000000B, 000000B] ];
DefineCursor[info: [pointDown, -7,-15, FALSE],
bits: [
001700B, 001700B, 001700B, 001700B,
001700B, 001700B, 001700B, 001700B,
001700B, 001700B, 037774B, 017770B,
007760B, 003740B, 001700B, 000600B] ];
DefineCursor[info: [pointLeft, 0,-7, FALSE],
bits: [
000000B, 000000B, 020000B, 060000B,
016000B, 036000B, 077777B, 177777B,
177777B, 077777B, 036000B, 016000B,
060000B, 020000B, 000000B, 000000B] ];
DefineCursor[info: [pointRight, -15,-7, FALSE],
bits: [
000000B, 000000B, 000040B, 000060B,
000070B, 000074B, 177776B, 177777B,
177777B, 177776B, 000074B, 000070B,
000060B, 000040B, 000000B, 000000B] ];
DefineCursor[info: [pointUp, -7,0, FALSE],
bits: [
000600B, 001700B, 003740B, 007760B,
017770B, 037774B, 001700B, 001700B,
001700B, 001700B, 001700B, 001700B,
001700B, 001700B, 001700B, 001700B] ];
DefineCursor[info: [questionMark, -7,-7, FALSE],
bits: [
017000B, 037600B, 060600B, 140300B,
140300B, 060300B, 000600B, 001400B,
003000B, 006000B, 006000B, 006000B,
000000B, 000000B, 006000B, 006000B] ];
DefineCursor[info: [retry, -7,-7, FALSE],
bits: [
036370B, 021200B, 021200B, 036347B,
024200B, 022200B, 021370B, 000000B,
000000B, 175721B, 021052B, 021044B,
021704B, 021204B, 021104B, 021044B] ];
DefineCursor[info: [scrollDown, -7,-7, FALSE],
bits: [
007760B, 007760B, 007760B, 007760B,
007760B, 007760B, 007760B, 007760B,
007760B, 077776B, 037774B, 017770B,
007760B, 003740B, 001700B, 000600B] ];
DefineCursor[info: [scrollLeft, -7,-7, FALSE],
bits: [
000000B, 001000B, 003000B, 007000B,
017777B, 037777B, 077777B, 177777B,
177777B, 077777B, 037777B, 017777B,
007000B, 003000B, 001000B, 000000B] ];
DefineCursor[info: [scrollLeftRight, -7,-7, FALSE],
bits: [
000000B, 000000B, 000000B, 004020B,
014030B, 034034B, 077776B, 177777B,
177777B, 077776B, 034034B, 014030B,
004020B, 000000B, 000000B, 000000B] ];
DefineCursor[info: [scrollUp, -7,-7, FALSE],
bits: [
000600B, 001700B, 003740B, 007760B,
017770B, 037774B, 077776B, 007760B,
007760B, 007760B, 007760B, 007760B,
007760B, 007760B, 007760B, 007760B] ];
DefineCursor[info: [scrollRight, -7,-7, FALSE],
bits: [
000000B, 000100B, 000140B, 000160B,
177770B, 177774B, 177776B, 177777B,
177777B, 177776B, 177774B, 177770B,
000160B, 000140B, 000100B, 000000B] ];
};
SetCursor: PUBLIC ENTRY PROC [type: CursorType] = {
globalInfo ← cursors[type].info;
TRUSTED{Interminal.SetCursorPattern[globalBits ← cursors[type].bits]};
TRUSTED{Interminal.SetCursorOffset[globalInfo.hotX, globalInfo.hotY]};
};
InvertCursor: PUBLIC ENTRY PROC = {
FOR n: CARDINAL IN [0..SIZE[CursorArray]) DO
globalBits[n] ← Inline.BITNOT[globalBits[n]];
ENDLOOP;
TRUSTED {Interminal.SetCursorPattern[globalBits]};
globalInfo.inverted ← ~ globalInfo.inverted;
};
NewCursor: PUBLIC ENTRY PROC [bits: CursorArray, hotX, hotY: INTEGER ← 0]
RETURNS [CursorType] = {
lastUsedCursor ← SUCC[lastUsedCursor];
cursors[lastUsedCursor] ← NEW[CursorRec ← [
[lastUsedCursor, hotX, hotY, FALSE],
bits
]];
RETURN[lastUsedCursor];
};
FetchCursor: PUBLIC ENTRY PROC[type: CursorType] RETURNS[CursorHandle] = {
RETURN[cursors[type]];
};
AddCursorCorner: PUBLIC ENTRY PROC [cornerSide: CornerSide] = {
i: CARDINAL[0..15];
SELECT cornerSide FROM
upperLeft =>
{
globalInfo.hotX ← globalInfo.hotY ← 0;
globalBits[0] ← 177777B;
globalBits[1] ← 177777B;
FOR i IN [2..16) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 140000B];
ENDLOOP;
};
upperRight =>
{
globalInfo.hotX ← -15;
globalInfo.hotY ← 0;
globalBits[0] ← 177777B;
globalBits[1] ← 177777B;
FOR i IN [2..16) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 000003B];
ENDLOOP;
};
lowerLeft =>
{
globalInfo.hotX ← 0;
globalInfo.hotY ← -15;
globalBits[14] ← 177777B;
globalBits[15] ← 177777B;
FOR i IN [0..14) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 140000B];
ENDLOOP;
};
lowerRight =>
{
globalInfo.hotX ← globalInfo.hotY ← -15;
globalBits[14] ← 177777B;
globalBits[15] ← 177777B;
FOR i IN [0..14) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 000003B];
ENDLOOP;
};
upperSide =>
{
globalBits[0] ← 177777B;
globalBits[1] ← 177777B;
};
lowerSide =>
{
globalBits[14] ← 177777B;
globalBits[15] ← 177777B;
};
leftSide =>
{
FOR i IN [0..16) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 140000B];
ENDLOOP;
};
rightSide =>
{
FOR i IN [0..16) DO
globalBits[i] ← Inline.BITOR[globalBits[i], 000003B];
ENDLOOP;
};
ENDCASE;
TRUSTED {Interminal.SetCursorPattern[globalBits]};
TRUSTED {Interminal.SetCursorOffset[globalInfo.hotX, globalInfo.hotY]};
};
InitializePredefinedCursors[];
END.