eudora-mac/spell.c

1 line
28 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SPELL_H #include "spell.h" #include "ssce.h" #endif #pragma segment Spell #ifdef WINTERTREE #define FILE_NUM 74 #define SPELL_OPT_MASK 0xf #define SPELL_SUGGEST_BOTH (1L<<20) Boolean SpellWordKnown(PStr word,PStr replace); short SpellOpenLexDir(FSSpecPtr inSpec); OSErr SpellOpenLex(FSSpecPtr spec); void SpellGetCurrentWord(PStr word,Boolean *checked,Boolean *writeable, Boolean *misspelled,long *start,long *stop); void SpellSuggestions(PStr word,UHandle *suggestions); OSErr SpellReplace(PETEHandle pte,PStr replaceMe); OSErr SpellRemove(PETEHandle pte); OSErr SpellAdd(PETEHandle pte); OSErr SpellNext(PETEHandle pte); OSErr SpellMakeUserDict(FSSpecPtr dirSpec,short id); static SpellInUse; static SpellUserDict = -1; static SpellUserADict = -1; static SpellTicks; /************************************************************************ * SpellOpen - open a spelling session ************************************************************************/ short SpellOpen(void) { FSSpec mySpec; short howMany=0; long domains[]={kNetworkDomain,kSystemDomain,kLocalDomain,kUserDomain}; FSSpec oldSpec; short n = sizeof(domains)/sizeof(domains[0]); Zero(oldSpec); if (!HaveSpeller()) return(-1); SpellInUse++; if (SpellSession<0) { SpellSession = SSCE_OpenSession(); SpellTicks = TickCount(); if (SpellSession>=0) { SpellUserDict = SpellUserADict = -1; // Eudora Folder:Eudora Items: mySpec.vRefNum = ItemsFolder.vRef; mySpec.parID = ItemsFolder.dirId; *mySpec.name = 0; if (!SubFolderSpecOf(&mySpec,SPELL_DICTS,false,&mySpec)) howMany += SpellOpenLexDir(&mySpec); // Eudora Folder: mySpec.vRefNum = Root.vRef; mySpec.parID = Root.dirId; *mySpec.name = 0; if (!SubFolderSpecOf(&mySpec,SPELL_DICTS,false,&mySpec)) howMany += SpellOpenLexDir(&mySpec); // Application Support:Eudora: while (n-->0) if (!FindSubFolderSpec(domains[n],kApplicationSupportFolderType,EUDORA_EUDORA,false,&mySpec)) if (!SameSpec(&mySpec,&oldSpec)) { oldSpec = mySpec; if (!SubFolderSpecOf(&mySpec,SPELL_DICTS,false,&mySpec)) howMany += SpellOpenLexDir(&mySpec); } // Eudora Stuff: if (!StuffFolderSpec(&mySpec)) if (!SubFolderSpecOf(&mySpec,SPELL_DICTS,false,&mySpec)) howMany += SpellOpenLexDir(&mySpec); // Do we need to make the user dictionaries? if (SpellUserDict<0 || SpellUserADict<0) { mySpec