home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
source
/
luschsrc.sit
/
edit.c
< prev
next >
Wrap
Text File
|
1990-05-23
|
2KB
|
108 lines
/********************************************************************************
* edit.c
*
* Edit Command Package
*
* Written by Paco Xander Nathan
* ⌐1990, Motorola Inc. Public domain source code.
********************************************************************************/
#include "applic.h"
#include "window.h"
#include "text.h"
#include "edit.h"
#include "test.h"
/* Handle a key press in a window
*/
void
EditKeyStroke (theWindow, theChar)
register WindowPtr theWindow;
register char theChar;
{
register InfoPtr infoPtr = (InfoPtr) GetWRefCon(theWindow);
GrafPtr savePort;
GetPort(&savePort);
SetPort(theWindow);
TEKey(theChar, infoPtr->item.text.teHdl);
TextSelView(theWindow);
if (!testUser)
infoPtr->dirty = TRUE;
SetPort(savePort);
}
/* Do the selected item from the edit menu
*/
void
EditMenu (theItem)
register short theItem;
{
register WindowPtr theWindow = FrontWindow();
register InfoPtr infoPtr = (InfoPtr) GetWRefCon(theWindow);
register OSErr theError;
GrafPtr savePort;
GetPort(&savePort);
SetPort(theWindow);
if (infoPtr->kind == wkText) {
register TEHandle teHdl = infoPtr->item.text.teHdl;
/* Handle individual items
*/
switch (theItem) {
case emUndo:
break;
case emCut:
TECut(teHdl);
TextSelView(theWindow);
if (!testUser)
infoPtr->dirty = TRUE;
if ((theError = ZeroScrap()) == noErr)
TEToScrap();
break;
case emCopy:
TECopy(teHdl);
if ((theError = ZeroScrap()) == noErr)
TEToScrap();
break;
case emPaste:
if ((theError = TEFromScrap()) == noErr) {
TEPaste(teHdl);
TextSelView(theWindow);
if (!testUser)
infoPtr->dirty = TRUE;
}
break;
case emClear:
TEDelete(teHdl);
TextSelView(theWindow);
if (!testUser)
infoPtr->dirty = TRUE;
break;
default:
break;
}
}
SetPort(savePort);
}