eudora-mac/peteglue.c

1 line
99 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "peteglue.h" #include "pete.h" #define FILE_NUM 48 /* Copyright (c) 1995 by Qualcomm, Inc. */ /* written by Steven Dorner */ #pragma segment PGLUE OSErr PeteDragTrack(PETEInst pi,PETEHandle ph,DragTrackingMessage message,DragReference theDragRef); Byte PeteLockedAt(PETEHandle pte,long offset); OSErr AppendContextSearch(PETEHandle pte,MenuHandle contextMenu); #define ATTRIBUTION_SCRAP_TYPE 'EuAt' /********************************************************************** * PeteEdit - wrapper for PETEEdit, that also does URL's and dirty bits **********************************************************************/ OSErr PeteEdit(MyWindowPtr win,PETEHandle ph,PETEEditEnum what,EventRecord* event) { OSErr err; long spot; long dirtyWas; Point mouse; Boolean launch; PETEDocInfo info; Str255 attribution; if (!ph && win) ph = win->pte; if (!ph) return(fnfErr); if (what==peeEvent && event->what==keyDown) { if ((*PeteExtra(ph))->not[event->message&charCodeMask]) return(errAEEventNotHandled); } PeteGetTextAndSelection(ph,nil,&spot,nil); // If copying, make an attribution just in case if (what==peeCut || what==peeCopy) { GrabAttribution(ATTR_PASTE_AS_QUOTE,win,attribution); if (*attribution) PCatC(attribution,'\015'); } else *attribution = 0; dirtyWas = PeteIsDirty(ph); MightSwitch(); DragFxxkOff = False; err = PETEEdit(PETE,ph,what,event); DragFxxkOff = True; AfterSwitch(); if (err) return(err); // stick the attribution on the clipboard if (*attribution) PutScrap(*attribution,ATTRIBUTION_SCRAP_TYPE,attribution+1); launch = (win && what==peeEvent && event->what==mouseDown && (ClickType==Double || (event->modifiers & cmdKey))); if (launch && ClickType==Double) { GetMouse(&mouse); LocalToGlobal(&mouse); if (ABS(mouse.h-event->where.h)>3 || ABS(mouse.v-event->where.v)>3) launch = False; } if (launch && ClickType==Double) { PETEGetDocInfo(PETE,ph,&info); if (!info.doubleClick) launch = False; } if (launch) { mouse = event->where; GlobalToLocal(&mouse); if (!PtInPETEView(mouse,ph)) launch = False; } if (launch) { if (!AttIsSelected(win,ph,-1,-1,attAll+(MainEvent.modifiers&controlKey?attFinder:0),nil,nil)) if (urlNot==URLIsSelected(win,ph,-1,-1,urlOpen|urlSelect,nil,nil)) if (ClickType==Single) SlackURL(win,ph,-1,-1,urlAll,nil,nil); } if (dirtyWas!=PeteIsDirty(ph)) PeteSetURLRescan(ph,spot);