eudora-mac/oops.c

1 line
12 KiB
C
Raw 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 "oops.h" #define FILE_NUM 40 /* Copyright (c) 1990-1992 by the University of Illinois Board of Trustees */ /************************************************************************ * routines for undoing editing changes ************************************************************************/ #pragma segment Main Boolean IsTransferUndo(void); short IsTextUndo(MyWindowPtr win); void TextUndo(void); void TransferUndo(void); static OSErr AddXfUndoSum(TOCHandle fromTocH, TOCHandle toTocH, short sumNum, Boolean open); static OSErr TransferUndoBox(XfUndoPtr pxfu, short *pCount, uLong *pTicks); OSErr IMAPTransferDeleteUndo(TOCHandle toTocH, TOCHandle fromTocH, XfUndoPtr pxfu); /************************************************************************ * DoUndo - undo the last undoable operation ************************************************************************/ void DoUndo(void) { MyWindowPtr win = GetWindowMyWindowPtr(FrontWindow_()); OSErr err; #ifdef TWO if (IsTextUndo(win)) { if (err=PeteEdit(win,win->pte,peeUndo,nil)) WarnUser(PETE_ERR,err); } else if (IsTransferUndo()) TransferUndo(); #endif } #ifdef TWO /************************************************************************ * TransferUndo - undo the last xfer for a mailbox ************************************************************************/ static OSErr TransferUndoBox(XfUndoPtr pxfu, short *allCount, uLong *pTicks) { XfUndo xfu = *pxfu; TOCHandle fromTocH,toTocH; short err=0; long sumNum; long origCount; short count; #ifdef NEVER if (RunType!=Production) { Str255 s; DebugStr(ComposeString(s,"\p%p %d %d %p;g", xfu.fromSpec.name, xfu.first, xfu.last, xfu.toSpec.name)); } #endif /* * grab the .toc files */ fromTocH = TOCBySpec(&xfu.fromSpec); toTocH = TOCBySpec(&xfu.toSpec); if (!fromTocH || !toTocH) return 0; if ((*toTocH)->imapTOC) err = IMAPTransferDeleteUndo(toTocH, fromTocH, pxfu); else { origCount = (*fromTocH)->count; for (count = xfu.ids.offset/sizeof(uLong);!err && count;count--,(*allCount)--) { if (!(*allCount%10) || TickCount()-*pTicks>30) { Progress(NoBar,*allCount,nil,nil,nil); *pTicks = TickCount(); } if (err=TOCFindMessByMID((*(uLong**)xfu.ids.data)[count-1],toTocH,&sumNum)) { WarnUser(CANT_XF_UNDO,fnfErr); return err; } err = MoveMessageLo(toTocH,sumNum,&xfu.fromSpec,False,false,true); } }