A Tour through TSF: Contexts and Ranges
Our next stop on our tour through TSF brings us to the two most heavily used interfaces in text services: Contexts and Ranges. But first, a quick diversion to discuss the relationship between threads, documents, and contexts.
The ITfThreadMgr object is the primary object implemented by TSF. TSF ensures that no more than one ITfThreadMgr object exists in each thread. The ITfThreadMgr object manages documents, text services, and handles focus changes between documents.
The ITfDocumentMgr object represents a logical document. It isn't heavily used, though; its primary purpose is to be a container for edit contexts. There is usually only one context in the document manager, although sometimes there can be two.
The ITfContext object represents a view of the document that you can interact with; it manages selections, properties, & ranges.
Contexts
A context represents a view of the document that a text service can interact with.
Interface |
How to Obtain |
---|---|
Varies widely. Common examples: |
|
QI on ITfContext |
|
QI on ITfContext |
|
QI on ITfContext |
|
QI on ITfContext |
|
QI on ITfContext |
|
QI on ITfContext |
|
Passed to any of: ITfContextOwnerCompositionSink::OnStartComposition |
Once you have a context (and usually an edit cookie - most of the things you can do with contexts can only be done from within edit sessions), you can start to manipulate the document.
Ranges
These interfaces deal with pieces of text within a logical document.
Interface |
How to Obtain |
---|---|
Varies widely; common instances are: |
|
QI on ITfRange |
|