Delen via


Investigation: Text Service Framework (TSF) and Keyboards

Overview

Windows has an entire API for text input and interaction.

The Text Services Framework (TSF) is a COM framework and API that supports advanced text input and text processing. It is designed to offer advanced language and word processing features to applications. It supports features such as multilingual support, keyboard drivers, handwriting recognition, speech recognition, as well as spell checking and other text and natural language processing functions.

Architecture

The diagram is below but please see the details at https://msdn.microsoft.com/en-us/library/ms538050(VS.85).aspx

Architecture of Text Services Framework

Using TSF

TSF can be implemented as an app or as a text service.

For a keyboard, we’d be writing a TSF text service.

  • A text service can obtain text from, and write text to, an application. A text service can also associate data and properties with a block of text. A text service is implemented as a COM in-proc server that registers itself with TSF. When registered, the user interacts with the text service using the language bar or keyboard shortcuts. Multiple text services can be installed.
  • TSF-aware apps can provide the input context or scope (e.g. “url”, “name”, “address”)

On the app side, extensibility is done by the app by implementing interfaces and registering them with TSF.

TSF can read the current "context" from the application, which . The "context" is the characters on the screen around the insertion point.

TSF and Managed Code:
Difficult since text service gets loaded into arbitrary processes, so they need to be small and lightweight, among other reasons. https://blogs.msdn.com/tsfaware/archive/2007/04/19/tsf-and-managed-code.aspx

Legacy apps:
TSF has a table of controls for legacy apps that describes the input scope (e.g. the address bar control in IE5 takes a “url”)

Other notes:
The Tablet PC TIP uses TSF to provide text to apps.

References