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
| Property | Description |
|---|---|
Editor | The editor to check. |
LanguageCode | The language, for example en-US or it-IT. SupportedLanguages lists those available. |
CheckAsYouType | Checks the text while the user types. |
PenColor | Color of the underline of the errors (default clRed). |
UnderlineStyle | Style of the underline. |
AttributesChecked | The highlighter attributes whose text is checked (for example comments and strings, to skip the code). |
OnChange | Fired when the settings change. |
Methods
| Method | Description |
|---|---|
CheckFile, CheckLine, CheckSelection, CheckWord | Check the whole text, the current line, the selection or the word under the caret. |
ClearErrors | Removes the marks of the errors. |
ErrorAtPos(BufferCoord) | Returns the error (ISpellingError) at a position, to build the suggestions menu. |
SpellChecker | The Windows ISpellChecker interface (suggestions, add word, ignore...). |
BeginUpdate, EndUpdate | Group changes of the settings. |
AddEditor, RemoveEditor | Serve more editors. |
Actions
The package registers a category of actions, SynEdit Spell Check, to build menus and toolbars without code:
| Action | Description |
|---|---|
TSynSpellCheckFile, TSynSpellCheckLine, TSynSpellCheckSelection, TSynSpellCheckWord | Check the text, the line, the selection or the word. |
TSynSpellClearErrors | Clears the errors. |
TSynSpellCheckAsYouType | Toggles the check while typing. |
TSynSpellErrorAdd, TSynSpellErrorIgnoreOnce, TSynSpellErrorIgnore, TSynSpellErrorDelete | For the context menu on an error: add the word to the dictionary, ignore it once or always, delete it. |
TSynSpellErrorReplace | Replaces the word with a suggestion. |
Demo
See the Spell Check demo.
