Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 32 additions & 37 deletions windows/src/support/tsf-tip-standalone-test/keyhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading