org.kde.koala

Class KSpell

public class KSpell extends QObject

%KDE Spellchecker A %KDE programmer's interface to International ISpell 3.1, ASpell, HSpell and ZPSpell.. A static method, modalCheck() is provided for convenient access to the spellchecker. See KSpellSignals for signals emitted by KSpell

Author: David Sweet

See Also: KSpellConfig KSyntaxHighlighter

UNKNOWN: %KDE Spellchecker

Field Summary
static intCleaning
static intCrashed
static intError
static intFinished
static intFinishedNoMisspellingsEncountered
static intHTML
static intNroff
static intRunning
static intStarting
Possible states of the spell checker.
static intText
These are possible types of documents which the spell checker can check.
static intTeX
Constructor Summary
protected KSpell(Class dummy)
KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar, boolean modal)
Starts the spellchecker.
KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar)
KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs)
KSpell(QWidget parent, String caption, QObject receiver, String slot)
KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar, boolean modal, int type)
Starts the spellchecker.
Method Summary
booleanaddPersonal(String word)
Adds a word to the user's personal dictionary.
booleancheck(String _buffer, boolean usedialog)
Spellchecks a buffer of many words in plain text format.
booleancheck(String _buffer)
protected voidcheck2(KProcIO arg1)
protected voidcheck3()
booleancheckList(String[] _wordlist, boolean usedialog)
Spellchecks a list of words. checkList() is more flexible than check().
booleancheckList(String[] _wordlist)
protected voidcheckList2()
protected voidcheckList3a(KProcIO arg1)
protected voidcheckList4()
protected voidcheckListReplaceCurrent()
protected voidcheckNext()
booleancheckWord(String _buffer, boolean usedialog)
Spellchecks a single word. checkWord() is the most flexible function.
booleancheckWord(String _buffer)
booleancheckWord(String buffer, boolean _usedialog, boolean suggest)
protected voidcheckWord2(KProcIO arg1)
protected voidcheckWord3()
StringclassName()
protected booleancleanFputs(String s, boolean appendCR)
protected booleancleanFputs(String s)
protected booleancleanFputsWord(String s, boolean appendCR)
protected booleancleanFputsWord(String s)
voidcleanUp()
Cleans up ISpell.
protected voiddialog(String word, String[] sugg, String _slot)
protected voiddialog2(int dlgresult)
voiddispose()
Delete the wrapped C++ instance ahead of finalize()
intdlgResult()
Gets the result code of the dialog box.
protected voidemitDeath()
protected voidemitProgress()
protected voidfinalize()
Deletes the wrapped C++ instance
protected StringfunnyWord(String word)
intheightDlg()
Returns the height of the dialog box.
voidhide()
Hides the dialog box.
booleanignore(String word)
Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.
protected voidinitialize(QWidget _parent, String _caption, QObject arg3, String slot, KSpellConfig _ksc, boolean _progressbar, boolean _modal, int type)
StringintermediateBuffer()
Returns the partially spellchecked buffer.
booleanisDisposed()
Has the wrapped C++ instance been deleted?
protected voidispellErrors(KProcess arg1, String arg2, int arg3)
protected voidispellExit(KProcess arg1)
KSpellConfigksConfig()
protected voidKSpell2(KProcIO arg1)
intlastPosition()
Returns the position (when using check()) or word number (when using checkList()) of the last word checked.
QMetaObjectmetaObject()
static intmodalCheck(StringBuffer text, KSpellConfig kcs)
Performs a synchronous spellcheck.
voidmoveDlg(int x, int y)
Moves the dialog.
protected intparseOneResponse(String _buffer, StringBuffer word, String[] sugg)
protected Stringreplacement()
voidsetAutoDelete(boolean _autoDelete)
Sets the auto-delete flag.
voidsetIgnoreTitleCase(boolean b)
Call setIgnoreTitleCase(true) to tell the spell-checker to ignore words with a 'title' case, i.e. starting with an uppercase letter.
voidsetIgnoreUpperWords(boolean b)
Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase.
voidsetProgressResolution(int res)
Sets the resolution (in percent) of the progress() signals.
protected voidsetUpDialog(boolean reallyusedialogbox)
protected voidsetUpDialog()
protected voidslotStopCancel(int arg1)
protected voidstartIspell()
intstatus()
Returns the status of KSpell.
ArrayListsuggestions()
Returns list of suggested word replacements.
protected voidsuggestWord(KProcIO arg1)
intwidthDlg()
Returns the width of the dialog box.
protected booleanwritePersonalDictionary()

Field Detail

Cleaning

public static final int Cleaning

Crashed

public static final int Crashed

Error

public static final int Error

Finished

public static final int Finished

FinishedNoMisspellingsEncountered

public static final int FinishedNoMisspellingsEncountered

HTML

public static final int HTML

Nroff

public static final int Nroff

Running

public static final int Running

Starting

public static final int Starting
Possible states of the spell checker.
  • Starting - After creation of KSpell.
  • Running - After the ready signal has been emitted.
  • Cleaning - After cleanUp() has been called.
  • Finished - After cleanUp() has been completed.
  • The following error states exist:
  • Error - An error occurred in the Starting state.
  • Crashed - An error occurred in the Running state.
  • UNKNOWN: Possible states of the spell checker.

    Text

    public static final int Text
    These are possible types of documents which the spell checker can check.
  • Text - The default type, checks every word
  • HTML - For HTML/SGML/XML documents, will skip the tags,
  • TeX - For TeX/LaTeX documents, will skip commands,
  • Nroff - For nroff/troff documents.
  • Please note that not every option is supported on every type of checker (e.g. ASpell doesn't support Nroff). In case a type of a document is not supported the default Text option will be used.

    UNKNOWN: These are possible types of documents which the spell checker can check.

    TeX

    public static final int TeX

    Constructor Detail

    KSpell

    protected KSpell(Class dummy)

    KSpell

    public KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar, boolean modal)
    Starts the spellchecker. KSpell emits ready() when it has verified that ISpell/ASpell is working properly. Pass the name of a slot -- do not pass zero! Be sure to call cleanUp() when you are done with KSpell. If KSpell could not be started correctly, death() is emitted.

    Parameters: parent Parent of KSpellConfig dialog.. caption Caption of KSpellConfig dialog. receiver Receiver object for the ready(KSpell ) signal. slot Receiver's slot, will be connected to the ready(KSpell ) signal. kcs Configuration for KSpell. progressbar Indicates if progress bar should be shown. modal Indicates modal or non-modal dialog.

    UNKNOWN: Starts the spellchecker.

    KSpell

    public KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar)

    KSpell

    public KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs)

    KSpell

    public KSpell(QWidget parent, String caption, QObject receiver, String slot)

    KSpell

    public KSpell(QWidget parent, String caption, QObject receiver, String slot, KSpellConfig kcs, boolean progressbar, boolean modal, int type)
    Starts the spellchecker. KSpell emits ready() when it has verified that ISpell/ASpell is working properly. Pass the name of a slot -- do not pass zero! Be sure to call cleanUp() when you are done with KSpell. If KSpell could not be started correctly, death() is emitted.

    Parameters: parent Parent of KSpellConfig dialog.. caption Caption of KSpellConfig dialog. receiver Receiver object for the ready(KSpell ) signal. slot Receiver's slot, will be connected to the ready(KSpell ) signal. kcs Configuration for KSpell. progressbar Indicates if progress bar should be shown. modal Indicates modal or non-modal dialog. type Type of the document to check

    UNKNOWN: Starts the spellchecker.

    Method Detail

    addPersonal

    public boolean addPersonal(String word)
    Adds a word to the user's personal dictionary.

    Returns: false if word is not a word or there was an error communicating with ISpell/ASpell.

    UNKNOWN: Adds a word to the user's personal dictionary.

    check

    public boolean check(String _buffer, boolean usedialog)
    Spellchecks a buffer of many words in plain text format. The _buffer is not modified. The signal done() will be sent when check() is finished and the argument will be a spell-corrected version of _buffer. The spell check may be stopped by the user before the entire buffer has been checked. You can check lastPosition() to see how far in _buffer check() reached before stopping.

    UNKNOWN: Spellchecks a buffer of many words in plain text format.

    check

    public boolean check(String _buffer)

    check2

    protected void check2(KProcIO arg1)

    check3

    protected void check3()

    checkList

    public boolean checkList(String[] _wordlist, boolean usedialog)
    Spellchecks a list of words. checkList() is more flexible than check(). You could parse any type of document (HTML, TeX, etc.) into a list of spell-checkable words and send the list to checkList(). Sending a marked-up document to check() would result in the mark-up tags being spell checked.

    UNKNOWN: Spellchecks a list of words.

    checkList

    public boolean checkList(String[] _wordlist)

    checkList2

    protected void checkList2()

    checkList3a

    protected void checkList3a(KProcIO arg1)

    checkList4

    protected void checkList4()

    checkListReplaceCurrent

    protected void checkListReplaceCurrent()

    checkNext

    protected void checkNext()

    checkWord

    public boolean checkWord(String _buffer, boolean usedialog)
    Spellchecks a single word. checkWord() is the most flexible function. Some applications might need this flexibility but will sacrifice speed when checking large numbers of words. Consider checkList() for checking many words. Use this method for implementing "online" spellchecking (i.e., spellcheck as-you-type). checkWord() returns false if buffer is not a single word (e.g. if it contains white space), otherwise it returns true; If usedialog is set to true, KSpell will open the standard dialog if the word is not found. The dialog results can be queried by using dlgResult() and replacement(). The signal corrected() is emitted when the check is complete. You can look at suggestions() to see what the suggested replacements were.

    UNKNOWN: Spellchecks a single word.

    checkWord

    public boolean checkWord(String _buffer)

    checkWord

    public boolean checkWord(String buffer, boolean _usedialog, boolean suggest)

    checkWord2

    protected void checkWord2(KProcIO arg1)

    checkWord3

    protected void checkWord3()

    className

    public String className()

    cleanFputs

    protected boolean cleanFputs(String s, boolean appendCR)

    cleanFputs

    protected boolean cleanFputs(String s)

    cleanFputsWord

    protected boolean cleanFputsWord(String s, boolean appendCR)

    cleanFputsWord

    protected boolean cleanFputsWord(String s)

    cleanUp

    public void cleanUp()
    Cleans up ISpell. Write out the personal dictionary and close ISpell's stdin. A death() signal will be emitted when the cleanup is complete, but this method will return immediately.

    UNKNOWN: Cleans up ISpell.

    dialog

    protected void dialog(String word, String[] sugg, String _slot)

    dialog2

    protected void dialog2(int dlgresult)

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()

    dlgResult

    public int dlgResult()
    Gets the result code of the dialog box. After calling checkWord, you can use this to get the dialog box's result code. The possible values are (from kspelldlg.h):
  • KS_CANCEL
  • KS_REPLACE
  • KS_REPLACEALL
  • KS_IGNORE
  • KS_IGNOREALL
  • KS_ADD
  • KS_STOP
  • UNKNOWN: Gets the result code of the dialog box.

    emitDeath

    protected void emitDeath()

    emitProgress

    protected void emitProgress()

    finalize

    protected void finalize()
    Deletes the wrapped C++ instance

    funnyWord

    protected String funnyWord(String word)

    heightDlg

    public int heightDlg()
    Returns the height of the dialog box.

    UNKNOWN: Returns the height of the dialog box.

    hide

    public void hide()
    Hides the dialog box. You'll need to do this when you are done with checkWord();

    UNKNOWN: Hides the dialog box.

    ignore

    public boolean ignore(String word)
    Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.

    Returns: false if word is not a word or there was an error communicating with ISpell/ASpell.

    UNKNOWN: Tells ISpell/ASpell to ignore this word for the life of this KSpell instance.

    initialize

    protected void initialize(QWidget _parent, String _caption, QObject arg3, String slot, KSpellConfig _ksc, boolean _progressbar, boolean _modal, int type)

    intermediateBuffer

    public String intermediateBuffer()
    Returns the partially spellchecked buffer. You might want the full buffer in its partially-checked state.

    UNKNOWN: Returns the partially spellchecked buffer.

    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?

    ispellErrors

    protected void ispellErrors(KProcess arg1, String arg2, int arg3)

    ispellExit

    protected void ispellExit(KProcess arg1)

    ksConfig

    public KSpellConfig ksConfig()

    Returns: the KSpellConfig object being used by this KSpell instance.

    UNKNOWN:

    KSpell2

    protected void KSpell2(KProcIO arg1)

    lastPosition

    public int lastPosition()
    Returns the position (when using check()) or word number (when using checkList()) of the last word checked.

    UNKNOWN: Returns the position (when using check()) or word number (when using checkList()) of the last word checked.

    metaObject

    public QMetaObject metaObject()

    modalCheck

    public static int modalCheck(StringBuffer text, KSpellConfig kcs)
    Performs a synchronous spellcheck. This method does not return until spellchecking is done or canceled. Your application's GUI will still be updated, however. This overloaded method uses the spell-check configuration passed as parameter.

    UNKNOWN: Performs a synchronous spellcheck.

    moveDlg

    public void moveDlg(int x, int y)
    Moves the dialog. If the dialog is not currently visible, it will be placed at this position when it becomes visible. Use this to get the dialog out of the way of a highlighted misspelled word in a document.

    UNKNOWN: Moves the dialog.

    parseOneResponse

    protected int parseOneResponse(String _buffer, StringBuffer word, String[] sugg)

    replacement

    protected String replacement()

    setAutoDelete

    public void setAutoDelete(boolean _autoDelete)
    Sets the auto-delete flag. If this is set, the KSpell object is automatically deleted after emitting death().

    UNKNOWN: Sets the auto-delete flag.

    setIgnoreTitleCase

    public void setIgnoreTitleCase(boolean b)
    Call setIgnoreTitleCase(true) to tell the spell-checker to ignore words with a 'title' case, i.e. starting with an uppercase letter. They are spell-checked by default.

    UNKNOWN: Call setIgnoreTitleCase(true) to tell the spell-checker to ignore words with a 'title' case, i.

    setIgnoreUpperWords

    public void setIgnoreUpperWords(boolean b)
    Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase. They are spell-checked by default.

    UNKNOWN: Call setIgnoreUpperWords(true) to tell the spell-checker to ignore words that are completely uppercase.

    setProgressResolution

    public void setProgressResolution(int res)
    Sets the resolution (in percent) of the progress() signals. E.g. setProgressResolution (10) instructs KSpell to send progress signals (at most) every 10% (10%, 20%, 30%...). The default is 10%.

    UNKNOWN: Sets the resolution (in percent) of the progress() signals.

    setUpDialog

    protected void setUpDialog(boolean reallyusedialogbox)

    setUpDialog

    protected void setUpDialog()

    slotStopCancel

    protected void slotStopCancel(int arg1)

    startIspell

    protected void startIspell()

    status

    public int status()
    Returns the status of KSpell.

    See Also: KSpell

    UNKNOWN: Returns the status of KSpell.

    suggestions

    public ArrayList suggestions()
    Returns list of suggested word replacements. After calling checkWord() (an in response to a misspelled() signal you can use this to get the list of suggestions (if any were available).

    UNKNOWN: Returns list of suggested word replacements.

    suggestWord

    protected void suggestWord(KProcIO arg1)

    widthDlg

    public int widthDlg()
    Returns the width of the dialog box.

    UNKNOWN: Returns the width of the dialog box.

    writePersonalDictionary

    protected boolean writePersonalDictionary()