Support cut/copy/paste/clear operation on the LineEdit control.
This commit is contained in:
parent
91c2707cf3
commit
ed3292dbc1
53
afpcdev.c
53
afpcdev.c
|
@ -14,7 +14,9 @@
|
||||||
#include <control.h>
|
#include <control.h>
|
||||||
#include <resources.h>
|
#include <resources.h>
|
||||||
#include <stdfile.h>
|
#include <stdfile.h>
|
||||||
|
#include <lineedit.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <desk.h>
|
||||||
#include <finder.h>
|
#include <finder.h>
|
||||||
#include "afpurlparser.h"
|
#include "afpurlparser.h"
|
||||||
#include "cdevutil.h"
|
#include "cdevutil.h"
|
||||||
|
@ -339,8 +341,7 @@ err:
|
||||||
|
|
||||||
void DoSave(void)
|
void DoSave(void)
|
||||||
{
|
{
|
||||||
Boolean sfStatus, loadedSF = FALSE, allocatedDP = FALSE, startedSF = FALSE;
|
Boolean loadedSF = FALSE, startedSF = FALSE, completedOK = FALSE;
|
||||||
Boolean completedOK = FALSE;
|
|
||||||
Handle dpSpace;
|
Handle dpSpace;
|
||||||
AFPURLParts urlParts;
|
AFPURLParts urlParts;
|
||||||
|
|
||||||
|
@ -360,18 +361,13 @@ void DoSave(void)
|
||||||
attrLocked|attrFixed|attrNoCross|attrBank|attrPage, 0x000000);
|
attrLocked|attrFixed|attrNoCross|attrBank|attrPage, 0x000000);
|
||||||
if (toolerror())
|
if (toolerror())
|
||||||
goto err;
|
goto err;
|
||||||
allocatedDP = TRUE;
|
|
||||||
SFStartUp(GetCurResourceApp(), (Word) *dpSpace);
|
SFStartUp(GetCurResourceApp(), (Word) *dpSpace);
|
||||||
if (toolerror())
|
|
||||||
goto err;
|
|
||||||
startedSF = TRUE;
|
startedSF = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initially proposed file name = volume name */
|
/* Initially proposed file name = volume name */
|
||||||
origNameString.length = strlen(urlParts.volume);
|
origNameString.length = strlen(urlParts.volume);
|
||||||
if (origNameString.length > sizeof(origNameString.text))
|
strcpy(origNameString.text, urlParts.volume); /* OK since VOLUME_MAX < 32 */
|
||||||
origNameString.length = sizeof(origNameString.text);
|
|
||||||
strncpy(origNameString.text, urlParts.volume, sizeof(origNameString.text));
|
|
||||||
|
|
||||||
/* Get the file name */
|
/* Get the file name */
|
||||||
memset(&sfReplyRec, 0, sizeof(sfReplyRec));
|
memset(&sfReplyRec, 0, sizeof(sfReplyRec));
|
||||||
|
@ -398,10 +394,10 @@ void DoSave(void)
|
||||||
err:
|
err:
|
||||||
if (!completedOK)
|
if (!completedOK)
|
||||||
AlertWindow(awResource+awButtonLayout, NULL, saveAliasError);
|
AlertWindow(awResource+awButtonLayout, NULL, saveAliasError);
|
||||||
if (startedSF)
|
if (startedSF) {
|
||||||
SFShutDown();
|
SFShutDown();
|
||||||
if (allocatedDP)
|
|
||||||
DisposeHandle(dpSpace);
|
DisposeHandle(dpSpace);
|
||||||
|
}
|
||||||
if (loadedSF)
|
if (loadedSF)
|
||||||
UnloadOneTool(0x17);
|
UnloadOneTool(0x17);
|
||||||
|
|
||||||
|
@ -439,6 +435,42 @@ long DoMachine(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoEdit(Word op)
|
||||||
|
{
|
||||||
|
CtlRecHndl ctl;
|
||||||
|
GrafPortPtr port;
|
||||||
|
LERecHndl leHandle;
|
||||||
|
LongWord ctlParams;
|
||||||
|
|
||||||
|
if (!wPtr)
|
||||||
|
return;
|
||||||
|
port = GetPort();
|
||||||
|
SetPort(wPtr);
|
||||||
|
|
||||||
|
ctl = FindTargetCtl();
|
||||||
|
if (toolerror() || GetCtlID(ctl) != urlLine)
|
||||||
|
goto ret;
|
||||||
|
|
||||||
|
switch (op) {
|
||||||
|
case cutAction: LECut((LERecHndl) GetCtlTitle(ctl));
|
||||||
|
if (LEGetScrapLen() > 0)
|
||||||
|
LEToScrap();
|
||||||
|
break;
|
||||||
|
case copyAction: LECopy((LERecHndl) GetCtlTitle(ctl));
|
||||||
|
if (LEGetScrapLen() > 0)
|
||||||
|
LEToScrap();
|
||||||
|
break;
|
||||||
|
case pasteAction: LEFromScrap();
|
||||||
|
LEPaste((LERecHndl) GetCtlTitle(ctl));
|
||||||
|
break;
|
||||||
|
case clearAction: LEDelete((LERecHndl) GetCtlTitle(ctl));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret:
|
||||||
|
SetPort(port);
|
||||||
|
}
|
||||||
|
|
||||||
LongWord cdevMain (LongWord data2, LongWord data1, Word message)
|
LongWord cdevMain (LongWord data2, LongWord data1, Word message)
|
||||||
{
|
{
|
||||||
long result = 0;
|
long result = 0;
|
||||||
|
@ -446,6 +478,7 @@ LongWord cdevMain (LongWord data2, LongWord data1, Word message)
|
||||||
switch(message) {
|
switch(message) {
|
||||||
case MachineCDEV: result = DoMachine(); break;
|
case MachineCDEV: result = DoMachine(); break;
|
||||||
case HitCDEV: DoHit(data2); break;
|
case HitCDEV: DoHit(data2); break;
|
||||||
|
case EditCDEV: DoEdit(data1 & 0xFFFF); break;
|
||||||
case InitCDEV: wPtr = (WindowPtr)data1; break;
|
case InitCDEV: wPtr = (WindowPtr)data1; break;
|
||||||
case CloseCDEV: wPtr = NULL; break;
|
case CloseCDEV: wPtr = NULL; break;
|
||||||
case EventsCDEV: modifiers = ((EventRecordPtr)data1)->modifiers;
|
case EventsCDEV: modifiers = ((EventRecordPtr)data1)->modifiers;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "types.rez"
|
#include "types.rez"
|
||||||
|
|
||||||
resource rCDEVFlags (1) {
|
resource rCDEVFlags (1) {
|
||||||
wantMachine+wantHit+wantInit+wantClose+wantEvents,
|
wantMachine+wantHit+wantInit+wantClose+wantEvents+wantEdit,
|
||||||
1, /* enabled */
|
1, /* enabled */
|
||||||
1, /* version */
|
1, /* version */
|
||||||
1, /* min ROM version */
|
1, /* min ROM version */
|
||||||
|
|
Loading…
Reference in New Issue