# TextServices
Class
## About
`TextServices` is the editor-owned ordered registry of character-input, spelling, correction, and text-service context-menu providers. Each editor creates its own registry so applications can replace one native capability without replacing the others.
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| MenuPlacements | BeforeEditing <br > AfterEditing <br > AfterNodeActions | (None) |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| Add | provider As TextServiceProvider | (None) | Adds the supplied provider to the end of this ordered text-service provider collection. |
| AddAt | index As Integer <br> provider As TextServiceProvider | (None) | Inserts the supplied provider at the requested zero-based position in this ordered text-service provider collection. |
| ApplyAutomaticCorrection | session As TextServiceSession | Boolean | Attempts to correct the contextual word through the first enabled correction provider that returns a replacement. |
| EndSession | session As TextServiceSession | (None) | Notifies every registered provider that the supplied text-service session has ended. |
| IndexOf | provider As TextServiceProvider | Integer | Returns the zero-based index of the supplied provider, or -1 when it is not registered. |
| ItemAt | index As Integer | TextServiceProvider | Returns the registered provider at the specified zero-based index. |
| Items | (None) | TextServiceProvider | Returns a copy of the registered providers in resolution order. |
| LastIndex | (None) | Integer | Returns the last zero-based provider index, or -1 when there are no providers. |
| MisspelledRanges | text As String <br> node As Node | TextRange | Returns the grapheme-aligned ranges identified as misspelled in the supplied text for the supplied node. |
| MisspelledRanges | session As TextServiceSession | TextRange | Returns the grapheme-aligned ranges identified as misspelled by the first available enabled text-checking provider. |
| Remove | provider As TextServiceProvider | (None) | Removes the supplied provider from this ordered text-service provider collection. |
| RemoveAll | (None) | (None) | Removes every provider from this ordered text-service provider collection. |
| RemoveAt | index As Integer | (None) | Removes the registered provider at the specified zero-based index. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| Language | String | (None) | Gets or sets the effective BCP 47 language tag passed to text-checking and correction providers; set an empty value to use the current system locale. |
| LanguageOverride | String | (None) | Returns the explicit BCP 47 language override, or an empty string when the current system locale is used. |
## Notes
Providers remain independent so applications can mix native and custom implementations.
### Language Selection
`Language` returns the effective BCP 47 language tag passed to spelling and correction providers. With no override it resolves `Locale.Current.Identifier`. ICU keyword and encoding suffixes are removed and underscores are normalized to hyphens, so a locale identifier such as `en_US@calendar=gregorian` becomes `en-US`. Assign a tag such as `fr-CA` to override the system locale. Assign an empty string to clear the override. `LanguageOverride` distinguishes an explicit selection from the resolved system language.
### Provider Ordering
Providers are queried in registry order. Remove or reorder the defaults when an application-defined service should take precedence. Disabled or unavailable providers remain registered but do not contribute behavior.
The editor creates a `TextServiceSession` for the current node, selection, caret, word, language, and menu location. Providers should use the session passed to each call rather than retaining editor state independently.
### Spelling Boundaries
While text is being edited, the word containing the caret is treated as unfinished and is not sent to spelling providers. It is checked when the caret crosses a word delimiter such as whitespace, a line ending, brackets, parentheses, or punctuation. Completed native Windows results are cached by word and language so subsequent edits do not repeatedly cross the COM boundary.
## Examples
Install providers in the order in which they should be queried.
### Replacing a Provider
```xojo
Editor.TextServices.RemoveAll
Editor.TextServices.Add(New MyEmojiProvider)
Editor.TextServices.Add(New MySpellCheckingProvider)
```
The `TextInputServicesExample` class in the project examples folder demonstrates the complete provider surface.