Since spell checker is actualy part of editor (as the poster probably 
noticed but possibly didn't make the connection) this might get more 
results in n.p.m.editor, so crossposting. BTW EdSpellCheck.js seems to 
look for a blank or null word at the end of the spellcheck.

> After not much thought it became obvious to me that writing a spell 
> checker for mozilla, or at least integrating one written by someone 
> else, would be orders of magnitude easier than learning to spell. 
> After not much more thought, but a lot more research, I discovered 
> that writing a spell checker was a lot easier than reverse engineering 
> mozilla's infrastructure. I am certainly not ready or willing to 
> declare to the rest of the world that I am even working on it, but I 
> do need some advice on how to proceed.
>
> Currently, I have a class that will read a bunch of words from a file 
> into a hash table and is able to check to see if a word is in the hash 
> table. I haven't yet tied the checking engine to the 
> TextServicesDocument, but that seems straightforward enough, given 
> that I have find and replace to copy from. I have no doubt that I can 
> add getting a list of suggested words, affix compression, and any 
> other spell checky goodness desired without too much trouble, but it 
> seems like now is the time to figure out how to do things right, 
> before I have to redo everything. I have three categories of 
> questions, first, questions about the spell checker itself, second, 
> questions about the mozilla infrastructure, specifically files and 
> strings, and finally questions about I18n.
>
> Spell checking:
> 1) Where do dictionaries go? Both default and personal. I have the 
> system dictionaries living in defaults/dictionaries.
> 2) Where does the spell checker go? I have included it in 
> editor/txtsvc, but I suspect that it should live in its own module, 
> probably somewhere in the extensions hierarchy.
> 4) Should NextMispelled word call SetSelection and 
> ScrollSelectionIntoView? Probably.
> 3) How are you supposed to signal no spelling errors in 
> NextMisspelledWord? Leaving the word parameter blank and returning 
> NS_OK seems to work but is it intended?
> 4) Should Replace wrap if we are replacing all occurrences? Probably not.
> 5) How should multiple dictionaries work It seems that if I populate 
> the StringArray, this has no effect on the combo box. How should it be 
> working?
>
> Infrastructure.
> 6) Strings. Is there any more documentation than 
> http://lxr.mozilla.org/seamonkey/source/string/doc/string-guide.html 
> for the new strings? Is there a stretch of code that exercises them 
> elegantly? Till then I am using the old strings, there are more 
> examples of their use.
> 7) Files. Is there any documentation other than header files on the 
> stuff in xpcom/io?
>
> to open the dictionary I do
>
> nsCOMPtr<nsIFile> aFile;
> res = NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR, 
> getter_AddRefs(aFile));
> if (NS_FAILED(res)) return res;
> res = aFile->Append("dictionaries");
> if (NS_FAILED(res)) return res;
> nsXPIDLCString pathBuf;
> aFile->GetPath(getter_Copies(pathBuf));
> nsCOMPtr<nsIFileSpec> tempSpec;
> res = NS_NewFileSpec(getter_AddRefs(tempSpec));
> if (NS_FAILED(res)) return res;
> res = tempSpec->SetNativePath(pathBuf);
> if (NS_FAILED(res)) return res;
> nsFileSpec dirSpec;
> res = tempSpec->GetFileSpec(&dirSpec);
> if (NS_FAILED(res)) return res;
> nsAutoString hashName(dictName);
> hashName.AppendWithConversion(".dic");
> nsInputFileStream strm(dirSpec+hashName);
>
> I can almost certainly do without the nsIFileSpec -> FileSpec 
> conversion, but is the rest of that necessary, or even safe. This was 
> copied more or less from the cookie code, so it should work.
>
> I18N
> 8) Are there equivalents to the ctype functions for unicode that 
> should be used. At least for western languages isalpha
> and isupper and is lower are useful for spell checkers.
>
> 9) Is there some documentation/examples on the character conversion 
> routines? I will need to be able to convert words from unicode to 
> whatever charset the dictionary is in and back. Right now I am just 
> happily using ascii, and that is easy to convert, and more than 
> sufficient for a USAian dictionary.


Reply via email to