Added support for MySpell spellchecker

This commit is contained in:
Ianos Gnatiuc 2006-03-11 17:04:06 +00:00
parent dbac4566d8
commit 8a041219e4
24 changed files with 489 additions and 198 deletions

View File

@ -545,9 +545,7 @@ GoldedCfgEdit::GoldedCfgEdit() {
str.push_back(""); cfg.external = str.size()-1; str.push_back(""); cfg.external = str.size()-1;
str.push_back(GOLDED_MSG); cfg.file = str.size()-1; str.push_back(GOLDED_MSG); cfg.file = str.size()-1;
str.push_back("<<"); cfg.hardline = str.size()-1; str.push_back("<<"); cfg.hardline = str.size()-1;
#if defined(GCFG_NOSPELLDLL)
str.push_back(""); cfg.spellchecker = str.size()-1; str.push_back(""); cfg.spellchecker = str.size()-1;
#endif
} }
@ -770,10 +768,11 @@ CfgGed::CfgGed() {
replylinkfloat = true; replylinkfloat = true;
replylinklist = 0; replylinklist = 0;
replylinkshowalways = true; replylinkshowalways = true;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
scheckerdeflang = 0xFFFF;
scheckerenabled = NO; scheckerenabled = NO;
strcpy(scheckerdeflang, "65535");
strcpy(scheckeruserdic, "user.dic"); strcpy(scheckeruserdic, "user.dic");
strcpy(scheckerdicpath, "dicts");
#endif #endif
screenblanker = 180; screenblanker = 180;
screenblankertype = BLANK_SLIDEWIN; screenblankertype = BLANK_SLIDEWIN;

View File

@ -167,9 +167,7 @@ const word CRC_EDITREPLYRE = 0x5D23;
const word CRC_EDITSAVEMENU = 0x7BC2; const word CRC_EDITSAVEMENU = 0x7BC2;
const word CRC_EDITSAVEUTIL = 0xF411; const word CRC_EDITSAVEUTIL = 0xF411;
const word CRC_EDITSOFTCRXLAT = 0xA49A; const word CRC_EDITSOFTCRXLAT = 0xA49A;
#if defined(GCFG_NOSPELLDLL)
const word CRC_EDITSPELLCHECK = 0xE167; const word CRC_EDITSPELLCHECK = 0xE167;
#endif
const word CRC_EDITUNDELETE = 0x4C34; const word CRC_EDITUNDELETE = 0x4C34;
const word CRC_EMPTYTEARLINE = 0x8D0A; const word CRC_EMPTYTEARLINE = 0x8D0A;
const word CRC_ENCODEEMAILHEADERS=0xA843; const word CRC_ENCODEEMAILHEADERS=0xA843;
@ -322,10 +320,11 @@ const word CRC_REPLYLINKFLOAT = 0xA3EC;
const word CRC_REPLYLINKLIST = 0x104F; const word CRC_REPLYLINKLIST = 0x104F;
const word CRC_REPLYLINKSHOWALWAYS = 0x2BCD; const word CRC_REPLYLINKSHOWALWAYS = 0x2BCD;
const word CRC_ROBOTNAME = 0x7393; const word CRC_ROBOTNAME = 0x7393;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
const word CRC_SCHECKERDEFLANG = 0xBBEB;
const word CRC_SCHECKERENABLED = 0x7394; const word CRC_SCHECKERENABLED = 0x7394;
const word CRC_SCHECKERDEFLANG = 0xBBEB;
const word CRC_SCHECKERUSERDIC = 0x0753; const word CRC_SCHECKERUSERDIC = 0x0753;
const word CRC_SCHECKERDICPATH = 0x4338;
#endif #endif
const word CRC_SCREENBLANKER = 0x5CF7; const word CRC_SCREENBLANKER = 0x5CF7;
const word CRC_SCREENMAXCOL = 0xFFFC; const word CRC_SCREENMAXCOL = 0xFFFC;

View File

@ -323,9 +323,7 @@ SwitchE:
case CRC_EDITSAVEMENU : CfgEditsavemenu (); break; case CRC_EDITSAVEMENU : CfgEditsavemenu (); break;
case CRC_EDITSAVEUTIL : CfgEditsaveutil (); break; case CRC_EDITSAVEUTIL : CfgEditsaveutil (); break;
case CRC_EDITSOFTCRXLAT : CfgEditsoftcrxlat (); break; case CRC_EDITSOFTCRXLAT : CfgEditsoftcrxlat (); break;
#if defined(GCFG_NOSPELLDLL)
case CRC_EDITSPELLCHECK : CfgEditspellcheck (); break; case CRC_EDITSPELLCHECK : CfgEditspellcheck (); break;
#endif
case CRC_EDITUNDELETE : CfgEditundelete (); break; case CRC_EDITUNDELETE : CfgEditundelete (); break;
case CRC_ENDGROUP : CfgEndgroup (); break; case CRC_ENDGROUP : CfgEndgroup (); break;
case CRC_ENCODEEMAILHEADERS: CfgEncodeemailheaders(); break; case CRC_ENCODEEMAILHEADERS: CfgEncodeemailheaders(); break;
@ -523,11 +521,13 @@ SwitchR:
goto End; goto End;
SwitchS: SwitchS:
switch(crc) { switch(crc)
#if !defined(GCFG_NOSPELLDLL) {
case CRC_SCHECKERDEFLANG : CfgScheckerdeflang (); break; #if defined(GCFG_SPELL_INCLUDED)
case CRC_SCHECKERENABLED : CfgScheckerenabled (); break; case CRC_SCHECKERENABLED : CfgScheckerenabled (); break;
case CRC_SCHECKERDEFLANG : CfgScheckerdeflang (); break;
case CRC_SCHECKERUSERDIC : CfgScheckeruserdic (); break; case CRC_SCHECKERUSERDIC : CfgScheckeruserdic (); break;
case CRC_SCHECKERDICPATH : CfgScheckerdicpath (); break;
#endif #endif
case CRC_SCREENBLANKER : CfgScreenblanker (); break; case CRC_SCREENBLANKER : CfgScreenblanker (); break;
case CRC_SCREENMAXCOL : CfgScreenmaxcol (); break; case CRC_SCREENMAXCOL : CfgScreenmaxcol (); break;
@ -699,6 +699,14 @@ static int do_if(char* val) {
return false; return false;
#endif #endif
} }
else if (strieql(val, "SPELL"))
{
#ifdef GCFG_SPELL_INCLUDED
return true;
#else
return false;
#endif
}
else if(strieql(val, "FIREBIRD")) else if(strieql(val, "FIREBIRD"))
return true; return true;
else if(strieql(val, "ASA") or strieql(val, "PLUS")) else if(strieql(val, "ASA") or strieql(val, "PLUS"))

View File

@ -324,12 +324,11 @@ void CfgEditsoftcrxlat() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if defined(GCFG_NOSPELLDLL)
void CfgEditspellcheck() { void CfgEditspellcheck() {
EDIT->SpellChecker(val); EDIT->SpellChecker(val);
} }
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void CfgEditundelete() { void CfgEditundelete() {

View File

@ -222,19 +222,17 @@ void CfgRobotname() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void CfgScheckerdeflang() void CfgScheckerenabled()
{ {
CFG->scheckerdeflang = atoi(val); CFG->scheckerenabled = GetYesno(val);
if (CFG->scheckerdeflang == 0)
CFG->scheckerdeflang = 0xFFFF;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void CfgScheckerenabled() void CfgScheckerdeflang()
{ {
CFG->scheckerenabled = GetYesno(val); strcpy(CFG->scheckerdeflang, val);
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -243,7 +241,14 @@ void CfgScheckeruserdic()
{ {
strcpy(CFG->scheckeruserdic, StripQuotes(val)); strcpy(CFG->scheckeruserdic, StripQuotes(val));
} }
#endif
// ------------------------------------------------------------------
void CfgScheckerdicpath()
{
strcpy(CFG->scheckerdicpath, StripQuotes(val));
}
#endif //#if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -119,9 +119,7 @@ CmdKey DefaultKeyset[] = {
{ Key_A_S , KK_EditSaveMsg , KT_E }, { Key_A_S , KK_EditSaveMsg , KT_E },
{ Key_C_Z , KK_EditSaveMsg , KT_E }, { Key_C_Z , KK_EditSaveMsg , KT_E },
{ Key_F2 , KK_EditSaveMsg , KT_E }, { Key_F2 , KK_EditSaveMsg , KT_E },
#if defined(GCFG_NOSPELLDLL)
{ Key_F9 , KK_EditSpellCheck , KT_E }, { Key_F9 , KK_EditSpellCheck , KT_E },
#endif
{ Key_Tab , KK_EditTab , KT_E }, { Key_Tab , KK_EditTab , KT_E },
{ Key_S_Tab , KK_EditTabReverse , KT_E }, { Key_S_Tab , KK_EditTabReverse , KT_E },
{ Key_A_3 , KK_EditToggleCase , KT_E }, { Key_A_3 , KK_EditToggleCase , KT_E },
@ -677,7 +675,7 @@ tglobalkey globalkeys[] = {
{ CRC_READSHOWDEL , KK_ReadShowDel , KT_R }, // 0x8615 { CRC_READSHOWDEL , KK_ReadShowDel , KT_R }, // 0x8615
{ CRC_K_ENTER , Key_Ent , 0 }, // 0x87BD { CRC_K_ENTER , Key_Ent , 0 }, // 0x87BD
{ CRC_EDITGOTOPLINE , KK_EditGoTopLine , KT_E }, // 0x87C2 { CRC_EDITGOTOPLINE , KK_EditGoTopLine , KT_E }, // 0x87C2
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
{ CRC_EDITSCHECKERMENU , KK_EditSCheckerMenu , KT_E }, // 0x881F { CRC_EDITSCHECKERMENU , KK_EditSCheckerMenu , KT_E }, // 0x881F
#endif #endif
{ CRC_HEADERTOGGLEARCSENT , KK_HeaderToggleArcsent , KT_H }, // 0x88A7 { CRC_HEADERTOGGLEARCSENT , KK_HeaderToggleArcsent , KT_H }, // 0x88A7
@ -826,9 +824,7 @@ tglobalkey globalkeys[] = {
{ CRC_EDITBLOCKUP , KK_EditBlockUp , KT_E }, // 0xE004 { CRC_EDITBLOCKUP , KK_EditBlockUp , KT_E }, // 0xE004
{ CRC_EDITGOBEGLINE , KK_EditGoBegLine , KT_E }, // 0xE045 { CRC_EDITGOBEGLINE , KK_EditGoBegLine , KT_E }, // 0xE045
{ CRC_READGOTONEXTMSG , KK_ReadGotoNextMsg , KT_R }, // 0xE0F1 { CRC_READGOTONEXTMSG , KK_ReadGotoNextMsg , KT_R }, // 0xE0F1
#if defined(GCFG_NOSPELLDLL)
{ CRC_EDITSPELLCHECK , KK_EditSpellCheck , KT_E }, // 0xE167 { CRC_EDITSPELLCHECK , KK_EditSpellCheck , KT_E }, // 0xE167
#endif
{ CRC_AREASCAN , KK_AreaScan , KT_A }, // 0xE440 { CRC_AREASCAN , KK_AreaScan , KT_A }, // 0xE440
{ CRC_EDITGOWORDLEFT , KK_EditGoWordLeft , KT_E }, // 0xE48C { CRC_EDITGOWORDLEFT , KK_EditGoWordLeft , KT_E }, // 0xE48C
{ CRC_EDITSCODENORMAL , KK_EditSCodeNormal , KT_E }, // 0xE4CE { CRC_EDITSCODENORMAL , KK_EditSCodeNormal , KT_E }, // 0xE4CE

View File

@ -113,7 +113,7 @@ const word CRC_EDITQUITNOW = 0x80BA;
const word CRC_EDITREFLOW = 0x13F9; const word CRC_EDITREFLOW = 0x13F9;
const word CRC_EDITSAVEFILE = 0x64A4; const word CRC_EDITSAVEFILE = 0x64A4;
const word CRC_EDITSAVEMSG = 0x660C; const word CRC_EDITSAVEMSG = 0x660C;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
const word CRC_EDITSCHECKERMENU = 0x881F; const word CRC_EDITSCHECKERMENU = 0x881F;
#endif #endif
const word CRC_EDITSCODENORMAL = 0xE4CE; const word CRC_EDITSCODENORMAL = 0xE4CE;
@ -122,9 +122,7 @@ const word CRC_EDITSCODEITALIC = 0x487F;
const word CRC_EDITSCODEUNDERLINE = 0xB1D9; const word CRC_EDITSCODEUNDERLINE = 0xB1D9;
const word CRC_EDITSCODEREVERSE = 0xFC0E; const word CRC_EDITSCODEREVERSE = 0xFC0E;
const word CRC_EDITSOUNDKILL = 0xA9A7; const word CRC_EDITSOUNDKILL = 0xA9A7;
#if defined(GCFG_NOSPELLDLL)
const word CRC_EDITSPELLCHECK = 0xE167; const word CRC_EDITSPELLCHECK = 0xE167;
#endif
const word CRC_EDITTAB = 0x8C26; const word CRC_EDITTAB = 0x8C26;
const word CRC_EDITTABREVERSE = 0xF5B6; const word CRC_EDITTABREVERSE = 0xF5B6;
const word CRC_EDITTOGGLECASE = 0xC282; const word CRC_EDITTOGGLECASE = 0xC282;

View File

@ -398,9 +398,7 @@ static LangCrc LangCrcs[] = {
{ CRC_IL_FOUNDPERSONAL , NULL , " Found %u personal mail%s in %u area%s " }, { CRC_IL_FOUNDPERSONAL , NULL , " Found %u personal mail%s in %u area%s " },
{ CRC_IL_NOPERSONAL , NULL , " No personal mail found " }, { CRC_IL_NOPERSONAL , NULL , " No personal mail found " },
{ CRC_ST_ESCORCONTINUE , NULL , "ESC exits. Other keys: Tries to continue" }, { CRC_ST_ESCORCONTINUE , NULL , "ESC exits. Other keys: Tries to continue" },
#if defined(GCFG_NOSPELLDLL)
{ CRC_MS_SPELLCHECKER , NULL , "SpellChecker: %s" }, { CRC_MS_SPELLCHECKER , NULL , "SpellChecker: %s" },
#endif
{ CRC_WT_INS , NULL , " Ins " }, { CRC_WT_INS , NULL , " Ins " },
{ CRC_WT_DRAWSL , NULL , " DL1 " }, { CRC_WT_DRAWSL , NULL , " DL1 " },
{ CRC_WT_DRAWDL , NULL , " DL2 " }, { CRC_WT_DRAWDL , NULL , " DL2 " },

View File

@ -401,9 +401,7 @@ const word CRC_WT_GRP = 0xD2EA;
const word CRC_IL_FOUNDPERSONAL = 0xA039; const word CRC_IL_FOUNDPERSONAL = 0xA039;
const word CRC_IL_NOPERSONAL = 0x2813; const word CRC_IL_NOPERSONAL = 0x2813;
const word CRC_ST_ESCORCONTINUE = 0x4800; const word CRC_ST_ESCORCONTINUE = 0x4800;
#if defined(GCFG_NOSPELLDLL)
const word CRC_MS_SPELLCHECKER = 0x69B4; const word CRC_MS_SPELLCHECKER = 0x69B4;
#endif
const word CRC_WT_INS = 0x2F27; const word CRC_WT_INS = 0x2F27;
const word CRC_WT_DRAWSL = 0x264D; const word CRC_WT_DRAWSL = 0x264D;
const word CRC_WT_DRAWDL = 0x314D; const word CRC_WT_DRAWDL = 0x314D;

View File

@ -225,7 +225,7 @@ const word CRC_STYLECODES = 0x4CB0;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
const word CRC_SPELL = 0xB8AE; const word CRC_SPELL = 0xB8AE;
const word CRC_SCERROR = 0xAB65; const word CRC_SCERROR = 0xAB65;
#endif #endif
@ -423,7 +423,7 @@ void GetColors(char* value) {
case CRC_STYLECODES: case CRC_STYLECODES:
wptr = &GC_STYLE_; wptr = &GC_STYLE_;
break; break;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
case CRC_SPELL: case CRC_SPELL:
wptr = &GC_SPELL_; wptr = &GC_SPELL_;
break; break;
@ -591,7 +591,7 @@ void GetColors(char* value) {
wptr->_ReverseBoldItalicUnderscore = attr; wptr->_ReverseBoldItalicUnderscore = attr;
} }
break; break;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
case CRC_SCERROR: case CRC_SCERROR:
wptr->_SpellError = attr; wptr->_SpellError = attr;
break; break;

View File

@ -165,9 +165,7 @@ void CfgEditreplyre ();
void CfgEditsavemenu (); void CfgEditsavemenu ();
void CfgEditsaveutil (); void CfgEditsaveutil ();
void CfgEditsoftcrxlat (); void CfgEditsoftcrxlat ();
#if defined(GCFG_NOSPELLDLL)
void CfgEditspellcheck (); void CfgEditspellcheck ();
#endif
void CfgEditundelete (); void CfgEditundelete ();
void CfgEmptytearline (); void CfgEmptytearline ();
void CfgEncodeemailheaders(); void CfgEncodeemailheaders();
@ -308,10 +306,11 @@ void CfgReplylinklist ();
void CfgReplylinkshowalways(); void CfgReplylinkshowalways();
void CfgReplyto (); void CfgReplyto ();
void CfgRobotname (); void CfgRobotname ();
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void CfgScheckerdeflang ();
void CfgScheckerenabled (); void CfgScheckerenabled ();
void CfgScheckerdeflang ();
void CfgScheckeruserdic (); void CfgScheckeruserdic ();
void CfgScheckerdicpath ();
#endif #endif
void CfgScreenblanker (); void CfgScreenblanker ();
void CfgScreenmaxcol (); void CfgScreenmaxcol ();

View File

@ -638,7 +638,7 @@ struct SaveUtil {
#define GC_CFGB_ CFG->color[11] #define GC_CFGB_ CFG->color[11]
#define GC_STYLE_ CFG->color[12] #define GC_STYLE_ CFG->color[12]
#define GC_SHAD_ CFG->color[13] #define GC_SHAD_ CFG->color[13]
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
#define GC_SPELL_ CFG->color[14] #define GC_SPELL_ CFG->color[14]
#endif #endif
@ -693,7 +693,7 @@ struct SaveUtil {
#define _ReverseItalicUnderscore c[14] #define _ReverseItalicUnderscore c[14]
#define _ReverseBoldItalicUnderscore c[15] #define _ReverseBoldItalicUnderscore c[15]
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
#define _SpellError c[0] #define _SpellError c[0]
#endif #endif
@ -813,7 +813,7 @@ struct SaveUtil {
#define C_STYLERUI_ GC_STYLE_._ReverseItalicUnderscore #define C_STYLERUI_ GC_STYLE_._ReverseItalicUnderscore
#define C_STYLERUIB GC_STYLE_._ReverseBoldItalicUnderscore #define C_STYLERUIB GC_STYLE_._ReverseBoldItalicUnderscore
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
#define C_SCERROR GC_SPELL_._SpellError #define C_SCERROR GC_SPELL_._SpellError
#endif #endif

View File

@ -310,10 +310,11 @@ public:
int replylinklist; int replylinklist;
bool replylinkshowalways; bool replylinkshowalways;
gstrarray robotname; gstrarray robotname;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
word scheckerdeflang;
int scheckerenabled; int scheckerenabled;
char scheckerdeflang[100];
Path scheckeruserdic; Path scheckeruserdic;
Path scheckerdicpath;
#endif #endif
int screenblanker; // blanktime; int screenblanker; // blanktime;
int screenblankertype; int screenblankertype;
@ -469,9 +470,7 @@ protected:
int external; int external;
int file; int file;
int hardline; int hardline;
#if defined(GCFG_NOSPELLDLL)
int spellchecker; int spellchecker;
#endif
} cfg; } cfg;
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@ -522,9 +521,7 @@ public:
int ReplyRe() { return cfg.replyre; } int ReplyRe() { return cfg.replyre; }
bool SaveMenu() { return cfg.savemenu; } bool SaveMenu() { return cfg.savemenu; }
char SoftCrXlat() { return cfg.softcrxlat; } char SoftCrXlat() { return cfg.softcrxlat; }
#if defined(GCFG_NOSPELLDLL)
const char* SpellChecker() { return str[cfg.spellchecker].c_str(); } const char* SpellChecker() { return str[cfg.spellchecker].c_str(); }
#endif
int UnDelete() { return cfg.undelete; } int UnDelete() { return cfg.undelete; }
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@ -555,9 +552,7 @@ public:
void ReplyRe(int s) { cfg.replyre = s; } void ReplyRe(int s) { cfg.replyre = s; }
void SaveMenu(bool s) { cfg.savemenu = s; } void SaveMenu(bool s) { cfg.savemenu = s; }
void SoftCrXlat(char s) { cfg.softcrxlat = s; } void SoftCrXlat(char s) { cfg.softcrxlat = s; }
#if defined(GCFG_NOSPELLDLL)
void SpellChecker(char* s) { str[cfg.spellchecker] = s; } void SpellChecker(char* s) { str[cfg.spellchecker] = s; }
#endif
void UnDelete(int s) { cfg.undelete = s; } void UnDelete(int s) { cfg.undelete = s; }
}; };

View File

@ -95,7 +95,7 @@ void IEclass::debugtest(char* __test, int __a, int __b, char* __file, int __line
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
inline bool isscchar(int c) inline bool isscchar(int c)
{ {
return isxalnum(c) || (c == '-') || (c == '\'') || (c == '.') ; return isxalnum(c) || (c == '-') || (c == '\'') || (c == '.') ;
@ -252,7 +252,7 @@ void IEclass::gotorowcol(uint __col, uint __row) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void IEclass::dispstringsc(char *__buf, uint __beg, uint __end, uint __row, uint __col, char endchar) void IEclass::dispstringsc(char *__buf, uint __beg, uint __end, uint __row, uint __col, char endchar)
{ {
char scbuf[EDIT_BUFLEN]; char scbuf[EDIT_BUFLEN];
@ -448,7 +448,7 @@ void IEclass::dispstring(Line* line, uint __row)
GFTRK(NULL); GFTRK(NULL);
} }
#else // #if !defined(GCFG_NOSPELLDLL) #else // #if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -564,7 +564,7 @@ void IEclass::dispstring(const char* __string, uint __row, int attr, Line* line)
GFTRK(NULL); GFTRK(NULL);
} }
#endif // #if !defined(GCFG_NOSPELLDLL) #endif // #if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -604,7 +604,7 @@ void IEclass::displine(Line* __line, uint __row) {
// Display line // Display line
setcolor(__line); setcolor(__line);
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
dispstring(__line, __row); dispstring(__line, __row);
#else #else
dispstring(__line->txt.c_str(), __row, -1, __line); dispstring(__line->txt.c_str(), __row, -1, __line);
@ -652,7 +652,7 @@ void IEclass::refresh(Line* __currline, uint __row) {
} }
// If we ran out of lines, blank the rest // If we ran out of lines, blank the rest
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
if (__row <= maxrow) if (__row <= maxrow)
editwin.fill(__row, mincol, __row, maxcol, _box_table(W_BREAD, 1), C_READB|ACSET); editwin.fill(__row, mincol, __row, maxcol, _box_table(W_BREAD, 1), C_READB|ACSET);
if (++__row <= maxrow) if (++__row <= maxrow)
@ -2084,7 +2084,7 @@ void IEclass::SaveMsg() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void IEclass::SCheckerMenu() void IEclass::SCheckerMenu()
{ {
if (!schecker.IsLoaded()) if (!schecker.IsLoaded())
@ -2783,13 +2783,11 @@ noselecting:
case KK_EditReflow: Reflow(); break; case KK_EditReflow: Reflow(); break;
case KK_EditSaveFile: SaveFile(); break; case KK_EditSaveFile: SaveFile(); break;
case KK_EditSaveMsg: SaveMsg(); break; case KK_EditSaveMsg: SaveMsg(); break;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
case KK_EditSCheckerMenu: SCheckerMenu(); break; case KK_EditSCheckerMenu: SCheckerMenu(); break;
#endif #endif
case KK_EditSoundkill: Soundkill(); break; case KK_EditSoundkill: Soundkill(); break;
#if defined(GCFG_NOSPELLDLL)
case KK_EditSpellCheck: SpellCheck(); break; case KK_EditSpellCheck: SpellCheck(); break;
#endif
case KK_EditTab: Tab(); break; case KK_EditTab: Tab(); break;
case KK_EditTabReverse: ReTab(); break; case KK_EditTabReverse: ReTab(); break;
case KK_EditToggleCase: ToggleCase(); break; case KK_EditToggleCase: ToggleCase(); break;
@ -2840,10 +2838,10 @@ int IEclass::Start(int __mode, uint* __position, GMsg* __msg) {
msgmode = __mode; msgmode = __mode;
currline = __msg->lin; currline = __msg->lin;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
if (CFG->scheckerenabled) if (CFG->scheckerenabled)
{ {
schecker.Init(); schecker.Init(CFG->xlatlocalset, CFG->scheckerdicpath);
schecker.Load(CFG->scheckerdeflang, CFG->scheckeruserdic); schecker.Load(CFG->scheckerdeflang, CFG->scheckeruserdic);
} }
#endif #endif

View File

@ -284,7 +284,7 @@ protected:
// ---------------------------------------------------------------- // ----------------------------------------------------------------
// Speller (DLL) // Speller (DLL)
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
CSpellChecker schecker; CSpellChecker schecker;
#endif #endif
@ -299,7 +299,7 @@ protected:
void dispins (); void dispins ();
void dispdl (); void dispdl ();
void displine (Line* __line, uint __row); void displine (Line* __line, uint __row);
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void dispstringsc (char *__buf, uint __beg, uint __end, uint __row, uint __col, char endchar); void dispstringsc (char *__buf, uint __beg, uint __end, uint __row, uint __col, char endchar);
void dispstring (Line* line, uint __row); void dispstring (Line* line, uint __row);
#else #else
@ -409,14 +409,12 @@ public:
void ReTab (); void ReTab ();
void SaveFile (); void SaveFile ();
void SaveMsg (); void SaveMsg ();
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
void SCheckerMenu (); void SCheckerMenu ();
#endif #endif
void Soundkill (); void Soundkill ();
#if defined(GCFG_NOSPELLDLL)
// External spell check tool // External spell check tool
void SpellCheck (); void SpellCheck ();
#endif
void Tab (); void Tab ();
void ToggleCase (); void ToggleCase ();
void ToggleCaseBlock(gkey key); void ToggleCaseBlock(gkey key);

View File

@ -1311,9 +1311,8 @@ void IEclass::editexport(Line* __exportline, int __endat) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if defined(GCFG_NOSPELLDLL) void IEclass::SpellCheck()
void IEclass::SpellCheck() { {
GFTRK("EditSpellCheck"); GFTRK("EditSpellCheck");
char _buf[EDIT_BUFLEN]; char _buf[EDIT_BUFLEN];
@ -1330,7 +1329,6 @@ void IEclass::SpellCheck() {
GFTRK(NULL); GFTRK(NULL);
} }
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -169,9 +169,7 @@ const gkey KK_EditReflow = 0xFEEE;
const gkey KK_EditSaveFile = 0xFEEF; const gkey KK_EditSaveFile = 0xFEEF;
const gkey KK_EditSaveMsg = 0xFEF0; const gkey KK_EditSaveMsg = 0xFEF0;
const gkey KK_EditSoundkill = 0xFEF1; const gkey KK_EditSoundkill = 0xFEF1;
#if defined(GCFG_NOSPELLDLL)
const gkey KK_EditSpellCheck = 0xFEF2; const gkey KK_EditSpellCheck = 0xFEF2;
#endif
const gkey KK_EditTab = 0xFEF3; const gkey KK_EditTab = 0xFEF3;
const gkey KK_EditTabReverse = 0xFEF4; const gkey KK_EditTabReverse = 0xFEF4;
const gkey KK_EditToggleCase = 0xFEF5; const gkey KK_EditToggleCase = 0xFEF5;
@ -198,7 +196,7 @@ const gkey KK_EditSCodeBold = 0xFF09;
const gkey KK_EditSCodeItalic = 0xFF0A; const gkey KK_EditSCodeItalic = 0xFF0A;
const gkey KK_EditSCodeUnderline = 0xFF0B; const gkey KK_EditSCodeUnderline = 0xFF0B;
const gkey KK_EditSCodeReverse = 0xFF0C; const gkey KK_EditSCodeReverse = 0xFF0C;
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
const gkey KK_EditSCheckerMenu = 0xFF0D; const gkey KK_EditSCheckerMenu = 0xFF0D;
#endif #endif
const gkey KK_EditDrawLines = 0xFF0E; const gkey KK_EditDrawLines = 0xFF0E;

View File

@ -385,9 +385,7 @@ struct LangGed {
char* FoundPersonal; // IL_FOUNDPERSONAL char* FoundPersonal; // IL_FOUNDPERSONAL
char* NoPersonal; // IL_NOPERSONAL char* NoPersonal; // IL_NOPERSONAL
char* EscOrContinue; // ST_ESCORCONTINUE char* EscOrContinue; // ST_ESCORCONTINUE
#if defined(GCFG_NOSPELLDLL)
char* SpellChecker; // MS_SPELLCHECKER char* SpellChecker; // MS_SPELLCHECKER
#endif
char* Ins; // WT_INS char* Ins; // WT_INS
char* DrawSL; // WT_DRAWSL char* DrawSL; // WT_DRAWSL
char* DrawDL; // WT_DRAWDL char* DrawDL; // WT_DRAWDL

View File

@ -1070,7 +1070,7 @@ int GMenuConfirm::Run() {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
int GMenuSChecker::Run(CSpellChecker &schecker, const char *word) int GMenuSChecker::Run(CSpellChecker &schecker, const char *word)
{ {
enum enum
@ -1110,23 +1110,20 @@ int GMenuSChecker::Run(CSpellChecker &schecker, const char *word)
size_t numrows = 7; size_t numrows = 7;
CSpellLangV &langs = schecker.GetLangs(); CSpellLangV &langs = schecker.GetLangs();
LIDC lidc = schecker.GetLangCode(); const char *lcode = schecker.GetLangCode();
std::vector<std::string> langstr; std::vector<std::string> langstr;
size_t langcount = langs.size(); size_t langcount = langs.size();
for (idx = 0; idx < langcount; idx++) for (idx = 0; idx < langcount; idx++)
{ {
char buff[10]; const char *code = langs[idx]->GetLangCode();
LIDC code = langs[idx].GetLangCode();
buff[0] = ' '; std::string buff = " ";
buff[1] = (code == lidc) ? '\x10' : ' '; buff += streql(lcode, code) ? '\x10' : ' ';
buff += code; buff += ' ';
itoa(code, &buff[2], 10); langstr.push_back(buff);
strcat(buff, " ");
langstr.push_back(std::string(buff));
} }
if (langcount) if (langcount)
@ -1143,7 +1140,7 @@ int GMenuSChecker::Run(CSpellChecker &schecker, const char *word)
End(); End();
} }
if (*word && schecker.IsUdrOpened()) if (*word && schecker.IsUdrLoaded())
{ {
Item(TAG_ADDWORD, "A Add Word... "); Item(TAG_ADDWORD, "A Add Word... ");
numrows++; numrows++;
@ -1199,7 +1196,7 @@ int GMenuSChecker::Run(CSpellChecker &schecker, const char *word)
} }
else if ((finaltag > TAG_LANG) && (finaltag < TAG_MORE)) else if ((finaltag > TAG_LANG) && (finaltag < TAG_MORE))
{ {
schecker.Load(langs[finaltag-TAG_LANG-1].GetLangCode(), CFG->scheckeruserdic); schecker.Load(langs[finaltag-TAG_LANG-1]->GetLangCode(), CFG->scheckeruserdic);
return -2; return -2;
} }

View File

@ -304,7 +304,7 @@ public:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
class GMenuSChecker : public GMnu class GMenuSChecker : public GMnu
{ {
public: public:

View File

@ -113,9 +113,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
TPLTOKEN_COMMENT, TPLTOKEN_COMMENT,
TPLTOKEN_QUOTEBUF, TPLTOKEN_QUOTEBUF,
TPLTOKEN_ATTRIB, TPLTOKEN_ATTRIB,
#if defined(GCFG_NOSPELLDLL)
TPLTOKEN_SPELLCHECKER, TPLTOKEN_SPELLCHECKER,
#endif
TPLTOKEN_SETSUBJ, TPLTOKEN_SETSUBJ,
TPLTOKEN_SETFROM, TPLTOKEN_SETFROM,
TPLTOKEN_SETTO, TPLTOKEN_SETTO,
@ -154,9 +152,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
{ CSTR_COMMA_SIZEOF_CSTR("comment") }, { CSTR_COMMA_SIZEOF_CSTR("comment") },
{ CSTR_COMMA_SIZEOF_CSTR("quotebuf") }, { CSTR_COMMA_SIZEOF_CSTR("quotebuf") },
{ CSTR_COMMA_SIZEOF_CSTR("attrib") }, { CSTR_COMMA_SIZEOF_CSTR("attrib") },
#if defined(GCFG_NOSPELLDLL)
{ CSTR_COMMA_SIZEOF_CSTR("spellchecker") }, { CSTR_COMMA_SIZEOF_CSTR("spellchecker") },
#endif
{ CSTR_COMMA_SIZEOF_CSTR("setsubj") }, { CSTR_COMMA_SIZEOF_CSTR("setsubj") },
{ CSTR_COMMA_SIZEOF_CSTR("setfrom") }, { CSTR_COMMA_SIZEOF_CSTR("setfrom") },
{ CSTR_COMMA_SIZEOF_CSTR("setto") }, { CSTR_COMMA_SIZEOF_CSTR("setto") },
@ -492,12 +488,10 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa
} }
continue; continue;
#if defined(GCFG_NOSPELLDLL)
case TPLTOKEN_SPELLCHECKER: case TPLTOKEN_SPELLCHECKER:
if(mode != MODE_QUOTEBUF) if(mode != MODE_QUOTEBUF)
EDIT->SpellChecker(strskip_wht(ptr)); EDIT->SpellChecker(strskip_wht(ptr));
continue; continue;
#endif
case TPLTOKEN_SETSUBJ: case TPLTOKEN_SETSUBJ:
case TPLTOKEN_FORCESUBJ: case TPLTOKEN_FORCESUBJ:

View File

@ -101,18 +101,23 @@
#define NL "\n" #define NL "\n"
#endif #endif
/* ----------------------------------------------------------------*/ /* ------------------------------------------------------------------
// Spellchecker */
#if !defined(__WIN32__) && !defined(GCFG_NO_MSSPELL)
#define GCFG_NO_MSSPELL
#endif
#if !defined(GCFG_NO_MSSPELL) && !defined(GCFG_NO_MYSPELL)
#define GCFG_SPELL_INCLUDED
#endif
/* ------------------------------------------------------------------ */
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define popen(f,m) _popen(f,m) #define popen(f,m) _popen(f,m)
#define pclose(fh) _pclose(fh) #define pclose(fh) _pclose(fh)
#endif #endif
/* ------------------------------------------------------------------
// Spellchecker using dynamic library load */
#if !defined(GCFG_NOSPELLDLL) && !defined(__WIN32__)
#undef GCFG_NOSPELLDLL
#endif
/* ------------------------------------------------------------------ /* ------------------------------------------------------------------
// Special character constants */ // Special character constants */

View File

@ -24,8 +24,6 @@
// SpellChecker functions. // SpellChecker functions.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL)
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* C4786: 'identifier' : identifier was truncated to 'number' /* C4786: 'identifier' : identifier was truncated to 'number'
characters in the debug information characters in the debug information
@ -35,13 +33,38 @@
#include <vector> #include <vector>
#include <gdirposx.h>
#include <gstrall.h> #include <gstrall.h>
#include <myspell.hxx>
#include <gespell.h> #include <gespell.h>
typedef char XlatName[17];
typedef byte ChsTab[4];
struct Chs
{
long id;
int version;
int level;
XlatName imp; // From Charset
XlatName exp; // To Charset
ChsTab t[256]; // The Translation Table
};
int LoadCharset(const char* imp, const char* exp, int query = 0);
char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false);
extern Chs* CharTable;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if defined(__WIN32__) #if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------
#if !defined(GCFG_NO_MSSPELL)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
@ -50,7 +73,6 @@
#define CHECK_NULL(ptr, jump) if (ptr == NULL) goto jump #define CHECK_NULL(ptr, jump) if (ptr == NULL) goto jump
#define CHECK_SEC(jump) if ((sec & 0xFF) != SC_SEC_NoErrors) goto jump #define CHECK_SEC(jump) if ((sec & 0xFF) != SC_SEC_NoErrors) goto jump
// ------------------------------------------------------------------ // ------------------------------------------------------------------
const char SC_RKEY_Prooftools[] = "Software\\Microsoft\\Shared Tools\\Proofing Tools"; const char SC_RKEY_Prooftools[] = "Software\\Microsoft\\Shared Tools\\Proofing Tools";
@ -163,7 +185,7 @@ const dword SC_SO_RussianIO = 0x20000000;
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellLang::Init(HKEY hKey, const char *name) bool CMSSpellLang::Init(HKEY hKey, const char *name)
{ {
bool result = false; bool result = false;
int error; int error;
@ -175,8 +197,13 @@ bool CSpellLang::Init(HKEY hKey, const char *name)
unsigned long dsize = sizeof(dictionary); unsigned long dsize = sizeof(dictionary);
mLIDC = atoi(name); mLIDC = atoi(name);
strcpy(mLangCode, name);
error = RegOpenKeyEx(hKey, name, 0, KEY_READ, &hKeyLang); char name2[1024];
strcpy(name2, name);
strcat(name2, "\\Normal");
error = RegOpenKeyEx(hKey, name2, 0, KEY_READ, &hKeyLang);
CHECK_ERROR(cleanup0); CHECK_ERROR(cleanup0);
error = RegQueryValueEx(hKeyLang, "Engine", NULL, NULL, engine, &esize); error = RegQueryValueEx(hKeyLang, "Engine", NULL, NULL, engine, &esize);
@ -198,7 +225,7 @@ cleanup0:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellLang::Load(const char *userdic) bool CMSSpellLang::Load(const char *codeset, const char *userdic)
{ {
bool result = false; bool result = false;
@ -267,18 +294,27 @@ cleanup1:
FreeLibrary(mLibrary); FreeLibrary(mLibrary);
mLibrary = NULL; mLibrary = NULL;
cleanup0: cleanup0:
if (result)
{
BuildRTable(codeset);
mIsMdrLoaded = (mSIB.cMdr != 0);
mIsUdrLoaded = (mSIB.cUdr != 0);
}
return result; return result;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void CSpellLang::UnLoad() void CMSSpellLang::UnLoad()
{ {
if (!mLibrary) return; if (!mLibrary) return;
if (mSIB.cUdr) mSpellCloseUdr(mSLID, mUDR, TRUE); if (mSIB.cUdr) mSpellCloseUdr(mSLID, mUDR, TRUE);
if (mSIB.cMdr) mSpellCloseMdr(mSLID, &mMDRS); if (mSIB.cMdr) mSpellCloseMdr(mSLID, &mMDRS);
if (mToDicTable) delete mToDicTable;
if (mToLocTable) delete mToLocTable;
mToDicTable = mToLocTable = NULL;
FreeLibrary(mLibrary); FreeLibrary(mLibrary);
mLibrary = NULL; mLibrary = NULL;
@ -287,9 +323,74 @@ void CSpellLang::UnLoad()
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellLang::SpellCheck(const char *text) void CMSSpellLang::BuildRTable(const char *codeset)
{ {
if (!IsLoaded()) return true; char codeset2[20];
sprintf(codeset2, "CP%i", GetACP());
LoadCharset(codeset, codeset2);
mToDicTable = new Chs;
memset(mToDicTable, 0, sizeof(Chs));
*mToDicTable = CharTable ? *CharTable : *mToDicTable;
LoadCharset(codeset2, codeset);
mToLocTable = new Chs;
memset(mToLocTable, 0, sizeof(Chs));
*mToLocTable = CharTable ? *CharTable : *mToLocTable;
}
// ------------------------------------------------------------------
void CMSSpellLang::RecodeText(const char *srcText, char *dstText, bool flag)
{
if (flag)
XlatStr(dstText, srcText, mToDicTable->level, mToDicTable);
else
XlatStr(dstText, srcText, mToLocTable->level, mToLocTable);
}
// ------------------------------------------------------------------
void CMSSpellLang::BuildSuggest(const char *text, CSpellSuggestV &suggest)
{
if (!SpellSuggest(text, false)) return;
bool flag = true;
bool more = false;
for (int idx = 0; idx < mSRB.cChrMac; idx++)
{
if (mSZ[idx] == 0) { idx++; flag = true; }
if (flag && mSZ[idx])
{
flag = false;
RecodeText(&mSZ[idx], &mSZ[idx], false);
suggest.push_back(std::pair<byte, std::string>(0, " " + std::string(&mSZ[idx]) + char(' ')));
}
else if (!more && !mSZ[idx])
{
more = true;
if (!SpellSuggest(text, more = true))
return;
else
{
flag = true;
idx = -1;
}
}
}
}
// ------------------------------------------------------------------
bool CMSSpellLang::SpellCheck(const char *text)
{
if (!IsMdrLoaded()) return true;
mSIB.wSpellState = 0; mSIB.wSpellState = 0;
mSIB.lrgChr = (char*)text; mSIB.lrgChr = (char*)text;
@ -309,9 +410,9 @@ bool CSpellLang::SpellCheck(const char *text)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellLang::SpellSuggest(const char *text, bool more) bool CMSSpellLang::SpellSuggest(const char *text, bool more)
{ {
if (!IsLoaded()) return false; if (!IsMdrLoaded()) return false;
mSIB.wSpellState = 0; mSIB.wSpellState = 0;
mSIB.lrgChr = (char*)text; mSIB.lrgChr = (char*)text;
@ -331,14 +432,146 @@ bool CSpellLang::SpellSuggest(const char *text, bool more)
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellLang::AddWord(const char *text) bool CMSSpellLang::AddWord(const char *text)
{ {
if (!IsLoaded()) return false; if (!IsMdrLoaded()) return false;
SEC error = mSpellAddUdr(mSLID, mUDR, (char*)text); SEC error = mSpellAddUdr(mSLID, mUDR, (char*)text);
return (error & 0xFF) == 0; return (error & 0xFF) == 0;
} }
// ------------------------------------------------------------------
#endif //#if !defined(GCFG_NO_MSSPELL)
// ------------------------------------------------------------------
#if !defined(GCFG_NO_MYSPELL)
// ------------------------------------------------------------------
bool CMYSpellLang::Init(const gdirentry *entry)
{
gposixdir dir(entry->dirname);
std::string affname = entry->name.substr(0, entry->name.length()-4);
strcpy(mLangCode, affname.c_str());
const gdirentry *entry2 = dir.nextentry((affname+".aff").c_str(), true);
if (entry2)
{
strcpy(mEngine, entry2->dirname);
strcat(mEngine, "/");
strcat(mEngine, entry2->name.c_str());
strcpy(mDictionary, entry->dirname);
strcat(mDictionary, "/");
strcat(mDictionary, entry->name.c_str());
return true;
}
return false;
}
// ------------------------------------------------------------------
bool CMYSpellLang::Load(const char *codeset, const char *)
{
mMSpell = new MySpell(mEngine, mDictionary);
if (mMSpell)
{
BuildRTable(codeset);
return (mIsMdrLoaded = true);
}
return false;
}
// ------------------------------------------------------------------
void CMYSpellLang::UnLoad()
{
if (!mMSpell) return;
delete mMSpell;
mMSpell = NULL;
if (mToDicTable) delete mToDicTable;
if (mToLocTable) delete mToLocTable;
mToDicTable = mToLocTable = NULL;
}
// ------------------------------------------------------------------
void CMYSpellLang::BuildRTable(const char *codeset)
{
LoadCharset(codeset, mMSpell->get_dic_encoding());
mToDicTable = new Chs;
memset(mToDicTable, 0, sizeof(Chs));
*mToDicTable = CharTable ? *CharTable : *mToDicTable;
LoadCharset(mMSpell->get_dic_encoding(), codeset);
mToLocTable = new Chs;
memset(mToLocTable, 0, sizeof(Chs));
*mToLocTable = CharTable ? *CharTable : *mToLocTable;
}
// ------------------------------------------------------------------
void CMYSpellLang::RecodeText(const char *srcText, char *dstText, bool flag)
{
if (flag)
XlatStr(dstText, srcText, mToDicTable->level, mToDicTable);
else
XlatStr(dstText, srcText, mToLocTable->level, mToLocTable);
}
// ------------------------------------------------------------------
void CMYSpellLang::BuildSuggest(const char *text, CSpellSuggestV &suggest)
{
char ** wlst = NULL;
int ns = mMSpell->suggest(&wlst, text);
for (int i=0; i < ns; i++)
{
char buff[1024];
RecodeText(wlst[i], buff, false);
suggest.push_back(std::pair<byte, std::string>(0, " " + std::string(buff) + char(' ')));
free(wlst[i]);
}
free(wlst);
}
// ------------------------------------------------------------------
bool CMYSpellLang::SpellCheck(const char *text)
{
if (!IsMdrLoaded()) return true;
if (mMSpell->spell(text))
return true;
return false;
}
// ------------------------------------------------------------------
bool CMYSpellLang::SpellSuggest(const char *text, bool more)
{
return false;
}
// ------------------------------------------------------------------ // ------------------------------------------------------------------
CSpellChecker::CSpellChecker() CSpellChecker::CSpellChecker()
@ -348,10 +581,18 @@ CSpellChecker::CSpellChecker()
mText[0] = 0; mText[0] = 0;
} }
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellChecker::Init() #endif //#if !defined(GCFG_NO_MYSPELL)
// ------------------------------------------------------------------
bool CSpellChecker::Init(const char *codeset, const char *dicPath)
{ {
#if !defined(GCFG_NO_MSSPELL)
int error; int error;
unsigned long index = 0; unsigned long index = 0;
@ -372,8 +613,12 @@ bool CSpellChecker::Init()
error = RegEnumKeyEx(hKeySpelling, index, name, &nsize, NULL, NULL, NULL, NULL); error = RegEnumKeyEx(hKeySpelling, index, name, &nsize, NULL, NULL, NULL, NULL);
if (error == ERROR_SUCCESS) if (error == ERROR_SUCCESS)
{ {
strcat(name, "\\Normal"); CMSSpellLang *lang = new CMSSpellLang;
AddLanguage(hKeySpelling, name); if (lang->Init(hKeySpelling, name))
mLangs.push_back(lang);
else
delete lang;
index++; index++;
} }
} }
@ -383,6 +628,27 @@ bool CSpellChecker::Init()
cleanup1: cleanup1:
RegCloseKey(hKeyPTools); RegCloseKey(hKeyPTools);
cleanup0: cleanup0:
#endif //#if !defined(GCFG_NO_MSSPELL)
#if !defined(GCFG_NO_MYSPELL)
gposixdir d(dicPath);
const gdirentry *de;
while ((de = d.nextentry("*.dic", true)) != NULL)
{
CMYSpellLang *lang = new CMYSpellLang;
if (lang->Init(de))
mLangs.push_back(lang);
else
delete lang;
}
#endif //#if !defined(GCFG_NO_MSSPELL)
strcpy(mXlatLocalset, codeset);
return mInited = (mLangs.size() > 0); return mInited = (mLangs.size() > 0);
} }
@ -400,18 +666,19 @@ void CSpellChecker::Close()
// ------------------------------------------------------------------ // ------------------------------------------------------------------
bool CSpellChecker::Load(LIDC lidc, const char *userdic) bool CSpellChecker::Load(const char *langId, const char *userDic)
{ {
if (!IsInited()) return false; if (!IsInited()) return false;
if (IsLoaded() && (mLang->GetLangCode() == lidc)) return true; if (IsLoaded() && streql(mLang->GetLangCode(), langId)) return true;
CSpellLangV::iterator it; CSpellLangV::iterator it;
for (it = mLangs.begin(); it != mLangs.end(); it++) for (it = mLangs.begin(); it != mLangs.end(); it++)
{ {
if ((it->GetLangCode() == lidc) && it->Load(userdic)) if (streql((*it)->GetLangCode(), langId) && (*it)->Load(mXlatLocalset, userDic))
{ {
UnLoad(); UnLoad();
mLang = it; mLang = *it;
break; break;
} }
} }
@ -436,7 +703,7 @@ bool CSpellChecker::Check(const char *text)
{ {
if (!IsLoaded()) return true; if (!IsLoaded()) return true;
OemToChar(text, mText); mLang->RecodeText(text, mText, true);
return mLang->SpellCheck(mText); return mLang->SpellCheck(mText);
} }
@ -447,34 +714,8 @@ CSpellSuggestV &CSpellChecker::Suggest()
{ {
mSuggest.clear(); mSuggest.clear();
if (!IsLoaded()) return mSuggest; if (!IsLoaded()) return mSuggest;
if (!mLang->SpellSuggest(mText, false)) return mSuggest;
bool flag = true; mLang->BuildSuggest(mText, mSuggest);
bool more = false;
for (int idx = 0; idx < mLang->mSRB.cChrMac; idx++)
{
if (mLang->mSZ[idx] == 0) { idx++; flag = true; }
if (flag && mLang->mSZ[idx])
{
flag = false;
CharToOem(&mLang->mSZ[idx], &mLang->mSZ[idx]);
mSuggest.push_back(std::pair<byte, std::string>(0, " " + std::string(&mLang->mSZ[idx]) + char(' ')));
}
else if (!more && !mLang->mSZ[idx])
{
more = true;
if (!mLang->SpellSuggest(mText, more = true))
return mSuggest;
else
{
flag = true;
idx = -1;
}
}
}
return mSuggest; return mSuggest;
} }
@ -489,11 +730,6 @@ CSpellSuggestV &CSpellChecker::Suggest()
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#endif // #if defined(__WIN32__) #endif //#if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------
#endif // #if !defined(GCFG_NOSPELLDLL)
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -30,16 +30,66 @@
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#if !defined(GCFG_NOSPELLDLL) #if defined(GCFG_SPELL_INCLUDED)
#if defined (__WIN32__)
// ------------------------------------------------------------------
#if defined(__WIN32__)
#include <windows.h> #include <windows.h>
#endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------
typedef std::vector< std::pair<byte, std::string> > CSpellSuggestV;
struct Chs;
class CSpellLang
{
friend class CSpellChecker;
protected:
bool mIsMdrLoaded;
bool mIsUdrLoaded;
char mLangCode[100];
char mEngine[_MAX_PATH];
char mDictionary[_MAX_PATH];
Chs *mToDicTable;
Chs *mToLocTable;
public:
CSpellLang()
{
mIsMdrLoaded = mIsUdrLoaded = false;
mToDicTable = mToLocTable = NULL;
}
virtual ~CSpellLang() {}
void Close() { UnLoad(); }
virtual bool Load(const char *codeset, const char *userdic) = 0;
virtual void UnLoad() = 0;
virtual void BuildRTable(const char *codeset) = 0;
virtual void RecodeText(const char *srcText, char *dstText, bool flag) = 0;
virtual void BuildSuggest(const char *text, CSpellSuggestV &suggest) = 0;
virtual bool SpellCheck(const char *text) = 0;
virtual bool SpellSuggest(const char *text, bool more) = 0;
virtual bool AddWord(const char *text) = 0;
bool IsMdrLoaded() { return mIsMdrLoaded; }
bool IsUdrLoaded() { return mIsUdrLoaded; }
const char *GetLangCode() { return mLangCode; }
};
// ------------------------------------------------------------------
#if !defined(GCFG_NO_MSSPELL)
typedef uint32_t MDR; // Main Dictionary Reference typedef uint32_t MDR; // Main Dictionary Reference
typedef uint32_t UDR; // User Dictionary Reference typedef uint32_t UDR; // User Dictionary Reference
typedef uint16_t SEC; // Spell Error Code typedef uint16_t SEC; // Spell Error Code
@ -113,7 +163,10 @@ typedef SEC (*SpellGetSizeUdr_fn ) (SLID, UDR, word*);
typedef SEC (*SpellGetListUdr_fn ) (SLID, UDR, word, SRB*); typedef SEC (*SpellGetListUdr_fn ) (SLID, UDR, word, SRB*);
typedef SEC (*SpellVerifyMdr_fn ) (char*, LIDC, LIDC*); typedef SEC (*SpellVerifyMdr_fn ) (char*, LIDC, LIDC*);
class CSpellLang
// ------------------------------------------------------------------
class CMSSpellLang: public CSpellLang
{ {
friend class CSpellChecker; friend class CSpellChecker;
@ -128,9 +181,6 @@ private:
char mSZ[1024]; char mSZ[1024];
byte mRate[1024]; byte mRate[1024];
char mEngine[_MAX_PATH];
char mDictionary[_MAX_PATH];
HINSTANCE mLibrary; HINSTANCE mLibrary;
SpellVer_fn mSpellVer; SpellVer_fn mSpellVer;
@ -151,56 +201,86 @@ private:
SpellVerifyMdr_fn mSpellVerifyMdr; SpellVerifyMdr_fn mSpellVerifyMdr;
public: public:
CSpellLang() { mLibrary = NULL; } CMSSpellLang() { mLibrary = NULL; }
~CSpellLang() { Close(); } ~CMSSpellLang() { Close(); }
bool Init(HKEY hKey, const char *name); bool Init(HKEY hKey, const char *name);
void Close() { UnLoad(); }
bool Load(const char *userdic); virtual bool Load(const char *codeset, const char *userdic);
void UnLoad(); virtual void UnLoad();
bool SpellCheck(const char *text); virtual void BuildRTable(const char *codeset);
bool SpellSuggest(const char *text, bool more); virtual void RecodeText(const char *srcText, char *dstText, bool flag);
bool AddWord(const char *text);
LIDC GetLangCode() { return mLIDC; } virtual void BuildSuggest(const char *text, CSpellSuggestV &suggest);
bool IsLoaded() { return mLibrary != NULL; } virtual bool SpellCheck(const char *text);
bool IsUdrOpened() { return mSIB.cUdr != 0; } virtual bool SpellSuggest(const char *text, bool more);
virtual bool AddWord(const char *text);
}; };
#endif //#if !defined(GCFG_NO_MSSPELL)
typedef std::vector< std::pair<byte, std::string> > CSpellSuggestV; #if !defined(GCFG_NO_MYSPELL)
typedef std::vector<CSpellLang> CSpellLangV; class gdirentry;
class MySpell;
class CMYSpellLang: public CSpellLang
{
friend class CSpellChecker;
private:
MySpell *mMSpell;
public:
CMYSpellLang() { mMSpell = NULL; }
~CMYSpellLang() { Close(); }
bool Init(const gdirentry *entry);
virtual bool Load(const char *codeset, const char *);
virtual void UnLoad();
virtual void BuildRTable(const char *codeset);
virtual void RecodeText(const char *srcText, char *dstText, bool flag);
virtual void BuildSuggest(const char *text, CSpellSuggestV &suggest);
virtual bool SpellCheck(const char *text);
virtual bool SpellSuggest(const char *text, bool more);
virtual bool AddWord(const char *) { return false; }
};
#endif //#if !defined(GCFG_NO_MYSPELL)
typedef std::vector<CSpellLang*> CSpellLangV;
class CSpellChecker class CSpellChecker
{ {
private: private:
int mDicType;
bool mInited; bool mInited;
char mText[1024]; char mText[1024];
char mXlatLocalset[256];
CSpellLang *mLang; CSpellLang *mLang;
CSpellLangV mLangs; CSpellLangV mLangs;
CSpellSuggestV mSuggest; CSpellSuggestV mSuggest;
private: private:
void AddLanguage(HKEY hKey, const char *name) void MSAddLanguage(HKEY hKey, const char *name);
{
CSpellLang lang;
if (lang.Init(hKey, name))
mLangs.push_back(lang);
}
public: public:
CSpellChecker(); CSpellChecker();
~CSpellChecker() { Close(); } ~CSpellChecker() { Close(); }
bool Init(); bool Init(const char *codeset, const char *dicPath);
void Close(); void Close();
bool Load(LIDC lidc, const char *userdic = NULL); bool Load(const char *langId, const char *userDic);
void UnLoad(); void UnLoad();
bool Check(const char *text); bool Check(const char *text);
@ -212,8 +292,8 @@ public:
CSpellSuggestV &GetSuggest() { return mSuggest; } CSpellSuggestV &GetSuggest() { return mSuggest; }
CSpellLangV &GetLangs() { return mLangs; } CSpellLangV &GetLangs() { return mLangs; }
LIDC GetLangCode() { return IsLoaded() ? mLang->GetLangCode() : 0xFFFF; } const char *GetLangCode() { return IsLoaded() ? mLang->GetLangCode() : "?*N/A*?"; }
bool IsUdrOpened() { return IsLoaded() ? mLang->IsUdrOpened() : false; } bool IsUdrLoaded() { return IsLoaded() ? mLang->IsUdrLoaded() : false; }
bool IsInited() { return mInited; } bool IsInited() { return mInited; }
bool IsLoaded() { return mLang != NULL; } bool IsLoaded() { return mLang != NULL; }
@ -222,12 +302,7 @@ public:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#endif //#if defined(__WIN32__) #endif //#if defined(GCFG_SPELL_INCLUDED)
// ------------------------------------------------------------------
#endif //#if !defined(GCFG_NOSPELLDLL)
// ------------------------------------------------------------------ // ------------------------------------------------------------------