mirror of
https://github.com/antoinevignau/source.git
synced 2024-08-12 06:29:33 +00:00
1 line
7.7 KiB
C++
1 line
7.7 KiB
C++
|
#include <stdio.h>
#include <prodos.h>
#include <string.h>
#include <types.h>
#include <quickdraw.h>
#include <qdaux.h>
#include <window.h>
#include <menu.h>
#include <memory.h>
#include <dialog.h>
#include <control.h>
#include <desk.h>
#include <event.h>
#include <lineedit.h>
#include <misctool.h>
#include <locator.h>
#include <intmath.h>
#include "sc.h"
#include "sp.h"
#include "th.h"
#include <texttool.h>
#define ScreenMode 0x80
#define MaxX 640
int ToolTable[] = {8,
4, 0x100, /* QuickDraw II */
5, 0x100, /* Desk Manager */
6, 0x100, /* Event Manager */
14, 0x100, /* Window Manager */
16, 0x100, /* Control Mnager */
18, 0x100, /* QDAux */
20, 0x100, /* Line Edit */
21, 0x100}; /* Dialog Manager */
extern int _SPErrNum[];
extern pascal char *THDlg();
extern pascal int SPDlg();
extern pascal void SPCloseDlg();
pascal unsigned handler();
char *dictpath;
main(argc,argv)
int argc;
char *argv[];
{
char query[200];
char *z, *junk;
int spelling=1;
if (argc != 2) {
fprintf(stderr,"usage: %s dictionary-directory/\r\n",argv[0]);
exit(1);
}
c2pstr(argv[1]);
dictpath = argv[1];
MTStartUp();
LoadTools(ToolTable);
z = *NewHandle(0x700L, _ownerid, 0xc005, 0L);
QDStartUp((int) z, ScreenMode, 160, _ownerid);
QDAuxStartUp();
EMStartUp((int) (z + 0x300), 20, 0, MaxX, 0, 200, _ownerid);
WindStartUp(_ownerid);
CtlStartUp(_ownerid, (int) (z + 0x500));
LEStartUp((int) (z + 0x600), _ownerid);
DialogStartUp(_ownerid);
DeskStartUp();
IMStartUp();
RefreshDesktop(0L);
ShowCursor();
GrafOff();
SPStartUp(_ownerid, dictpath);
if (_SPErrNum[0])
report_err("SP", _SPErrNum[0]);
printf("Welcome to the Proximity SP/TH demo.\r\nType ! for help\r\n");
while (printf(": "), mygets(query))
{
if (query[0] == '@')
break;
if (query[0] == '#') {
if (!spelling) {
THShutDown();
spelling=1;
printf("Loading spell checker\r\n");
SPStartUp(_ownerid, dictpath);
if (_SPErrNum[0]) {
report_err("SP", _SPErrNum[0]);
continue;
}
}
udictcommand(query);
}
else if (query[0] == '%')
{
if (spelling) {
SPShutDown();
spelling=0;
printf("Loading thesaurus\r\n");
THStartUp(_ownerid, dictpath);
if (_THErrNum[0]) {
report_err("TH", _THErrNum[0]);
continue;
}
}
query[0] = strlen(query) - 1;
GrafOn();
junk = THDlg(query);
GrafOff();
}
else if (query[0] == '!')
printf("To spell-check, simply type a sentence.\r\nTo thesaurize, type %%word.\r\n\nUser dictionary commands:\r\n#open:pathname\r\n#new:pathname\r\n#close:refnum\r\n#edit:refnum\r\n#add:refnum:word\r\n\nTo quit, type ^@ or @ <cr>\r\n\n");
else
{
if (!spelling) {
THShutDown();
spelling=1;
printf("Loading spell checker\r\n");
SPStartUp(_ownerid, dictpath);
if (_SPErrNum[0]) {
report_err("SP", _SPErrNum[0]);
continue;
}
}
GrafOn();
SPCheck(query, NULL, SPMSENT, handler);
SPCloseDlg();
GrafOff();
if (_SPErrNum[0])
report_err("SP", _SPErrNum[0]);
}
}
SPShutDown();
THShutDown();
GrafOff();
IMShutDown();
DeskShutDown();
MenuShutDown();
DialogShutDown();
LEShutDown();
CtlShutDown();
WindShutDown();
EMShutDown();
QDAuxShutDown();
QDShutDown();
MTShutDown();
DisposeHandle(FindHandle(z));
exit(0);
}
fixpath(fname)
char *fname;
{
char tmp[64];
if ((*fname >= '0' && *fname <= '9') || *fname == '/')
return;
strcpy(tmp,fname);
p2cstr(dictpath);
strcpy(fname,dictpath);
c2pstr(dictpath);
strcat(fname,tmp);
}
udictcommand(q)
char *q;
{
int refnum;
char *p;
if (!strncmp(q + 1, "new:", 4))
{
fixpath(q+5);
c2pstr(q + 5);
SPNe
|