home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff253.lzh
/
MultiSelect
/
MultiSelect.mod
< prev
next >
Wrap
Text File
|
1989-10-19
|
5KB
|
164 lines
(*---------------------------------------------------------------------------
:Program. MultiSelect.mod
:Author. Fridtjof Siebert
:Address. Nobileweg 67, D-7-Stgt-40
:Shortcut. [fbs]
:Version. 1.0
:Date. 16-Mar-89
:Copyright. PD
:Language. Modula-II
:Translator. M2Amiga v3.1d
:Contents. Enables file-multiselection without using keybord. Just
:Contents. select the first file, then press RMB while you hold LMB
:Contents. down. Then release LMB and select all files and double-
:Contents. select the last one. Then releas RMB.
---------------------------------------------------------------------------*)
MODULE MultiSelect;
FROM SYSTEM IMPORT ADR, LONGSET;
FROM Arts IMPORT Assert, TermProcedure, Terminate;
FROM Exec IMPORT FindPort, MsgPortPtr, Message, MessagePtr, GetMsg,
ReplyMsg, PutMsg, WaitPort, IOStdReq, Interrupt,
IOStdReqPtr, OpenDevice, CloseDevice, DoIO, IOFlagSet,
NodeType, Forbid, Permit;
FROM ExecSupport IMPORT CreatePort, DeletePort, CreateStdIO, DeleteStdIO;
FROM Input IMPORT inputName, addHandler, remHandler;
FROM InputEvent IMPORT InputEvent, InputEventPtr, Class, lButton, rButton,
lShift;
(*------ Constants: ------*)
CONST
PortName = "MultiSelect[fbs].Port";
ReplyName = "MultiSelect[fbs].ReplyPort";
oom = "Not enough memory!";
(*------ VARS: ------*)
VAR
MyMsg: Message;
QuitMessage: MessagePtr;
MyPort, OldPort: MsgPortPtr;
InputDevPort: MsgPortPtr;
InputRequestBlock: IOStdReqPtr;
HandlerStuff: Interrupt;
HandlerActive, InputOpen: BOOLEAN;
ev: InputEventPtr;
leftPressed: BOOLEAN;
shifted: BOOLEAN;
(*------ InputHandler: ------*)
PROCEDURE MyHandler(Ev{8}: InputEventPtr): InputEventPtr; (* $S- *)
BEGIN
ev := Ev;
WHILE ev#NIL DO
WITH ev^ DO
IF class=rawmouse THEN
CASE code OF
lButton: (* left pressed *)
leftPressed := TRUE |
lButton+128: (* left released *)
leftPressed := FALSE |
rButton: (* right pressed *)
IF leftPressed THEN
shifted := TRUE;
class := rawkey;
code := 96;
END |
rButton+128: (* right released *)
IF shifted THEN
shifted := FALSE;
class := rawkey;
code := 224;
END;
ELSE END;
END;
IF shifted THEN INCL(qualifier,lShift) END;
ev := nextEvent;
END;
END;
RETURN Ev;
END MyHandler; (* $S+ *)
(*------ CleanUp: ------*)
PROCEDURE CleanUp();
BEGIN
(*------ Remove Inputhandler: ------*)
IF HandlerActive THEN
WITH InputRequestBlock^ DO
command := remHandler;
data := ADR(HandlerStuff);
END;
DoIO(InputRequestBlock);
END;
IF InputRequestBlock#NIL THEN DeleteStdIO(InputRequestBlock) END;
IF InputDevPort#NIL THEN DeletePort(InputDevPort) END;
(*------ Remove Port: ------*)
IF MyPort#NIL THEN
Forbid();
IF QuitMessage=NIL THEN QuitMessage := GetMsg(MyPort) END;
WHILE QuitMessage#NIL DO
ReplyMsg(QuitMessage);
QuitMessage := GetMsg(MyPort);
END;
DeletePort(MyPort);
Permit();
END;
END CleanUp;
(*------ MAIN: ------*)
BEGIN
(*------ Initialization: ------*)
MyPort := NIL; InputDevPort := NIL; InputRequestBlock := NIL;
HandlerActive := FALSE; InputOpen := FALSE; shifted := FALSE;
leftPressed := FALSE;
TermProcedure(CleanUp);
(*------ Have we already been started? ------*)
OldPort := FindPort(ADR(PortName));
IF OldPort#NIL THEN
MyPort := CreatePort(ADR(ReplyName),0); Assert(MyPort#NIL,ADR(oom));
MyMsg.node.type := message;
MyMsg.replyPort := MyPort;
PutMsg(OldPort,ADR(MyMsg)); WaitPort(MyPort);
DeletePort(MyPort); MyPort := NIL; Terminate(0);
END;
MyPort := CreatePort(ADR(PortName),0); Assert(MyPort#NIL,ADR(oom));
(*------ Add Inputhandler: ------*)
InputDevPort := CreatePort(NIL,0);
Assert(InputDevPort#NIL,ADR(oom));
InputRequestBlock := CreateStdIO(InputDevPort);
Assert(InputRequestBlock#NIL,ADR(oom));
WITH HandlerStuff DO
data := NIL; code := ADR(MyHandler); node.pri := 51;
END;
OpenDevice(ADR(inputName),0,InputRequestBlock,LONGSET{});
IF InputRequestBlock^.error#0 THEN Terminate(0) ELSE InputOpen := TRUE END;
WITH InputRequestBlock^ DO
command := addHandler; data := ADR(HandlerStuff);
END;
DoIO(InputRequestBlock); HandlerActive := TRUE;
(*------ Wait: ------*)
REPEAT WaitPort(MyPort); QuitMessage := GetMsg(MyPort) UNTIL QuitMessage#NIL;
END MultiSelect.