home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
clintsrc.sit
/
DAundo.c
< prev
next >
Wrap
Text File
|
1990-06-20
|
4KB
|
178 lines
/*========================================================================
=== DAundo.c
===
=== Greg Anderson
=== 29 Kerr Hall
=== Social Sciences Computing
=== University of California at Santa Cruz
=== Santa Cruz CA 95062
===
=== (408) 459-2658
=== sirkm@ssyx.ucsc.edu
===
=== Text undo routines.
===
=== This code was never debugged, so all of the routines were removed.
========================================================================*/
#include <types.h>
#include <osutils.h>
#include <memory.h>
#include <devices.h>
#include <events.h>
#include <quickdraw.h>
#include <fonts.h>
#include <windows.h>
#include <files.h>
#include <errors.h>
#include <toolutils.h>
#include <packages.h>
#include <Limits.h>
#include <Controls.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Desk.h>
#include <Scrap.h>
#include <Traps.h>
#include <Lists.h>
#include <Menus.h>
#include "unixDA.h"
#include "DA.h"
/*----------------------------------------------------------------------
| Clear out the current Undo record
----------------------------------------------------------------------*/
zapUndo( DCtlPtr dCtl )
{
if( DA_global->undoText )
{
TEDispose( DA_global->undoText );
DA_global->undoText = (TEHandle) 0L;
}
DA_global->undoType = undoNothing;
}
/*----------------------------------------------------------------------
| Set the Undo record up before executing a 'Cut' command
----------------------------------------------------------------------*/
setUndoCut( DCtlPtr dCtl )
{
TEHandle saveScrap;
Handle theScrap;
Rect anyRect;
char *p;
long selLen = ((*DA_te)->selEnd - (*DA_te)->selStart);
return;
/*
* Save the TE scrap, as we are going to 'borrow' it for a moment.
*/
SetRect(&anyRect,0,0,400,200);
saveScrap = TENew(&anyRect,&anyRect);
TEPaste( saveScrap );
/*
* Clear out the old undo info and put in the new
*/
zapUndo( dCtl );
/*
* Create a new textEdit record & copy the selected
* text into it.
*/
DA_global->undoText = TENew(&anyRect,&anyRect);
/*
* This is the old (and simple) way of doing things. It
* didn't work, so I tried something more straightforward
*
* TECopy( DA_te );
* TEPaste( DA_global->undoText );
*
*
* The code inside of the 'if(selLen)' replaces the copy and
* paste above. It does not work either.
*/
if( selLen )
{
theScrap = (Handle) TEGetText( DA_te );
HLock( theScrap );
p = *theScrap;
p += (*DA_te)->selStart;
TESetText( p,selLen,DA_global->undoText);
HUnlock( theScrap );
}
/*
* Set the undo type & starting location
*/
DA_global->undoType = undoCut;
DA_global->undoFrom = (*DA_te)->selStart;
DA_global->undoTo = DA_global->undoFrom;
/*
* Time to restore the TE scrap
*/
TESetSelect( 0, kMaxTELength, saveScrap );
TECopy( saveScrap );
TEDispose( saveScrap );
}
/*----------------------------------------------------------------------
| Set the Undo record up before executing a 'paste' command
----------------------------------------------------------------------*/
setUndoPaste( DCtlPtr dCtl )
{
return;
setUndoCut( dCtl );
DA_global->undoTo += TEGetScrapLen();
DA_global->undoType = undoPaste;
}
/*----------------------------------------------------------------------
| Execute an 'undo'
----------------------------------------------------------------------*/
doUndo( DCtlPtr dCtl )
{
HiliteEditMenu();
switch( DA_global->undoType )
{
case undoCut:
case undoPaste:
doUndoPaste( dCtl );
break;
}
adjustScrollbars(DA_window, false);
adjustTE(DA_window);
shortPause();
HiliteMenu(0);
}
/*----------------------------------------------------------------------
| Undo a 'paste' command
----------------------------------------------------------------------*/
doUndoPaste( DCtlPtr dCtl )
{
long total,contig;
return;
PurgeSpace(&total, &contig);
/*
* First get rid of the text that was inserted (if any)
*/
TESetSelect( DA_global->undoFrom, DA_global->undoTo, DA_te );
TEDelete( DA_te );
/*
* Now paste into the whole
*/
TESetScrapLen( 0L );
TESetSelect( 0,kMaxTELength, DA_global->undoText );
TECopy( DA_global->undoText );
/*
setUndoPaste( dCtl );
*/
TEPaste( DA_te );
}