HRESULT CTextService::_ShowCandidateList(TfEditCookie ec, ITfContext *pContext, BOOL reg, BOOL comp)
{
	HRESULT hr = E_FAIL;

	try
	{
		if(_pCandidateList == NULL)
		{
			_pCandidateList = new CCandidateList(this);
		}

		ITfDocumentMgr *pDocumentMgr;
		if(pContext->GetDocumentMgr(&pDocumentMgr) == S_OK)
		{
			ITfRange *pRange;
			if(_IsComposing() && _pComposition->GetRange(&pRange) == S_OK)
			{
				hr = _pCandidateList->_StartCandidateList(_ClientId, pDocumentMgr, pContext, ec, pRange, reg, comp);
				SafeRelease(&pRange);
			}
			SafeRelease(&pDocumentMgr);
		}

		if(hr != S_OK)
		{
			_ResetStatus();
			_CancelComposition(ec, pContext);
		}
	}
	catch(...)
	{
	}

	return hr;
}
HRESULT CTextService::_HandleCharReturn(TfEditCookie ec, ITfContext *pContext, BOOL back)
{
	_EndCompletionList(ec, pContext);

	//terminate composition
	cursoridx = kana.size();
	_Update(ec, pContext, TRUE, back);
	_TerminateComposition(ec, pContext);
	_ResetStatus();

	return S_OK;
}
CTextService::CTextService()
{
	DllAddRef();

	_cRef = 1;

	_pThreadMgr = nullptr;
	_ClientId = TF_CLIENTID_NULL;
	_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
	_dwThreadFocusSinkCookie = TF_INVALID_COOKIE;
	_dwCompartmentEventSinkOpenCloseCookie = TF_INVALID_COOKIE;
	_dwCompartmentEventSinkInputmodeConversionCookie = TF_INVALID_COOKIE;
	_pTextEditSinkContext = nullptr;
	_dwTextEditSinkCookie = TF_INVALID_COOKIE;
	_pComposition = nullptr;
	_pLangBarItem = nullptr;
	_pLangBarItemI = nullptr;
	_pCandidateList = nullptr;
	_pInputModeWindow = nullptr;

	_gaDisplayAttributeInputMark = 0;
	_gaDisplayAttributeInputText = 0;
	_gaDisplayAttributeInputOkuri = 0;
	_gaDisplayAttributeConvMark = 0;
	_gaDisplayAttributeConvText = 0;
	_gaDisplayAttributeConvOkuri = 0;
	_gaDisplayAttributeConvAnnot = 0;

	_pD2DFactory = nullptr;
	_pD2DDCRT = nullptr;
	for(int i = 0; i < DISPLAY_LIST_COLOR_NUM; i++)
	{
		_pD2DBrush[i] = nullptr;
	}
	_drawtext_option = D2D1_DRAW_TEXT_OPTIONS_NONE;
	_pDWFactory = nullptr;

	_dwActiveFlags = 0;
	_ImmersiveMode = FALSE;
	_UILessMode = FALSE;
	_ShowInputMode = FALSE;

	hPipe = INVALID_HANDLE_VALUE;

	inputmode = im_direct;

	_ResetStatus();

	_CreateConfigPath();
	_CreateIpcName();
}
示例#4
0
CTextService::CTextService()
	: vihandler(this), c_otherimeoffwait(0)
{
	DllAddRef();

	_cRef = 1;

	_pThreadMgr = NULL;
	_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
	_dwCompartmentEventSinkOpenCloseCookie = TF_INVALID_COOKIE;
	_dwCompartmentEventSinkInputmodeConversionCookie = TF_INVALID_COOKIE;

	_ResetStatus();
}
示例#5
0
STDAPI CTextService::OnEndEdit(ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord)
{
	if(_IsComposing() && pic != nullptr)
	{
		ITfRange *pRange = nullptr;
		if(SUCCEEDED(_pComposition->GetRange(&pRange)) && (pRange != nullptr))
		{
			// clear when auto completion
			BOOL fEmpty = FALSE;
			if(SUCCEEDED(pRange->IsEmpty(ecReadOnly, &fEmpty)) && fEmpty)
			{
				if(!roman.empty() || !kana.empty())
				{
					_ResetStatus();
					_EndComposition(pic);
				}
			}

			// reposition candidate window
			if(_pCandidateList != nullptr)
			{
				ITfContextView *pContextView = nullptr;
				if(SUCCEEDED(pic->GetActiveView(&pContextView)) && (pContextView != nullptr))
				{
					RECT rc = {};
					BOOL fClipped;
					if(SUCCEEDED(pContextView->GetTextExt(ecReadOnly, pRange, &rc, &fClipped)))
					{
						_pCandidateList->_Move(&rc, ecReadOnly, pic);
					}

					SafeRelease(&pContextView);
				}
			}

			SafeRelease(&pRange);
		}
	}

	return S_OK;
}
HRESULT CTextService::_HandleCharShift(TfEditCookie ec, ITfContext *pContext)
{
	if(showentry || (!inputkey && !kana.empty() && roman.empty()))
	{
		_EndCompletionList(ec, pContext);

		//leave composition
		cursoridx = kana.size();
		_Update(ec, pContext, TRUE);
		if(pContext != NULL)
		{
			ITfRange *pRange;
			if(_IsComposing() && _pComposition->GetRange(&pRange) == S_OK)
			{
				pRange->Collapse(ec, TF_ANCHOR_END);
				_pComposition->ShiftStart(ec, pRange);
				SafeRelease(&pRange);
			}
		}
		_ResetStatus();
	}

	return S_OK;
}