1 line
9.6 KiB
C++
Raw Normal View History

2023-03-04 03:45:20 +01:00
#include <types.h> #include <stdio.h> #include <quickdraw.h> #include <qdaux.h> #include <window.h> #include <memory.h> #define dtItemListLength 9 #include <event.h> #include <dialog.h> #include <control.h> #include <lineedit.h> #include <string.h> #include <misctool.h> #include <gsos.h> #include "sp.h" #include "spdef.h" #include "sc.h" #include "scparam.h" #include "clam.h" #include "environ.h" #include "bl.h" #include "driver.h" #define max(x, y) ((x) > (y) ? (x) : (y)) extern CLAM *_SPudtable[]; extern char **_SPudpn[]; static int strhpcmp(); extern CLAM *clamalloc(); static pascal unsigned udfilter(); static pascal void drawWord(); static pascal void selProc(); static wListSize; static char ****wList; /* Handle to an array of handles to strings */ static int doingword, doingsel; static char texStr[] = "\pEdit User Dictionary"; static ItemTemplate texLine = { 8, {5, 25, 17, 200}, statText + itemDisable, texStr, 0, 0, 0L }; static char addStr[] = "\pAdd Word"; static ItemTemplate addButt = { 1, {42, 325, 54, 445}, buttonItem, addStr, 0, 0, 0L }; static char removeStr[] = "\pRemove Word"; static ItemTemplate removeButt = { 4, {58, 325, 70, 445}, buttonItem, removeStr, 0, 0, 0L }; static char okStr[] = "\pOK"; static ItemTemplate okButt = { 3, {74, 325, 86, 445}, buttonItem, okStr, 0, 0, 0L }; static char cancelStr[] = "\pCancel"; static ItemTemplate cancelButt = { 2, {90, 325, 102, 445}, buttonItem, cancelStr, 0, 0, 0L }; static ItemTemplate wordLine = { 5, {20, 290, 33, 480}, editLine + itemDisable, NULL, MAXWORD, 0, 0L }; static ListRec theList = { 0L, {20, 25, 102, 241}, /* Box Rect */ {20, 239, 102, 265},/* ScrollBar Rect */ 0, 10, /* Height of 10 (for Shaston) */ 0, drawWord, /* Draw Proc */ selProc, /* Select Proc */ 0L /* No changed proc */ /* reserved array is zeroed too. */ }; static DialogTemplate myDlg = { {35, 60, 145, 575}, 1, 0L, { &addButt, &removeButt, &okButt, &cancelButt, &wordLine, &texLine, NULL} }; static GrafPortPtr dlgPort; char *fullmsg = "\pChanges to the dictionary could not be saved."; /* Interactively edit a User Dictionary. The UDict must have been opened with SPOpenUDict. */ pascal void _SPEditUDict(refnum,addpath) unsigned refnum; /* User Dict reference number */ char *addpath; /* Text file to add to udict */ { char wBuf[2 * MAXWORD]; unsigned flags; int done, cancelled, x, init; char **temp; int thefile; CLAM *cp; char *thePath; char *pos; int wSel; unsigned Umodflag; if (!_SPActive[0]) SPErr2(SPINACTIVE, 0); _SPErrNum[0] = 0; _SPTHID[0] = _SPID; wListSize = doingword = doingsel = 0; --refnum; if (refnum < 0 || refnum >= SPMAXUDICT) SPErr2(SPBADREF, 0); if (!_SPudtable[refnum]) SPErr2(SPBADREF, 0); Umodflag = 0; wList = (char ****) NewHandle(0L, _SPID, 0x0010, 0L); /* Read in udict */ Sccurlist = (char *) _SPudtable[refnum]; init = TRUE; while (clamnext(wBuf, &flags, init, _SPudtable[refnum]) != CL_EOF) { char **hdl; unsigned i; init = FALSE; SetHandleSize(GetHandleSize(wList) + 4, wList); hdl = (char **) NewHandle(80L,_SPID,0x8010,0L); undoflags(wBuf,flags,*hdl); i = strlen(*hdl) + 1; HUnlock(hdl); SetHandleSize((unsigned long) i,hdl); (*wList)[wListSize++] = hdl; } /* <09> ASCII DICT if (addpath) { char **hdl; unsigned i; /* open the ascii file * for (;;) { /* read a word (up to a carriage return,space,newline,tab [max 32 char]) * break; /* add it to the list * i = strlen(*hdl) + 1; HUnlock(hdl); SetHandleSize((unsigned long) i,hdl); (*wList)[wListSize++] = hdl; } Umodflag = 1; } */ HLock(wList); clamclose(_SPudtable[refnum]); /* Close User.Dictionary */ /* Sort it quickly. We can use insertion for addword, but not here. UDicts could be large. */ qsort(*wList, wListSize, 4, strhpcmp); dlgPort = GetNewModalDialog(&myDlg); HiliteControl(255, GetControlDItem(dlgPort, 1)); HiliteControl(