Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site uwmacc.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!pyramid!pesnta!amd!amdcad!lll-crg!seismo!uwvax!uwmacc!dubois From: dubois@uwmacc.UUCP (Paul DuBois) Newsgroups: net.sources.mac Subject: __TEScrap.src (TextEdit Scrap routines for Rascal) Message-ID: <1836@uwmacc.UUCP> Date: Thu, 19-Dec-85 16:47:37 EST Article-I.D.: uwmacc.1836 Posted: Thu Dec 19 16:47:37 1985 Date-Received: Sat, 21-Dec-85 06:22:59 EST Distribution: net Organization: UW-Madison Primate Center Lines: 98 Rascal does not have the "[ Not in ROM ]" routines described in the Text Edit section of Inside Mac for transferring text back and forth between the text scrap and the desk scrap (clipboard), so I took the IMLib stuff posted recently by Andrew Shebanow and adapted the relevant calls to Rascal. Thank you, Andrew. Just compile the source and use it like any other library. --- cut here --- Program __TEScrap; (* Non-ROM TextEdit Scrap-handling routines. Rascal source written 18 December 1985 by Paul DuBois *) Uses __ToolBox, __ToolUtil ; Const TEScrpLength = $0AB0; (* TWO bytes *) TEScrpHandle = $0AB4; Type OSErr = integer; Handle = PtrL; (* these two are lifted from __Memory.src *) PROCEDURE HLock(h: ptrL); { RegCall(trap $A029,h,,)}; PROCEDURE HUnlock(h: ptrL); { RegCall(trap $A02A,h,,)}; (* Return handle to TextEdit scrap *) Func TEScrapHandle (): Handle; { TEScrapHandle := ptrl (TEScrpHandle)^; }; (* Return length of TextEdit scrap *) Func TEGetScrapLen (): longint; { TEGetScrapLen := longint (ptrw (TEScrpLength)^); }; (* Set length of TextEdit scrap *) Proc TESetScrapLen (len : longint); { ptrw (TEScrpLength)^ := integer (len); }; (* Copy the TextEdit scrap to the desk scrap. ZeroScrap should be called first. Actually returns the scrap length, not an OSErr. *) Func TEToScrap (): OSErr; var ScrpHand: Handle; result: longint; { ScrpHand := TEScrapHandle (); HLock (ScrpHand); result := PutScrap (TEGetScrapLen (), $54455854L (* 'TEXT' *), ScrpHand^); HUnlock (ScrpHand); if result > 0 then result := 0; TEToScrap := result; }; (* Copy the desk scrap into the TextEdit scrap. Actually returns the scrap length, not an OSErr. *) Func TEFromScrap (): OSErr; var ScrpHand: ptrl; result, offset: longint; { ScrpHand := TEScrapHandle (); result := GetScrap (ScrpHand, $54455854L (* 'TEXT' *), @offset); if result > 0 then TESetScrapLen (result); TEFromScrap := result; }; (* end __TEScrap.src *) -- | Paul DuBois {allegra,ihnp4,seismo}!uwvax!uwmacc!dubois --+-- | "The voice of the Lord is full of majesty." | Psalm 29:4