[Gambas-user] Textedit and Spell checking
Rob
sourceforge-raindog2 at ...94...
Fri Mar 28 21:37:45 CET 2008
On Friday 28 March 2008 15:02, MaxVK wrote:
> Can anyone steer me in the right direction please? I'm at a point
> now where its "No spell checker means no Program" and Id hate to
> just drop it here and a spell checker is a worth item of code to
> have.
There's no reason to try to use a perl module or integrate some other
GUI toolkit's spellchecker. Try something like this:
dim aspell as process
spellcheckresults = ""
aspell = shell "aspell pipe" for read write as "aspell"
print #aspell, textedit1.text ' if it is HTML, include -H in command
...
public sub aspell_Read
DIM sLine AS String
READ #LAST, sLine ' maybe line input instead?
' parse out aspell output and deal with it here
' it looks like this, one line per word:
' * - indicates word found in dictionary, and if not:
' & <misspelled word> <number of guesses> <position in source string>:
' followed by space separated guesses
end
You can just keep the process running and print more words to it when
needed, to save the overhead of starting it.
If you don't like the asynchronous way of doing things, you could
shell out to aspell one word at a time like so:
shell "echo word | aspell pipe | grep word" to spellcheckresults wait
with the caveat that you would have to remove non-word characters from
the source text to prevent the user from running arbitrary shell
commands.
Aspell was installed by default on my machine running Mandriva, don't
know about other Linuxes.
Rob
More information about the User
mailing list