mirror of
https://github.com/antoinevignau/source.git
synced 2024-09-29 07:54:50 +00:00
1 line
8.7 KiB
C++
1 line
8.7 KiB
C++
|
#include <types.h>
#include <stdio.h>
#include <quickdraw.h>
#include <qdaux.h>
#include <window.h>
#include <memory.h>
#define dtItemListLength 12
#include <event.h>
#include <dialog.h>
#include <control.h>
#include <lineedit.h>
#include <string.h>
#include <prodos.h>
#include "sp.h"
#include "bl.h"
#include "spdef.h"
#include "driver.h"
#define max(x, y) ((x) > (y) ? (x) : (y))
#define IgnoreI 3
#define SuggestI 2
#define ReplaceI 1
#define DoneI 4
#define AddI 11
#define disableButt 255
#define enableButt 0
extern unsigned _SPID;
static pascal unsigned myfilter();
static pascal void drawWord();
static pascal void selProc();
static char ignoreStr[] = "\pIgnore";
static ItemTemplate ignoreButt =
{ IgnoreI, {68, 24, 80, 134}, buttonItem, ignoreStr, 0, 0, 0L };
static char suggestStr[] = "\pSuggest";
static ItemTemplate suggestButt =
{ SuggestI, {68, 154, 80, 264}, buttonItem, suggestStr, 0, 0, 0L };
static char replaceStr[] = "\pReplace";
static ItemTemplate replaceButt =
{ ReplaceI, {68, 284, 80, 394}, buttonItem, replaceStr, 0, 0, 0L };
static char cancelStr[] = "\pDone";
static ItemTemplate cancelButt =
{ DoneI, {68, 414, 80, 524}, buttonItem, cancelStr, 0, 0, 0L };
static char addStr[] = "\pAdd to Dictionary";
static ItemTemplate addButt =
{ AddI, {50, 284, 62, 524}, buttonItem, addStr, 0, 0, 0L };
static char wordStr[40];
static ItemTemplate wordLine =
{ 5, {8, 289, 18, 523}, statText + itemDisable, wordStr, 0, 0, 0L };
char *sperrs[] =
{ "", "Spelling", "Punctuation", "", "Capitalization", "", "", "",
"Hyphenation"};
static char errStr[40];
static ItemTemplate errLine =
{ 6, {22, 289, 32, 523}, statText + itemDisable, errStr, 0, 0, 0L };
static char replStr[] = "\pReplace with:";
static ItemTemplate replLine =
{ 7, {36, 289, 46, 389}, statText + itemDisable, replStr, 0, 0, 0L };
static ItemTemplate replText =
{ 8, {34, 395, 47, 524}, editLine + itemDisable, NULL, 32, 0, 0L };
static ListRec theList = {
0L,
{7, 22, 59, 238}, /* Box Rect */
{7, 236, 59, 262}, /* ScrollBar Rect */
0,
10, /* Height of 10 (for Shaston) */
1, /* Dbl-Click -> Replace button */
drawWord, /* Draw Proc */
selProc, /* Select Proc */
0L /* No changed proc */
/* reserved array is zeroed too. */
};
static DialogTemplate myDlg =
{
{50, 44, 125, 594}, 1, 0L, {&ignoreButt, &suggestButt, &replaceButt,
&cancelButt, &wordLine, &errLine, &replLine, &replText, &addButt, NULL}
};
char *SPDidnt = "\pCouldn't add word.\rUser dictionary may be corrupt.";
static GrafPortPtr dlgPort;
static char **wlist;
static char **ignorelist;
static int isopen = 0;
extern char *WcurDoc;
static unsigned buttonState=0;
pascal int SPDlg(top, word, err, cor, upd, refnum)
unsigned top; /* Top of dlg in global coords */
char *word; /* Misspelled word */
int err; /* Error spcheck returned */
char *cor; /* Where to put replacement */
void (*upd)(); /* Routine to update what is exposed when dialog
moves; NULL if none. */
int refnum; /* User dict to add to */
{
unsigned x, retval, done = 0;
Point tmpPt;
GrafPortPtr tmpPort;
setbank;
strcpy(wordStr, "Word: ");
p2cstr(word);
strcat(wordStr, word);
c2pstr(word);
c2pstr(wordStr);
strcpy(errStr, "Error: ");
strcat(errStr, sperrs[err]);
c2pstr(errStr);
if (err > 1)
wlist = SPSuggest(NULL, 1);
if (!isopen)
{
myDlg.dtBoundsRect.v2 = (myDlg.dtBoundsRect.v1 = top) + 85;
dlgPort = GetNewModalDialog(&myDlg);
theList.Dialog = dlgPort;
theList.ListSize = (err > 1 ? 1 : 0);
D_BLMAKELIST(&theList);
isopen = 1;
}
else
{
Rect tmpRect;
if (ignorelist) {
char *list;
HLock(ignorelist);
for (list = *ignorelist;*list;) {
unsigned size;
size = *list;
/* same length? equivalent for that length? */
if (size == *word && !strncmp(list+1,word+1,size)) {
/* then we ignore it, because it's the same word */
HUnlock(ignorelist);
ret
|