class KSpell

A KDE programmer's interface to International ISpell 3.1 (GPL 1997). More...

Definition#include <kspell.h>
InheritsQObject
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Signals

Protected Methods

Protected Slots

Protected Members


Detailed Description

?/ ?/98 Entered into CVS 1/ 2/98 KSpell 0.3.1 11/25/97 KSpell 0.2.3 11/ /97 KSpell 0.2.2 9/21/97 KSpell 0.2 9/11/97 KSpell 0.1

KSpell offers easy access to International ISpell 3.1 as well as a typical spell-checker GUI ("Add", "Replace", etc.). You can use KSpell to automatically spell-check an ASCII file as well as to implement online spell-checking and to spell-check proprietary format and marked up (e.g. HTML, TeX) documents. The relevant methods for these three procedures are check(), checkWord(), and checkList().

KSpellConfig holds configuration information about KSpell as well as acting as an options-setting dialog.

 KSpell (QWidget *_parent, const char *caption, QObject *obj, const char *slot, KSpellConfig *_kcs=0)

KSpell emits ready() when it has verified that ispell is working properly. Pass the name of a slot -- do not pass zero! Be sure to call cleanUp() when you are done with KSpell.

inline bool  isOk (void)

Be sure your instance of KSpell isOk() before you use it. isOk()==TRUE would indicate that any memory that needed to be allocated was and that ispell is up and running. If you find that isOk()==FALSE, it's probably b/c either ispell isn't installed (and in $PATH) or an invalid path was given for the dictionary or personal dictionary (see KSpellConfig).

If an instance of KSpell is not Ok, then it never will be. Delete it, reconfigure a KSpellConfig and try again (perhaps with the system defaults).

void  cleanUp (void)

[virtual]

Clean up ISpell (write out the personal dictionary and close ispell's stdin). A "death()" signal will be emitted when the cleanup is complete, but the cleanUp() method will return immediately.

bool  check (char *_buffer)

[virtual]

check() will spell check a buffer of many words in plain text format The _buffer is not modified. The signal done(char *) will be sent when check() is finished and the argument will be a spell-corrected version of _buffer. (See done() for more information.) The progress() signal is only sent when a misspelled word is found, so you may not get as fine a resolution as you requested; but you won't get a _finer_ resolution. 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.

inline int  lastPosition (void)

bool  checkList (QStrList *_wordlist)

[virtual]

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. The progress() signals will be accurate here since words are checked one at a time.

bool  checkWord (char *_buffer, bool usedialog=FALSE)

[virtual]

checkWord() is the most flexible function. Some apps might need this flexibility.

checkWord () returns FALSE if buffer is not a word, otherwise it returns TRUE;

If usedialog is set to TRUE, KSpell will put up the standard dialog if the word is not found. The dialog results can be queried by using dlgResult() and replacement(). The possible dlgResult() values are (from kspelldlg.h): KS_CANCEL 0 KS_REPLACE 1 KS_REPLACEALL 2 KS_IGNORE 3 KS_IGNOREALL 4 KS_ADD 5 KS_STOP 7

The signal corrected() is emitted when the check is complete. You can look at suggestions() to see what the suggested replacements were. If the dialog box is not used, or the user chooses not to change the word, then new word is just word. pos=0 always.

void  hide (void)

You can use this to manually hide the dialog box. You only _need_ to do this when you are done with checkWord();

inline QStrListsuggestions (void)

After calling checkWord (an in response to a misspelled() signal you can use this to get the list of suggestions (if any were available)

inline int  dlgResult (void)

After calling checkWord, you can use this to get the dialog box's result code.

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.

inline int  heightDlg (void)

inline int  widthDlg (void)

const char * intermediateBuffer (void)

You might want the full buffer in its partially-checked state.

bool  ignore (const char *word)

[virtual]

Tell ispell to ignore this word for the life of this KSpell instance. ignore() returns FALSE if word is not a word or there was an error communicating with ispell.

bool  addPersonal (const char *word)

[virtual]

Add a word to the user's personal dictionary. Returns FALSE if word is not a word or there was an error communicating with ispell.

KSpellConfig  ksConfig (void)

[const]

Returns the KSpellConfig object being used by this KSpell.

void  setProgressResolution (unsigned res)

Set 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%.

KSpell ()

[virtual]

The destructor instructs ispell to write out the personal dictionary and then terminates ispell.

void  misspelling (char *originalword, QStrList *suggestions, unsigned pos)

[signal]

This is emitted whenever a misspelled word is found by check() or by checkWord(). If it is emitted by checkWord(), pos=0. If it is emitted by check(), the pos indicates the position of the misspelled word in the _buffer. (The first position is zero.) If it is emitted by checkList(), pos is the index to the misspelled word in the QStrList passed to checkList().

These are called _before_ the dialog is opened, so that the calling program's GUI may be updated. (e.g. the misspelled word may be highlighted).

void  corrected (char *originalword, char *newword, unsigned pos)

[signal]

This is emitted after the dialog is closed, or if the word was corrected without calling the dialog (i.e., the user previously chose "Replace All" for this word). Results from the dialog may be checked with dlgResult() and replacement() (see notes for check() for more information).

void  ready (KSpell *)

[signal]

This is emitted after KSpell has verified that ispell is running and working properly. The calling application should check isOk() in response to this signal before attempting to use any of the spell-checking methods (check(), et at). Those methods _don't_ check isOk() for you.

void  progress (unsigned int i)

[signal]

i is between 1 and 100 -- emitted only during a check ()

void  done (char *buffer)

[signal]

emitted when check() is done Copy the results of buffer if you need them. You can only rely on the contents of buffer for the life of the slot which was signaled by done(char *).

void  done (bool)

[signal]

emitted when checkList() is done. If the argument is <i>TRUE</i>, then you should update your text from the wordlist, otherwise, don't.

void  cleanDone ()

[signal]

emitted when cleanUp() is done

void  death (KSpell *)

[signal]

emitted on terminal errors

void  KSpell2 (KProcIO *)

[protected slot]

void  checkWord2 (KProcIO *)

[protected slot]

void  checkWord3 ()

[protected slot]

void  check2 (KProcIO *)

[protected slot]

void  checkList2 ()

[protected slot]

void  checkList3a (KProcIO *)

[protected slot]

void  checkList3 ()

[protected slot]

void  checkList4 ()

[protected slot]

void  dialog2 (int dlgresult)

[protected slot]

void  check3 ()

[protected slot]

void  slotStopCancel (int)

[protected slot]

void  ispellExit (KProcess *)

[protected slot]

void  dialog3 ()

[signal]

void  ez ()

[signal]

void  eza ()

[signal]

KProcIO * proc

[protected]

QWidget * parent

[protected]

KSpellConfig * ksconfig

[protected]

KSpellDlg * ksdlg

[protected]

QStrList * wordlist

[protected]

QStrList ignorelist

[protected]

QStrList replacelist

[protected]

QStrList sugg

[protected]

char * temp

[protected]

bool cleaning

[protected]

bool usedialog

[protected]

bool texmode

[protected]

bool dlgon

[protected]

bool ok

[protected]

bool personaldict

[protected]

bool dialogwillprocess

[protected]

QString ispellID

[protected]

QString caption

[protected]

QString orig

[protected]

QString buffer

[protected]

QString newbuffer

[protected]

QString cwword

[protected]

QString dlgorigword

[protected]

QString dlgreplacement

[protected]

QString dialog3slot

[protected]

int dlgresult

[protected]

int trystart

[protected]

int maxtrystart

[protected]

unsigned int lastpos

[protected]

unsigned int totalpos

[protected]

unsigned int lastline

[protected]

unsigned int posinline

[protected]

unsigned int lastlastline

[protected]

unsigned int offset

[protected]

unsigned int progres

[protected]

unsigned int curprog

[protected]

int  parseOneResponse (char *_buffer, char *word, QStrList *sugg)

[protected]

char * funnyWord (char *word)

[protected]

void  dialog (char *word, QStrList *sugg, char *_slot)

[protected]

inline char * replacement (void)

[protected]

void  emitProgress (void)

[protected]

bool  cleanFputs (const char *s, bool appendCR=TRUE)

[protected]

bool  cleanFputsWord (const char *s, bool appendCR=TRUE)

[protected]

void  startIspell (void)

[protected]

bool  writePersonalDictionary (void)

[protected]