Skip to content

Spell Check ​

TSynSpellCheck (unit SynEdit.SpellCheck) checks the spelling of the text of a TSynEdit with the spell checking API of Windows (ISpellChecker): no dictionary has to be distributed, it uses the languages installed in the operating system. The errors are underlined with an indicator, and can be checked as you type.

Requirement

The Windows spell checking API is available from Windows 8. If no language is available SpellChecker returns nil.

Using the component ​

pascal
SynSpellCheck1.Editor := SynEdit1;
SynSpellCheck1.LanguageCode := 'en-US';
SynSpellCheck1.CheckAsYouType := True;

Properties ​

PropertyDescription
EditorThe editor to check.
LanguageCodeThe language, for example en-US or it-IT. SupportedLanguages lists those available.
CheckAsYouTypeChecks the text while the user types.
PenColorColor of the underline of the errors (default clRed).
UnderlineStyleStyle of the underline.
AttributesCheckedThe highlighter attributes whose text is checked (for example comments and strings, to skip the code).
OnChangeFired when the settings change.

Methods ​

MethodDescription
CheckFile, CheckLine, CheckSelection, CheckWordCheck the whole text, the current line, the selection or the word under the caret.
ClearErrorsRemoves the marks of the errors.
ErrorAtPos(BufferCoord)Returns the error (ISpellingError) at a position, to build the suggestions menu.
SpellCheckerThe Windows ISpellChecker interface (suggestions, add word, ignore...).
BeginUpdate, EndUpdateGroup changes of the settings.
AddEditor, RemoveEditorServe more editors.

Actions ​

The package registers a category of actions, SynEdit Spell Check, to build menus and toolbars without code:

ActionDescription
TSynSpellCheckFile, TSynSpellCheckLine, TSynSpellCheckSelection, TSynSpellCheckWordCheck the text, the line, the selection or the word.
TSynSpellClearErrorsClears the errors.
TSynSpellCheckAsYouTypeToggles the check while typing.
TSynSpellErrorAdd, TSynSpellErrorIgnoreOnce, TSynSpellErrorIgnore, TSynSpellErrorDeleteFor the context menu on an error: add the word to the dictionary, ignore it once or always, delete it.
TSynSpellErrorReplaceReplaces the word with a suggestion.

Demo ​

See the Spell Check demo.

Released under the MPL 1.1 / GPL 2 dual license.