private static IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam) { if (Imm32Manager.ImmEnabled) { if (Imm32Manager.Current.ProcessMessage(hWnd, msg, ref wParam, ref lParam)) { return(IntPtr.Zero); } } switch (msg) { case NativeMethods.WM_DESTROY: TextServicesContext.Current.Uninitialize(true); break; case NativeMethods.WM_CHAR: { if (InputMethod.Enabled) { InputMethod.OnTextInput(null, (char)wParam.ToInt32()); } break; } } return(NativeMethods.CallWindowProc(_prevWndProc, hWnd, msg, wParam, lParam)); }
public void OnEndEdit(ITfContext context, int ecReadOnly, ITfEditRecord editRecord) { ITfProperty property; context.GetProperty(GUID_PROP_COMPOSING, out property); ITfRangeACP rangeACP; TextServicesContext.Current.ContextOwnerServices.CreateRange(_compositionStart, _compositionStart + _compositionLength, out rangeACP); Variant val; property.GetValue(ecReadOnly, rangeACP, out val); property.Dispose(); rangeACP.Dispose(); if (val.Value == null || (int)val.Value == 0) { if (_commitLength == 0 || _inputBuffer.Count == 0) { return; } //Debug.WriteLine("Composition result: {0}", new object[] { new string(_inputBuffer.GetRange(_commitStart, _commitLength).ToArray()) }); _commited = true; for (int i = _commitStart; i < _commitLength; i++) { InputMethod.OnTextInput(this, _inputBuffer[i]); } } if (_commited) { return; } if (_inputBuffer.Count == 0 && _compositionLength > 0) // Composition just ended { return; } _currentComposition.Clear(); for (int i = _compositionStart; i < _compositionLength; i++) { _currentComposition.Add(_inputBuffer[i]); } InputMethod.OnTextComposition(this, new IMEString(_currentComposition), _acpEnd); //var compStr = new string(_currentComposition.ToArray()); //compStr = compStr.Insert(_acpEnd, "|"); //Debug.WriteLine("Composition string: {0}, cursor pos: {1}", compStr, _acpEnd); }