Skip to content

Commit 1f55e0a

Browse files
committed
docs(windows): remove dulpicate descriptions corrrect
correct the sequence diagram.
1 parent 842d4bc commit 1f55e0a

File tree

3 files changed

+12
-39
lines changed

3 files changed

+12
-39
lines changed

knowledge-base/assets/kb0118/windows-compliant-app-sequence.mmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ sequenceDiagram
1414
Keyman->>TSF: ITfContext.GetStatus()
1515
Keyman->>TSF: ITfContext.GetSelection()
1616
TSF->>App: Request current selection
17-
App-->>TSF: Return caret/selection
17+
App-->>TSF: Return selection
1818
TSF-->>Keyman: Return GetSelection
1919

2020

21-
Note right of Keyman: Keyman applies keyboard rules and computes output
21+
Note right of Keyman: Keyman applies keyboard rules and inserts or modifies the text in the selection
2222

23-
Keyman->>TSF: ITfContext.SetText()
24-
TSF->>App: Delete or replace text in range
23+
Keyman->>TSF: ITfContext.SetSelection()
24+
TSF->>App: Modified selection is applied to the application
2525

2626
App-->>User: Display “∆” in document
7.65 KB
Loading

knowledge-base/kb0118.md

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -225,57 +225,30 @@ on the Keyman system service which emits a fake key event. That way it is possib
225225

226226
On Windows, Keyman integrates with applications primarily through the Text Services Framework (TSF). Keyman implements a Text Input Processor (TIP) that communicates with the TSF manager and the target application.
227227

228-
When the user types, the TSF manager passes key events and text context to Keyman through the `ITfContext` interface, which provides access to the current edit context within the application. Keyman relies on this interface to retrieve context, determine the current selection, and insert or replace text.
228+
When the user types, the TSF manager passes key events and text context to Keyman through the `ITfContext` interface, which provides access to the current edit context within the application. Keyman relies on this interface to retrieve context, as a selection object, and insert or replace text.
229229
For `ITfContext` details see [Learn Microsoft](https://learn.microsoft.com/en-us/windows/win32/api/msctf/nn-msctf-itfcontext).
230230

231231
Relevant for Keyman are the following API functions:
232232

233-
**`GetStatus()`** — Retrieves the current status of the text context. Keyman uses this to check for the TF_SS_TRANSITORY flag, which indicates temporary or non-standard contexts that may not behave consistently.
233+
**`GetStatus()`** — Retrieves the current status of the text context. Keyman uses this to check for the `TF_SS_TRANSITORY` flag, which indicates temporary or non-standard contexts that may not behave consistently.
234234

235-
**`GetSelection()`**Retrieves the current text selection or caret position.
235+
**`GetSelection()`**Used by Keyman for Windows to get the context next to the cursor.
236236

237-
**`SetSelection()`** — Updates the current selection or caret position after Keyman inserts or replaces text.
237+
**`SetSelection()`** — Updates the current selection or caret position after Keyman inserts or replaces text in the selection retrieved with `GetSelection()`.
238238

239-
**`GetText()`** — Retrieves text from a specified range around the caret, giving Keyman the context needed to process complex keyboard rules.
240239

241-
**`SetText()`** — Replaces text in a specific range within the context.
240+
Keyman determines whether an application is compliant by inspecting the status returned by `ITfContext::GetStatus()`. Compliant applications provide a stable, non-transitory context and correctly implement the TSF APIs needed to retrieve context and modify text.
242241

243242
Applications can restrict how much surrounding text can be read; Keyman limits its requests to 64 characters of context.
244243

245244
<img src="./assets/kb0118/windows-compliant-app-sequence.png" width="75%" alt="compliant sequence on Windows"/>
246245

247246
The sequence diagram is for a rule that replaces "D" with "∆".
248247

249-
Keyman determines whether an application is compliant by inspecting the status returned by `ITfContext::GetStatus()`.
250-
251-
- **Compliant applications** provide a stable, non-transitory context and correctly implement the TSF APIs needed to retrieve context and modify text.
252-
- **Non-compliant applications** may expose only a transitory context or fail to return reliable selection or text data.
253-
254-
If the `TF_SS_TRANSITORY` flag is present or context cannot be read as expected, Keyman treats the application as non-compliant and falls back to legacy behavior, maintaining its own internal context buffer and simulating text operations where possible.
248+
Note: For both compliant and non-compliant apps. When there is a highlighted section of text if backspace is the determined action from processing the keystroke on Windows Keyman will emit the key (backspace), allowing the application to handle clearing selected text in the correct manner.
255249

256250
### Non-compliance on Windows
257251

258-
When a non-compliant application is detected, Keyman falls back to **legacy behavior**.
259-
260-
With non-compliant applications, Keyman maintains an **internal context buffer** that records the characters it has recently output. This buffered context is used to apply keyboard rules that depend on previously typed characters.
261-
262-
263-
### Limitations of legacy behavior
264-
265-
The internal context buffer remains valid only while Keyman has exclusive knowledge of text changes. The buffer becomes invalid if the user performs actions such as:
266-
267-
- Moving the caret using the mouse or keyboard
268-
- Changing the selection
269-
- Using shortcut keys or menu commands to edit text
270-
- Switching to another application or document
271-
272-
When such an action occurs, Keyman discards its internal context and assumes an empty context. If this happens in the middle of typing a multi-character sequence, the sequence may not be recognized correctly and may need to be retyped.
273-
274-
### Simulating text operations
275-
276-
Because TSF APIs cannot be relied upon in non-compliant applications, Keyman may simulate text operations by generating keyboard events:
277-
278-
- **Backspace key events** are used to delete previously typed characters
279-
- **Synthetic key events** may be used to insert characters
252+
If the `TF_SS_TRANSITORY` flag is present or context cannot be read as expected, Keyman treats the application as **non-compliant** and falls back to legacy behavior, maintaining its own internal context buffer and simulating text operations where possible.
280253

281-
These simulated events are asynchronous and are processed by the application in sequence. As a result, text deletion and insertion may not always behave exactly as intended, particularly when dealing with composed characters or surrogate pairs.
254+
The limitations are as stated at the start of this knowledge base article [Working around non-compliant behavior](##-working-around-non-compliant-behavior). Further reading on sending a backspace to an application to perform a delete can be found on the Keyman wiki [here](https://github.com/keymanapp/keyman/wiki/Backspace-and-cluster-deletion).

0 commit comments

Comments
 (0)