From 300608188adf42b6bcec3832f35bbf20dba2d0eb Mon Sep 17 00:00:00 2001
From: rc-swag <58423624+rc-swag@users.noreply.github.com>
Date: Wed, 8 Apr 2026 15:10:51 +1000
Subject: [PATCH] fix(windows): deletion test using tsf interface
---
.../tsf-tip-standalone-test/keyhandler.cpp | 69 ++--
.../textservice.step06.3.sln | 19 +-
.../textservice.step06.3.vcproj | 315 ------------------
.../textservice.step06.3.vcxproj | 76 +++++
4 files changed, 123 insertions(+), 356 deletions(-)
delete mode 100644 windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcproj
diff --git a/windows/src/support/tsf-tip-standalone-test/keyhandler.cpp b/windows/src/support/tsf-tip-standalone-test/keyhandler.cpp
index 539468c95b9..fad97d3b232 100644
--- a/windows/src/support/tsf-tip-standalone-test/keyhandler.cpp
+++ b/windows/src/support/tsf-tip-standalone-test/keyhandler.cpp
@@ -112,50 +112,45 @@ HRESULT CTextService::_HandleCharacterKey(TfEditCookie ec, ITfContext *pContext,
ULONG cFetched;
WCHAR ch;
BOOL fCovered;
-
- // Start the new compositon if there is no composition.
-// if (!_IsComposing())
-// _StartComposition(pContext);
-
- //
- // Assign VK_ value to the char. So the inserted the character is always
- // uppercase.
- //
- ch = (WCHAR)wParam + 1;
+ LONG n, outn, cch;
// first, test where a keystroke would go in the document if we did an insert
if (pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK || cFetched != 1)
return S_FALSE;
- // is the insertion point covered by a composition?
-/* if (_pComposition->GetRange(&pRangeComposition) == S_OK)
- {
- fCovered = IsRangeCovered(ec, tfSelection.range, pRangeComposition);
-
- pRangeComposition->Release();
-
- if (!fCovered)
- {
- goto Exit;
- }
+ // USE wparam == VK_T to do the test, removing last character next to
+ // the cursor. First by moving the start anchor one character to the left,
+ // Then Settext replaces the entire range with 0 characters (empty text),
+ // which deletes whatever is in that range.
+ //
+ // For all else Assign VK_ value to the char. So the inserted the character is always
+ // uppercase and display the next VK_ key to prove keyboard is active.
+ if (wParam != 0x54) { // VK_T
+ ch = (WCHAR)wParam + 1;
+ cch = 1;
+ } else {
+ n = -1;
+ ch = L'\0';
+ cch = 0;
+ if (tfSelection.range->ShiftStart(ec, n, &outn, NULL) != S_OK) {
+ tfSelection.range->Release();
+ return S_FALSE;
+ }
}
- */
+
// insert the text
// we use SetText here instead of InsertTextAtSelection because we've already started a composition
// we don't want to the app to adjust the insertion point inside our composition
- if (tfSelection.range->SetText(ec, 0, &ch, 1) != S_OK)
- goto Exit;
+ if (tfSelection.range->SetText(ec, 0, &ch, cch) != S_OK) {
+ tfSelection.range->Release();
+ return S_FALSE;
+ }
// update the selection, we'll make it an insertion point just past
// the inserted text.
tfSelection.range->Collapse(ec, TF_ANCHOR_END);
pContext->SetSelection(ec, 1, &tfSelection);
- //
- // set the display attribute to the composition range.
- //
- //_SetCompositionDisplayAttributes(ec, pContext, _gaDisplayAttributeInput);
-
Exit:
tfSelection.range->Release();
return S_OK;
@@ -185,27 +180,27 @@ HRESULT CTextService::_HandleSpaceKey(TfEditCookie ec, ITfContext *pContext)
//
// set the display attribute to the composition range.
//
- // The real text service may have linguistic logic here and set
- // the specific range to apply the display attribute rather than
+ // The real text service may have linguistic logic here and set
+ // the specific range to apply the display attribute rather than
// applying the display attribute to the entire composition range.
//
_SetCompositionDisplayAttributes(ec, pContext, _gaDisplayAttributeConverted);
- //
+ //
// create an instance of the candidate list class.
- //
+ //
if (_pCandidateList == NULL)
_pCandidateList = new CCandidateList(this);
- //
+ //
// we don't cache the document manager object. So get it from pContext.
- //
+ //
ITfDocumentMgr *pDocumentMgr;
if (pContext->GetDocumentMgr(&pDocumentMgr) == S_OK)
{
- //
+ //
// get the composition range.
- //
+ //
ITfRange *pRange;
if (_pComposition->GetRange(&pRange) == S_OK)
{
diff --git a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.sln b/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.sln
index 0a72d1e9aa8..39c97bb2bf0 100644
--- a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.sln
+++ b/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.sln
@@ -1,20 +1,31 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.37027.9 d17.14
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextService-Step06-3", "textservice.step06.3.vcxproj", "{ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|Win32.ActiveCfg = Debug|Win32
- {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|Win32.Build.0 = Debug|Win32
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|Win32.ActiveCfg = Debug|x64
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|Win32.Build.0 = Debug|x64
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|x64.ActiveCfg = Debug|x64
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Debug|x64.Build.0 = Debug|x64
{ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Release|Win32.ActiveCfg = Release|Win32
{ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Release|Win32.Build.0 = Release|Win32
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Release|x64.ActiveCfg = Release|x64
+ {ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {6FA8F2EF-C8CB-4FB4-830B-8F0A9B9D6414}
+ EndGlobalSection
EndGlobal
diff --git a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcproj b/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcproj
deleted file mode 100644
index 132c20df5d2..00000000000
--- a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcproj
+++ /dev/null
@@ -1,315 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcxproj b/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcxproj
index e0bd37adb99..485411db677 100644
--- a/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcxproj
+++ b/windows/src/support/tsf-tip-standalone-test/textservice.step06.3.vcxproj
@@ -5,26 +5,48 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
TextService-Step06-3
{ED0CC610-5F1E-43C1-8E31-122EE3EE70E9}
TextServiceStep063
Win32Proj
+ 10.0
DynamicLibrary
Unicode
true
+ v143
+
+
+ DynamicLibrary
+ Unicode
+ true
+ v143
DynamicLibrary
Unicode
+ v143
+
+
+ DynamicLibrary
+ Unicode
+ v143
@@ -32,24 +54,44 @@
+
+
+
+
+
+
<_ProjectFileVersion>10.0.40219.1
$(SolutionDir)$(Configuration)\
$(Configuration)\
true
+ true
$(SolutionDir)$(Configuration)\
$(Configuration)\
false
+ false
AllRules.ruleset
+ AllRules.ruleset
+
+
AllRules.ruleset
+ AllRules.ruleset
+
+
+
+
+ $(ProjectName)_x64
+
+
+ $(ProjectName)_x64
@@ -70,6 +112,23 @@
MachineX86
+
+
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ EnableFastChecks
+ MultiThreaded
+
+
+ Level3
+ ProgramDatabase
+
+
+ TextService.def
+ true
+ Windows
+
+
WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
@@ -88,6 +147,23 @@
MachineX86
+
+
+ WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ MultiThreaded
+
+
+ Level3
+ ProgramDatabase
+
+
+ TextService.def
+ true
+ Windows
+ true
+ true
+
+